diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index 5ddbeb899..7b1f60314 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -512,6 +512,7 @@ public class QuickShop extends JavaPlugin { } } + getLogger().severe("===========Error Reporting End==========="); if (errors < 3) { getLogger().info("Removeing shop from database..."); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 9eeb91ca7..679b74a54 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -379,7 +379,7 @@ public class ShopManager { /* The shop has hereforth been successfully created */ createShop(shop); Location loc = shop.getLocation(); - plugin.log(p.getName() + " created a " + MsgUtil.getItemi18n(shop.getDataName()) + " shop at (" + loc.getWorld().getName() + " - " + loc.getX() + "," + loc.getY() + "," + loc.getZ() + ")"); + plugin.log(p.getName() + " created a " + MsgUtil.getDisplayName(shop.getItem(), shop.getDataName()) + " shop at (" + loc.getWorld().getName() + " - " + loc.getX() + "," + loc.getY() + "," + loc.getZ() + ")"); if (!plugin.getConfig().getBoolean("shop.lock")) { // Warn them if they haven't been warned since // reboot @@ -471,7 +471,7 @@ public class ShopManager { if (shop.isSelling()) { int stock = shop.getRemainingStock(); if (stock < amount) { - p.sendMessage(MsgUtil.getMessage("shop-stock-too-low", String.valueOf(shop.getRemainingStock()),MsgUtil.getItemi18n(shop.getDataName()))); + p.sendMessage(MsgUtil.getMessage("shop-stock-too-low", String.valueOf(shop.getRemainingStock()), MsgUtil.getDisplayName(shop.getItem(), shop.getDataName()))); return; } if (amount == 0) { @@ -533,12 +533,12 @@ public class ShopManager { } // Notify the shop owner if (plugin.getConfig().getBoolean("show-tax")) { - String msg = MsgUtil.getMessage("player-bought-from-your-store-tax", p.getName(), "" + amount, MsgUtil.getItemi18n(shop.getDataName()), Util.format((tax * total))); + String msg = MsgUtil.getMessage("player-bought-from-your-store-tax", p.getName(), "" + amount, MsgUtil.getDisplayName(shop.getItem(), shop.getDataName()), Util.format((tax * total))); if (stock == amount) - msg += "\n" + MsgUtil.getMessage("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), MsgUtil.getItemi18n(shop.getDataName())); + msg += "\n" + MsgUtil.getMessage("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), MsgUtil.getDisplayName(shop.getItem(), shop.getDataName())); MsgUtil.send(shop.getOwner(), msg); } else { - String msg = MsgUtil.getMessage("player-bought-from-your-store", p.getName(), "" + amount, shop.getDataName()); + String msg = MsgUtil.getMessage("player-bought-from-your-store", p.getName(), "" + amount, MsgUtil.getDisplayName(shop.getItem(), shop.getDataName())); if (stock == amount) msg += "\n" + MsgUtil.getMessage("shop-out-of-stock", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ(), shop.getDataName()); MsgUtil.send(shop.getOwner(), msg); @@ -552,13 +552,13 @@ public class ShopManager { } else if (shop.isBuying()) { int space = shop.getRemainingSpace(); if (space < amount) { - p.sendMessage(MsgUtil.getMessage("shop-has-no-space", "" + space, MsgUtil.getItemi18n(shop.getDataName()))); + p.sendMessage(MsgUtil.getMessage("shop-has-no-space", "" + space, MsgUtil.getDisplayName(shop.getItem(), shop.getDataName()))); return; } int count = Util.countItems(p.getInventory(), shop.getItem()); // Not enough items if (amount > count) { - p.sendMessage(MsgUtil.getMessage("you-dont-have-that-many-items", "" + count, MsgUtil.getItemi18n(shop.getDataName()))); + p.sendMessage(MsgUtil.getMessage("you-dont-have-that-many-items", "" + count, MsgUtil.getDisplayName(shop.getItem(), shop.getDataName()))); return; } if (amount == 0) { @@ -613,7 +613,7 @@ public class ShopManager { boolean depositresult = plugin.getEcon().deposit(p.getUniqueId(), total * (1 - tax)); if(QuickShop.debug) {plugin.getLogger().info("Economy debug:deposit2 in shopmanager result:"+depositresult);} // Notify the owner of the purchase. - String msg = MsgUtil.getMessage("player-sold-to-your-store", p.getName(), "" + amount, MsgUtil.getItemi18n(shop.getDataName())); + String msg = MsgUtil.getMessage("player-sold-to-your-store", p.getName(), "" + amount, MsgUtil.getDisplayName(shop.getItem(), shop.getDataName())); if (space == amount) msg += "\n" + MsgUtil.getMessage("shop-out-of-space", "" + shop.getLocation().getBlockX(), "" + shop.getLocation().getBlockY(), "" + shop.getLocation().getBlockZ()); MsgUtil.send(shop.getOwner(), msg); diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java index aa8ebae25..2529971c1 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java +++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java @@ -26,6 +26,8 @@ import org.bukkit.potion.PotionEffectType; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.Shop.Shop; +import net.minecraft.server.v1_13_R1.DataWatcher.Item; + public class MsgUtil { static QuickShop plugin = QuickShop.instance; private static YamlConfiguration messages; @@ -428,7 +430,16 @@ public class MsgUtil { } p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+"); } - + public static String getDisplayName(ItemStack iStack, String DataName){ + ItemStack is = iStack.clone(); + + if(is.hasItemMeta()&&is.getItemMeta().hasDisplayName()) { + return is.getItemMeta().getDisplayName(); + }else { + return MsgUtil.getItemi18n(DataName); + } + + } public static String getMessage(String loc, String... args) { String raw = messages.getString(loc); if (raw == null) { diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index c853977ef..6afcc3cdb 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -356,6 +356,12 @@ public class Util { ItemStack is = itemStack.clone(); is.setAmount(1); + if(is.hasItemMeta()) { + if(is.getItemMeta().hasDisplayName()) { + return is.getItemMeta().getDisplayName(); + } + } + String name = MsgUtil.getItemi18n(itemStack.getType().name()).trim(); String[] nameParts = name.split("_");