From a0768cdf7aa65239705261023dd0c2a21ca2c3e2 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Thu, 8 Oct 2015 22:20:14 +0800 Subject: [PATCH] add new SuperItem Action... Signed-off-by: j502647092 --- .../QuickShop/Listeners/PlayerListener.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/QuickShop/Listeners/PlayerListener.java b/src/main/java/org/maxgamer/QuickShop/Listeners/PlayerListener.java index 00b18c4..ac4ca95 100644 --- a/src/main/java/org/maxgamer/QuickShop/Listeners/PlayerListener.java +++ b/src/main/java/org/maxgamer/QuickShop/Listeners/PlayerListener.java @@ -23,6 +23,7 @@ import org.maxgamer.QuickShop.QuickShop; import org.maxgamer.QuickShop.Shop.Info; import org.maxgamer.QuickShop.Shop.Shop; import org.maxgamer.QuickShop.Shop.ShopAction; +import org.maxgamer.QuickShop.Shop.ShopType; import org.maxgamer.QuickShop.Util.MsgUtil; import org.maxgamer.QuickShop.Util.Util; @@ -171,10 +172,24 @@ public class PlayerListener implements Listener { final Block attached = Util.getAttached(b); final Shop shop = attached == null ? null : plugin.getShopManager().getShop(attached.getLocation()); if (shop != null) { - if (e.getAction() == Action.RIGHT_CLICK_BLOCK && p.hasPermission("quickshop.unlimited")) { - shop.setUnlimited(!shop.isUnlimited()); + if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { + if (p.hasPermission("quickshop.unlimited") && p.getGameMode() == GameMode.CREATIVE) { + shop.setUnlimited(!shop.isUnlimited()); + p.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "无限模式" : "有限模式"))); + return; + } else if (p.getGameMode() == GameMode.SURVIVAL) { + if (shop.getShopType() == ShopType.BUYING && p.hasPermission("quickshop.create.sell")) { + shop.setShopType(ShopType.SELLING); + p.sendMessage(MsgUtil.p("command.now-selling", shop.getDataName())); + return; + } else if (shop.getShopType() == ShopType.SELLING && p.hasPermission("quickshop.create.buy")) { + shop.setShopType(ShopType.BUYING); + p.sendMessage(MsgUtil.p("command.now-buying", shop.getDataName())); + return; + } + } + shop.setSignText(); shop.update(); - p.sendMessage(MsgUtil.p("command.toggle-unlimited", (shop.isUnlimited() ? "无限模式" : "有限模式"))); } } }