diff --git a/pom.xml b/pom.xml index 51efeb3c..411ccb76 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ net.milkbowl.vault Vault - 1.6.7 + 1.7.3 provided @@ -145,13 +145,25 @@ bukkit + + net.java.truevfs + + truevfs-profile-default_2.13 + + me.clip - placeholderapi - 2.10.6 + PlaceholderAPI + 2.10.7 provided + + + me.rayzr522 + jsonmessage + + diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarManager.java index f6e8f8b8..f7131db7 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarManager.java @@ -62,8 +62,7 @@ public class ActionBarManager { return; } - RawMessage rm = new RawMessage(); - rm.add(msg); + RawMessage rm = new RawMessage().addText(msg); Object serialized = nmsChatSerializer.getMethod("a", String.class).invoke(null, CMIChatColor.translate(rm.getRaw())); if (Version.isCurrentHigher(Version.v1_15_R1)) packet = packetType.getConstructor(nmsIChatBaseComponent, sub, UUID.class).newInstance(serialized, consts[2], receivingPacket.getUniqueId()); diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java index 6b5deced..f8c83814 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java @@ -1196,7 +1196,7 @@ public enum CMIMaterial { @Deprecated public Integer getLegacyId() { - return this.legacyId == null ? 0 : this.legacyId; + return legacyId == null ? 0 : legacyId; } @Deprecated @@ -1317,8 +1317,6 @@ public enum CMIMaterial { List ls = new ArrayList<>(); for (CMIMaterial one : CMIMaterial.values()) { - if (one.getLegacyId() == null) - continue; if (one.getLegacyId() != mat.getLegacyId()) continue; ls.add(one); @@ -1348,8 +1346,6 @@ public enum CMIMaterial { if (mat == null) return CMIMaterial.NONE; for (CMIMaterial one : CMIMaterial.values()) { - if (one.getLegacyId() == null) - continue; if (one.getLegacyId() != mat.getLegacyId()) continue; if (one.getLegacyData() == id) @@ -1417,9 +1413,7 @@ public enum CMIMaterial { if (mat == null) return CMIMaterial.NONE; CMIMaterial m = ItemManager.byRealMaterial.get(mat); - if (m != null) - return m; - return get(mat.toString()); + return m != null ? m : get(mat.toString()); } public static CMIMaterial get(int id) { @@ -1455,10 +1449,7 @@ public enum CMIMaterial { } public static CMIMaterial get(Block block) { - if (block == null) - return CMIMaterial.NONE; - - if (Bukkit.getWorld(block.getWorld().getUID()) == null) + if (block == null || Bukkit.getWorld(block.getWorld().getUID()) == null) return CMIMaterial.NONE; if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { @@ -1498,17 +1489,15 @@ public enum CMIMaterial { public static CMIMaterial getLegacy(int id) { CMIMaterial mat = ItemManager.byId.get(id); - if (mat != null) - return mat; - return CMIMaterial.NONE; + return mat != null ? mat : CMIMaterial.NONE; } public short getMaxDurability() { - return this.getMaterial() == null ? 0 : this.getMaterial().getMaxDurability(); + return getMaterial() == null ? 0 : getMaterial().getMaxDurability(); } public boolean isBlock() { - return this.getMaterial() == null ? false : this.getMaterial().isBlock(); + return getMaterial() == null ? false : getMaterial().isBlock(); } public boolean isEquipment() { @@ -1516,14 +1505,12 @@ public enum CMIMaterial { } public boolean isSolid() { - return this.getMaterial() == null ? false : this.getMaterial().isSolid(); + return getMaterial() == null ? false : getMaterial().isSolid(); } public static boolean isMonsterEgg(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isMonsterEgg(); + return m == null ? false : m.isMonsterEgg(); } public boolean isMonsterEgg() { @@ -1608,9 +1595,7 @@ public enum CMIMaterial { public static boolean isBed(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isBed(); + return m == null ? false : m.isBed(); } public boolean isBed() { @@ -1641,9 +1626,7 @@ public enum CMIMaterial { public static boolean isStairs(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isStairs(); + return m == null ? false : m.isStairs(); } public boolean isStairs() { @@ -1695,9 +1678,7 @@ public enum CMIMaterial { public static boolean isPotion(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isPotion(); + return m == null ? false : m.isPotion(); } public boolean isPotion() { @@ -1714,9 +1695,7 @@ public enum CMIMaterial { public static boolean isBoat(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isBoat(); + return m == null ? false : m.isBoat(); } public boolean isBoat() { @@ -1736,9 +1715,7 @@ public enum CMIMaterial { public static boolean isSapling(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isSapling(); + return m == null ? false : m.isSapling(); } public boolean isSapling() { @@ -1758,9 +1735,7 @@ public enum CMIMaterial { public static boolean isButton(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isButton(); + return m == null ? false : m.isButton(); } public boolean isButton() { @@ -1783,9 +1758,7 @@ public enum CMIMaterial { public static boolean isWater(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isWater(); + return m == null ? false : m.isWater(); } public boolean isWater() { @@ -1801,9 +1774,7 @@ public enum CMIMaterial { public static boolean isLava(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isLava(); + return m == null ? false : m.isLava(); } public boolean isLava() { @@ -1819,9 +1790,7 @@ public enum CMIMaterial { public static boolean isPlate(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isPlate(); + return m == null ? false : m.isPlate(); } public boolean isPlate() { @@ -1847,9 +1816,7 @@ public enum CMIMaterial { public static boolean isWool(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isWool(); + return m == null ? false : m.isWool(); } public boolean isWool() { @@ -1879,9 +1846,7 @@ public enum CMIMaterial { public static boolean isCarpet(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isCarpet(); + return m == null ? false : m.isCarpet(); } public boolean isCarpet() { @@ -1911,9 +1876,7 @@ public enum CMIMaterial { public static boolean isShulkerBox(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isShulkerBox(); + return m == null ? false : m.isShulkerBox(); } public boolean isShulkerBox() { @@ -1944,9 +1907,7 @@ public enum CMIMaterial { public static boolean isLeatherArmor(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isLeatherArmor(); + return m == null ? false : m.isLeatherArmor(); } public boolean isLeatherArmor() { @@ -1964,9 +1925,7 @@ public enum CMIMaterial { public static boolean isArmor(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isArmor(); + return m == null ? false : m.isArmor(); } public boolean isArmor() { @@ -2010,9 +1969,7 @@ public enum CMIMaterial { public static boolean isWeapon(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isWeapon(); + return m == null ? false : m.isWeapon(); } public boolean isWeapon() { @@ -2035,9 +1992,7 @@ public enum CMIMaterial { public static boolean isTool(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isTool(); + return m == null ? false : m.isTool(); } public boolean isTool() { @@ -2079,15 +2034,22 @@ public enum CMIMaterial { return false; } + public static boolean isValidItem(Material mat) { + CMIMaterial m = CMIMaterial.get(mat); + return m == null ? false : m.isValidItem(); + } + + public boolean isValidItem() { + return !equals(CMIMaterial.NONE) && !isAir() && getMaterial() != null; + } + public boolean isNone() { - return this.equals(CMIMaterial.NONE); + return equals(CMIMaterial.NONE); } public static boolean isAir(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isAir(); + return m == null ? false : m.isAir(); } public boolean isAir() { @@ -2104,9 +2066,7 @@ public enum CMIMaterial { public static boolean isPotted(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isPotted(); + return m == null ? false : m.isPotted(); } public boolean isPotted() { @@ -2145,9 +2105,7 @@ public enum CMIMaterial { public static boolean isAnvil(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isAnvil(); + return m == null ? false : m.isAnvil(); } public boolean isAnvil() { @@ -2164,9 +2122,7 @@ public enum CMIMaterial { public static boolean isDoor(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isDoor(); + return m == null ? false : m.isDoor(); } public boolean isDoor() { @@ -2205,9 +2161,7 @@ public enum CMIMaterial { public static boolean isGate(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isGate(); + return m == null ? false : m.isGate(); } public boolean isGate() { @@ -2230,9 +2184,7 @@ public enum CMIMaterial { public static boolean isFence(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isFence(); + return m == null ? false : m.isFence(); } public boolean isFence() { @@ -2256,9 +2208,7 @@ public enum CMIMaterial { public static boolean isRail(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isRail(); + return m == null ? false : m.isRail(); } public boolean isRail() { @@ -2276,9 +2226,7 @@ public enum CMIMaterial { public static boolean isGlassPane(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isGlassPane(); + return m == null ? false : m.isGlassPane(); } public boolean isGlassPane() { @@ -2309,9 +2257,7 @@ public enum CMIMaterial { public static boolean isWallSign(Material mat) { CMIMaterial m = get(mat); - if (m == null) - return false; - return m.isWallSign(); + return m == null ? false : m.isWallSign(); } public boolean isWallSign() { @@ -2334,9 +2280,7 @@ public enum CMIMaterial { public static boolean isSign(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isSign(); + return m == null ? false : m.isSign(); } public boolean isSign() { @@ -2378,9 +2322,7 @@ public enum CMIMaterial { public static boolean isWall(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isWall(); + return m == null ? false : m.isWall(); } public boolean isWall() { @@ -2409,9 +2351,7 @@ public enum CMIMaterial { public static boolean isTrapDoor(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isTrapDoor(); + return m == null ? false : m.isTrapDoor(); } public boolean isTrapDoor() { @@ -2434,9 +2374,7 @@ public enum CMIMaterial { public static boolean isSkull(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isSkull(); + return m == null ? false : m.isSkull(); } public boolean isSkull() { @@ -2458,9 +2396,7 @@ public enum CMIMaterial { public static boolean isDye(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isDye(); + return m == null ? false : m.isDye(); } public boolean isDye() { @@ -2498,9 +2434,7 @@ public enum CMIMaterial { public static boolean isSlab(Material mat) { CMIMaterial m = CMIMaterial.get(mat); - if (m == null) - return false; - return m.isSlab(); + return m == null ? false : m.isSlab(); } public boolean isSlab() { diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index a0973aa9..ae30deef 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -25,9 +25,8 @@ import com.gamingmesh.jobs.CMILib.CMIChatColor; import com.gamingmesh.jobs.CMILib.CMIReflections; import com.gamingmesh.jobs.CMILib.VersionChecker; import com.gamingmesh.jobs.Gui.GuiManager; -import com.gamingmesh.jobs.Placeholders.NewPlaceholderAPIHook; -import com.gamingmesh.jobs.Placeholders.Placeholder; import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook; +import com.gamingmesh.jobs.Placeholders.Placeholder; import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.Signs.SignUtil; import com.gamingmesh.jobs.api.JobsExpGainEvent; @@ -133,24 +132,26 @@ public class Jobs extends JavaPlugin { return Placeholder; } - @SuppressWarnings("deprecation") private boolean setupPlaceHolderAPI() { if (!getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) return false; try { if (Integer.parseInt(getServer().getPluginManager().getPlugin("PlaceholderAPI") - .getDescription().getVersion().replace(".", "")) >= Integer.parseInt("2100")) { - if (new NewPlaceholderAPIHook(this).register()) - consoleMsg("&e[Jobs] PlaceholderAPI hooked."); - } else { - if (new PlaceholderAPIHook(this).hook()) - consoleMsg("&e[Jobs] PlaceholderAPI hooked. This is a deprecated version of PlaceholderAPI. Please update " - + "to the latest version."); + .getDescription().getVersion().replace(".", "")) >= Integer.parseInt("2107")) { + PlaceholderAPIHook hook = new PlaceholderAPIHook(this); + if (hook.canRegister()) { + hook.getPlaceholderAPI().getLocalExpansionManager().register(hook); + if (hook.isRegistered()) + consoleMsg("&e[Jobs] PlaceholderAPI hooked."); + } } } catch (NumberFormatException e) { // when using a dev build - if (new NewPlaceholderAPIHook(this).register()) { - consoleMsg("&e[Jobs] PlaceholderAPI hooked."); + PlaceholderAPIHook hook = new PlaceholderAPIHook(this); + if (hook.canRegister()) { + hook.getPlaceholderAPI().getLocalExpansionManager().register(hook); + if (hook.isRegistered()) + consoleMsg("&e[Jobs] PlaceholderAPI hooked."); } } @@ -1295,7 +1296,8 @@ public class Jobs extends JavaPlugin { return false; } RawMessage rm = new RawMessage(); - rm.add(lManager.getMessage("general.error.permission"), "&2" + perm); + rm.addText(lManager.getMessage("general.error.permission")); + rm.addHover("&2" + perm); rm.show((Player) sender); return false; @@ -1323,15 +1325,17 @@ public class Jobs extends JavaPlugin { Prevpage = CurrentPage > 1 ? Prevpage : CurrentPage; RawMessage rm = new RawMessage(); + rm.addText((CurrentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff"))); + rm.addHover(CurrentPage > 1 ? "<<<" : ">|"); + rm.addCommand(CurrentPage > 1 ? cmd + " " + pagePrefix + Prevpage : cmd + " " + pagePrefix + pageCount); + + rm.addText(lManager.getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount)); + rm.addHover(lManager.getMessage("command.help.output.pageCountHover", "[totalEntries]", totalEntries)); + + rm.addText(pageCount > CurrentPage ? lManager.getMessage("command.help.output.nextPage") : lManager.getMessage("command.help.output.nextPageOff")); + rm.addHover(pageCount > CurrentPage ? ">>>" : "|<"); + rm.addCommand(pageCount > CurrentPage ? cmd + " " + pagePrefix + NextPage : cmd + " " + pagePrefix + 1); - rm.add((CurrentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff")), - CurrentPage > 1 ? "<<<" : ">|", - CurrentPage > 1 ? cmd + " " + pagePrefix + Prevpage : cmd + " " + pagePrefix + pageCount); - rm.add(lManager.getMessage("command.help.output.pageCount", "[current]", CurrentPage, "[total]", pageCount), lManager.getMessage("command.help.output.pageCountHover", "[totalEntries]", - totalEntries)); - rm.add(pageCount > CurrentPage ? lManager.getMessage("command.help.output.nextPage") : lManager.getMessage("command.help.output.nextPageOff"), - pageCount > CurrentPage ? ">>>" : "|<", - pageCount > CurrentPage ? cmd + " " + pagePrefix + NextPage : cmd + " " + pagePrefix + 1); if (pageCount != 0) rm.show(sender); } diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/NewPlaceholderAPIHook.java b/src/main/java/com/gamingmesh/jobs/Placeholders/NewPlaceholderAPIHook.java deleted file mode 100644 index f1d365d4..00000000 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/NewPlaceholderAPIHook.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.gamingmesh.jobs.Placeholders; - -import org.bukkit.entity.Player; - -import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders; - -import me.clip.placeholderapi.expansion.PlaceholderExpansion; - -public class NewPlaceholderAPIHook extends PlaceholderExpansion { - - private Jobs plugin; - - public NewPlaceholderAPIHook(Jobs plugin) { - this.plugin = plugin; - } - - @Override - public String onPlaceholderRequest(Player player, String identifier) { - JobsPlaceHolders placeHolder = JobsPlaceHolders.getByName(identifier); - if (placeHolder == null) - return null; - - return plugin.getPlaceholderAPIManager().getValue(player, placeHolder, "%" + Placeholder.pref + "_" + identifier + "%"); - } - - @Override - public boolean persist() { - return true; - } - - @Override - public boolean canRegister() { - return true; - } - - @Override - public String getAuthor() { - return plugin.getDescription().getAuthors().toString(); - } - - @Override - public String getIdentifier() { - return Placeholder.pref; - } - - @Override - public String getVersion() { - return plugin.getDescription().getVersion(); - } -} diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index be74907a..fda002c9 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -11,6 +11,7 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; @@ -283,7 +284,7 @@ public class Placeholder { } if (plugin.isPlaceholderAPIEnabled()) { if (placeholder.contains("%")) { - if (!placeholder.equals(me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, placeholder))) + if (!placeholder.equals(me.clip.placeholderapi.PlaceholderAPI.setPlaceholders((OfflinePlayer) player, placeholder))) return JobsPlaceholderType.PAPI; } } @@ -303,7 +304,7 @@ public class Placeholder { message = translateOwnPlaceHolder(player, message); if (plugin.isPlaceholderAPIEnabled()) { if (message.contains("%")) - message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message); + message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders((OfflinePlayer) player, message); } // For MVdWPlaceholderAPI // if (plugin.isMVdWPlaceholderAPIEnabled()) { diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java b/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java index 4e7b28df..e0b89c78 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java @@ -5,24 +5,47 @@ import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders; -import me.clip.placeholderapi.external.EZPlaceholderHook; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; -public class PlaceholderAPIHook extends EZPlaceholderHook { +public class PlaceholderAPIHook extends PlaceholderExpansion { private Jobs plugin; public PlaceholderAPIHook(Jobs plugin) { - super(plugin, Placeholder.pref); this.plugin = plugin; } @Override public String onPlaceholderRequest(Player player, String identifier) { JobsPlaceHolders placeHolder = JobsPlaceHolders.getByName(identifier); - if (placeHolder == null) { + if (placeHolder == null) return null; - } + return plugin.getPlaceholderAPIManager().getValue(player, placeHolder, "%" + Placeholder.pref + "_" + identifier + "%"); } + @Override + public boolean persist() { + return true; + } + + @Override + public boolean canRegister() { + return true; + } + + @Override + public String getAuthor() { + return plugin.getDescription().getAuthors().toString(); + } + + @Override + public String getIdentifier() { + return Placeholder.pref; + } + + @Override + public String getVersion() { + return plugin.getDescription().getVersion(); + } } diff --git a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java index 52d088c3..1f83b8c1 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java @@ -250,7 +250,7 @@ public class SignUtil { } TopList pl = PlayerList.get(i + number); - String PlayerName = pl.getPlayerName(); + String PlayerName = pl.getPlayerInfo().getName(); if (PlayerName.length() > 15) { // We need to split 10 char of name, because of sign rows PlayerName = PlayerName.split("(?<=\\G.{10})")[0] + "~"; @@ -273,7 +273,7 @@ public class SignUtil { sign.setLine(i, line); } sign.update(); - if (!UpdateHead(sign, PlayerList.get(0).getPlayerName(), timelapse)) { + if (!UpdateHead(sign, PlayerList.get(0).getPlayerInfo().getName(), timelapse)) { timelapse--; } } else { @@ -281,7 +281,7 @@ public class SignUtil { continue; TopList pl = PlayerList.get(jSign.getNumber() - 1); - String PlayerName = pl.getPlayerName(); + String PlayerName = pl.getPlayerInfo().getName(); if (PlayerName.length() > 15) { PlayerName = PlayerName.split("(?<=\\G.{10})")[0] + "~"; } @@ -304,7 +304,7 @@ public class SignUtil { sign.setLine(3, translateSignLine("signs.SpecialList.bottom", no, PlayerName, pl.getLevel(), SignJobName)); sign.update(); - if (!UpdateHead(sign, pl.getPlayerName(), timelapse)) { + if (!UpdateHead(sign, pl.getPlayerInfo().getName(), timelapse)) { timelapse--; } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index dc07814a..8f1510ed 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -81,7 +81,8 @@ public class JobsCommands implements CommandExecutor { if (!hasCommandPermission(sender, cmd)) { if (sender instanceof Player) { RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + label + ".command." + cmd); + rm.addText(Jobs.getLanguage().getMessage("general.error.permission")); + rm.addHover("&2" + label + ".command." + cmd); rm.show(sender); } else sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission")); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/archive.java b/src/main/java/com/gamingmesh/jobs/commands/list/archive.java index fb54b758..61606634 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/archive.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/archive.java @@ -45,12 +45,15 @@ public class archive implements Cmd { for (JobProgression jobInfo : AllJobs) { RawMessage rm = new RawMessage(); if (jobInfo.canRejoin()) - rm.add(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo), Jobs.getLanguage().getMessage("command.join.rejoin"), "jobs join " + jobInfo.getJob().getName()); + rm.addText(ChatColor.GREEN + "+" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo)) + .addHover(Jobs.getLanguage().getMessage("command.join.rejoin")).addCommand("jobs join " + jobInfo.getJob().getName()); else - rm.add(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo), Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo + rm.addText(ChatColor.RED + "-" + Jobs.getCommandManager().jobStatsMessageArchive(jPlayer, jobInfo)) + .addHover(Jobs.getLanguage().getMessage("command.join.error.rejoin", "[time]", jobInfo .getRejoinTimeMessage())); rm.show(sender); } + sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); return true; } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java b/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java index dd4466a3..9d9a0203 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java @@ -67,7 +67,7 @@ public class bonus implements Cmd { "%exp%", formatText(boost.getFinal(CurrencyType.EXP, true, true))); rm.addText(msg); - rm.addHoverText(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation")); + rm.addHover(Jobs.getLanguage().getMessage("command.bonus.output.finalExplanation")); rm.build(); rm.show(player); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/browse.java b/src/main/java/com/gamingmesh/jobs/commands/list/browse.java index aa951454..6a198514 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/browse.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/browse.java @@ -110,8 +110,8 @@ public class browse implements Cmd { hoverMsg += " \n"; hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); - rm.add(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), "[jobname]", one.getName()), - hoverMsg, "jobs browse -j:" + one.getName()); + rm.addText(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), + "[jobname]", one.getName())).addHover(hoverMsg).addCommand("jobs browse -j:" + one.getName()); rm.show(sender); } @@ -140,15 +140,13 @@ public class browse implements Cmd { } RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.browse.output.detailed"), - Jobs.getLanguage().getMessage("command.browse.output.detailed"), - "jobs info " + j.getName()); + rm.addText(Jobs.getLanguage().getMessage("command.browse.output.detailed")) + .addHover(Jobs.getLanguage().getMessage("command.browse.output.detailed")).addCommand("jobs info " + j.getName()); rm.show(sender); rm.clear(); - rm.add(Jobs.getLanguage().getMessage("command.browse.output.chooseJob"), - Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover"), - "jobs join " + j.getName() + " -needConfirmation"); - rm.show(sender); + rm.addText(Jobs.getLanguage().getMessage("command.browse.output.chooseJob")) + .addHover(Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover")) + .addCommand("jobs join " + j.getName() + " -needConfirmation").show(sender); } } else { if (j == null) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java index e110f291..a6b5ce8e 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java @@ -1,5 +1,6 @@ package com.gamingmesh.jobs.commands.list; +import com.gamingmesh.jobs.CMILib.CMIChatColor; import com.gamingmesh.jobs.CMILib.ItemReflection; import com.gamingmesh.jobs.CMILib.RawMessage; import com.gamingmesh.jobs.Jobs; @@ -403,21 +404,22 @@ public class editjobs implements Cmd { private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo) { RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.job"), "&eJob list", "jobs editjobs"); - rm.show(player); + rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.job")).addHover("&eJob list") + .addCommand("jobs editjobs").show(player); if (job != null) { rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getChatColor() + job.getName()), job.getName(), "jobs editjobs list " + job.getName()); + rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getNameWithColor())) + .addHover(job.getName()).addCommand("jobs editjobs list " + job.getName()); rm.show(player); } if (action != null && job != null) { rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", action.getName()), action.getName(), "jobs editjobs list " + job.getName() + " " + action.getName() - + " 1"); - rm.show(player); + rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.actions", "%actionname%", action.getName())) + .addHover(action.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName()+ " 1") + .show(player); } if (action != null && job != null && jInfo != null) { @@ -426,11 +428,11 @@ public class editjobs implements Cmd { String materialName = jInfo.getName().toLowerCase().replace('_', ' '); materialName = Character.toUpperCase(materialName.charAt(0)) + materialName.substring(1); materialName = Jobs.getNameTranslatorManager().Translate(materialName, jInfo); - materialName = org.bukkit.ChatColor.translateAlternateColorCodes('&', materialName); + materialName = CMIChatColor.translate(materialName); - rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName()), jInfo.getName(), "jobs editjobs list " + job.getName() + " " + action.getName() - + " " + materialName); - rm.show(player); + rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.material", "%materialname%", jInfo.getName())) + .addHover(jInfo.getName()).addCommand("jobs editjobs list " + job.getName() + " " + action.getName() + + " " + materialName).show(player); } } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java b/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java index 42f0bcd0..ff0e7689 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java @@ -595,22 +595,22 @@ public class editquests implements Cmd { private static void showPath(Player player, Job job, ActionType action, JobInfo jInfo, Quest q) { RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.quest"), "&eQuest list", "jobs editquests"); + rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.list.quest")).addHover("&eQuest list") + .addCommand("jobs editquests"); rm.show(player); if (job != null) { rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", job.getNameWithColor()), - job.getName(), "jobs editquests list " + job.getName()); + rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", job.getNameWithColor())) + .addHover(job.getName()).addCommand("jobs editquests list " + job.getName()); rm.show(player); } if (action != null && job != null) { rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", action.getName()), - action.getName(), "jobs editquests list " + job.getName() + " " + action.getName() - + " 1"); + rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", action.getName())) + .addHover(action.getName()).addCommand("jobs editquests list " + job.getName() + " " + action.getName() + " 1"); rm.show(player); } @@ -619,8 +619,8 @@ public class editquests implements Cmd { String materialName = jInfo.getRealisticName(); - rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.quests", "%questname%", q.getConfigName()), - jInfo.getName(), "jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName() + rm.addText(Jobs.getLanguage().getMessage("command.editquests.help.list.quests", "%questname%", q.getConfigName())) + .addHover(jInfo.getName()).addCommand("jobs editquests list " + job.getName() + " " + action.getName() + " " + q.getConfigName() + " " + materialName); rm.show(player); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java b/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java index 3a428c0e..7e798228 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/gtop.java @@ -63,10 +63,9 @@ public class gtop implements Cmd { if (i > amount) break; - String PlayerName = One.getPlayerName(); sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list", "%number%", pi.getPositionForOutput(i-1), - "%playername%", PlayerName, + "%playername%", One.getPlayerInfo().getName(), "%level%", One.getLevel(), "%exp%", One.getExp())); ++i; @@ -80,7 +79,7 @@ public class gtop implements Cmd { ls.add(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", pi.getPositionForOutput(i), - "%playername%", one.getPlayerName(), + "%playername%", one.getPlayerInfo().getName(), "%level%", one.getLevel())); ++i; } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/itembonus.java b/src/main/java/com/gamingmesh/jobs/commands/list/itembonus.java index 90f3a2a0..2709e755 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/itembonus.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/itembonus.java @@ -33,7 +33,6 @@ public class itembonus implements Cmd { Player player = (Player) sender; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - if (jPlayer == null) return false; @@ -41,7 +40,7 @@ public class itembonus implements Cmd { List items = new ArrayList<>(); - if (iih != null && !iih.getType().equals(Material.AIR)) + if (iih != null && iih.getType() != Material.AIR) items.add(iih); for (ItemStack OneArmor : player.getInventory().getArmorContents()) { @@ -56,13 +55,9 @@ public class itembonus implements Cmd { JobItems jitem = Jobs.getPlayerManager().getJobsItemByNbt(oneI); if (jitem == null) continue; - for (Job one : jitem.getJobs()) { - BoostMultiplier boost = null; - if (!jPlayer.isInJob(one)) - boost = jitem.getBoost(); - else - boost = jitem.getBoost(jPlayer.getJobProgression(one)); + for (Job one : jitem.getJobs()) { + BoostMultiplier boost = !jPlayer.isInJob(one) ? jitem.getBoost() : jitem.getBoost(jPlayer.getJobProgression(one)); boolean any = false; for (CurrencyType oneC : CurrencyType.values()) { @@ -91,7 +86,6 @@ public class itembonus implements Cmd { "%points%", pc + formatText((int) (boost.get(CurrencyType.POINTS) * 100)), "%exp%", ec + formatText((int) (boost.get(CurrencyType.EXP) * 100))); - RawMessage rm = new RawMessage(); String name = CMIMaterial.get(oneI.getType()).getName(); if (jitem.getFromLevel() != 0 || jitem.getUntilLevel() != Integer.MAX_VALUE) @@ -99,8 +93,7 @@ public class itembonus implements Cmd { "%from%", jitem.getFromLevel(), "%until%", jitem.getUntilLevel()); - rm.add(msg, name); - rm.show(sender); + new RawMessage().addText(msg).addHover(name).show(sender); } } return true; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/join.java b/src/main/java/com/gamingmesh/jobs/commands/list/join.java index 766b8be6..cc4c2b5a 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/join.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/join.java @@ -66,10 +66,9 @@ public class join implements Cmd { } if (args.length == 2 && args[1].equalsIgnoreCase("-needConfirmation")) { - RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()), - Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName()), "jobs join " + job.getName()); - rm.show(pSender); + new RawMessage().addText(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName())) + .addHover(Jobs.getLanguage().getMessage("command.join.confirm", "[jobname]", job.getName())) + .addCommand("jobs join " + job.getName()).show(pSender); return true; } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java b/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java index e3539a41..e8e45591 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java @@ -85,8 +85,8 @@ public class placeholders implements Cmd { // else // hover += "\n" + "{" + one.getFull().substring(1, one.getFull().length() - 2) + "}"; // } - rm.add(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra, hover, null, one.getFull()); - rm.show(sender); + rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra) + .addHover(hover).addSuggestion(one.getFull()).show(sender); } if (player != null) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java index 9f2cdb1e..24a46d1c 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java @@ -132,9 +132,9 @@ public class quests implements Cmd { hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip"); hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests())); } - rm.add(msg, hover, "jobs skipquest " + jobProg.getJob().getName() + " " + q.getQuest().getConfigName() + " " + jPlayer.getName()); + rm.addText(msg).addHover(hover).addCommand("jobs skipquest " + jobProg.getJob().getName() + " " + q.getQuest().getConfigName() + " " + jPlayer.getName()); } else - rm.add(msg, hover); + rm.addText(msg).addHover(hover); rm.show(sender); } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/stats.java b/src/main/java/com/gamingmesh/jobs/commands/list/stats.java index a43fda87..39b97b4c 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/stats.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/stats.java @@ -40,9 +40,8 @@ public class stats implements Cmd { sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName())); for (JobProgression jobProg : jPlayer.getJobProgression()) { for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg).split("\n")) { - RawMessage rm = new RawMessage(); - rm.add(msg, Jobs.getLanguage().getMessage("command.info.gui.leftClick"), "jobs info " + jobProg.getJob().getName()); - rm.show(sender); + new RawMessage().addText(msg).addHover(Jobs.getLanguage().getMessage("command.info.gui.leftClick")) + .addCommand("jobs info " + jobProg.getJob().getName()).show(sender); } } sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/top.java b/src/main/java/com/gamingmesh/jobs/commands/list/top.java index c2753f64..b76284c0 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/top.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/top.java @@ -75,7 +75,7 @@ public class top implements Cmd { player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.list", "%number%", pi.getPositionForOutput(), - "%playername%", One.getPlayerName(), + "%playername%", One.getPlayerInfo().getName(), "%level%", One.getLevel(), "%exp%", One.getExp())); } @@ -90,7 +90,7 @@ public class top implements Cmd { break; ls.add(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", pi.getPositionForOutput(), - "%playername%", one.getPlayerName(), "%level%", one.getLevel())); + "%playername%", one.getPlayerInfo().getName(), "%level%", one.getLevel())); } plugin.getCMIScoreboardManager().setScoreBoard(player, Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", job.getName()), ls); diff --git a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java index ba2c94c0..259f4f34 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java +++ b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java @@ -70,7 +70,7 @@ public class ExploreChunk { } public Set getPlayers() { - return playerIds == null ? new HashSet() : playerIds; + return playerIds == null ? new HashSet<>() : playerIds; } public String serializeNames() { @@ -94,7 +94,7 @@ public class ExploreChunk { } if (playerIds == null) { - playerIds = new HashSet(); + playerIds = new HashSet<>(); } List split = Arrays.asList(names.split(";")); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 7622d0bf..ccc84e22 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1243,8 +1243,7 @@ public class JobsPaymentListener implements Listener { Projectile pr = (Projectile) e.getDamager(); if (pr.getShooter() instanceof Player) pDamager = (Player) pr.getShooter(); - } else - return; + } if (pDamager == null) return; @@ -1290,8 +1289,7 @@ public class JobsPaymentListener implements Listener { if (jPlayer == null) return; - List jobs = jPlayer.getJobProgression(); - for (JobProgression job : jobs) { + for (JobProgression job : jPlayer.getJobProgression()) { Jobs.action(jDamager, new CustomKillInfo(job.getJob().getName(), ActionType.CUSTOMKILL), pDamager, lVictim); } }