e : enchants.entrySet()) {
- tag.append("{id:" + e.getKey().getId() + ",lvl:" + e.getValue() + "},");
+ tag.append("{id:").append(e.getKey().getId()).append(",lvl:").append(e.getValue()).append("},");
}
tag.delete(tag.length() - 1, tag.length());
tag.append("]");
diff --git a/src/main/java/me/skymc/taboolib/listener/ListenerPlayerCommand.java b/src/main/java/me/skymc/taboolib/listener/ListenerPlayerCommand.java
index f6195e5..4f92e24 100644
--- a/src/main/java/me/skymc/taboolib/listener/ListenerPlayerCommand.java
+++ b/src/main/java/me/skymc/taboolib/listener/ListenerPlayerCommand.java
@@ -1,26 +1,17 @@
package me.skymc.taboolib.listener;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.server.ServerCommandEvent;
-
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.database.PlayerDataManager;
-import me.skymc.taboolib.inventory.ItemUtils;
-import me.skymc.taboolib.itemnbtapi.NBTCompound;
import me.skymc.taboolib.itemnbtapi.NBTItem;
-import me.skymc.taboolib.jsonformatter.JSONFormatter;
-import me.skymc.taboolib.jsonformatter.click.RunCommandEvent;
-import me.skymc.taboolib.jsonformatter.click.SuggestCommandEvent;
-import me.skymc.taboolib.jsonformatter.hover.ShowTextEvent;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.permission.PermissionUtils;
import me.skymc.taboolib.playerdata.DataUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.bukkit.event.server.ServerCommandEvent;
public class ListenerPlayerCommand implements Listener {
@@ -30,7 +21,7 @@ public class ListenerPlayerCommand implements Listener {
if (TabooLib.getVerint() > 10700) {
e.setCancelled(true);
}
- Bukkit.getScheduler().runTask(Main.getInst(), () -> DataUtils.saveAllCaches());
+ Bukkit.getScheduler().runTask(Main.getInst(), DataUtils::saveAllCaches);
Bukkit.getScheduler().runTask(Main.getInst(), () -> PlayerDataManager.saveAllCaches(true, false));
}
}
diff --git a/src/main/java/me/skymc/taboolib/listener/ListenerPlayerJump.java b/src/main/java/me/skymc/taboolib/listener/ListenerPlayerJump.java
index dfc07f3..d0d4fa1 100644
--- a/src/main/java/me/skymc/taboolib/listener/ListenerPlayerJump.java
+++ b/src/main/java/me/skymc/taboolib/listener/ListenerPlayerJump.java
@@ -1,12 +1,10 @@
package me.skymc.taboolib.listener;
-import java.util.HashMap;
+import me.skymc.taboolib.events.PlayerJumpEvent;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
-import org.bukkit.Server;
-import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -14,7 +12,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-import me.skymc.taboolib.events.PlayerJumpEvent;
+import java.util.HashMap;
public class ListenerPlayerJump
implements Listener
@@ -31,17 +29,16 @@ public class ListenerPlayerJump
{
if (!this.cooldown.containsKey(event.getPlayer()))
{
- this.cooldown.put(event.getPlayer(), Long.valueOf(System.currentTimeMillis() + 350L));
+ this.cooldown.put(event.getPlayer(), System.currentTimeMillis() + 350L);
PlayerJumpEvent evt = new PlayerJumpEvent(event.isCancelled(), event.getPlayer());
Bukkit.getPluginManager().callEvent(evt);
if (evt.isCancelled())
{
event.setCancelled(true);
}
- }
- else if (((Long)this.cooldown.get(event.getPlayer())).longValue() <= System.currentTimeMillis())
+ } else if (this.cooldown.get(event.getPlayer()) <= System.currentTimeMillis())
{
- this.cooldown.put(event.getPlayer(), Long.valueOf(System.currentTimeMillis() + 350L));
+ this.cooldown.put(event.getPlayer(), System.currentTimeMillis() + 350L);
PlayerJumpEvent evt = new PlayerJumpEvent(event.isCancelled(), event.getPlayer());
Bukkit.getPluginManager().callEvent(evt);
diff --git a/src/main/java/me/skymc/taboolib/listener/ListenerPlayerQuit.java b/src/main/java/me/skymc/taboolib/listener/ListenerPlayerQuit.java
index 8a12c79..066e77c 100644
--- a/src/main/java/me/skymc/taboolib/listener/ListenerPlayerQuit.java
+++ b/src/main/java/me/skymc/taboolib/listener/ListenerPlayerQuit.java
@@ -1,15 +1,10 @@
package me.skymc.taboolib.listener;
+import me.skymc.taboolib.playerdata.DataUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import me.skymc.taboolib.Main;
-import me.skymc.taboolib.database.PlayerDataManager;
-import me.skymc.taboolib.playerdata.DataUtils;
public class ListenerPlayerQuit implements Listener{
diff --git a/src/main/java/me/skymc/taboolib/listener/ListenerPluginDisable.java b/src/main/java/me/skymc/taboolib/listener/ListenerPluginDisable.java
index 51c3ccc..95f9a60 100644
--- a/src/main/java/me/skymc/taboolib/listener/ListenerPluginDisable.java
+++ b/src/main/java/me/skymc/taboolib/listener/ListenerPluginDisable.java
@@ -1,19 +1,17 @@
package me.skymc.taboolib.listener;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.bukkit.Bukkit;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.server.PluginDisableEvent;
-import org.bukkit.scheduler.BukkitRunnable;
-
import me.skymc.taboolib.Main;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.mysql.MysqlUtils;
import me.skymc.taboolib.mysql.protect.MySQLConnection;
import me.skymc.taboolib.timecycle.TimeCycleManager;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.server.PluginDisableEvent;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.util.ArrayList;
+import java.util.List;
public class ListenerPluginDisable implements Listener {
diff --git a/src/main/java/me/skymc/taboolib/location/LocationUtils.java b/src/main/java/me/skymc/taboolib/location/LocationUtils.java
index d4988f7..21ae208 100644
--- a/src/main/java/me/skymc/taboolib/location/LocationUtils.java
+++ b/src/main/java/me/skymc/taboolib/location/LocationUtils.java
@@ -5,8 +5,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
-import me.skymc.taboolib.methods.MethodsUtils;
-
public class LocationUtils {
/**
diff --git a/src/main/java/me/skymc/taboolib/message/ChatCatcher.java b/src/main/java/me/skymc/taboolib/message/ChatCatcher.java
index 79ee1a6..60be8b6 100644
--- a/src/main/java/me/skymc/taboolib/message/ChatCatcher.java
+++ b/src/main/java/me/skymc/taboolib/message/ChatCatcher.java
@@ -1,17 +1,14 @@
package me.skymc.taboolib.message;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.bukkit.Bukkit;
+import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-import lombok.Getter;
+import java.util.HashMap;
+import java.util.LinkedList;
public class ChatCatcher implements Listener {
@@ -66,13 +63,13 @@ public class ChatCatcher implements Listener {
playerdata.remove(player.getName());
}
}
-
- public abstract interface Catcher {
-
- public abstract Catcher before();
-
- public abstract boolean after(String message);
-
- public abstract void cancel();
+
+ public interface Catcher {
+
+ Catcher before();
+
+ boolean after(String message);
+
+ void cancel();
}
}
diff --git a/src/main/java/me/skymc/taboolib/methods/MethodsUtils.java b/src/main/java/me/skymc/taboolib/methods/MethodsUtils.java
index 5007cd4..25f3f04 100644
--- a/src/main/java/me/skymc/taboolib/methods/MethodsUtils.java
+++ b/src/main/java/me/skymc/taboolib/methods/MethodsUtils.java
@@ -9,11 +9,7 @@ public class MethodsUtils {
public static boolean checkUser(String packagename, String current)
{
- if (current.substring(0, 8).equals(packagename))
- {
- return true;
- }
- return false;
+ return current.substring(0, 8).equals(packagename);
}
@SuppressWarnings("rawtypes")
@@ -23,22 +19,14 @@ public class MethodsUtils {
{
throw new Error("未经允许的方法调用");
}
-
- Class extends Object> clazz = classname.getClass();
+
+ Class> clazz = classname.getClass();
Method method = null;
try {
method = clazz.getDeclaredMethod(methodname, classes);
method.setAccessible(true);
return new Object[] { method.invoke(classname, objects) };
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
+ } catch (SecurityException | InvocationTargetException | IllegalAccessException | NoSuchMethodException | IllegalArgumentException e) {
e.printStackTrace();
}
return null;
@@ -50,21 +38,15 @@ public class MethodsUtils {
{
throw new Error("未经允许的方法调用");
}
-
- Class extends Object> clazz = classname.getClass();
+
+ Class> clazz = classname.getClass();
Field field = null;
Object object = null;
try {
field = clazz.getDeclaredField(fieldname);
field.setAccessible(true);
object = field.get(classname);
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
+ } catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException | SecurityException e) {
e.printStackTrace();
}
return object;
diff --git a/src/main/java/me/skymc/taboolib/methods/ReflectionUtils.java b/src/main/java/me/skymc/taboolib/methods/ReflectionUtils.java
index f87f4be..6b2c54a 100644
--- a/src/main/java/me/skymc/taboolib/methods/ReflectionUtils.java
+++ b/src/main/java/me/skymc/taboolib/methods/ReflectionUtils.java
@@ -1,5 +1,7 @@
package me.skymc.taboolib.methods;
+import org.bukkit.Bukkit;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -7,8 +9,6 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
-import org.bukkit.Bukkit;
-
/**
* ReflectionUtils
*
@@ -60,7 +60,6 @@ public final class ReflectionUtils {
* @return The constructor of the desired target class with the specified parameter types
* @throws NoSuchMethodException If the desired constructor with the specified parameter types cannot be found
* @throws ClassNotFoundException ClassNotFoundException If the desired target class with the specified name and package cannot be found
- * @see #getClass(String, PackageType)
* @see #getConstructor(Class, Class...)
*/
public static Constructor> getConstructor(String className, PackageType packageType, Class>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException {
@@ -96,7 +95,6 @@ public final class ReflectionUtils {
* @throws InvocationTargetException If the desired constructor cannot be invoked
* @throws NoSuchMethodException If the desired constructor with the specified arguments cannot be found
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found
- * @see #getClass(String, PackageType)
* @see #instantiateObject(Class, Object...)
*/
public static Object instantiateObject(String className, PackageType packageType, Object... arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
@@ -135,7 +133,6 @@ public final class ReflectionUtils {
* @return The method of the desired target class with the specified name and parameter types
* @throws NoSuchMethodException If the desired method of the desired target class with the specified name and parameter types cannot be found
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found
- * @see #getClass(String, PackageType)
* @see #getMethod(Class, String, Class...)
*/
public static Method getMethod(String className, PackageType packageType, String methodName, Class>... parameterTypes) throws NoSuchMethodException, ClassNotFoundException {
@@ -193,7 +190,6 @@ public final class ReflectionUtils {
* @throws InvocationTargetException If the desired method cannot be invoked on the target object
* @throws NoSuchMethodException If the desired method of the desired target class with the specified name and arguments cannot be found
* @throws ClassNotFoundException If the desired target class with the specified name and package cannot be found
- * @see #getClass(String, PackageType)
* @see #invokeMethod(Object, Class, String, Object...)
*/
public static Object invokeMethod(Object instance, String className, PackageType packageType, String methodName, Object... arguments) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
@@ -380,7 +376,7 @@ public final class ReflectionUtils {
*
* @param path Path of the package
*/
- private PackageType(String path) {
+ PackageType(String path) {
this.path = path;
}
@@ -390,7 +386,7 @@ public final class ReflectionUtils {
* @param parent Parent package of the package
* @param path Path of the package
*/
- private PackageType(PackageType parent, String path) {
+ PackageType(PackageType parent, String path) {
this(parent + "." + path);
}
@@ -448,7 +444,7 @@ public final class ReflectionUtils {
DOUBLE(double.class, Double.class),
BOOLEAN(boolean.class, Boolean.class);
- private static final Map, DataType> CLASS_MAP = new HashMap, DataType>();
+ private static final Map, DataType> CLASS_MAP = new HashMap<>();
private final Class> primitive;
private final Class> reference;
@@ -466,7 +462,7 @@ public final class ReflectionUtils {
* @param primitive Primitive class of this data type
* @param reference Reference class of this data type
*/
- private DataType(Class> primitive, Class> reference) {
+ DataType(Class> primitive, Class> reference) {
this.primitive = primitive;
this.reference = reference;
}
@@ -554,7 +550,6 @@ public final class ReflectionUtils {
/**
* Returns the primitive class array of the given object array
*
- * @param object Given object array
* @return The primitive class array
*/
public static Class>[] getPrimitive(Object[] objects) {
@@ -569,7 +564,6 @@ public final class ReflectionUtils {
/**
* Returns the reference class array of the given object array
*
- * @param object Given object array
* @return The reference class array
*/
public static Class>[] getReference(Object[] objects) {
diff --git a/src/main/java/me/skymc/taboolib/mysql/MysqlConnection.java b/src/main/java/me/skymc/taboolib/mysql/MysqlConnection.java
index 0aff42d..e22b8a3 100644
--- a/src/main/java/me/skymc/taboolib/mysql/MysqlConnection.java
+++ b/src/main/java/me/skymc/taboolib/mysql/MysqlConnection.java
@@ -1,17 +1,9 @@
package me.skymc.taboolib.mysql;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
+import java.sql.*;
import java.util.ArrayList;
import java.util.List;
-import org.bukkit.configuration.file.FileConfiguration;
-
-import com.mysql.jdbc.PreparedStatement;
-
@Deprecated
public class MysqlConnection {
@@ -56,8 +48,6 @@ public class MysqlConnection {
}
Thread.sleep(30000);
- } catch (SQLException e) {
- e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
@@ -120,10 +110,10 @@ public class MysqlConnection {
for (int i = 0 ; i < list.length ; i++) {
if (i + 1 < list.length) {
- stringBuilder.append("`" + checkString(list[i]) + "` varchar(255), ");
+ stringBuilder.append("`").append(checkString(list[i])).append("` varchar(255), ");
}
else {
- stringBuilder.append("`" + checkString(list[i]) + "` varchar(255)");
+ stringBuilder.append("`").append(checkString(list[i])).append("` varchar(255)");
}
}
String url = "CREATE TABLE IF NOT EXISTS `" + table + "` ( " + stringBuilder + " )";
@@ -150,12 +140,12 @@ public class MysqlConnection {
for (int i = 0 ; i < list.length ; i++) {
if (i + 1 < list.length) {
- listbuilder.append("`" + checkString(list[i]) + "`, ");
- valuebuilder.append("'" + checkString(values[i]) + "', ");
+ listbuilder.append("`").append(checkString(list[i])).append("`, ");
+ valuebuilder.append("'").append(checkString(values[i])).append("', ");
}
else {
- listbuilder.append("`" + checkString(list[i]) + "`");
- valuebuilder.append("'" + checkString(values[i]) + "'");
+ listbuilder.append("`").append(checkString(list[i])).append("`");
+ valuebuilder.append("'").append(checkString(values[i])).append("'");
}
}
diff --git a/src/main/java/me/skymc/taboolib/mysql/MysqlUtils.java b/src/main/java/me/skymc/taboolib/mysql/MysqlUtils.java
index b76a16a..ebfe373 100644
--- a/src/main/java/me/skymc/taboolib/mysql/MysqlUtils.java
+++ b/src/main/java/me/skymc/taboolib/mysql/MysqlUtils.java
@@ -1,15 +1,12 @@
package me.skymc.taboolib.mysql;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.plugin.Plugin;
-
import me.skymc.taboolib.Main;
import me.skymc.taboolib.message.MsgUtils;
import me.skymc.taboolib.mysql.protect.MySQLConnection;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.plugin.Plugin;
+
+import java.util.concurrent.CopyOnWriteArrayList;
public class MysqlUtils {
diff --git a/src/main/java/me/skymc/taboolib/mysql/protect/MySQLConnection.java b/src/main/java/me/skymc/taboolib/mysql/protect/MySQLConnection.java
index 601da3d..13046fb 100644
--- a/src/main/java/me/skymc/taboolib/mysql/protect/MySQLConnection.java
+++ b/src/main/java/me/skymc/taboolib/mysql/protect/MySQLConnection.java
@@ -1,20 +1,15 @@
package me.skymc.taboolib.mysql.protect;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.bukkit.plugin.Plugin;
-
import lombok.Getter;
import lombok.Setter;
import me.skymc.taboolib.Main;
+import org.bukkit.plugin.Plugin;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
public class MySQLConnection {
@@ -69,25 +64,19 @@ public class MySQLConnection {
connect();
// 断线检测
- recheckThread = new Thread(new Runnable() {
-
- @Override
- public void run() {
- while (!Main.isDisable()) {
- try {
- Thread.sleep(getReCheckSeconds() * 1000);
-
- if (connection == null) {
- print("警告! 数据库尚未连接, 请检查配置文件后重启服务器! (" + (plugin.getName()) + ")");
- continue;
- }
- else {
- isExists("taboolib");
- }
- } catch (Exception e) {
- print("数据库命令执行出错");
- print("错误原因: " + e.getMessage());
+ recheckThread = new Thread(() -> {
+ while (!Main.isDisable()) {
+ try {
+ Thread.sleep(getReCheckSeconds() * 1000);
+
+ if (connection == null) {
+ print("警告! 数据库尚未连接, 请检查配置文件后重启服务器! (" + (plugin.getName()) + ")");
+ } else {
+ isExists("taboolib");
}
+ } catch (Exception e) {
+ print("数据库命令执行出错");
+ print("错误原因: " + e.getMessage());
}
}
});
@@ -266,7 +255,7 @@ public class MySQLConnection {
*/
public boolean intoValue(String name, Object... values) {
StringBuilder sb = new StringBuilder();
- for (int i = 0 ; i < values.length ; i++) {
+ for (Object value : values) {
sb.append("?, ");
}
PreparedStatement pstmt = null;
@@ -300,7 +289,7 @@ public class MySQLConnection {
public boolean createTable(String name, Column... columns) {
StringBuilder sb = new StringBuilder();
for (Column column : columns) {
- sb.append(column.toString() + ", ");
+ sb.append(column.toString()).append(", ");
}
return execute("create table if not exists " + name + " (id int(1) not null primary key auto_increment, " + sb.substring(0, sb.length() - 2) + ")");
}
@@ -316,9 +305,9 @@ public class MySQLConnection {
StringBuilder sb = new StringBuilder();
for (String column : columns) {
if (!column.contains("/")) {
- sb.append("`" + column + "` text, ");
+ sb.append("`").append(column).append("` text, ");
} else {
- sb.append("`" + column.split("/")[0] + "` " + column.split("/")[1] + ", ");
+ sb.append("`").append(column.split("/")[0]).append("` ").append(column.split("/")[1]).append(", ");
}
}
return execute("create table if not exists " + name + " (id int(1) not null primary key auto_increment, " + sb.substring(0, sb.length() - 2) + ")");
@@ -749,25 +738,25 @@ public class MySQLConnection {
return false;
}
}
-
- public static enum ColumnInteger {
-
- TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT;
+
+ public enum ColumnInteger {
+
+ TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT
}
-
- public static enum ColumnFloat {
-
- FLOAT, DOUBLE;
+
+ public enum ColumnFloat {
+
+ FLOAT, DOUBLE
}
-
- public static enum ColumnChar {
-
- CHAR, VARCHAR;
+
+ public enum ColumnChar {
+
+ CHAR, VARCHAR
}
-
- public static enum ColumnString {
-
- TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT;
+
+ public enum ColumnString {
+
+ TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT
}
public static class Column {
diff --git a/src/main/java/me/skymc/taboolib/nms/NMSUtil18.java b/src/main/java/me/skymc/taboolib/nms/NMSUtil18.java
index c31f568..274cf6f 100644
--- a/src/main/java/me/skymc/taboolib/nms/NMSUtil18.java
+++ b/src/main/java/me/skymc/taboolib/nms/NMSUtil18.java
@@ -1,10 +1,6 @@
package me.skymc.taboolib.nms;
-import org.bukkit.Bukkit;
-import org.bukkit.DyeColor;
-import org.bukkit.Location;
-import org.bukkit.Server;
-import org.bukkit.World;
+import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
@@ -915,7 +911,7 @@ public class NMSUtil18 {
// Testing Glow API based on ItemMetadata storage
Object bukkitData = createNode(stack, "bukkit");
class_NBTTagCompound_setBooleanMethod.invoke(bukkitData, "glow", true);
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
}
@@ -939,7 +935,7 @@ public class NMSUtil18 {
if (bukkitData != null) {
class_NBTTagCompound_setBooleanMethod.invoke(bukkitData, "glow", false);
}
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
}
@@ -960,7 +956,7 @@ public class NMSUtil18 {
unbreakableFlag = class_NBTTagByte_legacy_constructor.newInstance("", (byte) 1);
}
class_NBTTagCompound_setMethod.invoke(tagObject, "Unbreakable", unbreakableFlag);
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
}
@@ -985,7 +981,7 @@ public class NMSUtil18 {
hideFlag = class_NBTTagByte_legacy_constructor.newInstance("", flags);
}
class_NBTTagCompound_setMethod.invoke(tagObject, "HideFlags", hideFlag);
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
}
diff --git a/src/main/java/me/skymc/taboolib/nms/NMSUtil19.java b/src/main/java/me/skymc/taboolib/nms/NMSUtil19.java
index ac5a67f..4437f76 100644
--- a/src/main/java/me/skymc/taboolib/nms/NMSUtil19.java
+++ b/src/main/java/me/skymc/taboolib/nms/NMSUtil19.java
@@ -1,12 +1,7 @@
package me.skymc.taboolib.nms;
import org.apache.commons.lang.StringUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.DyeColor;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.Server;
-import org.bukkit.World;
+import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemorySection;
@@ -24,12 +19,7 @@ import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
import java.util.logging.Level;
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -1139,8 +1129,7 @@ public class NMSUtil19 {
}
public static boolean hasMeta(ItemStack stack, String tag) {
- if (NMSUtil19.isEmpty(stack)) return false;
- return getNode(stack, tag) != null;
+ return !NMSUtil19.isEmpty(stack) && getNode(stack, tag) != null;
}
public static Object getTag(ItemStack itemStack) {
@@ -1474,7 +1463,7 @@ public class NMSUtil19 {
Object tagObject = getTag(craft);
if (tagObject == null) return false;
unbreakableFlag = getMetaBoolean(tagObject, "Unbreakable");
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
@@ -1493,7 +1482,7 @@ public class NMSUtil19 {
Object unbreakableFlag = null;
unbreakableFlag = class_NBTTagByte_constructor.newInstance((byte) 1);
class_NBTTagCompound_setMethod.invoke(tagObject, "Unbreakable", unbreakableFlag);
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
}
@@ -1514,7 +1503,7 @@ public class NMSUtil19 {
Object hideFlag = null;
hideFlag = class_NBTTagByte_constructor.newInstance(flags);
class_NBTTagCompound_setMethod.invoke(tagObject, "HideFlags", hideFlag);
- } catch (Throwable ex) {
+ } catch (Throwable ignored) {
}
}
diff --git a/src/main/java/me/skymc/taboolib/nms/NMSUtils.java b/src/main/java/me/skymc/taboolib/nms/NMSUtils.java
index 9cfb28b..c68b463 100644
--- a/src/main/java/me/skymc/taboolib/nms/NMSUtils.java
+++ b/src/main/java/me/skymc/taboolib/nms/NMSUtils.java
@@ -1,14 +1,11 @@
package me.skymc.taboolib.nms;
+import org.bukkit.Bukkit;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.UUID;
-
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.entity.Entity;
public class NMSUtils {
@@ -34,7 +31,7 @@ public class NMSUtils {
for(String s : strings){
try{
return getClassWithException(s);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
}
return null;
@@ -43,7 +40,7 @@ public class NMSUtils {
public static Class> getClassSilent(String name){
try{
return getClassWithException(name);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
@@ -64,7 +61,7 @@ public class NMSUtils {
public static Class> getNMSClassSilent(String className){
try{
return getNMSClassWithException(className);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
@@ -101,7 +98,7 @@ public class NMSUtils {
public static Class> getOBCClassSilent(String className){
try{
return getOBCClassWithException(className);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
@@ -175,7 +172,7 @@ public class NMSUtils {
for(String name : names){
try{
return getFieldWithException(clazz, name);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
}
return null;
@@ -184,7 +181,7 @@ public class NMSUtils {
public static Field getFieldSilent(Class> clazz, String name){
try{
return getFieldWithException(clazz, name);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
@@ -193,7 +190,7 @@ public class NMSUtils {
for(String name : names){
try{
return getFieldWithException(clazz, name);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
}
return null;
@@ -298,7 +295,7 @@ public class NMSUtils {
public static Method getMethodSilent(Class> clazz, String name, Class>... args){
try{
return getMethodWithException(clazz, name, args);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
@@ -331,7 +328,7 @@ public class NMSUtils {
public static Class> getInnerClassSilent(Class> c, String className){
try{
return getInnerClassWithException(c, className);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
@@ -353,7 +350,7 @@ public class NMSUtils {
public static Constructor> getConstructorSilent(Class> clazz, Class>... args){
try{
return getConstructor(clazz, args);
- }catch(Exception e){
+ } catch (Exception ignored) {
}
return null;
}
diff --git a/src/main/java/me/skymc/taboolib/nms/item/DabItemUtils.java b/src/main/java/me/skymc/taboolib/nms/item/DabItemUtils.java
index 9bf0060..dad63d1 100644
--- a/src/main/java/me/skymc/taboolib/nms/item/DabItemUtils.java
+++ b/src/main/java/me/skymc/taboolib/nms/item/DabItemUtils.java
@@ -1,22 +1,21 @@
package me.skymc.taboolib.nms.item;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
+import me.skymc.taboolib.Main;
+import me.skymc.taboolib.json.JSONArray;
+import me.skymc.taboolib.json.JSONObject;
+import me.skymc.taboolib.message.MsgUtils;
+import me.skymc.taboolib.nms.item.impl._164ItemUtils;
+import me.skymc.taboolib.nms.item.impl._1710ItemUtils;
+import me.skymc.taboolib.nms.item.impl._194ItemUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import me.skymc.taboolib.Main;
-import me.skymc.taboolib.json.JSONArray;
-import me.skymc.taboolib.json.JSONObject;
-import me.skymc.taboolib.message.MsgUtils;
-import me.skymc.taboolib.nms.item.impl._194ItemUtils;
-import me.skymc.taboolib.nms.item.impl._164ItemUtils;
-import me.skymc.taboolib.nms.item.impl._1710ItemUtils;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
public class DabItemUtils {
@@ -32,21 +31,21 @@ public class DabItemUtils {
inst.convertItemStackToJSON(is);
MsgUtils.send("载入 1.9.4 Spigot 物品工具成功!");
return inst;
- }catch(Exception e){
+ } catch (Exception ignored) {
}
try{
_1710ItemUtils inst = new _1710ItemUtils();
inst.convertItemStackToJSON(is);
MsgUtils.send("载入 1.7.10 Cauldron 物品工具成功!");
return inst;
- }catch(Exception e){
+ } catch (Exception ignored) {
}
try{
IDabItemUtils inst = new _164ItemUtils();
inst.convertItemStackToJSON(is);
MsgUtils.send("载入 1.6.4 Cauldron 物品工具成功!");
return inst;
- }catch(Exception e){
+ } catch (Exception ignored) {
}
MsgUtils.send("&4物品工具载入失败, 插件已关闭!");
Bukkit.getPluginManager().disablePlugin(Main.getInst());
diff --git a/src/main/java/me/skymc/taboolib/nms/item/IDabItemUtils.java b/src/main/java/me/skymc/taboolib/nms/item/IDabItemUtils.java
index 81e59d0..c24b652 100644
--- a/src/main/java/me/skymc/taboolib/nms/item/IDabItemUtils.java
+++ b/src/main/java/me/skymc/taboolib/nms/item/IDabItemUtils.java
@@ -1,102 +1,171 @@
package me.skymc.taboolib.nms.item;
+import me.skymc.taboolib.json.JSONArray;
+import me.skymc.taboolib.json.JSONObject;
+import org.bukkit.inventory.ItemStack;
+
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
-import org.bukkit.inventory.ItemStack;
-
-import me.skymc.taboolib.json.JSONArray;
-import me.skymc.taboolib.json.JSONObject;
-
public interface IDabItemUtils{
//@formatter:off
- public boolean hasBanner();
- public Object getNMSCopy(ItemStack is) throws Exception;
- public boolean hasTag(Object is) throws Exception;
- public ItemStack asCraftMirror(Object nis) throws Exception;
- public ItemStack asBukkitCopy(Object nmis) throws Exception;
- public String getName(ItemStack is);
- public Object getItem(Object nis) throws Exception;
- public Method getA();
- public String getRawName(ItemStack is);
- public String getItemName(ItemStack is);
- public Object getRegistry();
- public String getMinecraftName(ItemStack is);
- public Object getTag(Object is) throws Exception;
- public void setTag(Object is, Object tag1) throws Exception;
- public boolean isEmpty(Object tag) throws Exception;
- public Object getMap(Object tag) throws Exception;
- public void set(Object tag, String key, Object value) throws Exception;
- public void setString(Object tag, String key, String value) throws Exception;
- public void setShort(Object tag, String key, short value) throws Exception;
- public void setInt(Object tag, String key, int i) throws Exception;
- public void setDouble(Object tag, String key, double d) throws Exception;
- public void setLong(Object tag, String key, long l) throws Exception;
- public boolean hasKey(Object tag, String key) throws Exception;
- public Object get(Object tag, String key) throws Exception;
- public String getString(Object tag, String key) throws Exception;
- public int getInt(Object tag, String key) throws Exception;
- public double getDouble(Object tag, String key) throws Exception;
- public long getLong(Object tag, String key) throws Exception;
- public short getShort(Object tag, String key) throws Exception;
- public Object getNewNBTTagCompound() throws Exception;
- public boolean hasAttributeModifiersKey(Object tag) throws Exception;
- public Object getList(Object tag) throws Exception;
- public Object getList(Object tag, String name, int id) throws Exception;
- public boolean getUnbreakable(Object tag) throws Exception;
- public void setUnbreakable(Object tag, boolean value) throws Exception;
- public Object getNewNBTTagList() throws Exception;
- public void addToList(Object taglist, Object nbt) throws Exception;
- public int getSize(Object list) throws Exception;
- public Object get(Object tlist, int i) throws Exception;
- public Object getNewNBTTagByte(byte value) throws Exception;
- public Object getNewNBTTagByteArray(byte[] value) throws Exception;
- public Object getData(Object nbt) throws Exception;
- public Object createData(Object value) throws Exception;
- public Map convertCompoundTagToValueMap(Object nbt) throws Exception;
- public List