SteamWar/BauSystem2.0
Archiviert
12
0

Add guards to everything up until by progress from multilingual
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-11-17 09:32:41 +01:00
Ursprung 5205b1fc93
Commit 847b8ad601
14 geänderte Dateien mit 271 neuen und 210 gelöschten Zeilen

Datei anzeigen

@ -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_ON=§aTNT-Schaden aktiviert
REGION_TNT_OFF=§cTNT-Schaden deaktiviert REGION_TNT_OFF=§cTNT-Schaden deaktiviert
REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert 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 REGION_TNT_BUILD=§cEine Explosion hätte Blöcke im Baubereich zerstört
# Team # Team
LOCK_SCHEM_NO_USER=§7Dieser Spieler existiert nicht! LOCK_SCHEM_NO_USER=§7Dieser Spieler existiert nicht!

Datei anzeigen

@ -23,6 +23,9 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; 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 de.steamwar.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -57,127 +60,115 @@ public class LoaderCommand extends SWCommand {
} }
@Register("setup") @Register("setup")
public void setupLoader(Player p) { public void setupLoader(@Guard Player p) {
if (permissionCheck(p)) { if (Loader.getLoader(p) != null) {
if (Loader.getLoader(p) != null) { Loader.getLoader(p).setup();
Loader.getLoader(p).setup(); BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p);
BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p); } else {
} else { Loader.newLoader(p);
Loader.newLoader(p); BauSystem.MESSAGE.send("LOADER_NEW", p);
BauSystem.MESSAGE.send("LOADER_NEW", p); BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p);
BauSystem.MESSAGE.send("LOADER_HOW_TO_START", p);
}
} }
} }
@Register("start") @Register("start")
public void startLoader(Player p) { public void startLoader(@Guard Player p) {
if (permissionCheck(p)) { Loader loader = Loader.getLoader(p);
Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) {
if (loaderNullCheck(loader, p)) { return;
return;
}
loader.start();
BauSystem.MESSAGE.send("LOADER_ACTIVE", p);
} }
loader.start();
BauSystem.MESSAGE.send("LOADER_ACTIVE", p);
} }
@Register("stop") @Register("stop")
public void stopLoader(Player p) { public void stopLoader(@Guard Player p) {
if (permissionCheck(p)) { Loader loader = Loader.getLoader(p);
Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) {
if (loaderNullCheck(loader, p)) { return;
return;
}
loader.stop();
BauSystem.MESSAGE.send("LOADER_STOP", p);
} }
loader.stop();
BauSystem.MESSAGE.send("LOADER_STOP", p);
} }
@Register("pause") @Register("pause")
public void pauseLoader(Player p) { public void pauseLoader(@Guard Player p) {
if (permissionCheck(p)) { Loader loader = Loader.getLoader(p);
Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) {
if (loaderNullCheck(loader, p)) { return;
return;
}
loader.pause();
BauSystem.MESSAGE.send("LOADER_PAUSED", p);
} }
loader.pause();
BauSystem.MESSAGE.send("LOADER_PAUSED", p);
} }
@Register("resume") @Register("resume")
public void resumeLoader(Player p) { public void resumeLoader(@Guard Player p) {
if (permissionCheck(p)) { Loader loader = Loader.getLoader(p);
Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) {
if (loaderNullCheck(loader, p)) { return;
return;
}
loader.resume();
BauSystem.MESSAGE.send("LOADER_RESUME", p);
} }
loader.resume();
BauSystem.MESSAGE.send("LOADER_RESUME", p);
} }
@Register("wait") @Register("wait")
public void shotDelayLoader(Player p, int delay) { public void shotDelayLoader(@Guard Player p, int delay) {
if (permissionCheck(p)) { if (delay < 1) {
if (delay < 1) { BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); return;
return;
}
Loader loader = Loader.getLoader(p);
if (loaderNullCheck(loader, p)) {
return;
}
BauSystem.MESSAGE.send("LOADER_NEW_TIME", p, delay, loader.getTicksBetweenShots());
loader.setTicksBetweenShots(delay);
} }
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") @Register("speed")
public void speedLoader(Player p, int delay) { public void speedLoader(@Guard Player p, int delay) {
if (permissionCheck(p)) { if (delay < 1) {
if (delay < 1) { BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p);
BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); return;
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);
} }
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") @Register("undo")
public void undoLast(Player p) { public void undoLast(@Guard Player p) {
if (permissionCheck(p)) { Loader loader = Loader.getLoader(p);
Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) {
if (loaderNullCheck(loader, p)) { return;
return;
}
BauSystem.MESSAGE.send("LOADER_UNDO", p);
loader.undo();
} }
BauSystem.MESSAGE.send("LOADER_UNDO", p);
loader.undo();
} }
@Register("clear") @Register("clear")
public void clearLoader(Player p) { public void clearLoader(@Guard Player p) {
if (permissionCheck(p)) { Loader loader = Loader.getLoader(p);
Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) {
if (loaderNullCheck(loader, p)) { return;
return;
}
loader.clear();
} }
loader.clear();
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(player, Permission.WORLD)) { public GuardChecker loaderGuard() {
BauSystem.MESSAGE.send("LOADER_PERMS", player); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLD)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("LOADER_PERMS", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
} }

