mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Remove ServerNMS
Former-commit-id: 1b1fc2e4af612cc03658153c63d1b92974271f71 [formerly 08d6e1465493e8cce5ed2c5a56dd39d20d09710c] Former-commit-id: e12ba4bddfcf7aff9730c0dbda9ee1aac5d54df3
This commit is contained in:
1 parent
25279f5d43
commit
cbb0b5dac6
1 file changed
-44
@@ -1,44 +0,0 @@
|
||||
package org.maxgamer.quickshop.Util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public abstract class ServerNMS {
|
||||
private static Method craftItemStack_asNMSCopyMethod;
|
||||
private static Class<?> nbtTagCompoundClass;
|
||||
private static Method itemStack_saveMethod;
|
||||
|
||||
static {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
String nmsVersion = name.substring(name.lastIndexOf('.') + 1);
|
||||
|
||||
try {
|
||||
craftItemStack_asNMSCopyMethod = Class.forName("org.bukkit.craftbukkit." + nmsVersion + ".inventory.CraftItemStack")
|
||||
.getDeclaredMethod("asNMSCopy", ItemStack.class);
|
||||
|
||||
nbtTagCompoundClass = Class.forName("net.minecraft.server." + nmsVersion + ".NBTTagCompound");
|
||||
|
||||
itemStack_saveMethod = Class.forName("net.minecraft.server." + nmsVersion + ".ItemStack")
|
||||
.getDeclaredMethod("save", nbtTagCompoundClass);
|
||||
|
||||
} catch (Throwable t) {
|
||||
QuickShop.instance.getLogger().info("A error happend:");
|
||||
t.printStackTrace();
|
||||
QuickShop.instance.getLogger().info("Try update QSRR. And feedback this bug on issue tracker.");
|
||||
}
|
||||
}
|
||||
|
||||
public static String saveJsonfromNMS(ItemStack bStack) throws Throwable {
|
||||
if (bStack.getType() == Material.AIR)
|
||||
return null;
|
||||
Object mcStack = craftItemStack_asNMSCopyMethod.invoke(null, bStack);
|
||||
Object nbtTagCompound = nbtTagCompoundClass.newInstance();
|
||||
|
||||
itemStack_saveMethod.invoke(mcStack, nbtTagCompound);
|
||||
return nbtTagCompound.toString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user