diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarTitleMessages.java b/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarTitleMessages.java index cce216a9..83c0535b 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarTitleMessages.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ActionBarTitleMessages.java @@ -116,10 +116,11 @@ public class ActionBarTitleMessages { sendTitle(receivingPacket, title, subtitle, 0, 20, 20); } - public static void sendTitle(final Player receivingPacket, final Object title, final Object subtitle, final int fadeIn, final int keep, final int fadeOut) { + @SuppressWarnings("deprecation") + public static void sendTitle(final Player receivingPacket, final Object title, final Object subtitle, final int fadeIn, final int keep, final int fadeOut) { Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> { - String t = title == null ? null : CMIChatColor.translateAlternateColorCodes((String) title); - String s = subtitle == null ? null : CMIChatColor.translateAlternateColorCodes((String) subtitle); + String t = title == null ? null : CMIChatColor.translate((String) title); + String s = subtitle == null ? null : CMIChatColor.translate((String) subtitle); if (simpleTitleMessages) { receivingPacket.sendMessage(t); diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java index d10ace69..8e34b71c 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/CMIMaterial.java @@ -2653,10 +2653,7 @@ public enum CMIMaterial { } public boolean equals(Material mat) { - if (getMaterial() == null) { - return false; - } - return this.getMaterial().equals(mat); + return getMaterial() == null ? false : getMaterial().equals(mat); } public List getLegacyNames() { @@ -2681,7 +2678,7 @@ public enum CMIMaterial { public String getMojangName() { if (mojangName == null) - mojangName = Reflections.getItemMinecraftName(this.newItemStack()); + mojangName = ItemReflection.getItemMinecraftName(newItemStack()); return mojangName; } diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 53c7c939..bd4cbcfd 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -21,9 +21,9 @@ import com.gamingmesh.jobs.stuff.Util; public class ItemManager { - static HashMap byRealMaterial = new HashMap(); - static HashMap byId = new HashMap(); - static HashMap byName = new HashMap(); + static HashMap byRealMaterial = new HashMap<>(); + static HashMap byId = new HashMap<>(); + static HashMap byName = new HashMap<>(); public HashMap idMap() { return byId; @@ -218,7 +218,7 @@ public class ItemManager { return cm; } - HashMap headCache = new HashMap(); + HashMap headCache = new HashMap<>(); public CMIItemStack getItem(String name) { // if (byBukkitName.isEmpty()) @@ -471,7 +471,7 @@ public class ItemManager { } public List getAllRecipes() { - List results = new ArrayList(); + List results = new ArrayList<>(); Iterator iter = Bukkit.recipeIterator(); while (iter.hasNext()) { Recipe recipe = iter.next(); @@ -481,7 +481,7 @@ public class ItemManager { } public List getRecipesFor(ItemStack result) { - List results = new ArrayList(); + List results = new ArrayList<>(); Iterator iter = Bukkit.recipeIterator(); while (iter.hasNext()) { Recipe recipe = iter.next(); diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/Reflections.java b/src/main/java/com/gamingmesh/jobs/CMILib/Reflections.java index 065de798..14782895 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/Reflections.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/Reflections.java @@ -4,21 +4,18 @@ package com.gamingmesh.jobs.CMILib; -import java.lang.reflect.Field; import java.lang.reflect.Method; import org.bukkit.Bukkit; import org.bukkit.inventory.ItemStack; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.CMILib.VersionChecker.Version; public class Reflections { private Class CraftServerClass; private Object CraftServer; - private static Class Item; private static Class NBTTagCompound; private Class NBTBase; // private Class NBTTagList; @@ -48,7 +45,6 @@ public class Reflections { } catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) { e.printStackTrace(); }*/ - Item = getMinecraftClass("Item"); IStack = getMinecraftClass("ItemStack"); } catch (ClassCastException | ClassNotFoundException e) { e.printStackTrace(); @@ -288,30 +284,4 @@ public class Reflections { public Object getCraftServer() { return CraftServer; } - - public static String getItemMinecraftName(ItemStack item) { - try { - - Object nmsStack = asNMSCopy(item); - - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - Object pre = nmsStack.getClass().getMethod("getItem").invoke(nmsStack); - Object n = pre.getClass().getMethod("getName").invoke(pre); - Class ll = Class.forName("net.minecraft.server." + Version.getCurrent() + ".LocaleLanguage"); - Object lla = ll.getMethod("a").invoke(ll); - return (String) lla.getClass().getMethod("a", String.class).invoke(lla, (String) n); - } - - Field field = Item.getField("REGISTRY"); - Object reg = field.get(field); - Method meth = reg.getClass().getMethod("b", Object.class); - meth.setAccessible(true); - Method secmeth = nmsStack.getClass().getMethod("getItem"); - Object res2 = secmeth.invoke(nmsStack); - Object res = meth.invoke(reg, res2); - return res.toString(); - } catch (Exception e) { - return null; - } - } }