fix: siege start admin override

This commit is contained in:
darksaid98 committed 2023-08-01 17:27:32 +02:00
1 parent 2977d19d00
commit 31d0bb1f6b
1 file changed
+4 -5
@@ -71,7 +71,7 @@ public class SiegeCommands {
.setOptional(true) .setOptional(true)
.withPermission("AlathranWars.admin")*/ .withPermission("AlathranWars.admin")*/
) )
.executesPlayer((Player p, CommandArguments args) -> siegeStart(p, args, false)); .executesPlayer((Player p, CommandArguments args) -> siegeStart(p, args, asAdmin));
} }
public static CommandAPICommand commandStop(boolean asAdmin) { public static CommandAPICommand commandStop(boolean asAdmin) {
@@ -145,16 +145,15 @@ public class SiegeCommands {
if (!location.getWorld().equals(townLocation.getWorld())) if (!location.getWorld().equals(townLocation.getWorld()))
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to be in the same world as the town you're attacking!").build()); throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to be in the same world as the town you're attacking!").build());
if (location.distance(townLocation) >= Siege.BATTLEFIELD_START_MAX_RANGE) if (location.distance(townLocation) >= Siege.BATTLEFIELD_START_MAX_RANGE && !asAdmin)
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to be within <range> blocks of the town to start a siege!").parseMinimessagePlaceholder("range", String.valueOf(Siege.BATTLEFIELD_START_MAX_RANGE)).build()); throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to be within <range> blocks of the town to start a siege!").parseMinimessagePlaceholder("range", String.valueOf(Siege.BATTLEFIELD_START_MAX_RANGE)).build());
if (location.distance(townLocation) <= Siege.BATTLEFIELD_START_MIN_RANGE) if (location.distance(townLocation) <= Siege.BATTLEFIELD_START_MIN_RANGE && !asAdmin)
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to be further than <range> blocks away from the town to start a siege!").parseMinimessagePlaceholder("range", String.valueOf(Siege.BATTLEFIELD_START_MIN_RANGE)).build()); throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to be further than <range> blocks away from the town to start a siege!").parseMinimessagePlaceholder("range", String.valueOf(Siege.BATTLEFIELD_START_MIN_RANGE)).build());
if ((Main.econ.getBalance(siegeLeader) < Siege.SIEGE_VICTORY_MONEY)) if ((Main.econ.getBalance(siegeLeader) < Siege.SIEGE_VICTORY_MONEY) && !asAdmin)
throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to have $<amount> to start a siege!").parseMinimessagePlaceholder("amount", String.valueOf(Siege.SIEGE_VICTORY_MONEY)).build()); throw CommandAPIBukkit.failWithAdventureComponent(ColorParser.of("<red>You need to have $<amount> to start a siege!").parseMinimessagePlaceholder("amount", String.valueOf(Siege.SIEGE_VICTORY_MONEY)).build());
side.setSiegeGrace(); side.setSiegeGrace();
Siege siege = new Siege(war, town, siegeLeader); Siege siege = new Siege(war, town, siegeLeader);