From 4a62044a82f6ca4941f3e58bbd477b464c0caf65 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Thu, 2 Aug 2018 19:54:11 +0800 Subject: [PATCH] add bypass-owner-check in config.yml Former-commit-id: 0e31cabf3169ee3a92cedec1e416aadd69e5732a --- .../org/maxgamer/quickshop/Shop/ShopManager.java | 12 ++++++++++-- src/main/resources/config.yml | 5 ++++- src/main/resources/messages.yml | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 382004410..bd5877d6e 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -30,7 +30,7 @@ import org.maxgamer.quickshop.Util.Permissions; import org.maxgamer.quickshop.Util.Util; public class ShopManager { - private QuickShop plugin; + QuickShop plugin = QuickShop.instance; private HashMap actions = new HashMap(); private HashMap>> shops = new HashMap>>(); final private static ItemStack AIR = new ItemStack(Material.AIR); @@ -562,10 +562,13 @@ public class ShopManager { if (e.isCancelled()) return; // Cancelled // Money handling - if (!p.getUniqueId().equals(shop.getOwner())) { + if (!p.getUniqueId().equals(shop.getOwner()) || plugin.getConfig().getBoolean("shop.bypass-owner-check")) { // Don't tax them if they're purchasing from // themselves. // Do charge an amount of tax though. + + //Add a warning + double tax = plugin.getConfig().getDouble("tax"); double total = amount * shop.getPrice(); if (!shop.isUnlimited() || plugin.getConfig().getBoolean("shop.pay-unlimited-shop-owners")) { @@ -601,6 +604,11 @@ public class ShopManager { 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); + }else { + if(p.getUniqueId().equals(shop.getOwner()) && !plugin.getConfig().getBoolean("shop.bypass-owner-check")) { + p.sendMessage(MsgUtil.getMessage("owner-bypass-check")); + //Bypass check message + } } shop.buy(p, amount); MsgUtil.sendSellSuccess(p, shop, amount); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 886359e9e..9df242ac7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -76,6 +76,9 @@ shop: #If you buy from YOUR unlimited shop, you will NEVER be charged $$, regardless of this setting pay-unlimited-shop-owners: false + #Still discounts money when shop's owner tradeing with himself shop... + bypass-owner-check: false + #Should we place display items on the chests? This may cause duped items, especially for modded servers. display-items: true @@ -89,7 +92,7 @@ shop: #List of items to disallow selling of. Anyone with quickshop.bypass. can bypass it blacklist: -- 7 #Bedrock +- Bedrock #List of items with restricted prices. Format: ;; diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 1134e4e24..c732e73ee 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -42,6 +42,7 @@ refill-success: "&aRefill success" empty-success: "&aEmpty success" admin-shop: "AdminShop" unknown-owner: "Unknown" +owner-bypass-check: "&eBypass all check,Trade successful! (You are shop owner)" menu: successful-purchase: "&aSuccessfully Purchased:"