SteamWar/BauSystem2.0
Archiviert
12
0

Adjusted more permissions
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
D4rkr34lm 2023-12-16 15:53:02 +01:00
Ursprung 37e6628aaa
Commit 3dddb48d0c
68 geänderte Dateien mit 107 neuen und 205 gelöschten Zeilen

Datei anzeigen

@ -44,7 +44,7 @@ public class AttributeRemoveCommand extends SWCommand {
@Register({"all"}) @Register({"all"})
@Register({"*"}) @Register({"*"})
public void genericCommand(Player player) { public void genericCommand(@Validator Player player) {
ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setLore(new ArrayList<>()); itemMeta.setLore(new ArrayList<>());
@ -53,7 +53,7 @@ public class AttributeRemoveCommand extends SWCommand {
} }
@Register(description = "ATTRIBUTE_REMOVE_COMMAND_HELP") @Register(description = "ATTRIBUTE_REMOVE_COMMAND_HELP")
public void genericCommand(Player player, @Mapper("attribute") String attribute) { public void genericCommand(@Validator Player player, @Mapper("attribute") String attribute) {
ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) { if (itemMeta == null) {

Datei anzeigen

@ -41,7 +41,7 @@ public class AttributesCopyCommand extends SWCommand {
} }
@Register @Register
public void genericCommand(Player player) { public void genericCommand(@Validator Player player) {
Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS); Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS);
if (block == null) return; if (block == null) return;
ItemStack mainHand = player.getInventory().getItemInMainHand(); ItemStack mainHand = player.getInventory().getItemInMainHand();

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.attributescopy; package de.steamwar.bausystem.features.attributescopy;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -40,6 +41,7 @@ public class AttributesPlaceListener implements Listener {
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ItemStack itemStack = event.getItemInHand(); ItemStack itemStack = event.getItemInHand();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null) return; if (itemMeta == null) return;

Datei anzeigen

@ -32,7 +32,7 @@ public class AutoStartCommand extends SWCommand {
} }
@Register(description = "AUTOSTART_COMMAND_HELP") @Register(description = "AUTOSTART_COMMAND_HELP")
public void genericCommand(Player p) { public void genericCommand(@Validator Player p) {
SWUtils.giveItemToPlayer(p, AutostartListener.getWandItem(p)); SWUtils.giveItemToPlayer(p, AutostartListener.getWandItem(p));
} }
} }

Datei anzeigen

@ -50,6 +50,6 @@ public class AutoStartGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.MEMBER; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.autostart; package de.steamwar.bausystem.features.autostart;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
@ -66,6 +67,7 @@ public class AutostartListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!ItemUtils.isItem(event.getItem(), "autostart")) { if (!ItemUtils.isItem(event.getItem(), "autostart")) {
return; return;
} }
@ -83,6 +85,7 @@ public class AutostartListener implements Listener {
if (!(event.getPlayer() instanceof Player)) { if (!(event.getPlayer() instanceof Player)) {
return; return;
} }
if(!Permission.BUILD.hasPermission((Player) event.getPlayer())) return;
if (!ItemUtils.isItem(event.getPlayer().getInventory().getItemInMainHand(), "autostart")) { if (!ItemUtils.isItem(event.getPlayer().getInventory().getItemInMainHand(), "autostart")) {
return; return;
} }

Datei anzeigen

@ -140,13 +140,6 @@ 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));
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> backupValidator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "BACKUP_NO_PERMS");
};
}
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

