Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use world key instead of world name #7388

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,12 @@ public enum ConfigNodes {
"",
"# If enabled, players will be prompted to open a url when clicking on coordinates in towny status screens."
),
PLUGIN_WEB_MAP_WORLD_NAME_USES_KEY(
"plugin.interfacing.web_map.world_name_uses_world_key",
"false",
"",
"# If enabled, the world name placeholder will be replaced with the world key instead of the Bukkit name."
),

PLUGIN_WEB_MAP_URL(
"plugin.interfacing.web_map.url",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -1046,12 +1047,14 @@ public static String getTime() {

private static String formatWebUrl(SpawnLocation spawnLocation) {
String webUrl = "";
if (TownySettings.isUsingWebMapStatusScreens() && spawnLocation.hasSpawn() && !TownySettings.getWebMapUrl().isEmpty())
if (TownySettings.isUsingWebMapStatusScreens() && spawnLocation.hasSpawn() && !TownySettings.getWebMapUrl().isEmpty()) {
World world = spawnLocation.getSpawnOrNull().getWorld();
String worldName = TownySettings.isUsingWorldKeyForWorldName() ? world.getKey().toString() : world.getName();
gecko10000 marked this conversation as resolved.
Show resolved Hide resolved
webUrl = TownySettings.getWebMapUrl()
.replaceAll("\\{world}", spawnLocation.getSpawnOrNull().getWorld().getName())
.replaceAll("\\{world}", worldName)
.replaceAll("\\{x}", "" + spawnLocation.getSpawnOrNull().getBlockX())
.replaceAll("\\{z}", "" + spawnLocation.getSpawnOrNull().getBlockZ());

}
return webUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3608,6 +3608,10 @@ public static boolean isUsingWebMapStatusScreens() {
return getBoolean(ConfigNodes.PLUGIN_WEB_MAP_USING_STATUSSCREEN);
}

public static boolean isUsingWorldKeyForWorldName() {
return getBoolean(ConfigNodes.PLUGIN_WEB_MAP_WORLD_NAME_USES_KEY);
}

public static String getWebMapUrl() {
return getString(ConfigNodes.PLUGIN_WEB_MAP_URL);
}
Expand Down Expand Up @@ -3781,4 +3785,3 @@ public static double maxBuyTownPrice() {
return getDouble(ConfigNodes.GTOWN_SETTINGS_MAX_BUYTOWN_PRICE);
}
}

Loading