mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-27 14:13:05 +02:00
Remove Towny integration in favour of a stand-alone module
This commit is contained in:
parent
7b8396a3ef
commit
46d09ded82
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user