Compare commits

...

10 Commits

Author SHA1 Message Date
b5f1313c58 Merge pull request 'Update dependency org.codehaus.mojo:buildnumber-maven-plugin to v3' (#4) from renovate/org.codehaus.mojo-buildnumber-maven-plugin-3.x into main
Some checks failed
continuous-integration/drone Build was killed
Reviewed-on: #4
2025-03-23 12:55:10 +01:00
3432f0cdea Update dependency org.codehaus.mojo:buildnumber-maven-plugin to v3 2025-03-23 11:28:19 +00:00
95d8cab7c9 Merge pull request 'Configure Renovate' (#2) from renovate/configure into main
Reviewed-on: #2
2025-03-23 12:04:57 +01:00
43e84de8ab Add renovate.json 2025-03-22 23:11:48 +00:00
21f613bbe7 Improve code quality
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-11 21:05:54 +01:00
85cecca263 Bump build number
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-11 20:58:11 +01:00
122b4b064c Rename config entries class
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-11 20:57:29 +01:00
7f792b5ca8 Rename messages class
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-11 20:57:11 +01:00
0839161bb2 Update lang string
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-11 20:56:19 +01:00
48b2043dda Make min/max versions Strings 2023-02-11 20:55:53 +01:00
26 changed files with 119 additions and 124 deletions

View File

@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Tue May 31 20:08:48 CEST 2022 #Sat Feb 11 20:48:42 CET 2023
buildNumber=186 buildNumber=198

View File

@@ -27,7 +27,7 @@
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId> <artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version> <version>3.2.1</version>
<executions> <executions>
<execution> <execution>
<id>buildnumber</id> <id>buildnumber</id>

3
renovate.json Normal file
View File

@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@@ -7,7 +7,7 @@ import wtf.beatrice.hubthat.listeners.PlayerChatListener;
import wtf.beatrice.hubthat.listeners.PlayerJoinListener; import wtf.beatrice.hubthat.listeners.PlayerJoinListener;
import wtf.beatrice.hubthat.listeners.PlayerMoveListener; import wtf.beatrice.hubthat.listeners.PlayerMoveListener;
import wtf.beatrice.hubthat.listeners.PlayerRespawnListener; import wtf.beatrice.hubthat.listeners.PlayerRespawnListener;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.Debugger; import wtf.beatrice.hubthat.utils.Debugger;
import wtf.beatrice.hubthat.utils.TeleportUtils; import wtf.beatrice.hubthat.utils.TeleportUtils;
import wtf.beatrice.hubthat.utils.files.FileUtils; import wtf.beatrice.hubthat.utils.files.FileUtils;
@@ -54,7 +54,10 @@ public class HubThat extends JavaPlugin
// Initialize command classes. // Initialize command classes.
debugger.sendDebugMessage(Level.INFO, "Loading classes..."); debugger.sendDebugMessage(Level.INFO, "Loading classes...");
FileUtils fileUtilsInstance = new FileUtils(this); FileUtils fileUtilsInstance = new FileUtils(this);
// todo: ^ this is bad, utils should not be instantiated.
HubThatCommand hubThatCommandInstance = new HubThatCommand(this); HubThatCommand hubThatCommandInstance = new HubThatCommand(this);
HubCommand hubCommandInstance = new HubCommand(this); HubCommand hubCommandInstance = new HubCommand(this);
SpawnCommand spawnCommandInstance = new SpawnCommand(this); SpawnCommand spawnCommandInstance = new SpawnCommand(this);
@@ -141,19 +144,19 @@ public class HubThat extends JavaPlugin
Metrics metrics = new Metrics(this); Metrics metrics = new Metrics(this);
YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml; YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml;
metrics.addCustomChart(new Metrics.SimplePie("respawn-handler", () -> config.getString(ConfigEntries.TELEPORTATION_RESPAWN_HANDLER.path))); metrics.addCustomChart(new Metrics.SimplePie("respawn-handler", () -> config.getString(ConfigEntry.TELEPORTATION_RESPAWN_HANDLER.path)));
metrics.addCustomChart(new Metrics.SimplePie("world-related-chat", () -> config.getString(ConfigEntries.WORLD_RELATED_CHAT.path))); metrics.addCustomChart(new Metrics.SimplePie("world-related-chat", () -> config.getString(ConfigEntry.WORLD_RELATED_CHAT.path)));
metrics.addCustomChart(new Metrics.SimplePie("update-notify", () -> config.getString(ConfigEntries.UPDATE_CHECKER_ENABLED.path))); metrics.addCustomChart(new Metrics.SimplePie("update-notify", () -> config.getString(ConfigEntry.UPDATE_CHECKER_ENABLED.path)));
metrics.addCustomChart(new Metrics.SimplePie("set-gamemode-on-join", () -> config.getString(ConfigEntries.GAMEMODE_SET_ON_JOIN.path))); metrics.addCustomChart(new Metrics.SimplePie("set-gamemode-on-join", () -> config.getString(ConfigEntry.GAMEMODE_SET_ON_JOIN.path)));
metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-join", () -> config.getString(ConfigEntries.TELEPORTATION_TP_HUB_ON_JOIN.path))); metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-join", () -> config.getString(ConfigEntry.TELEPORTATION_TP_HUB_ON_JOIN.path)));
metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-respawn", () -> config.getString(ConfigEntries.TELEPORTATION_TP_HUB_ON_RESPAWN.path))); metrics.addCustomChart(new Metrics.SimplePie("tp-hub-on-respawn", () -> config.getString(ConfigEntry.TELEPORTATION_TP_HUB_ON_RESPAWN.path)));
metrics.addCustomChart(new Metrics.SimplePie("multiverse-bypass", () -> config.getString(ConfigEntries.MULTIVERSE_BYPASS.path))); metrics.addCustomChart(new Metrics.SimplePie("multiverse-bypass", () -> config.getString(ConfigEntry.MULTIVERSE_BYPASS.path)));
metrics.addCustomChart(new Metrics.SimplePie("send-tp-message-on-join", () -> config.getString(ConfigEntries.TELEPORTATION_TP_MESSAGE_ON_JOIN.path))); metrics.addCustomChart(new Metrics.SimplePie("send-tp-message-on-join", () -> config.getString(ConfigEntry.TELEPORTATION_TP_MESSAGE_ON_JOIN.path)));
metrics.addCustomChart(new Metrics.SimplePie("fix-invisible-after-tp", () -> config.getString(ConfigEntries.INVISIBILITY_FIX.path))); metrics.addCustomChart(new Metrics.SimplePie("fix-invisible-after-tp", () -> config.getString(ConfigEntry.INVISIBILITY_FIX.path)));
if (config.getBoolean(ConfigEntries.GAMEMODE_SET_ON_JOIN.path)) if (config.getBoolean(ConfigEntry.GAMEMODE_SET_ON_JOIN.path))
{ {
metrics.addCustomChart(new Metrics.SimplePie("join-gamemode", () -> config.getString(ConfigEntries.GAMEMODE.path))); metrics.addCustomChart(new Metrics.SimplePie("join-gamemode", () -> config.getString(ConfigEntry.GAMEMODE.path)));
} }
} }

