diff --git a/com/Acrobot/ChestShop/ChestShop.java b/com/Acrobot/ChestShop/ChestShop.java index 8618c6a..7a10d91 100644 --- a/com/Acrobot/ChestShop/ChestShop.java +++ b/com/Acrobot/ChestShop/ChestShop.java @@ -31,6 +31,7 @@ import java.util.List; public class ChestShop extends JavaPlugin { public static final File folder = new File("plugins/ChestShop"); + public static final String chatPrefix = "[ChestShop] "; private static EbeanServer DB; private static PluginDescriptionFile description; diff --git a/com/Acrobot/ChestShop/Config/Property.java b/com/Acrobot/ChestShop/Config/Property.java index cf03f51..1ec3e72 100644 --- a/com/Acrobot/ChestShop/Config/Property.java +++ b/com/Acrobot/ChestShop/Config/Property.java @@ -6,6 +6,7 @@ package com.Acrobot.ChestShop.Config; public enum Property { PREFERRED_ECONOMY_PLUGIN("", "Preferred economy plugin (iConomy, BOSEconomy, Essentials). If you do not want to specify this, leave it blank."), REVERSE_BUTTONS(false, "If true, people will buy with left-click and sell with right-click."), + //ALLOW_LEFT_CLICK_DESTROYING(false, "If true, if you left-click your own shop sign you won't open chest's inventory, but instead you will start destroying the sign."), SERVER_ECONOMY_ACCOUNT("", "Economy account's name you want Admin Shops to be assigned to"), ADMIN_SHOP_NAME("Admin Shop", "First line of your admin shop should look like this"), SHOP_CREATION_PRICE(0, "Amount of money player must pay to create a shop"), diff --git a/com/Acrobot/ChestShop/Listeners/playerInteract.java b/com/Acrobot/ChestShop/Listeners/playerInteract.java index 21bd9fd..1a8acb9 100644 --- a/com/Acrobot/ChestShop/Listeners/playerInteract.java +++ b/com/Acrobot/ChestShop/Listeners/playerInteract.java @@ -4,7 +4,7 @@ import com.Acrobot.ChestShop.Config.Config; import com.Acrobot.ChestShop.Config.Language; import com.Acrobot.ChestShop.Config.Property; import com.Acrobot.ChestShop.Permission; -import com.Acrobot.ChestShop.Protection.Default; +import com.Acrobot.ChestShop.Protection.Plugins.Default; import com.Acrobot.ChestShop.Shop.ShopManagement; import com.Acrobot.ChestShop.Signs.restrictedSign; import com.Acrobot.ChestShop.Utils.uBlock; diff --git a/com/Acrobot/ChestShop/Listeners/pluginEnable.java b/com/Acrobot/ChestShop/Listeners/pluginEnable.java index c077c44..d74b644 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginEnable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginEnable.java @@ -5,8 +5,9 @@ import com.Acrobot.ChestShop.Config.Config; import com.Acrobot.ChestShop.Economy; import com.Acrobot.ChestShop.Items.Odd; import com.Acrobot.ChestShop.Permission; -import com.Acrobot.ChestShop.Protection.LWCplugin; -import com.Acrobot.ChestShop.Protection.LockettePlugin; +import com.Acrobot.ChestShop.Protection.Plugins.LWCplugin; +import com.Acrobot.ChestShop.Protection.Plugins.LockettePlugin; +import com.Acrobot.ChestShop.Protection.Plugins.OldLockettePlugin; import com.Acrobot.ChestShop.Protection.Security; import com.griefcraft.lwc.LWCPlugin; import com.nijikokun.bukkit.Permissions.Permissions; @@ -28,7 +29,6 @@ import java.util.List; public class pluginEnable extends ServerListener { public static final Methods methods = new Methods(Config.getPreferred()); - private static final String lineStart = "[ChestShop] "; private static final List pluginsToLoad = new LinkedList(Arrays.asList( "Permissions", @@ -44,7 +44,7 @@ public class pluginEnable extends ServerListener { if (!methods.hasMethod()) { if (methods.setMethod(event.getPlugin())) { Economy.economy = methods.getMethod(); - System.out.println(lineStart + Economy.economy.getName() + ' ' + Economy.economy.getVersion() + " loaded."); + System.out.println(ChestShop.chatPrefix + Economy.economy.getName() + ' ' + Economy.economy.getVersion() + " loaded."); } } @@ -68,13 +68,18 @@ public class pluginEnable extends ServerListener { LWCplugin.setLWC(((LWCPlugin) plugin).getLWC()); Security.protection = new LWCplugin(); } else if (name.equals("Lockette")) { - if (LockettePlugin.lockette != null) return; - LockettePlugin.lockette = (Lockette) plugin; - Security.protection = new LockettePlugin(); + if (OldLockettePlugin.lockette != null || LockettePlugin.lockette != null) return; + if (plugin.getClass().getName().equals("com.daemitus.lockette.Lockette")) { + LockettePlugin.lockette = (com.daemitus.lockette.Lockette) plugin; + Security.protection = new LockettePlugin(); + } else { + OldLockettePlugin.lockette = (Lockette) plugin; + Security.protection = new OldLockettePlugin(); + } } else if (name.equals("OddItem")) { if (Odd.oddItem != null) return; Odd.oddItem = (OddItem) plugin; } - System.out.println(lineStart + description.getName() + " version " + description.getVersion() + " loaded."); + System.out.println(ChestShop.chatPrefix + description.getName() + " version " + description.getVersion() + " loaded."); } } diff --git a/com/Acrobot/ChestShop/Listeners/signChange.java b/com/Acrobot/ChestShop/Listeners/signChange.java index 32726ad..de8ee49 100644 --- a/com/Acrobot/ChestShop/Listeners/signChange.java +++ b/com/Acrobot/ChestShop/Listeners/signChange.java @@ -6,7 +6,7 @@ import com.Acrobot.ChestShop.Config.Property; import com.Acrobot.ChestShop.Economy; import com.Acrobot.ChestShop.Items.Items; import com.Acrobot.ChestShop.Permission; -import com.Acrobot.ChestShop.Protection.Default; +import com.Acrobot.ChestShop.Protection.Plugins.Default; import com.Acrobot.ChestShop.Protection.Security; import com.Acrobot.ChestShop.Signs.restrictedSign; import com.Acrobot.ChestShop.Utils.uBlock; diff --git a/com/Acrobot/ChestShop/Protection/Default.java b/com/Acrobot/ChestShop/Protection/Plugins/Default.java similarity index 92% rename from com/Acrobot/ChestShop/Protection/Default.java rename to com/Acrobot/ChestShop/Protection/Plugins/Default.java index 084bdd5..9bcefa0 100644 --- a/com/Acrobot/ChestShop/Protection/Default.java +++ b/com/Acrobot/ChestShop/Protection/Plugins/Default.java @@ -1,5 +1,6 @@ -package com.Acrobot.ChestShop.Protection; +package com.Acrobot.ChestShop.Protection.Plugins; +import com.Acrobot.ChestShop.Protection.Protection; import com.Acrobot.ChestShop.Utils.uBlock; import com.Acrobot.ChestShop.Utils.uLongName; import org.bukkit.block.Block; diff --git a/com/Acrobot/ChestShop/Protection/LWCplugin.java b/com/Acrobot/ChestShop/Protection/Plugins/LWCplugin.java similarity index 73% rename from com/Acrobot/ChestShop/Protection/LWCplugin.java rename to com/Acrobot/ChestShop/Protection/Plugins/LWCplugin.java index 52d31f5..c92514d 100644 --- a/com/Acrobot/ChestShop/Protection/LWCplugin.java +++ b/com/Acrobot/ChestShop/Protection/Plugins/LWCplugin.java @@ -1,6 +1,7 @@ -package com.Acrobot.ChestShop.Protection; +package com.Acrobot.ChestShop.Protection.Plugins; import com.Acrobot.ChestShop.ChestShop; +import com.Acrobot.ChestShop.Protection.Protection; import com.griefcraft.lwc.LWC; import com.griefcraft.model.ProtectionTypes; import com.griefcraft.modules.limits.LimitsModule; @@ -16,10 +17,11 @@ public class LWCplugin implements Protection { private static LimitsModule limitsModule; - public static void setLWC(LWC LWC){ + public static void setLWC(LWC LWC) { lwc = LWC; limitsModule = new LimitsModule(); } + public boolean isProtected(Block block) { return lwc.findProtection(block) != null; } @@ -31,7 +33,12 @@ public class LWCplugin implements Protection { public boolean protect(String name, Block block) { if (lwc.findProtection(block) != null) return false; Player player = ChestShop.getBukkitServer().getPlayer(name); - if (player != null && lwc.getPhysicalDatabase().getProtectionCount(name) >= limitsModule.mapProtectionLimit(player, block.getTypeId())) return false; + try { + if (player != null && limitsModule.hasReachedLimit(player, block)) return false; + } catch (NoSuchMethodError e) { + System.out.println(ChestShop.chatPrefix + "Your LWC plugin is outdated!"); + } + lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), ProtectionTypes.PRIVATE, block.getWorld().getName(), name, "", block.getX(), block.getY(), block.getZ()); return true; } diff --git a/com/Acrobot/ChestShop/Protection/LockettePlugin.java b/com/Acrobot/ChestShop/Protection/Plugins/LockettePlugin.java similarity index 77% rename from com/Acrobot/ChestShop/Protection/LockettePlugin.java rename to com/Acrobot/ChestShop/Protection/Plugins/LockettePlugin.java index caf2032..962093a 100644 --- a/com/Acrobot/ChestShop/Protection/LockettePlugin.java +++ b/com/Acrobot/ChestShop/Protection/Plugins/LockettePlugin.java @@ -1,8 +1,9 @@ -package com.Acrobot.ChestShop.Protection; +package com.Acrobot.ChestShop.Protection.Plugins; +import com.Acrobot.ChestShop.Protection.Protection; +import com.daemitus.lockette.Lockette; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.yi.acru.bukkit.Lockette.Lockette; /** * @author Acrobot @@ -16,7 +17,7 @@ public class LockettePlugin implements Protection { public boolean canAccess(Player player, Block block) { int length = (player.getName().length() > 15? 15 : player.getName().length()); - return player.getName().substring(0, length).equals(Lockette.getProtectedOwner(block)); + return player.getName().substring(0, length).equals(Lockette.getOwnerName(block)); } public boolean protect(String name, Block block) { diff --git a/com/Acrobot/ChestShop/Protection/Plugins/OldLockettePlugin.java b/com/Acrobot/ChestShop/Protection/Plugins/OldLockettePlugin.java new file mode 100644 index 0000000..be4540e --- /dev/null +++ b/com/Acrobot/ChestShop/Protection/Plugins/OldLockettePlugin.java @@ -0,0 +1,26 @@ +package com.Acrobot.ChestShop.Protection.Plugins; + +import com.Acrobot.ChestShop.Protection.Protection; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.yi.acru.bukkit.Lockette.Lockette; + +/** + * @author Acrobot + */ +public class OldLockettePlugin implements Protection { + public static Lockette lockette; + + public boolean isProtected(Block block) { + return Lockette.isProtected(block); + } + + public boolean canAccess(Player player, Block block) { + int length = (player.getName().length() > 15? 15 : player.getName().length()); + return player.getName().substring(0, length).equals(Lockette.getProtectedOwner(block)); + } + + public boolean protect(String name, Block block) { + return false; + } +} diff --git a/com/Acrobot/ChestShop/Protection/Security.java b/com/Acrobot/ChestShop/Protection/Security.java index c00448e..4444102 100644 --- a/com/Acrobot/ChestShop/Protection/Security.java +++ b/com/Acrobot/ChestShop/Protection/Security.java @@ -1,5 +1,6 @@ package com.Acrobot.ChestShop.Protection; +import com.Acrobot.ChestShop.Protection.Plugins.Default; import com.Acrobot.ChestShop.Utils.uBlock; import com.Acrobot.ChestShop.Utils.uLongName; import org.bukkit.block.Block; diff --git a/plugin.yml b/plugin.yml index 20c9109..421eae8 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: ChestShop main: com.Acrobot.ChestShop.ChestShop -version: 3.03 +version: 3.04 author: Acrobot