Datei anzeigen

@ -23,6 +23,9 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; 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 de.steamwar.command.SWCommand;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -49,19 +52,24 @@ public class ClearCommand extends SWCommand {
} }
@Register @Register
public void clearPlayerCommand(Player p, Player target) { public void clearPlayerCommand(@Guard Player p, Player target) {
if (!permissionCheck(p)) return;
clear(target); clear(target);
BauSystem.MESSAGE.send("OTHER_CLEAR_FROM", target, p.getName()); BauSystem.MESSAGE.send("OTHER_CLEAR_FROM", target, p.getName());
BauSystem.MESSAGE.send("OTHER_CLEAR_TO", p, target.getName()); BauSystem.MESSAGE.send("OTHER_CLEAR_TO", p, target.getName());
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(player, Permission.WORLD)) { public GuardChecker loaderGuard() {
BauSystem.MESSAGE.send("OTHER_CLEAR_NO_PERMS", player); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLD)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("OTHER_CLEAR_NO_PERMS", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
private void clear(Player player) { private void clear(Player player) {

Datei anzeigen

@ -66,5 +66,4 @@ public class DeclutterCommand extends SWCommand {
BauSystem.MESSAGE.send("OTHER_DECLUTTER_DONE", p); BauSystem.MESSAGE.send("OTHER_DECLUTTER_DONE", p);
} }
} }

Datei anzeigen

@ -23,9 +23,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -48,21 +46,13 @@ public class TimeCommand extends SWCommand {
} }
@Register @Register
public void genericCommand(Player p, Time time) { public void genericCommand(@Guard Player p, Time time) {
if (!Permission.hasPermission(p, Permission.WORLD)) {
BauSystem.MESSAGE.send("OTHER_TIME_NO_PERM", p);
return;
}
Bukkit.getWorlds().get(0).setTime(time.getValue()); Bukkit.getWorlds().get(0).setTime(time.getValue());
BauSystem.MESSAGE.send("OTHER_TIME_RESULT", p); BauSystem.MESSAGE.send("OTHER_TIME_RESULT", p);
} }
@Register @Register
public void genericCommand(Player p, int time) { public void genericCommand(@Guard Player p, int time) {
if (!Permission.hasPermission(p, Permission.WORLD)) {
BauSystem.MESSAGE.send("OTHER_TIME_NO_PERM", p);
return;
}
if (time < 0 || time > 24000) { if (time < 0 || time > 24000) {
BauSystem.MESSAGE.send("OTHER_TIME_INVALID", p); BauSystem.MESSAGE.send("OTHER_TIME_INVALID", p);
return; return;
@ -82,6 +72,20 @@ public class TimeCommand extends SWCommand {
}, s -> tabCompletions); }, 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 { public enum Time {
NIGHT(18000), NIGHT(18000),
DAY(6000), DAY(6000),

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.region; package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; 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.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; 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.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -58,10 +62,7 @@ public class ColorCommand extends SWCommand {
} }
@Register @Register
public void genericColorSet(Player p, ColorMode color, ColorizationType colorizationType) { public void genericColorSet(@Guard Player p, ColorMode color, ColorizationType colorizationType) {
if (!permissionCheck(p)) {
return;
}
if (colorizationType == ColorizationType.GLOBAL) { if (colorizationType == ColorizationType.GLOBAL) {
Region.setGlobal(Flag.COLOR, color); Region.setGlobal(Flag.COLOR, color);
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p)); 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); genericColorSet(p, color, colorizationType);
} }
private boolean permissionCheck(Player p) { @ClassGuard(value = Player.class, local = true)
if (bauServer.getOwner().equals(p.getUniqueId())) { public GuardChecker loaderGuard() {
return true; return (commandSender, guardCheckType, strings, s) -> {
} Player player = (Player) commandSender;
BauSystem.MESSAGE.send("REGION_COLOR_NO_PERMS", p); if (bauServer.getOwner().equals(player.getUniqueId())) {
return false; return GuardResult.ALLOWED;
}
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("REGION_COLOR_NO_PERMS", player);
}
return GuardResult.DENIED;
};
} }
public enum ColorizationType { public enum ColorizationType {

Datei anzeigen

@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.DamageMode; 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 de.steamwar.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -45,8 +48,7 @@ public class DamageCommand extends SWCommand {
} }
@Register @Register
public void toggleCommand(Player p) { public void toggleCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (toggle(region)) { if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage()); RegionUtils.actionBar(region, getEnableMessage());
@ -79,11 +81,17 @@ public class DamageCommand extends SWCommand {
} }
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(player, Permission.WORLD)) { public GuardChecker guard() {
BauSystem.MESSAGE.send(getNoPermMessage(), player); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLD)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send(getNoPermMessage(), player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
} }

Datei anzeigen

@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FireMode; 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 de.steamwar.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,8 +47,7 @@ public class FireCommand extends SWCommand {
} }
@Register @Register
public void toggleCommand(Player p) { public void toggleCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (toggle(region)) { if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage()); RegionUtils.actionBar(region, getEnableMessage());
@ -78,12 +80,17 @@ public class FireCommand extends SWCommand {
} }
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(player, Permission.WORLD)) { public GuardChecker guard() {
BauSystem.MESSAGE.send(getNoPermMessage(), player); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLD)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send(getNoPermMessage(), player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
} }