View File

@@ -41,7 +41,7 @@ public class HubCommand implements CommandExecutor
Player teleportingPlayer = plugin.getServer().getPlayer(teleportingPlayerName); Player teleportingPlayer = plugin.getServer().getPlayer(teleportingPlayerName);
if(teleportingPlayer == null) if(teleportingPlayer == null)
{ {
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_PLAYER_OFFLINE, true).replace("%player%", teleportingPlayerName); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_PLAYER_OFFLINE, true).replace("%player%", teleportingPlayerName);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return true; return true;
} }
@@ -54,7 +54,7 @@ public class HubCommand implements CommandExecutor
else else
{ {
// Warn the player he doesn't have permissions to teleport others to the hub. // Warn the player he doesn't have permissions to teleport others to the hub.
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.HUB_TELEPORT_OTHERS.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.HUB_TELEPORT_OTHERS.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return true; return true;
} }
@@ -65,7 +65,7 @@ public class HubCommand implements CommandExecutor
boolean senderIsConsole = !(commandSender instanceof Player); boolean senderIsConsole = !(commandSender instanceof Player);
if(senderIsConsole) if(senderIsConsole)
{ {
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED);
return true; return true;
} }
@@ -90,11 +90,11 @@ public class HubCommand implements CommandExecutor
// Put the player in the ArrayList of players waiting to be teleported. // Put the player in the ArrayList of players waiting to be teleported.
PluginCache.teleporting.add(username); PluginCache.teleporting.add(username);
// Load the teleportation delay. // Load the teleportation delay.
int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntries.HUB_DELAY.path); int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntry.HUB_DELAY.path);
// Warn the player about the delay. // Warn the player about the delay.
String delayMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_TELEPORT_DELAY, false); String delayMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_TELEPORT_DELAY, false);
delayMessage = delayMessage.replace("%delay%", delay + ""); delayMessage = delayMessage.replace("%delay%", delay + "");
MessageUtils.sendColorizedMessage(commandSender, delayMessage); MessageUtils.sendColorizedMessage(commandSender, delayMessage);
@@ -118,7 +118,7 @@ public class HubCommand implements CommandExecutor
else else
{ {
// Send a message to the player stating it, and do nothing. // Send a message to the player stating it, and do nothing.
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_ALREADY_TELEPORTING); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_ALREADY_TELEPORTING);
return true; return true;
} }
} }
@@ -126,7 +126,7 @@ public class HubCommand implements CommandExecutor
else else
{ {
// Warn the player he doesn't have permissions to go to the hub. // Warn the player he doesn't have permissions to go to the hub.
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.HUB_TELEPORT.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.HUB_TELEPORT.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return true; return true;
} }

View File

@@ -29,7 +29,7 @@ public class SetHubCommand implements CommandExecutor
boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender); boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender);
if(senderIsConsole) if(senderIsConsole)
{ {
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED);
return true; return true;
} }
@@ -61,7 +61,7 @@ public class SetHubCommand implements CommandExecutor
FileUtils.saveExistingYaml(FileUtils.FileType.HUB_YAML); FileUtils.saveExistingYaml(FileUtils.FileType.HUB_YAML);
// Tell the player he set the hub successfully. // Tell the player he set the hub successfully.
String hubSetMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_HUB_SET, false); String hubSetMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_HUB_SET, false);
hubSetMessage = hubSetMessage.replace("%w%", worldName); hubSetMessage = hubSetMessage.replace("%w%", worldName);
hubSetMessage = hubSetMessage.replace("%x%", (int)x + ""); hubSetMessage = hubSetMessage.replace("%x%", (int)x + "");
hubSetMessage = hubSetMessage.replace("%y%", (int)y + ""); hubSetMessage = hubSetMessage.replace("%y%", (int)y + "");
@@ -70,7 +70,7 @@ public class SetHubCommand implements CommandExecutor
} }
else else
{ {
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.HUB_SET.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.HUB_SET.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
} }
return true; return true;

View File

@@ -41,7 +41,7 @@ public class SetSpawnCommand implements CommandExecutor
boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender); boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender);
if(senderIsConsole) if(senderIsConsole)
{ {
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED);
return true; return true;
} }
@@ -83,7 +83,7 @@ public class SetSpawnCommand implements CommandExecutor
{ {
// Warn the player and stop. // Warn the player and stop.
// Tell the player that the world does not exist. // Tell the player that the world does not exist.
String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false); String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_WORLD_NOT_EXISTING, false);
errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldYouAreSettingTheSpawnOf); errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldYouAreSettingTheSpawnOf);
MessageUtils.sendColorizedMessage(commandSender, errorWorldNotExistingMessage); MessageUtils.sendColorizedMessage(commandSender, errorWorldNotExistingMessage);
return true; return true;
@@ -104,7 +104,7 @@ public class SetSpawnCommand implements CommandExecutor
FileUtils.saveExistingYaml(FileUtils.FileType.SPAWN_YAML); FileUtils.saveExistingYaml(FileUtils.FileType.SPAWN_YAML);
// Tell the player he set the spawn successfully. // Tell the player he set the spawn successfully.
String spawnSetMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_SPAWN_SET, false) String spawnSetMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_SPAWN_SET, false)
.replace("%dw%", worldYouAreSettingTheSpawnOf) .replace("%dw%", worldYouAreSettingTheSpawnOf)
.replace("%cw%", currentWorldName) .replace("%cw%", currentWorldName)
.replace("%x%", (int)x + "") .replace("%x%", (int)x + "")
@@ -115,7 +115,7 @@ public class SetSpawnCommand implements CommandExecutor
} }
else else
{ {
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_SET.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_SET.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
} }