@ -45,7 +45,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
private Map<Region, DesignEndStone> designEndStoneMap = new HashMap<>(); private Map<Region, DesignEndStone> designEndStoneMap = new HashMap<>();
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP") @Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
public void genericCommand(Player player) { public void genericCommand(@Validator Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (!region.hasType(RegionType.BUILD)) { if (!region.hasType(RegionType.BUILD)) {
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);

Datei anzeigen

@ -47,6 +47,6 @@ public class DetonatorBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.MEMBER; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -58,12 +58,12 @@ public class DetonatorCommand extends SWCommand {
} }
@Register(value = "wand", description = "DETONATOR_HELP_WAND") @Register(value = "wand", description = "DETONATOR_HELP_WAND")
public void giveWand(Player p) { public void giveWand(@Validator Player p) {
SWUtils.giveItemToPlayer(p, getWAND(p)); SWUtils.giveItemToPlayer(p, getWAND(p));
} }
@Register(value = "click", description = "DETONATOR_HELP_CLICK") @Register(value = "click", description = "DETONATOR_HELP_CLICK")
public void clickDetonator(Player p) { public void clickDetonator(@Validator Player p) {
Detonator.activateDetonator(new ItemStorage(p)); Detonator.activateDetonator(new ItemStorage(p));
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.detonator; package de.steamwar.bausystem.features.detonator;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
import de.steamwar.bausystem.features.detonator.storage.ItemStorage; import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
@ -65,6 +66,7 @@ public class DetonatorListener implements Listener {
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
Player p = event.getPlayer(); Player p = event.getPlayer();
if (Detonator.isDetonator(p.getInventory().getItemInMainHand())) { if (Detonator.isDetonator(p.getInventory().getItemInMainHand())) {
event.setCancelled(true); event.setCancelled(true);
@ -75,6 +77,7 @@ public class DetonatorListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Detonator.isDetonator(event.getItem())) { if (!Detonator.isDetonator(event.getItem())) {
return; return;
} }
@ -89,6 +92,7 @@ public class DetonatorListener implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) { if (!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
if (Detonator.hasActiveDetonatorShow(event.getPlayer())) { if (Detonator.hasActiveDetonatorShow(event.getPlayer())) {
Detonator.hideDetonator(event.getPlayer()); Detonator.hideDetonator(event.getPlayer());
@ -110,6 +114,7 @@ public class DetonatorListener implements Listener {
@EventHandler @EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) { public void onPlayerItemHeld(PlayerItemHeldEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) { if (Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
HAS_UPDATED.add(event.getPlayer()); HAS_UPDATED.add(event.getPlayer());
} }
@ -117,6 +122,7 @@ public class DetonatorListener implements Listener {
@EventHandler @EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem())) { if (Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem())) {
HAS_UPDATED.add(event.getPlayer()); HAS_UPDATED.add(event.getPlayer());
} }

Datei anzeigen

@ -35,7 +35,7 @@ public class HotbarCommand extends SWCommand {
} }
@Register(value = "load", description = "HOTBAR_HELP_LOAD") @Register(value = "load", description = "HOTBAR_HELP_LOAD")
public void loadHotbar(Player p) { public void loadHotbar(@Validator Player p) {
DefaultHotbar.setHotbar(p); DefaultHotbar.setHotbar(p);
BauSystem.MESSAGE.send("HOTBAR_LOADED", p); BauSystem.MESSAGE.send("HOTBAR_LOADED", p);
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.features.hotbar; package de.steamwar.bausystem.features.hotbar;
import de.steamwar.bausystem.Permission;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -30,6 +31,7 @@ public class HotbarListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (allNull(event.getPlayer().getInventory().getContents()) && allNull(event.getPlayer().getInventory().getArmorContents())) { if (allNull(event.getPlayer().getInventory().getContents()) && allNull(event.getPlayer().getInventory().getArmorContents())) {
DefaultHotbar.setHotbar(event.getPlayer()); DefaultHotbar.setHotbar(event.getPlayer());
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.inventoryfiller; package de.steamwar.bausystem.features.inventoryfiller;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
@ -38,6 +39,7 @@ public class InventoryFiller implements Listener {
@EventHandler @EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) { public void onPlayerDropItem(PlayerDropItemEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
if (!event.getPlayer().isSneaking()) return; if (!event.getPlayer().isSneaking()) return;
Block block = event.getPlayer().getTargetBlockExact(5); Block block = event.getPlayer().getTargetBlockExact(5);
@ -59,6 +61,7 @@ public class InventoryFiller implements Listener {
*/ */
@EventHandler @EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) { public void onPlayerItemHeld(PlayerItemHeldEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return;
if (!event.getPlayer().isSneaking()) return; if (!event.getPlayer().isSneaking()) return;
ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand(); ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand();

Datei anzeigen

@ -54,7 +54,7 @@ public class KillcheckerCommand extends SWCommand implements Listener {
} }
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE") @Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
public void genericCommand(Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) { public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService)); KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
killcheckerVisualizer.recalc(); killcheckerVisualizer.recalc();

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.loader; 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.features.loader.elements.LoaderElement; import de.steamwar.bausystem.features.loader.elements.LoaderElement;
import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement; import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT; import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
@ -70,6 +71,7 @@ public class Loader implements Listener {
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
if (stage != Stage.RUNNING) return; if (stage != Stage.RUNNING) return;
if(!Permission.BUILD.hasPermission(p)) return;
if (waitTime > 0) { if (waitTime > 0) {
waitTime--; waitTime--;
return; return;

Datei anzeigen

@ -101,11 +101,4 @@ public class LoaderCommand extends SWCommand {
BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay); BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay);
loader.setTicksBetweenBlocks(delay); loader.setTicksBetweenBlocks(delay);
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> loaderValidator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "LOADER_PERMS");
};
}
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.loader; 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.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
@ -40,6 +41,7 @@ public class LoaderScoreboardElement implements ScoreboardElement {
@Override @Override
public String get(Region region, Player p) { public String get(Region region, Player p) {
if(!Permission.BUILD.hasPermission(p)) return null;
Loader loader = Loader.getLoader(p); Loader loader = Loader.getLoader(p);
if (loader == null) return null; if (loader == null) return null;
if (loader.getStage() == Loader.Stage.RUNNING) { if (loader.getStage() == Loader.Stage.RUNNING) {

Datei anzeigen

@ -32,12 +32,12 @@ public class LoadtimerCommand extends SWCommand {
} }
@Register(value = "start", description = "LOADTIMER_HELP_START_1") @Register(value = "start", description = "LOADTIMER_HELP_START_1")
public void start(Player p) { public void start(@Validator Player p) {
start(p, TimerMode.HALF); start(p, TimerMode.HALF);
} }
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"}) @Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
public void start(Player p, TimerMode mode) { public void start(@Validator Player p, TimerMode mode) {
Region r = Region.getRegion(p.getLocation()); Region r = Region.getRegion(p.getLocation());
if (r.isGlobal()) return; if (r.isGlobal()) return;
if (!Loadtimer.hasTimer(r)) if (!Loadtimer.hasTimer(r))
@ -45,7 +45,7 @@ public class LoadtimerCommand extends SWCommand {
} }
@Register(value = "stop", description = "LOADTIMER_HELP_STOP") @Register(value = "stop", description = "LOADTIMER_HELP_STOP")
public void stop(Player p) { public void stop(@Validator Player p) {
Region r = Region.getRegion(p.getLocation()); Region r = Region.getRegion(p.getLocation());
if (r.isGlobal()) return; if (r.isGlobal()) return;
if (Loadtimer.hasTimer(r)) if (Loadtimer.hasTimer(r))

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.observer; package de.steamwar.bausystem.features.observer;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -52,7 +53,7 @@ public class ObserverTracerCommand extends SWCommand {
} }
@Register(value = "retrace", description = "OBSERVER_HELP_RETRACE") @Register(value = "retrace", description = "OBSERVER_HELP_RETRACE")
public void retrace(Player p) { public void retrace(@Validator Player p) {
if (ObserverTracerListener.observerTracerMap.containsKey(p)) { if (ObserverTracerListener.observerTracerMap.containsKey(p)) {
BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO_TRACE", p); BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO_TRACE", p);
return; return;

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.observer; package de.steamwar.bausystem.features.observer;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -55,6 +56,7 @@ public class ObserverTracerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!enabled.contains(event.getPlayer())) { if (!enabled.contains(event.getPlayer())) {
return; return;
} }

Datei anzeigen

@ -85,7 +85,7 @@ public class ColorCommand extends SWCommand {
@ClassValidator(value = Player.class, local = true) @ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() { public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> { return (commandSender, player, messageSender) -> {
return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "REGION_COLOR_NO_PERMS"); return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "NO_PERMISSION");
}; };
} }

Datei anzeigen

@ -46,10 +46,6 @@ public class FireCommand extends SWCommand {
} }
} }
private String getNoPermMessage() {
return "REGION_FIRE_NO_PERMS";
}
private String getEnableMessage() { private String getEnableMessage() {
return "REGION_FIRE_ENABLED"; return "REGION_FIRE_ENABLED";
} }
@ -69,11 +65,4 @@ public class FireCommand extends SWCommand {
return false; return false;
} }
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
};
}
} }

Datei anzeigen

@ -46,10 +46,6 @@ public class FreezeCommand extends SWCommand {
} }
} }
private String getNoPermMessage() {
return "REGION_FREEZE_NO_PERMS";
}
private String getEnableMessage(){ private String getEnableMessage(){
return "REGION_FREEZE_ENABLED"; return "REGION_FREEZE_ENABLED";
} }
@ -69,11 +65,4 @@ public class FreezeCommand extends SWCommand {
return true; return true;
} }
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
};
}
} }

Datei anzeigen

@ -49,10 +49,6 @@ public class ItemsCommand extends SWCommand {
} }
} }
private String getNoPermMessage() {
return "REGION_ITEMS_NO_PERMS";
}
private String getEnableMessage(){ private String getEnableMessage(){
return "REGION_ITEMS_ENABLED"; return "REGION_ITEMS_ENABLED";
} }
@ -72,11 +68,4 @@ public class ItemsCommand extends SWCommand {
return true; return true;
} }
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage());
};
}
} }

