From 46d09ded82efe3a2aa70c37c04e3f1a05ee6e7e8 Mon Sep 17 00:00:00 2001 From: Acrobot Date: Fri, 4 Oct 2013 18:40:40 +0200 Subject: [PATCH] Remove Towny integration in favour of a stand-alone module --- .../ChestShop/Configuration/Properties.java | 7 -- .../com/Acrobot/ChestShop/Dependencies.java | 11 -- .../com/Acrobot/ChestShop/Plugins/Towny.java | 112 ------------------ src/main/resources/plugin.yml | 2 +- 4 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 src/main/java/com/Acrobot/ChestShop/Plugins/Towny.java diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index 2b5d8e0..9bd0971 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -133,13 +133,6 @@ public class Properties { @ConfigurationComment("How often should the website be generated?") public static long STATISTICS_PAGE_GENERATION_INTERVAL = 60; - @PrecededBySpace - @ConfigurationComment("Do you want to only let people build inside shop plots?") - public static boolean TOWNY_INTEGRATION = false; - - @ConfigurationComment("If true, only plot owners are able to build inside a shop plot. If false, every town's resident is able to build there.") - public static boolean TOWNY_SHOPS_FOR_OWNERS_ONLY = true; - @PrecededBySpace @ConfigurationComment("Do you want to only let people build inside regions?") public static boolean WORLDGUARD_INTEGRATION = false; diff --git a/src/main/java/com/Acrobot/ChestShop/Dependencies.java b/src/main/java/com/Acrobot/ChestShop/Dependencies.java index 8a98884..821daa8 100644 --- a/src/main/java/com/Acrobot/ChestShop/Dependencies.java +++ b/src/main/java/com/Acrobot/ChestShop/Dependencies.java @@ -77,16 +77,6 @@ public class Dependencies { break; //Terrain protection plugins - case Towny: - Towny towny = Towny.getTowny(); - - if (towny == null || !Properties.TOWNY_INTEGRATION) { - return; - } - - listener = towny; - - break; case WorldGuard: WorldGuardPlugin worldGuard = (WorldGuardPlugin) plugin; boolean inUse = Properties.WORLDGUARD_USE_PROTECTION || Properties.WORLDGUARD_INTEGRATION; @@ -137,7 +127,6 @@ public class Dependencies { OddItem, - Towny, WorldGuard, Heroes diff --git a/src/main/java/com/Acrobot/ChestShop/Plugins/Towny.java b/src/main/java/com/Acrobot/ChestShop/Plugins/Towny.java deleted file mode 100644 index b0559aa..0000000 --- a/src/main/java/com/Acrobot/ChestShop/Plugins/Towny.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.Acrobot.ChestShop.Plugins; - -import com.Acrobot.ChestShop.Configuration.Properties; -import com.Acrobot.ChestShop.Events.Protection.BuildPermissionEvent; -import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; -import com.palmergames.bukkit.towny.object.TownBlockOwner; -import com.palmergames.bukkit.towny.object.TownBlockType; -import com.palmergames.bukkit.towny.object.TownyUniverse; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -/** - * @author Acrobot - */ -public class Towny implements Listener { - - @EventHandler - public static void canBuild(BuildPermissionEvent event) { - Location chest = event.getChest(); - Location sign = event.getSign(); - - if (isInWilderness(chest, sign) || !isInsideShopPlot(chest, sign)) { - event.disallow(); - return; - } - - boolean allow; - - if (Properties.TOWNY_SHOPS_FOR_OWNERS_ONLY) { - allow = isPlotOwner(event.getPlayer(), chest, sign); - } else { - allow = isResident(event.getPlayer(), chest, sign); - } - - event.allow(allow); - } - - private static boolean isResident(Player player, Location location) throws NotRegisteredException { - return TownyUniverse.getTownBlock(location).getTown().hasResident(player.getName()); - } - - private static boolean isResident(Player player, Location... locations) { - try { - for (Location location : locations) { - if (!isResident(player, location)) { - return false; - } - } - } catch (NotRegisteredException exception) { - return false; - } - - return true; - } - - private static boolean isPlotOwner(Player player, Location location) throws NotRegisteredException { - TownBlockOwner owner = TownyUniverse.getDataSource().getResident(player.getName()); - return TownyUniverse.getTownBlock(location).isOwner(owner); - } - - private static boolean isPlotOwner(Player player, Location... locations) { - try { - for (Location location : locations) { - if (!isPlotOwner(player, location)) { - return false; - } - } - } catch (NotRegisteredException exception) { - return false; - } - - return true; - } - - private static boolean isInsideShopPlot(Location location) { - return TownyUniverse.getTownBlock(location).getType() == TownBlockType.COMMERCIAL; - } - - private static boolean isInsideShopPlot(Location... locations) { - for (Location location : locations) { - if (location != null && !isInsideShopPlot(location)) { - return false; - } - } - - return true; - } - - private static boolean isInWilderness(Location location) { - return TownyUniverse.isWilderness(location.getBlock()); - } - - private static boolean isInWilderness(Location... locations) { - for (Location location : locations) { - if (location != null && !isInWilderness(location)) { - return false; - } - } - - return true; - } - - public static Towny getTowny() { - if (!Properties.TOWNY_INTEGRATION) { - return null; - } - - return new Towny(); - } -} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c3153cd..da8e989 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -13,7 +13,7 @@ description: > A chest shop for economy plugins. -softdepend: [LWC, Lockette, Deadbolt, OddItem, Towny, WorldGuard, Vault, Heroes, +softdepend: [LWC, Lockette, Deadbolt, OddItem, WorldGuard, Vault, Heroes, iConomy, BOSEconomy, SimpleChestLock, Residence] commands: iteminfo: