diff --git a/config.yml b/config.yml index 30001f23..ed4cb6c6 100644 --- a/config.yml +++ b/config.yml @@ -13,13 +13,19 @@ Island: # [!] If you go over 1000, the size of the Island will be 100. Size: 100 Creation: + # Rather than opening the 'Island Creator' menu. Create an island + # as soon as a player performs the '/island' or '/island create' + # command. + # [!] The first created structure will be selected. + Menu: + Enable: true Cooldown: # When enabled cooldown will start when a player creates an Island. Creation: - Enable: true + Enable: false # When enabled cooldown will start when a player deletes their Island. Deletion: - Enable: true + Enable: false Time: 300 World: # [!] The Island height is 72 blocks. diff --git a/language.yml b/language.yml index 0cbb36af..0783ca50 100644 --- a/language.yml +++ b/language.yml @@ -234,6 +234,29 @@ Command: Message: "&bSkyBlock &8| &aInfo&8: &eYou have demoted the player &d%player &eto a &dMember&e." Target: Message: "&bSkyBlock &8| &aInfo&8: &eYou have been demoted to a &dMember&e." + Vote: + Info: + Message: "Add/Remove a vote for a players Island." + Invalid: + Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island vote " + Disabled: + Message: "&bSkyBlock &8| &cError&8: &eYou cannot vote for that Island because voting is disabled." + Island: + None: + Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island." + Unloaded: + Message: "&bSkyBlock &8| &cError&8: &eThere are no members of that Island online." + Closed: + Message: "&bSkyBlock &8| &cError&8: &eYou cannot vote for that Island because it is closed." + Member: + Message: "&bSkyBlock &8| &cError&8: &eYou cannot vote for that Island because you are a member of it." + Location: + Message: "&bSkyBlock &8| &cError&8: &eYou must be at that players Island to vote." + Vote: + Added: + Message: "&bSkyBlock &8| &aInfo&8: &eYour vote has been &a&lADDED &efor &a%player's &eIsland." + Removed: + Message: "&bSkyBlock &8| &aInfo&8: &eYour vote has been &c&lREMOVED &efor &a%player's &eIsland." Kick: Info: Message: "&f&oRemove a Member or Visitor from your Island." @@ -532,6 +555,9 @@ Command: Private: Message: "&bSkyBlock &8| &aInfo&8: &eYour Island is now &cPrivate&e." Admin: + Help: + Permission: + Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command." Create: Info: Message: "&f&oManage Structures for the Island Creator menu." @@ -701,11 +727,6 @@ Island: Message: "&bSkyBlock &8| &aInfo&8: &eYour vote has been &a&lADDED &efor &a%player's &eIsland." Removed: Message: "&bSkyBlock &8| &aInfo&8: &eYour vote has been &c&lREMOVED &efor &a%player's &eIsland." - Location: - Add: - Message: "&bSkyBlock &8| &cError&8: &eYou must be at the Island to add a vote." - Remove: - Message: "&bSkyBlock &8| &cError&8: &eYou must be at the Island to remove your vote." Banned: Message: "&bSkyBlock &8| &aInfo&8: &eYou have been banned from the Island." Structure: diff --git a/plugin.yml b/plugin.yml index 0d345210..a074872d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkyBlock main: me.goodandevil.skyblock.Main -version: 24 +version: 25 api-version: 1.13 description: A unique SkyBlock plugin author: GoodAndEvil diff --git a/src/me/goodandevil/skyblock/Main.java b/src/me/goodandevil/skyblock/Main.java index 26a2619c..7095ab2f 100644 --- a/src/me/goodandevil/skyblock/Main.java +++ b/src/me/goodandevil/skyblock/Main.java @@ -11,6 +11,7 @@ import me.goodandevil.skyblock.biome.BiomeManager; import me.goodandevil.skyblock.command.CommandManager; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.confirmation.ConfirmationTask; +import me.goodandevil.skyblock.creation.CreationManager; import me.goodandevil.skyblock.generator.GeneratorManager; import me.goodandevil.skyblock.invite.InviteManager; import me.goodandevil.skyblock.island.IslandManager; @@ -41,11 +42,11 @@ import me.goodandevil.skyblock.menus.Members; import me.goodandevil.skyblock.menus.Ownership; import me.goodandevil.skyblock.menus.Rollback; import me.goodandevil.skyblock.menus.Settings; -import me.goodandevil.skyblock.menus.Structure; import me.goodandevil.skyblock.menus.Visit; import me.goodandevil.skyblock.menus.Visitors; import me.goodandevil.skyblock.menus.Weather; import me.goodandevil.skyblock.menus.admin.Generator; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.placeholder.PlaceholderManager; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.playtime.PlaytimeTask; @@ -66,7 +67,7 @@ public class Main extends JavaPlugin { private VisitManager visitManager; private BanManager banManager; private IslandManager islandManager; - //private CreationManager creationManager; + private CreationManager creationManager; private PlayerDataManager playerDataManager; private ScoreboardManager scoreboardManager; private InviteManager inviteManager; @@ -78,6 +79,7 @@ public class Main extends JavaPlugin { private GeneratorManager generatorManager; private PlaceholderManager placeholderManager; private LeaderboardManager leaderboardManager; + private MessageManager messageManager; @Override public void onEnable() { @@ -88,7 +90,7 @@ public class Main extends JavaPlugin { visitManager = new VisitManager(this); banManager = new BanManager(this); islandManager = new IslandManager(this); - //creationManager = new CreationManager(this); + creationManager = new CreationManager(this); playerDataManager = new PlayerDataManager(this); if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) { @@ -110,6 +112,7 @@ public class Main extends JavaPlugin { placeholderManager.registerPlaceholders(); leaderboardManager = new LeaderboardManager(this); + messageManager = new MessageManager(this); new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L); new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L); @@ -144,7 +147,6 @@ public class Main extends JavaPlugin { pluginManager.registerEvents(new Bans(), this); pluginManager.registerEvents(new ControlPanel(), this); pluginManager.registerEvents(new Creator(), this); - pluginManager.registerEvents(new Structure(), this); pluginManager.registerEvents(new Leaderboard(), this); pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Levelling(), this); @@ -175,6 +177,10 @@ public class Main extends JavaPlugin { this.biomeManager.onDisable(); } + if (this.creationManager != null) { + this.creationManager.onDisable(); + } + if (this.playerDataManager != null) { this.playerDataManager.onDisable(); } @@ -204,9 +210,9 @@ public class Main extends JavaPlugin { return islandManager; } - /*public CreationManager getCreationManager() { + public CreationManager getCreationManager() { return creationManager; - }*/ + } public PlayerDataManager getPlayerDataManager() { return playerDataManager; @@ -252,6 +258,10 @@ public class Main extends JavaPlugin { return leaderboardManager; } + public MessageManager getMessageManager() { + return messageManager; + } + @Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { return new VoidGenerator(); diff --git a/src/me/goodandevil/skyblock/ban/BanManager.java b/src/me/goodandevil/skyblock/ban/BanManager.java index d8ac0692..991f9cb4 100644 --- a/src/me/goodandevil/skyblock/ban/BanManager.java +++ b/src/me/goodandevil/skyblock/ban/BanManager.java @@ -6,7 +6,6 @@ import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.utils.world.LocationUtil; @@ -72,6 +72,7 @@ public class BanManager { } public void removeVisitor(Island island) { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -83,7 +84,7 @@ public class BanManager { LocationUtil.teleportPlayerToSpawn(targetPlayer); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Banned.Message"))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Banned.Message")); soundManager.playSound(targetPlayer, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/CommandManager.java b/src/me/goodandevil/skyblock/command/CommandManager.java index 27b5d689..16646e32 100644 --- a/src/me/goodandevil/skyblock/command/CommandManager.java +++ b/src/me/goodandevil/skyblock/command/CommandManager.java @@ -6,6 +6,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -47,6 +48,7 @@ import me.goodandevil.skyblock.command.commands.TeleportCommand; import me.goodandevil.skyblock.command.commands.UnbanCommand; import me.goodandevil.skyblock.command.commands.VisitCommand; import me.goodandevil.skyblock.command.commands.VisitorsCommand; +import me.goodandevil.skyblock.command.commands.VoteCommand; import me.goodandevil.skyblock.command.commands.WeatherCommand; import me.goodandevil.skyblock.command.commands.admin.GeneratorCommand; import me.goodandevil.skyblock.command.commands.admin.ReloadCommand; @@ -54,7 +56,7 @@ import me.goodandevil.skyblock.command.commands.admin.StructureCommand; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.menus.ControlPanel; -import me.goodandevil.skyblock.menus.Creator; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.ChatComponent; import me.goodandevil.skyblock.utils.version.Sounds; @@ -83,6 +85,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { List subCommands = new ArrayList<>(); subCommands.add(new VisitCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visit.Info.Message")))); + subCommands.add(new VoteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Vote.Info.Message")))); subCommands.add(new ControlPanelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.ControlPanel.Info.Message")))); subCommands.add(new LeaderboardCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Leaderboard.Info.Message")))); subCommands.add(new CreateCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Create.Info.Message")))); @@ -145,6 +148,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { new BukkitRunnable() { @Override public void run() { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -154,12 +158,11 @@ public class CommandManager implements CommandExecutor, TabCompleter { if (args.length == 0) { if (plugin.getIslandManager().hasIsland(player)) { ControlPanel.getInstance().open(player); + soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - Creator.getInstance().open(player); + Bukkit.getServer().dispatchCommand(player, "island create"); } - soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); - return; } @@ -175,7 +178,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { if (args[1].matches("[0-9]+")) { page = Integer.valueOf(args[1]); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Integer.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Help.Integer.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -188,24 +191,29 @@ public class CommandManager implements CommandExecutor, TabCompleter { return; } else if (args[0].equalsIgnoreCase("admin")) { if (args.length == 1 || (args.length >= 2 && args[1].equalsIgnoreCase("help"))) { - int page = -1; - - if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Command.Help.List")) { - page = 1; + if (player.hasPermission("skyblock.admin") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) { + int page = -1; - if (args.length == 3) { - if (args[2].matches("[0-9]+")) { - page = Integer.valueOf(args[2]); - } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Help.Integer.Message"))); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); - - return; + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Command.Help.List")) { + page = 1; + + if (args.length == 3) { + if (args[2].matches("[0-9]+")) { + page = Integer.valueOf(args[2]); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Help.Integer.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } } } + + sendHelpCommands(player, CommandManager.Type.Admin, page); + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Help.Permission.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } - - sendHelpCommands(player, CommandManager.Type.Admin, page); return; } @@ -216,7 +224,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { } if (subCommand == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Argument.Unrecognised.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Argument.Unrecognised.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } else { ArrayList arguments = new ArrayList<>(); @@ -253,8 +261,10 @@ public class CommandManager implements CommandExecutor, TabCompleter { commandAliases.add(subCommandList.getName()); } } else { - if ("admin".contains(args[0].toLowerCase())) { - commandAliases.add("admin"); + if (sender.hasPermission("skyblock.admin") || sender.hasPermission("skyblock.admin.*") || sender.hasPermission("skyblock.*")) { + if ("admin".contains(args[0].toLowerCase())) { + commandAliases.add("admin"); + } } for (SubCommand subCommandList : subCommands.get(Type.Default)) { @@ -264,31 +274,35 @@ public class CommandManager implements CommandExecutor, TabCompleter { } } } else if (args.length == 2) { - if (args[0].equalsIgnoreCase("admin")) { - if (args[1] == null || args[1].isEmpty()) { - for (SubCommand subCommandList : subCommands.get(Type.Admin)) { - commandAliases.add(subCommandList.getName()); - } - } else { - for (SubCommand subCommandList : subCommands.get(Type.Admin)) { - if (subCommandList.getName().toLowerCase().contains(args[1].toLowerCase())) { + if (sender.hasPermission("skyblock.admin") || sender.hasPermission("skyblock.admin.*") || sender.hasPermission("skyblock.*")) { + if (args[0].equalsIgnoreCase("admin")) { + if (args[1] == null || args[1].isEmpty()) { + for (SubCommand subCommandList : subCommands.get(Type.Admin)) { commandAliases.add(subCommandList.getName()); } + } else { + for (SubCommand subCommandList : subCommands.get(Type.Admin)) { + if (subCommandList.getName().toLowerCase().contains(args[1].toLowerCase())) { + commandAliases.add(subCommandList.getName()); + } + } } } } } else if (args.length == 3) { - if (args[0].equalsIgnoreCase("admin") && args[1].equalsIgnoreCase("structure")) { - if (args[2] == null || args[2].isEmpty()) { - commandAliases.add("tool"); - commandAliases.add("save"); - } else { - if ("tool".contains(args[2].toLowerCase())) { + if (sender.hasPermission("skyblock.admin") || sender.hasPermission("skyblock.admin.*") || sender.hasPermission("skyblock.*")) { + if (args[0].equalsIgnoreCase("admin") && args[1].equalsIgnoreCase("structure")) { + if (args[2] == null || args[2].isEmpty()) { commandAliases.add("tool"); - } - - if ("save".contains(args[2].toLowerCase())) { - commandAliases.add("save"); + commandAliases.add("save"); + } else { + if ("tool".contains(args[2].toLowerCase())) { + commandAliases.add("tool"); + } + + if ("save".contains(args[2].toLowerCase())) { + commandAliases.add("save"); + } } } } @@ -382,7 +396,7 @@ public class CommandManager implements CommandExecutor, TabCompleter { } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', helpLines)); + plugin.getMessageManager().sendMessage(player, helpLines); } } diff --git a/src/me/goodandevil/skyblock/command/commands/AcceptCommand.java b/src/me/goodandevil/skyblock/command/commands/AcceptCommand.java index e074e61f..b0bf869b 100644 --- a/src/me/goodandevil/skyblock/command/commands/AcceptCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/AcceptCommand.java @@ -24,6 +24,7 @@ import me.goodandevil.skyblock.invite.InviteManager; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; @@ -44,6 +45,7 @@ public class AcceptCommand extends SubCommand { public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -64,7 +66,7 @@ public class AcceptCommand extends SubCommand { inviteManager.removeInvite(player.getUniqueId()); if (islandManager.hasIsland(player)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { boolean unloadIsland = false; @@ -89,11 +91,11 @@ public class AcceptCommand extends SubCommand { Player targetPlayer = Bukkit.getServer().getPlayer(invite.getSenderUUID()); if (targetPlayer != null) { - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Accepted.Target.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Accept.Accepted.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Accepted.Sender.Message").replace("%player", invite.getSenderName()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Accepted.Sender.Message").replace("%player", invite.getSenderName())); soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); playerData.setPlaytime(0); @@ -182,15 +184,15 @@ public class AcceptCommand extends SubCommand { } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Invited.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Invited.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Invite.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Invite.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Accept.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Accept.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/BanCommand.java b/src/me/goodandevil/skyblock/command/commands/BanCommand.java index 4ac0a6e0..0d5318de 100644 --- a/src/me/goodandevil/skyblock/command/commands/BanCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/BanCommand.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -15,6 +14,7 @@ import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -38,6 +38,7 @@ public class BanCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -68,19 +69,19 @@ public class BanCommand extends SubCommand { } if (targetPlayerUUID == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Found.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Found.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (targetPlayerUUID.equals(player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID) || island.isRole(Role.Owner, targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.getBan().isBanned(targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); Ban ban = island.getBan(); @@ -88,7 +89,7 @@ public class BanCommand extends SubCommand { ban.save(); if (targetPlayer != null) { - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Banned.Target.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Ban.Banned.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); for (Location.World worldList : Location.World.values()) { @@ -101,19 +102,19 @@ public class BanCommand extends SubCommand { } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ban.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/BansCommand.java b/src/me/goodandevil/skyblock/command/commands/BansCommand.java index bfa8e36c..710e1fa4 100644 --- a/src/me/goodandevil/skyblock/command/commands/BansCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/BansCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -15,6 +14,7 @@ import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; import me.goodandevil.skyblock.menus.Bans; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -29,6 +29,7 @@ public class BansCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -40,18 +41,18 @@ public class BansCommand extends SubCommand { if ((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Unban").getStatus()) || island.isRole(Role.Owner, player.getUniqueId())) { if (island.getBan().getBans().size() == 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Bans.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Bans.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Bans.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/BiomeCommand.java b/src/me/goodandevil/skyblock/command/commands/BiomeCommand.java index 2fe2617d..804e8a3b 100644 --- a/src/me/goodandevil/skyblock/command/commands/BiomeCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/BiomeCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class BiomeCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -41,11 +42,11 @@ public class BiomeCommand extends SubCommand { me.goodandevil.skyblock.menus.Biome.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Biome.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Biome.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Biome.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/CancelCommand.java b/src/me/goodandevil/skyblock/command/commands/CancelCommand.java index aa81d621..f19b747b 100644 --- a/src/me/goodandevil/skyblock/command/commands/CancelCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/CancelCommand.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -16,6 +15,7 @@ import me.goodandevil.skyblock.invite.Invite; import me.goodandevil.skyblock.invite.InviteManager; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -30,6 +30,7 @@ public class CancelCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); InviteManager inviteManager = plugin.getInviteManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -46,10 +47,10 @@ public class CancelCommand extends SubCommand { Player targetPlayer = Bukkit.getServer().getPlayer(playerName); if (targetPlayer == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Offline.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Offline.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId()) || island.isRole(Role.Owner, targetPlayer.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (inviteManager.hasInvite(targetPlayer.getUniqueId())) { Invite invite = inviteManager.getInvite(targetPlayer.getUniqueId()); @@ -57,26 +58,26 @@ public class CancelCommand extends SubCommand { if (invite.getOwnerUUID().equals(island.getOwnerUUID())) { inviteManager.removeInvite(targetPlayer.getUniqueId()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Cancelled.Message").replace("%player", targetPlayer.getName()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Cancelled.Message").replace("%player", targetPlayer.getName())); soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Invited.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Invited.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Invited.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Invited.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Owner.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Cancel.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Cancel.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/ChatCommand.java b/src/me/goodandevil/skyblock/command/commands/ChatCommand.java index 8f355d97..91c48bcb 100644 --- a/src/me/goodandevil/skyblock/command/commands/ChatCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/ChatCommand.java @@ -5,7 +5,6 @@ import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -15,6 +14,7 @@ import me.goodandevil.skyblock.events.IslandChatSwitchEvent; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -35,6 +35,7 @@ public class ChatCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -46,7 +47,7 @@ public class ChatCommand extends SubCommand { Island island = islandManager.getIsland(playerData.getOwner()); if ((island.getRole(Role.Member).size() + island.getRole(Role.Operator).size()) == 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Team.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Team.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Map playerDataStorage = playerDataManager.getPlayerData(); @@ -58,11 +59,11 @@ public class ChatCommand extends SubCommand { if (targetPlayerData.getOwner().equals(playerData.getOwner())) { if (playerData.isChat()) { Bukkit.getServer().getPluginManager().callEvent(new IslandChatSwitchEvent(player, island, false)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Untoggled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Untoggled.Message")); playerData.setChat(false); } else { Bukkit.getServer().getPluginManager().callEvent(new IslandChatSwitchEvent(player, island, true)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Toggled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Toggled.Message")); playerData.setChat(true); } @@ -73,11 +74,11 @@ public class ChatCommand extends SubCommand { } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Offline.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Offline.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Chat.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Chat.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/CloseCommand.java b/src/me/goodandevil/skyblock/command/commands/CloseCommand.java index 1ad05b7c..4238f486 100644 --- a/src/me/goodandevil/skyblock/command/commands/CloseCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/CloseCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class CloseCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -41,18 +42,18 @@ public class CloseCommand extends SubCommand { if (island.isOpen()) { islandManager.closeIsland(island); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Closed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Closed.Message")); soundManager.playSound(player, Sounds.DOOR_CLOSE.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Close.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Close.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java b/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java index 54d06f2c..f20ed2bc 100644 --- a/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/ConfirmCommand.java @@ -19,6 +19,7 @@ import me.goodandevil.skyblock.confirmation.Confirmation; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.scoreboard.Scoreboard; import me.goodandevil.skyblock.scoreboard.ScoreboardManager; @@ -39,6 +40,7 @@ public class ConfirmCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -59,7 +61,7 @@ public class ConfirmCommand extends SubCommand { UUID targetPlayerUUID = playerData.getOwnership(); if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Confirmed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Confirmed.Message")); String targetPlayerName; Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID); @@ -68,7 +70,7 @@ public class ConfirmCommand extends SubCommand { targetPlayerName = new OfflinePlayer(targetPlayerUUID).getName(); } else { targetPlayerName = targetPlayer.getName(); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Ownership.Assigned.Message"))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Confirmation.Ownership.Assigned.Message")); soundManager.playSound(targetPlayer, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); } @@ -84,14 +86,14 @@ public class ConfirmCommand extends SubCommand { islandManager.giveIslandOwnership(targetPlayerUUID); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Ownership.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Ownership.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else if (confirmation == Confirmation.Deletion) { playerData.setConfirmation(null); playerData.setConfirmationTime(0); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Confirmed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Confirmed.Message")); boolean hasSpawnPoint = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") != null; @@ -128,23 +130,23 @@ public class ConfirmCommand extends SubCommand { plugin.getVisitManager().deleteIsland(player.getUniqueId()); plugin.getBanManager().deleteIsland(player.getUniqueId()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message")); soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Role.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Specified.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Specified.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Pending.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Pending.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/ControlPanelCommand.java b/src/me/goodandevil/skyblock/command/commands/ControlPanelCommand.java index cf1d315b..741de790 100644 --- a/src/me/goodandevil/skyblock/command/commands/ControlPanelCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/ControlPanelCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -35,7 +34,7 @@ public class ControlPanelCommand extends SubCommand { ControlPanel.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.ControlPanel.Owner.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.ControlPanel.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/CreateCommand.java b/src/me/goodandevil/skyblock/command/commands/CreateCommand.java index afbb612d..b352204a 100644 --- a/src/me/goodandevil/skyblock/command/commands/CreateCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/CreateCommand.java @@ -1,8 +1,9 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; +import java.util.List; -import org.bukkit.ChatColor; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -10,10 +11,16 @@ import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.command.CommandManager; import me.goodandevil.skyblock.command.SubCommand; import me.goodandevil.skyblock.command.CommandManager.Type; +import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.creation.Creation; +import me.goodandevil.skyblock.creation.CreationManager; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.menus.Creator; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; +import me.goodandevil.skyblock.structure.Structure; +import me.goodandevil.skyblock.utils.NumberUtil; import me.goodandevil.skyblock.utils.version.Sounds; public class CreateCommand extends SubCommand { @@ -27,19 +34,63 @@ public class CreateCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + CreationManager creationManager = plugin.getCreationManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (islandManager.hasIsland(player)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Create.Owner.Message"))); - soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); - } else { - Creator.getInstance().open(player); - soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); - } + Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() { + @Override + public void run() { + if (islandManager.hasIsland(player)) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Create.Owner.Message")); + soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); + } else { + Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + + if (mainConfig.getFileConfiguration().getBoolean("Island.Creation.Menu.Enable")) { + Creator.getInstance().open(player); + soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); + } else { + List structures = plugin.getStructureManager().getStructures(); + + if (structures.size() == 0) { + messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.None.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } else if (!fileManager.isFileExist(new File(new File(plugin.getDataFolder().toString() + "/structures"), structures.get(0).getFile()))) { + messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") && creationManager.hasPlayer(player)) { + Creation creation = creationManager.getPlayer(player); + + if (creation.getTime() < 60) { + messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", creation.getTime() + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second"))); + } else { + long[] durationTime = NumberUtil.getDuration(creation.getTime()); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second"))); + } + + soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); + + return; + } + + islandManager.createIsland(player, structures.get(0)); + + messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message")); + soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); + } + } + } + }); } @Override diff --git a/src/me/goodandevil/skyblock/command/commands/CurrentCommand.java b/src/me/goodandevil/skyblock/command/commands/CurrentCommand.java index 3e41f8e8..ef657da3 100644 --- a/src/me/goodandevil/skyblock/command/commands/CurrentCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/CurrentCommand.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -12,6 +11,7 @@ import me.goodandevil.skyblock.command.CommandManager; import me.goodandevil.skyblock.command.SubCommand; import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -30,6 +30,7 @@ public class CurrentCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); @@ -42,7 +43,7 @@ public class CurrentCommand extends SubCommand { Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); if (targetPlayer == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Offline.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Offline.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -52,7 +53,7 @@ public class CurrentCommand extends SubCommand { PlayerData playerData = playerDataManager.getPlayerData(targetPlayer); if (playerData.getIsland() == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.None.Other.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Island.None.Other.Message")); } else { String targetPlayerName = targetPlayer.getName(), ownerPlayerName; targetPlayer = Bukkit.getServer().getPlayer(playerData.getIsland()); @@ -63,7 +64,7 @@ public class CurrentCommand extends SubCommand { ownerPlayerName = targetPlayer.getName(); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.Owner.Other.Message").replace("%target", targetPlayerName).replace("%owner", ownerPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Island.Owner.Other.Message").replace("%target", targetPlayerName).replace("%owner", ownerPlayerName)); } soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); @@ -71,13 +72,13 @@ public class CurrentCommand extends SubCommand { return; } } else if (args.length > 1) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -88,7 +89,7 @@ public class CurrentCommand extends SubCommand { PlayerData playerData = playerDataManager.getPlayerData(player); if (playerData.getIsland() == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.None.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Island.None.Yourself.Message")); } else { Player targetPlayer = Bukkit.getServer().getPlayer(playerData.getIsland()); String targetPlayerName; @@ -99,7 +100,7 @@ public class CurrentCommand extends SubCommand { targetPlayerName = targetPlayer.getName(); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Current.Island.Owner.Yourself.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Current.Island.Owner.Yourself.Message").replace("%player", targetPlayerName)); } soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); diff --git a/src/me/goodandevil/skyblock/command/commands/DeleteCommand.java b/src/me/goodandevil/skyblock/command/commands/DeleteCommand.java index 2b36fdb5..c01281ea 100644 --- a/src/me/goodandevil/skyblock/command/commands/DeleteCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/DeleteCommand.java @@ -14,6 +14,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.confirmation.Confirmation; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.ChatComponent; @@ -35,6 +36,7 @@ public class DeleteCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -47,7 +49,7 @@ public class DeleteCommand extends SubCommand { if (islandManager.hasIsland(player)) { if (islandManager.getIsland(playerData.getOwner()).isRole(Role.Owner, player.getUniqueId())) { if (playerData.getConfirmationTime() > 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Confirmation.Pending.Message")); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } else { int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Confirmation.Timeout"); @@ -59,11 +61,11 @@ public class DeleteCommand extends SubCommand { soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Delete.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Delete.Owner.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/DemoteCommand.java b/src/me/goodandevil/skyblock/command/commands/DemoteCommand.java index 28afb68e..ea0dfea0 100644 --- a/src/me/goodandevil/skyblock/command/commands/DemoteCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/DemoteCommand.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -16,6 +15,7 @@ import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.OfflinePlayer; @@ -32,6 +32,7 @@ public class DemoteCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -51,10 +52,10 @@ public class DemoteCommand extends SubCommand { if (targetPlayer.getUniqueId() != null && (islandMembers.contains(targetPlayer.getUniqueId()) || island.getRole(Role.Operator).contains(targetPlayer.getUniqueId()))) { if (islandMembers.contains(targetPlayer.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Role.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Promoted.Sender.Message").replace("%player", targetPlayer.getName()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Promoted.Sender.Message").replace("%player", targetPlayer.getName())); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); island.removeRole(Role.Operator, targetPlayer.getUniqueId()); @@ -62,7 +63,7 @@ public class DemoteCommand extends SubCommand { island.save(); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { @@ -70,11 +71,11 @@ public class DemoteCommand extends SubCommand { if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId())) { if (island.isRole(Role.Member, targetPlayer.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Role.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Demoted.Sender.Message").replace("%player", targetPlayer.getName()))); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Demoted.Target.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Demoted.Sender.Message").replace("%player", targetPlayer.getName())); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Demote.Demoted.Target.Message")); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); @@ -83,20 +84,20 @@ public class DemoteCommand extends SubCommand { island.save(); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Demote.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Demote.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/DenyCommand.java b/src/me/goodandevil/skyblock/command/commands/DenyCommand.java index 1365eb81..01d168ca 100644 --- a/src/me/goodandevil/skyblock/command/commands/DenyCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/DenyCommand.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.invite.Invite; import me.goodandevil.skyblock.invite.InviteManager; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,14 +28,14 @@ public class DenyCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); + InviteManager inviteManager = plugin.getInviteManager(); SoundManager soundManager = plugin.getSoundManager(); Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (args.length == 1) { - InviteManager inviteManager = plugin.getInviteManager(); - if (inviteManager.hasInvite(player.getUniqueId())) { Invite invite = inviteManager.getInvite(player.getUniqueId()); String playerName = args[0]; @@ -44,24 +44,24 @@ public class DenyCommand extends SubCommand { Player targetPlayer = Bukkit.getServer().getPlayer(invite.getSenderUUID()); if (targetPlayer != null) { - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Denied.Target.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Deny.Denied.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Denied.Sender.Message").replace("%player", invite.getSenderName()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Denied.Sender.Message").replace("%player", invite.getSenderName())); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F); inviteManager.removeInvite(player.getUniqueId()); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Invited.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Invited.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Invited.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Invited.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Deny.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Deny.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/InviteCommand.java b/src/me/goodandevil/skyblock/command/commands/InviteCommand.java index 9e83f161..6885b200 100644 --- a/src/me/goodandevil/skyblock/command/commands/InviteCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/InviteCommand.java @@ -17,6 +17,7 @@ import me.goodandevil.skyblock.invite.Invite; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.ChatComponent; import me.goodandevil.skyblock.utils.version.Sounds; @@ -37,6 +38,7 @@ public class InviteCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -52,34 +54,34 @@ public class InviteCommand extends SubCommand { Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); if ((island.getRole(Role.Member).size() + island.getRole(Role.Operator).size() + 1) >= mainConfig.getFileConfiguration().getInt("Island.Member.Capacity")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Capacity.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Capacity.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { String playerName = args[0]; if (playerName.equalsIgnoreCase(player.getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Player targetPlayer = Bukkit.getServer().getPlayer(playerName); if (targetPlayer == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Offline.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Offline.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (targetPlayer.getName().equalsIgnoreCase(player.getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId()) || island.isRole(Role.Owner, targetPlayer.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (plugin.getInviteManager().hasInvite(targetPlayer.getUniqueId())) { Invite invite = plugin.getInviteManager().getInvite(targetPlayer.getUniqueId()); if (invite.getOwnerUUID().equals(island.getOwnerUUID())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Already.Own.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Already.Own.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Already.Other.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Already.Other.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { @@ -103,15 +105,15 @@ public class InviteCommand extends SubCommand { } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Owner.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/KickAllCommand.java b/src/me/goodandevil/skyblock/command/commands/KickAllCommand.java index f1ef47fc..7d534975 100644 --- a/src/me/goodandevil/skyblock/command/commands/KickAllCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/KickAllCommand.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -19,6 +18,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -37,6 +37,7 @@ public class KickAllCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -52,7 +53,7 @@ public class KickAllCommand extends SubCommand { List islandVisitors = island.getVisitors(); if (islandVisitors.size() == 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Visitors.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Visitors.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { for (UUID islandVisitorList : islandVisitors) { @@ -64,24 +65,24 @@ public class KickAllCommand extends SubCommand { if (!islandKickEvent.isCancelled()) { LocationUtil.teleportPlayerToSpawn(targetPlayer); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Kicked.Target.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.KickAll.Kicked.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Kicked.Sender.Message").replace("%visitors", "" + islandVisitors.size()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Kicked.Sender.Message").replace("%visitors", "" + islandVisitors.size())); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Closed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Closed.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Role.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Role.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.KickAll.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.KickAll.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/KickCommand.java b/src/me/goodandevil/skyblock/command/commands/KickCommand.java index 0f10cf6c..1723f3b0 100644 --- a/src/me/goodandevil/skyblock/command/commands/KickCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/KickCommand.java @@ -21,6 +21,7 @@ import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; @@ -43,6 +44,7 @@ public class KickCommand extends SubCommand { public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -75,13 +77,13 @@ public class KickCommand extends SubCommand { } if (targetPlayerUUID.equals(player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (islandOperators.contains(player.getUniqueId()) && islandOperators.contains(targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Operator.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Operator.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.getOwnerUUID().equals(targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (isOpen && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) { IslandKickEvent islandKickEvent = new IslandKickEvent(island, Role.Visitor, targetPlayerUUID, player); @@ -90,10 +92,10 @@ public class KickCommand extends SubCommand { if (!islandKickEvent.isCancelled()) { LocationUtil.teleportPlayerToSpawn(targetPlayer); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } } else if (islandMembers.contains(targetPlayerUUID) || islandOperators.contains(targetPlayerUUID)) { @@ -107,7 +109,7 @@ public class KickCommand extends SubCommand { Bukkit.getServer().getPluginManager().callEvent(islandKickEvent); if (!islandKickEvent.isCancelled()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); if (targetPlayer == null) { @@ -124,7 +126,7 @@ public class KickCommand extends SubCommand { e.printStackTrace(); } } else { - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName())); soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); for (Location.World worldList : Location.World.values()) { @@ -169,7 +171,7 @@ public class KickCommand extends SubCommand { if (targetPlayerData.isChat()) { targetPlayerData.setChat(false); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message"))); + messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message")); } } } @@ -193,28 +195,28 @@ public class KickCommand extends SubCommand { } } else { if (isOpen) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message")); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message")); } soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { if (isOpen) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message")); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message")); } soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/LeaveCommand.java b/src/me/goodandevil/skyblock/command/commands/LeaveCommand.java index 820b02e1..4a188b8c 100644 --- a/src/me/goodandevil/skyblock/command/commands/LeaveCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/LeaveCommand.java @@ -18,6 +18,7 @@ import me.goodandevil.skyblock.events.IslandLeaveEvent; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; @@ -39,6 +40,7 @@ public class LeaveCommand extends SubCommand { public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -51,7 +53,7 @@ public class LeaveCommand extends SubCommand { me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner()); if (island.isRole(Role.Owner, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Owner.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Leave.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { IslandLeaveEvent islandLeaveEvent = new IslandLeaveEvent(player, island); @@ -90,7 +92,7 @@ public class LeaveCommand extends SubCommand { if (targetPlayerData.isChat()) { targetPlayerData.setChat(false); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message"))); + messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message")); } } } @@ -123,7 +125,7 @@ public class LeaveCommand extends SubCommand { } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Left.Sender.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Leave.Left.Sender.Message")); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F); if (scoreboardManager != null) { @@ -136,7 +138,7 @@ public class LeaveCommand extends SubCommand { } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Command.Island.Leave.Member.Message"))); + messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Leave.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/LevelCommand.java b/src/me/goodandevil/skyblock/command/commands/LevelCommand.java index 93052081..2d24f885 100644 --- a/src/me/goodandevil/skyblock/command/commands/LevelCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/LevelCommand.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -16,6 +15,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.levelling.LevellingManager; import me.goodandevil.skyblock.menus.Levelling; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.NumberUtil; @@ -35,6 +35,7 @@ public class LevelCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); VisitManager visitManager = plugin.getVisitManager(); @@ -58,7 +59,7 @@ public class LevelCommand extends SubCommand { } if (islandOwnerUUID == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Owner.Other.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Other.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -66,25 +67,25 @@ public class LevelCommand extends SubCommand { if (visitManager.hasIsland(islandOwnerUUID)) { me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Level.Message").replace("%player", targetPlayerName).replace("%level", "" + visit.getLevel()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Level.Message").replace("%player", targetPlayerName).replace("%level", "" + visit.getLevel())); soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); return; } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Owner.Other.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Other.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else if (args.length != 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -103,11 +104,11 @@ public class LevelCommand extends SubCommand { long[] durationTime = NumberUtil.getDuration(levelling.getTime()); if (levelling.getTime() >= 3600) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second")))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second"))); } else if (levelling.getTime() >= 60) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second")))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second"))); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second")))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second"))); } soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); @@ -115,19 +116,19 @@ public class LevelCommand extends SubCommand { return; } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Processing.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Processing.Message")); soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); levellingManager.createLevelling(island.getOwnerUUID()); levellingManager.loadLevelling(island.getOwnerUUID()); levellingManager.calculatePoints(player, island); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Loading.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Loading.Message")); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); Levelling.getInstance().open(player); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Owner.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/MembersCommand.java b/src/me/goodandevil/skyblock/command/commands/MembersCommand.java index 4c15981a..d4d30147 100644 --- a/src/me/goodandevil/skyblock/command/commands/MembersCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/MembersCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import me.goodandevil.skyblock.Main; @@ -35,7 +34,7 @@ public class MembersCommand extends SubCommand { Members.getInstance().open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort()); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Settings.Owner.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Settings.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/OpenCommand.java b/src/me/goodandevil/skyblock/command/commands/OpenCommand.java index c8580ec8..859361ff 100644 --- a/src/me/goodandevil/skyblock/command/commands/OpenCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/OpenCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class OpenCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -39,20 +40,20 @@ public class OpenCommand extends SubCommand { if (island.isRole(Role.Owner, player.getUniqueId()) || (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Visitor").getStatus())) { if (island.isOpen()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { island.setOpen(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Opened.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Opened.Message")); soundManager.playSound(player, Sounds.DOOR_OPEN.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Open.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Open.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/OwnerCommand.java b/src/me/goodandevil/skyblock/command/commands/OwnerCommand.java index dc82a77d..2ca74924 100644 --- a/src/me/goodandevil/skyblock/command/commands/OwnerCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/OwnerCommand.java @@ -17,6 +17,7 @@ import me.goodandevil.skyblock.confirmation.Confirmation; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.menus.Ownership; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.ChatComponent; @@ -39,6 +40,7 @@ public class OwnerCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -62,7 +64,7 @@ public class OwnerCommand extends SubCommand { } else if (args.length == 1) { if (island.isRole(Role.Owner, player.getUniqueId())) { if (playerData.getConfirmationTime() > 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Confirmation.Pending.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Confirmation.Pending.Message")); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } else { UUID targetPlayerUUID; @@ -80,10 +82,10 @@ public class OwnerCommand extends SubCommand { } if (targetPlayerUUID == null || (!island.isRole(Role.Member, targetPlayerUUID) && !island.isRole(Role.Operator, targetPlayerUUID) && !island.isRole(Role.Owner, targetPlayerUUID))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (targetPlayerUUID.equals(player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Confirmation.Timeout"); @@ -106,16 +108,16 @@ public class OwnerCommand extends SubCommand { } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Assigned.Sender.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Assigned.Sender.Message")); soundManager.playSound(player, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); islandManager.giveIslandOwnership(player.getUniqueId()); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Password.Incorrect.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Password.Incorrect.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Password.Unset.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Password.Unset.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -123,10 +125,10 @@ public class OwnerCommand extends SubCommand { return; } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/PromoteCommand.java b/src/me/goodandevil/skyblock/command/commands/PromoteCommand.java index 8fa46a81..dab8e155 100644 --- a/src/me/goodandevil/skyblock/command/commands/PromoteCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/PromoteCommand.java @@ -16,6 +16,7 @@ import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -34,6 +35,7 @@ public class PromoteCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -53,10 +55,10 @@ public class PromoteCommand extends SubCommand { if (targetPlayer.getUniqueId() != null && (island.getRole(Role.Member).contains(targetPlayer.getUniqueId()) || islandOperators.contains(targetPlayer.getUniqueId()))) { if (islandOperators.contains(targetPlayer.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Operator.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Operator.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Sender.Message").replace("%player", targetPlayer.getName()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Promoted.Sender.Message").replace("%player", targetPlayer.getName())); for (Player all : Bukkit.getOnlinePlayers()) { if (islandManager.hasIsland(all)) { @@ -77,7 +79,7 @@ public class PromoteCommand extends SubCommand { island.save(); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { @@ -85,11 +87,11 @@ public class PromoteCommand extends SubCommand { if (island.isRole(Role.Member, targetPlayer.getUniqueId()) || island.isRole(Role.Operator, targetPlayer.getUniqueId())) { if (island.isRole(Role.Operator, targetPlayer.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Operator.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Operator.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Sender.Message").replace("%player", targetPlayer.getName()))); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Promoted.Target.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Promoted.Sender.Message").replace("%player", targetPlayer.getName())); + messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Promote.Promoted.Target.Message")); for (Player all : Bukkit.getOnlinePlayers()) { if (islandManager.hasIsland(all)) { @@ -108,20 +110,20 @@ public class PromoteCommand extends SubCommand { island.setRole(Role.Operator, targetPlayer.getUniqueId()); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Promote.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Promote.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/PublicCommand.java b/src/me/goodandevil/skyblock/command/commands/PublicCommand.java index 294c6c26..5a45a2f6 100644 --- a/src/me/goodandevil/skyblock/command/commands/PublicCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/PublicCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class PublicCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -41,20 +42,20 @@ public class PublicCommand extends SubCommand { if (island.isOpen()) { islandManager.closeIsland(island); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Private.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Private.Message")); soundManager.playSound(player, Sounds.DOOR_CLOSE.bukkitSound(), 1.0F, 1.0F); } else { island.setOpen(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Public.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Public.Message")); soundManager.playSound(player, Sounds.DOOR_OPEN.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Public.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Public.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/RollbackCommand.java b/src/me/goodandevil/skyblock/command/commands/RollbackCommand.java index 18943cfd..7b0f1f9e 100644 --- a/src/me/goodandevil/skyblock/command/commands/RollbackCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/RollbackCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.menus.Rollback; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class RollbackCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -41,11 +42,11 @@ public class RollbackCommand extends SubCommand { Rollback.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Rollback.Role.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Rollback.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Rollback.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Rollback.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/SetSpawnCommand.java b/src/me/goodandevil/skyblock/command/commands/SetSpawnCommand.java index 10154dfc..4815f42d 100644 --- a/src/me/goodandevil/skyblock/command/commands/SetSpawnCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/SetSpawnCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; @@ -19,6 +18,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Materials; import me.goodandevil.skyblock.utils.version.Sounds; @@ -37,6 +37,7 @@ public class SetSpawnCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -51,7 +52,7 @@ public class SetSpawnCommand extends SubCommand { } else if (args[0].equalsIgnoreCase("Visitor")) { locationEnvironment = me.goodandevil.skyblock.island.Location.Environment.Visitor; } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Spawn.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Spawn.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -67,22 +68,22 @@ public class SetSpawnCommand extends SubCommand { if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { if (location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR || location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Materials.LEGACY_PISTON_MOVING_PIECE.getPostMaterial()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } else if (location.getY() - location.getBlockY() != 0.0D) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } else if (location.getBlock().isLiquid() || location.clone().add(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } else if (location.getBlock().getType() == Materials.NETHER_PORTAL.parseMaterial() || location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Materials.NETHER_PORTAL.parseMaterial()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -103,7 +104,7 @@ public class SetSpawnCommand extends SubCommand { } }.runTask(plugin); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Protection.Centre.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Protection.Centre.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -113,29 +114,29 @@ public class SetSpawnCommand extends SubCommand { island.setLocation(worldList, locationEnvironment, location); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn", locationEnvironment.name().toLowerCase()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn", locationEnvironment.name().toLowerCase())); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); return; } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn", locationEnvironment.name().toLowerCase()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn", locationEnvironment.name().toLowerCase())); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn", locationEnvironment.name().toLowerCase()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn", locationEnvironment.name().toLowerCase())); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Role.Message").replace("%spawn", locationEnvironment.name().toLowerCase()))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Role.Message").replace("%spawn", locationEnvironment.name().toLowerCase())); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.SetSpawn.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/SettingsCommand.java b/src/me/goodandevil/skyblock/command/commands/SettingsCommand.java index 6ca15491..347cba14 100644 --- a/src/me/goodandevil/skyblock/command/commands/SettingsCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/SettingsCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class SettingsCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -42,15 +43,15 @@ public class SettingsCommand extends SubCommand { me.goodandevil.skyblock.menus.Settings.getInstance().open(player, me.goodandevil.skyblock.menus.Settings.Type.Categories, null, null); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Permission.Default.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Settings.Permission.Default.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Role.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Settings.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Settings.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/TeleportCommand.java b/src/me/goodandevil/skyblock/command/commands/TeleportCommand.java index 50cf8f96..26219d54 100644 --- a/src/me/goodandevil/skyblock/command/commands/TeleportCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/TeleportCommand.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.command.SubCommand; import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Location; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -33,6 +33,7 @@ public class TeleportCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); VisitManager visitManager = plugin.getVisitManager(); @@ -56,7 +57,7 @@ public class TeleportCommand extends SubCommand { } if (islandOwnerUUID == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Island.None.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.None.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -64,43 +65,43 @@ public class TeleportCommand extends SubCommand { if (visitManager.hasIsland(islandOwnerUUID)) { me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID); - if (visit.isOpen()) { + if (player.hasPermission("skyblock.bypass") || player.hasPermission("skyblock.bypass.*") || player.hasPermission("skyblock.*") || visit.isOpen()) { if (!islandManager.containsIsland(islandOwnerUUID)) { islandManager.loadIsland(islandOwnerUUID); } islandManager.visitIsland(player, islandManager.getIsland(islandOwnerUUID)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Island.Closed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.Closed.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } return; } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Island.None.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.None.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else if (args.length != 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } if (islandManager.hasIsland(player)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message")); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); me.goodandevil.skyblock.island.Island island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner()); @@ -112,7 +113,7 @@ public class TeleportCommand extends SubCommand { } }); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Teleport.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/UnbanCommand.java b/src/me/goodandevil/skyblock/command/commands/UnbanCommand.java index 36374a49..162633f2 100644 --- a/src/me/goodandevil/skyblock/command/commands/UnbanCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/UnbanCommand.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -18,6 +17,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -36,6 +36,7 @@ public class UnbanCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -66,19 +67,19 @@ public class UnbanCommand extends SubCommand { } if (targetPlayerUUID == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Found.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Found.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (targetPlayerUUID.equals(player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Yourself.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Yourself.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.isRole(Role.Member, targetPlayerUUID) || island.isRole(Role.Operator, targetPlayerUUID) || island.isRole(Role.Owner, targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Member.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Member.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!island.getBan().isBanned(targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Banned.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Banned.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Unbanned.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Unbanned.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); Ban ban = island.getBan(); @@ -86,19 +87,19 @@ public class UnbanCommand extends SubCommand { ban.save(); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Unban.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/VisitorsCommand.java b/src/me/goodandevil/skyblock/command/commands/VisitorsCommand.java index 25872002..3ae99dff 100644 --- a/src/me/goodandevil/skyblock/command/commands/VisitorsCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/VisitorsCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -10,6 +9,7 @@ import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.menus.Visitors; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class VisitorsCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -39,17 +40,17 @@ public class VisitorsCommand extends SubCommand { me.goodandevil.skyblock.island.Island island = islandManager.getIsland(playerData.getOwner()); if (!island.isOpen()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Closed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Visitors.Closed.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (island.getVisitors().size() == 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Visitors.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Visitors.Visitors.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Visitors.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Visitors.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/VoteCommand.java b/src/me/goodandevil/skyblock/command/commands/VoteCommand.java new file mode 100644 index 00000000..975c85c3 --- /dev/null +++ b/src/me/goodandevil/skyblock/command/commands/VoteCommand.java @@ -0,0 +1,150 @@ +package me.goodandevil.skyblock.command.commands; + +import java.io.File; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import me.goodandevil.skyblock.Main; +import me.goodandevil.skyblock.command.CommandManager; +import me.goodandevil.skyblock.command.SubCommand; +import me.goodandevil.skyblock.command.CommandManager.Type; +import me.goodandevil.skyblock.config.FileManager; +import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.island.Island; +import me.goodandevil.skyblock.island.IslandManager; +import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; +import me.goodandevil.skyblock.playerdata.PlayerData; +import me.goodandevil.skyblock.playerdata.PlayerDataManager; +import me.goodandevil.skyblock.sound.SoundManager; +import me.goodandevil.skyblock.utils.OfflinePlayer; +import me.goodandevil.skyblock.utils.version.Sounds; +import me.goodandevil.skyblock.visit.VisitManager; + +public class VoteCommand extends SubCommand { + + private final Main plugin; + private String info; + + public VoteCommand(Main plugin) { + this.plugin = plugin; + } + + @Override + public void onCommand(Player player, String[] args) { + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + VisitManager visitManager = plugin.getVisitManager(); + FileManager fileManager = plugin.getFileManager(); + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (args.length == 1) { + if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Disabled.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } + + Player targetPlayer = Bukkit.getServer().getPlayer(args[0]); + UUID islandOwnerUUID; + String targetPlayerName; + + if (targetPlayer == null) { + OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]); + islandOwnerUUID = targetPlayerOffline.getOwner(); + targetPlayerName = targetPlayerOffline.getName(); + } else { + islandOwnerUUID = playerDataManager.getPlayerData(player).getOwner(); + targetPlayerName = targetPlayer.getName(); + } + + if (islandOwnerUUID == null) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Island.None.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } else if (!visitManager.hasIsland(islandOwnerUUID)) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Island.Unloaded.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } else { + me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(islandOwnerUUID); + + if (visit.isOpen()) { + if (!islandManager.containsIsland(islandOwnerUUID)) { + islandManager.loadIsland(islandOwnerUUID); + } + + Island island = islandManager.getIsland(islandOwnerUUID); + + if (island.isRole(Role.Member, player.getUniqueId()) || island.isRole(Role.Operator, player.getUniqueId()) || island.isRole(Role.Owner, player.getUniqueId())) { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Island.Member.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } else if (!playerDataManager.hasPlayerData(player)) { + PlayerData playerData = playerDataManager.getPlayerData(player); + + if (playerData.getIsland() != null && playerData.getIsland().equals(island.getOwnerUUID())) { + List islandVotes = visit.getVoters(); + + if (islandVotes.contains(player.getUniqueId())) { + visit.removeVoter(player.getUniqueId()); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Vote.Removed.Message").replace("%player", targetPlayerName)); + soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F); + } else { + visit.addVoter(player.getUniqueId()); + + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Vote.Added.Message").replace("%player", targetPlayerName)); + soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); + } + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Island.Location.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } + + islandManager.unloadIsland(islandOwnerUUID); + } + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Island.Closed.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } + } + } else { + messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Invalid.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } + } + + @Override + public String getName() { + return "vote"; + } + + @Override + public String getInfo() { + return info; + } + + @Override + public SubCommand setInfo(String info) { + this.info = info; + + return this; + } + + @Override + public String[] getAliases() { + return new String[0]; + } + + @Override + public Type getType() { + return CommandManager.Type.Default; + } +} diff --git a/src/me/goodandevil/skyblock/command/commands/WeatherCommand.java b/src/me/goodandevil/skyblock/command/commands/WeatherCommand.java index 76558065..fa4ac81d 100644 --- a/src/me/goodandevil/skyblock/command/commands/WeatherCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/WeatherCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -15,6 +14,7 @@ import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; import me.goodandevil.skyblock.menus.Weather; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -29,6 +29,7 @@ public class WeatherCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -42,11 +43,11 @@ public class WeatherCommand extends SubCommand { Weather.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Weather.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Weather.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Weather.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Weather.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/CreateCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/CreateCommand.java index 30a04e04..f3a2bb37 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/CreateCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/CreateCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands.admin; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -43,7 +42,7 @@ public class CreateCommand extends SubCommand { Creator.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Create.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Admin.Create.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/DeleteCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/DeleteCommand.java index 9e34bcc8..0ce7cf30 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/DeleteCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/DeleteCommand.java @@ -19,6 +19,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; import me.goodandevil.skyblock.scoreboard.ScoreboardManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -38,6 +39,7 @@ public class DeleteCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -99,18 +101,18 @@ public class DeleteCommand extends SubCommand { plugin.getVisitManager().deleteIsland(player.getUniqueId()); plugin.getBanManager().deleteIsland(player.getUniqueId()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Delete.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Delete.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Delete.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/GeneratorCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/GeneratorCommand.java index b6b27233..2275d353 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/GeneratorCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/GeneratorCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands.admin; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -13,6 +12,7 @@ import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.menus.admin.Generator; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -29,6 +29,7 @@ public class GeneratorCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -36,10 +37,10 @@ public class GeneratorCommand extends SubCommand { FileConfiguration configLoad = config.getFileConfiguration(); if (!(player.hasPermission("skyblock.admin.generator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Generator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Generator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (plugin.getGeneratorManager() == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Generator.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Generator.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { if (playerDataManager.hasPlayerData(player)) { diff --git a/src/me/goodandevil/skyblock/command/commands/admin/LevelCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/LevelCommand.java index 30e8e9da..b266ecd8 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/LevelCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/LevelCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands.admin; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -37,7 +36,7 @@ public class LevelCommand extends SubCommand { Levelling.getInstance().open(player); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Level.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Admin.Level.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/OwnerCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/OwnerCommand.java index 19ae4bc9..2e45783e 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/OwnerCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/OwnerCommand.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.command.SubCommand; import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.OfflinePlayer; @@ -31,6 +31,7 @@ public class OwnerCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -55,10 +56,10 @@ public class OwnerCommand extends SubCommand { } if (islandOwnerUUID == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Island.None.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Owner.Island.None.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } else if (islandOwnerUUID.equals(targetPlayerUUID)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Island.Owner.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Owner.Island.Owner.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); } else { targetPlayer = Bukkit.getServer().getPlayer(islandOwnerUUID); @@ -69,15 +70,15 @@ public class OwnerCommand extends SubCommand { islandOwnerName = targetPlayer.getName(); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Island.Member.Message").replace("%player", targetPlayerName).replace("%owner", islandOwnerName))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Owner.Island.Member.Message").replace("%player", targetPlayerName).replace("%owner", islandOwnerName)); soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Owner.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Owner.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/ReloadCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/ReloadCommand.java index a8889365..2b3d95eb 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/ReloadCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/ReloadCommand.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.command.commands.admin; import java.io.File; import java.util.Map; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -13,6 +12,7 @@ import me.goodandevil.skyblock.command.SubCommand; import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -27,6 +27,7 @@ public class ReloadCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -50,10 +51,10 @@ public class ReloadCommand extends SubCommand { plugin.getScoreboardManager().resendScoreboard(); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message")); soundManager.playSound(player, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Reload.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Reload.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/SetSpawnCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/SetSpawnCommand.java index 03437458..c3eca965 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/SetSpawnCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/SetSpawnCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands.admin; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.World; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -14,6 +13,7 @@ import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Location; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -28,6 +28,7 @@ public class SetSpawnCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -39,7 +40,7 @@ public class SetSpawnCommand extends SubCommand { World world = plugin.getWorldManager().getWorld(worldList); if (world.getName().equals(player.getWorld().getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.World.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.World.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -47,10 +48,10 @@ public class SetSpawnCommand extends SubCommand { } fileManager.setLocation(fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")), "Location.Spawn", player.getLocation(), true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.Set.Message")); soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.SetSpawn.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java index 488404ac..b3492b2a 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.command.commands.admin; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -37,7 +36,7 @@ public class SettingsCommand extends SubCommand { Settings.getInstance().open(player, Settings.Type.Categories, null); soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Admin.Settings.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/command/commands/admin/StructureCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/StructureCommand.java index 07b7db10..4f7135c7 100644 --- a/src/me/goodandevil/skyblock/command/commands/admin/StructureCommand.java +++ b/src/me/goodandevil/skyblock/command/commands/admin/StructureCommand.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import me.goodandevil.skyblock.command.CommandManager.Type; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.ChatComponent; @@ -35,6 +36,7 @@ public class StructureCommand extends SubCommand { @Override public void onCommand(Player player, String[] args) { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); @@ -61,7 +63,7 @@ public class StructureCommand extends SubCommand { player.spigot().sendMessage(new ChatComponent(prefix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Info.Message"))) + "/island admin structure tool" + suffix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Info.Message"))), false, null, null, new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Info.Message"))).create())).getTextComponent()); player.spigot().sendMessage(new ChatComponent(prefix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Info.Message"))) + "/island admin structure save" + suffix.replace("%info", ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Info.Message"))), false, null, null, new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Info.Message"))).create())).getTextComponent()); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', helpLines)); + messageManager.sendMessage(player, helpLines); } } @@ -77,7 +79,7 @@ public class StructureCommand extends SubCommand { for (ItemStack itemList : player.getInventory().getContents()) { if (itemList != null) { if ((itemList.getType() == is.getType()) && (itemList.hasItemMeta()) && (itemList.getItemMeta().getDisplayName().equals(is.getItemMeta().getDisplayName()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Inventory.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Tool.Inventory.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -86,16 +88,16 @@ public class StructureCommand extends SubCommand { } player.getInventory().addItem(is); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Equiped.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Tool.Equiped.Message")); soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F); } catch (Exception e) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Structure.Tool.Material.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Structure.Tool.Material.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: The defined material in the configuration file for the Structure selection tool could not be found."); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Tool.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } @@ -109,46 +111,46 @@ public class StructureCommand extends SubCommand { Location position2Location = playerData.getArea().getPosition(2); if (position1Location == null && position2Location == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Position.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Position.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if ((position1Location == null && position2Location != null) || (position1Location != null && position2Location == null)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Complete.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Complete.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!position1Location.getWorld().getName().equals(position2Location.getWorld().getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Selection.World.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Selection.World.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!player.getWorld().getName().equals(position1Location.getWorld().getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Player.World.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Player.World.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!LocationUtil.isInsideArea(player.getLocation(), position1Location, position2Location)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Player.Area.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Player.Area.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { try { File configFile = new File(plugin.getDataFolder().toString() + "/structures/" + args[1] + ".structure"); StructureUtil.saveStructure(configFile, player.getLocation(), StructureUtil.getFixedLocations(position1Location, position2Location)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Saved.Successful.Message").replace("%name", args[1]))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Saved.Successful.Message").replace("%name", args[1])); soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); } catch(Exception e) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Saved.Failed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Saved.Failed.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); e.printStackTrace(); } } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Save.Invalid.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Save.Invalid.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Tool.Save.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Structure.Tool.Save.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } return; } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Argument.Unrecognised.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Argument.Unrecognised.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/config/FileChecker.java b/src/me/goodandevil/skyblock/config/FileChecker.java index 1640b4a3..52bb1bf9 100644 --- a/src/me/goodandevil/skyblock/config/FileChecker.java +++ b/src/me/goodandevil/skyblock/config/FileChecker.java @@ -14,14 +14,20 @@ import me.goodandevil.skyblock.Main; public class FileChecker { + private final Main plugin; + private final FileManager fileManager; + private Map loadedFiles; - public FileChecker(Main plugin, String configurationFileName) { + public FileChecker(Main plugin, FileManager fileManager, String configurationFileName) { + this.plugin = plugin; + this.fileManager = fileManager; + loadedFiles = new EnumMap<>(File.Type.class); java.io.File configFile = new java.io.File(plugin.getDataFolder(), configurationFileName); - loadedFiles.put(File.Type.CREATED, new File(configFile, YamlConfiguration.loadConfiguration(configFile))); - loadedFiles.put(File.Type.RESOURCE, new File(null, YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getResource(configurationFileName))))); + loadedFiles.put(File.Type.CREATED, new File(fileManager, configFile, YamlConfiguration.loadConfiguration(configFile))); + loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(plugin.getResource(configurationFileName))))); } public void loadSections() { @@ -45,18 +51,22 @@ public class FileChecker { if (fileType == File.Type.CREATED) { File resourceFile = loadedFiles.get(File.Type.RESOURCE); - for (String configKeysList : file.getKeys().keySet()) { - if (!resourceFile.getKeys().containsKey(configKeysList)) { - configLoad.set(configKeysList, null); + for (String configKeyList : file.getKeys().keySet()) { + if (!configKeyList.contains(plugin.getDescription().getName() + "_COMMENT")) { + if (!resourceFile.getKeys().containsKey(configKeyList)) { + configLoad.set(configKeyList, null); + } } } } else if (fileType == File.Type.RESOURCE) { File createdFile = loadedFiles.get(File.Type.CREATED); FileConfiguration createdConfigLoad = createdFile.getFileConfiguration(); - for (String configKeysList : file.getKeys().keySet()) { - if (createdConfigLoad.getString(configKeysList) == null) { - createdConfigLoad.set(configKeysList, file.getKeys().get(configKeysList)); + for (String configKeyList : file.getKeys().keySet()) { + if (!configKeyList.contains(plugin.getDescription().getName() + "_COMMENT")) { + if (createdConfigLoad.getString(configKeyList) == null) { + createdConfigLoad.set(configKeyList, file.getKeys().get(configKeyList)); + } } } } @@ -67,7 +77,11 @@ public class FileChecker { File file = loadedFiles.get(File.Type.CREATED); try { - file.getFileConfiguration().save(file.getFile()); + if (file.getFile().getName().equals("config.yml")) { + fileManager.saveConfig(file.getFileConfiguration().saveToString(), file.getFile()); + } else { + file.getFileConfiguration().save(file.getFile()); + } } catch (IOException e) { e.printStackTrace(); } @@ -80,10 +94,14 @@ public class FileChecker { private HashMap configKeys; - public File(java.io.File configFile, FileConfiguration configLoad) { + public File(FileManager fileManager, java.io.File configFile, FileConfiguration configLoad) { this.configFile = configFile; this.configLoad = configLoad; configKeys = new HashMap<>(); + + if (configFile != null) { + this.configLoad = YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile))); + } } public java.io.File getFile() { diff --git a/src/me/goodandevil/skyblock/config/FileManager.java b/src/me/goodandevil/skyblock/config/FileManager.java index ca220bf3..b7709f04 100644 --- a/src/me/goodandevil/skyblock/config/FileManager.java +++ b/src/me/goodandevil/skyblock/config/FileManager.java @@ -1,10 +1,17 @@ package me.goodandevil.skyblock.config; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; @@ -52,7 +59,7 @@ public class FileManager { if (configFile.exists()) { if (configFileList.equals("config.yml") || configFileList.equals("language.yml") || configFileList.equals("settings.yml")) { - FileChecker fileChecker = new FileChecker(plugin, configFileList); + FileChecker fileChecker = new FileChecker(plugin, this, configFileList); fileChecker.loadSections(); fileChecker.compareFiles(); fileChecker.saveChanges(); @@ -142,7 +149,7 @@ public class FileManager { return loadedConfigs.get(configPath.getPath()); } - Config config = new Config(configPath); + Config config = new Config(this, configPath); loadedConfigs.put(configPath.getPath(), config); return config; @@ -156,14 +163,79 @@ public class FileManager { return loadedConfigs.containsKey(configPath.getPath()); } + public InputStream getConfigContent(File configFile) { + if(!configFile.exists()) { + return null; + } + + try { + String addLine, currentLine, pluginName = plugin.getDescription().getName(); + int commentNum = 0; + + StringBuilder whole = new StringBuilder(""); + BufferedReader reader = new BufferedReader(new FileReader(configFile)); + + while((currentLine = reader.readLine()) != null) { + if(currentLine.contains("#")) { + addLine = currentLine.replace("[!]", "IMPORTANT").replace(":", "-").replaceFirst("#", pluginName + "_COMMENT_" + commentNum + ":"); + whole.append(addLine + "\n"); + commentNum++; + } else { + whole.append(currentLine + "\n"); + } + } + + String config = whole.toString(); + InputStream configStream = new ByteArrayInputStream(config.getBytes(Charset.forName("UTF-8"))); + reader.close(); + + return configStream; + } catch (IOException e) { + e.printStackTrace(); + + return null; + } + } + + private String prepareConfigString(String configString) { + String[] lines = configString.split("\n"); + StringBuilder config = new StringBuilder(""); + + for(String line : lines) { + if(line.contains(plugin.getDescription().getName() + "_COMMENT")) { + config.append(line.replace("IMPORTANT", "[!]").replace("\n", "").replace(plugin.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "") + "\n"); + } else { + config.append(line + "\n"); + } + } + + return config.toString(); + } + + public void saveConfig(String configString, File configFile) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(configFile)); + writer.write(prepareConfigString(configString)); + writer.flush(); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + public static class Config { private File configFile; private FileConfiguration configLoad; - public Config(java.io.File configPath) { + public Config(FileManager fileManager, java.io.File configPath) { configFile = configPath; - configLoad = YamlConfiguration.loadConfiguration(configFile); + + if (configPath.getName().equals("config.yml")) { + configLoad = YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile))); + } else { + configLoad = YamlConfiguration.loadConfiguration(configPath); + } } public File getFile() { diff --git a/src/me/goodandevil/skyblock/creation/CreationTask.java b/src/me/goodandevil/skyblock/creation/CreationTask.java index 360e7c18..473f9f15 100644 --- a/src/me/goodandevil/skyblock/creation/CreationTask.java +++ b/src/me/goodandevil/skyblock/creation/CreationTask.java @@ -16,17 +16,17 @@ public class CreationTask extends BukkitRunnable { @Override public void run() { - /*CreationManager creationManager = plugin.getCreationManager(); + CreationManager creationManager = plugin.getCreationManager(); for (Player all : Bukkit.getOnlinePlayers()) { if (creationManager.hasPlayer(all)) { Creation creation = creationManager.getPlayer(all); creation.setTime(creation.getTime() - 1); - if (creation.getTime() == 0) { + if (creation.getTime() <= 0) { creationManager.removePlayer(all); } } - }*/ + } } } diff --git a/src/me/goodandevil/skyblock/invite/InviteTask.java b/src/me/goodandevil/skyblock/invite/InviteTask.java index b49b639a..fae3758e 100644 --- a/src/me/goodandevil/skyblock/invite/InviteTask.java +++ b/src/me/goodandevil/skyblock/invite/InviteTask.java @@ -9,6 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.ChatComponent; import me.goodandevil.skyblock.utils.version.Sounds; @@ -30,6 +31,7 @@ public class InviteTask extends BukkitRunnable { @Override public void run() { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); @@ -48,7 +50,7 @@ public class InviteTask extends BukkitRunnable { soundManager.playSound(targetPlayer, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } - all.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Invite.Invited.Target.Expired.Message").replace("%player", invite.getSenderName()))); + messageManager.sendMessage(all, configLoad.getString("Command.Island.Invite.Invited.Target.Expired.Message").replace("%player", invite.getSenderName())); soundManager.playSound(all, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); inviteManager.removeInvite(all.getUniqueId()); diff --git a/src/me/goodandevil/skyblock/island/Island.java b/src/me/goodandevil/skyblock/island/Island.java index a22ef8e2..e8ead671 100644 --- a/src/me/goodandevil/skyblock/island/Island.java +++ b/src/me/goodandevil/skyblock/island/Island.java @@ -17,7 +17,6 @@ import org.bukkit.Material; import org.bukkit.WeatherType; import org.bukkit.block.Biome; import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.scheduler.BukkitRunnable; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.ban.Ban; @@ -136,14 +135,16 @@ public class Island { playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date())); playerData.save(); - new BukkitRunnable() { - @Override - public void run() { - islandNormalLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE); - islandManager.setSpawnProtection(islandNormalLocation); - islandManager.setSpawnProtection(islandNetherLocation); - } - }.runTask(plugin); + if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) { + Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() { + @Override + public void run() { + islandNormalLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE); + islandManager.setSpawnProtection(islandNormalLocation); + islandManager.setSpawnProtection(islandNetherLocation); + } + }); + } } level = new Level(getOwnerUUID(), plugin); @@ -178,8 +179,8 @@ public class Island { return size; } - public int getRadius() { - return size / 2; + public double getRadius() { + return (size / 2) + 0.5; } public boolean hasPassword() { diff --git a/src/me/goodandevil/skyblock/island/IslandManager.java b/src/me/goodandevil/skyblock/island/IslandManager.java index 52fae264..d688c5fd 100644 --- a/src/me/goodandevil/skyblock/island/IslandManager.java +++ b/src/me/goodandevil/skyblock/island/IslandManager.java @@ -31,6 +31,7 @@ import me.goodandevil.skyblock.events.IslandUnloadEvent; import me.goodandevil.skyblock.invite.Invite; import me.goodandevil.skyblock.invite.InviteManager; import me.goodandevil.skyblock.island.Location.World; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; @@ -71,15 +72,14 @@ public class IslandManager { } public void onDisable() { - saveNextAvailableLocation(); - for (Player all : Bukkit.getOnlinePlayers()) { unloadIsland(all.getUniqueId()); } } public void saveNextAvailableLocation() { - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileManager fileManager = plugin.getFileManager(); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); File configFile = config.getFile(); FileConfiguration configLoad = config.getFileConfiguration(); @@ -94,11 +94,7 @@ public class IslandManager { } } - try { - configLoad.save(configFile); - } catch (IOException e) { - e.printStackTrace(); - } + fileManager.saveConfig(configLoad.saveToString(), configFile); } public void setNextAvailableLocation(Location.World world, org.bukkit.Location location) { @@ -154,9 +150,9 @@ public class IslandManager { Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - /*if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable")) { + if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable")) { plugin.getCreationManager().createPlayer(player, configLoad.getInt("Island.Creation.Cooldown.Time")); - }*/ + } Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(player, island)); @@ -303,12 +299,16 @@ public class IslandManager { FileManager fileManager = plugin.getFileManager(); fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml")); - /*Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - if (configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable")) { - plugin.getCreationManager().createPlayer(island.getOwnerUUID(), configLoad.getInt("Island.Creation.Cooldown.Time")); - }*/ + Player player = Bukkit.getServer().getPlayer(island.getOwnerUUID()); + + if (player != null) { + if (configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable")) { + plugin.getCreationManager().createPlayer(player, configLoad.getInt("Island.Creation.Cooldown.Time")); + } + } Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island)); @@ -484,6 +484,11 @@ public class IslandManager { } public void closeIsland(Island island) { + MessageManager messageManager = plugin.getMessageManager(); + + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + island.setOpen(false); UUID islandOwnerUUID = island.getOwnerUUID(); @@ -496,15 +501,12 @@ public class IslandManager { islandOwnerPlayerName = islandOwnerPlayer.getName(); } - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - for (UUID visitorList : island.getVisitors()) { Player targetPlayer = Bukkit.getServer().getPlayer(visitorList); LocationUtil.teleportPlayerToSpawn(targetPlayer); - - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName))); + + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", islandOwnerPlayerName)); } } @@ -574,7 +576,9 @@ public class IslandManager { for (Location.World worldList : Location.World.values()) { if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { - if (!island.getSetting(Settings.Role.Visitor, setting).getStatus()) { + if (player.hasPermission("skyblock.bypass." + setting.toLowerCase()) || player.hasPermission("skyblock.bypass.*") || player.hasPermission("skyblock.*")) { + return true; + } else if (!island.getSetting(Settings.Role.Visitor, setting).getStatus()) { return false; } @@ -672,7 +676,7 @@ public class IslandManager { } if (configLoad.getBoolean("Island.WorldBorder.Enable")) { - WorldBorder.send(player, island.getSize(), island.getLocation(Location.World.Normal, Location.Environment.Island)); + WorldBorder.send(player, island.getSize() + 2.5, island.getLocation(Location.World.Normal, Location.Environment.Island)); } } } diff --git a/src/me/goodandevil/skyblock/levelling/LevellingManager.java b/src/me/goodandevil/skyblock/levelling/LevellingManager.java index e4acf3e9..e8b7e7f5 100644 --- a/src/me/goodandevil/skyblock/levelling/LevellingManager.java +++ b/src/me/goodandevil/skyblock/levelling/LevellingManager.java @@ -12,7 +12,6 @@ import java.util.UUID; import java.util.logging.Level; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.ChunkSnapshot; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -148,7 +147,7 @@ public class LevellingManager { } if (materials.size() == 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Materials.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Materials.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } else { me.goodandevil.skyblock.island.Level level = island.getLevel(); diff --git a/src/me/goodandevil/skyblock/listeners/Block.java b/src/me/goodandevil/skyblock/listeners/Block.java index 27200ccd..daea61b3 100644 --- a/src/me/goodandevil/skyblock/listeners/Block.java +++ b/src/me/goodandevil/skyblock/listeners/Block.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.configuration.file.FileConfiguration; @@ -95,7 +94,7 @@ public class Block implements Listener { } else { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } @@ -146,7 +145,7 @@ public class Block implements Listener { } else { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } diff --git a/src/me/goodandevil/skyblock/listeners/Bucket.java b/src/me/goodandevil/skyblock/listeners/Bucket.java index e87cfc36..305599d9 100644 --- a/src/me/goodandevil/skyblock/listeners/Bucket.java +++ b/src/me/goodandevil/skyblock/listeners/Bucket.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.listeners; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -31,7 +30,7 @@ public class Bucket implements Listener { if (!plugin.getIslandManager().hasPermission(player, "Bucket")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/listeners/Chat.java b/src/me/goodandevil/skyblock/listeners/Chat.java index ff68fe0a..394dc024 100644 --- a/src/me/goodandevil/skyblock/listeners/Chat.java +++ b/src/me/goodandevil/skyblock/listeners/Chat.java @@ -35,32 +35,34 @@ public class Chat implements Listener { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); IslandManager islandManager = plugin.getIslandManager(); - PlayerData playerData = playerDataManager.getPlayerData(player); - - if (playerData.isChat()) { - event.setCancelled(true); + if (playerDataManager.hasPlayerData(player)) { + PlayerData playerData = playerDataManager.getPlayerData(player); - Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - Island island = plugin.getIslandManager().getIsland(playerData.getOwner()); - String islandRole = ""; - - if (island.isRole(Role.Member, player.getUniqueId())) { - islandRole = configLoad.getString("Island.Chat.Format.Role.Member"); - } else if (island.isRole(Role.Operator, player.getUniqueId())) { - islandRole = configLoad.getString("Island.Chat.Format.Role.Operator"); - } else if (island.isRole(Role.Owner, player.getUniqueId())) { - islandRole = configLoad.getString("Island.Chat.Format.Role.Owner"); - } - - IslandChatEvent islandChatEvent = new IslandChatEvent(player, island, event.getMessage(), configLoad.getString("Island.Chat.Format.Message")); - Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); - - if (!islandChatEvent.isCancelled()) { - for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) { - Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())).replace("%message", islandChatEvent.getMessage())); + if (playerData.isChat()) { + event.setCancelled(true); + + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + Island island = plugin.getIslandManager().getIsland(playerData.getOwner()); + String islandRole = ""; + + if (island.isRole(Role.Member, player.getUniqueId())) { + islandRole = configLoad.getString("Island.Chat.Format.Role.Member"); + } else if (island.isRole(Role.Operator, player.getUniqueId())) { + islandRole = configLoad.getString("Island.Chat.Format.Role.Operator"); + } else if (island.isRole(Role.Owner, player.getUniqueId())) { + islandRole = configLoad.getString("Island.Chat.Format.Role.Owner"); + } + + IslandChatEvent islandChatEvent = new IslandChatEvent(player, island, event.getMessage(), configLoad.getString("Island.Chat.Format.Message")); + Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); + + if (!islandChatEvent.isCancelled()) { + for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) { + Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); + targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())).replace("%message", islandChatEvent.getMessage())); + } } } } diff --git a/src/me/goodandevil/skyblock/listeners/Entity.java b/src/me/goodandevil/skyblock/listeners/Entity.java index 8ddd4404..097b0029 100644 --- a/src/me/goodandevil/skyblock/listeners/Entity.java +++ b/src/me/goodandevil/skyblock/listeners/Entity.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -24,6 +23,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.utils.world.LocationUtil; @@ -38,6 +38,7 @@ public class Entity implements Listener { @EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); if (event.getDamager() instanceof Player) { @@ -64,7 +65,7 @@ public class Entity implements Listener { if (!plugin.getIslandManager().hasPermission(player, "MobHurting")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -81,7 +82,7 @@ public class Entity implements Listener { if (!plugin.getIslandManager().hasPermission(player, "Destroy")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -95,7 +96,7 @@ public class Entity implements Listener { if (!plugin.getIslandManager().hasPermission(player, "Destroy")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -112,7 +113,7 @@ public class Entity implements Listener { if (!plugin.getIslandManager().hasPermission(player, "Shearing")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -127,7 +128,7 @@ public class Entity implements Listener { if (!plugin.getIslandManager().hasPermission(player, "MobTaming")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/listeners/Interact.java b/src/me/goodandevil/skyblock/listeners/Interact.java index 9bd501f6..6c02e44a 100644 --- a/src/me/goodandevil/skyblock/listeners/Interact.java +++ b/src/me/goodandevil/skyblock/listeners/Interact.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.listeners; import java.io.File; import java.util.Set; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType; @@ -19,6 +18,7 @@ import org.bukkit.inventory.ItemStack; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.island.Location; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.utils.structure.StructureUtil; @@ -38,6 +38,7 @@ public class Interact implements Listener { public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -47,7 +48,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Anvil")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -56,7 +57,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Beacon")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -65,7 +66,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Bed")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -74,7 +75,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Brewing")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -83,7 +84,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Storage")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -92,7 +93,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Workbench")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -101,7 +102,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Door")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -110,7 +111,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Enchant")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -119,7 +120,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Furnace")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -128,7 +129,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "LeverButton")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -137,7 +138,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Jukebox")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -146,7 +147,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Redstone")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -155,7 +156,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Gate")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -164,7 +165,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "DropperDispenser")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -173,7 +174,7 @@ public class Interact implements Listener { if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, "Cake")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -182,7 +183,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "DragonEggUse")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -191,7 +192,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Hopper")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -203,7 +204,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Bucket")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else if (event.getItem().getType() == Material.GLASS_BOTTLE) { @@ -211,7 +212,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "WaterCollection")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -219,7 +220,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "SpawnEgg")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -236,7 +237,7 @@ public class Interact implements Listener { plugin.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "2"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "2")); soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F); } } @@ -248,7 +249,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Fire")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -264,7 +265,7 @@ public class Interact implements Listener { plugin.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "1"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "1")); soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F); } } @@ -276,7 +277,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Crop")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } else if (event.getClickedBlock().getType() == Materials.STONE_PRESSURE_PLATE.parseMaterial() || event.getClickedBlock().getType() == Materials.OAK_PRESSURE_PLATE.parseMaterial() || event.getClickedBlock().getType() == Materials.SPRUCE_PRESSURE_PLATE.parseMaterial() || event.getClickedBlock().getType() == Materials.BIRCH_PRESSURE_PLATE.parseMaterial() || event.getClickedBlock().getType() == Materials.JUNGLE_PRESSURE_PLATE.parseMaterial() || event.getClickedBlock().getType() == Materials.ACACIA_PRESSURE_PLATE.parseMaterial() || event.getClickedBlock().getType() == Materials.DARK_OAK_PRESSURE_PLATE.parseMaterial()) { @@ -289,7 +290,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Redstone")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -302,6 +303,7 @@ public class Interact implements Listener { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { Player player = event.getPlayer(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -311,7 +313,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Leash")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -327,7 +329,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "HorseInventory")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -336,7 +338,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "MobRiding")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -346,7 +348,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "MobRiding")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -357,7 +359,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Milking")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -367,7 +369,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "Trading")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -376,7 +378,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "MinecartBoat")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -418,7 +420,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "AnimalBreeding")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } @@ -434,7 +436,7 @@ public class Interact implements Listener { if (!islandManager.hasPermission(player, "ArmorStand")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/listeners/Inventory.java b/src/me/goodandevil/skyblock/listeners/Inventory.java index 805337bb..b2499f9a 100644 --- a/src/me/goodandevil/skyblock/listeners/Inventory.java +++ b/src/me/goodandevil/skyblock/listeners/Inventory.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.listeners; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -30,7 +29,7 @@ public class Inventory implements Listener { if (!plugin.getIslandManager().hasPermission(player, "HorseInventory")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); plugin.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/listeners/Join.java b/src/me/goodandevil/skyblock/listeners/Join.java index 103208cb..47b9e16b 100644 --- a/src/me/goodandevil/skyblock/listeners/Join.java +++ b/src/me/goodandevil/skyblock/listeners/Join.java @@ -68,7 +68,7 @@ public class Join implements Listener { playerDataManager.storeIsland(player); plugin.getBiomeManager().loadPlayer(player); - //plugin.getCreationManager().loadPlayer(player); + plugin.getCreationManager().loadPlayer(player); ScoreboardManager scoreboardManager = plugin.getScoreboardManager(); FileManager fileManager = plugin.getFileManager(); diff --git a/src/me/goodandevil/skyblock/listeners/Move.java b/src/me/goodandevil/skyblock/listeners/Move.java index dd41bae8..a0576024 100644 --- a/src/me/goodandevil/skyblock/listeners/Move.java +++ b/src/me/goodandevil/skyblock/listeners/Move.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.listeners; import java.io.File; import java.util.UUID; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -17,6 +16,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -43,13 +43,14 @@ public class Move implements Listener { if (player.getWorld().getName().equals(plugin.getWorldManager().getWorld(me.goodandevil.skyblock.island.Location.World.Normal).getName()) || player.getWorld().getName().equals(netherWorldName)) { PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); if (player.getWorld().getName().equals(netherWorldName)) { if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World.Nether.Enable")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.World.Nether.Message"))); + messageManager.sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.World.Nether.Message")); if (playerDataManager.hasPlayerData(player)) { PlayerData playerData = playerDataManager.getPlayerData(player); @@ -128,7 +129,7 @@ public class Move implements Listener { player.teleport(island.getLocation(me.goodandevil.skyblock.island.Location.World.Nether, me.goodandevil.skyblock.island.Location.Environment.Main)); } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Outside.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Outside.Message")); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } } @@ -139,7 +140,7 @@ public class Move implements Listener { LocationUtil.teleportPlayerToSpawn(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message")); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/listeners/Portal.java b/src/me/goodandevil/skyblock/listeners/Portal.java index e2cbffdf..a55aa1fb 100644 --- a/src/me/goodandevil/skyblock/listeners/Portal.java +++ b/src/me/goodandevil/skyblock/listeners/Portal.java @@ -3,7 +3,6 @@ package me.goodandevil.skyblock.listeners; import java.io.File; import java.util.UUID; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -13,6 +12,7 @@ import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -34,6 +34,7 @@ public class Portal implements Listener { Player player = (Player) event.getEntity(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -48,7 +49,7 @@ public class Portal implements Listener { soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } else { player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } @@ -65,7 +66,7 @@ public class Portal implements Listener { soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } else { player.teleport(island.getLocation(Location.World.Nether, Location.Environment.Main)); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } diff --git a/src/me/goodandevil/skyblock/listeners/Projectile.java b/src/me/goodandevil/skyblock/listeners/Projectile.java index 9cedb20a..7d9ccfc5 100644 --- a/src/me/goodandevil/skyblock/listeners/Projectile.java +++ b/src/me/goodandevil/skyblock/listeners/Projectile.java @@ -2,7 +2,6 @@ package me.goodandevil.skyblock.listeners; import java.io.File; -import org.bukkit.ChatColor; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -11,6 +10,7 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.island.Location; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -27,6 +27,7 @@ public class Projectile implements Listener { if (event.getEntity().getShooter() instanceof Player) { Player player = (Player) event.getEntity().getShooter(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); if (player.getWorld().getName().equals(plugin.getWorldManager().getWorld(Location.World.Normal).getName()) || player.getWorld().getName().equals(plugin.getWorldManager().getWorld(Location.World.Nether).getName())) { @@ -34,7 +35,7 @@ public class Projectile implements Listener { if (!plugin.getIslandManager().hasPermission(player, "Fishing")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } @@ -44,7 +45,7 @@ public class Projectile implements Listener { if (!plugin.getIslandManager().hasPermission(player, "Projectile")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/listeners/Quit.java b/src/me/goodandevil/skyblock/listeners/Quit.java index f4f14485..04fb8ddc 100644 --- a/src/me/goodandevil/skyblock/listeners/Quit.java +++ b/src/me/goodandevil/skyblock/listeners/Quit.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -15,11 +14,13 @@ import org.bukkit.event.player.PlayerQuitEvent; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.biome.BiomeManager; +import me.goodandevil.skyblock.creation.CreationManager; import me.goodandevil.skyblock.invite.Invite; import me.goodandevil.skyblock.invite.InviteManager; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.levelling.LevellingManager; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.utils.version.Sounds; @@ -37,6 +38,7 @@ public class Quit implements Listener { Player player = event.getPlayer(); PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); PlayerData playerData = playerDataManager.getPlayerData(player); @@ -62,7 +64,7 @@ public class Quit implements Listener { if (targetPlayerData.isChat()) { targetPlayerData.setChat(false); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message"))); + messageManager.sendMessage(targetPlayer, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Chat.Untoggled.Message")); } } } @@ -87,7 +89,7 @@ public class Quit implements Listener { Player targetPlayer = Bukkit.getServer().getPlayer(invite.getOwnerUUID()); if (targetPlayer != null) { - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Invite.Invited.Sender.Disconnected.Message").replace("%player", player.getName()))); + messageManager.sendMessage(targetPlayer, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Invite.Invited.Sender.Disconnected.Message").replace("%player", player.getName())); plugin.getSoundManager().playSound(targetPlayer, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } @@ -98,8 +100,8 @@ public class Quit implements Listener { biomeManager.savePlayer(player); biomeManager.unloadPlayer(player); - /*CreationManager creationManager = plugin.getCreationManager(); + CreationManager creationManager = plugin.getCreationManager(); creationManager.savePlayer(player); - creationManager.unloadPlayer(player);*/ + creationManager.unloadPlayer(player); } } diff --git a/src/me/goodandevil/skyblock/listeners/Teleport.java b/src/me/goodandevil/skyblock/listeners/Teleport.java index 8910cf37..8750d1a5 100644 --- a/src/me/goodandevil/skyblock/listeners/Teleport.java +++ b/src/me/goodandevil/skyblock/listeners/Teleport.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.UUID; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -20,6 +19,7 @@ import me.goodandevil.skyblock.events.IslandExitEvent; import me.goodandevil.skyblock.events.IslandSwitchEvent; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; @@ -40,6 +40,7 @@ public class Teleport implements Listener { public void onPlayerTeleport(PlayerTeleportEvent event) { Player player = event.getPlayer(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -54,7 +55,7 @@ public class Teleport implements Listener { if (!islandManager.hasPermission(player, "Portal")) { event.setCancelled(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Settings.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Settings.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -75,20 +76,22 @@ public class Teleport implements Listener { for (Location.World worldList : Location.World.values()) { if (LocationUtil.isLocationAtLocationRadius(event.getTo(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { if (!island.getOwnerUUID().equals(playerData.getOwner())) { - if (!island.isOpen()) { - event.setCancelled(true); - - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Closed.Plugin.Message"))); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); - - return; - } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && island.getBan().isBanned(player.getUniqueId())) { - event.setCancelled(true); - - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Banned.Teleport.Message"))); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); - - return; + if (!(player.hasPermission("skyblock.bypass") && player.hasPermission("skyblock.bypass.*") && player.hasPermission("skyblock.*"))) { + if (!island.isOpen()) { + event.setCancelled(true); + + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Plugin.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && island.getBan().isBanned(player.getUniqueId())) { + event.setCancelled(true); + + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Teleport.Message")); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } } } diff --git a/src/me/goodandevil/skyblock/menus/Bans.java b/src/me/goodandevil/skyblock/menus/Bans.java index 29bdd4cb..6c181201 100644 --- a/src/me/goodandevil/skyblock/menus/Bans.java +++ b/src/me/goodandevil/skyblock/menus/Bans.java @@ -22,6 +22,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -113,6 +114,7 @@ public class Bans implements Listener { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { Main plugin = Main.getInstance(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -131,14 +133,14 @@ public class Bans implements Listener { island = islandManager.getIsland(playerData.getOwner()); if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -174,7 +176,7 @@ public class Bans implements Listener { } }.runTaskLater(plugin, 3L); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Bans.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/menus/Biome.java b/src/me/goodandevil/skyblock/menus/Biome.java index 9297bc98..1e4d6e38 100644 --- a/src/me/goodandevil/skyblock/menus/Biome.java +++ b/src/me/goodandevil/skyblock/menus/Biome.java @@ -22,6 +22,7 @@ import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.NumberUtil; import me.goodandevil.skyblock.utils.item.InventoryUtil; @@ -128,6 +129,7 @@ public class Biome implements Listener { if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Title")))) { event.setCancelled(true); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); BiomeManager biomeManager = plugin.getBiomeManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -138,14 +140,14 @@ public class Biome implements Listener { island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner()); if (!((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Biome.Permission.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Biome.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Biome.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Biome.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -164,10 +166,10 @@ public class Biome implements Listener { me.goodandevil.skyblock.biome.Biome biome = biomeManager.getPlayer(player); if (biome.getTime() < 60) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", biome.getTime() + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", biome.getTime() + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second"))); } else { long[] durationTime = NumberUtil.getDuration(biome.getTime()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second"))); } soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); diff --git a/src/me/goodandevil/skyblock/menus/Creator.java b/src/me/goodandevil/skyblock/menus/Creator.java index 0ba990de..3cd18dd8 100644 --- a/src/me/goodandevil/skyblock/menus/Creator.java +++ b/src/me/goodandevil/skyblock/menus/Creator.java @@ -16,9 +16,13 @@ import org.bukkit.inventory.ItemStack; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.creation.Creation; +import me.goodandevil.skyblock.creation.CreationManager; import me.goodandevil.skyblock.island.IslandManager; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.structure.Structure; +import me.goodandevil.skyblock.utils.NumberUtil; import me.goodandevil.skyblock.utils.item.InventoryUtil; import me.goodandevil.skyblock.utils.version.Sounds; @@ -59,7 +63,7 @@ public class Creator implements Listener { int inventoryRows = 0; if (availableStructures.size() == 0) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Creator.Selector.None.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Island.Creator.Selector.None.Message")); plugin.getSoundManager().playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -111,6 +115,9 @@ public class Creator implements Listener { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { Main plugin = Main.getInstance(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); @@ -119,12 +126,10 @@ public class Creator implements Listener { if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Title")))) { event.setCancelled(true); - //CreationManager creationManager = plugin.getCreationManager(); - IslandManager islandManager = plugin.getIslandManager(); - SoundManager soundManager = plugin.getSoundManager(); + CreationManager creationManager = plugin.getCreationManager(); if (islandManager.hasIsland(player)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Create.Owner.Message"))); + messageManager.sendMessage(player, configLoad.getString("Command.Island.Create.Owner.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -134,7 +139,7 @@ public class Creator implements Listener { if ((event.getCurrentItem().getType() == structureList.getMaterials().parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Item.Island.Displayname").replace("%displayname", structureList.getDisplayname()))))) { if (structureList.isPermission() && structureList.getPermission() != null && !structureList.getPermission().isEmpty()) { if (!player.hasPermission(structureList.getPermission()) && !player.hasPermission("skyblock.island.*") && !player.hasPermission("skyblock.*")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Creator.Selector.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); open(player); @@ -144,30 +149,28 @@ public class Creator implements Listener { } if (!fileManager.isFileExist(new File(new File(plugin.getDataFolder().toString() + "/structures"), structureList.getFile()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Creator.Selector.File.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; - } - - /*if (creationManager.hasPlayer(player)) { + } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") && creationManager.hasPlayer(player)) { Creation creation = creationManager.getPlayer(player); if (creation.getTime() < 60) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", creation.getTime() + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", creation.getTime() + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second"))); } else { long[] durationTime = NumberUtil.getDuration(creation.getTime()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second"))); } soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; - }*/ + } islandManager.createIsland(player, structureList); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Creator.Selector.Created.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message")); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/me/goodandevil/skyblock/menus/Levelling.java b/src/me/goodandevil/skyblock/menus/Levelling.java index 958f7add..e30d4e7d 100644 --- a/src/me/goodandevil/skyblock/menus/Levelling.java +++ b/src/me/goodandevil/skyblock/menus/Levelling.java @@ -23,6 +23,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Level; import me.goodandevil.skyblock.levelling.LevellingManager; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.NumberUtil; @@ -120,17 +121,18 @@ public class Levelling implements Listener { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { Main plugin = Main.getInstance(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")))) { event.setCancelled(true); - IslandManager islandManager = plugin.getIslandManager(); - SoundManager soundManager = plugin.getSoundManager(); - if (!islandManager.hasIsland(player)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Level.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -155,11 +157,11 @@ public class Levelling implements Listener { long[] durationTime = NumberUtil.getDuration(levelling.getTime()); if (levelling.getTime() >= 3600) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second"))); } else if (levelling.getTime() >= 60) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second"))); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second")))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second"))); } soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); @@ -171,7 +173,7 @@ public class Levelling implements Listener { new BukkitRunnable() { public void run() { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Level.Processing.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Processing.Message")); soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F); levellingManager.createLevelling(island.getOwnerUUID()); diff --git a/src/me/goodandevil/skyblock/menus/Members.java b/src/me/goodandevil/skyblock/menus/Members.java index a8265239..e475d8a5 100644 --- a/src/me/goodandevil/skyblock/menus/Members.java +++ b/src/me/goodandevil/skyblock/menus/Members.java @@ -328,7 +328,7 @@ public class Members implements Listener { if (islandManager.hasIsland(player)) { island = islandManager.getIsland(playerData.getOwner()); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Members.Owner.Message"))); + plugin.getMessageManager().sendMessage(player, config.getFileConfiguration().getString("Command.Island.Members.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/me/goodandevil/skyblock/menus/Ownership.java b/src/me/goodandevil/skyblock/menus/Ownership.java index 6187ae86..1abff22a 100644 --- a/src/me/goodandevil/skyblock/menus/Ownership.java +++ b/src/me/goodandevil/skyblock/menus/Ownership.java @@ -22,6 +22,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -96,30 +97,31 @@ public class Ownership implements Listener { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { Main plugin = Main.getInstance(); + PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Title")))) { event.setCancelled(true); - PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); - IslandManager islandManager = plugin.getIslandManager(); - SoundManager soundManager = plugin.getSoundManager(); - Island island = null; if (islandManager.hasIsland(player)) { island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner()); if (!island.isRole(Role.Owner, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -151,13 +153,13 @@ public class Ownership implements Listener { island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner()); if (!island.isRole(Role.Owner, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -217,14 +219,14 @@ public class Ownership implements Listener { island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner()); if (!island.isRole(Role.Owner, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/me/goodandevil/skyblock/menus/Rollback.java b/src/me/goodandevil/skyblock/menus/Rollback.java index 3b8bd7a1..4c9c12b6 100644 --- a/src/me/goodandevil/skyblock/menus/Rollback.java +++ b/src/me/goodandevil/skyblock/menus/Rollback.java @@ -22,6 +22,7 @@ import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Materials; import me.goodandevil.skyblock.utils.version.Sounds; @@ -109,27 +110,28 @@ public class Rollback implements Listener { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { Main plugin = Main.getInstance(); + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Rollback.Title")))) { event.setCancelled(true); - IslandManager islandManager = plugin.getIslandManager(); - SoundManager soundManager = plugin.getSoundManager(); - if (islandManager.hasIsland(player)) { island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner()); if (!island.isRole(Role.Owner, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Rollback.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Rollback.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Rollback.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Rollback.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/me/goodandevil/skyblock/menus/Settings.java b/src/me/goodandevil/skyblock/menus/Settings.java index b8bd7436..946bd120 100644 --- a/src/me/goodandevil/skyblock/menus/Settings.java +++ b/src/me/goodandevil/skyblock/menus/Settings.java @@ -24,6 +24,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Message; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.AnvilGUI; @@ -271,6 +272,7 @@ public class Settings implements Listener { event.setCancelled(true); PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); SoundManager soundManager = plugin.getSoundManager(); @@ -280,14 +282,14 @@ public class Settings implements Listener { island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner()); if (!(island.isRole(Role.Operator, player.getUniqueId()) || island.isRole(Role.Owner, player.getUniqueId()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -300,7 +302,7 @@ public class Settings implements Listener { player.closeInventory(); } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Categories.Item.Visitor.Displayname"))))) { if (island.isRole(Role.Operator, player.getUniqueId()) && !island.getSetting(me.goodandevil.skyblock.island.Settings.Role.Operator, "Visitor").getStatus()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -310,7 +312,7 @@ public class Settings implements Listener { soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); } else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Categories.Item.Member.Displayname"))))) { if (island.isRole(Role.Operator, player.getUniqueId()) && !island.getSetting(me.goodandevil.skyblock.island.Settings.Role.Operator, "Member").getStatus()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -320,7 +322,7 @@ public class Settings implements Listener { soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); } else if ((event.getCurrentItem().getType() == Material.ITEM_FRAME) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Categories.Item.Operator.Displayname"))))) { if (island.isRole(Role.Operator, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -330,7 +332,7 @@ public class Settings implements Listener { soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); } else if ((event.getCurrentItem().getType() == Materials.OAK_SAPLING.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Categories.Item.Owner.Displayname"))))) { if (island.isRole(Role.Operator, player.getUniqueId()) && !island.getSetting(me.goodandevil.skyblock.island.Settings.Role.Operator, "Island").getStatus()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Access.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); return; @@ -342,14 +344,14 @@ public class Settings implements Listener { } else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Visitor.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Member.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Operator.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Owner.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Title")))) { if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Title")))) { if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Settings.Visitor.Signature.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Settings.Visitor.Signature.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Title")))) { if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Settings.Visitor.Welcome.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Settings.Visitor.Welcome.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -396,7 +398,7 @@ public class Settings implements Listener { island1 = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner()); if (!(island1.isRole(Role.Operator, player.getUniqueId()) || island1.isRole(Role.Owner, player.getUniqueId()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -405,7 +407,7 @@ public class Settings implements Listener { return; } else if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Settings.Visitor.Welcome.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Settings.Visitor.Welcome.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); event1.setWillClose(true); @@ -414,7 +416,7 @@ public class Settings implements Listener { return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -484,19 +486,19 @@ public class Settings implements Listener { island1 = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner()); if (!(island1.isRole(Role.Operator, player.getUniqueId()) || island1.isRole(Role.Owner, player.getUniqueId()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Role.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Role.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } else if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Settings.Visitor.Signature.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Settings.Visitor.Signature.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); @@ -558,7 +560,7 @@ public class Settings implements Listener { roleName = "Default"; if (island.isRole(Role.Operator, player.getUniqueId()) && !island.getSetting(me.goodandevil.skyblock.island.Settings.Role.Operator, "Visitor").getStatus()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -568,7 +570,7 @@ public class Settings implements Listener { roleName = "Default"; if (island.isRole(Role.Operator, player.getUniqueId()) && !island.getSetting(me.goodandevil.skyblock.island.Settings.Role.Operator, "Member").getStatus()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -578,7 +580,7 @@ public class Settings implements Listener { roleName = role.name(); if (!island.isRole(Role.Owner, player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -588,7 +590,7 @@ public class Settings implements Listener { roleName = role.name(); if (island.isRole(Role.Operator, player.getUniqueId()) && !island.getSetting(me.goodandevil.skyblock.island.Settings.Role.Operator, "Island").getStatus()) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Settings.Permission.Change.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; diff --git a/src/me/goodandevil/skyblock/menus/Structure.java b/src/me/goodandevil/skyblock/menus/Structure.java deleted file mode 100644 index 1a83a590..00000000 --- a/src/me/goodandevil/skyblock/menus/Structure.java +++ /dev/null @@ -1,21 +0,0 @@ -package me.goodandevil.skyblock.menus; - -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -public class Structure implements Listener { - - private static Structure instance; - - public static Structure getInstance(){ - if(instance == null) { - instance = new Structure(); - } - - return instance; - } - - public void openBrowse(Player player) { - // TODO Display Structures - } -} diff --git a/src/me/goodandevil/skyblock/menus/Visit.java b/src/me/goodandevil/skyblock/menus/Visit.java index 3d57c450..b1a34fb8 100644 --- a/src/me/goodandevil/skyblock/menus/Visit.java +++ b/src/me/goodandevil/skyblock/menus/Visit.java @@ -27,6 +27,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -260,6 +261,7 @@ public class Visit implements Listener { Main plugin = Main.getInstance(); PlayerDataManager playerDataManager = plugin.getPlayerDataManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -337,46 +339,26 @@ public class Visit implements Listener { List islandVotes = visit.getVoters(); if (islandVotes.contains(player.getUniqueId())) { - for (Location.World worldList : Location.World.values()) { - if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { - visit.removeVoter(player.getUniqueId()); - - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Removed.Message").replace("%player", targetPlayerName))); - soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F); - - open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort()); - - return; - } - } - - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Location.Remove.Message"))); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + visit.removeVoter(player.getUniqueId()); + + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Removed.Message").replace("%player", targetPlayerName)); + soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F); } else { - for (Location.World worldList : Location.World.values()) { - if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { - visit.addVoter(player.getUniqueId()); - - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Added.Message").replace("%player", targetPlayerName))); - soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); - - open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort()); - - return; - } - } - - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Location.Add.Message"))); - soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + visit.addVoter(player.getUniqueId()); + + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Added.Message").replace("%player", targetPlayerName)); + soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); } open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort()); soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Vote.Island.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Island.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } + islandManager.unloadIsland(targetPlayerUUID); + return; } else if (event.getClick() != ClickType.LEFT) { return; @@ -385,7 +367,7 @@ public class Visit implements Listener { for (Location.World worldList : Location.World.values()) { if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Already.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Already.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -394,10 +376,10 @@ public class Visit implements Listener { islandManager.visitIsland(player, island); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Teleported.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Teleported.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Closed.Menu.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Menu.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort()); } @@ -405,7 +387,7 @@ public class Visit implements Listener { return; } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Exist.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Exist.Message").replace("%player", targetPlayerName)); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort()); } diff --git a/src/me/goodandevil/skyblock/menus/Visitors.java b/src/me/goodandevil/skyblock/menus/Visitors.java index bec589de..b395e4b4 100644 --- a/src/me/goodandevil/skyblock/menus/Visitors.java +++ b/src/me/goodandevil/skyblock/menus/Visitors.java @@ -166,7 +166,7 @@ public class Visitors implements Listener { if (islandManager.hasIsland(player)) { island = islandManager.getIsland(playerData.getOwner()); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Visitors.Owner.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Visitors.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/me/goodandevil/skyblock/menus/Weather.java b/src/me/goodandevil/skyblock/menus/Weather.java index 468d2145..f31a05d5 100644 --- a/src/me/goodandevil/skyblock/menus/Weather.java +++ b/src/me/goodandevil/skyblock/menus/Weather.java @@ -21,6 +21,7 @@ import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; import me.goodandevil.skyblock.island.Settings; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.item.InventoryUtil; import me.goodandevil.skyblock.utils.version.Materials; @@ -104,6 +105,10 @@ public class Weather implements Listener { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { Main plugin = Main.getInstance(); + + MessageManager messageManager = plugin.getMessageManager(); + IslandManager islandManager = plugin.getIslandManager(); + SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); @@ -112,23 +117,20 @@ public class Weather implements Listener { if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Title")))) { event.setCancelled(true); - IslandManager islandManager = plugin.getIslandManager(); - SoundManager soundManager = plugin.getSoundManager(); - Island island = null; if (islandManager.hasIsland(player)) { island = islandManager.getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner()); if (!((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId()))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Weather.Permission.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Weather.Permission.Message")); soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); return; } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Command.Island.Weather.Owner.Message"))); + messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Weather.Owner.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); player.closeInventory(); diff --git a/src/me/goodandevil/skyblock/menus/admin/Creator.java b/src/me/goodandevil/skyblock/menus/admin/Creator.java index 556bf97b..20bfdc73 100644 --- a/src/me/goodandevil/skyblock/menus/admin/Creator.java +++ b/src/me/goodandevil/skyblock/menus/admin/Creator.java @@ -21,6 +21,7 @@ import org.bukkit.inventory.meta.ItemMeta; import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.playerdata.PlayerDataManager; import me.goodandevil.skyblock.sound.SoundManager; @@ -161,6 +162,7 @@ public class Creator implements Listener { Main plugin = Main.getInstance(); StructureManager structureManager = plugin.getStructureManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -173,7 +175,7 @@ public class Creator implements Listener { PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("skyblock.admin.create") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -202,18 +204,18 @@ public class Creator implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.creator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (structureManager.containsStructure(event1.getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!event1.getName().replace(" ", "").matches("^[a-zA-Z0-9]+$")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Characters.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Characters.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { structureManager.addStructure(event1.getName(), Materials.GRASS_BLOCK, null, null, false, new ArrayList<>()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Created.Message").replace("%structure", event1.getName()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Created.Message").replace("%structure", event1.getName())); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -265,7 +267,7 @@ public class Creator implements Listener { if (playerData.getViewer() == null) { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -276,7 +278,7 @@ public class Creator implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.creator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (playerData.getViewer() == null) { Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -286,7 +288,7 @@ public class Creator implements Listener { } }, 3L); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!structureManager.containsStructure(name)) { Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -296,7 +298,7 @@ public class Creator implements Listener { } }, 3L); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Structure structure = structureManager.getStructure(name); @@ -347,7 +349,7 @@ public class Creator implements Listener { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -357,7 +359,7 @@ public class Creator implements Listener { if (playerData.getViewer() == null) { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -399,7 +401,7 @@ public class Creator implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.creator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (playerData.getViewer() == null) { Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -409,7 +411,7 @@ public class Creator implements Listener { } }, 3L); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!structureManager.containsStructure(name)) { Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -419,7 +421,7 @@ public class Creator implements Listener { } }, 3L); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { structure.addLine(event1.getName()); @@ -469,7 +471,7 @@ public class Creator implements Listener { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -479,7 +481,7 @@ public class Creator implements Listener { if (playerData.getViewer() == null) { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -515,7 +517,7 @@ public class Creator implements Listener { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -525,7 +527,7 @@ public class Creator implements Listener { if (playerData.getViewer() == null) { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { String name = ((Creator.Viewer) playerData.getViewer()).getName(); @@ -536,7 +538,7 @@ public class Creator implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.creator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (playerData.getViewer() == null) { Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -546,7 +548,7 @@ public class Creator implements Listener { } }, 3L); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!structureManager.containsStructure(name)) { Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -556,7 +558,7 @@ public class Creator implements Listener { } }, 3L); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { if (fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/structures", event1.getName()))) { @@ -588,7 +590,7 @@ public class Creator implements Listener { } }); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.File.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.File.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } @@ -619,7 +621,7 @@ public class Creator implements Listener { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -629,7 +631,7 @@ public class Creator implements Listener { if (playerData.getViewer() == null) { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Creator.Viewer viewer = (Viewer) playerData.getViewer(); @@ -637,18 +639,18 @@ public class Creator implements Listener { if (viewer.isItem()) { viewer.setItem(false); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Item.Cancelled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Item.Cancelled.Message")); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } else { if (structureManager.containsStructure(name)) { viewer.setItem(true); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Item.Added.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Item.Added.Message")); soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F); } else { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -694,13 +696,13 @@ public class Creator implements Listener { viewer.setItem(false); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Item.Removed.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Item.Removed.Message")); soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); } else { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } @@ -719,7 +721,7 @@ public class Creator implements Listener { structureManager.removeStructure(structureList); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Removed.Message").replace("%structure", structureList.getName()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Removed.Message").replace("%structure", structureList.getName())); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @@ -743,7 +745,7 @@ public class Creator implements Listener { } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Creator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); open(player); @@ -770,7 +772,7 @@ public class Creator implements Listener { if (viewer != null) { if (viewer.isItem()) { viewer.setItem(false); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Creator.Item.Removed.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Island.Admin.Creator.Item.Removed.Message")); plugin.getSoundManager().playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/menus/admin/Generator.java b/src/me/goodandevil/skyblock/menus/admin/Generator.java index db0a03d7..b9ba8af5 100644 --- a/src/me/goodandevil/skyblock/menus/admin/Generator.java +++ b/src/me/goodandevil/skyblock/menus/admin/Generator.java @@ -22,6 +22,7 @@ import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.generator.GeneratorManager; import me.goodandevil.skyblock.generator.GeneratorMaterial; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.AnvilGUI; @@ -133,6 +134,7 @@ public class Generator implements Listener { Main plugin = Main.getInstance(); GeneratorManager generatorManager = plugin.getGeneratorManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -145,14 +147,14 @@ public class Generator implements Listener { PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("skyblock.admin.generator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; } if (generatorManager == null) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Disabled.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Disabled.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -183,18 +185,18 @@ public class Generator implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.generator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (generatorManager.containsGenerator(event1.getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!event1.getName().replace(" ", "").matches("^[a-zA-Z0-9]+$")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Characters.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Characters.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { generatorManager.addGenerator(event1.getName(), new ArrayList<>(), false); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Created.Message").replace("%generator", event1.getName()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Created.Message").replace("%generator", event1.getName())); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -242,7 +244,7 @@ public class Generator implements Listener { if (playerData.getViewer() == null) { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Selected.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Selected.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { String name = ((Generator.Viewer) playerData.getViewer()).getName(); @@ -278,7 +280,7 @@ public class Generator implements Listener { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } @@ -321,19 +323,19 @@ public class Generator implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.generator") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (generatorManager.containsGenerator(event1.getName())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!event1.getName().replace(" ", "").matches("^[a-zA-Z0-9]+$")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Characters.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Characters.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!generator.getGeneratorMaterials().contains(generatorMaterialList)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Material.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Material.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (!event1.getName().matches("[0-9]+")) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Chance.Numerical.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Chance.Numerical.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { int materialChance = Integer.valueOf(event1.getName()); @@ -346,7 +348,7 @@ public class Generator implements Listener { } if (totalMaterialChance > 100) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Chance.Over.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Chance.Over.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { generatorMaterialList.setChance(Integer.valueOf(event1.getName())); @@ -421,7 +423,7 @@ public class Generator implements Listener { } if (generator.getGeneratorMaterials() != null && generator.getGeneratorMaterials().size() == 36) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Material.Limit.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Material.Limit.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else { Materials materials; @@ -434,7 +436,7 @@ public class Generator implements Listener { for (GeneratorMaterial generatorMaterialList : generator.getGeneratorMaterials()) { if (generatorMaterialList.getMaterials() == materials) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Material.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Material.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -445,7 +447,7 @@ public class Generator implements Listener { open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Material.Added.Message").replace("%material", materials.name()).replace("%generator", generator.getName()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Material.Added.Message").replace("%material", materials.name()).replace("%generator", generator.getName())); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @@ -470,7 +472,7 @@ public class Generator implements Listener { playerData.setViewer(null); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } @@ -488,7 +490,7 @@ public class Generator implements Listener { generatorManager.removeGenerator(generatorList); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Removed.Message").replace("%generator", generatorList.getName()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Removed.Message").replace("%generator", generatorList.getName())); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @@ -512,7 +514,7 @@ public class Generator implements Listener { } } - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Generator.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Generator.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); open(player); diff --git a/src/me/goodandevil/skyblock/menus/admin/Levelling.java b/src/me/goodandevil/skyblock/menus/admin/Levelling.java index 178b8ed2..224fbd6c 100644 --- a/src/me/goodandevil/skyblock/menus/admin/Levelling.java +++ b/src/me/goodandevil/skyblock/menus/admin/Levelling.java @@ -20,6 +20,7 @@ import me.goodandevil.skyblock.Main; import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.levelling.LevellingManager; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.playerdata.PlayerData; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.AnvilGUI; @@ -100,6 +101,7 @@ public class Levelling implements Listener { Main plugin = Main.getInstance(); LevellingManager levellingManager = plugin.getLevellingManager(); + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -110,7 +112,7 @@ public class Levelling implements Listener { PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player); if (!(player.hasPermission("skyblock.admin.level") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -134,12 +136,12 @@ public class Levelling implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.level") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (event1.getName().matches("[0-9]+")) { int pointDivision = Integer.valueOf(event1.getName()); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Division.Message").replace("%division", NumberUtil.formatNumber(pointDivision)))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Division.Message").replace("%division", NumberUtil.formatNumber(pointDivision))); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @@ -165,7 +167,7 @@ public class Levelling implements Listener { } }, 3L); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Numerical.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Numerical.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } @@ -222,14 +224,14 @@ public class Levelling implements Listener { AnvilGUI gui = new AnvilGUI(player, event1 -> { if (event1.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) { if (!(player.hasPermission("skyblock.admin.level") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Permission.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } else if (levellingManager.containsMaterials(materials)) { if (event1.getName().matches("[0-9]+")) { int materialPoints = Integer.valueOf(event1.getName()); materialList.setPoints(materialPoints); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Points.Message").replace("%material", materials.name()).replace("%points", NumberUtil.formatNumber(materialPoints)))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Points.Message").replace("%material", materials.name()).replace("%points", NumberUtil.formatNumber(materialPoints))); soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @@ -255,11 +257,11 @@ public class Levelling implements Listener { } }); } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Numerical.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Numerical.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Exist.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Exist.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); } @@ -282,7 +284,7 @@ public class Levelling implements Listener { levellingManager.removeMaterial(materialList); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Removed.Message").replace("%material", materials.name()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Removed.Message").replace("%material", materials.name())); soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @@ -318,7 +320,7 @@ public class Levelling implements Listener { } if (levellingManager.containsMaterials(materials)) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Already.Message"))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Already.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; @@ -327,7 +329,7 @@ public class Levelling implements Listener { levellingManager.addMaterial(materials, 0); open(player); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Levelling.Added.Message").replace("%material", materials.name()))); + messageManager.sendMessage(player, configLoad.getString("Island.Admin.Levelling.Added.Message").replace("%material", materials.name())); soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { diff --git a/src/me/goodandevil/skyblock/menus/admin/Settings.java b/src/me/goodandevil/skyblock/menus/admin/Settings.java index 87d344ed..9a522f2d 100644 --- a/src/me/goodandevil/skyblock/menus/admin/Settings.java +++ b/src/me/goodandevil/skyblock/menus/admin/Settings.java @@ -198,7 +198,7 @@ public class Settings implements Listener { event.setCancelled(true); if (!(player.hasPermission("skyblock.admin.settings") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Settings.Permission.Message"))); + plugin.getMessageManager().sendMessage(player, configLoad.getString("Island.Admin.Settings.Permission.Message")); soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); return; diff --git a/src/me/goodandevil/skyblock/message/MessageManager.java b/src/me/goodandevil/skyblock/message/MessageManager.java new file mode 100644 index 00000000..9c3663ff --- /dev/null +++ b/src/me/goodandevil/skyblock/message/MessageManager.java @@ -0,0 +1,26 @@ +package me.goodandevil.skyblock.message; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import me.goodandevil.skyblock.Main; +import me.goodandevil.skyblock.placeholder.PlaceholderManager; + +public class MessageManager { + + private final Main plugin; + + public MessageManager(Main plugin) { + this.plugin = plugin; + } + + public void sendMessage(Player player, String message) { + PlaceholderManager placeholderManager = plugin.getPlaceholderManager(); + + if (placeholderManager.isPlaceholderAPIEnabled()) { + message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message.replace("&", "clr")).replace("clr", "&"); + } + + player.sendMessage(ChatColor.translateAlternateColorCodes('&', message)); + } +} diff --git a/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java b/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java index fd9cd1e2..5ff70dc6 100644 --- a/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java +++ b/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java @@ -41,6 +41,10 @@ public class EZPlaceholder extends PlaceholderExpansion { } public String onPlaceholderRequest(Player player, String identifier) { + if (identifier.equalsIgnoreCase("islands")) { + return "" + plugin.getVisitManager().getIslands().size(); + } + if(player == null){ return ""; } diff --git a/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java b/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java index cd23384f..fd0238a5 100644 --- a/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java +++ b/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java @@ -32,6 +32,13 @@ public class MVdWPlaceholder { Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); FileConfiguration configLoad = config.getFileConfiguration(); + PlaceholderAPI.registerPlaceholder(plugin, "skyblock_islands", new PlaceholderReplacer() { + @Override + public String onPlaceholderReplace(PlaceholderReplaceEvent event) { + return "" + plugin.getVisitManager().getIslands().size(); + } + }); + PlaceholderAPI.registerPlaceholder(plugin, "skyblock_island_level", new PlaceholderReplacer() { @Override public String onPlaceholderReplace(PlaceholderReplaceEvent event) { diff --git a/src/me/goodandevil/skyblock/playerdata/PlayerDataManager.java b/src/me/goodandevil/skyblock/playerdata/PlayerDataManager.java index 4c42defa..ebaf6a0a 100644 --- a/src/me/goodandevil/skyblock/playerdata/PlayerDataManager.java +++ b/src/me/goodandevil/skyblock/playerdata/PlayerDataManager.java @@ -23,6 +23,7 @@ import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Location; import me.goodandevil.skyblock.island.IslandManager; import me.goodandevil.skyblock.island.Role; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.scoreboard.Scoreboard; import me.goodandevil.skyblock.scoreboard.ScoreboardManager; import me.goodandevil.skyblock.utils.OfflinePlayer; @@ -126,6 +127,7 @@ public class PlayerDataManager { } public void storeIsland(Player player) { + MessageManager messageManager = plugin.getMessageManager(); IslandManager islandManager = plugin.getIslandManager(); WorldManager worldManager = plugin.getWorldManager(); FileManager fileManager = plugin.getFileManager(); @@ -208,7 +210,7 @@ public class PlayerDataManager { } if (banManager.hasIsland(visitIslandList) && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && banManager.getIsland(visitIslandList).isBanned(player.getUniqueId())) { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Teleport.Island.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Teleport.Island.Message").replace("%player", targetPlayerName)); } else { if (visit.isOpen()) { PlayerData playerData = getPlayerData(player); @@ -218,7 +220,7 @@ public class PlayerDataManager { return; } else { - player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName))); + messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName)); } } diff --git a/src/me/goodandevil/skyblock/utils/world/LocationUtil.java b/src/me/goodandevil/skyblock/utils/world/LocationUtil.java index 4ad09566..2aa3b688 100644 --- a/src/me/goodandevil/skyblock/utils/world/LocationUtil.java +++ b/src/me/goodandevil/skyblock/utils/world/LocationUtil.java @@ -40,13 +40,13 @@ public final class LocationUtil { return false; } - public static boolean isLocationAtLocationRadius(Location location1, Location location2, int radius) { + public static boolean isLocationAtLocationRadius(Location location1, Location location2, double radius) { if (location1 == null || location2 == null || !location1.getWorld().getName().equals(location2.getWorld().getName())) { return false; } - int x = Math.abs(location1.getBlockX() - location2.getBlockX()); - int z = Math.abs(location1.getBlockZ() - location2.getBlockZ()); + double x = Math.abs(location1.getX() - location2.getX()); + double z = Math.abs(location1.getZ() - location2.getZ()); return x < radius && z < radius; } diff --git a/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java b/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java index 78477177..6771f6a3 100644 --- a/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java +++ b/src/me/goodandevil/skyblock/utils/world/block/BlockUtil.java @@ -328,7 +328,6 @@ public final class BlockUtil { } else if (blockTypeState == BlockStateType.FLOWERPOT) { FlowerPot flowerPot = (FlowerPot) block.getState(); String[] flower = blockData.getFlower().split(":"); - Bukkit.broadcastMessage(flower[0] + " | " + flower[1]); flowerPot.setContents(new MaterialData(Material.valueOf(flower[0].toUpperCase()), (byte) Integer.parseInt(flower[1]))); } @@ -406,7 +405,7 @@ public final class BlockUtil { chunk.getClass().getMethod("setType", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true); } else { chunk.getClass().getMethod("a", blockPosition.getClass(), IBlockDataClass, boolean.class).invoke(chunk, blockPosition, IBlockData, true); - } + } } else { Object IBlockData = NMSUtil.getNMSClass("Block").getMethod("getByCombinedId", int.class).invoke(null, material.getId() + (data << 12)); worldHandle.getClass().getMethod("setTypeAndData", blockPosition.getClass(), IBlockDataClass, int.class).invoke(worldHandle, blockPosition, IBlockData, 3); diff --git a/src/me/goodandevil/skyblock/visit/VisitManager.java b/src/me/goodandevil/skyblock/visit/VisitManager.java index 19843b61..b217dc37 100644 --- a/src/me/goodandevil/skyblock/visit/VisitManager.java +++ b/src/me/goodandevil/skyblock/visit/VisitManager.java @@ -10,7 +10,6 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -20,6 +19,7 @@ import me.goodandevil.skyblock.config.FileManager; import me.goodandevil.skyblock.config.FileManager.Config; import me.goodandevil.skyblock.island.Island; import me.goodandevil.skyblock.island.Level; +import me.goodandevil.skyblock.message.MessageManager; import me.goodandevil.skyblock.sound.SoundManager; import me.goodandevil.skyblock.utils.version.Sounds; import me.goodandevil.skyblock.utils.world.LocationUtil; @@ -52,7 +52,7 @@ public class VisitManager { if (configFile.exists()) { for (File fileList : configFile.listFiles()) { - Config config = new FileManager.Config(fileList); + Config config = new FileManager.Config(fileManager, fileList); FileConfiguration configLoad = config.getFileConfiguration(); UUID islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", "")); @@ -99,6 +99,7 @@ public class VisitManager { } public void removeVisitors(Island island, VisitManager.Removal removal) { + MessageManager messageManager = plugin.getMessageManager(); SoundManager soundManager = plugin.getSoundManager(); FileManager fileManager = plugin.getFileManager(); @@ -110,7 +111,7 @@ public class VisitManager { LocationUtil.teleportPlayerToSpawn(targetPlayer); - targetPlayer.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Visit." + removal.name() + ".Message"))); + messageManager.sendMessage(targetPlayer, configLoad.getString("Island.Visit." + removal.name() + ".Message")); soundManager.playSound(targetPlayer, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F); } } diff --git a/src/me/goodandevil/skyblock/world/WorldManager.java b/src/me/goodandevil/skyblock/world/WorldManager.java index d13b867a..f41038ca 100644 --- a/src/me/goodandevil/skyblock/world/WorldManager.java +++ b/src/me/goodandevil/skyblock/world/WorldManager.java @@ -1,6 +1,7 @@ package me.goodandevil.skyblock.world; import java.io.File; +import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.World; @@ -37,7 +38,7 @@ public class WorldManager { netherWorld = Bukkit.getServer().getWorld(netherWorldName); if (normalWorld == null) { - Bukkit.getServer().getConsoleSender().sendMessage("SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'."); + Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'."); normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new VoidGenerator()).createWorld(); Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() { @@ -49,7 +50,7 @@ public class WorldManager { } if (netherWorld == null) { - Bukkit.getServer().getConsoleSender().sendMessage("SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'."); + Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'."); netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(World.Environment.NETHER).generator(new VoidGenerator()).createWorld(); Bukkit.getServer().getScheduler().runTask(plugin, new Runnable() {