Add guards to everything up until by progress from multilingual
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
5205b1fc93
Commit
847b8ad601
@ -824,6 +824,7 @@ REGION_TNT_HELP_2=§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten au
|
||||
REGION_TNT_ON=§aTNT-Schaden aktiviert
|
||||
REGION_TNT_OFF=§cTNT-Schaden deaktiviert
|
||||
REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert
|
||||
REGION_TNT_NO_PERMS=§cDu darfst hier nicht TNT-Schaden (de-)aktivieren
|
||||
REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört
|
||||
# Team
|
||||
LOCK_SCHEM_NO_USER=§7Dieser Spieler existiert nicht!
|
||||
|
@ -23,6 +23,9 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -57,127 +60,115 @@ public class LoaderCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("setup")
|
||||
public void setupLoader(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
if (Loader.getLoader(p) != null) {
|
||||
Loader.getLoader(p).setup();
|
||||
BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p);
|
||||
} else {
|
||||
Loader.newLoader(p);
|
||||
BauSystem.MESSAGE.send("LOADER_NEW", p);
|
||||
BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p);
|
||||
}
|
||||
public void setupLoader(@Guard Player p) {
|
||||
if (Loader.getLoader(p) != null) {
|
||||
Loader.getLoader(p).setup();
|
||||
BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p);
|
||||
} else {
|
||||
Loader.newLoader(p);
|
||||
BauSystem.MESSAGE.send("LOADER_NEW", p);
|
||||
BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("start")
|
||||
public void startLoader(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.start();
|
||||
BauSystem.MESSAGE.send("LOADER_ACTIVE", p);
|
||||
public void startLoader(@Guard Player p) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.start();
|
||||
BauSystem.MESSAGE.send("LOADER_ACTIVE", p);
|
||||
}
|
||||
|
||||
@Register("stop")
|
||||
public void stopLoader(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.stop();
|
||||
BauSystem.MESSAGE.send("LOADER_STOP", p);
|
||||
public void stopLoader(@Guard Player p) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.stop();
|
||||
BauSystem.MESSAGE.send("LOADER_STOP", p);
|
||||
}
|
||||
|
||||
@Register("pause")
|
||||
public void pauseLoader(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.pause();
|
||||
BauSystem.MESSAGE.send("LOADER_PAUSED", p);
|
||||
public void pauseLoader(@Guard Player p) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.pause();
|
||||
BauSystem.MESSAGE.send("LOADER_PAUSED", p);
|
||||
}
|
||||
|
||||
@Register("resume")
|
||||
public void resumeLoader(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.resume();
|
||||
BauSystem.MESSAGE.send("LOADER_RESUME", p);
|
||||
public void resumeLoader(@Guard Player p) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.resume();
|
||||
BauSystem.MESSAGE.send("LOADER_RESUME", p);
|
||||
}
|
||||
|
||||
@Register("wait")
|
||||
public void shotDelayLoader(Player p, int delay) {
|
||||
if (permissionCheck(p)) {
|
||||
if (delay < 1) {
|
||||
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
|
||||
return;
|
||||
}
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay, loader.getTicksBetweenShots());
|
||||
loader.setTicksBetweenShots(delay);
|
||||
public void shotDelayLoader(@Guard Player p, int delay) {
|
||||
if (delay < 1) {
|
||||
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
|
||||
return;
|
||||
}
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay, loader.getTicksBetweenShots());
|
||||
loader.setTicksBetweenShots(delay);
|
||||
}
|
||||
|
||||
@Register("speed")
|
||||
public void speedLoader(Player p, int delay) {
|
||||
if (permissionCheck(p)) {
|
||||
if (delay < 1) {
|
||||
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
|
||||
return;
|
||||
}
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay, loader.getTicksBetweenBlocks());
|
||||
loader.setTicksBetweenBlocks(delay);
|
||||
public void speedLoader(@Guard Player p, int delay) {
|
||||
if (delay < 1) {
|
||||
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
|
||||
return;
|
||||
}
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay, loader.getTicksBetweenBlocks());
|
||||
loader.setTicksBetweenBlocks(delay);
|
||||
}
|
||||
|
||||
@Register("undo")
|
||||
public void undoLast(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("LOADER_UNDO", p);
|
||||
loader.undo();
|
||||
public void undoLast(@Guard Player p) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.send("LOADER_UNDO", p);
|
||||
loader.undo();
|
||||
}
|
||||
|
||||
@Register("clear")
|
||||
public void clearLoader(Player p) {
|
||||
if (permissionCheck(p)) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.clear();
|
||||
public void clearLoader(@Guard Player p) {
|
||||
Loader loader = Loader.getLoader(p);
|
||||
if (loaderNullCheck(loader, p)) {
|
||||
return;
|
||||
}
|
||||
loader.clear();
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send("LOADER_PERMS", player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker loaderGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("LOADER_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -49,19 +52,24 @@ public class ClearCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void clearPlayerCommand(Player p, Player target) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void clearPlayerCommand(@Guard Player p, Player target) {
|
||||
clear(target);
|
||||
BauSystem.MESSAGE.send("OTHER_CLEAR_FROM", target, p.getName());
|
||||
BauSystem.MESSAGE.send("OTHER_CLEAR_TO", p, target.getName());
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send("OTHER_CLEAR_NO_PERMS", player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker loaderGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("OTHER_CLEAR_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
private void clear(Player player) {
|
||||
|
@ -66,5 +66,4 @@ public class DeclutterCommand extends SWCommand {
|
||||
|
||||
BauSystem.MESSAGE.send("OTHER_DECLUTTER_DONE", p);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,9 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -48,21 +46,13 @@ public class TimeCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, Time time) {
|
||||
if (!Permission.hasPermission(p, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send("OTHER_TIME_NO_PERM", p);
|
||||
return;
|
||||
}
|
||||
public void genericCommand(@Guard Player p, Time time) {
|
||||
Bukkit.getWorlds().get(0).setTime(time.getValue());
|
||||
BauSystem.MESSAGE.send("OTHER_TIME_RESULT", p);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, int time) {
|
||||
if (!Permission.hasPermission(p, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send("OTHER_TIME_NO_PERM", p);
|
||||
return;
|
||||
}
|
||||
public void genericCommand(@Guard Player p, int time) {
|
||||
if (time < 0 || time > 24000) {
|
||||
BauSystem.MESSAGE.send("OTHER_TIME_INVALID", p);
|
||||
return;
|
||||
@ -82,6 +72,20 @@ public class TimeCommand extends SWCommand {
|
||||
}, s -> tabCompletions);
|
||||
}
|
||||
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker loaderGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("OTHER_TIME_NO_PERM", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
public enum Time {
|
||||
NIGHT(18000),
|
||||
DAY(6000),
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.region;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.config.BauServer;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
@ -30,6 +31,9 @@ import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -58,10 +62,7 @@ public class ColorCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColorSet(Player p, ColorMode color, ColorizationType colorizationType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
public void genericColorSet(@Guard Player p, ColorMode color, ColorizationType colorizationType) {
|
||||
if (colorizationType == ColorizationType.GLOBAL) {
|
||||
Region.setGlobal(Flag.COLOR, color);
|
||||
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
||||
@ -87,12 +88,18 @@ public class ColorCommand extends SWCommand {
|
||||
genericColorSet(p, color, colorizationType);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player p) {
|
||||
if (bauServer.getOwner().equals(p.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
BauSystem.MESSAGE.send("REGION_COLOR_NO_PERMS", p);
|
||||
return false;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker loaderGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (bauServer.getOwner().equals(player.getUniqueId())) {
|
||||
return GuardResult.ALLOWED;
|
||||
}
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_COLOR_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
};
|
||||
}
|
||||
|
||||
public enum ColorizationType {
|
||||
|
@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.DamageMode;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -45,8 +48,7 @@ public class DamageCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void toggleCommand(@Guard Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
@ -79,11 +81,17 @@ public class DamageCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send(getNoPermMessage(), player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker guard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send(getNoPermMessage(), player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
}
|
@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -44,8 +47,7 @@ public class FireCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void toggleCommand(@Guard Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
@ -78,12 +80,17 @@ public class FireCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send(getNoPermMessage(), player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker guard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send(getNoPermMessage(), player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -44,8 +47,7 @@ public class FreezeCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void toggleCommand(@Guard Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
@ -78,11 +80,17 @@ public class FreezeCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
BauSystem.MESSAGE.send(getNoPermMessage(), player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker guard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send(getNoPermMessage(), player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -44,8 +47,7 @@ public class ProtectCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericProtectCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void genericProtectCommand(@Guard Player p) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) {
|
||||
@ -61,12 +63,18 @@ public class ProtectCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (!Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
BauSystem.MESSAGE.send("REGION_PROTECT_NO_PERMS", player);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker guard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_PROTECT_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
@ -77,5 +85,4 @@ public class ProtectCommand extends SWCommand {
|
||||
}
|
||||
return region;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,8 +31,7 @@ import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -86,8 +85,7 @@ public class RegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("undo")
|
||||
public void undoCommand(Player p) {
|
||||
if(!permissionCheck(p, Permission.WORLDEDIT)) return;
|
||||
public void undoCommand(@Guard("WORLD_EDIT") Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) return;
|
||||
|
||||
@ -109,10 +107,7 @@ public class RegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("redo")
|
||||
public void redoCommand(Player p) {
|
||||
if (!permissionCheck(p, Permission.WORLDEDIT)) {
|
||||
return;
|
||||
}
|
||||
public void redoCommand(@Guard("WORLD_EDIT") Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
@ -126,8 +121,7 @@ public class RegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void genericRestoreCommand(Player p) {
|
||||
if (!permissionCheck(p, Permission.WORLDEDIT)) return;
|
||||
public void genericRestoreCommand(@Guard("WORLD_EDIT") Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
@ -146,8 +140,7 @@ public class RegionCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void schematicRestoreCommand(Player p, String s) {
|
||||
if (!permissionCheck(p, Permission.WORLDEDIT)) return;
|
||||
public void schematicRestoreCommand(@Guard("WORLD_EDIT") Player p, String s) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) return;
|
||||
|
||||
@ -206,8 +199,7 @@ public class RegionCommand extends SWCommand {
|
||||
|
||||
@Register("changetype")
|
||||
@Register("type")
|
||||
public void changeTypeCommand(Player p, @Mapper("regionTypeMapper") String s) {
|
||||
if (!permissionCheck(p, Permission.WORLD)) return;
|
||||
public void changeTypeCommand(@Guard("WORLD") Player p, @Mapper("regionTypeMapper") String s) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
@ -245,12 +237,31 @@ public class RegionCommand extends SWCommand {
|
||||
};
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player, Permission permission) {
|
||||
if (Permission.hasPermission(player, permission)) {
|
||||
return true;
|
||||
}
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NO_PERMS", player);
|
||||
return false;
|
||||
@Guard(value = "WORLD", local = true)
|
||||
public GuardChecker worldGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
@Guard(value = "WORLD_EDIT", local = true)
|
||||
public GuardChecker worldEditGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_REGION_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.GuardCheckType;
|
||||
import de.steamwar.command.GuardChecker;
|
||||
import de.steamwar.command.GuardResult;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -50,8 +53,7 @@ public class ResetCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericResetCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void genericResetCommand(@Guard Player p) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
@ -64,8 +66,7 @@ public class ResetCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicResetCommand(Player p, String s) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void schematicResetCommand(@Guard Player p, String s) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
|
||||
@ -82,12 +83,18 @@ public class ResetCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Permission.hasPermission(player, Permission.WORLD)) {
|
||||
return true;
|
||||
}
|
||||
BauSystem.MESSAGE.send("REGION_RESET_NO_PERMS", player);
|
||||
return false;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker worldGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_RESET_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
|
@ -28,9 +28,7 @@ import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -54,15 +52,13 @@ public class TNTCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void toggleCommand(@Guard Player p) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
tntToggle(region, null, null);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void setCommand(Player p, TNTMode tntMode) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void setCommand(@Guard Player p, TNTMode tntMode) {
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
String requestedMessage = null;
|
||||
@ -151,12 +147,17 @@ public class TNTCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player p) {
|
||||
if (!Permission.hasPermission(p, Permission.WORLD)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker worldGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLD)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_TNT_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,7 @@ import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.*;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -61,8 +59,7 @@ public class TestblockCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericTestblockCommand(Player p, RegionExtensionType regionExtensionType) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void genericTestblockCommand(@Guard Player p, RegionExtensionType regionExtensionType) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
@ -85,8 +82,7 @@ public class TestblockCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) {
|
||||
if (!permissionCheck(p)) return;
|
||||
public void schematicTestblockCommand(@Guard Player p, String s, RegionExtensionType regionExtensionType) {
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
|
||||
@ -118,12 +114,18 @@ public class TestblockCommand extends SWCommand {
|
||||
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
return true;
|
||||
}
|
||||
BauSystem.MESSAGE.send("REGION_TB_NO_PERMS", player);
|
||||
return false;
|
||||
@ClassGuard(value = Player.class, local = true)
|
||||
public GuardChecker worldGuard() {
|
||||
return (commandSender, guardCheckType, strings, s) -> {
|
||||
Player player = (Player) commandSender;
|
||||
if (!Permission.hasPermission(player, Permission.WORLDEDIT)) {
|
||||
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
|
||||
BauSystem.MESSAGE.send("REGION_TB_NO_PERMS", player);
|
||||
}
|
||||
return GuardResult.DENIED;
|
||||
}
|
||||
return GuardResult.ALLOWED;
|
||||
};
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren