mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-06 16:27:59 +01:00
Correct some things
This commit is contained in:
parent
1c8316a4c1
commit
c162f1a2be
@ -116,10 +116,11 @@ public class ActionBarTitleMessages {
|
|||||||
sendTitle(receivingPacket, title, subtitle, 0, 20, 20);
|
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(), () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> {
|
||||||
String t = title == null ? null : CMIChatColor.translateAlternateColorCodes((String) title);
|
String t = title == null ? null : CMIChatColor.translate((String) title);
|
||||||
String s = subtitle == null ? null : CMIChatColor.translateAlternateColorCodes((String) subtitle);
|
String s = subtitle == null ? null : CMIChatColor.translate((String) subtitle);
|
||||||
|
|
||||||
if (simpleTitleMessages) {
|
if (simpleTitleMessages) {
|
||||||
receivingPacket.sendMessage(t);
|
receivingPacket.sendMessage(t);
|
||||||
|
@ -2653,10 +2653,7 @@ public enum CMIMaterial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Material mat) {
|
public boolean equals(Material mat) {
|
||||||
if (getMaterial() == null) {
|
return getMaterial() == null ? false : getMaterial().equals(mat);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.getMaterial().equals(mat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getLegacyNames() {
|
public List<String> getLegacyNames() {
|
||||||
@ -2681,7 +2678,7 @@ public enum CMIMaterial {
|
|||||||
|
|
||||||
public String getMojangName() {
|
public String getMojangName() {
|
||||||
if (mojangName == null)
|
if (mojangName == null)
|
||||||
mojangName = Reflections.getItemMinecraftName(this.newItemStack());
|
mojangName = ItemReflection.getItemMinecraftName(newItemStack());
|
||||||
return mojangName;
|
return mojangName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import com.gamingmesh.jobs.stuff.Util;
|
|||||||
|
|
||||||
public class ItemManager {
|
public class ItemManager {
|
||||||
|
|
||||||
static HashMap<Material, CMIMaterial> byRealMaterial = new HashMap<Material, CMIMaterial>();
|
static HashMap<Material, CMIMaterial> byRealMaterial = new HashMap<>();
|
||||||
static HashMap<Integer, CMIMaterial> byId = new HashMap<Integer, CMIMaterial>();
|
static HashMap<Integer, CMIMaterial> byId = new HashMap<>();
|
||||||
static HashMap<String, CMIMaterial> byName = new HashMap<String, CMIMaterial>();
|
static HashMap<String, CMIMaterial> byName = new HashMap<>();
|
||||||
|
|
||||||
public HashMap<Integer, CMIMaterial> idMap() {
|
public HashMap<Integer, CMIMaterial> idMap() {
|
||||||
return byId;
|
return byId;
|
||||||
@ -218,7 +218,7 @@ public class ItemManager {
|
|||||||
return cm;
|
return cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, ItemStack> headCache = new HashMap<String, ItemStack>();
|
HashMap<String, ItemStack> headCache = new HashMap<>();
|
||||||
|
|
||||||
public CMIItemStack getItem(String name) {
|
public CMIItemStack getItem(String name) {
|
||||||
// if (byBukkitName.isEmpty())
|
// if (byBukkitName.isEmpty())
|
||||||
@ -471,7 +471,7 @@ public class ItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Recipe> getAllRecipes() {
|
public List<Recipe> getAllRecipes() {
|
||||||
List<Recipe> results = new ArrayList<Recipe>();
|
List<Recipe> results = new ArrayList<>();
|
||||||
Iterator<Recipe> iter = Bukkit.recipeIterator();
|
Iterator<Recipe> iter = Bukkit.recipeIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Recipe recipe = iter.next();
|
Recipe recipe = iter.next();
|
||||||
@ -481,7 +481,7 @@ public class ItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Recipe> getRecipesFor(ItemStack result) {
|
public List<Recipe> getRecipesFor(ItemStack result) {
|
||||||
List<Recipe> results = new ArrayList<Recipe>();
|
List<Recipe> results = new ArrayList<>();
|
||||||
Iterator<Recipe> iter = Bukkit.recipeIterator();
|
Iterator<Recipe> iter = Bukkit.recipeIterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Recipe recipe = iter.next();
|
Recipe recipe = iter.next();
|
||||||
|
@ -4,21 +4,18 @@
|
|||||||
|
|
||||||
package com.gamingmesh.jobs.CMILib;
|
package com.gamingmesh.jobs.CMILib;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
|
||||||
|
|
||||||
public class Reflections {
|
public class Reflections {
|
||||||
|
|
||||||
private Class<?> CraftServerClass;
|
private Class<?> CraftServerClass;
|
||||||
private Object CraftServer;
|
private Object CraftServer;
|
||||||
|
|
||||||
private static Class<?> Item;
|
|
||||||
private static Class<?> NBTTagCompound;
|
private static Class<?> NBTTagCompound;
|
||||||
private Class<?> NBTBase;
|
private Class<?> NBTBase;
|
||||||
// private Class<?> NBTTagList;
|
// private Class<?> NBTTagList;
|
||||||
@ -48,7 +45,6 @@ public class Reflections {
|
|||||||
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
} catch (ClassNotFoundException | SecurityException | IllegalArgumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
Item = getMinecraftClass("Item");
|
|
||||||
IStack = getMinecraftClass("ItemStack");
|
IStack = getMinecraftClass("ItemStack");
|
||||||
} catch (ClassCastException | ClassNotFoundException e) {
|
} catch (ClassCastException | ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -288,30 +284,4 @@ public class Reflections {
|
|||||||
public Object getCraftServer() {
|
public Object getCraftServer() {
|
||||||
return CraftServer;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user