Skip to content

Commit

Permalink
Capitalize culture in the dynmap info window and other places a bit more
Browse files Browse the repository at this point in the history
thoroughly.
  - Closes #29.
  • Loading branch information
LlmDl committed Nov 5, 2021
1 parent 9c77e57 commit c1b082c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.util.Version;
import com.palmergames.util.StringMgmt;
import com.gmail.goosius.townycultures.listeners.NationEventListener;
import com.gmail.goosius.townycultures.listeners.TownEventListener;

Expand Down Expand Up @@ -137,7 +138,7 @@ public static String getCulture(Resident resident) {
}

public static String getCulture(Town town) {
return TownMetaDataController.getTownCulture(town);
return StringMgmt.capitalize(TownMetaDataController.getTownCulture(town));
}

public static void info(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gmail.goosius.townycultures.command;

import com.gmail.goosius.townycultures.Messaging;
import com.gmail.goosius.townycultures.TownyCultures;
import com.gmail.goosius.townycultures.metadata.TownMetaDataController;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.TownyUniverse;
Expand Down Expand Up @@ -46,13 +47,13 @@ private void parseCultureCommunicationCommand(Player player, String[] args) {
String townCulture = "";
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
if (resident != null && resident.hasTown() && TownMetaDataController.hasTownCulture(TownyAPI.getInstance().getResidentTownOrNull(resident))) {
townCulture = TownMetaDataController.getTownCulture(TownyAPI.getInstance().getResidentTownOrNull(resident));
townCulture = TownyCultures.getCulture(TownyAPI.getInstance().getResidentTownOrNull(resident));
} else {
Messaging.sendErrorMsg(player, Translation.of("msg_err_command_disable"));
return;
}

String formattedMessage = Translation.of("culture_chat_message", StringMgmt.capitalize(townCulture), resident.getName(), StringMgmt.join(args, " "));
String formattedMessage = Translation.of("culture_chat_message", townCulture, resident.getName(), StringMgmt.join(args, " "));

Resident otherResident;
for(Player otherPlayer: BukkitTools.getOnlinePlayers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import java.util.Arrays;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import com.gmail.goosius.townycultures.TownyCultures;
import com.gmail.goosius.townycultures.metadata.TownMetaDataController;
import com.gmail.goosius.townycultures.settings.TownyCulturesSettings;
import com.gmail.goosius.townycultures.settings.Translation;
import com.palmergames.bukkit.towny.event.statusscreen.TownStatusScreenEvent;
import com.palmergames.util.StringMgmt;

/**
*
Expand All @@ -20,7 +21,7 @@ public class TownEventListener implements Listener {
public void onTownStatusScreen(TownStatusScreenEvent event) {
if (TownyCulturesSettings.isTownyCulturesEnabled())
if (TownMetaDataController.hasTownCulture(event.getTown()))
event.addLines(Arrays.asList(Translation.of("status_town_culture", StringMgmt.capitalize(TownMetaDataController.getTownCulture(event.getTown())))));
event.addLines(Arrays.asList(Translation.of("status_town_culture", TownyCultures.getCulture(event.getTown()))));
else
event.addLines(Arrays.asList(Translation.of("status_town_culture", "/culture set [culture]")));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gmail.goosius.townycultures.listeners;

import com.gmail.goosius.townycultures.TownyCultures;
import com.gmail.goosius.townycultures.metadata.TownMetaDataController;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -18,7 +19,7 @@ public void on(BuildTownMarkerDescriptionEvent event) {
if (event.getDescription().contains("%culture%")) {
String finalDescription;
if (TownMetaDataController.hasTownCulture(event.getTown())) {
finalDescription = event.getDescription().replace("%culture%", TownMetaDataController.getTownCulture(event.getTown()));
finalDescription = event.getDescription().replace("%culture%", TownyCultures.getCulture(event.getTown()));
} else {
finalDescription = event.getDescription().replace("%culture%", "");
}
Expand Down

0 comments on commit c1b082c

Please sign in to comment.