SteamWar/BauSystem2.0
Archiviert
12
0

Remove last guard checks
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-18 20:27:05 +02:00
Ursprung 028c115731
Commit b722d9ab0f
12 geänderte Dateien mit 88 neuen und 166 gelöschten Zeilen

Datei anzeigen

@ -1204,6 +1204,7 @@ SELECT_NO_EXTENSION = §cThis region has no extension
SELECT_MESSAGE = §7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5}
SKULL_HELP = §8/§eskull §8[§eplayer§8] §8-§7 Receive a player head
SKULL_INVALID = §cInvalid player name
SKULL_ITEM = §e{0}§8s Head
SPEED_HELP = §8/§espeed §8[§71§8-§710§8|§edefault§8] §8-§7 Set your flight and walking speed.

Datei anzeigen

@ -1184,6 +1184,7 @@ SELECT_NO_EXTENSION = §cDiese Region hat keine Ausfahrmaße
SELECT_MESSAGE = §7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt
SKULL_HELP = §8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf
SKULL_INVALID = §cUngültiger Spieler
SKULL_ITEM = §e{0}§8s Kopf
SPEED_HELP = §8/§espeed §8[§71§8-§710§8|§edefault§8] §8-§7 Setzte deine Flug- und Laufgeschindigkeit.

Datei anzeigen

