From acaa45ac3fe61cf160d75a7e12baede8e13b06b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Thu, 11 Aug 2022 18:17:57 +0200 Subject: [PATCH] Rename utils classes to follow correct naming schemes --- .../uhccore/commands/UhcCoreCommand.java | 8 ++--- .../uhccommands/SetFireworkCommand.java | 4 +-- .../commands/uhccommands/SetSpawnCommand.java | 14 ++++---- .../beatrice/uhccore/utils/MessageUtils.java | 8 ++--- .../{Permissions.java => Permission.java} | 4 +-- .../uhccore/utils/PermissionUtils.java | 2 +- .../wtf/beatrice/uhccore/utils/UhcUtils.java | 4 +-- .../{ConfigEntries.java => ConfigEntry.java} | 4 +-- .../utils/configuration/FileUtils.java | 34 +++++++++---------- ...zedMessages.java => LocalizedMessage.java} | 4 +-- 10 files changed, 43 insertions(+), 43 deletions(-) rename src/main/java/wtf/beatrice/uhccore/utils/{Permissions.java => Permission.java} (59%) rename src/main/java/wtf/beatrice/uhccore/utils/configuration/{ConfigEntries.java => ConfigEntry.java} (92%) rename src/main/java/wtf/beatrice/uhccore/utils/configuration/{LocalizedMessages.java => LocalizedMessage.java} (84%) diff --git a/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java index fecdb1c..99d7947 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java @@ -3,7 +3,7 @@ package wtf.beatrice.uhccore.commands; import wtf.beatrice.uhccore.UhcCore; import wtf.beatrice.uhccore.utils.Debugger; import wtf.beatrice.uhccore.utils.MessageUtils; -import wtf.beatrice.uhccore.utils.configuration.LocalizedMessages; +import wtf.beatrice.uhccore.utils.configuration.LocalizedMessage; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -41,7 +41,7 @@ public class UhcCoreCommand implements CommandExecutor boolean senderIsConsole = (commandSender instanceof ConsoleCommandSender); if(senderIsConsole) { - MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessages.WARNING_CONSOLE_ACCESS); + MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessage.WARNING_CONSOLE_ACCESS); // Only uncomment the following line if the command should not be able to run this command. } @@ -62,7 +62,7 @@ public class UhcCoreCommand implements CommandExecutor { if(!(commandSender instanceof Player)) { - MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); + MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED); } else { @@ -73,7 +73,7 @@ public class UhcCoreCommand implements CommandExecutor { if(!(commandSender instanceof Player)) { - MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); + MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessage.ERROR_CONSOLE_ACCESS_BLOCKED); } else { diff --git a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java index a5aa41a..3b9dd82 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java @@ -1,7 +1,7 @@ package wtf.beatrice.uhccore.commands.uhccommands; import wtf.beatrice.uhccore.utils.Cache; -import wtf.beatrice.uhccore.utils.configuration.ConfigEntries; +import wtf.beatrice.uhccore.utils.configuration.ConfigEntry; import wtf.beatrice.uhccore.utils.Debugger; import wtf.beatrice.uhccore.utils.configuration.FileUtils; import org.bukkit.Location; @@ -36,7 +36,7 @@ public class SetFireworkCommand Cache.fireworksLocations.add(fireworkLoc); } - String currentPath = ConfigEntries.FIREWORK_POS.path + "." + listPos; + String currentPath = ConfigEntry.FIREWORK_POS.path + "." + listPos; config.set(currentPath + ".x", fireworkLoc.getX()); config.set(currentPath + ".y", fireworkLoc.getY()); diff --git a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetSpawnCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetSpawnCommand.java index 5003f42..e39eb26 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetSpawnCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetSpawnCommand.java @@ -1,7 +1,7 @@ package wtf.beatrice.uhccore.commands.uhccommands; import wtf.beatrice.uhccore.utils.Cache; -import wtf.beatrice.uhccore.utils.configuration.ConfigEntries; +import wtf.beatrice.uhccore.utils.configuration.ConfigEntry; import wtf.beatrice.uhccore.utils.configuration.FileUtils; import org.bukkit.Location; import org.bukkit.command.CommandSender; @@ -18,12 +18,12 @@ public class SetSpawnCommand Cache.spawn = playerLoc; YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml; - config.set(ConfigEntries.SPAWN_WORLD.path, playerLoc.getWorld().getName()); - config.set(ConfigEntries.SPAWN_X.path, playerLoc.getX()); - config.set(ConfigEntries.SPAWN_Y.path, playerLoc.getY()); - config.set(ConfigEntries.SPAWN_Z.path, playerLoc.getZ()); - config.set(ConfigEntries.SPAWN_YAW.path, playerLoc.getYaw()); - config.set(ConfigEntries.SPAWN_PITCH.path, playerLoc.getPitch()); + config.set(ConfigEntry.SPAWN_WORLD.path, playerLoc.getWorld().getName()); + config.set(ConfigEntry.SPAWN_X.path, playerLoc.getX()); + config.set(ConfigEntry.SPAWN_Y.path, playerLoc.getY()); + config.set(ConfigEntry.SPAWN_Z.path, playerLoc.getZ()); + config.set(ConfigEntry.SPAWN_YAW.path, playerLoc.getYaw()); + config.set(ConfigEntry.SPAWN_PITCH.path, playerLoc.getPitch()); FileUtils.FileType.CONFIG_YAML.yaml = config; diff --git a/src/main/java/wtf/beatrice/uhccore/utils/MessageUtils.java b/src/main/java/wtf/beatrice/uhccore/utils/MessageUtils.java index 6f16e08..8cc9dfe 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/MessageUtils.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/MessageUtils.java @@ -3,7 +3,7 @@ package wtf.beatrice.uhccore.utils; import wtf.beatrice.uhccore.UhcCore; import wtf.beatrice.uhccore.utils.configuration.FileUtils; -import wtf.beatrice.uhccore.utils.configuration.LocalizedMessages; +import wtf.beatrice.uhccore.utils.configuration.LocalizedMessage; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; @@ -22,7 +22,7 @@ public class MessageUtils MessageUtils.plugin = plugin; } // Method to automatically load and send a localized message to the CommandSender. - public static void sendLocalizedMessage(String senderName, LocalizedMessages messageEnum) + public static void sendLocalizedMessage(String senderName, LocalizedMessage messageEnum) { // We are gonna need to know who to send the message to! CommandSender sender; @@ -39,7 +39,7 @@ public class MessageUtils sendLocalizedMessage(sender, messageEnum); } - 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! @@ -67,7 +67,7 @@ public class MessageUtils else debugger.sendDebugMessage(Level.SEVERE, "Sender is null!"); } - public static String getLocalizedMessage(LocalizedMessages messageEnum, boolean applyColor) + public static String getLocalizedMessage(LocalizedMessage messageEnum, boolean applyColor) { /* diff --git a/src/main/java/wtf/beatrice/uhccore/utils/Permissions.java b/src/main/java/wtf/beatrice/uhccore/utils/Permission.java similarity index 59% rename from src/main/java/wtf/beatrice/uhccore/utils/Permissions.java rename to src/main/java/wtf/beatrice/uhccore/utils/Permission.java index 4a16331..5fabb57 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/Permissions.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/Permission.java @@ -1,10 +1,10 @@ package wtf.beatrice.uhccore.utils; -public enum Permissions +public enum Permission { TEXTCOMPONENT_COMMAND("pluginname.command.textcomponent"); public String permission; - Permissions(String permission) { this.permission = permission; } + Permission(String permission) { this.permission = permission; } } diff --git a/src/main/java/wtf/beatrice/uhccore/utils/PermissionUtils.java b/src/main/java/wtf/beatrice/uhccore/utils/PermissionUtils.java index fc6d787..a786bcd 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/PermissionUtils.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/PermissionUtils.java @@ -16,7 +16,7 @@ public class PermissionUtils public PermissionUtils(UhcCore givenPlugin) { plugin = givenPlugin; } // Method to get the permission string from the Permissions enum. - public static boolean playerHasPermission(String username, Permissions permission) + public static boolean playerHasPermission(String username, Permission permission) { debugger.sendDebugMessage(Level.INFO, "Permission: " + permission.permission + "; Player name is: " + username); Player user = plugin.getServer().getPlayer(username); diff --git a/src/main/java/wtf/beatrice/uhccore/utils/UhcUtils.java b/src/main/java/wtf/beatrice/uhccore/utils/UhcUtils.java index b242b5e..436c4f2 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/UhcUtils.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/UhcUtils.java @@ -8,7 +8,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.inventory.meta.FireworkMeta; -import wtf.beatrice.uhccore.utils.configuration.LocalizedMessages; +import wtf.beatrice.uhccore.utils.configuration.LocalizedMessage; public class UhcUtils { @@ -72,7 +72,7 @@ public class UhcUtils { { if(Cache.spawn == null) { - MessageUtils.sendLocalizedMessage(player, LocalizedMessages.ERROR_SERVER_NOT_SET_UP); + MessageUtils.sendLocalizedMessage(player, LocalizedMessage.ERROR_SERVER_NOT_SET_UP); return; } diff --git a/src/main/java/wtf/beatrice/uhccore/utils/configuration/ConfigEntries.java b/src/main/java/wtf/beatrice/uhccore/utils/configuration/ConfigEntry.java similarity index 92% rename from src/main/java/wtf/beatrice/uhccore/utils/configuration/ConfigEntries.java rename to src/main/java/wtf/beatrice/uhccore/utils/configuration/ConfigEntry.java index 91476a4..a71a4a4 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/configuration/ConfigEntries.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/configuration/ConfigEntry.java @@ -1,6 +1,6 @@ package wtf.beatrice.uhccore.utils.configuration; -public enum ConfigEntries +public enum ConfigEntry { UHC_WORLDS("settings.uhcworlds"), @@ -29,7 +29,7 @@ public enum ConfigEntries public String path; - ConfigEntries(String path) + ConfigEntry(String path) { this.path = path; } diff --git a/src/main/java/wtf/beatrice/uhccore/utils/configuration/FileUtils.java b/src/main/java/wtf/beatrice/uhccore/utils/configuration/FileUtils.java index e669269..e1126a1 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/configuration/FileUtils.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/configuration/FileUtils.java @@ -70,16 +70,16 @@ public class FileUtils YamlConfiguration config = FileType.CONFIG_YAML.yaml; - Cache.teamNames = config.getStringList(ConfigEntries.TEAMS_NAMES.path); - for(String matName : config.getStringList(ConfigEntries.TEAMS_ITEMS.path)) + Cache.teamNames = config.getStringList(ConfigEntry.TEAMS_NAMES.path); + for(String matName : config.getStringList(ConfigEntry.TEAMS_ITEMS.path)) { Cache.teamItemsMaterials.add(Material.valueOf(matName)); } - Cache.uhcWorlds = config.getStringList(ConfigEntries.UHC_WORLDS.path); - Cache.lobbyWorlds = config.getStringList(ConfigEntries.LOBBY_WORLDS.path); + Cache.uhcWorlds = config.getStringList(ConfigEntry.UHC_WORLDS.path); + Cache.lobbyWorlds = config.getStringList(ConfigEntry.LOBBY_WORLDS.path); - Cache.friendlyFire = config.getBoolean(ConfigEntries.FRIENDLY_FIRE.path); + Cache.friendlyFire = config.getBoolean(ConfigEntry.FRIENDLY_FIRE.path); Cache.teamsItem = new ItemStack(Material.NETHER_STAR); ItemMeta im = Cache.teamsItem.getItemMeta(); @@ -91,34 +91,34 @@ public class FileUtils im.setDisplayName("§cEsci dal Team"); Cache.quitTeamItem.setItemMeta(im); - Cache.totalTeams = config.getInt(ConfigEntries.TEAMS_NUMBER.path); + Cache.totalTeams = config.getInt(ConfigEntry.TEAMS_NUMBER.path); Cache.teamsSelectorGUI = new TeamsSelectorGUI(); Cache.teamsSelectorGUI.initializeInv(); - Cache.borderX = config.getInt(ConfigEntries.BORDER_CENTER_X.path); - Cache.borderZ = config.getInt(ConfigEntries.BORDER_CENTER_Z.path); - Cache.borderSize = config.getInt(ConfigEntries.BORDER_SIZE.path); + Cache.borderX = config.getInt(ConfigEntry.BORDER_CENTER_X.path); + Cache.borderZ = config.getInt(ConfigEntry.BORDER_CENTER_Z.path); + Cache.borderSize = config.getInt(ConfigEntry.BORDER_SIZE.path); - String spawnWorldName = config.getString(ConfigEntries.SPAWN_WORLD.path); + String spawnWorldName = config.getString(ConfigEntry.SPAWN_WORLD.path); if(spawnWorldName != null) { World spawnWorld = plugin.getServer().getWorld(spawnWorldName); if(spawnWorld != null) { - double x = config.getDouble(ConfigEntries.SPAWN_X.path); - double y = config.getDouble(ConfigEntries.SPAWN_Y.path); - double z = config.getDouble(ConfigEntries.SPAWN_Z.path); - double yaw = config.getDouble(ConfigEntries.SPAWN_YAW.path); - double pitch = config.getDouble(ConfigEntries.SPAWN_PITCH.path); + double x = config.getDouble(ConfigEntry.SPAWN_X.path); + double y = config.getDouble(ConfigEntry.SPAWN_Y.path); + double z = config.getDouble(ConfigEntry.SPAWN_Z.path); + double yaw = config.getDouble(ConfigEntry.SPAWN_YAW.path); + double pitch = config.getDouble(ConfigEntry.SPAWN_PITCH.path); Cache.spawn = new Location(spawnWorld, x, y, z, (float) yaw, (float) pitch); } } - for(String s : config.getConfigurationSection(ConfigEntries.FIREWORK_POS.path).getKeys(false)) + for(String s : config.getConfigurationSection(ConfigEntry.FIREWORK_POS.path).getKeys(false)) { - String currentPath = ConfigEntries.FIREWORK_POS.path + "." + s; + String currentPath = ConfigEntry.FIREWORK_POS.path + "." + s; String world = config.getString(currentPath + ".world"); double x = config.getDouble(currentPath + ".x"); double y = config.getDouble(currentPath + ".y"); diff --git a/src/main/java/wtf/beatrice/uhccore/utils/configuration/LocalizedMessages.java b/src/main/java/wtf/beatrice/uhccore/utils/configuration/LocalizedMessage.java similarity index 84% rename from src/main/java/wtf/beatrice/uhccore/utils/configuration/LocalizedMessages.java rename to src/main/java/wtf/beatrice/uhccore/utils/configuration/LocalizedMessage.java index da399a5..e999ed3 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/configuration/LocalizedMessages.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/configuration/LocalizedMessage.java @@ -1,6 +1,6 @@ package wtf.beatrice.uhccore.utils.configuration; -public enum LocalizedMessages { +public enum LocalizedMessage { INFO("info"), PLAYER_POSITION("player_position"), @@ -15,7 +15,7 @@ public enum LocalizedMessages { public String path; - LocalizedMessages(String path) + LocalizedMessage(String path) { this.path = path; }