View File

@@ -42,7 +42,7 @@ public class SpawnCommand implements CommandExecutor
boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender); boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender);
if(senderIsConsole) if(senderIsConsole)
{ {
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED);
return true; return true;
} }
@@ -56,14 +56,14 @@ public class SpawnCommand implements CommandExecutor
Player teleportPlayer = plugin.getServer().getPlayer(teleportingPlayerName); Player teleportPlayer = plugin.getServer().getPlayer(teleportingPlayerName);
if(teleportPlayer == null) if(teleportPlayer == null)
{ {
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_PLAYER_OFFLINE, true).replace("%player%", teleportingPlayerName); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_PLAYER_OFFLINE, true).replace("%player%", teleportingPlayerName);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return true; return true;
} }
if(plugin.getServer().getWorld(worldName) == null) if(plugin.getServer().getWorld(worldName) == null)
{ {
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_SPAWN_NOT_SET); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_SPAWN_NOT_SET);
return true; return true;
} }
@@ -73,7 +73,7 @@ public class SpawnCommand implements CommandExecutor
else else
{ {
// Warn the player he doesn't have permissions to teleport others to the hub. // Warn the player he doesn't have permissions to teleport others to the hub.
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_TELEPORT_OTHERS.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_TELEPORT_OTHERS.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return true; return true;
} }
@@ -103,14 +103,14 @@ public class SpawnCommand implements CommandExecutor
if(!PermissionUtils.playerHasPermission(commandSender, Permissions.SPAWN_TELEPORT_ANOTHER_WORLD)) if(!PermissionUtils.playerHasPermission(commandSender, Permissions.SPAWN_TELEPORT_ANOTHER_WORLD))
{ {
// Tell the player he has no permission to teleport to another world's spawn. // Tell the player he has no permission to teleport to another world's spawn.
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_TELEPORT_ANOTHER_WORLD.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_TELEPORT_ANOTHER_WORLD.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return true; return true;
} }
if(plugin.getServer().getWorld(args[0]) == null) if(plugin.getServer().getWorld(args[0]) == null)
{ {
String erroMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, true).replace("%w%", args[0]); String erroMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_WORLD_NOT_EXISTING, true).replace("%w%", args[0]);
commandSender.sendMessage(erroMessage); commandSender.sendMessage(erroMessage);
return true; return true;
} }
@@ -118,10 +118,10 @@ public class SpawnCommand implements CommandExecutor
// Load the teleportation delay. // Load the teleportation delay.
int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntries.SPAWN_DELAY.path); int delay = FileUtils.FileType.CONFIG_YAML.yaml.getInt(ConfigEntry.SPAWN_DELAY.path);
// Warn the player about the delay. // Warn the player about the delay.
String delayMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_TELEPORT_DELAY, false); String delayMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_TELEPORT_DELAY, false);
delayMessage = delayMessage.replace("%delay%", delay + ""); delayMessage = delayMessage.replace("%delay%", delay + "");
MessageUtils.sendColorizedMessage(commandSender, delayMessage); MessageUtils.sendColorizedMessage(commandSender, delayMessage);
@@ -146,7 +146,7 @@ public class SpawnCommand implements CommandExecutor
else else
{ {
// Send a message to the player stating it, and do nothing. // Send a message to the player stating it, and do nothing.
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_ALREADY_TELEPORTING); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_ALREADY_TELEPORTING);
return true; return true;
} }
} }
@@ -154,7 +154,7 @@ public class SpawnCommand implements CommandExecutor
else else
{ {
// Warn the player he doesn't have permissions to go to the spawn. // Warn the player he doesn't have permissions to go to the spawn.
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_TELEPORT.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.SPAWN_TELEPORT.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
} }

View File

@@ -36,7 +36,7 @@ public class WorldListCommand implements CommandExecutor
if(PermissionUtils.playerHasPermission(commandSender, Permissions.WORLD_LIST)) if(PermissionUtils.playerHasPermission(commandSender, Permissions.WORLD_LIST))
{ {
// send the translated title. // send the translated title.
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.INFO_WORLDS_LIST); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.INFO_WORLDS_LIST);
MessageUtils.sendColorizedMessage(commandSender, "&7---------"); MessageUtils.sendColorizedMessage(commandSender, "&7---------");
@@ -77,7 +77,7 @@ public class WorldListCommand implements CommandExecutor
else // If player doesn't have permissions... else // If player doesn't have permissions...
{ {
// Tell him. // Tell him.
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.WORLD_LIST.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.WORLD_LIST.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
} }
return true; return true;

View File

