更新
This commit is contained in:
parent
381d96c5b1
commit
93e84b1b80
@ -12,7 +12,6 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
@ -169,7 +168,7 @@ public class TConfigInjector {
|
||||
return ((Collection) o).stream().map(this::serialize).collect(Collectors.toList());
|
||||
} else if (o instanceof Map) {
|
||||
Map map = new LinkedHashMap<>();
|
||||
((Map) o).forEach((o1, o2) -> map.put((String) o1, serialize(o2)));
|
||||
((Map) o).forEach((o1, o2) -> map.put(o1, serialize(o2)));
|
||||
return map;
|
||||
} else if (o instanceof ConfigurationSerializable) {
|
||||
Map map = new LinkedHashMap<>();
|
||||
|
@ -4,17 +4,12 @@ import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
|
||||
public final class TLocale {
|
||||
|
||||
|
@ -11,7 +11,6 @@ import javax.annotation.concurrent.ThreadSafe;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -1,14 +1,8 @@
|
||||
package com.ilummc.tlib.resources;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
@ -16,7 +10,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -24,6 +17,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.inject.TConfigInjector;
|
||||
import com.ilummc.tlib.resources.type.TLocaleText;
|
||||
import com.ilummc.tlib.resources.type.TLocaleTitle;
|
||||
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||
@ -43,6 +37,7 @@ public class TLocaleLoader {
|
||||
|
||||
public static void init() {
|
||||
ConfigurationSerialization.registerClass(TLocaleText.class, "TEXT");
|
||||
ConfigurationSerialization.registerClass(TLocaleTitle.class, "TITLE");
|
||||
}
|
||||
|
||||
public static void load(Plugin plugin, boolean ignoreLoaded) {
|
||||
|
@ -17,6 +17,7 @@ public class AnvilContainer_V1_11_R1 extends ContainerAnvil {
|
||||
super(player.inventory, player.world, new BlockPosition(0, 0, 0), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player)
|
||||
{
|
||||
return true;
|
||||
@ -25,6 +26,7 @@ public class AnvilContainer_V1_11_R1 extends ContainerAnvil {
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
@Deprecated
|
||||
public static void openAnvil(Player p)
|
||||
{
|
||||
EntityPlayer player = ((CraftPlayer)p).getHandle();
|
||||
|
@ -17,6 +17,7 @@ public class AnvilContainer_V1_8_R3 extends ContainerAnvil {
|
||||
super(player.inventory, player.world, new BlockPosition(0, 0, 0), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player)
|
||||
{
|
||||
return true;
|
||||
@ -25,6 +26,7 @@ public class AnvilContainer_V1_8_R3 extends ContainerAnvil {
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
@Deprecated
|
||||
public static void openAnvil(Player p)
|
||||
{
|
||||
EntityPlayer player = ((CraftPlayer)p).getHandle();
|
||||
|
@ -17,6 +17,7 @@ public class AnvilContainer_V1_9_4 extends ContainerAnvil {
|
||||
super(player.inventory, player.world, new BlockPosition(0, 0, 0), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman player)
|
||||
{
|
||||
return true;
|
||||
@ -25,6 +26,7 @@ public class AnvilContainer_V1_9_4 extends ContainerAnvil {
|
||||
/**
|
||||
* @deprecated 方法已过期,已有新的方法
|
||||
*/
|
||||
@Deprecated
|
||||
public static void openAnvil(Player p)
|
||||
{
|
||||
EntityPlayer player = ((CraftPlayer)p).getHandle();
|
||||
|
@ -979,7 +979,8 @@ public class CsvReader
|
||||
}
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
@Override
|
||||
protected void finalize() {
|
||||
this.close(false);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,8 @@ public class CsvWriter
|
||||
}
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
@Override
|
||||
protected void finalize() {
|
||||
this.close(false);
|
||||
}
|
||||
|
||||
|
@ -2,65 +2,51 @@ package me.skymc.taboolib.display;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
* @since 2018-04-26
|
||||
*/
|
||||
public class ActionUtils {
|
||||
|
||||
private static void sendPacket(Player player, Object packet)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object handle = player.getClass().getMethod("getHandle", new Class[0]).invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", new Class[]{getNMSClass("Packet")}).invoke(playerConnection, packet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static Class<?> Packet = NMSUtils.getNMSClass("Packet");
|
||||
private static Class<?> ChatComponentText = NMSUtils.getNMSClass("ChatComponentText");
|
||||
private static Class<?> ChatMessageType = NMSUtils.getNMSClass("ChatMessageType");
|
||||
private static Class<?> PacketPlayOutChat = NMSUtils.getNMSClass("PacketPlayOutChat");
|
||||
private static Class<?> IChatBaseComponent = NMSUtils.getNMSClass("IChatBaseComponent");
|
||||
|
||||
private static Class<?> getNMSClass(String class_name)
|
||||
{
|
||||
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
try
|
||||
{
|
||||
return Class.forName("net.minecraft.server." + version + "." + class_name);
|
||||
public static void send(Player player, String action) {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void send(Player p, String msg)
|
||||
{
|
||||
if (msg == null) {
|
||||
msg = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
Object ab = getNMSClass("ChatComponentText").getConstructor(new Class[]{String.class}).newInstance(msg);
|
||||
try {
|
||||
Object ab = ChatComponentText.getConstructor(String.class).newInstance(action);
|
||||
Constructor<?> ac = null;
|
||||
Object abPacket = null;
|
||||
// 如果版本大于 1.11.0
|
||||
if (TabooLib.getVerint() > 11100) {
|
||||
Class<?> chatMessageType = getNMSClass("ChatMessageType");
|
||||
ac = getNMSClass("PacketPlayOutChat").getConstructor(getNMSClass("IChatBaseComponent"), chatMessageType);
|
||||
abPacket = ac.newInstance(ab, chatMessageType.getMethod("a", Byte.TYPE).invoke(null, (byte) 2));
|
||||
ac = PacketPlayOutChat.getConstructor(IChatBaseComponent, ChatMessageType);
|
||||
abPacket = ac.newInstance(ab, ChatMessageType.getMethod("a", Byte.TYPE).invoke(null, (byte) 2));
|
||||
} else {
|
||||
ac = getNMSClass("PacketPlayOutChat").getConstructor(getNMSClass("IChatBaseComponent"), Byte.TYPE);
|
||||
ac = PacketPlayOutChat.getConstructor(IChatBaseComponent, Byte.TYPE);
|
||||
abPacket = ac.newInstance(ab, (byte) 2);
|
||||
}
|
||||
sendPacket(p, abPacket);
|
||||
sendPacket(player, abPacket);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getMethod("getHandle", new Class[0]).invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", Packet).invoke(playerConnection, packet);
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,85 +1,69 @@
|
||||
package me.skymc.taboolib.display;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.skymc.taboolib.nms.NMSUtils;
|
||||
|
||||
/**
|
||||
* @author Bkm016
|
||||
* @since 2018-04-26
|
||||
*/
|
||||
public class TitleUtils {
|
||||
|
||||
private static void sendPacket(Player player, Object packet)
|
||||
{
|
||||
try
|
||||
{
|
||||
Object handle = player.getClass().getMethod("getHandle", new Class[0]).invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", new Class[]{getNMSClass("Packet")}).invoke(playerConnection, packet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> getNMSClass(String class_name)
|
||||
{
|
||||
String version = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
try
|
||||
{
|
||||
return Class.forName("net.minecraft.server." + version + "." + class_name);
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static Class<?> Packet = NMSUtils.getNMSClass("Packet");
|
||||
private static Class<?> PacketPlayOutTitle = NMSUtils.getNMSClass("PacketPlayOutTitle");
|
||||
private static Class<?> IChatBaseComponent = NMSUtils.getNMSClass("IChatBaseComponent");
|
||||
private static Class<?> EnumTitleAction = PacketPlayOutTitle.getDeclaredClasses()[0];
|
||||
|
||||
public static void sendTitle(Player p, String title, String subtitle, int fadein, int stay, int fadeout) {
|
||||
sendTitle(p, title, fadein, stay, fadeout, subtitle, fadein, stay, fadeout);
|
||||
}
|
||||
|
||||
public static void sendTitle(Player p, String title, int fadeint, int stayt, int fadeoutt, String subtitle, int fadeinst, int stayst, int fadeoutst)
|
||||
{
|
||||
if (title == null) {
|
||||
title = "";
|
||||
}
|
||||
if (subtitle == null) {
|
||||
subtitle = "";
|
||||
}
|
||||
try
|
||||
{
|
||||
if (title != null)
|
||||
{
|
||||
Object e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TIMES").get(null);
|
||||
Object chatTitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke(null, "{\"text\":\"" + title + "\"}");
|
||||
Constructor<?> subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), Integer.TYPE, Integer.TYPE, Integer.TYPE);
|
||||
Object titlePacket = subtitleConstructor.newInstance(e, chatTitle, fadeint, stayt, fadeoutt);
|
||||
public static void sendTitle(Player p, String title, int fadeint, int stayt, int fadeoutt, String subtitle, int fadeinst, int stayst, int fadeoutst) {
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (title != null) {
|
||||
Object times = EnumTitleAction.getField("TIMES").get(null);
|
||||
Object chatTitle = IChatBaseComponent.getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + title + "\"}");
|
||||
Constructor<?> subtitleConstructor = PacketPlayOutTitle.getConstructor(EnumTitleAction, IChatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE);
|
||||
Object titlePacket = subtitleConstructor.newInstance(times, chatTitle, fadeint, stayt, fadeoutt);
|
||||
sendPacket(p, titlePacket);
|
||||
|
||||
e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TITLE").get(null);
|
||||
chatTitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke(null, "{\"text\":\"" + title + "\"}");
|
||||
subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"));
|
||||
titlePacket = subtitleConstructor.newInstance(e, chatTitle);
|
||||
times = EnumTitleAction.getField("TITLE").get(null);
|
||||
chatTitle = IChatBaseComponent.getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + title + "\"}");
|
||||
subtitleConstructor = PacketPlayOutTitle.getConstructor(EnumTitleAction, IChatBaseComponent);
|
||||
titlePacket = subtitleConstructor.newInstance(times, chatTitle);
|
||||
sendPacket(p, titlePacket);
|
||||
}
|
||||
if (subtitle != null)
|
||||
{
|
||||
Object e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TIMES").get(null);
|
||||
Object chatSubtitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke(null, "{\"text\":\"" + title + "\"}");
|
||||
Constructor<?> subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), Integer.TYPE, Integer.TYPE, Integer.TYPE);
|
||||
Object subtitlePacket = subtitleConstructor.newInstance(e, chatSubtitle, fadeinst, stayst, fadeoutst);
|
||||
if (subtitle != null) {
|
||||
Object times = EnumTitleAction.getField("TIMES").get(null);
|
||||
Object chatSubtitle = IChatBaseComponent.getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + title + "\"}");
|
||||
Constructor<?> subtitleConstructor = PacketPlayOutTitle.getConstructor(EnumTitleAction, IChatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE);
|
||||
Object subtitlePacket = subtitleConstructor.newInstance(times, chatSubtitle, fadeinst, stayst, fadeoutst);
|
||||
sendPacket(p, subtitlePacket);
|
||||
|
||||
e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("SUBTITLE").get(null);
|
||||
chatSubtitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke(null, "{\"text\":\"" + subtitle + "\"}");
|
||||
subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), Integer.TYPE, Integer.TYPE, Integer.TYPE);
|
||||
subtitlePacket = subtitleConstructor.newInstance(e, chatSubtitle, fadeinst, stayst, fadeoutst);
|
||||
times = EnumTitleAction.getField("SUBTITLE").get(null);
|
||||
chatSubtitle = IChatBaseComponent.getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + subtitle + "\"}");
|
||||
subtitleConstructor = PacketPlayOutTitle.getConstructor(EnumTitleAction, IChatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE);
|
||||
subtitlePacket = subtitleConstructor.newInstance(times, chatSubtitle, fadeinst, stayst, fadeoutst);
|
||||
sendPacket(p, subtitlePacket);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getDeclaredMethod("getHandle").invoke(player);
|
||||
Object playerConnection = handle.getClass().getDeclaredField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getDeclaredMethod("sendPacket", Packet).invoke(playerConnection, packet);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public class DefaultEvent extends Event {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ public class DefaultEvent2 extends PlayerEvent
|
||||
return DefaultEvent2.handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return DefaultEvent2.handlers;
|
||||
}
|
||||
|
||||
@ -34,11 +35,13 @@ public class DefaultEvent2 extends PlayerEvent
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
@Override
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
|
@ -24,17 +24,20 @@ public class PlayerJumpEvent
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean e)
|
||||
@Override
|
||||
public void setCancelled(boolean e)
|
||||
{
|
||||
this.isCancelled = e;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class PlayerLoadedEvent extends Event {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -2,11 +2,9 @@ package me.skymc.taboolib.fileutils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -15,8 +13,6 @@ import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.ilummc.tlib.TLib;
|
||||
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
|
||||
public class ConfigUtils {
|
||||
|
||||
public static FileConfiguration decodeYAML(String args) {
|
||||
|
@ -24,11 +24,13 @@ public class NBTContainer extends NBTCompound{
|
||||
}
|
||||
}
|
||||
|
||||
protected Object getCompound() {
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
protected void setCompound(Object tag) {
|
||||
@Override
|
||||
protected void setCompound(Object tag) {
|
||||
nbt = tag;
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,13 @@ public class NBTEntity extends NBTCompound {
|
||||
ent = entity;
|
||||
}
|
||||
|
||||
protected Object getCompound() {
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return NBTReflectionUtil.getEntityNBTTagCompound(NBTReflectionUtil.getNMSEntity(ent));
|
||||
}
|
||||
|
||||
protected void setCompound(Object compound) {
|
||||
@Override
|
||||
protected void setCompound(Object compound) {
|
||||
NBTReflectionUtil.setEntityNBTTag(compound, NBTReflectionUtil.getNMSEntity(ent));
|
||||
}
|
||||
|
||||
|
@ -35,11 +35,13 @@ public class NBTFile extends NBTCompound {
|
||||
return file;
|
||||
}
|
||||
|
||||
protected Object getCompound() {
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
protected void setCompound(Object compound) {
|
||||
@Override
|
||||
protected void setCompound(Object compound) {
|
||||
nbt = compound;
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,13 @@ public class NBTItem extends NBTCompound {
|
||||
bukkitItem = item.clone();
|
||||
}
|
||||
|
||||
protected Object getCompound() {
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return NBTReflectionUtil.getItemRootNBTTagCompound(NBTReflectionUtil.getNMSItemStack(bukkitItem));
|
||||
}
|
||||
|
||||
protected void setCompound(Object compound) {
|
||||
@Override
|
||||
protected void setCompound(Object compound) {
|
||||
bukkitItem = NBTReflectionUtil.getBukkitItemStack(NBTReflectionUtil.setNBTTag(compound, NBTReflectionUtil.getNMSItemStack(bukkitItem)));
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,13 @@ public class NBTTileEntity extends NBTCompound {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
protected Object getCompound() {
|
||||
@Override
|
||||
protected Object getCompound() {
|
||||
return NBTReflectionUtil.getTileEntityNBTTagCompound(tile);
|
||||
}
|
||||
|
||||
protected void setCompound(Object compound) {
|
||||
@Override
|
||||
protected void setCompound(Object compound) {
|
||||
NBTReflectionUtil.setTileEntityNBTTagCompound(tile, compound);
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,8 @@ public class JSONArray {
|
||||
return jo;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return '[' + this.join(",") + ']';
|
||||
} catch (Exception e) {
|
||||
|
@ -15,7 +15,8 @@ public class JSONException extends Exception {
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
public Throwable getCause() {
|
||||
@Override
|
||||
public Throwable getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,18 @@ public class JSONObject {
|
||||
|
||||
private static final class Null {
|
||||
|
||||
protected final Object clone() {
|
||||
@Override
|
||||
protected final Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object == null || object == this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
@ -702,7 +705,8 @@ public class JSONObject {
|
||||
return ja;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return this.toString(0);
|
||||
} catch (Exception e) {
|
||||
|
@ -8,7 +8,8 @@ public class JSONStringer extends JSONWriter {
|
||||
super(new StringWriter());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.mode == 'd' ? this.writer.toString() : null;
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,8 @@ public class JSONTokener {
|
||||
return new JSONException(message + this.toString());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return " at " + this.index + " [character " + this.character + " line " +
|
||||
this.line + "]";
|
||||
}
|
||||
|
@ -285,6 +285,7 @@ public class MysqlConnection {
|
||||
*
|
||||
* @see Example: SQL_ClearTable("tablename");
|
||||
*/
|
||||
@Deprecated
|
||||
public void SQL_ClearTable(String table) {
|
||||
if (!isConnection()) {
|
||||
return;
|
||||
|
@ -804,6 +804,7 @@ public class MySQLConnection {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (type instanceof ColumnInteger || type instanceof ColumnChar) {
|
||||
return "`" + name + "` " + type.toString().toLowerCase() + "(" + a + ")";
|
||||
|
@ -52,8 +52,7 @@ public class NMSUtils {
|
||||
public static Class<?> getNMSClass(String className){
|
||||
try{
|
||||
return getNMSClassWithException(className);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}catch(Exception ignored){
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -89,8 +88,7 @@ public class NMSUtils {
|
||||
public static Class<?> getOBCClass(String className){
|
||||
try{
|
||||
return getOBCClassWithException(className);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}catch(Exception ignored){
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -106,8 +104,7 @@ public class NMSUtils {
|
||||
public static Object getHandle(Object obj){
|
||||
try{
|
||||
return getMethodWithException(obj.getClass(), "getHandle").invoke(obj);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}catch(Exception ignored){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBanner(){
|
||||
return banner;
|
||||
}
|
||||
@ -43,18 +44,21 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nmis = NMSUtils.getClass("net.minecraft.item.ItemStack"), cis = NMSUtils.getOBCClass("inventory.CraftItemStack");
|
||||
public Method nmscopy = NMSUtils.getMethodSilent(cis, "asNMSCopy", ItemStack.class);
|
||||
|
||||
@Override
|
||||
public Object getNMSCopy(ItemStack is) throws Exception{
|
||||
return nmscopy.invoke(null, is);
|
||||
}
|
||||
|
||||
public Method hastag = NMSUtils.getMethodSilent(nmis, "func_77978_p");
|
||||
|
||||
@Override
|
||||
public boolean hasTag(Object is) throws Exception{
|
||||
return (boolean)hastag.invoke(is);
|
||||
}
|
||||
|
||||
public Method acm = NMSUtils.getMethodSilent(cis, "asCraftMirror", nmis);
|
||||
|
||||
@Override
|
||||
public ItemStack asCraftMirror(Object nis) throws Exception{
|
||||
return (ItemStack)acm.invoke(null, nis);
|
||||
}
|
||||
@ -63,12 +67,14 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method abc = NMSUtils.getMethodSilent(cis, "asBukkitCopy", nmis);
|
||||
|
||||
@Override
|
||||
public ItemStack asBukkitCopy(Object nmis) throws Exception{
|
||||
return (ItemStack)abc.invoke(null, nmis);
|
||||
}
|
||||
|
||||
public Method gn = NMSUtils.getMethodSilent(nmis, "func_77977_a");
|
||||
|
||||
@Override
|
||||
public String getName(ItemStack is){
|
||||
try{
|
||||
return (String)gn.invoke(getNMSCopy(is));
|
||||
@ -79,14 +85,17 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gi = NMSUtils.getMethodSilent(nmis, "func_77973_b"), ia = getA();
|
||||
|
||||
@Override
|
||||
public Object getItem(Object nis) throws Exception{
|
||||
return gi.invoke(nis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getA(){
|
||||
return NMSUtils.getMethodSilent(ni, "func_77658_a", nmis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawName(ItemStack is){
|
||||
try{
|
||||
Object nis = getNMSCopy(is);
|
||||
@ -98,6 +107,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getName");
|
||||
|
||||
@Override
|
||||
public String getItemName(ItemStack is){
|
||||
try{
|
||||
return (String)gin.invoke(gi.invoke(getNMSCopy(is)));
|
||||
@ -108,6 +118,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Object registry = getRegistry();
|
||||
|
||||
@Override
|
||||
public Object getRegistry(){
|
||||
try{
|
||||
return NMSUtils.getFieldSilent(ni, "REGISTRY", "field_150901_e").get(null);
|
||||
@ -120,6 +131,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Field nmrsc = NMSUtils.getFieldSilent(nmrs, "field_82596_a");
|
||||
|
||||
@Override
|
||||
public String getMinecraftName(ItemStack is){
|
||||
String name = getItemName(is);
|
||||
if(nmrs == null){ return name; }
|
||||
@ -139,22 +151,26 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nbttc = NMSUtils.getClass("net.minecraft.nbt.NBTTagCompound");
|
||||
public Field tag = NMSUtils.getField(nmis, "field_77990_d");
|
||||
|
||||
@Override
|
||||
public Object getTag(Object is) throws Exception{
|
||||
return tag.get(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTag(Object is, Object tag1) throws Exception{
|
||||
tag.set(is, tag1);
|
||||
}
|
||||
|
||||
public Method nbtcie = NMSUtils.getMethodSilent(nbttc, "func_82582_d");
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(Object tag) throws Exception{
|
||||
return (boolean)nbtcie.invoke(tag);
|
||||
}
|
||||
|
||||
public Field nbttcm = NMSUtils.getField(nbttc, "field_74784_a");
|
||||
|
||||
@Override
|
||||
public Object getMap(Object tag) throws Exception{
|
||||
return nbttcm.get(tag);
|
||||
}
|
||||
@ -167,32 +183,39 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public Method nbttcsl = NMSUtils.getMethodSilent(nbttc, "func_74772_a", String.class, long.class);
|
||||
public Method nbttcss1 = NMSUtils.getMethodSilent(nbttc, "func_74777_a", String.class, short.class);
|
||||
|
||||
@Override
|
||||
public void set(Object tag, String key, Object value) throws Exception{
|
||||
nbttcs.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(Object tag, String key, String value) throws Exception{
|
||||
nbttcss.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(Object tag, String key, short value) throws Exception{
|
||||
nbttcss1.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(Object tag, String key, int i) throws Exception{
|
||||
nbttcsi.invoke(tag, key, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(Object tag, String key, double d) throws Exception{
|
||||
nbttcsd.invoke(tag, key, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(Object tag, String key, long l) throws Exception{
|
||||
nbttcsl.invoke(tag, key, l);
|
||||
}
|
||||
|
||||
public Method nbttchk = NMSUtils.getMethodSilent(nbttc, "func_74764_b", String.class);
|
||||
|
||||
@Override
|
||||
public boolean hasKey(Object tag, String key) throws Exception{
|
||||
return (boolean)nbttchk.invoke(tag, key);
|
||||
}
|
||||
@ -204,38 +227,46 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public Method nbttcgl = NMSUtils.getMethodSilent(nbttc, "func_74763_f", String.class);
|
||||
public Method nbttcgs1 = NMSUtils.getMethodSilent(nbttc, "func_74765_d", String.class);
|
||||
|
||||
@Override
|
||||
public Object get(Object tag, String key) throws Exception{
|
||||
return nbttcg.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(Object tag, String key) throws Exception{
|
||||
return (String)nbttcgs.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Object tag, String key) throws Exception{
|
||||
return (int)nbttcgi.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Object tag, String key) throws Exception{
|
||||
return (double)nbttcgd.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(Object tag, String key) throws Exception{
|
||||
return (long)nbttcgl.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(Object tag, String key) throws Exception{
|
||||
return (short)nbttcgs1.invoke(tag, key);
|
||||
}
|
||||
|
||||
public Constructor<?> nbttcc = NMSUtils.getConstructorSilent(nbttc);
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagCompound() throws Exception{
|
||||
return nbttcc.newInstance();
|
||||
}
|
||||
|
||||
public Method hkot = NMSUtils.getMethodSilent(nbttc, "func_150297_b", String.class, int.class);
|
||||
|
||||
@Override
|
||||
public boolean hasAttributeModifiersKey(Object tag) throws Exception{
|
||||
return (boolean)hkot.invoke(tag, "AttributeModifiers", 9);
|
||||
}
|
||||
@ -247,38 +278,46 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public Method nbttla = NMSUtils.getMethodSilent(nbttl, "func_74742_a", nbtb);
|
||||
public Constructor<?> nbttlc = NMSUtils.getConstructorSilent(nbttl);
|
||||
|
||||
@Override
|
||||
public Object getList(Object tag) throws Exception{
|
||||
return gl.invoke(tag, "AttributeModifiers", 9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getList(Object tag, String name, int id) throws Exception{
|
||||
return gl.invoke(tag, name, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUnbreakable(Object tag) throws Exception{
|
||||
return (boolean)gb.invoke(tag, "Unbreakable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnbreakable(Object tag, boolean value) throws Exception{
|
||||
sb.invoke(tag, "Unbreakable", value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagList() throws Exception{
|
||||
return nbttlc.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToList(Object taglist, Object nbt) throws Exception{
|
||||
nbttla.invoke(taglist, nbt);
|
||||
}
|
||||
|
||||
public Method gs = NMSUtils.getMethodSilent(nbttl, "func_74745_c");
|
||||
|
||||
@Override
|
||||
public int getSize(Object list) throws Exception{
|
||||
return (int)gs.invoke(list);
|
||||
}
|
||||
|
||||
public Method g = NMSUtils.getMethodSilent(nbttl, "func_150305_b", int.class);
|
||||
|
||||
@Override
|
||||
public Object get(Object tlist, int i) throws Exception{
|
||||
return g.invoke(tlist, i);
|
||||
}
|
||||
@ -322,16 +361,19 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
public Field nbtsd = NMSUtils.getField(nbts, "field_74752_a");
|
||||
public Field nbtstd = NMSUtils.getField(nbtst, "field_74751_a");
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagByte(byte value) throws Exception{
|
||||
return nbtbc.newInstance(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagByteArray(byte[] value) throws Exception{
|
||||
return nbtbac.newInstance(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(Object nbt) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
switch(i){
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
return nbtbd.get(nbt);
|
||||
@ -359,6 +401,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object createData(Object value) throws Exception{
|
||||
if(value.getClass().equals(byte.class)){ return nbtbc.newInstance(value); }
|
||||
@ -375,6 +418,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public Map<String, Object> convertCompoundTagToValueMap(Object nbt) throws Exception{
|
||||
Map<String, Object> ret = new HashMap<>();
|
||||
@ -389,6 +433,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> convertListTagToValueList(Object nbttl) throws Exception{
|
||||
List<Object> ret = new ArrayList<>();
|
||||
@ -402,6 +447,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValueMapToCompoundTag(Map<String, Object> map) throws Exception{
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
for(Entry<String, Object> e : map.entrySet()){
|
||||
@ -412,6 +458,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValueListToListTag(List<Object> list) throws Exception{
|
||||
List<Object> value = new ArrayList<>();
|
||||
for(Object e : list){
|
||||
@ -425,6 +472,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertListTagToJSON(Object nbttl, JSONArray ja, JSONArray helper) throws Exception{
|
||||
@ -437,6 +485,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertListTagToJSON(Object nbttl, JSONArray ja) throws Exception{
|
||||
List<Object> list = (List<Object>)nbtld.get(nbttl);
|
||||
@ -448,6 +497,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertCompoundTagToJSON(Object nbt, JSONObject jo, JSONObject helper) throws Exception{
|
||||
@ -461,6 +511,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertCompoundTagToJSON(Object nbt, JSONObject jo) throws Exception{
|
||||
Map<String, Object> map = (Map<String, Object>)getMap(nbt);
|
||||
@ -473,6 +524,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertJSONToCompoundTag(JSONObject jo, JSONObject helper) throws Exception{
|
||||
@ -487,6 +539,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertJSONToCompoundTag(JSONObject jo) throws Exception{
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
@ -500,6 +553,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertJSONToListTag(JSONArray ja, JSONArray helper) throws Exception{
|
||||
@ -515,6 +569,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertJSONToListTag(JSONArray ja) throws Exception{
|
||||
List value = new ArrayList();
|
||||
@ -529,9 +584,10 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object getDataJSON(String key, Object nbt, JSONObject jo, JSONObject helper) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
Object help = i;
|
||||
switch(i){
|
||||
@ -584,8 +640,9 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDataJSON(Object nbt) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
switch(i){
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
@ -632,8 +689,9 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return new JSONArray(new Object[]{ i, ret });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDataJSON(Object nbt, JSONArray ja, JSONArray helper) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
Object help = i;
|
||||
switch(i){
|
||||
@ -685,6 +743,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(String key, JSONObject jo, JSONObject helper) throws Exception{
|
||||
Object help = helper.get(key);
|
||||
Object ret = null;
|
||||
@ -740,6 +799,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(String key, JSONObject jo) throws Exception{
|
||||
JSONArray j = jo.getJSONArray(key);
|
||||
Object ret = null;
|
||||
@ -775,7 +835,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return nbtbac.newInstance("", b);
|
||||
}
|
||||
case NBTConstants.TYPE_STRING:
|
||||
ret = nbtstc.newInstance("", (String)j.get(1));
|
||||
ret = nbtstc.newInstance("", j.get(1));
|
||||
break;
|
||||
case NBTConstants.TYPE_INT_ARRAY:
|
||||
JSONArray ja = jo.getJSONArray(key);
|
||||
@ -791,6 +851,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(Object o){
|
||||
if(o.getClass().equals(Integer.class)){ return (byte)(int)o; }
|
||||
if(o.getClass().equals(Short.class)){ return (byte)(short)o; }
|
||||
@ -798,40 +859,46 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return (byte)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(Object o){
|
||||
if(o.getClass().equals(Integer.class)){ return (short)(int)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (short)(byte)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (byte)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (short)(int)o; }
|
||||
return (short)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Object o){
|
||||
if(o.getClass().equals(Short.class)){ return (int)(short)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (int)(byte)o; }
|
||||
if(o.getClass().equals(Short.class)){ return (short)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (byte)o; }
|
||||
return (int)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Object o){
|
||||
if(o.getClass().equals(Float.class)){ return (double)(float)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (double)(long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (double)(int)o; }
|
||||
if(o.getClass().equals(Float.class)){ return (float)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (double)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(Object o){
|
||||
if(o.getClass().equals(Double.class)){ return (float)(double)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (float)(long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (float)(int)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (float)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(Object o){
|
||||
if(o.getClass().equals(Float.class)){ return (long)(float)o; }
|
||||
if(o.getClass().equals(Double.class)){ return (long)(double)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (long)(int)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (long)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(int key, JSONArray jo, JSONArray helper) throws Exception{
|
||||
Object help = helper.get(key);
|
||||
Object ret = null;
|
||||
@ -887,6 +954,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(int key, JSONArray jo) throws Exception{
|
||||
JSONArray j = jo.getJSONArray(key);
|
||||
Object ret = null;
|
||||
@ -922,7 +990,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return nbtbac.newInstance("", b);
|
||||
}
|
||||
case NBTConstants.TYPE_STRING:
|
||||
ret = nbtstc.newInstance("", (String)j.get(1));
|
||||
ret = nbtstc.newInstance("", j.get(1));
|
||||
break;
|
||||
case NBTConstants.TYPE_INT_ARRAY:
|
||||
JSONArray ja = jo.getJSONArray(key);
|
||||
@ -938,9 +1006,10 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compareBaseTag(Object tag, Object tag1) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(tag));
|
||||
int i1 = (int)((byte)gti.invoke(tag1));
|
||||
int i = ((byte)gti.invoke(tag));
|
||||
int i1 = ((byte)gti.invoke(tag1));
|
||||
if(i != i1)
|
||||
return false;
|
||||
switch(i){
|
||||
@ -989,6 +1058,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean compareCompoundTag(Object tag, Object tag1) throws Exception{
|
||||
Map<String, Object> map = (Map<String, Object>)getMap(tag);
|
||||
@ -1006,6 +1076,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public boolean compareListTag(Object tag, Object tag1) throws Exception{
|
||||
List list = (List)nbtld.get(tag);
|
||||
@ -1055,6 +1126,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compare(ItemStack is1, ItemStack is2){
|
||||
if(is1.getType().equals(is2.getType())){
|
||||
if(is1.getDurability() == is2.getDurability()){
|
||||
@ -1078,10 +1150,12 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMerge(ItemStack add, ItemStack to){
|
||||
return compare(add, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified(ItemStack is){
|
||||
ItemStack is1 = is.clone();
|
||||
is1.setAmount(1);
|
||||
@ -1089,6 +1163,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return !is1.equals(is2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByMaterial(List<ItemStack> items){
|
||||
items.sort(new MaterialComparator());
|
||||
}
|
||||
@ -1100,6 +1175,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByName(List<ItemStack> items){
|
||||
items.sort(new NameComparator());
|
||||
}
|
||||
@ -1117,6 +1193,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByAmount(List<ItemStack> items){
|
||||
items.sort(new AmountComparator());
|
||||
}
|
||||
@ -1136,6 +1213,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack convertJSONToItemStack(JSONObject jo) throws Exception{
|
||||
Material material = Material.valueOf(jo.getString("material"));
|
||||
int amount = jo.getInt("amount");
|
||||
@ -1151,6 +1229,7 @@ public class _164ItemUtils implements IDabItemUtils{
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject convertItemStackToJSON(ItemStack is) throws Exception{
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("material", is.getType().name());
|
||||
|
@ -36,6 +36,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBanner(){
|
||||
return banner;
|
||||
}
|
||||
@ -43,18 +44,21 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nmis = NMSUtils.getClass("net.minecraft.item.ItemStack"), cis = NMSUtils.getOBCClass("inventory.CraftItemStack");
|
||||
public Method nmscopy = NMSUtils.getMethodSilent(cis, "asNMSCopy", ItemStack.class);
|
||||
|
||||
@Override
|
||||
public Object getNMSCopy(ItemStack is) throws Exception{
|
||||
return nmscopy.invoke(null, is);
|
||||
}
|
||||
|
||||
public Method hastag = NMSUtils.getMethodSilent(nmis, "func_77942_o");
|
||||
|
||||
@Override
|
||||
public boolean hasTag(Object is) throws Exception{
|
||||
return (boolean)hastag.invoke(is);
|
||||
}
|
||||
|
||||
public Method acm = NMSUtils.getMethodSilent(cis, "asCraftMirror", nmis);
|
||||
|
||||
@Override
|
||||
public ItemStack asCraftMirror(Object nis) throws Exception{
|
||||
return (ItemStack)acm.invoke(null, nis);
|
||||
}
|
||||
@ -63,12 +67,14 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method abc = NMSUtils.getMethodSilent(cis, "asBukkitCopy", nmis);
|
||||
|
||||
@Override
|
||||
public ItemStack asBukkitCopy(Object nmis) throws Exception{
|
||||
return (ItemStack)abc.invoke(null, nmis);
|
||||
}
|
||||
|
||||
public Method gn = NMSUtils.getMethodSilent(nmis, "func_82833_r");
|
||||
|
||||
@Override
|
||||
public String getName(ItemStack is){
|
||||
try{
|
||||
return (String)gn.invoke(getNMSCopy(is));
|
||||
@ -79,14 +85,17 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gi = NMSUtils.getMethodSilent(nmis, "func_77973_b"), ia = getA();
|
||||
|
||||
@Override
|
||||
public Object getItem(Object nis) throws Exception{
|
||||
return gi.invoke(nis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getA(){
|
||||
return NMSUtils.getMethodSilent(ni, "func_77653_i", nmis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawName(ItemStack is){
|
||||
try{
|
||||
Object nis = getNMSCopy(is);
|
||||
@ -98,6 +107,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getName");
|
||||
|
||||
@Override
|
||||
public String getItemName(ItemStack is){
|
||||
try{
|
||||
return (String)gin.invoke(gi.invoke(getNMSCopy(is)));
|
||||
@ -108,6 +118,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Object registry = getRegistry();
|
||||
|
||||
@Override
|
||||
public Object getRegistry(){
|
||||
try{
|
||||
return NMSUtils.getFieldSilent(ni, "REGISTRY", "field_150901_e").get(null);
|
||||
@ -120,6 +131,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Field nmrsc = NMSUtils.getField(nmrs, "field_82596_a");
|
||||
|
||||
@Override
|
||||
public String getMinecraftName(ItemStack is){
|
||||
String name = getItemName(is);
|
||||
try{
|
||||
@ -138,22 +150,26 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nbttc = NMSUtils.getClass("net.minecraft.nbt.NBTTagCompound");
|
||||
public Field tag = NMSUtils.getField(nmis, "field_77990_d");
|
||||
|
||||
@Override
|
||||
public Object getTag(Object is) throws Exception{
|
||||
return tag.get(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTag(Object is, Object tag1) throws Exception{
|
||||
tag.set(is, tag1);
|
||||
}
|
||||
|
||||
public Method nbtcie = NMSUtils.getMethodSilent(nbttc, "func_82582_d");
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(Object tag) throws Exception{
|
||||
return (boolean)nbtcie.invoke(tag);
|
||||
}
|
||||
|
||||
public Field nbttcm = NMSUtils.getField(nbttc, "field_74784_a");
|
||||
|
||||
@Override
|
||||
public Object getMap(Object tag) throws Exception{
|
||||
return nbttcm.get(tag);
|
||||
}
|
||||
@ -166,32 +182,39 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public Method nbttcsl = NMSUtils.getMethodSilent(nbttc, "func_74772_a", String.class, long.class);
|
||||
public Method nbttcss1 = NMSUtils.getMethodSilent(nbttc, "func_74777_a", String.class, short.class);
|
||||
|
||||
@Override
|
||||
public void set(Object tag, String key, Object value) throws Exception{
|
||||
nbttcs.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(Object tag, String key, String value) throws Exception{
|
||||
nbttcss.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(Object tag, String key, short value) throws Exception{
|
||||
nbttcss1.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(Object tag, String key, int i) throws Exception{
|
||||
nbttcsi.invoke(tag, key, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(Object tag, String key, double d) throws Exception{
|
||||
nbttcsd.invoke(tag, key, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(Object tag, String key, long l) throws Exception{
|
||||
nbttcsl.invoke(tag, key, l);
|
||||
}
|
||||
|
||||
public Method nbttchk = NMSUtils.getMethodSilent(nbttc, "func_74764_b", String.class);
|
||||
|
||||
@Override
|
||||
public boolean hasKey(Object tag, String key) throws Exception{
|
||||
return (boolean)nbttchk.invoke(tag, key);
|
||||
}
|
||||
@ -203,38 +226,46 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public Method nbttcgl = NMSUtils.getMethodSilent(nbttc, "func_74763_f", String.class);
|
||||
public Method nbttcgs1 = NMSUtils.getMethodSilent(nbttc, "func_74765_d", String.class);
|
||||
|
||||
@Override
|
||||
public Object get(Object tag, String key) throws Exception{
|
||||
return nbttcg.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(Object tag, String key) throws Exception{
|
||||
return (String)nbttcgs.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Object tag, String key) throws Exception{
|
||||
return (int)nbttcgi.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Object tag, String key) throws Exception{
|
||||
return (double)nbttcgd.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(Object tag, String key) throws Exception{
|
||||
return (long)nbttcgl.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(Object tag, String key) throws Exception{
|
||||
return (short)nbttcgs1.invoke(tag, key);
|
||||
}
|
||||
|
||||
public Constructor<?> nbttcc = NMSUtils.getConstructorSilent(nbttc);
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagCompound() throws Exception{
|
||||
return nbttcc.newInstance();
|
||||
}
|
||||
|
||||
public Method hkot = NMSUtils.getMethodSilent(nbttc, "func_150297_b", String.class, int.class);
|
||||
|
||||
@Override
|
||||
public boolean hasAttributeModifiersKey(Object tag) throws Exception{
|
||||
return (boolean)hkot.invoke(tag, "AttributeModifiers", 9);
|
||||
}
|
||||
@ -246,38 +277,46 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public Method nbttla = NMSUtils.getMethodSilent(nbttl, "func_74742_a", nbtb);
|
||||
public Constructor<?> nbttlc = NMSUtils.getConstructorSilent(nbttl);
|
||||
|
||||
@Override
|
||||
public Object getList(Object tag) throws Exception{
|
||||
return gl.invoke(tag, "AttributeModifiers", 9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getList(Object tag, String name, int id) throws Exception{
|
||||
return gl.invoke(tag, name, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUnbreakable(Object tag) throws Exception{
|
||||
return (boolean)gb.invoke(tag, "Unbreakable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnbreakable(Object tag, boolean value) throws Exception{
|
||||
sb.invoke(tag, "Unbreakable", value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagList() throws Exception{
|
||||
return nbttlc.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToList(Object taglist, Object nbt) throws Exception{
|
||||
nbttla.invoke(taglist, nbt);
|
||||
}
|
||||
|
||||
public Method gs = NMSUtils.getMethodSilent(nbttl, "func_74745_c");
|
||||
|
||||
@Override
|
||||
public int getSize(Object list) throws Exception{
|
||||
return (int)gs.invoke(list);
|
||||
}
|
||||
|
||||
public Method g = NMSUtils.getMethodSilent(nbttl, "func_150305_b", int.class);
|
||||
|
||||
@Override
|
||||
public Object get(Object tlist, int i) throws Exception{
|
||||
return g.invoke(tlist, i);
|
||||
}
|
||||
@ -321,16 +360,19 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
public Field nbtsd = NMSUtils.getField(nbts, "field_74752_a");
|
||||
public Field nbtstd = NMSUtils.getField(nbtst, "field_74751_a");
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagByte(byte value) throws Exception{
|
||||
return nbtbc.newInstance(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagByteArray(byte[] value) throws Exception{
|
||||
return nbtbac.newInstance(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(Object nbt) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
switch(i){
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
return nbtbd.get(nbt);
|
||||
@ -358,6 +400,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object createData(Object value) throws Exception{
|
||||
if(value.getClass().equals(byte.class)){ return nbtbc.newInstance(value); }
|
||||
@ -374,6 +417,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public Map<String, Object> convertCompoundTagToValueMap(Object nbt) throws Exception{
|
||||
Map<String, Object> ret = new HashMap<>();
|
||||
@ -388,6 +432,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> convertListTagToValueList(Object nbttl) throws Exception{
|
||||
List<Object> ret = new ArrayList<>();
|
||||
@ -401,6 +446,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValueMapToCompoundTag(Map<String, Object> map) throws Exception{
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
for(Entry<String, Object> e : map.entrySet()){
|
||||
@ -411,6 +457,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValueListToListTag(List<Object> list) throws Exception{
|
||||
List<Object> value = new ArrayList<>();
|
||||
for(Object e : list){
|
||||
@ -424,6 +471,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertListTagToJSON(Object nbttl, JSONArray ja, JSONArray helper) throws Exception{
|
||||
@ -436,6 +484,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertListTagToJSON(Object nbttl, JSONArray ja) throws Exception{
|
||||
List<Object> list = (List<Object>)nbtld.get(nbttl);
|
||||
@ -447,6 +496,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertCompoundTagToJSON(Object nbt, JSONObject jo, JSONObject helper) throws Exception{
|
||||
@ -460,6 +510,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertCompoundTagToJSON(Object nbt, JSONObject jo) throws Exception{
|
||||
Map<String, Object> map = (Map<String, Object>)getMap(nbt);
|
||||
@ -472,6 +523,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertJSONToCompoundTag(JSONObject jo, JSONObject helper) throws Exception{
|
||||
@ -486,6 +538,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertJSONToCompoundTag(JSONObject jo) throws Exception{
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
@ -499,6 +552,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertJSONToListTag(JSONArray ja, JSONArray helper) throws Exception{
|
||||
@ -514,6 +568,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertJSONToListTag(JSONArray ja) throws Exception{
|
||||
List value = new ArrayList();
|
||||
@ -528,9 +583,10 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object getDataJSON(String key, Object nbt, JSONObject jo, JSONObject helper) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
Object help = i;
|
||||
switch(i){
|
||||
@ -583,8 +639,9 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDataJSON(Object nbt) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
switch(i){
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
@ -631,8 +688,9 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return new JSONArray(new Object[]{ i, ret });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDataJSON(Object nbt, JSONArray ja, JSONArray helper) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
Object help = i;
|
||||
switch(i){
|
||||
@ -684,6 +742,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(String key, JSONObject jo, JSONObject helper) throws Exception{
|
||||
Object help = helper.get(key);
|
||||
Object ret = null;
|
||||
@ -739,6 +798,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(String key, JSONObject jo) throws Exception{
|
||||
JSONArray j = jo.getJSONArray(key);
|
||||
Object ret = null;
|
||||
@ -790,6 +850,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(Object o){
|
||||
if(o.getClass().equals(Integer.class)){ return (byte)(int)o; }
|
||||
if(o.getClass().equals(Short.class)){ return (byte)(short)o; }
|
||||
@ -797,40 +858,46 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return (byte)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(Object o){
|
||||
if(o.getClass().equals(Integer.class)){ return (short)(int)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (short)(byte)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (byte)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (short)(int)o; }
|
||||
return (short)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Object o){
|
||||
if(o.getClass().equals(Short.class)){ return (int)(short)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (int)(byte)o; }
|
||||
if(o.getClass().equals(Short.class)){ return (short)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (byte)o; }
|
||||
return (int)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Object o){
|
||||
if(o.getClass().equals(Float.class)){ return (double)(float)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (double)(long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (double)(int)o; }
|
||||
if(o.getClass().equals(Float.class)){ return (float)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (double)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(Object o){
|
||||
if(o.getClass().equals(Double.class)){ return (float)(double)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (float)(long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (float)(int)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (float)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(Object o){
|
||||
if(o.getClass().equals(Float.class)){ return (long)(float)o; }
|
||||
if(o.getClass().equals(Double.class)){ return (long)(double)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (long)(int)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (long)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(int key, JSONArray jo, JSONArray helper) throws Exception{
|
||||
Object help = helper.get(key);
|
||||
Object ret = null;
|
||||
@ -886,6 +953,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(int key, JSONArray jo) throws Exception{
|
||||
JSONArray j = jo.getJSONArray(key);
|
||||
Object ret = null;
|
||||
@ -937,9 +1005,10 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compareBaseTag(Object tag, Object tag1) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(tag));
|
||||
int i1 = (int)((byte)gti.invoke(tag1));
|
||||
int i = ((byte)gti.invoke(tag));
|
||||
int i1 = ((byte)gti.invoke(tag1));
|
||||
if(i != i1)
|
||||
return false;
|
||||
switch(i){
|
||||
@ -988,6 +1057,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean compareCompoundTag(Object tag, Object tag1) throws Exception{
|
||||
Map<String, Object> map = (Map<String, Object>)getMap(tag);
|
||||
@ -1005,6 +1075,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public boolean compareListTag(Object tag, Object tag1) throws Exception{
|
||||
List list = (List)nbtld.get(tag);
|
||||
@ -1026,6 +1097,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Field amd = NMSUtils.getField(am, "field_111170_d");
|
||||
|
||||
@Override
|
||||
public boolean compare(ItemStack is1, ItemStack is2){
|
||||
if(is1.getType().equals(is2.getType())){
|
||||
if(is1.getDurability() == is2.getDurability()){
|
||||
@ -1049,10 +1121,12 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMerge(ItemStack add, ItemStack to){
|
||||
return compare(add, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified(ItemStack is){
|
||||
ItemStack is1 = is.clone();
|
||||
is1.setAmount(1);
|
||||
@ -1060,6 +1134,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return !is1.equals(is2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByMaterial(List<ItemStack> items){
|
||||
items.sort(new MaterialComparator());
|
||||
}
|
||||
@ -1071,6 +1146,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByName(List<ItemStack> items){
|
||||
items.sort(new NameComparator());
|
||||
}
|
||||
@ -1088,6 +1164,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByAmount(List<ItemStack> items){
|
||||
items.sort(new AmountComparator());
|
||||
}
|
||||
@ -1107,6 +1184,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack convertJSONToItemStack(JSONObject jo) throws Exception{
|
||||
Material material = Material.valueOf(jo.getString("material"));
|
||||
int amount = jo.getInt("amount");
|
||||
@ -1122,6 +1200,7 @@ public class _1710ItemUtils implements IDabItemUtils{
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject convertItemStackToJSON(ItemStack is) throws Exception{
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("material", is.getType().name());
|
||||
|
@ -35,6 +35,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBanner(){
|
||||
return banner;
|
||||
}
|
||||
@ -42,24 +43,28 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nmis = NMSUtils.getNMSClassSilent("ItemStack"), cis = NMSUtils.getOBCClass("inventory.CraftItemStack");
|
||||
public Method nmscopy = NMSUtils.getMethodSilent(cis, "asNMSCopy", ItemStack.class);
|
||||
|
||||
@Override
|
||||
public Object getNMSCopy(ItemStack is) throws Exception{
|
||||
return nmscopy.invoke(null, is);
|
||||
}
|
||||
|
||||
public Method hastag = NMSUtils.getMethodSilent(nmis, "hasTag");
|
||||
|
||||
@Override
|
||||
public boolean hasTag(Object is) throws Exception{
|
||||
return (boolean)hastag.invoke(is);
|
||||
}
|
||||
|
||||
public Method acm = NMSUtils.getMethodSilent(cis, "asCraftMirror", nmis);
|
||||
|
||||
@Override
|
||||
public ItemStack asCraftMirror(Object nis) throws Exception{
|
||||
return (ItemStack)acm.invoke(null, nis);
|
||||
}
|
||||
|
||||
public Method abc = NMSUtils.getMethodSilent(cis, "asBukkitCopy", nmis);
|
||||
|
||||
@Override
|
||||
public ItemStack asBukkitCopy(Object nmis) throws Exception{
|
||||
return (ItemStack)abc.invoke(null, nmis);
|
||||
}
|
||||
@ -68,6 +73,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gn = NMSUtils.getMethodSilent(nmis, "getName");
|
||||
|
||||
@Override
|
||||
public String getName(ItemStack is){
|
||||
try{
|
||||
return (String)gn.invoke(getNMSCopy(is));
|
||||
@ -78,10 +84,12 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gi = NMSUtils.getMethodSilent(nmis, "getItem"), ia = getA();
|
||||
|
||||
@Override
|
||||
public Object getItem(Object nis) throws Exception{
|
||||
return gi.invoke(nis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getA(){
|
||||
Method m = NMSUtils.getMethodSilent(ni, "a", nmis);
|
||||
if(m == null){
|
||||
@ -90,6 +98,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawName(ItemStack is){
|
||||
try{
|
||||
Object nis = getNMSCopy(is);
|
||||
@ -101,6 +110,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Method gin = NMSUtils.getMethodSilent(ni, "getName");
|
||||
|
||||
@Override
|
||||
public String getItemName(ItemStack is){
|
||||
try{
|
||||
return (String)gin.invoke(gi.invoke(getNMSCopy(is)));
|
||||
@ -111,6 +121,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
|
||||
public Object registry = getRegistry();
|
||||
|
||||
@Override
|
||||
public Object getRegistry(){
|
||||
try{
|
||||
return NMSUtils.getFieldSilent(ni, "REGISTRY").get(null);
|
||||
@ -122,6 +133,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nmrs = NMSUtils.getNMSClassSilent("RegistrySimple");
|
||||
public Field nmrsc = NMSUtils.getField(nmrs, "c");
|
||||
|
||||
@Override
|
||||
public String getMinecraftName(ItemStack is){
|
||||
String name = getItemName(is);
|
||||
try{
|
||||
@ -140,22 +152,26 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Class<?> nbttc = NMSUtils.getNMSClassSilent("NBTTagCompound");
|
||||
public Field tag = NMSUtils.getField(nmis, "tag");
|
||||
|
||||
@Override
|
||||
public Object getTag(Object is) throws Exception{
|
||||
return tag.get(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTag(Object is, Object tag1) throws Exception{
|
||||
tag.set(is, tag1);
|
||||
}
|
||||
|
||||
public Method nbtcie = NMSUtils.getMethodSilent(nbttc, "isEmpty");
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(Object tag) throws Exception{
|
||||
return (boolean)nbtcie.invoke(tag);
|
||||
}
|
||||
|
||||
public Field nbttcm = NMSUtils.getField(nbttc, "map");
|
||||
|
||||
@Override
|
||||
public Object getMap(Object tag) throws Exception{
|
||||
return nbttcm.get(tag);
|
||||
}
|
||||
@ -168,32 +184,39 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Method nbttcsl = NMSUtils.getMethodSilent(nbttc, "setLong", String.class, long.class);
|
||||
public Method nbttcss1 = NMSUtils.getMethodSilent(nbttc, "setShort", String.class, short.class);
|
||||
|
||||
@Override
|
||||
public void set(Object tag, String key, Object value) throws Exception{
|
||||
nbttcs.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(Object tag, String key, String value) throws Exception{
|
||||
nbttcss.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(Object tag, String key, short value) throws Exception{
|
||||
nbttcss1.invoke(tag, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(Object tag, String key, int i) throws Exception{
|
||||
nbttcsi.invoke(tag, key, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(Object tag, String key, double d) throws Exception{
|
||||
nbttcsd.invoke(tag, key, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(Object tag, String key, long l) throws Exception{
|
||||
nbttcsl.invoke(tag, key, l);
|
||||
}
|
||||
|
||||
public Method nbttchk = NMSUtils.getMethodSilent(nbttc, "hasKey", String.class);
|
||||
|
||||
@Override
|
||||
public boolean hasKey(Object tag, String key) throws Exception{
|
||||
return (boolean)nbttchk.invoke(tag, key);
|
||||
}
|
||||
@ -205,38 +228,46 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Method nbttcgl = NMSUtils.getMethodSilent(nbttc, "getLong", String.class);
|
||||
public Method nbttcgs1 = NMSUtils.getMethodSilent(nbttc, "getShort", String.class);
|
||||
|
||||
@Override
|
||||
public Object get(Object tag, String key) throws Exception{
|
||||
return nbttcg.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(Object tag, String key) throws Exception{
|
||||
return (String)nbttcgs.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Object tag, String key) throws Exception{
|
||||
return (int)nbttcgi.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Object tag, String key) throws Exception{
|
||||
return (double)nbttcgd.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(Object tag, String key) throws Exception{
|
||||
return (long)nbttcgl.invoke(tag, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(Object tag, String key) throws Exception{
|
||||
return (short)nbttcgs1.invoke(tag, key);
|
||||
}
|
||||
|
||||
public Constructor<?> nbttcc = NMSUtils.getConstructorSilent(nbttc);
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagCompound() throws Exception{
|
||||
return nbttcc.newInstance();
|
||||
}
|
||||
|
||||
public Method hkot = NMSUtils.getMethodSilent(nbttc, "hasKeyOfType", String.class, int.class);
|
||||
|
||||
@Override
|
||||
public boolean hasAttributeModifiersKey(Object tag) throws Exception{
|
||||
return (boolean)hkot.invoke(tag, "AttributeModifiers", 9);
|
||||
}
|
||||
@ -248,38 +279,46 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Method nbttla = NMSUtils.getMethodSilent(nbttl, "add", nbtb);
|
||||
public Constructor<?> nbttlc = NMSUtils.getConstructorSilent(nbttl);
|
||||
|
||||
@Override
|
||||
public Object getList(Object tag) throws Exception{
|
||||
return gl.invoke(tag, "AttributeModifiers", 9);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getList(Object tag, String name, int id) throws Exception{
|
||||
return gl.invoke(tag, name, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUnbreakable(Object tag) throws Exception{
|
||||
return (boolean)gb.invoke(tag, "Unbreakable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnbreakable(Object tag, boolean value) throws Exception{
|
||||
sb.invoke(tag, "Unbreakable", value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagList() throws Exception{
|
||||
return nbttlc.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToList(Object taglist, Object nbt) throws Exception{
|
||||
nbttla.invoke(taglist, nbt);
|
||||
}
|
||||
|
||||
public Method gs = NMSUtils.getMethodSilent(nbttl, "size");
|
||||
|
||||
@Override
|
||||
public int getSize(Object list) throws Exception{
|
||||
return (int)gs.invoke(list);
|
||||
}
|
||||
|
||||
public Method g = NMSUtils.getMethodSilent(nbttl, "get", int.class);
|
||||
|
||||
@Override
|
||||
public Object get(Object tlist, int i) throws Exception{
|
||||
return g.invoke(tlist, i);
|
||||
}
|
||||
@ -321,16 +360,19 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
public Field nbtsd = NMSUtils.getField(nbts, "data");
|
||||
public Field nbtstd = NMSUtils.getField(nbtst, "data");
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagByte(byte value) throws Exception{
|
||||
return nbtbc.newInstance(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNewNBTTagByteArray(byte[] value) throws Exception{
|
||||
return nbtbac.newInstance(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(Object nbt) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
switch(i){
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
return nbtbd.get(nbt);
|
||||
@ -358,6 +400,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object createData(Object value) throws Exception{
|
||||
if(value.getClass().equals(byte.class)){ return nbtbc.newInstance(value); }
|
||||
@ -374,6 +417,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public Map<String, Object> convertCompoundTagToValueMap(Object nbt) throws Exception{
|
||||
Map<String, Object> ret = new HashMap<>();
|
||||
@ -388,6 +432,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> convertListTagToValueList(Object nbttl) throws Exception{
|
||||
List<Object> ret = new ArrayList<>();
|
||||
@ -401,6 +446,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValueMapToCompoundTag(Map<String, Object> map) throws Exception{
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
for(Entry<String, Object> e : map.entrySet()){
|
||||
@ -411,6 +457,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convertValueListToListTag(List<Object> list) throws Exception{
|
||||
List<Object> value = new ArrayList<>();
|
||||
for(Object e : list){
|
||||
@ -424,6 +471,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public void convertListTagToJSON(Object nbttl, JSONArray ja, JSONArray helper) throws Exception{
|
||||
@ -436,6 +484,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertListTagToJSON(Object nbttl, JSONArray ja) throws Exception{
|
||||
List<Object> list = (List<Object>)nbtld.get(nbttl);
|
||||
@ -447,6 +496,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public void convertCompoundTagToJSON(Object nbt, JSONObject jo, JSONObject helper) throws Exception{
|
||||
@ -460,6 +510,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertCompoundTagToJSON(Object nbt, JSONObject jo) throws Exception{
|
||||
Map<String, Object> map = (Map<String, Object>)getMap(nbt);
|
||||
@ -472,6 +523,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public Object convertJSONToCompoundTag(JSONObject jo, JSONObject helper) throws Exception{
|
||||
@ -486,6 +538,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convertJSONToCompoundTag(JSONObject jo) throws Exception{
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
@ -499,6 +552,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Deprecated
|
||||
public Object convertJSONToListTag(JSONArray ja, JSONArray helper) throws Exception{
|
||||
@ -514,6 +568,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object convertJSONToListTag(JSONArray ja) throws Exception{
|
||||
List value = new ArrayList();
|
||||
@ -528,9 +583,10 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object getDataJSON(String key, Object nbt, JSONObject jo, JSONObject helper) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
Object help = i;
|
||||
switch(i){
|
||||
@ -583,8 +639,9 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDataJSON(Object nbt) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
switch(i){
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
@ -631,9 +688,10 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return new JSONArray(new Object[]{ i, ret });
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object getDataJSON(Object nbt, JSONArray ja, JSONArray helper) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(nbt));
|
||||
int i = ((byte)gti.invoke(nbt));
|
||||
Object ret = null;
|
||||
Object help = i;
|
||||
switch(i){
|
||||
@ -685,6 +743,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object createDataJSON(String key, JSONObject jo, JSONObject helper) throws Exception{
|
||||
Object help = helper.get(key);
|
||||
@ -741,6 +800,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(String key, JSONObject jo) throws Exception{
|
||||
JSONArray j = jo.getJSONArray(key);
|
||||
Object ret = null;
|
||||
@ -792,6 +852,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(Object o){
|
||||
if(o.getClass().equals(Integer.class)){ return (byte)(int)o; }
|
||||
if(o.getClass().equals(Short.class)){ return (byte)(short)o; }
|
||||
@ -799,40 +860,46 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return (byte)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(Object o){
|
||||
if(o.getClass().equals(Integer.class)){ return (short)(int)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (short)(byte)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (byte)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (short)(int)o; }
|
||||
return (short)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Object o){
|
||||
if(o.getClass().equals(Short.class)){ return (int)(short)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (int)(byte)o; }
|
||||
if(o.getClass().equals(Short.class)){ return (short)o; }
|
||||
if(o.getClass().equals(Byte.class)){ return (byte)o; }
|
||||
return (int)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(Object o){
|
||||
if(o.getClass().equals(Float.class)){ return (double)(float)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (double)(long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (double)(int)o; }
|
||||
if(o.getClass().equals(Float.class)){ return (float)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (double)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(Object o){
|
||||
if(o.getClass().equals(Double.class)){ return (float)(double)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (float)(long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (float)(int)o; }
|
||||
if(o.getClass().equals(Long.class)){ return (long)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (float)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(Object o){
|
||||
if(o.getClass().equals(Float.class)){ return (long)(float)o; }
|
||||
if(o.getClass().equals(Double.class)){ return (long)(double)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (long)(int)o; }
|
||||
if(o.getClass().equals(Integer.class)){ return (int)o; }
|
||||
return (long)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object createDataJSON(int key, JSONArray jo, JSONArray helper) throws Exception{
|
||||
Object help = helper.get(key);
|
||||
@ -889,6 +956,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createDataJSON(int key, JSONArray jo) throws Exception{
|
||||
JSONArray j = jo.getJSONArray(key);
|
||||
Object ret = null;
|
||||
@ -940,9 +1008,10 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compareBaseTag(Object tag, Object tag1) throws Exception{
|
||||
int i = (int)((byte)gti.invoke(tag));
|
||||
int i1 = (int)((byte)gti.invoke(tag1));
|
||||
int i = ((byte)gti.invoke(tag));
|
||||
int i1 = ((byte)gti.invoke(tag1));
|
||||
if(i != i1)
|
||||
return false;
|
||||
switch(i){
|
||||
@ -991,6 +1060,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean compareCompoundTag(Object tag, Object tag1) throws Exception{
|
||||
Map<String, Object> map = (Map<String, Object>)getMap(tag);
|
||||
@ -1008,6 +1078,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public boolean compareListTag(Object tag, Object tag1) throws Exception{
|
||||
List list = (List)nbtld.get(tag);
|
||||
@ -1038,6 +1109,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return copy.isEmpty() && copy1.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compare(ItemStack is1, ItemStack is2){
|
||||
if(is1.getType().equals(is2.getType())){
|
||||
if(is1.getDurability() == is2.getDurability()){
|
||||
@ -1061,10 +1133,12 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMerge(ItemStack add, ItemStack to){
|
||||
return compare(add, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified(ItemStack is){
|
||||
ItemStack is1 = is.clone();
|
||||
is1.setAmount(1);
|
||||
@ -1072,6 +1146,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return !is1.equals(is2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByMaterial(List<ItemStack> items){
|
||||
items.sort(new MaterialComparator());
|
||||
}
|
||||
@ -1083,6 +1158,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByName(List<ItemStack> items){
|
||||
items.sort(new NameComparator());
|
||||
}
|
||||
@ -1100,6 +1176,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortByAmount(List<ItemStack> items){
|
||||
items.sort(new AmountComparator());
|
||||
}
|
||||
@ -1119,6 +1196,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack convertJSONToItemStack(JSONObject jo) throws Exception{
|
||||
Material material = Material.valueOf(jo.getString("material"));
|
||||
int amount = jo.getInt("amount");
|
||||
@ -1134,6 +1212,7 @@ public class _194ItemUtils implements IDabItemUtils{
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject convertItemStackToJSON(ItemStack is) throws Exception{
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("material", is.getType().name());
|
||||
|
@ -1177,7 +1177,7 @@ public enum EffLib {
|
||||
*/
|
||||
@Override
|
||||
public float getValueX() {
|
||||
return (float) red / 255F;
|
||||
return red / 255F;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1187,7 +1187,7 @@ public enum EffLib {
|
||||
*/
|
||||
@Override
|
||||
public float getValueY() {
|
||||
return (float) green / 255F;
|
||||
return green / 255F;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1197,7 +1197,7 @@ public enum EffLib {
|
||||
*/
|
||||
@Override
|
||||
public float getValueZ() {
|
||||
return (float) blue / 255F;
|
||||
return blue / 255F;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1235,7 +1235,7 @@ public enum EffLib {
|
||||
*/
|
||||
@Override
|
||||
public float getValueX() {
|
||||
return (float) note / 24F;
|
||||
return note / 24F;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,8 @@ public class TabooSignChangeEvent
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
@ -20,58 +20,29 @@ public class Language2 {
|
||||
|
||||
@Getter
|
||||
private FileConfiguration configuration;
|
||||
|
||||
@Getter
|
||||
private File languageFile;
|
||||
|
||||
@Getter
|
||||
private File languageFolder;
|
||||
|
||||
@Getter
|
||||
private Plugin plugin;
|
||||
|
||||
@Getter
|
||||
private String languageName;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param plugin 插件
|
||||
*/
|
||||
public Language2(Plugin plugin) {
|
||||
this("zh_CN", plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param languageName 语言文件
|
||||
* @param plugin 插件
|
||||
*/
|
||||
public Language2(String languageName, Plugin plugin) {
|
||||
this.languageName = languageName;
|
||||
this.plugin = plugin;
|
||||
// 重载语言文件
|
||||
reload(languageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言文件
|
||||
*
|
||||
* @param key 键
|
||||
* @return {@link Language2Value}
|
||||
*/
|
||||
public Language2Value get(String key) {
|
||||
return new Language2Value(this, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取语言文件
|
||||
*
|
||||
* @param key 键
|
||||
* @param placeholder 替换变量,从 @$0 开始
|
||||
* @return {@link Language2Value}
|
||||
*/
|
||||
public Language2Value get(String key, String... placeholder) {
|
||||
Language2Value value = new Language2Value(this, key);
|
||||
for (int i = 0 ; i < placeholder.length ; i++) {
|
||||
@ -80,52 +51,27 @@ public class Language2 {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载语言文件
|
||||
*/
|
||||
public void reload() {
|
||||
reload(this.languageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载语言文件
|
||||
*
|
||||
* @param languageName 新语言文件名称
|
||||
*/
|
||||
public void reload(String languageName) {
|
||||
// 初始化文件夹
|
||||
createFolder(plugin);
|
||||
// 格式化配置名
|
||||
languageName = formatName(languageName);
|
||||
// 获取文件
|
||||
languageFile = new File(languageFolder, languageName);
|
||||
// 文件不存在
|
||||
if (!languageFile.exists()) {
|
||||
// 如果语言文件不存在
|
||||
if (plugin.getResource("Language2/" + languageName) == null) {
|
||||
try {
|
||||
throw new FileNotFoundException("语言文件 " + languageName + " 不存在");
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 释放资源
|
||||
} else {
|
||||
plugin.saveResource("Language2/" + languageName, true);
|
||||
}
|
||||
}
|
||||
// 载入配置
|
||||
configuration = ConfigUtils.load(plugin, languageFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* PlaceholderAPI 变量识别
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param string 文本
|
||||
* @return String
|
||||
*/
|
||||
public String setPlaceholderAPI(Player player, String string) {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null && player != null) {
|
||||
return PlaceholderAPI.setPlaceholders(player, string);
|
||||
@ -133,21 +79,10 @@ public class Language2 {
|
||||
return string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 语言文件名称格式化
|
||||
*
|
||||
* @param name 语言文件名称
|
||||
* @return String
|
||||
*/
|
||||
private String formatName(String name) {
|
||||
return name.contains(".yml") ? name : name + ".yml";
|
||||
}
|
||||
|
||||
/**
|
||||
* 语言文件夹初始化
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
private void createFolder(Plugin plugin) {
|
||||
languageFolder = new File(plugin.getDataFolder(), "Language2");
|
||||
if (!languageFolder.exists()) {
|
||||
|
@ -67,6 +67,7 @@ public class Language2Action implements Language2Line {
|
||||
*
|
||||
* @param player 玩家
|
||||
*/
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
// 检查版本
|
||||
if (TabooLib.getVerint() < 10800) {
|
||||
|
@ -129,6 +129,7 @@ public class Language2Json implements Language2Line {
|
||||
*
|
||||
* @param player 玩家
|
||||
*/
|
||||
@Override
|
||||
public void send(Player player) {
|
||||
json.send(player);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public class TimeCycleEvent extends Event {
|
||||
return this.cycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public class TimeCycleInitializeEvent extends Event {
|
||||
return this.cycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -15,9 +15,11 @@ commands:
|
||||
language2:
|
||||
aliases: [lang2]
|
||||
permission: taboolib.admin
|
||||
tabooliblocale:
|
||||
aliases: [taboolocale, tlocale]
|
||||
permission: taboolib.admin
|
||||
taboolibrarymodule:
|
||||
aliases: [tlm]
|
||||
|
||||
depend: [Vault]
|
||||
softdepend: [PlaceholderAPI, Skript, TabooCode, MassiveLag]
|
||||
loadbefore: [Skript]
|
Loading…
Reference in New Issue
Block a user