Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only apply the outsiders prevent pvp toggle when enabling pvp. #5560

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/com/palmergames/bukkit/config/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ public enum ConfigNodes {
"global_town_settings.outsiders_prevent_pvp_toggle",
"false",
"",
"# If set to true, Towny will prevent a town or plot from toggling PVP while an outsider is within the town's or plot's boundaries.",
"# If set to true, Towny will prevent a town or plot from enabling PVP while an outsider is within the town's or plot's boundaries.",
"# When active this feature can cause a bit of lag when the /t toggle pvp command is used, depending on how many players are online."
),
GTOWN_SETTINGS_HOMEBLOCKS_PREVENT_FORCEPVP(
Expand Down
4 changes: 2 additions & 2 deletions src/com/palmergames/bukkit/towny/command/PlotCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ public void plotToggle(Player player, TownBlock townBlock, String[] split) {
if (town.isAdminEnabledPVP() && townBlock.getPermissions().pvp)
throw new TownyException(Translatable.of("msg_err_admin_controlled_pvp_prevents_you_from_changing_pvp", "adminEnabledPVP", "off"));

if (TownySettings.getOutsidersPreventPVPToggle()) {
if (TownySettings.getOutsidersPreventPVPToggle() && choice.orElse(!townBlock.getPermissions().pvp)) {
for (Player target : Bukkit.getOnlinePlayers()) {
if (!town.hasResident(target) && !player.getName().equals(target.getName()) && townBlock.getWorldCoord().equals(WorldCoord.parseWorldCoord(target)))
throw new TownyException(Translatable.of("msg_cant_toggle_pvp_outsider_in_plot"));
Expand Down Expand Up @@ -1249,7 +1249,7 @@ public void plotGroupToggle(Player player, PlotGroup plotGroup, String[] split)
throw new TownyException(Translatable.of("msg_err_cannot_toggle_pvp_x_seconds_remaining", CooldownTimerTask.getCooldownRemaining(groupBlock.getWorldCoord().toString(), CooldownType.PVP)));
}

if (TownySettings.getOutsidersPreventPVPToggle()) {
if (TownySettings.getOutsidersPreventPVPToggle() && choice.orElse(!groupBlock.getPermissions().pvp)) {
for (Player target : Bukkit.getOnlinePlayers()) {
if (!town.hasResident(target) && !player.getName().equals(target.getName()) && groupBlock.getWorldCoord().equals(WorldCoord.parseWorldCoord(target)))
throw new TownyException(Translatable.of("msg_cant_toggle_pvp_outsider_in_plot"));
Expand Down
2 changes: 1 addition & 1 deletion src/com/palmergames/bukkit/towny/command/TownCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ public static void townToggle(CommandSender sender, String[] split, boolean admi
throw new TownyException(Translatable.of("msg_err_cannot_toggle_pvp_x_seconds_remaining", CooldownTimerTask.getCooldownRemaining(town.getName(), CooldownType.PVP)));

// Test to see if an outsider being inside of the Town would prevent toggling PVP.
if (TownySettings.getOutsidersPreventPVPToggle()) {
if (TownySettings.getOutsidersPreventPVPToggle() && choice.orElse(!town.isPVP())) {
for (Player target : Bukkit.getOnlinePlayers()) {
if (!town.hasResident(target) && town.equals(TownyAPI.getInstance().getTown(target.getLocation())))
throw new TownyException(Translatable.of("msg_cant_toggle_pvp_outsider_in_town"));
Expand Down