Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added minimal claim distance from other town plots. #125

Closed
wants to merge 1 commit into from

2 participants

@coaster3000

No description provided.

@coaster3000

DO NOT PULL Needs fixing. Turns out reason the stuff been working on my server is that one of my staff edited it.. I need to apply the fixes to this specific branch.

...com/palmergames/bukkit/towny/command/TownCommand.java
@@ -1888,6 +1892,10 @@ public static void parseTownClaimCommand(Player player, String[] split) {
selection = AreaSelectionUtil.selectWorldCoordArea(town, new WorldCoord(world.getName(), key), split);
blockCost = TownySettings.getClaimPrice();
}
+
+ if ((world.getMinDistanceFromOtherTownsPlots(key) < TownySettings.getMinDistanceFromTownPlotblocks()))

This is missing the town parameter causing the bug.

When I am not busy I will edit this real quick and force push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@coaster3000

I repaired the build. It is now safe to use.

@ElgarL
Owner

Manually merged

@ElgarL ElgarL closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -0,0 +1 @@
+bin/
View
6 src/com/palmergames/bukkit/config/ConfigNodes.java
@@ -135,6 +135,12 @@
"town.town_limit",
"3000",
"# Maximum number of towns allowed on the server."),
+ TOWN_MIN_PLOT_DISTANCE_FROM_TOWN_PLOT(
+ "town.min_plot_distance_from_town_plot",
+ "5",
+ "",
+ "# Minimum number of plots any towns plot must be from the next town's own plots.",
+ "# This will prevent town encasement to a certain degree."),
TOWN_MIN_DISTANCE_FROM_TOWN_HOMEBLOCK(
"town.min_distance_from_town_homeblock",
"5",
View
6 src/com/palmergames/bukkit/towny/TownySettings.java
@@ -1542,7 +1542,11 @@ public static int getMinDistanceFromTownHomeblocks() {
return getInt(ConfigNodes.TOWN_MIN_DISTANCE_FROM_TOWN_HOMEBLOCK);
}
-
+
+ public static int getMinDistanceFromTownPlotblocks() {
+ return getInt(ConfigNodes.TOWN_MIN_PLOT_DISTANCE_FROM_TOWN_PLOT);
+ }
+
public static int getMaxDistanceBetweenHomeblocks() {
return getInt(ConfigNodes.TOWN_MAX_DISTANCE_BETWEEN_HOMEBLOCKS);
View
8 src/com/palmergames/bukkit/towny/command/TownCommand.java
@@ -1051,6 +1051,9 @@ public void newTown(Player player, String name, String mayorName) {
if (world.getMinDistanceFromOtherTowns(key) < TownySettings.getMinDistanceFromTownHomeblocks())
throw new TownyException(TownySettings.getLangString("msg_too_close"));
+ if ((world.getMinDistanceFromOtherTownsPlots(key) < TownySettings.getMinDistanceFromTownPlotblocks()))
+ throw new TownyException(TownySettings.getLangString("msg_too_close"));
+
if (TownySettings.getMaxDistanceBetweenHomeblocks() > 0)
if ((world.getMinDistanceFromOtherTowns(key) > TownySettings.getMaxDistanceBetweenHomeblocks()) && world.hasTowns())
throw new TownyException(TownySettings.getLangString("msg_too_far"));
@@ -1866,6 +1869,7 @@ public static void parseTownClaimCommand(Player player, String[] split) {
if (!TownyUniverse.getPermissionSource().isTownyAdmin(player) && maxOutposts != -1 &&(maxOutposts <= resident.getTown().getAllOutpostSpawns().size()))
throw new TownyException(String.format(TownySettings.getLangString("msg_max_outposts_own"), maxOutposts));
+
if (TownySettings.isAllowingOutposts()) {
if (world.hasTownBlock(key))
@@ -1888,6 +1892,10 @@ public static void parseTownClaimCommand(Player player, String[] split) {
selection = AreaSelectionUtil.selectWorldCoordArea(town, new WorldCoord(world.getName(), key), split);
blockCost = TownySettings.getClaimPrice();
}
+
+ if ((world.getMinDistanceFromOtherTownsPlots(key, town) < TownySettings.getMinDistanceFromTownPlotblocks()))
+ throw new TownyException(TownySettings.getLangString("msg_too_close"));
+
TownyMessaging.sendDebugMsg("townClaim: Pre-Filter Selection " + Arrays.toString(selection.toArray(new WorldCoord[0])));
selection = AreaSelectionUtil.filterTownOwnedBlocks(selection);
View
36 src/com/palmergames/bukkit/towny/object/TownyWorld.java
@@ -640,6 +640,42 @@ public int getMinDistanceFromOtherTowns(Coord key, Town homeTown) {
return (int) Math.ceil(min);
}
+
+ /**
+ * Checks the distance from the closest town block.
+ *
+ * @param key
+ * @return the distance to nearest towns townblock.
+ */
+ public int getMinDistanceFromOtherTownsPlots(Coord key) {
+ return getMinDistanceFromOtherTownsPlots(key, null);
+ }
+
+ /**
+ * Checks the distance from a another town's plots.
+ *
+ * @param key
+ * @param homeTown Players town
+ * @return the closest distance to another towns nearest plot.
+ */
+ public int getMinDistanceFromOtherTownsPlots(Coord key, Town homeTown) {
+ double min = Integer.MAX_VALUE;
+ for (Town town : getTowns())
+ try {
+ if (homeTown != null)
+ if (homeTown.getHomeBlock().equals(town.getHomeBlock()))
+ continue;
+ for (TownBlock b : town.getTownBlocks()) {
+ Coord townCoord = b.getCoord();
+ double dist = Math.sqrt(Math.pow(townCoord.getX() - key.getX(), 2) + Math.pow(townCoord.getZ() - key.getZ(), 2));
+ if (dist < min)
+ min = dist;
+ }
+ } catch (TownyException e) {
+ }
+
+ return (int) Math.ceil(min);
+ }
public void addWarZone(Coord coord) {
Something went wrong with that request. Please try again.