@@ -40,7 +40,7 @@ public class WorldTpCommand implements CommandExecutor
boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender); boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender);
if(senderIsConsole) if(senderIsConsole)
{ {
MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); MessageUtils.sendLocalizedMessage(commandSender, LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED);
return true; return true;
} }
@@ -51,7 +51,7 @@ public class WorldTpCommand implements CommandExecutor
if(args.length != 1) if(args.length != 1)
{ {
// Warn the player in case it's wrong. // Warn the player in case it's wrong.
String wrongUsageMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WRONG_USAGE, false).replace("%usage%", "/worldtp <world>"); String wrongUsageMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_WRONG_USAGE, false).replace("%usage%", "/worldtp <world>");
MessageUtils.sendColorizedMessage(commandSender, wrongUsageMessage); MessageUtils.sendColorizedMessage(commandSender, wrongUsageMessage);
return true; return true;
} }
@@ -62,7 +62,7 @@ public class WorldTpCommand implements CommandExecutor
// If the world does not exist, warn the player. // If the world does not exist, warn the player.
if(destinationWorld == null) if(destinationWorld == null)
{ {
String worldDoesNotExistMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false); String worldDoesNotExistMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_WORLD_NOT_EXISTING, false);
worldDoesNotExistMessage = worldDoesNotExistMessage.replace("%w%", destinationWorldName); worldDoesNotExistMessage = worldDoesNotExistMessage.replace("%w%", destinationWorldName);
MessageUtils.sendColorizedMessage(commandSender, worldDoesNotExistMessage); MessageUtils.sendColorizedMessage(commandSender, worldDoesNotExistMessage);
return true; return true;
@@ -77,7 +77,7 @@ public class WorldTpCommand implements CommandExecutor
plugin.getServer().getScheduler().runTaskLater(plugin, () -> player.teleport(destinationLocation), 1); plugin.getServer().getScheduler().runTaskLater(plugin, () -> player.teleport(destinationLocation), 1);
fixInvisibilityAfter(player); fixInvisibilityAfter(player);
// Tell the player he has been teleported. // Tell the player he has been teleported.
String teleportedMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_WORLDTP_TELEPORTED, false); String teleportedMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_WORLDTP_TELEPORTED, false);
teleportedMessage = teleportedMessage.replace("%world%", destinationWorldName).replace("%w%", destinationWorldName); teleportedMessage = teleportedMessage.replace("%world%", destinationWorldName).replace("%w%", destinationWorldName);
MessageUtils.sendColorizedMessage(commandSender, teleportedMessage); MessageUtils.sendColorizedMessage(commandSender, teleportedMessage);
} }

View File

@@ -1,6 +1,6 @@
package wtf.beatrice.hubthat.commands.hubthatcommands; package wtf.beatrice.hubthat.commands.hubthatcommands;
import wtf.beatrice.hubthat.utils.LocalizedMessages; import wtf.beatrice.hubthat.utils.LocalizedMessage;
import wtf.beatrice.hubthat.utils.MessageUtils; import wtf.beatrice.hubthat.utils.MessageUtils;
import wtf.beatrice.hubthat.utils.PermissionUtils; import wtf.beatrice.hubthat.utils.PermissionUtils;
import wtf.beatrice.hubthat.utils.Permissions; import wtf.beatrice.hubthat.utils.Permissions;
@@ -13,7 +13,7 @@ public class HelpCommand
{ {
if(!PermissionUtils.playerHasPermission(commandSender, Permissions.HELP_MESSAGE)) if(!PermissionUtils.playerHasPermission(commandSender, Permissions.HELP_MESSAGE))
{ {
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.HELP_MESSAGE.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.HELP_MESSAGE.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
return; return;
} }

View File

@@ -28,7 +28,7 @@ public class ReloadCommand
} }
else else
{ {
String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.NO_PERMISSION, true).replace("%permission%", Permissions.RELOAD_CONFIG.permission); String errorMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.NO_PERMISSION, true).replace("%permission%", Permissions.RELOAD_CONFIG.permission);
commandSender.sendMessage(errorMessage); commandSender.sendMessage(errorMessage);
} }

View File

@@ -1,7 +1,7 @@
package wtf.beatrice.hubthat.listeners; package wtf.beatrice.hubthat.listeners;
import wtf.beatrice.hubthat.HubThat; import wtf.beatrice.hubthat.HubThat;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.Debugger; import wtf.beatrice.hubthat.utils.Debugger;
import wtf.beatrice.hubthat.utils.files.FileUtils; import wtf.beatrice.hubthat.utils.files.FileUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -27,7 +27,7 @@ public class PlayerChatListener implements Listener
Player messageSender = event.getPlayer(); Player messageSender = event.getPlayer();
// Check if the world-related chat is enabled. // Check if the world-related chat is enabled.
if(FileUtils.FileType.CONFIG_YAML.yaml.getBoolean(ConfigEntries.WORLD_RELATED_CHAT.path)) if(FileUtils.FileType.CONFIG_YAML.yaml.getBoolean(ConfigEntry.WORLD_RELATED_CHAT.path))
{ {
// Store the sender's world spawn name in a string. Fallback to "__UNSET__". // Store the sender's world spawn name in a string. Fallback to "__UNSET__".

View File

@@ -2,7 +2,7 @@ package wtf.beatrice.hubthat.listeners;
import wtf.beatrice.hubthat.HubThat; import wtf.beatrice.hubthat.HubThat;
import wtf.beatrice.hubthat.commands.HubCommand; import wtf.beatrice.hubthat.commands.HubCommand;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.Debugger; import wtf.beatrice.hubthat.utils.Debugger;
import wtf.beatrice.hubthat.utils.MessageUtils; import wtf.beatrice.hubthat.utils.MessageUtils;
import wtf.beatrice.hubthat.utils.PluginCache; import wtf.beatrice.hubthat.utils.PluginCache;
@@ -49,10 +49,10 @@ public class PlayerJoinListener implements Listener
plugin.updateChecker.playerMessage(player); plugin.updateChecker.playerMessage(player);
// Check if gamemode has to be set on join. // Check if gamemode has to be set on join.
if(configYaml.getBoolean(ConfigEntries.GAMEMODE_SET_ON_JOIN.path)) if(configYaml.getBoolean(ConfigEntry.GAMEMODE_SET_ON_JOIN.path))
{ {
// Load the gamemode int from config. // Load the gamemode int from config.
int gamemodeInt = configYaml.getInt(ConfigEntries.GAMEMODE.path); int gamemodeInt = configYaml.getInt(ConfigEntry.GAMEMODE.path);
GameMode gamemode; GameMode gamemode;
// Set the gamemode accordingly. // Set the gamemode accordingly.
@@ -72,7 +72,7 @@ public class PlayerJoinListener implements Listener
break; break;
} }
if(configYaml.getBoolean(ConfigEntries.MULTIVERSE_BYPASS.path)) if(configYaml.getBoolean(ConfigEntry.MULTIVERSE_BYPASS.path))
{ {
plugin.getServer().getScheduler().runTaskLater(plugin, ()-> player.setGameMode(gamemode), 10L); plugin.getServer().getScheduler().runTaskLater(plugin, ()-> player.setGameMode(gamemode), 10L);
} }
@@ -83,10 +83,10 @@ public class PlayerJoinListener implements Listener
} }
// Check if we have to teleport the player to the Hub on join. // Check if we have to teleport the player to the Hub on join.
if(configYaml.getBoolean(ConfigEntries.TELEPORTATION_TP_HUB_ON_JOIN.path)) if(configYaml.getBoolean(ConfigEntry.TELEPORTATION_TP_HUB_ON_JOIN.path))
{ {
if(configYaml.getBoolean(ConfigEntries.MULTIVERSE_BYPASS.path)) if(configYaml.getBoolean(ConfigEntry.MULTIVERSE_BYPASS.path))
{ {
plugin.getServer().getScheduler().runTaskLater(plugin, ()-> HubCommand.teleportToHub(player, player, PluginCache.sendJoinTpMessage), 10L); plugin.getServer().getScheduler().runTaskLater(plugin, ()-> HubCommand.teleportToHub(player, player, PluginCache.sendJoinTpMessage), 10L);
} }

View File

@@ -1,8 +1,8 @@
package wtf.beatrice.hubthat.listeners; package wtf.beatrice.hubthat.listeners;
import wtf.beatrice.hubthat.utils.PluginCache; import wtf.beatrice.hubthat.utils.PluginCache;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.LocalizedMessages; import wtf.beatrice.hubthat.utils.LocalizedMessage;
import wtf.beatrice.hubthat.utils.MessageUtils; import wtf.beatrice.hubthat.utils.MessageUtils;
import wtf.beatrice.hubthat.utils.files.FileUtils; import wtf.beatrice.hubthat.utils.files.FileUtils;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -17,7 +17,7 @@ public class PlayerMoveListener implements Listener
{ {
// Check if the movement detection is enabled. // Check if the movement detection is enabled.
if(FileUtils.FileType.CONFIG_YAML.yaml.getBoolean(ConfigEntries.MOVEMENT_DETECTION_ENABLED.path)) if(FileUtils.FileType.CONFIG_YAML.yaml.getBoolean(ConfigEntry.MOVEMENT_DETECTION_ENABLED.path))
{ {
// We are only going to allocate the playerName string and not the whole Player because we want efficiency. // We are only going to allocate the playerName string and not the whole Player because we want efficiency.
String playerName = event.getPlayer().getName(); String playerName = event.getPlayer().getName();
@@ -33,7 +33,7 @@ public class PlayerMoveListener implements Listener
// Remove the player from the list and warn him. // Remove the player from the list and warn him.
PluginCache.teleporting.remove(playerName); PluginCache.teleporting.remove(playerName);
PluginCache.cancelRunnable.add(playerName); PluginCache.cancelRunnable.add(playerName);
MessageUtils.sendLocalizedMessage(event.getPlayer(), LocalizedMessages.WARNING_TELEPORTATION_CANCELLED); MessageUtils.sendLocalizedMessage(event.getPlayer(), LocalizedMessage.WARNING_TELEPORTATION_CANCELLED);
} }
} }
} }