@ -26,7 +26,9 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.command.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -41,13 +43,13 @@ public class SimulatorCommand extends SWCommand {
}
@Register(description = "SIMULATOR_HELP")
public void genericCommand(@Guard Player p) {
public void genericCommand(@Validator Player p) {
SimulatorCursor.hide(p, null);
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
}
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
public void change(@Guard Player p) {
public void change(@Validator Player p) {
ItemStack itemStack = p.getInventory().getItemInMainHand();
if (!ItemUtils.isItem(itemStack, "simulator")) {
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
@ -57,7 +59,7 @@ public class SimulatorCommand extends SWCommand {
}
@Register(value = "create", description = "SIMULATOR_CREATE_HELP")
public void create(@Guard Player p, String name) {
public void create(@Validator Player p, String name) {
createSimulator(p, name);
}
@ -76,7 +78,7 @@ public class SimulatorCommand extends SWCommand {
}
@Register(value = "delete", description = "SIMULATOR_DELETE_HELP")
public void delete(@Guard Player p, @Mapper("simulators") String name) {
public void delete(@Validator Player p, @Mapper("simulators") String name) {
if (!SimulatorStorage.getSimulatorNames().contains(name)) {
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
return;
@ -86,7 +88,7 @@ public class SimulatorCommand extends SWCommand {
}
@Register(value = "start", description = "SIMULATOR_START_HELP")
public void start(@Guard Player p, @Mapper("simulators") String name) {
public void start(@Validator Player p, @Mapper("simulators") String name) {
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(name);
if (tntSimulator == null) {
BauSystem.MESSAGE.send("SIMULATOR_NOT_EXISTS", p);
@ -114,17 +116,10 @@ public class SimulatorCommand extends SWCommand {
};
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker guardChecker() {
return (commandSender, guardCheckType, strings, s) -> {
Player player = (Player) commandSender;
if (Permission.hasPermission(player, Permission.WORLD)) {
return GuardResult.ALLOWED;
}
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("SIMULATOR_NO_PERMS", player);
}
return GuardResult.DENIED;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "SIMULATOR_NO_PERMS");
};
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -39,19 +40,8 @@ public class LaufbauCommand extends SWCommand {
super("laufbau", "laufsklave");
}
private boolean permissionCheck(Player player, Permission permission) {
if (Permission.hasPermission(player, permission)) {
return true;
}
BauSystem.MESSAGE.send("LAUFBAU_NO_PERM", player);
return false;
}
@Register(description = {"LAUFBAU_HELP", "LAUFBAU_PREPARE1", "LAUFBAU_PREPARE2"})
public void laufbauSelection(Player player, @StaticValue(value = {"smallest", "blastresistant"}, allowISE = true) boolean preferingBlastResistance) {
if (!permissionCheck(player, Permission.WORLDEDIT)) {
return;
}
public void laufbauSelection(@Validator Player player, @StaticValue(value = {"smallest", "blastresistant"}, allowISE = true) boolean preferingBlastResistance) {
Pair<Location, Location> selection = WorldEditUtils.getSelection(player);
if (selection == null) {
BauSystem.MESSAGE.send("LAUFBAU_NO_WORLDEDIT", player);
@ -84,10 +74,14 @@ public class LaufbauCommand extends SWCommand {
}
@Register(value = "settings", description = "LAUFBAU_HELP_SETTINGS")
public void laufbauSettings(Player player) {
if (!permissionCheck(player, Permission.WORLDEDIT)) {
return;
}
public void laufbauSettings(@Validator Player player) {
new LaufbauSettings(player);
}
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "LAUFBAU_NO_PERM");
};
}
}

Datei anzeigen

@ -26,7 +26,9 @@ import de.steamwar.bausystem.features.slaves.WorldEditUtils;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.command.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -52,7 +54,7 @@ public class PanzernCommand extends SWCommand {
}
@Register
public void panzerSelection(@Guard Player player, @Mapper("block") Material blockMaterial, @Mapper("slab") Material slabMaterial) {
public void panzerSelection(@Validator Player player, @Mapper("block") Material blockMaterial, @Mapper("slab") Material slabMaterial) {
Pair<Location, Location> selection = WorldEditUtils.getSelection(player);
if (selection == null) {
BauSystem.MESSAGE.send("PANZERN_NO_WORLDEDIT", player);
@ -88,17 +90,10 @@ public class PanzernCommand extends SWCommand {
}.runTaskTimer(BauSystem.getInstance(), 1, 1);
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker guardChecker() {
return (commandSender, guardCheckType, strings, s) -> {
Player player = (Player) commandSender;
if (Permission.hasPermission(player, Permission.WORLDEDIT)) {
return GuardResult.ALLOWED;
}
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("PANZERN_NO_PERM", player);
}
return GuardResult.DENIED;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "PANZERN_NO_PERM");
};
}

Datei anzeigen

@ -34,7 +34,9 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.ListChatView;
import de.steamwar.command.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import lombok.AllArgsConstructor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
@ -104,13 +106,13 @@ public class TraceCommand extends SWCommand {
}
@Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI")
public void guiCommand(@Guard Player p) {
public void guiCommand(@Validator Player p) {
TraceGui.openGui(p);
}
@Register(value = {"record", "list"})
@Register(value = {"list"}, description = "TRACE_COMMAND_HELP_LIST")
public void listCommand(@Guard Player player, @OptionalValue("0") int page) {
public void listCommand(@Validator Player player, @OptionalValue("0") int page) {
ListChatView.chatView(player, StoredRecords.getRecords(), page, record -> {
TextComponent component = new TextComponent();
component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT", player, record.size()));
@ -133,13 +135,13 @@ public class TraceCommand extends SWCommand {
}
@Register(value = {"record", "delete"}, noTabComplete = true)
public void recordDelete(@Guard Player p, int id) {
public void recordDelete(@Validator Player p, int id) {
StoredRecords.remove(id);
BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p);
}
@Register(value = "record", noTabComplete = true)
public void recordList(@Guard Player player, int recordID, @OptionalValue("0") int page) {
public void recordList(@Validator Player player, int recordID, @OptionalValue("0") int page) {
Record traceRecord = StoredRecords.get(recordID);
if (traceRecord == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -167,7 +169,7 @@ public class TraceCommand extends SWCommand {
}
@Register(value = {"record", "tnt", "delete"}, noTabComplete = true)
public void deleteRecordTNT(@Guard Player player, int recordID, int tntID) {
public void deleteRecordTNT(@Validator Player player, int recordID, int tntID) {
Record record = StoredRecords.get(recordID);
if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -178,7 +180,7 @@ public class TraceCommand extends SWCommand {
}
@Register(value = "record", noTabComplete = true)
public void recordTNTPositions(@Guard Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @OptionalValue("0") int page) {
public void recordTNTPositions(@Validator Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @OptionalValue("0") int page) {
Record record = StoredRecords.get(recordID);
if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -205,7 +207,7 @@ public class TraceCommand extends SWCommand {
}
@Register(value = "record", noTabComplete = true)
public void recordTNTPositions(@Guard Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @StaticValue("fuse") String fuse, int fuseTicks) {
public void recordTNTPositions(@Validator Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @StaticValue("fuse") String fuse, int fuseTicks) {
Record record = StoredRecords.get(recordID);
if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -229,39 +231,39 @@ public class TraceCommand extends SWCommand {
}
@Register(value = {"start"}, description = "TRACE_COMMAND_HELP_START")
public void startCommand(@Guard Player p) {
public void startCommand(@Validator Player p) {
RecordStateMachine.commandStart();
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p);
}
@Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE")
public void singleCommand(@Guard Player p) {
public void singleCommand(@Validator Player p) {
RecordStateMachine.commandSingle();
BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p);
}
@Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP")
public void stopCommand(@Guard Player p) {
public void stopCommand(@Validator Player p) {
RecordStateMachine.commandStop();
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p);
}
@Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO")
@Register({"toggleauto"})
public void autoCommand(@Guard Player p) {
public void autoCommand(@Validator Player p) {
RecordStateMachine.commandAuto();
BauSystem.MESSAGE.send(RecordStateMachine.getRecordStatus().getAutoMessage(), p);
}
@Register(value = {"delete"}, description = "TRACE_COMMAND_HELP_DELETE")
@Register({"clear"})
public void deleteCommand(@Guard Player p) {
public void deleteCommand(@Validator Player p) {
StoredRecords.clear();
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p);
}
@Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW")
public void showCommand(@Guard Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) {
public void showCommand(@Validator Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) {
ShowModeParameter showModeParameter = new ShowModeParameter();
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
@ -282,27 +284,20 @@ public class TraceCommand extends SWCommand {
}
@Register(value = {"show", "gui"}, description = "TRACE_COMMAND_HELP_SHOW_GUI")
public void showGuiCommand(@Guard Player p) {
public void showGuiCommand(@Validator Player p) {
TraceShowGui.openGui(p);
}
@Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE")
public void hideCommand(@Guard Player p) {
public void hideCommand(@Validator Player p) {
TraceShowManager.hide(p);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p);
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker guardChecker() {
return (commandSender, guardCheckType, strings, s) -> {
Player player = (Player) commandSender;
if (Permission.hasPermission(player, Permission.WORLD)) {
return GuardResult.ALLOWED;
}
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("TRACE_MESSAGE_DISALLOWED", player);
}
return GuardResult.DENIED;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "TRACE_MESSAGE_DISALLOWED");
};
}
}

Datei anzeigen

@ -23,10 +23,8 @@ 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 de.steamwar.command.TypeValidator;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -45,23 +43,16 @@ public class ClearCommand extends SWCommand {
}
@Register(description = "OTHER_CLEAR_HELP_PLAYER")
public void clearPlayerCommand(@Guard Player p, Player target) {
public void clearPlayerCommand(@Validator Player p, Player target) {
clear(target);
BauSystem.MESSAGE.send("OTHER_CLEAR_FROM", target, p.getName());
BauSystem.MESSAGE.send("OTHER_CLEAR_TO", p, target.getName());
}
@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;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "OTHER_CLEAR_NO_PERMS");
};
}

Datei anzeigen

@ -9,10 +9,8 @@ import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import org.bukkit.entity.Player;
@Linked(LinkageType.COMMAND)
@ -23,7 +21,7 @@ public class SelectCommand extends SWCommand {
}
@Register(description = {"SELECT_HELP", "SELECT_EXTENSION_HELP"})
public void baurahmenCommand(@Guard Player p, RegionType regionType, @OptionalValue("NORMAL") RegionExtensionType regionExtensionType) {
public void baurahmenCommand(@Validator Player p, RegionType regionType, @OptionalValue("NORMAL") RegionExtensionType regionExtensionType) {
Region region = Region.getRegion(p.getLocation());
if (region.isGlobal()) {
@ -43,17 +41,10 @@ public class SelectCommand extends SWCommand {
setSelection(regionType, regionExtensionType, region, p);
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker guardChecker() {
return (commandSender, guardCheckType, strings, s) -> {
Player player = (Player) commandSender;
if (Permission.hasPermission(player, Permission.WORLDEDIT)) {
return GuardResult.ALLOWED;
}
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("SELECT_NO_PERMS", player);
}
return GuardResult.DENIED;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "SELECT_NO_PERMS");
};
}

Datei anzeigen

@ -43,8 +43,7 @@ public class SkullCommand extends SWCommand {
}
@Register(description = "SKULL_HELP")
public void giveCommand(Player p, @Mapper("player") String skull) {
// TODO: Add message to invalid Skulls!
public void giveCommand(Player p, @Mapper("player") @ErrorMessage("SKULL_INVALID") String skull) {
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
SkullMeta sm = (SkullMeta) is.getItemMeta();
assert sm != null;

Datei anzeigen

@ -40,32 +40,14 @@ public class TimeCommand extends SWCommand {
addDefaultHelpMessage("OTHER_TIME_HELP");
}
// TODO: Add set as OptionalValue
@Register
public void genericCommand(@Guard Player p, Time time) {
public void genericCommand(@Validator Player p, @OptionalValue("") @StaticValue({"set", ""}) String set, Time time) {
Bukkit.getWorlds().get(0).setTime(time.getValue());
BauSystem.MESSAGE.send("OTHER_TIME_RESULT", p);
}
@Register
public void genericCommand(@Guard Player p, @StaticValue(value = "set") String set, Time time) {
Bukkit.getWorlds().get(0).setTime(time.getValue());
BauSystem.MESSAGE.send("OTHER_TIME_RESULT", p);
}
// TODO: Add set as OptionalValue
@Register
public void genericCommand(@Guard Player p, int time) {
if (time < 0 || time > 24000) {
BauSystem.MESSAGE.send("OTHER_TIME_INVALID", p);
return;
}
Bukkit.getWorlds().get(0).setTime(time);
BauSystem.MESSAGE.send("OTHER_TIME_RESULT", p);
}
@Register
public void genericCommand(@Guard Player p, @StaticValue(value = "set") String set, int time) {
public void genericCommand(@Validator Player p, @OptionalValue("") @StaticValue({"set", ""}) String set, int time) {
if (time < 0 || time > 24000) {
BauSystem.MESSAGE.send("OTHER_TIME_INVALID", p);
return;
@ -85,17 +67,10 @@ 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;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "OTHER_TIME_NO_PERM");
};
}

Datei anzeigen

@ -58,7 +58,7 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
@Register(value = "add", description = "WARP_HELP_ADD")
@Register("create")
public void addWarp(@Guard Player player, String name) {
public void addWarp(@Validator Player player, String name) {
for (String forbiddenName : FORBIDDEN_NAMES) {
if (name.equalsIgnoreCase(forbiddenName)) {
BauSystem.MESSAGE.send("WARP_NAME_RESERVED", player, name);
@ -79,7 +79,7 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
}
@Register(value = "delete", description = "WARP_HELP_DELETE")
public void deleteWarp(@Guard Player player, Warp warp) {
public void deleteWarp(@Validator Player player, Warp warp) {
warp.delete();
BauSystem.MESSAGE.send("WARP_DELETED", player, warp.getName());
}
@ -122,17 +122,10 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation()));
}
@ClassGuard(value = Player.class, local = true)
public GuardChecker commandGuard() {
return (commandSender, guardCheckType, strings, s) -> {
Player player = (Player) commandSender;
if (!Permission.hasPermission(player, Permission.WORLD)) {
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("WARP_DISALLOWED", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "WARP_DISALLOWED");
};
}

Datei anzeigen

@ -24,10 +24,8 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
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 de.steamwar.command.TypeValidator;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -41,29 +39,23 @@ public class StopCommand extends SWCommand {
}
@Register(description = "STOP_HELP")
public void genericCommand(@Guard CommandSender sender) {
public void genericCommand(@Validator CommandSender sender) {
SWUtils.message(current -> BauSystem.MESSAGE.parsePrefixed("STOP_MESSAGE", current));
Bukkit.getServer().shutdown();
}
@ClassGuard(value = CommandSender.class, local = true)
public GuardChecker stopGuard() {
return (commandSender, guardCheckType, strings, s) -> {
if (!(commandSender instanceof Player)) {
return GuardResult.ALLOWED;
}
Player player = (Player) commandSender;
@ClassMapper(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
if (Permission.hasPermission(player, Permission.WORLD)) {
return GuardResult.ALLOWED;
return true;
}
SteamwarUser steamwarUser = SteamwarUser.get(player);
if (steamwarUser.getUserGroup().isAdminGroup()) {
return GuardResult.ALLOWED;
return true;
}
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("STOP_NO_PERMS", player);
}
return GuardResult.DENIED;
messageSender.send("STOP_NO_PERMS");
return false;
};
}
}