Skip to content

Commit

Permalink
- New Config Option:
Browse files Browse the repository at this point in the history
global_town_settings.display_xyz_instead_of_towny_coords
    - default: false
    - If set to true, the /town screen will display the xyz coordinate
for a town's spawn rather than the homeblock's Towny coords.
    - Closes ticket #3347
  • Loading branch information
LlmDl committed Oct 25, 2019
1 parent 51e05cb commit 709b3e2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
6 changes: 5 additions & 1 deletion resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3675,4 +3675,8 @@ v0.92.0.11:
- When the days amount is not used the player will be jailed indefinetly as usual.
- Remaining days are shown on a player's /res screen.
- Closes ticket #3232
- Make plot set only show cost when the cost is more than 0.
- Make plot set only show cost when the cost is more than 0.
- New Config Option: global_town_settings.display_xyz_instead_of_towny_coords
- default: false
- If set to true, the /town screen will display the xyz coordinate for a town's spawn rather than the homeblock's Towny coords.
- Closes ticket #3347
8 changes: 7 additions & 1 deletion src/com/palmergames/bukkit/config/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,13 @@ public enum ConfigNodes {
"1000000.0",
"# Maximum amount that a town can set their plot, embassy, shop, etc plots' prices to.",
"# Setting this higher can be dangerous if you use Towny in a mysql database. Large numbers can become shortened to scientific notation. "
),
),
GTOWN_SETTINGS_DISPLAY_XYZ_INSTEAD_OF_TOWNY_COORDS(
"global_town_settings.display_xyz_instead_of_towny_coords",
"false",
"# If set to true, the /town screen will display the xyz coordinate for a town's spawn rather than the homeblock's Towny coords."
),

GNATION_SETTINGS(
"global_nation_settings",
"",
Expand Down
4 changes: 3 additions & 1 deletion src/com/palmergames/bukkit/towny/TownyFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ public static List<String> getStatus(Town town) {
(TownySettings.isSellingBonusBlocks() ? String.format(TownySettings.getLangString("status_town_size_part_2"), town.getPurchasedBlocks(), TownySettings.getMaxPurchedBlocks()) : "") +
(town.getBonusBlocks() > 0 ? String.format(TownySettings.getLangString("status_town_size_part_3"), town.getBonusBlocks()) : "") +
(TownySettings.getNationBonusBlocks(town) > 0 ? String.format(TownySettings.getLangString("status_town_size_part_4"), TownySettings.getNationBonusBlocks(town)) : "") +
(town.isPublic() ? TownySettings.getLangString("status_town_size_part_5") + (town.hasHomeBlock() ? town.getHomeBlock().getCoord().toString() : TownySettings.getLangString("status_no_town")) + "]" : "")
(town.isPublic() ? TownySettings.getLangString("status_town_size_part_5") +
(TownySettings.getTownDisplaysXYZ() ? (town.hasSpawn() ? BukkitTools.convertCoordtoXYZ(town.getSpawn()) : TownySettings.getLangString("status_no_town")) + "]"
: (town.hasHomeBlock() ? town.getHomeBlock().getCoord().toString() : TownySettings.getLangString("status_no_town")) + "]") : "")
);
} catch (TownyException e) {
}
Expand Down
4 changes: 4 additions & 0 deletions src/com/palmergames/bukkit/towny/TownySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2820,5 +2820,9 @@ public static int getMaxDistanceFromTownSpawnForInvite() {
return getInt(ConfigNodes.INVITE_SYSTEM_MAX_DISTANCE_FROM_TOWN_SPAWN);
}

public static boolean getTownDisplaysXYZ() {
return getBoolean(ConfigNodes.GTOWN_SETTINGS_DISPLAY_XYZ_INSTEAD_OF_TOWNY_COORDS);
}

}

7 changes: 7 additions & 0 deletions src/com/palmergames/bukkit/util/BukkitTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.themoep.idconverter.IdMappings;
import net.citizensnpcs.api.CitizensAPI;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
Expand Down Expand Up @@ -213,4 +214,10 @@ public static OfflinePlayer getOfflinePlayerForVault(String name) {

return Bukkit.getOfflinePlayer(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)));
}

public static String convertCoordtoXYZ(Location loc) {
String string = loc.getWorld().getName() + " " + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ();

return string;
}
}

0 comments on commit 709b3e2

Please sign in to comment.