Skip to content

Commit f01a5a3

Browse files
committed
feat: Only apply wartime flags to combatants, close #378
1 parent 498c1a1 commit f01a5a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

common/src/main/java/net/william278/husktowns/listener/OperationHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ private boolean cancelOperation(@NotNull Operation operation, @NotNull TownClaim
8989
final Town town = townClaim.town();
9090
final Claim claim = townClaim.claim();
9191

92-
// Apply wartime flags if the town is at war
92+
// Apply wartime flags if the user is active in a town that is at war
9393
if (plugin.getSettings().doTownWars() && plugin.getSettings().doTownRelations() &&
94-
town.getCurrentWar().map(war -> war.getDefending() == town.getId()).orElse(false)) {
94+
town.getCurrentWar().map(war -> war.getDefending() == town.getId() && operation.getUser()
95+
.map(online -> war.isPlayerActive(online.getUuid()))
96+
.orElse(false))
97+
.orElse(false)) {
9598
return plugin.getRulePresets().getWarRules().cancelOperation(operation.getType(), plugin.getFlags());
9699
}
97100

0 commit comments

Comments
 (0)