From d0d75a1ca668aa39327362e3de2310d4c933b5e6 Mon Sep 17 00:00:00 2001 From: xjboss Date: Tue, 9 May 2017 00:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86BossShop-Re=E7=9A=84?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=88=B0=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E4=BA=86BS-RE=E5=B0=86=E7=A6=81=E7=94=A8YumCore?= =?UTF-8?q?=E9=87=8C=E7=9A=84=E8=AF=AD=E8=A8=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../org/maxgamer/QuickShop/Util/Util.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7df3611..49fb55a 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ pw.yumc YumCore jar - 1.8 + 1.7 io.github.Cnly.WowSuchCleaner diff --git a/src/main/java/org/maxgamer/QuickShop/Util/Util.java b/src/main/java/org/maxgamer/QuickShop/Util/Util.java index a7229b8..4100a7e 100644 --- a/src/main/java/org/maxgamer/QuickShop/Util/Util.java +++ b/src/main/java/org/maxgamer/QuickShop/Util/Util.java @@ -1,5 +1,6 @@ package org.maxgamer.QuickShop.Util; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -20,6 +21,7 @@ import org.maxgamer.QuickShop.QuickShop; import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.global.L10N; +import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.HashSet; import java.util.List; @@ -157,6 +159,10 @@ public class Util { * @return The human readable item name. */ public static String getName(final ItemStack i) { + if(BS){ + String S; + return (S=getDisplayName(i))==null?L10N.getItemName(i):S; + } return L10N.getItemName(i); } @@ -368,6 +374,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){ + + } } /**