From 09684b2cba55ee632d7ae52404f7ef0d080a6ea3 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Fri, 9 Nov 2018 23:18:14 +0800 Subject: [PATCH] control panel Former-commit-id: b19a1eadbd4faf2b8bbaf2260f48c498f5b4abef [formerly e2a7cff04a9ac72907ac4bad8a1ce9c7c9c11976] Former-commit-id: b7802164736af3fa7926472f0fc16f1ff02f2613 --- pom.xml | 2 +- .../org/maxgamer/quickshop/Command/QS.java | 10 ---------- .../quickshop/Listeners/PlayerListener.java | 20 +++++++------------ .../org/maxgamer/quickshop/Util/MsgUtil.java | 15 +++++++++----- .../org/maxgamer/quickshop/Util/Util.java | 1 - src/main/resources/messages.yml | 5 +++-- 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index 85395a41a..fc958cb75 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.maxgamer QuickShop - Reremake 1.2.7.4_snapshot_2 + Reremake 1.3.0_snapshot diff --git a/src/main/java/org/maxgamer/quickshop/Command/QS.java b/src/main/java/org/maxgamer/quickshop/Command/QS.java index 5841bc776..54158846e 100644 --- a/src/main/java/org/maxgamer/quickshop/Command/QS.java +++ b/src/main/java/org/maxgamer/quickshop/Command/QS.java @@ -2,10 +2,8 @@ package org.maxgamer.quickshop.Command; import java.io.File; import java.sql.SQLException; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.logging.Level; import org.bukkit.Bukkit; @@ -14,13 +12,7 @@ import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.World; -import org.bukkit.block.Biome; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.BlockState; -import org.bukkit.block.PistonMoveReaction; -import org.bukkit.block.data.BlockData; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -30,8 +22,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.Plugin; import org.bukkit.util.BlockIterator; import org.maxgamer.quickshop.QuickShop; import org.maxgamer.quickshop.Database.Database; diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java index d3c692092..f332fb655 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java @@ -144,20 +144,14 @@ public class PlayerListener implements Listener { } } else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { /** @TODO: ControlPanel **/ - ShopManager manager = new ShopManager(plugin); - Shop shop = null; - if (manager.getShop(e.getClickedBlock().getLocation()) != null) { - shop = manager.getShop(e.getClickedBlock().getLocation()); - } else { - Block block = Util.getAttached(e.getClickedBlock()); - if (manager.getShop(block.getLocation()) != null) { - shop = manager.getShop(block.getLocation()); - } else { - shop = null; - } + Block block; + if(e.getClickedBlock().getType()==Material.WALL_SIGN) { + block = Util.getAttached(e.getClickedBlock()); + }else { + block = e.getClickedBlock(); } - if (shop != null) { - MsgUtil.sendControlPanelInfo((CommandSender) e.getPlayer(), shop); + if (plugin.getShopManager().getShop(block.getLocation()) != null) { + MsgUtil.sendControlPanelInfo((CommandSender)e.getPlayer(), plugin.getShopManager().getShop(block.getLocation())); } } diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java index 8339793f2..3c7c4b743 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java +++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java @@ -65,7 +65,7 @@ public class MsgUtil { if(messages.getInt("language-version")==0) { - messages.set("language-version", 1 ); + messages.set("language-version", 1); } updateMessages(messages.getInt("language-version")); } @@ -77,7 +77,7 @@ public class MsgUtil { messages.set("controlpanel.infomation", "&aShop Control Panel:"); messages.set("controlpanel.setowner", "&aOwner: &b{0} &e[&d&lChange&e]"); messages.set("controlpanel.setowner-hover", "&eLooking you want changing shop and click to switch owner."); - messages.set("controlpanel.unlimited", "&aUnlimited: {0} &e[&rSwitch&e]"); + messages.set("controlpanel.unlimited", "&aUnlimited: {0} &e[&d&lSwitch&e]"); messages.set("controlpanel.unlimited-hover", "&eLooking you want changing shop and click to switch enabled or disabled."); messages.set("controlpanel.mode-selling", "&aShop mode: &bSelling &e[&d&lSwitch&e]"); messages.set("controlpanel.mode-selling-hover", "&eLooking you want changing shop and click to switch enabled or disabled."); @@ -92,6 +92,7 @@ public class MsgUtil { messages.set("controlpanel.remove", "&c&l[Remove Shop]"); messages.set("controlpanel.remove-hover", "&eClick to remove this shop."); messages.set("config-version", 2); + Util.parseColours(messages); selectedVersion = 2; } } @@ -113,7 +114,7 @@ public class MsgUtil { if (!sender.hasPermission("quickshop.setowner")) { sender.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.getMessage("menu.owner", shop.ownerName())); } else { - String Text = MsgUtil.getMessage("controlpanel.setowner"); + String Text = MsgUtil.getMessage("controlpanel.setowner",shop.ownerName()); String hoverText = MsgUtil.getMessage("controlpanel.setowner-hover"); String clickCommand = "/qs setowner [Player]"; TextComponent message = new TextComponent(ChatColor.DARK_PURPLE + "| " + Text); @@ -158,8 +159,12 @@ public class MsgUtil { if (sender.hasPermission("quickshop.refill")) { String Text = MsgUtil.getMessage("controlpanel.refill", String.valueOf(shop.getPrice())); String hoverText = MsgUtil.getMessage("controlpanel.refill-hover"); - String clickCommand = "/qs refill"; - MsgUtil.sendPanelMessage(sender, Text, hoverText, clickCommand); + String clickCommand = "/qs refill [Amount]"; + TextComponent message = new TextComponent(ChatColor.DARK_PURPLE + "| " + Text); + message.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, clickCommand)); + message.setHoverEvent( + new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create())); + sender.spigot().sendMessage(message); } // Refill if (sender.hasPermission("quickshop.empty")) { diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index f12f1df53..e80091c41 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -32,7 +32,6 @@ import java.text.DecimalFormat; import java.util.AbstractMap.SimpleEntry; import java.util.*; import java.util.Map.Entry; -import java.util.logging.Level; /** * @author MACHENIKE diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index ac0505352..6b8c60599 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -11,7 +11,7 @@ language-version: "&c&lSupport Version: &b&lReremake 1.2.5.2" language-country: "&c&lLanguage Zone: &b&lEnglish (en_US)" # ====================================================================== -language-version: 1 +language-version: 2 not-looking-at-shop: "&cNo QuickShop found. You must be looking at one." no-anythings-in-your-hand: "&cNo anythings in your hand." @@ -102,6 +102,7 @@ command: reloading: "&aReloading..." cleaned: "&aCleaned &e{0}&a shops" no-type-given: "&cUsage: /qs find " + no-amount-given: "cNo amount given. Use &a/qs refill &c" description: title: "&aQuickShop Help" unlimited: "&eMakes a shop unlimited" @@ -126,7 +127,7 @@ controlpanel: infomation: "&aShop Control Panel:" setowner: "&aOwner: &b{0} &e[&d&lChange&e]" setowner-hover: "&eLooking you want changing shop and click to switch owner." - unlimited: "&aUnlimited: {0} &e[&rSwitch&e]" + unlimited: "&aUnlimited: {0} &e[&d&lSwitch&e]" unlimited-hover: "&eLooking you want changing shop and click to switch enabled or disabled." mode-selling: "&aShop mode: &bSelling &e[&d&lSwitch&e]" mode-selling-hover: "&eLooking you want changing shop and click to switch enabled or disabled."