1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-23 02:08:55 +00:00

添加了BossShop-Re的语言功能,如果检测到服务器安装了BS-RE将禁用YumCore里的语言功能

This commit is contained in:
xjboss 2017-05-09 00:01:12 +08:00
parent dec12d75cb
commit d0d75a1ca6
2 changed files with 39 additions and 1 deletions

View File

@ -78,7 +78,7 @@
<groupId>pw.yumc</groupId> <groupId>pw.yumc</groupId>
<artifactId>YumCore</artifactId> <artifactId>YumCore</artifactId>
<type>jar</type> <type>jar</type>
<version>1.8</version> <version>1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.github.Cnly.WowSuchCleaner</groupId> <groupId>io.github.Cnly.WowSuchCleaner</groupId>

View File

@ -1,5 +1,6 @@
package org.maxgamer.QuickShop.Util; package org.maxgamer.QuickShop.Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,6 +21,7 @@ import org.maxgamer.QuickShop.QuickShop;
import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.global.L10N; import pw.yumc.YumCore.global.L10N;
import java.lang.reflect.Method;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -157,6 +159,10 @@ public class Util {
* @return The human readable item name. * @return The human readable item name.
*/ */
public static String getName(final ItemStack i) { public static String getName(final ItemStack i) {
if(BS){
String S;
return (S=getDisplayName(i))==null?L10N.getItemName(i):S;
}
return L10N.getItemName(i); return L10N.getItemName(i);
} }
@ -368,6 +374,38 @@ public class Util {
addTransparentBlock(Material.BREWING_STAND); addTransparentBlock(Material.BREWING_STAND);
addTransparentBlock(Material.WOODEN_DOOR); addTransparentBlock(Material.WOODEN_DOOR);
addTransparentBlock(Material.WOOD_STEP); 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){
}
} }
/** /**