Datei anzeigen

@ -54,13 +54,6 @@ public class ProtectCommand extends SWCommand {
} }
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_PROTECT_NO_PERMS");
};
}
private Region regionCheck(Player player) { private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region.getFloorLevel() == 0) { if (region.getFloorLevel() == 0) {

Datei anzeigen

@ -71,7 +71,7 @@ public class RegionCommand extends SWCommand {
} }
@Register(value = "undo", description = "REGION_REGION_HELP_UNDO") @Register(value = "undo", description = "REGION_REGION_HELP_UNDO")
public void undoCommand(@Validator("WORLD_EDIT") Player p) { public void undoCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return; if (checkGlobalRegion(region, p)) return;
@ -83,7 +83,7 @@ public class RegionCommand extends SWCommand {
} }
@Register(value = "redo", description = "REGION_REGION_HELP_REDO") @Register(value = "redo", description = "REGION_REGION_HELP_REDO")
public void redoCommand(@Validator("WORLD_EDIT") Player p) { public void redoCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
@ -97,7 +97,7 @@ public class RegionCommand extends SWCommand {
} }
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE") @Register(value = "restore", description = "REGION_REGION_HELP_RESTORE")
public void genericRestoreCommand(@Validator("WORLD_EDIT") Player p) { public void genericRestoreCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return; if(checkGlobalRegion(region, p)) return;
@ -114,7 +114,7 @@ public class RegionCommand extends SWCommand {
} }
@Register(value = "restore", description = "REGION_REGION_HELP_RESTORE_SCHEMATIC") @Register(value = "restore", description = "REGION_REGION_HELP_RESTORE_SCHEMATIC")
public void schematicRestoreCommand(@Validator("WORLD_EDIT") Player p, SchematicNode node) { public void schematicRestoreCommand(@Validator Player p, SchematicNode node) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return; if (checkGlobalRegion(region, p)) return;
@ -176,7 +176,7 @@ public class RegionCommand extends SWCommand {
@Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE") @Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE")
@Register("type") @Register("type")
public void changeTypeCommand(@Validator("WORLD") Player p, @Mapper("regionTypeMapper") String s) { public void changeTypeCommand(@Validator Player p, @Mapper("regionTypeMapper") String s) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
@ -210,7 +210,7 @@ public class RegionCommand extends SWCommand {
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN") @Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN")
@Register("skin") @Register("skin")
public void changeSkinCommand(@Validator("WORLD") Player p, @Mapper("skinTypeMapper") String s) { public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") String s) {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
@ -266,18 +266,4 @@ public class RegionCommand extends SWCommand {
} }
}; };
} }
@Validator(value = "WORLD", local = true)
public TypeValidator<Player> worldValidator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_REGION_NO_PERMS");
};
}
@Validator(value = "WORLD_EDIT", local = true)
public TypeValidator<Player> worldEditValidator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_REGION_NO_PERMS");
};
}
} }

