Skip to content

Commit

Permalink
- New Config Option: plugin.day_timer.delete_0_plot_towns
Browse files Browse the repository at this point in the history
    - Default: false
    - Whether towns with no claimed townblocks should be deleted when
the new day is run.
    - Closes #3746.
  • Loading branch information
LlmDl committed Apr 10, 2020
1 parent 2c54a6f commit ff59ad7
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 15 deletions.
6 changes: 5 additions & 1 deletion resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4451,4 +4451,8 @@ v0.92.0.11:
- Do not set this value to an amount less than the global_town_settings.required_number_residents_join_nation.
- Do not set this value to an amount less than the global_town_settings.required_number_residents_create_nation.
- This will not remove residents from nation-less towns that are already above the limit, they will not be able to invite more.
- Closes #3720.
- Closes #3720.
- New Config Option: plugin.day_timer.delete_0_plot_towns
- Default: false
- Whether towns with no claimed townblocks should be deleted when the new day is run.
- Closes #3746.
3 changes: 2 additions & 1 deletion resources/chinese.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1113,4 +1113,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/es-mx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1100,4 +1100,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/french.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1113,4 +1113,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/german.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1115,4 +1115,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/italian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1114,4 +1114,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/korean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1025,4 +1025,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/norwegian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/polish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/pt-br.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1116,4 +1116,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/russian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/spanish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
3 changes: 2 additions & 1 deletion resources/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1111,4 +1111,5 @@ msg_cache_block_error_plot_outsiders: 'outsiders'
msg_cache_block_error_plot_town_members: 'town members'
msg_err_invalid_nation_map_color: '&cUnknown map color. Allowed colors are %s.'
msg_nation_map_color_changed: '&bThe nation map color was changed to %s.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_err_unable_to_add_more_residents_without_nation: 'Your town cannot invite more than %s residents without first joining or creating a nation.'
msg_the_following_towns_were_deleted_for_having_0_claims: 'The following towns were deleted for having 0 claims: %s'
5 changes: 4 additions & 1 deletion src/com/palmergames/bukkit/config/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,10 @@ public enum ConfigNodes {
"12h",
"# The time each \"day\", when taxes will be collected.",
"# MUST be less than day_interval. Default is 12h (midday)."),

PLUGIN_NEWDAY_DELETE_0_PLOT_TOWNS(
"plugin.day_timer.delete_0_plot_towns",
"false",
"# Whether towns with no claimed townblocks should be deleted when the new day is run."),
PLUGIN_DEBUG_MODE(
"plugin.debug_mode",
"false",
Expand Down
4 changes: 4 additions & 0 deletions src/com/palmergames/bukkit/towny/TownySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,10 @@ public static long getNewDayTime() {
}
return time;
}

public static boolean isNewDayDeleting0PlotTowns() {
return getBoolean(ConfigNodes.PLUGIN_NEWDAY_DELETE_0_PLOT_TOWNS);
}

public static SpawnLevel isAllowingTownSpawn() {

Expand Down
12 changes: 12 additions & 0 deletions src/com/palmergames/bukkit/towny/tasks/DailyTimerTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ public void run() {
new ResidentPurge(plugin, null, TownySettings.getDeleteTime() * 1000, TownySettings.isDeleteTownlessOnly()).start();
}

if (TownySettings.isNewDayDeleting0PlotTowns()) {
List<String> deletedTowns = new ArrayList<>();
for (Town town : TownyUniverse.getInstance().getTownsMap().values()) {
if (town.getTownBlocks().size() == 0) {
deletedTowns.add(town.getName());
TownyUniverse.getInstance().getDataSource().removeTown(town);
}
}
if (!deletedTowns.isEmpty())
TownyMessaging.sendGlobalMessage(String.format(TownySettings.getLangString("msg_the_following_towns_were_deleted_for_having_0_claims"), String.join(", ", deletedTowns)));
}

TownyUniverse townyUniverse = TownyUniverse.getInstance();

// Reduce jailed residents jail time
Expand Down

0 comments on commit ff59ad7

Please sign in to comment.