From 675613c0f87a0cf323860a022397caf76c961b47 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Wed, 21 Nov 2018 11:42:50 +0800 Subject: [PATCH] add back old-algorithm and can make user switch to it. Former-commit-id: 728d028cb85b9560557f07be510453135821018f [formerly f86514c80aac345056bbecdf0f3d584dcab604a5] Former-commit-id: 4578b0ede4abcdaff20b21fc18d2082f60f468fc --- .../maxgamer/quickshop/Shop/ShopManager.java | 27 +++++++++++-------- src/main/resources/config.yml | 5 +++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 12226c493..268bc3d9b 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -251,23 +251,28 @@ public class ShopManager { } } + if (plugin.limit) { int owned = 0; - for (HashMap> shopmap : getShops().values()) { - for (HashMap shopLocs : shopmap.values()) { - for (Shop shop : shopLocs.values()) { - if (shop.getOwner().equals(p.getUniqueId())&&shop.isUnlimited()) { - owned++; + if (!plugin.getConfig().getBoolean("limits.old-algorithm")) { + for (HashMap> shopmap : getShops().values()) { + for (HashMap shopLocs : shopmap.values()) { + for (Shop shop : shopLocs.values()) { + if (shop.getOwner().equals(p.getUniqueId())&&shop.isUnlimited()) { + owned++; + } } } } + }else { + Iterator it = getShopIterator(); + while (it.hasNext()) { + if (it.next().getOwner().equals(p.getUniqueId())) { + owned++; + } + } } -// Iterator it = getShopIterator(); -// while (it.hasNext()) { -// if (it.next().getOwner().equals(p.getUniqueId())) { -// owned++; -// } -// } + int max = plugin.getShopLimit(p); if (owned + 1 > max) { //p.sendMessage(ChatColor.RED + "You have already created a maximum of " + owned + "/" + max + " shops!"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9385d160f..5b64c67c2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -53,6 +53,9 @@ limits: #The default number of shops players can make default: 10 + #Use old algorithm to calc unlimited shops into limits. + old-algorithm: false + #Players with these permissions can create these amounts of shops. ranks: #Anyone with 'quickshop.vip' permissions, can create 20 shops instead of 10. @@ -194,7 +197,7 @@ float: list: - Super Sword(Can't float) #add keywords in there, plugin will check it contain or not on items. -# Ongoing Fee +# Ongoing Fee TODO ongoingfee: enable: false # CheckTime unit is tick (1 seconds = 20 ticks) Do not set low than 600!