Skip to content

Commit

Permalink
- Disable admins-bypassing-pvp settings by default.
Browse files Browse the repository at this point in the history
  - New Config Option: global_town_settings.admins_can_always_pvp
    - Default: false
    - If set to true, any player with towny.admin (or OP,) will be able
to hurt other players overriding any location's PVP setting.
    - Setting this to true will create avenues for admins to abuse
players.
  • Loading branch information
LlmDl committed May 9, 2024
1 parent 4e5c597 commit e5356e8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,13 @@ public enum ConfigNodes {
"",
"# If set to true, when a world has forcepvp set to true, homeblocks of towns will not be affected and have PVP set to off.",
"# Does not have any effect when Event War is active."),
GTOWN_SETTINGS_ADMINS_CAN_ALWAYS_PVP(
"global_town_settings.admins_can_always_pvp",
"false",
"",
"# If set to true, any player with towny.admin (or OP,) will be able to hurt other players overriding any location's PVP setting.",
"# Setting this to true will create avenues for admins to abuse players."),

GTOWN_SETTINGS_KEEP_INVENTORY_ON_DEATH_IN_TOWN(
"global_town_settings.keep_inventory_on_death_in_town",
"false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2922,6 +2922,10 @@ public static boolean isForcePvpNotAffectingHomeblocks() {
return getBoolean(ConfigNodes.GTOWN_SETTINGS_HOMEBLOCKS_PREVENT_FORCEPVP);
}

public static boolean isPVPAlwaysAllowedForAdmins() {
return getBoolean(ConfigNodes.GTOWN_SETTINGS_ADMINS_CAN_ALWAYS_PVP);
}

public static int getConfirmationTimeoutSeconds() {
return getInt(ConfigNodes.INVITE_SYSTEM_CONFIRMATION_TIMEOUT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ private static boolean preventDamageCall(TownyWorld world, Entity attackingEntit

/*
* Both townblocks are not Arena plot and Player is not considered an Admin by Towny.
* Arena plots never prevent pvp, admins are never prevented from pvping.
* Arena plots never prevent pvp, admins can some times bypass pvp settings.
*/
if (!isArenaPlot(attackerTB, defenderTB) && !isTownyAdmin(attackingPlayer)) {
if (!isArenaPlot(attackerTB, defenderTB) && !isTownyAdminBypassingPVP(attackingPlayer)) {
/*
* Check if we are preventing friendly fire between allies
* Check the attackers TownBlock for its PvP status, else the world.
Expand Down Expand Up @@ -710,7 +710,7 @@ private static boolean isNotNPC(Entity entity) {
}
}

private static boolean isTownyAdmin(Player attackingPlayer) {
return TownyUniverse.getInstance().getPermissionSource().isTownyAdmin(attackingPlayer);
private static boolean isTownyAdminBypassingPVP(Player attackingPlayer) {
return TownySettings.isPVPAlwaysAllowedForAdmins() && TownyUniverse.getInstance().getPermissionSource().isTownyAdmin(attackingPlayer);
}
}
7 changes: 6 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9757,4 +9757,9 @@ v0.92.0.11:
- Closes #7397.
0.100.2.9:
- Fix scheduling 0 tick delayed task on paper, courtesy of Warrior with PR #7404.
- Call NewResidentThread sync on Folia, courtesy of Warrior with PR #7394.
- Call NewResidentThread sync on Folia, courtesy of Warrior with PR #7394.
- Disable admins-bypassing-pvp settings by default.
- New Config Option: global_town_settings.admins_can_always_pvp
- Default: false
- If set to true, any player with towny.admin (or OP,) will be able to hurt other players overriding any location's PVP setting.
- Setting this to true will create avenues for admins to abuse players.

0 comments on commit e5356e8

Please sign in to comment.