Skip to content

Commit

Permalink
- Add the ability to harm outlaws, and separately make outlaws be able
Browse files Browse the repository at this point in the history
to always harm people in towns.
    - Closes #7733.
  - New Config Option: global_town_settings.force_pvp_on_outlaws
    - Default: false
    - While true, outlaws can always be harmed in towns they are
outlawed in.
  - New Config Option: global_town_settings.allows_outlaws_to_always_pvp
    - Default: false
    - While true, outlaws can always harm players in towns they are
outlawed in, despite the town pvp setting.
  • Loading branch information
LlmDl committed Jan 18, 2025
1 parent 36e5cb0 commit 94dc241
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Towny/src/main/java/com/palmergames/bukkit/config/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,16 @@ public enum ConfigNodes {
"",
"# Enables the [~Home] TownName - PlotOwner - PlotName message line..",
"# If false players will not be shown any notifications when they move in and out of towns, between plots."),
GTOWN_SETTING_FORCE_PVP_ON_OUTLAWS(
"global_town_settings.force_pvp_on_outlaws",
"false",
"",
"# While true, outlaws can always be harmed in towns they are outlawed in."),
GTOWN_SETTING_ALLOW_OUTLAWS_TO_ALWAYS_PVP(
"global_town_settings.allows_outlaws_to_always_pvp",
"false",
"",
"# While true, outlaws can always harm players in towns they are outlawed in, despite the town pvp setting."),
GTOWN_SETTINGS_ALLOW_OUTLAWS_TO_ENTER_TOWN(
"global_town_settings.allow_outlaws_to_enter_town",
"true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3516,6 +3516,14 @@ public static boolean doBankruptTownsPayNationTax() {
return getBoolean(ConfigNodes.ECO_BANKRUPTCY_DO_BANKRUPT_TOWNS_PAY_NATION_TAX);
}

public static boolean forcePVPForTownOutlaws() {
return getBoolean(ConfigNodes.GTOWN_SETTING_FORCE_PVP_ON_OUTLAWS);
}

public static boolean outlawsAlwaysAllowedToPVP() {
return getBoolean(ConfigNodes.GTOWN_SETTING_ALLOW_OUTLAWS_TO_ALWAYS_PVP);
}

public static boolean canOutlawsEnterTowns() {
return getBoolean(ConfigNodes.GTOWN_SETTINGS_ALLOW_OUTLAWS_TO_ENTER_TOWN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ 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 can some times bypass pvp settings.
*/
if (!isArenaPlot(attackerTB, defenderTB) && !isTownyAdminBypassingPVP(attackingPlayer)) {
if (!isArenaPlot(attackerTB, defenderTB) && !isOutlawInTown(defenderTB, attackingPlayer, defendingPlayer) && !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 @@ -428,6 +428,25 @@ public static boolean isArenaPlot(TownBlock attackerTB, TownBlock defenderTB) {
return false;
}

/**
* Return true if the outlaw system allows for outlaws to harm/be harmed.
*
* @param defenderTB TownBlock where the defendingPlayer is harmed.
* @param attackingPlayer Player harming the defendingPlayer.
* @param defendingPlayer Player getting harmed.
* @return true if one of the players is an outlaw in a situation where that matters.
*/
private static boolean isOutlawInTown(TownBlock defenderTB, Player attackingPlayer, Player defendingPlayer) {
Town town = defenderTB.getTownOrNull();
if (town == null)
return false;
if (TownySettings.forcePVPForTownOutlaws() && town.hasOutlaw(defendingPlayer.getName()))
return true;
if (TownySettings.outlawsAlwaysAllowedToPVP() && town.hasOutlaw(attackingPlayer.getName()))
return true;
return false;
}

/**
* Is the defending resident an ally of the attacking resident?
*
Expand Down
10 changes: 9 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10204,4 +10204,12 @@ v0.92.0.11:
- Bump version for release.
0.101.1.1:
- Replace a couple of deprecations required when we supported MC 1.16.*.
- Fix showing spawn hovers in the nation and town list, when the config is set to prevent all spawning.
- Fix showing spawn hovers in the nation and town list, when the config is set to prevent all spawning.
- Add the ability to harm outlaws, and separately make outlaws be able to always harm people in towns.
- Closes #7733.
- New Config Option: global_town_settings.force_pvp_on_outlaws
- Default: false
- While true, outlaws can always be harmed in towns they are outlawed in.
- New Config Option: global_town_settings.allows_outlaws_to_always_pvp
- Default: false
- While true, outlaws can always harm players in towns they are outlawed in, despite the town pvp setting.

0 comments on commit 94dc241

Please sign in to comment.