Datei anzeigen

@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; 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 de.steamwar.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,8 +47,7 @@ public class FreezeCommand extends SWCommand {
} }
@Register @Register
public void toggleCommand(Player p) { public void toggleCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (toggle(region)) { if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage()); RegionUtils.actionBar(region, getEnableMessage());
@ -78,11 +80,17 @@ public class FreezeCommand extends SWCommand {
} }
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(player, Permission.WORLD)) { public GuardChecker guard() {
BauSystem.MESSAGE.send(getNoPermMessage(), player); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLD)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send(getNoPermMessage(), player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
} }

Datei anzeigen

@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; 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 de.steamwar.command.SWCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -44,8 +47,7 @@ public class ProtectCommand extends SWCommand {
} }
@Register @Register
public void genericProtectCommand(Player p) { public void genericProtectCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) { switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) {
@ -61,12 +63,18 @@ public class ProtectCommand extends SWCommand {
} }
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(player, Permission.WORLDEDIT)) { public GuardChecker guard() {
BauSystem.MESSAGE.send("REGION_PROTECT_NO_PERMS", player); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLDEDIT)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("REGION_PROTECT_NO_PERMS", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
private Region regionCheck(Player player) { private Region regionCheck(Player player) {
@ -77,5 +85,4 @@ public class ProtectCommand extends SWCommand {
} }
return region; return region;
} }
} }

Datei anzeigen

