From d77d78e3c033ca8e2999e68a7bcbf49962686dc6 Mon Sep 17 00:00:00 2001 From: xjboss Date: Sun, 14 May 2017 01:46:31 +0800 Subject: [PATCH] =?UTF-8?q?1.7.10=20MOD=E6=9C=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=89=A9=E4=BF=AE=E5=A4=8D=EF=BC=8C=E6=B7=BB=E5=8A=A0BSRE?= =?UTF-8?q?=E7=9A=84=E8=AF=AD=E8=A8=80=E6=96=87=E4=BB=B6=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QuickShop/Shop/Item/DisplayItem.java | 2 +- .../QuickShop/Shop/Item/FakeItem_17.java | 1 + .../org/maxgamer/QuickShop/Util/Util.java | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/maxgamer/QuickShop/Shop/Item/DisplayItem.java b/src/main/java/org/maxgamer/QuickShop/Shop/Item/DisplayItem.java index 75fd066..7746de7 100644 --- a/src/main/java/org/maxgamer/QuickShop/Shop/Item/DisplayItem.java +++ b/src/main/java/org/maxgamer/QuickShop/Shop/Item/DisplayItem.java @@ -30,7 +30,7 @@ public abstract class DisplayItem { private static Constructor constructor; public static void init() { - List> fakeItems = Arrays.asList(FakeItem_19_111.class, FakeItem_18.class, FakeItem_17.class); + List> fakeItems = Arrays.asList(FakeItem_19_111.class, FakeItem_17.class); Log.i("启用虚拟悬浮物 尝试启动中..."); FakeItem.register(plugin); for (Class c : fakeItems) { diff --git a/src/main/java/org/maxgamer/QuickShop/Shop/Item/FakeItem_17.java b/src/main/java/org/maxgamer/QuickShop/Shop/Item/FakeItem_17.java index 6ad5053..cf0aead 100644 --- a/src/main/java/org/maxgamer/QuickShop/Shop/Item/FakeItem_17.java +++ b/src/main/java/org/maxgamer/QuickShop/Shop/Item/FakeItem_17.java @@ -44,6 +44,7 @@ public class FakeItem_17 extends FakeItem { is.write(1, getNormalizedDistance(location.getX())); is.write(2, getNormalizedDistance(location.getY())); is.write(3, getNormalizedDistance(location.getZ())); + is.write(9,2); return fakePacket; } } diff --git a/src/main/java/org/maxgamer/QuickShop/Util/Util.java b/src/main/java/org/maxgamer/QuickShop/Util/Util.java index 524f261..467809b 100644 --- a/src/main/java/org/maxgamer/QuickShop/Util/Util.java +++ b/src/main/java/org/maxgamer/QuickShop/Util/Util.java @@ -1,11 +1,13 @@ package org.maxgamer.QuickShop.Util; +import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -156,6 +158,8 @@ public class Util { * @return The human readable item name. */ public static String getName(final ItemStack i) { + String S; + if(BS) return (S=getDisplayName(i))==null?L10N.getItemName(i):S; return L10N.getItemName(i); } @@ -366,6 +370,38 @@ public class Util { addTransparentBlock(Material.BREWING_STAND); addTransparentBlock(Material.WOODEN_DOOR); addTransparentBlock(Material.WOOD_STEP); + BS=false; + try { + Class.forName("org.black_ixx.bossshop.managers.ItemNameManager"); + plugin.getLogger().info("检测到bossshop-re已经加载,使用bsre的物品名称功能。"); + BSplug= Bukkit.getPluginManager().getPlugin("BossShop"); + BS=true; + BSREItemLang(); + }catch (Throwable e){ + plugin.getLogger().info("检测到bossshop-re没有加载,使用内置的物品名称功能。"); + } + } + private static Object BSplug; + private static Method BS_GIS; + private static Object BS_IM; + private static boolean BS=false; + public static String getDisplayName(final ItemStack item){ + try { + BS_GIS.setAccessible(true); + return (String) BS_GIS.invoke(BS_IM, item); + }catch (Throwable e){} + return null; + } + private static void BSREItemLang(){ + try { + Class BSLM = Class.forName("org.black_ixx.bossshop.managers.ItemNameManager"); + Method GM=BSplug.getClass().getMethod("getManager",Class.class); + BS_IM=GM.invoke(BSplug,BSLM); + BS_GIS=BS_IM.getClass().getMethod("getDisplayName",ItemStack.class); + BS=true; + }catch (Throwable e){ + + } } /**