Skip to content

Commit

Permalink
Fix exception when putting a group for sale with eco off (TownyAdvanc…
Browse files Browse the repository at this point in the history
…ed#6970)

* Fix exception when putting a group for sale with eco off

* Redundant isActive check
  • Loading branch information
Warriorrrr authored and jwkerr committed Oct 9, 2023
1 parent 3342b19 commit e64feaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1311,18 +1311,21 @@ public void parsePlotGroupForSale(String[] split, Resident resident, TownBlock t
checkPermOrThrow(player, PermissionNodes.TOWNY_COMMAND_PLOT_GROUP_FORSALE.getNode());

// This means the player wants to fs the plot group they are in.
if (split.length < 2)
if (split.length < 2 && TownyEconomyHandler.isActive())
throw new TownyException(Translatable.of("msg_err_plot_group_specify_price"));

PlotGroup group = catchMissingPlotGroup(townBlock);

double price = MoneyUtil.getMoneyAboveZeroOrThrow(split[1]);
double price = split.length >= 2 ? MoneyUtil.getMoneyAboveZeroOrThrow(split[1]) : 0;
group.setPrice(Math.min(price, TownySettings.getMaxPlotPrice()));

// Save
group.save();

Translatable message = Translatable.of("msg_player_put_group_up_for_sale", player.getName(), group.getName(), TownyEconomyHandler.getFormattedBalance(group.getPrice()));
Translatable message = TownyEconomyHandler.isActive()
? Translatable.of("msg_player_put_group_up_for_sale_amount", player.getName(), group.getName(), TownyEconomyHandler.getFormattedBalance(group.getPrice()))
: Translatable.of("msg_player_put_group_up_for_sale", player.getName(), group.getName());

TownyMessaging.sendPrefixedTownMessage(town, message);

if (!resident.hasTown() || resident.getTownOrNull() != town)
Expand Down
3 changes: 2 additions & 1 deletion Towny/src/main/resources/lang/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,8 @@ msg_err_plot_not_associated_with_a_group: 'This plot is not associated with a gr
msg_plot_was_removed_from_group_x: 'Plot &9(%s,%s) &2was removed from group %s'
msg_plot_renamed_from_x_to_y: 'Plot %s has been renamed to %s.'
msg_err_plot_group_specify_price: 'Please specify the price, ex: /plot group fs [price]'
msg_player_put_group_up_for_sale: '%s put group %s up for sale for %s'
msg_player_put_group_up_for_sale_amount: '%s put group %s up for sale for %s!'
msg_player_put_group_up_for_sale: '%s put group %s up for sale!'
msg_err_could_not_set_group_type: 'Could not set group type - '
msg_set_group_type_to_x: 'Changed plot group''s type to %s'
msg_player_successfully_bought_group_x: '%s successfully bought plot group %s'
Expand Down

0 comments on commit e64feaa

Please sign in to comment.