mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Support Item CustomName display
Former-commit-id: 122f3f88a330254914bfcfa32c3d8b9b138a8e7b
This commit is contained in:
1 parent
b4ba8e1718
commit
e1a5164894
4 files changed
+27
-9
No files matched your search
@@ -512,6 +512,7 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
|
||||
}
|
||||
getLogger().severe("===========Error Reporting End===========");
|
||||
|
||||
if (errors < 3) {
|
||||
getLogger().info("Removeing shop from database...");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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("_");
|
||||
|
||||
Reference in new issue
Block a user