@ -31,8 +31,7 @@ import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -86,8 +85,7 @@ public class RegionCommand extends SWCommand {
} }
@Register("undo") @Register("undo")
public void undoCommand(Player p) { public void undoCommand(@Guard("WORLD_EDIT") Player p) {
if(!permissionCheck(p, Permission.WORLDEDIT)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return; if (checkGlobalRegion(region, p)) return;
@ -109,10 +107,7 @@ public class RegionCommand extends SWCommand {
} }
@Register("redo") @Register("redo")
public void redoCommand(Player p) { public void redoCommand(@Guard("WORLD_EDIT") Player p) {
if (!permissionCheck(p, Permission.WORLDEDIT)) {
return;
}
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
@ -126,8 +121,7 @@ public class RegionCommand extends SWCommand {
} }
@Register("restore") @Register("restore")
public void genericRestoreCommand(Player p) { public void genericRestoreCommand(@Guard("WORLD_EDIT") Player p) {
if (!permissionCheck(p, Permission.WORLDEDIT)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return; if(checkGlobalRegion(region, p)) return;
@ -146,8 +140,7 @@ public class RegionCommand extends SWCommand {
} }
@Register("restore") @Register("restore")
public void schematicRestoreCommand(Player p, String s) { public void schematicRestoreCommand(@Guard("WORLD_EDIT") Player p, String s) {
if (!permissionCheck(p, Permission.WORLDEDIT)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return; if (checkGlobalRegion(region, p)) return;
@ -206,8 +199,7 @@ public class RegionCommand extends SWCommand {
@Register("changetype") @Register("changetype")
@Register("type") @Register("type")
public void changeTypeCommand(Player p, @Mapper("regionTypeMapper") String s) { public void changeTypeCommand(@Guard("WORLD") Player p, @Mapper("regionTypeMapper") String s) {
if (!permissionCheck(p, Permission.WORLD)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
@ -245,12 +237,31 @@ public class RegionCommand extends SWCommand {
}; };
} }
private boolean permissionCheck(Player player, Permission permission) { @Guard(value = "WORLD", local = true)
if (Permission.hasPermission(player, permission)) { public GuardChecker worldGuard() {
return true; return (commandSender, guardCheckType, strings, s) -> {
} Player player = (Player) commandSender;
BauSystem.MESSAGE.send("REGION_REGION_NO_PERMS", player); if (!Permission.hasPermission(player, Permission.WORLD)) {
return false; 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;
};
}
} }

Datei anzeigen

@ -27,6 +27,9 @@ import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionType; 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.command.SWCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -50,8 +53,7 @@ public class ResetCommand extends SWCommand {
} }
@Register @Register
public void genericResetCommand(Player p) { public void genericResetCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
try { try {
@ -64,8 +66,7 @@ public class ResetCommand extends SWCommand {
} }
@Register @Register
public void schematicResetCommand(Player p, String s) { public void schematicResetCommand(@Guard Player p, String s) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId());
@ -82,12 +83,18 @@ public class ResetCommand extends SWCommand {
} }
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (Permission.hasPermission(player, Permission.WORLD)) { public GuardChecker worldGuard() {
return true; return (commandSender, guardCheckType, strings, s) -> {
} Player player = (Player) commandSender;
BauSystem.MESSAGE.send("REGION_RESET_NO_PERMS", player); if (!Permission.hasPermission(player, Permission.WORLD)) {
return false; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("REGION_RESET_NO_PERMS", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
private Region regionCheck(Player player) { private Region regionCheck(Player player) {

Datei anzeigen

@ -28,9 +28,7 @@ import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,15 +52,13 @@ public class TNTCommand extends SWCommand {
} }
@Register @Register
public void toggleCommand(Player p) { public void toggleCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
tntToggle(region, null, null); tntToggle(region, null, null);
} }
@Register @Register
public void setCommand(Player p, TNTMode tntMode) { public void setCommand(@Guard Player p, TNTMode tntMode) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
String requestedMessage = null; String requestedMessage = null;
@ -151,12 +147,17 @@ public class TNTCommand extends SWCommand {
} }
} }
private boolean permissionCheck(Player p) { @ClassGuard(value = Player.class, local = true)
if (!Permission.hasPermission(p, Permission.WORLD)) { public GuardChecker worldGuard() {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren"); return (commandSender, guardCheckType, strings, s) -> {
return false; Player player = (Player) commandSender;
} if (!Permission.hasPermission(player, Permission.WORLD)) {
return true; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("REGION_TNT_NO_PERMS", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
} }

Datei anzeigen

@ -27,9 +27,7 @@ import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -61,8 +59,7 @@ public class TestblockCommand extends SWCommand {
} }
@Register @Register
public void genericTestblockCommand(Player p, RegionExtensionType regionExtensionType) { public void genericTestblockCommand(@Guard Player p, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
try { try {
@ -85,8 +82,7 @@ public class TestblockCommand extends SWCommand {
} }
@Register @Register
public void schematicTestblockCommand(Player p, String s, RegionExtensionType regionExtensionType) { public void schematicTestblockCommand(@Guard Player p, String s, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p); Region region = regionCheck(p);
if (region == null) return; if (region == null) return;
Schematic schem = Schematic.getSchemFromDB(s, p.getUniqueId()); 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); return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
} }
private boolean permissionCheck(Player player) { @ClassGuard(value = Player.class, local = true)
if (Permission.hasPermission(player, Permission.WORLDEDIT)) { public GuardChecker worldGuard() {
return true; return (commandSender, guardCheckType, strings, s) -> {
} Player player = (Player) commandSender;
BauSystem.MESSAGE.send("REGION_TB_NO_PERMS", player); if (!Permission.hasPermission(player, Permission.WORLDEDIT)) {
return false; if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("REGION_TB_NO_PERMS", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
private Region regionCheck(Player player) { private Region regionCheck(Player player) {