Skip to content

Commit

Permalink
Prevent non-residents from making protections in Towny towns when cor…
Browse files Browse the repository at this point in the history
…e.townyBorders is enabled
  • Loading branch information
pop4959 committed Apr 22, 2019
1 parent f4fa4ae commit c1d515f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/main/java/com/griefcraft/modules/pluginsupport/Towny.java
Expand Up @@ -189,15 +189,14 @@ public void onRegisterProtection(LWCProtectionRegisterEvent event) {
return;
}

// attempt to get the town block
@SuppressWarnings("unused")
TownBlock townBlock;

try {
townBlock = world.getTownBlock(Coord.parseCoord(block));
TownBlock townBlock = world.getTownBlock(Coord.parseCoord(block));
// If an exception is not thrown, we are in a town.
if (!townBlock.getTown().hasResident(event.getPlayer().getName())) {
trigger(event);
}
} catch (Exception e) {
// No world, don't let them protect it!
trigger(event);
// If an exception is thrown, we are not in a town (do nothing).
}
}

Expand Down

0 comments on commit c1d515f

Please sign in to comment.