diff --git a/config.yml b/config.yml index c7319120..ba2e579d 100644 --- a/config.yml +++ b/config.yml @@ -31,6 +31,12 @@ Island: Deletion: Enable: false Time: 300 + # Commands that are executed either by the player or the console on Island creation. + # [!] To add commands, create a list and remove the open and closed brackets. + # Use the variable %player to get the players name. + Commands: + Player: [] + Console: [] World: # [!] The Island height is 72 blocks. # Delete the Island world when changing the liquid option. diff --git a/language.yml b/language.yml index 65a89ff7..986604a7 100644 --- a/language.yml +++ b/language.yml @@ -839,6 +839,16 @@ Island: Division: Message: "&bSkyBlock &8| &aInfo&8: &eYou have set the points division to '&f%division&e'." Placeholder: + skyblock_island_size: + Empty: + Message: "&c0" + Non-empty: + Message: "&f%placeholder" + skyblock_island_radius: + Empty: + Message: "&c0" + Non-empty: + Message: "&f%placeholder" skyblock_island_level: Empty: Message: "&c0" @@ -925,6 +935,7 @@ Scoreboard: - "&bIsland&f:" - " &8- &7Level&8: &f%island_level" - " &8- &7Visitors&8: &f%island_visitors" + - " &8- &7Size&8: &f%island_size&7x&f%island_size" - "" - "&bProfile&f:" - " &8- &7Rank&8: &fDefault" @@ -936,6 +947,7 @@ Scoreboard: - "" - "&bIsland&f:" - " &8- &7Level&8: &f%island_level" + - " &8- &7Size&8: &f%island_size&7x&f%island_size" - "" - "&bProfile&f:" - " &8- &7Rank&8: &fDefault" @@ -956,6 +968,7 @@ Scoreboard: - " &8- &7Members&8: &f%island_members" - " &8- &7Level&8: &f%island_level" - " &8- &7Visitors&8: &f%island_visitors" + - " &8- &7Size&8: &f%island_size&7x&f%island_size" - "" - "&bProfile&f:" - " &8- &7Rank&8: &fDefault" @@ -969,6 +982,7 @@ Scoreboard: - " &8- &7Role&8: &f%island_role" - " &8- &7Members&8: &f%island_members" - " &8- &7Level&8: &f%island_level" + - " &8- &7Size&8: &f%island_size&7x&f%island_size" - "" - "&bProfile&f:" - " &8- &7Rank&8: &fDefault" diff --git a/plugin.yml b/plugin.yml index c6b435a5..0cc60baf 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkyBlock -main: me.goodandevil.skyblock.Main -version: 27 +main: me.goodandevil.skyblock.SkyBlock +version: 28 api-version: 1.13 description: A unique SkyBlock plugin author: GoodAndEvil diff --git a/src/me/goodandevil/skyblock/island/IslandManager.java b/src/me/goodandevil/skyblock/island/IslandManager.java index 6e9a8e15..7bd409f5 100644 --- a/src/me/goodandevil/skyblock/island/IslandManager.java +++ b/src/me/goodandevil/skyblock/island/IslandManager.java @@ -206,6 +206,29 @@ public class IslandManager { Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() { @Override public void run() { + Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (configLoad.getString("Island.Creation.Commands.Player") != null) { + List commands = configLoad.getStringList("Island.Creation.Commands.Player"); + + if (commands != null) { + for (String commandList : commands) { + Bukkit.getServer().dispatchCommand(player, commandList.replace("%player", player.getName())); + } + } + } + + if (configLoad.getString("Island.Creation.Commands.Console") != null) { + List commands = configLoad.getStringList("Island.Creation.Commands.Console"); + + if (commands != null) { + for (String commandList : commands) { + Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), commandList.replace("%player", player.getName())); + } + } + } + player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Main)); } }); diff --git a/src/me/goodandevil/skyblock/listeners/Chat.java b/src/me/goodandevil/skyblock/listeners/Chat.java index 59368143..9e34a64e 100644 --- a/src/me/goodandevil/skyblock/listeners/Chat.java +++ b/src/me/goodandevil/skyblock/listeners/Chat.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; @@ -17,6 +16,7 @@ import me.goodandevil.skyblock.events.IslandChatEvent; 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; @@ -33,6 +33,7 @@ public class Chat implements Listener { Player player = event.getPlayer(); PlayerDataManager playerDataManager = skyblock.getPlayerDataManager(); + MessageManager messageManager = skyblock.getMessageManager(); IslandManager islandManager = skyblock.getIslandManager(); if (playerDataManager.hasPlayerData(player)) { @@ -61,7 +62,7 @@ public class Chat implements Listener { 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())); + targetPlayer.sendMessage(messageManager.replaceMessage(targetPlayer, islandChatEvent.getFormat().replace("%role", islandRole).replace("%player", player.getName())).replace("%message", islandChatEvent.getMessage())); } } } diff --git a/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java b/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java index c8c88211..6aad722f 100644 --- a/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java +++ b/src/me/goodandevil/skyblock/placeholder/EZPlaceholder.java @@ -57,7 +57,11 @@ public class EZPlaceholder extends PlaceholderExpansion { if (islandManager.hasIsland(player)) { Island island = islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner()); - if (identifier.equalsIgnoreCase("island_level")) { + if (identifier.equalsIgnoreCase("island_size")) { + return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_size.Non-empty.Message").replace("%placeholder", "" + island.getSize())); + } else if (identifier.equalsIgnoreCase("island_radius")) { + return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_radius.Non-empty.Message").replace("%placeholder", "" + island.getRadius())); + } else if (identifier.equalsIgnoreCase("island_level")) { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_level.Non-empty.Message").replace("%placeholder", "" + island.getLevel().getLevel())); } else if (identifier.equalsIgnoreCase("island_points")) { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_points.Non-empty.Message").replace("%placeholder", "" + island.getLevel().getPoints())); @@ -101,7 +105,11 @@ public class EZPlaceholder extends PlaceholderExpansion { return null; } - if (identifier.equalsIgnoreCase("island_level")) { + if (identifier.equalsIgnoreCase("island_size")) { + return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_size.Empty.Message")); + } else if (identifier.equalsIgnoreCase("island_radius")) { + return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_radius.Empty.Message")); + } else if (identifier.equalsIgnoreCase("island_level")) { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_level.Empty.Message")); } else if (identifier.equalsIgnoreCase("island_points")) { return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_points.Empty.Message")); diff --git a/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java b/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java index 546b0ddd..079c4eb9 100644 --- a/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java +++ b/src/me/goodandevil/skyblock/placeholder/MVdWPlaceholder.java @@ -38,6 +38,40 @@ public class MVdWPlaceholder { return "" + skyblock.getVisitManager().getIslands().size(); } }); + + PlaceholderAPI.registerPlaceholder(skyblock, "skyblock_island_size", new PlaceholderReplacer() { + @Override + public String onPlaceholderReplace(PlaceholderReplaceEvent event) { + Player player = event.getPlayer(); + + if (player == null) { + return null; + } + + if (islandManager.hasIsland(player)) { + return "" + islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner()).getSize(); + } + + return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_size.Empty.Message")); + } + }); + + PlaceholderAPI.registerPlaceholder(skyblock, "skyblock_island_radius", new PlaceholderReplacer() { + @Override + public String onPlaceholderReplace(PlaceholderReplaceEvent event) { + Player player = event.getPlayer(); + + if (player == null) { + return null; + } + + if (islandManager.hasIsland(player)) { + return "" + islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner()).getRadius(); + } + + return ChatColor.translateAlternateColorCodes('&', configLoad.getString("Placeholder.skyblock_island_radius.Empty.Message")); + } + }); PlaceholderAPI.registerPlaceholder(skyblock, "skyblock_island_level", new PlaceholderReplacer() { @Override diff --git a/src/me/goodandevil/skyblock/scoreboard/Scoreboard.java b/src/me/goodandevil/skyblock/scoreboard/Scoreboard.java index 8444136c..296e0edf 100644 --- a/src/me/goodandevil/skyblock/scoreboard/Scoreboard.java +++ b/src/me/goodandevil/skyblock/scoreboard/Scoreboard.java @@ -173,7 +173,7 @@ public class Scoreboard { Level level = island.getLevel(); if (island.getRole(Role.Member).size() == 0 && island.getRole(Role.Operator).size() == 0) { - displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumber(level.getLevel())).replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null").replace("%island_visitors", "" + island.getVisitors().size()); + displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumber(level.getLevel())).replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null").replace("%island_visitors", "" + island.getVisitors().size()).replace("%island_size", "" + island.getSize()).replace("%island_radius", "" + island.getRadius()); } else { int islandMembers = 1 + island.getRole(Role.Member).size() + island.getRole(Role.Operator).size(); String islandRole = ""; @@ -186,10 +186,10 @@ public class Scoreboard { islandRole = displayVariables.get("%member"); } - displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumber(level.getLevel())).replace("%island_members", "" + islandMembers).replace("%island_role", islandRole).replace("%island_visitors", "" + island.getVisitors().size()); + displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumber(level.getLevel())).replace("%island_members", "" + islandMembers).replace("%island_role", islandRole).replace("%island_visitors", "" + island.getVisitors().size()).replace("%island_size", "" + island.getSize()).replace("%island_radius", "" + island.getRadius()); } } else { - displayLine = displayLine.replace("%island_level", ChatColor.RED + "0").replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null"); + displayLine = displayLine.replace("%island_level", ChatColor.RED + "0").replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null").replace("%island_size", ChatColor.RED + "0").replace("%island_radius", ChatColor.RED + "0"); } PlaceholderManager placeholderManager = skyblock.getPlaceholderManager();