Datei anzeigen

@ -97,13 +97,6 @@ public class ResetCommand extends SWCommand {
} }
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_RESET_NO_PERMS");
};
}
private Region regionCheck(Player player) { private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region == GlobalRegion.getInstance()) { if (region == GlobalRegion.getInstance()) {

Datei anzeigen

@ -157,11 +157,4 @@ public class TNTCommand extends SWCommand {
break; break;
} }
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_TNT_NO_PERMS");
};
}
} }

Datei anzeigen

@ -157,11 +157,6 @@ public class TestblockCommand extends SWCommand {
}; };
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_TB_NO_PERMS");
}
private Region regionCheck(Player player) { private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (!region.hasType(RegionType.TESTBLOCK)) { if (!region.hasType(RegionType.TESTBLOCK)) {

Datei anzeigen

@ -57,6 +57,6 @@ public class FireBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLD; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -57,6 +57,6 @@ public class FreezeBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLD; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -58,6 +58,6 @@ public class ProtectBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLDEDIT; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -65,6 +65,6 @@ public class ResetBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLDEDIT; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -64,6 +64,6 @@ public class TestblockBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLDEDIT; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -116,6 +116,6 @@ public class TntBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLD; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -31,7 +31,7 @@ public class ScriptCommand extends SWCommand {
} }
@Register @Register
public void genericCommand(Player player) { public void genericCommand(@Validator Player player) {
ScriptGUI.open(player); ScriptGUI.open(player);
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.features.script; package de.steamwar.bausystem.features.script;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -42,6 +43,8 @@ public class ScriptListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) { public void onLeftClick(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ItemStack item = event.getItem(); ItemStack item = event.getItem();
if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) { if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) {
return; return;
@ -68,6 +71,7 @@ public class ScriptListener implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.updateGlobalScript(event.getPlayer()); ScriptRunner.updateGlobalScript(event.getPlayer());
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem.features.script.event; package de.steamwar.bausystem.features.script.event;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,6 +42,7 @@ public class CommandListener implements Listener {
@EventHandler @EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
String[] split = event.getMessage().split(" "); String[] split = event.getMessage().split(" ");
if (calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).contains(split[0])) { if (calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).contains(split[0])) {
return; return;

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.script.event; package de.steamwar.bausystem.features.script.event;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin; import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
import de.steamwar.bausystem.features.script.lua.libs.StorageLib; import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
@ -64,17 +65,20 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL, event); ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL, event);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
StorageLib.removePlayer(event.getPlayer()); StorageLib.removePlayer(event.getPlayer());
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event); ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (LAST_FS.containsKey(event.getPlayer())) { if (LAST_FS.containsKey(event.getPlayer())) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL, event); ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL, event);
@ -86,6 +90,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
LuaTable table = new LuaTable(); LuaTable table = new LuaTable();
table.set("x", event.getBlock().getX()); table.set("x", event.getBlock().getX());
table.set("y", event.getBlock().getY()); table.set("y", event.getBlock().getY());
@ -96,6 +101,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
LuaTable table = new LuaTable(); LuaTable table = new LuaTable();
table.set("x", event.getBlock().getX()); table.set("x", event.getBlock().getX());
table.set("y", event.getBlock().getY()); table.set("y", event.getBlock().getY());
@ -108,6 +114,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (ignore.remove(event.getPlayer())) { if (ignore.remove(event.getPlayer())) {
return; return;
} }
@ -144,6 +151,7 @@ public class EventListener implements Listener {
Region tntRegion = Region.getRegion(event.getLocation()); Region tntRegion = Region.getRegion(event.getLocation());
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue;
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
} }
@ -165,6 +173,7 @@ public class EventListener implements Listener {
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue;
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
if (inBuild) { if (inBuild) {
@ -176,6 +185,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onPlayerDropItem(PlayerDropItemEvent event) { public void onPlayerDropItem(PlayerDropItemEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ignore.add(event.getPlayer()); ignore.add(event.getPlayer());
LuaTable table = new LuaTable(); LuaTable table = new LuaTable();
table.set("type", event.getItemDrop().getItemStack().getType().name()); table.set("type", event.getItemDrop().getItemStack().getType().name());
@ -185,6 +195,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue;
LuaTable table = new LuaTable(); LuaTable table = new LuaTable();
table.set("type", event.getEntityType().name()); table.set("type", event.getEntityType().name());
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.EntityDeath, table, event); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.EntityDeath, table, event);

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.script.event; package de.steamwar.bausystem.features.script.event;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Plain; import de.steamwar.linkage.api.Plain;
@ -36,6 +37,7 @@ public class HotkeyListener implements PluginMessageListener, Plain {
@Override @Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) { public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if(!Permission.BUILD.hasPermission(player)) return;
if (!channel.equals("sw:hotkeys")) return; if (!channel.equals("sw:hotkeys")) return;
if (message.length < 5) return; if (message.length < 5) return;
int action = message[4] & 0xFF; int action = message[4] & 0xFF;

Datei anzeigen

@ -108,8 +108,8 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
@ClassValidator(value = Player.class, local = true) @ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() { public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> { return (commandSender, player, messageSender) -> {
if (!Permission.hasPermission(player, Permission.WORLD)) { if (!Permission.BUILD.hasPermission(player)) {
messageSender.send("SHIELD_PRINTING_DISALLOWED", player); messageSender.send("NO_PERMISSION", player);
return false; return false;
} }
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
@ -123,6 +123,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (event.getClickedBlock() == null) { if (event.getClickedBlock() == null) {
return; return;
} }

Datei anzeigen

@ -102,11 +102,4 @@ public class SimulatorCommand extends SWCommand {
} }
}; };
} }
@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

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement; import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
@ -148,6 +149,7 @@ public class SimulatorCursor implements Listener {
} }
return; return;
} }
if(!Permission.BUILD.hasPermission(player)) return;
Simulator simulator = SimulatorStorage.getSimulator(player); Simulator simulator = SimulatorStorage.getSimulator(player);
SimulatorWatcher.show(simulator, player); SimulatorWatcher.show(simulator, player);