View File

@@ -3,7 +3,7 @@ package wtf.beatrice.hubthat.listeners;
import wtf.beatrice.hubthat.HubThat; import wtf.beatrice.hubthat.HubThat;
import wtf.beatrice.hubthat.commands.HubCommand; import wtf.beatrice.hubthat.commands.HubCommand;
import wtf.beatrice.hubthat.commands.SpawnCommand; import wtf.beatrice.hubthat.commands.SpawnCommand;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.files.FileUtils; import wtf.beatrice.hubthat.utils.files.FileUtils;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -31,7 +31,7 @@ public class PlayerRespawnListener implements Listener
if(configYaml.getBoolean(ConfigEntries.MULTIVERSE_BYPASS.path)) if(configYaml.getBoolean(ConfigEntry.MULTIVERSE_BYPASS.path))
{ {
plugin.getServer().getScheduler().runTaskLater(plugin, ()-> tpPlayer(event.getPlayer(), configYaml), 5L); plugin.getServer().getScheduler().runTaskLater(plugin, ()-> tpPlayer(event.getPlayer(), configYaml), 5L);
@@ -48,11 +48,11 @@ public class PlayerRespawnListener implements Listener
private void tpPlayer(Player player, YamlConfiguration configYaml) private void tpPlayer(Player player, YamlConfiguration configYaml)
{ {
// Check if the respawn handler is enabled in config. // Check if the respawn handler is enabled in config.
if(configYaml.getBoolean(ConfigEntries.TELEPORTATION_RESPAWN_HANDLER.path)) if(configYaml.getBoolean(ConfigEntry.TELEPORTATION_RESPAWN_HANDLER.path))
{ {
// Check if the player has to be teleported to Hub on respawn. // Check if the player has to be teleported to Hub on respawn.
if(configYaml.getBoolean(ConfigEntries.TELEPORTATION_TP_HUB_ON_RESPAWN.path)) if(configYaml.getBoolean(ConfigEntry.TELEPORTATION_TP_HUB_ON_RESPAWN.path))
{ {
HubCommand.teleportToHub(player, player); HubCommand.teleportToHub(player, player);
} }

View File

@@ -1,6 +1,6 @@
package wtf.beatrice.hubthat.utils; package wtf.beatrice.hubthat.utils;
public enum ConfigEntries public enum ConfigEntry
{ {
HUB_DELAY("hub.delay"), HUB_DELAY("hub.delay"),
@@ -13,27 +13,21 @@ public enum ConfigEntries
MOVEMENT_DETECTION_ENABLED("movement-detection.enable"), MOVEMENT_DETECTION_ENABLED("movement-detection.enable"),
GAMEMODE_SET_ON_JOIN("gamemode.set-on-join"), GAMEMODE_SET_ON_JOIN("gamemode.set-on-join"),
GAMEMODE("gamemode.mode"), GAMEMODE("gamemode.mode"),
TELEPORTATION_RESPAWN_HANDLER("teleportation.respawn-handler"), TELEPORTATION_RESPAWN_HANDLER("teleportation.respawn-handler"),
TELEPORTATION_TP_HUB_ON_JOIN("teleportation.teleport-to-hub-on-join"), TELEPORTATION_TP_HUB_ON_JOIN("teleportation.teleport-to-hub-on-join"),
TELEPORTATION_TP_MESSAGE_ON_JOIN("teleportation.send-tp-message-on-join"), TELEPORTATION_TP_MESSAGE_ON_JOIN("teleportation.send-tp-message-on-join"),
TELEPORTATION_TP_HUB_ON_RESPAWN("teleportation.teleport-to-hub-on-respawn"), TELEPORTATION_TP_HUB_ON_RESPAWN("teleportation.teleport-to-hub-on-respawn"),
MULTIVERSE_BYPASS("settings.multiverse-bypass"), MULTIVERSE_BYPASS("settings.multiverse-bypass"),
INVISIBILITY_FIX("settings.fix-invisible-after-tp"), INVISIBILITY_FIX("settings.fix-invisible-after-tp"),
//UPDATE_CHECKER_ENABLE("updates.enable-update-checker"),
; ;
public String path; public String path;
ConfigEntries(String path) ConfigEntry(String path)
{ {
this.path = path; this.path = path;
} }

View File

@@ -1,6 +1,6 @@
package wtf.beatrice.hubthat.utils; package wtf.beatrice.hubthat.utils;
public enum LocalizedMessages public enum LocalizedMessage
{ {
@@ -49,7 +49,7 @@ public enum LocalizedMessages
public String path; public String path;
LocalizedMessages(String path) LocalizedMessage(String path)
{ {
this.path = path; this.path = path;
} }

View File

@@ -14,7 +14,7 @@ public class MessageUtils
private static final Debugger debugger = new Debugger(MessageUtils.class.getName()); private static final Debugger debugger = new Debugger(MessageUtils.class.getName());
// Method to automatically load and send a localized message to the CommandSender. // Method to automatically load and send a localized message to the CommandSender.
public static void sendLocalizedMessage(CommandSender sender, LocalizedMessages messageEnum) public static void sendLocalizedMessage(CommandSender sender, LocalizedMessage messageEnum)
{ {
// If we actually have a sender, send it the message and color it! // If we actually have a sender, send it the message and color it!
if(sender != null) sender.sendMessage(getLocalizedMessage(messageEnum, true)); if(sender != null) sender.sendMessage(getLocalizedMessage(messageEnum, true));
@@ -32,7 +32,7 @@ public class MessageUtils
else debugger.sendDebugMessage(Level.SEVERE, "Sender is null!"); else debugger.sendDebugMessage(Level.SEVERE, "Sender is null!");
} }
public static String getLocalizedMessage(LocalizedMessages messageEnum, boolean applyColor) public static String getLocalizedMessage(LocalizedMessage messageEnum, boolean applyColor)
{ {
/* /*
@@ -47,7 +47,7 @@ public class MessageUtils
YamlConfiguration langFile = FileUtils.FileType.LANG_YAML.yaml; YamlConfiguration langFile = FileUtils.FileType.LANG_YAML.yaml;
// Initialize the message string and store the String from the lang file to it. // Initialize the message string and store the String from the lang file to it.
String localizedMessage = langFile.getString(LocalizedMessages.INFO_PREFIX.path) + langFile.getString(path); String localizedMessage = langFile.getString(LocalizedMessage.INFO_PREFIX.path) + langFile.getString(path);
// Check if the message is null and if we have to color the message or leave the symbols inside for further elaboration. // Check if the message is null and if we have to color the message or leave the symbols inside for further elaboration.
if (localizedMessage != null) if (localizedMessage != null)

View File

@@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender;
public class PermissionUtils public class PermissionUtils
{ {
// Method to get the permission string from the Permissions enum. // Method to get the permission string from the Permissions enum.
public static boolean playerHasPermission(CommandSender user, Permissions permission) public static boolean playerHasPermission(CommandSender user, Permissions permission)
{ {

View File

@@ -7,8 +7,6 @@ import java.util.ArrayList;
public class PluginCache public class PluginCache
{ {
public static ArrayList<String> teleporting = new ArrayList<>(); public static ArrayList<String> teleporting = new ArrayList<>();
public static ArrayList<String>cancelRunnable = new ArrayList<>(); public static ArrayList<String>cancelRunnable = new ArrayList<>();
@@ -17,6 +15,6 @@ public class PluginCache
public static boolean sendJoinTpMessage = true; public static boolean sendJoinTpMessage = true;
public static final ItemStack AIR = new ItemStack(Material.AIR, 1); public static final ItemStack AIR = new ItemStack(Material.AIR, 1);
public static final double minSupportedVersion = 1.7; public static final String minSupportedVersion = "1.7";
public static final double maxSupportedVersion = 1.16; public static final String maxSupportedVersion = "1.20";
} }

View File

@@ -88,12 +88,12 @@ public class TeleportUtils
if(type == FileUtils.FileType.HUB_YAML) if(type == FileUtils.FileType.HUB_YAML)
{ {
// send a message about the hub being not set // send a message about the hub being not set
if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET); if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessage.ERROR_HUB_NOT_SET);
} }
else if(type == FileUtils.FileType.SPAWN_YAML) else if(type == FileUtils.FileType.SPAWN_YAML)
{ {
// send a message about the spawn being not set. // send a message about the spawn being not set.
if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_SPAWN_NOT_SET); if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessage.ERROR_SPAWN_NOT_SET);
} }
else else
{ {
@@ -109,7 +109,7 @@ public class TeleportUtils
if(worldName.equals("__UNSET__") && type == FileUtils.FileType.HUB_YAML) if(worldName.equals("__UNSET__") && type == FileUtils.FileType.HUB_YAML)
{ {
// Warn the player about the hub not being set. // Warn the player about the hub not being set.
if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessages.ERROR_HUB_NOT_SET); if(sendMessage) MessageUtils.sendLocalizedMessage(sender, LocalizedMessage.ERROR_HUB_NOT_SET);
// Stop. // Stop.
return; return;
} }
@@ -122,7 +122,7 @@ public class TeleportUtils
// Tell the player that the world does not exist. // Tell the player that the world does not exist.
if(sendMessage) if(sendMessage)
{ {
String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, false); String errorWorldNotExistingMessage = MessageUtils.getLocalizedMessage(LocalizedMessage.ERROR_WORLD_NOT_EXISTING, false);
errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldName); errorWorldNotExistingMessage = errorWorldNotExistingMessage.replace("%w%", worldName);
MessageUtils.sendColorizedMessage(player, errorWorldNotExistingMessage); MessageUtils.sendColorizedMessage(player, errorWorldNotExistingMessage);
} }
@@ -143,21 +143,21 @@ public class TeleportUtils
if(type == FileUtils.FileType.HUB_YAML) if(type == FileUtils.FileType.HUB_YAML)
{ {
// Send a message to the player about him being successfully teleported. // Send a message to the player about him being successfully teleported.
if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_HUB_TELEPORTED); if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessage.INFO_HUB_TELEPORTED);
if((sender != player) && (sendMessage)) if((sender != player) && (sendMessage))
{ {
String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_HUB_TELEPORTED_OTHER, true).replace("%player%", player.getName()); String message = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_HUB_TELEPORTED_OTHER, true).replace("%player%", player.getName());
sender.sendMessage(message); sender.sendMessage(message);
} }
} }
else //if(type == FileUtils.FileType.SPAWN_YAML) // left here but commented, for easy understanding else //if(type == FileUtils.FileType.SPAWN_YAML) // left here but commented, for easy understanding
{ {
if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessages.INFO_SPAWN_TELEPORTED); if(sendMessage) MessageUtils.sendLocalizedMessage(player, LocalizedMessage.INFO_SPAWN_TELEPORTED);
if((sender != player) && (sendMessage)) if((sender != player) && (sendMessage))
{ {
String message = MessageUtils.getLocalizedMessage(LocalizedMessages.INFO_SPAWN_TELEPORTED_OTHER, true).replace("%player%", player.getName()).replace("%world%", worldName); String message = MessageUtils.getLocalizedMessage(LocalizedMessage.INFO_SPAWN_TELEPORTED_OTHER, true).replace("%player%", player.getName()).replace("%world%", worldName);
sender.sendMessage(message); sender.sendMessage(message);
} }
} }

View File

@@ -2,7 +2,7 @@ package wtf.beatrice.hubthat.utils.files;
import wtf.beatrice.hubthat.HubThat; import wtf.beatrice.hubthat.HubThat;
import wtf.beatrice.hubthat.utils.PluginCache; import wtf.beatrice.hubthat.utils.PluginCache;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.Debugger; import wtf.beatrice.hubthat.utils.Debugger;
import wtf.beatrice.hubthat.utils.metrics.UpdateChecker; import wtf.beatrice.hubthat.utils.metrics.UpdateChecker;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -59,7 +59,7 @@ public class FileUtils
YamlConfiguration config = FileType.CONFIG_YAML.yaml; YamlConfiguration config = FileType.CONFIG_YAML.yaml;
if(config.getBoolean(ConfigEntries.UPDATE_CHECKER_ENABLED.path)) if(config.getBoolean(ConfigEntry.UPDATE_CHECKER_ENABLED.path))
{ {
PluginCache.updateChecker = true; PluginCache.updateChecker = true;
if(UpdateChecker.task != null) if(UpdateChecker.task != null)
@@ -74,8 +74,8 @@ public class FileUtils
PluginCache.updateChecker = false; PluginCache.updateChecker = false;
} }
PluginCache.invisibilityFix = config.getBoolean(ConfigEntries.INVISIBILITY_FIX.path); PluginCache.invisibilityFix = config.getBoolean(ConfigEntry.INVISIBILITY_FIX.path);
PluginCache.sendJoinTpMessage = config.getBoolean(ConfigEntries.TELEPORTATION_TP_MESSAGE_ON_JOIN.path); PluginCache.sendJoinTpMessage = config.getBoolean(ConfigEntry.TELEPORTATION_TP_MESSAGE_ON_JOIN.path);
} }
// Only reload the needed File. // Only reload the needed File.

View File

@@ -1,8 +1,8 @@
package wtf.beatrice.hubthat.utils.files; package wtf.beatrice.hubthat.utils.files;
import wtf.beatrice.hubthat.HubThat; import wtf.beatrice.hubthat.HubThat;
import wtf.beatrice.hubthat.utils.ConfigEntries; import wtf.beatrice.hubthat.utils.ConfigEntry;
import wtf.beatrice.hubthat.utils.LocalizedMessages; import wtf.beatrice.hubthat.utils.LocalizedMessage;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
@@ -37,21 +37,21 @@ public class OldConfigConversion
FileUtils.checkFiles(); FileUtils.checkFiles();
// newPath, oldPath // newPath, oldPath
HashMap<ConfigEntries, String>newAndOldConfigEntries = new HashMap<>(); HashMap<ConfigEntry, String>newAndOldConfigEntries = new HashMap<>();
logger.warning("Loading config entries..."); logger.warning("Loading config entries...");
newAndOldConfigEntries.put(ConfigEntries.HUB_DELAY, "hub.delay"); newAndOldConfigEntries.put(ConfigEntry.HUB_DELAY, "hub.delay");
newAndOldConfigEntries.put(ConfigEntries.SPAWN_DELAY, "spawn.delay"); newAndOldConfigEntries.put(ConfigEntry.SPAWN_DELAY, "spawn.delay");
newAndOldConfigEntries.put(ConfigEntries.WORLD_RELATED_CHAT, "global.world-related-chat"); newAndOldConfigEntries.put(ConfigEntry.WORLD_RELATED_CHAT, "global.world-related-chat");
newAndOldConfigEntries.put(ConfigEntries.UPDATE_CHECKER_ENABLED, "updates.update-notify"); newAndOldConfigEntries.put(ConfigEntry.UPDATE_CHECKER_ENABLED, "updates.update-notify");
newAndOldConfigEntries.put(ConfigEntries.MOVEMENT_DETECTION_ENABLED, "global.move-detect"); newAndOldConfigEntries.put(ConfigEntry.MOVEMENT_DETECTION_ENABLED, "global.move-detect");
newAndOldConfigEntries.put(ConfigEntries.GAMEMODE_SET_ON_JOIN, "global.set-gamemode-on-join"); newAndOldConfigEntries.put(ConfigEntry.GAMEMODE_SET_ON_JOIN, "global.set-gamemode-on-join");
newAndOldConfigEntries.put(ConfigEntries.GAMEMODE, "global.gamemode"); newAndOldConfigEntries.put(ConfigEntry.GAMEMODE, "global.gamemode");
newAndOldConfigEntries.put(ConfigEntries.TELEPORTATION_TP_HUB_ON_JOIN, "global.tp-hub-on-join"); newAndOldConfigEntries.put(ConfigEntry.TELEPORTATION_TP_HUB_ON_JOIN, "global.tp-hub-on-join");
newAndOldConfigEntries.put(ConfigEntries.TELEPORTATION_TP_HUB_ON_RESPAWN, "global.tp-hub-on-respawn"); newAndOldConfigEntries.put(ConfigEntry.TELEPORTATION_TP_HUB_ON_RESPAWN, "global.tp-hub-on-respawn");
newAndOldConfigEntries.put(ConfigEntries.TELEPORTATION_RESPAWN_HANDLER, "global.respawn-handler"); newAndOldConfigEntries.put(ConfigEntry.TELEPORTATION_RESPAWN_HANDLER, "global.respawn-handler");
logger.warning("Converting config entries..."); logger.warning("Converting config entries...");
for(ConfigEntries entry : newAndOldConfigEntries.keySet()) for(ConfigEntry entry : newAndOldConfigEntries.keySet())
{ {
logger.warning("Entry: " + entry.path); logger.warning("Entry: " + entry.path);
FileUtils.FileType.CONFIG_YAML.yaml.set(entry.path, oldConfig.get(newAndOldConfigEntries.get(entry))); FileUtils.FileType.CONFIG_YAML.yaml.set(entry.path, oldConfig.get(newAndOldConfigEntries.get(entry)));
@@ -62,18 +62,18 @@ public class OldConfigConversion
logger.warning("Done with config.yml!"); logger.warning("Done with config.yml!");
logger.warning("Loading lang entries..."); logger.warning("Loading lang entries...");
HashMap<LocalizedMessages, String>newAndOldLangEntries = new HashMap<>(); HashMap<LocalizedMessage, String>newAndOldLangEntries = new HashMap<>();
newAndOldLangEntries.put(LocalizedMessages.ERROR_ALREADY_TELEPORTING, "global.ALREADY-TELEPORTING"); newAndOldLangEntries.put(LocalizedMessage.ERROR_ALREADY_TELEPORTING, "global.ALREADY-TELEPORTING");
newAndOldLangEntries.put(LocalizedMessages.ERROR_HUB_NOT_SET, "hub.HUB_NOT_SET"); newAndOldLangEntries.put(LocalizedMessage.ERROR_HUB_NOT_SET, "hub.HUB_NOT_SET");
newAndOldLangEntries.put(LocalizedMessages.ERROR_SPAWN_NOT_SET, "spawn.SPAWN_NOT_SET"); newAndOldLangEntries.put(LocalizedMessage.ERROR_SPAWN_NOT_SET, "spawn.SPAWN_NOT_SET");
newAndOldLangEntries.put(LocalizedMessages.ERROR_WORLD_NOT_EXISTING, "worldtp.UNKNOWN_WORLD"); newAndOldLangEntries.put(LocalizedMessage.ERROR_WORLD_NOT_EXISTING, "worldtp.UNKNOWN_WORLD");
newAndOldLangEntries.put(LocalizedMessages.WARNING_TELEPORTATION_CANCELLED, "global.MOVED"); newAndOldLangEntries.put(LocalizedMessage.WARNING_TELEPORTATION_CANCELLED, "global.MOVED");
newAndOldLangEntries.put(LocalizedMessages.INFO_HUB_TELEPORTED, "hub.TELEPORTED"); newAndOldLangEntries.put(LocalizedMessage.INFO_HUB_TELEPORTED, "hub.TELEPORTED");
newAndOldLangEntries.put(LocalizedMessages.INFO_SPAWN_TELEPORTED, "spawn.TELEPORTED"); newAndOldLangEntries.put(LocalizedMessage.INFO_SPAWN_TELEPORTED, "spawn.TELEPORTED");
newAndOldLangEntries.put(LocalizedMessages.INFO_WORLDTP_TELEPORTED, "worldtp.TELEPORTED"); newAndOldLangEntries.put(LocalizedMessage.INFO_WORLDTP_TELEPORTED, "worldtp.TELEPORTED");
logger.warning("Converting lang entries..."); logger.warning("Converting lang entries...");
for(LocalizedMessages message : newAndOldLangEntries.keySet()) for(LocalizedMessage message : newAndOldLangEntries.keySet())
{ {
logger.warning("Entry: " + message.path); logger.warning("Entry: " + message.path);
FileUtils.FileType.LANG_YAML.yaml.set(message.path, oldConfig.get(newAndOldLangEntries.get(message))); FileUtils.FileType.LANG_YAML.yaml.set(message.path, oldConfig.get(newAndOldLangEntries.get(message)));

View File

@@ -87,8 +87,7 @@ public class UpdateChecker implements Runnable
} catch (IOException e) } catch (IOException e)
{ {
setAndSendErrorCode(e.getMessage(), console);
setAndSendErrorCode("null json", console);
return; return;
} }
@@ -97,11 +96,10 @@ public class UpdateChecker implements Runnable
JsonObject json = (JsonObject)jsonParser.parse(new InputStreamReader(jsonIS, StandardCharsets.UTF_8)); JsonObject json = (JsonObject)jsonParser.parse(new InputStreamReader(jsonIS, StandardCharsets.UTF_8));
// Close the input stream... // Close the input stream...
/*try { try {
jsonIS.close(); jsonIS.close();
} catch (IOException ignored) } catch (IOException ignored)
{ {}
}*/
// Check if the "version" String is present... // Check if the "version" String is present...
newVersion = null; newVersion = null;

View File

@@ -1,6 +1,6 @@
error: error:
console-access-blocked: '&cSorry, but this command is not available via console.' console-access-blocked: '&cSorry, but this command is not available via console.'
already-teleporting: '&cYou are already in the teleportation queue!' already-teleporting: '&cYou are already being teleported!'
hub-not-set: '&cThe hub is not set.' hub-not-set: '&cThe hub is not set.'
spawn-not-set: '&cThe spawn is not set.' spawn-not-set: '&cThe spawn is not set.'
unknown-world: '&cError: world "%w%" does not exist!' unknown-world: '&cError: world "%w%" does not exist!'