Skip to content

Commit

Permalink
- Make /ta town new [townname] bypass the proximity/claiming rules.
Browse files Browse the repository at this point in the history
    - Closes #7163.
  • Loading branch information
LlmDl committed Jan 4, 2024
1 parent 01c63d1 commit 6e4c0f2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Towny/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<artifactId>towny</artifactId>
<packaging>jar</packaging>
<version>0.100.0.18</version>
<version>0.100.0.19</version>

<licenses>
<license>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,20 @@ private void parseTownNewCommand(final Player player, String[] split) throws NoP
* @throws TownyException when a new town isn't allowed.
*/
public static void newTown(Player player, String name, Resident resident, boolean noCharge) throws TownyException {
newTown(player, name, resident, noCharge, false);
}

/**
* Create a new town. Command: /town new [townname] or /ta town new [townname]
*
* @param player Player using the command.
* @param name Name of town
* @param resident The resident in charge of the town.
* @param noCharge Charging for creation - /ta town new NAME MAYOR has no charge.
* @param adminCreated true when an admin has used /ta town new [NAME].
* @throws TownyException when a new town isn't allowed.
*/
public static void newTown(Player player, String name, Resident resident, boolean noCharge, boolean adminCreated) throws TownyException {
if (TownySettings.hasTownLimit() && TownyUniverse.getInstance().getTowns().size() >= TownySettings.getTownLimit())
throw new TownyException(Translatable.of("msg_err_universe_limit"));

Expand Down Expand Up @@ -2556,17 +2570,19 @@ public static void newTown(Player player, String name, Resident resident, boolea
if (!TownyAPI.getInstance().isWilderness(spawnLocation))
throw new TownyException(Translatable.of("msg_already_claimed_1", key));

// Check that a town isn't being formed inside of a biome that isn't allowed to be claimed.
if (TownySettings.isUnwantedBiomeClaimingEnabled() || TownySettings.isOceanClaimingBlocked()) {
List<WorldCoord> selection = Arrays.asList(WorldCoord.parseWorldCoord(spawnLocation));
selection = AreaSelectionUtil.filterOutUnwantedBiomeWorldCoords(player, selection);
selection = AreaSelectionUtil.filterOutOceanBiomeWorldCoords(player, selection);
if (selection.isEmpty())
throw new TownyException("msg_err_cannot_begin_town_in_this_biome");
if (!adminCreated) {
// Check that a town isn't being formed inside of a biome that isn't allowed to be claimed.
if (TownySettings.isUnwantedBiomeClaimingEnabled() || TownySettings.isOceanClaimingBlocked()) {
List<WorldCoord> selection = Arrays.asList(WorldCoord.parseWorldCoord(spawnLocation));
selection = AreaSelectionUtil.filterOutUnwantedBiomeWorldCoords(player, selection);
selection = AreaSelectionUtil.filterOutOceanBiomeWorldCoords(player, selection);
if (selection.isEmpty())
throw new TownyException("msg_err_cannot_begin_town_in_this_biome");
}

ProximityUtil.allowTownHomeBlockOrThrow(world, key, null, true);
}

ProximityUtil.allowTownHomeBlockOrThrow(world, key, null, true);

// If the town doesn't cost money to create, just make the Town.
if (noCharge || !TownyEconomyHandler.isActive()) {
BukkitTools.ifCancelledThenThrow(new PreNewTownEvent(player, name, spawnLocation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ private void parseAdminNewTownCommand(CommandSender sender, String[] split) thro
throw new TownyException(Translatable.of("msg_player_is_not_online", split[2]));
player = resident.getPlayer();
}
TownCommand.newTown(player, split[1], resident, true);
TownCommand.newTown(player, split[1], resident, true, true);
}

private void parseAdminTownSet(CommandSender sender, Town town, String[] split) throws TownyException {
Expand Down
5 changes: 4 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9376,4 +9376,7 @@ v0.92.0.11:
- If true, towns which have one or more bank plots will no longer be able to use their homeblock for withdraw/depositing.
- Requires the above is_banking_limited_to_bank_plots to be true as well.
- Fix plots not losing their trusted residents when the owner of the plot changes.
- Closes #7161.
- Closes #7161.
0.100.0.19:
- Make /ta town new [townname] bypass the proximity/claiming rules.
- Closes #7163.

0 comments on commit 6e4c0f2

Please sign in to comment.