SteamWar/BauSystem2.0
Archiviert
12
0

Add first guard stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-11-16 22:55:37 +01:00
Ursprung 157b787e41
Commit 5205b1fc93
5 geänderte Dateien mit 37 neuen und 33 gelöschten Zeilen

Datei anzeigen

@ -492,7 +492,7 @@ SCRIPT_COMMAND_VARS_SET_VALUE = {0} auf {1} gesetzt
SCRIPT_COMMAND_VARS_REMOVE_VALUE = Variable {0} gelöscht SCRIPT_COMMAND_VARS_REMOVE_VALUE = Variable {0} gelöscht
# Unsign Book # Unsign Book
UNSIGN_HELP_1=§8/§eunsign §8- §7Mache ein Buch beschreibbar UNSIGN_HELP=§8/§eunsign §8- §7Mache ein Buch beschreibbar
# Simulator # Simulator
SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator

Datei anzeigen

@ -25,9 +25,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.tags.Tag; import de.steamwar.bausystem.region.tags.Tag;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; import de.steamwar.inventory.SWListInv;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
@ -73,8 +71,7 @@ public class BackupCommand extends SWCommand {
} }
@Register("create") @Register("create")
public void backupCreate(Player p) { public void backupCreate(@Guard 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;
@ -91,8 +88,7 @@ public class BackupCommand extends SWCommand {
} }
@Register("load") @Register("load")
public void backupLoad(Player p, @Mapper("backupName") String backupName) { public void backupLoad(@Guard Player p, @Mapper("backupName") String backupName) {
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;
@ -147,6 +143,20 @@ public class BackupCommand extends SWCommand {
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender)); return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
} }
@ClassGuard(value = Player.class, local = true)
public GuardChecker backupGuard() {
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("BACKUP_NO_PERMS", player);
}
return GuardResult.DENIED;
};
}
private List<String> listBackup(Player p) { private List<String> listBackup(Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {

Datei anzeigen

@ -25,9 +25,7 @@ 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;
import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.LinkedInstance;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.BauweltMember; import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -59,18 +57,12 @@ public class BauCommand extends SWCommand {
} }
@Register("togglewe") @Register("togglewe")
public void toggleWECommand(Player p, SteamwarUser user) { public void toggleWECommand(@Guard Player p, SteamwarUser user) {
if (!permissionCheck(p)) {
return;
}
onToggleWE(p, user); onToggleWE(p, user);
} }
@Register("toggleworld") @Register("toggleworld")
public void toggleWorldCommand(Player p, SteamwarUser user) { public void toggleWorldCommand(@Guard Player p, SteamwarUser user) {
if (!permissionCheck(p)) {
return;
}
onToggleWorld(p, user); onToggleWorld(p, user);
} }
@ -116,17 +108,6 @@ public class BauCommand extends SWCommand {
return false; return false;
} }
private boolean permissionCheck(Player p) {
if (!bauServer.getOwner().equals(p.getUniqueId())) {
BauSystem.MESSAGE.send("BAU_NO-WORLD", p);
return false;
} else {
return true;
}
}
@ClassMapper(value = SteamwarUser.class, local = true) @ClassMapper(value = SteamwarUser.class, local = true)
private TypeMapper<SteamwarUser> steamwarUserTypeMapper() { private TypeMapper<SteamwarUser> steamwarUserTypeMapper() {
return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(bauServer.getOwnerID()) return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(bauServer.getOwnerID())
@ -146,4 +127,18 @@ public class BauCommand extends SWCommand {
.collect(Collectors.toList()); .collect(Collectors.toList());
}); });
} }
@ClassGuard(value = Player.class, local = true)
public GuardChecker bauGuard() {
return (commandSender, guardCheckType, strings, s) -> {
Player p = (Player) commandSender;
if (!bauServer.getOwner().equals(p.getUniqueId())) {
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("BAU_NO-WORLD", p);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
}
} }

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.ColorConfig;
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.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.linkage.specific.BauGuiItem;
@ -44,7 +43,7 @@ public class LoaderBauGuiItem extends BauGuiItem {
@Override @Override
public ItemStack getItem(Player player) { public ItemStack getItem(Player player) {
return new SWItem(Material.FLINT_AND_STEEL, ColorConfig.HIGHLIGHT + BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)).getItemStack(); return new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)).getItemStack();
} }
@Override @Override

Datei anzeigen

@ -38,7 +38,7 @@ public class UnsignCommand extends SWCommand {
@Register(help = true) @Register(help = true)
public void genericHelp(Player p, String... args) { public void genericHelp(Player p, String... args) {
BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", p, "Unsign"); BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", p, "Unsign");
BauSystem.MESSAGE.sendPrefixless("UNSIGN_HELP_1", p); BauSystem.MESSAGE.sendPrefixless("UNSIGN_HELP", p);
} }
@Register @Register