From 271bbed5da5dafc52841005aabcfb2afe7152f62 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Mon, 19 Sep 2016 16:32:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../pw/yumc/YumCore/tellraw/ItemSerialize.java | 16 ++++++++-------- .../pw/yumc/YumCore/tellraw/JsonBuilder.java | 6 +++--- .../pw/yumc/YumCore/tellraw/MessagePart.java | 2 +- .../java/pw/yumc/YumCore/tellraw/Tellraw.java | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/tellraw/ItemSerialize.java b/src/main/java/pw/yumc/YumCore/tellraw/ItemSerialize.java index 5fef031..1282f85 100644 --- a/src/main/java/pw/yumc/YumCore/tellraw/ItemSerialize.java +++ b/src/main/java/pw/yumc/YumCore/tellraw/ItemSerialize.java @@ -15,7 +15,7 @@ import pw.yumc.YumCore.bukkit.Log; /** * 物品序列化类 - * + * * @since 2016年9月9日 下午3:47:17 * @author 喵♂呜 */ @@ -52,14 +52,14 @@ public abstract class ItemSerialize { final Class nmsItemStack = asNMSCopyMethod.getReturnType(); for (final Method method : nmsItemStack.getMethods()) { final Class rt = method.getReturnType(); - if (method.getParameterTypes().length == 0 && rt.getSimpleName().equals("NBTTagCompound")) { + if (method.getParameterTypes().length == 0 && "NBTTagCompound".equals(rt.getSimpleName())) { nmsNBTTagCompound = rt; } } for (final Method method : nmsItemStack.getMethods()) { final Class[] paras = method.getParameterTypes(); final Class rt = method.getReturnType(); - if (paras.length == 1 && paras[0].getSimpleName().equals("NBTTagCompound") && rt.getSimpleName().equals("NBTTagCompound")) { + if (paras.length == 1 && "NBTTagCompound".equals(paras[0].getSimpleName()) && "NBTTagCompound".equals(rt.getSimpleName())) { nmsSaveNBTMethod = method; } } @@ -70,7 +70,7 @@ public abstract class ItemSerialize { return "Automatic"; } - public Class getOBCClass(final String cname) throws ClassNotFoundException { + public Class getOBCClass(final String cname) throws ClassNotFoundException { return Class.forName("org.bukkit.craftbukkit." + ver + "." + cname); } @@ -105,7 +105,7 @@ public abstract class ItemSerialize { * @return 获取显示序列化 */ private String getDisplay(final ItemMeta im) { - final StringBuffer display = new StringBuffer(); + final StringBuilder display = new StringBuilder(); display.append("{"); if (im.hasDisplayName()) { display.append(String.format("Name:\"%s\",", im.getDisplayName())); @@ -133,7 +133,7 @@ public abstract class ItemSerialize { * @return 获得附魔序列化 */ private String getEnch(final Set> set) { - final StringBuffer enchs = new StringBuffer(); + final StringBuilder enchs = new StringBuilder(); for (final Map.Entry ench : set) { enchs.append(String.format("{id:%s,lvl:%s},", ench.getKey().getId(), ench.getValue())); } @@ -149,7 +149,7 @@ public abstract class ItemSerialize { * @return 获得属性序列化 */ private String getTag(final ItemMeta im) { - final StringBuffer meta = new StringBuffer("{"); + final StringBuilder meta = new StringBuilder("{"); if (im.hasEnchants()) { meta.append(String.format("ench:[%s],", getEnch(im.getEnchants().entrySet()))); } @@ -169,7 +169,7 @@ public abstract class ItemSerialize { * @return 物品字符串 */ private String serialize(final ItemStack item) { - final StringBuffer json = new StringBuffer("{"); + final StringBuilder json = new StringBuilder("{"); json.append(String.format("id:\"%s\",Damage:\"%s\"", item.getTypeId(), item.getDurability())); if (item.getAmount() > 1) { json.append(String.format(",Count:%s", item.getAmount())); diff --git a/src/main/java/pw/yumc/YumCore/tellraw/JsonBuilder.java b/src/main/java/pw/yumc/YumCore/tellraw/JsonBuilder.java index d439e62..1d12fda 100644 --- a/src/main/java/pw/yumc/YumCore/tellraw/JsonBuilder.java +++ b/src/main/java/pw/yumc/YumCore/tellraw/JsonBuilder.java @@ -2,7 +2,7 @@ package pw.yumc.YumCore.tellraw; /** * Json构建 - * + * * @since 2016年9月14日 上午11:55:36 * @author 喵♂呜 */ @@ -21,10 +21,10 @@ public class JsonBuilder { REPLACEMENT_CHARS['\r'] = "\\r"; REPLACEMENT_CHARS['\f'] = "\\f"; } - StringBuffer json; + StringBuilder json; public JsonBuilder() { - json = new StringBuffer(); + json = new StringBuilder(); } public JsonBuilder(final String string) { diff --git a/src/main/java/pw/yumc/YumCore/tellraw/MessagePart.java b/src/main/java/pw/yumc/YumCore/tellraw/MessagePart.java index a11f859..37d5089 100644 --- a/src/main/java/pw/yumc/YumCore/tellraw/MessagePart.java +++ b/src/main/java/pw/yumc/YumCore/tellraw/MessagePart.java @@ -57,7 +57,7 @@ public class MessagePart { * @param str * 流对象 */ - public void writeJson(final StringBuffer str) { + public void writeJson(final StringBuilder str) { str.append("{"); str.append(String.format(TEXT_FORMAT, new JsonBuilder(text))); if (clickActionName != null) { diff --git a/src/main/java/pw/yumc/YumCore/tellraw/Tellraw.java b/src/main/java/pw/yumc/YumCore/tellraw/Tellraw.java index 0abf888..909bca4 100644 --- a/src/main/java/pw/yumc/YumCore/tellraw/Tellraw.java +++ b/src/main/java/pw/yumc/YumCore/tellraw/Tellraw.java @@ -232,10 +232,10 @@ public class Tellraw { * @return {@link Tellraw} */ public Tellraw tip(final List texts) { - if (texts.size() == 0) { + if (texts.isEmpty()) { return this; } - final StringBuffer text = new StringBuffer(); + final StringBuilder text = new StringBuilder(); for (final String t : texts) { text.append(t).append("\n"); } @@ -270,7 +270,7 @@ public class Tellraw { * @return Json串 */ public String toJsonString() { - final StringBuffer msg = new StringBuffer(); + final StringBuilder msg = new StringBuilder(); msg.append("[\"\""); for (final MessagePart messagePart : messageParts) { msg.append(",");