Datei anzeigen

@ -78,11 +78,4 @@ public class LaufbauCommand extends SWCommand {
public void laufbauSettings(@Validator Player player) { public void laufbauSettings(@Validator Player player) {
new LaufbauSettings(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

@ -91,13 +91,6 @@ public class PanzernCommand extends SWCommand {
}.runTaskTimer(BauSystem.getInstance(), 1, 1); }.runTaskTimer(BauSystem.getInstance(), 1, 1);
} }
@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");
};
}
@Mapper(value = "block", local = true) @Mapper(value = "block", local = true)
private TypeMapper<Material> blockMapper() { private TypeMapper<Material> blockMapper() {
Set<String> strings = new HashSet<>(); Set<String> strings = new HashSet<>();

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.smartplace;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
@ -90,6 +91,7 @@ public class SmartPlaceListener implements Plain, Listener {
public SmartPlaceListener() { public SmartPlaceListener() {
TinyProtocol.instance.addFilter(useItem, (player, packet) -> { TinyProtocol.instance.addFilter(useItem, (player, packet) -> {
if(!Permission.BUILD.hasPermission(player)) return packet;
if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet; if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet;
Block block = player.getTargetBlockExact(6); Block block = player.getTargetBlockExact(6);
boolean shouldSneak = !(block != null && (block.getType().isInteractable() || block.getType() == Material.NOTE_BLOCK) && !CONTAINERS.contains(block.getType()) && !IGNORED.contains(block.getType())); boolean shouldSneak = !(block != null && (block.getType().isInteractable() || block.getType() == Material.NOTE_BLOCK) && !CONTAINERS.contains(block.getType()) && !IGNORED.contains(block.getType()));
@ -116,6 +118,7 @@ public class SmartPlaceListener implements Plain, Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
WAS_EXECUTED.add(event.getPlayer()); WAS_EXECUTED.add(event.getPlayer());
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
@ -134,6 +137,7 @@ public class SmartPlaceListener implements Plain, Listener {
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
if (!SMART_PLACING.contains(event.getPlayer())) { if (!SMART_PLACING.contains(event.getPlayer())) {
if (CONTAINERS.contains(event.getBlockAgainst().getType())) { if (CONTAINERS.contains(event.getBlockAgainst().getType())) {

Datei anzeigen

@ -55,7 +55,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
public XrayCommand xrayCommand; public XrayCommand xrayCommand;
@Register(description = "TECHHIDER_HELP") @Register(description = "TECHHIDER_HELP")
public void toggleHider(Player player) { public void toggleHider(@Validator Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) { if (region.isGlobal()) {
BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player); BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player);

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.testblock.blockcounter; package de.steamwar.bausystem.features.testblock.blockcounter;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@ -49,6 +50,8 @@ public class BlockCounter {
} }
public String getMessage(Player player, int count, int tntCount, long tick, long lastTick) { public String getMessage(Player player, int count, int tntCount, long tick, long lastTick) {
if(!Permission.BUILD.hasPermission(player)) return null;
double countPerTNT = (double) count / tntCount; double countPerTNT = (double) count / tntCount;
double countPerTick = (double) count / Math.max((lastTick - tick), 1); double countPerTick = (double) count / Math.max((lastTick - tick), 1);
if (isActive(player)) { if (isActive(player)) {

Datei anzeigen

@ -143,16 +143,6 @@ public class TPSSystem implements Plain {
}.runTaskTimer(BauSystem.getInstance(), 1, 1); }.runTaskTimer(BauSystem.getInstance(), 1, 1);
} }
public TypeValidator<Player> player() {
return (commandSender, player, messageSender) -> {
if (!Permission.hasPermission(player, Permission.WORLD)) {
messageSender.send("TPSLIMIT_NO_PERMS");
return false;
}
return true;
};
}
private class TPSBaseCommand extends SWCommand { private class TPSBaseCommand extends SWCommand {
private TPSBaseCommand() { private TPSBaseCommand() {
@ -160,11 +150,6 @@ public class TPSSystem implements Plain {
setMessage(BauSystem.MESSAGE); setMessage(BauSystem.MESSAGE);
addDefaultHelpMessage("TPSLIMIT_HELP"); addDefaultHelpMessage("TPSLIMIT_HELP");
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> player() {
return TPSSystem.this.player();
}
} }
@AbstractSWCommand.PartOf(TPSBaseCommand.class) @AbstractSWCommand.PartOf(TPSBaseCommand.class)
@ -230,11 +215,6 @@ public class TPSSystem implements Plain {
super("tick"); super("tick");
setMessage(BauSystem.MESSAGE); setMessage(BauSystem.MESSAGE);
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> player() {
return TPSSystem.this.player();
}
} }
@AbstractSWCommand.PartOf(TickBaseCommand.class) @AbstractSWCommand.PartOf(TickBaseCommand.class)
@ -403,7 +383,7 @@ public class TPSSystem implements Plain {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLD; return Permission.BUILD;
} }
} }
} }

Datei anzeigen

@ -243,15 +243,4 @@ public class TraceCommand extends SWCommand {
} }
}; };
} }
@ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> validator() {
return (commandSender, player, messageSender) -> {
if (!Permission.hasPermission(player, Permission.WORLD)) {
messageSender.send("TRACE_MESSAGE_DISALLOWED", player);
return false;
}
return true;
};
}
} }

Datei anzeigen

@ -96,6 +96,6 @@ public class TracerBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLD; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.bausystem.features.util; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.script.ScriptCommand; import de.steamwar.bausystem.features.script.ScriptCommand;
import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.ScriptRunner;
@ -62,7 +63,7 @@ public class BindCommand extends SWCommand implements Listener {
} }
@Register(description = "OTHER_BIND_HELP") @Register(description = "OTHER_BIND_HELP")
public void bind(Player player, @Mapper("command") @ErrorMessage("OTHER_BIND_ERROR") String... command) { public void bind(@Validator Player player, @Mapper("command") @ErrorMessage("OTHER_BIND_ERROR") String... command) {
bindInternal(player, command); bindInternal(player, command);
} }
@ -91,6 +92,7 @@ public class BindCommand extends SWCommand implements Listener {
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (!event.hasItem()) return; if (!event.hasItem()) return;
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ItemStack itemStack = event.getItem(); ItemStack itemStack = event.getItem();
ItemMeta meta = itemStack.getItemMeta(); ItemMeta meta = itemStack.getItemMeta();
if (meta == null) { if (meta == null) {

Datei anzeigen

@ -17,7 +17,7 @@ public class BookReplaceCommand extends SWCommand {
} }
@Register("color") @Register("color")
public void color(Player player) { public void color(@Validator Player player) {
ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta instanceof BookMeta) { if (itemMeta instanceof BookMeta) {
@ -29,7 +29,7 @@ public class BookReplaceCommand extends SWCommand {
} }
@Register("uncolor") @Register("uncolor")
public void uncolor(Player player) { public void uncolor(@Validator Player player) {
ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta instanceof BookMeta) { if (itemMeta instanceof BookMeta) {

Datei anzeigen

@ -34,7 +34,7 @@ public class DebugStickCommand extends SWCommand {
} }
@Register(description = "DEBUG_STICK_COMMAND_HELP") @Register(description = "DEBUG_STICK_COMMAND_HELP")
public void genericCommand(Player p) { public void genericCommand(@Validator Player p) {
SWUtils.giveItemToPlayer(p, new ItemStack(Material.DEBUG_STICK)); SWUtils.giveItemToPlayer(p, new ItemStack(Material.DEBUG_STICK));
} }
} }

Datei anzeigen

@ -45,12 +45,12 @@ public class KillAllCommand extends SWCommand {
} }
@Register(description = "OTHER_KILLALL_HELP_SELF") @Register(description = "OTHER_KILLALL_HELP_SELF")
public void genericCommand(Player player) { public void genericCommand(@Validator Player player) {
genericCommand(player, RegionSelectionType.LOCAL); genericCommand(player, RegionSelectionType.LOCAL);
} }
@Register(description = "OTHER_KILLALL_HELP_ALL") @Register(description = "OTHER_KILLALL_HELP_ALL")
public void genericCommand(Player player, RegionSelectionType regionSelectionType) { public void genericCommand(@Validator Player player, RegionSelectionType regionSelectionType) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
AtomicLong count = new AtomicLong(0); AtomicLong count = new AtomicLong(0);
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) { if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) {

Datei anzeigen

@ -45,13 +45,6 @@ public class SelectCommand extends SWCommand {
baurahmenCommand(p, RegionType.TESTBLOCK, regionExtensionType); baurahmenCommand(p, RegionType.TESTBLOCK, regionExtensionType);
} }
@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");
};
}
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) { private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
Point minPoint = region.getMinPoint(regionType, regionExtensionType); Point minPoint = region.getMinPoint(regionType, regionExtensionType);
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);

Datei anzeigen

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

Datei anzeigen

@ -34,7 +34,7 @@ public class StructureVoidCommand extends SWCommand {
} }
@Register(description = "STRUCTURE_VOID_COMMAND_HELP") @Register(description = "STRUCTURE_VOID_COMMAND_HELP")
public void genericCommand(Player p) { public void genericCommand(@Validator Player p) {
SWUtils.giveItemToPlayer(p, new ItemStack(Material.STRUCTURE_VOID, 1)); SWUtils.giveItemToPlayer(p, new ItemStack(Material.STRUCTURE_VOID, 1));
} }
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.util; package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -34,9 +35,9 @@ public class TNTClickListener implements Listener {
@EventHandler @EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { if (event.getHand() != EquipmentSlot.HAND) return;
return; if (!Permission.BUILD.hasPermission(event.getPlayer()));
}
Entity entity = event.getRightClicked(); Entity entity = event.getRightClicked();
if (event.getRightClicked() instanceof TNTPrimed) { if (event.getRightClicked() instanceof TNTPrimed) {
TNTPrimed tntPrimed = (TNTPrimed) entity; TNTPrimed tntPrimed = (TNTPrimed) entity;

Datei anzeigen

@ -66,13 +66,6 @@ public class TimeCommand extends SWCommand {
}, s -> tabCompletions); }, s -> tabCompletions);
} }
@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");
};
}
public enum Time { public enum Time {
NIGHT(18000), NIGHT(18000),
DAY(6000), DAY(6000),

Datei anzeigen

@ -50,6 +50,6 @@ public class DebugstickBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.MEMBER; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -62,6 +62,6 @@ public class KillAllBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.MEMBER; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -39,7 +39,7 @@ public class NavWandBauGuiItem extends BauGuiItem {
} }
@Override public Permission permission() { @Override public Permission permission() {
return Permission.WORLDEDIT; return Permission.MEMBER;
} }
@Override public ItemStack getItem(Player player) { @Override public ItemStack getItem(Player player) {

Datei anzeigen

@ -18,7 +18,7 @@ public class SchemBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLDEDIT; return Permission.BUILD;
} }
@Override @Override

Datei anzeigen

@ -88,7 +88,7 @@ public class SelectBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLDEDIT; return Permission.BUILD;
} }
@AllArgsConstructor @AllArgsConstructor

Datei anzeigen

@ -54,6 +54,6 @@ public class SkullBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.MEMBER; return Permission.BUILD;
} }
} }

Datei anzeigen

@ -40,7 +40,7 @@ public class WorldEditBauGuiItem extends BauGuiItem {
@Override @Override
public Permission permission() { public Permission permission() {
return Permission.WORLDEDIT; return Permission.BUILD;
} }
@Override @Override