From 1a6c0de502df750703406fd256799867f6114d53 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:01:42 +0100 Subject: [PATCH 01/29] Update Permission --- .../src/de/steamwar/bausystem/Permission.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index b2f14e4f..6d9dbf96 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -36,27 +36,21 @@ import java.util.function.Predicate; @AllArgsConstructor public enum Permission { - WORLD(BauweltMember::isWorld), - WORLDEDIT(BauweltMember::isWorldEdit), - MEMBER(bauweltMember -> true), - OWNER(bauweltMember -> false); + OWNER(bauweltMember -> { + return bauweltMember.getBauweltID() == BauServer.getInstance().getOwnerID(); + }), + SUPERVISOR(bauweltMember -> { + return OWNER.permissionPredicate.test(bauweltMember); // TODO: Needs to be changed later on + }), + BUILD(bauweltMember -> { + return bauweltMember.isWorld() || bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); + }); private final Predicate permissionPredicate; public boolean hasPermission(Player member) { - if (member.getUniqueId().equals(BauServer.getInstance().getOwner())) { - return true; - } - BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauMember == null) { - return false; - } - + if (bauMember == null) return false; return permissionPredicate.test(bauMember); } - - public static boolean hasPermission(Player member, Permission permission) { - return permission.hasPermission(member); - } } \ No newline at end of file From ec93dfd8ec7162376e48a13436221151a4789f7e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:04:46 +0100 Subject: [PATCH 02/29] Add Permission.SPECTATOR --- BauSystem_Main/src/de/steamwar/bausystem/Permission.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 6d9dbf96..009e51a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -44,6 +44,9 @@ public enum Permission { }), BUILD(bauweltMember -> { return bauweltMember.isWorld() || bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); + }), + SPECTATOR(bauweltMember -> { + return !BUILD.permissionPredicate.test(bauweltMember); }); private final Predicate permissionPredicate; From 0b70bdfe97dc58d09e78816e4dd40b57854318c5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:05:58 +0100 Subject: [PATCH 03/29] Fix Permission.SPECTATOR --- BauSystem_Main/src/de/steamwar/bausystem/Permission.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 009e51a5..3e25ced6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -52,8 +52,8 @@ public enum Permission { private final Predicate permissionPredicate; public boolean hasPermission(Player member) { - BauweltMember bauMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauMember == null) return false; - return permissionPredicate.test(bauMember); + BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); + if (bauweltMember == null) return this != SPECTATOR; + return permissionPredicate.test(bauweltMember); } } \ No newline at end of file From 0cec90c55cfa92a18105a4c01b179b540690e001 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:19:30 +0100 Subject: [PATCH 04/29] Add validator for player and commandsender for checking build Permission --- BauSystem_Main/src/BauSystem.properties | 3 +++ BauSystem_Main/src/BauSystem_de.properties | 3 +++ .../src/de/steamwar/bausystem/BauSystem.java | 21 +++++++++++++++++++ .../src/de/steamwar/bausystem/Permission.java | 7 ------- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 27ca6f67..0231d101 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -27,6 +27,9 @@ PAGE_LIST=§e Page ({0}/{1}) »» LIST_PREVIOUS_PAGE=§ePrevious page LIST_NEXT_PAGE=§eNext page +# Permissions +NO_PERMISSION = You are not allowed to use that here + # Scoreboard SCOREBOARD_TIME = Time SCOREBOARD_REGION = Region diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 439267cf..f81caadd 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -27,6 +27,9 @@ PAGE_LIST=§e Seite ({0}/{1}) »» LIST_PREVIOUS_PAGE=§eVorherige Seite LIST_NEXT_PAGE=§eNächste Seite +# Permission +NO_PERMISSION = Du darfst dies hier nicht nutzen + # Scoreboard SCOREBOARD_TIME = Uhrzeit SCOREBOARD_REGION = Region diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 10b36297..ad5790a0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -29,9 +29,12 @@ import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.Updater; import de.steamwar.bausystem.utils.TickListener; import de.steamwar.bausystem.worlddata.WorldData; +import de.steamwar.command.SWCommandUtils; import de.steamwar.message.Message; import lombok.Getter; import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -75,6 +78,24 @@ public class BauSystem extends JavaPlugin implements Listener { new Updater(PrototypeLoader.file, PrototypeLoader::load); new Updater(RegionLoader.file, RegionLoader::load); + SWCommandUtils.addValidator(Player.class, (player, object, messageSender) -> { + if (Permission.BUILD.hasPermission(player)) { + return true; + } + messageSender.send("NO_PERMISSION"); + return false; + }); + SWCommandUtils.addValidator(CommandSender.class, (commandSender, object, messageSender) -> { + if (commandSender instanceof Player) { + if (Permission.BUILD.hasPermission((Player) commandSender)) { + return true; + } + messageSender.send("NO_PERMISSION"); + return false; + } + return true; + }); + LinkageUtils.link(); RamUsage.init(); TickListener.impl.init(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 3e25ced6..68900972 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -20,17 +20,10 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.config.BauServer; -import de.steamwar.command.CommandMetaData; -import de.steamwar.command.TypeValidator; import de.steamwar.sql.BauweltMember; import lombok.AllArgsConstructor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import java.util.function.Predicate; @AllArgsConstructor From 20af36a4a2f32b8cee75f15f3c1a4faaaa6b8c45 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:42:01 +0100 Subject: [PATCH 05/29] Add SpectatorListener --- .../features/world/SpectatorListener.java | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java new file mode 100644 index 00000000..ffc45f90 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -0,0 +1,110 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.world; + +import de.steamwar.bausystem.Permission; +import de.steamwar.linkage.Linked; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockCanBuildEvent; +import org.bukkit.event.block.BlockMultiPlaceEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.*; + +@Linked +public class SpectatorListener implements Listener { + + private boolean anySupervisorOnline(Player player) { + return Bukkit.getOnlinePlayers().stream().filter(p -> p != player).anyMatch(Permission.SUPERVISOR::hasPermission); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + if (!anySupervisorOnline(null)) { + event.getPlayer().kickPlayer(""); + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + if (!anySupervisorOnline(event.getPlayer())) { + Bukkit.getOnlinePlayers().forEach(player -> { + player.kickPlayer(""); + }); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + if (event.getMessage().startsWith("/schem save") || event.getMessage().startsWith("//schem save") || event.getMessage().startsWith("/schematic save") || event.getMessage().startsWith("//schematic save")) { + if (!Permission.SUPERVISOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + event.setMessage("/"); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onBlockMultiPlace(BlockMultiPlaceEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onBlockCanBuild(BlockCanBuildEvent event) { + if (event.getPlayer() == null) return; + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setBuildable(false); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onBlockPlace(BlockPlaceEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onBlockBreak(BlockBreakEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerBucket(PlayerBucketEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } +} From 7802a03f48faaf2ffdfab19de58ded3988a4f110 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 16 Dec 2023 14:47:33 +0100 Subject: [PATCH 06/29] Addjusted permissions --- .../bausystem/features/warp/WarpCommand.java | 7 ------- .../de/steamwar/bausystem/features/warp/WarpGui.java | 2 +- .../features/world/AxiomPermissionCheck.java | 2 +- .../bausystem/features/world/ClipboardListener.java | 5 +++++ .../bausystem/features/world/ItemFrameListener.java | 4 ++++ .../bausystem/features/world/KickallCommand.java | 12 ++++-------- .../bausystem/features/world/StopCommand.java | 2 +- .../bausystem/features/world/WorldEditListener.java | 2 +- .../features/worldedit/ColorReplaceCommand.java | 2 +- .../features/worldedit/TypeReplaceCommand.java | 2 +- .../bausystem/features/xray/XrayCommand.java | 2 +- 11 files changed, 20 insertions(+), 22 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java index 8fa832a7..aad07fcb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java @@ -122,13 +122,6 @@ public class WarpCommand extends SWCommand implements Disable, Enable { BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation())); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "WARP_DISALLOWED"); - }; - } - @Linked public static class WarpsLink extends SWCommand { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java index 7c5c87a6..30fd21e3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpGui.java @@ -55,7 +55,7 @@ public class WarpGui { ), warp))); SWListInv inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("WARP_GUI_NAME", player), false, entries, (clickType, warp) -> { - if (clickType.isRightClick() && Permission.hasPermission(player, Permission.WORLD)) { + if (clickType.isRightClick() && Permission.BUILD.hasPermission(player)) { openWarpGui(player, warp); } else { warp.teleport(player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java index 5ee07dae..e006e184 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java @@ -32,7 +32,7 @@ public class AxiomPermissionCheck implements Listener { @EventHandler public void onAxiomHandshake(AxiomHandshakeEvent event) { - if (Permission.WORLDEDIT.hasPermission(event.getPlayer())) return; + if (Permission.BUILD.hasPermission(event.getPlayer())) return; event.setCancelled(true); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java index 3d3ca140..04c95e5c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; @@ -35,6 +36,8 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogin(PlayerJoinEvent e) { + if(!Permission.BUILD.hasPermission(e.getPlayer())) return; + try { SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null); if (schematic != null) { @@ -47,6 +50,8 @@ public class ClipboardListener implements Listener { @EventHandler public void onLogout(PlayerQuitEvent e) { + if(!Permission.SUPERVISOR.hasPermission(e.getPlayer())) return; + SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null); boolean newSchem = false; if (schematic == null) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java index 9a294708..535551ab 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.linkage.Linked; import org.bukkit.Material; @@ -40,6 +41,9 @@ public class ItemFrameListener implements Listener { if (!(event.getEntity() instanceof ItemFrame)) { return; } + + if(!Permission.BUILD.hasPermission((Player) event.getDamager())) return; + event.setCancelled(true); ItemFrame itemFrame = (ItemFrame) event.getEntity(); ItemStack itemStack = itemFrame.getItem(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java index ee9ace1b..d4e5d3f7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; @@ -38,16 +39,11 @@ public class KickallCommand extends SWCommand { } @Register(description = "KICKALL_HELP") - public void genericCommand(@Validator Player player) { + public void genericCommand(Player player) { + if(!Permission.OWNER.hasPermission(player)) return; + Bukkit.getOnlinePlayers().forEach(p -> { if (!bauServer.getOwner().equals(p.getUniqueId())) p.kickPlayer(""); }); } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!bauServer.getOwner().equals(player.getUniqueId()), "KICKALL_NO_PERM"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java index 4017e548..479cd9ad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java @@ -51,7 +51,7 @@ public class StopCommand extends SWCommand { return true; } Player player = (Player) sender; - if (Permission.hasPermission(player, Permission.WORLD)) { + if (Permission.SUPERVISOR.hasPermission(player)) { return true; } SteamwarUser user = SteamwarUser.get(player.getUniqueId()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java index ba9d6d9e..6cda80be 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java @@ -40,7 +40,7 @@ public class WorldEditListener implements Listener { if (!isWorldEditCommand(e.getMessage().split(" ")[0])) return; Player p = e.getPlayer(); - if (!Permission.hasPermission(p, Permission.WORLDEDIT)) { + if (!Permission.BUILD.hasPermission(e.getPlayer())) { BauSystem.MESSAGE.send("WORLD_EDIT_NO_PERMS", p); e.setCancelled(true); e.setMessage("/"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 010498a8..6b6659ba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand { @Register(description = "COLORREPLACE_HELP") @SneakyThrows - public void genericCommand(Player player, Pair from, Color to) { + public void genericCommand(@Validator Player player, Pair from, Color to) { if (from.getValue() == to) { BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)})); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java index 0cc939d6..8013c92b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java @@ -67,7 +67,7 @@ public class TypeReplaceCommand extends SWCommand { @Register(description = "TYPEREPLACE_HELP") @SneakyThrows - public void genericCommand(Player player, Pair from, Type to) { + public void genericCommand(@Validator Player player, Pair from, Type to) { if (from.getValue() == to) { BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)})); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index ef30fbcd..2e5d90a0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -62,7 +62,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen public TechHiderCommand techHiderCommand; @Register(description = "XRAY_HELP") - public void toggleHider(Player player) { + public void toggleHider(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); if (region.isGlobal()) { BauSystem.MESSAGE.send("XRAY_GLOBAL", player); From bcb8b31ba99ab5b3b16d03c9f6ea3bc395792188 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 14:51:24 +0100 Subject: [PATCH 07/29] Add Permission.MEMBER --- BauSystem_Main/src/de/steamwar/bausystem/Permission.java | 3 +++ .../de/steamwar/bausystem/features/util/ClearCommand.java | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 68900972..40978989 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -40,6 +40,9 @@ public enum Permission { }), SPECTATOR(bauweltMember -> { return !BUILD.permissionPredicate.test(bauweltMember); + }), + MEMBER(bauweltMember -> { + return true; }); private final Predicate permissionPredicate; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java index 3e8899d6..1df08e5d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java @@ -48,13 +48,6 @@ public class ClearCommand extends SWCommand { BauSystem.MESSAGE.send("OTHER_CLEAR_TO", p, target.getName()); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "OTHER_CLEAR_NO_PERMS"); - }; - } - private void clear(Player player) { player.getInventory().clear(); player.getInventory().setHelmet(new ItemStack(Material.AIR)); From 37e6628aaadb77e2f1c02c8407209b2a886f7761 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 15:12:16 +0100 Subject: [PATCH 08/29] Fix SpectatorListener --- .../features/world/SpectatorListener.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index ffc45f90..942d8eb7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -30,7 +32,9 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockMultiPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.*; +import org.bukkit.inventory.ItemStack; @Linked public class SpectatorListener implements Listener { @@ -44,6 +48,38 @@ public class SpectatorListener implements Listener { if (!anySupervisorOnline(null)) { event.getPlayer().kickPlayer(""); } + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + Player p = event.getPlayer(); + ItemStack[] content = event.getPlayer().getInventory().getContents(); + for (int i = 0; i < content.length; i++) { + if (content[i] == null) continue; + if (checkItemStack(content[i])) { + p.getInventory().setItem(i, null); + } + } + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onInventoryClick(InventoryClickEvent event) { + ItemStack itemStack = event.getCurrentItem(); + if (itemStack == null || !itemStack.hasItemMeta()) { + return; + } + if (checkItemStack(itemStack)) { + event.setCancelled(true); + event.setCurrentItem(null); + } + } + + private boolean checkItemStack(ItemStack itemStack) { + switch (itemStack.getType()) { + case WOODEN_AXE: + case DEBUG_STICK: + return true; + default: + return false; + } } @EventHandler From 3dddb48d0ca4b475e954557436759f754811a7c8 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 16 Dec 2023 15:53:02 +0100 Subject: [PATCH 09/29] Adjusted more permissions --- .../AttributeRemoveCommand.java | 4 +-- .../attributescopy/AttributesCopyCommand.java | 2 +- .../AttributesPlaceListener.java | 2 ++ .../features/autostart/AutoStartCommand.java | 2 +- .../features/autostart/AutoStartGuiItem.java | 2 +- .../features/autostart/AutostartListener.java | 3 +++ .../features/backup/BackupCommand.java | 7 ----- .../endstone/DesignEndStoneCommand.java | 2 +- .../detonator/DetonatorBauGuiItem.java | 2 +- .../features/detonator/DetonatorCommand.java | 4 +-- .../features/detonator/DetonatorListener.java | 6 +++++ .../features/hotbar/HotbarCommand.java | 2 +- .../features/hotbar/HotbarListener.java | 2 ++ .../inventoryfiller/InventoryFiller.java | 3 +++ .../killchecker/KillcheckerCommand.java | 2 +- .../bausystem/features/loader/Loader.java | 2 ++ .../features/loader/LoaderCommand.java | 7 ----- .../loader/LoaderScoreboardElement.java | 2 ++ .../features/loadtimer/LoadtimerCommand.java | 6 ++--- .../observer/ObserverTracerCommand.java | 3 ++- .../observer/ObserverTracerListener.java | 2 ++ .../features/region/ColorCommand.java | 2 +- .../features/region/FireCommand.java | 11 -------- .../features/region/FreezeCommand.java | 11 -------- .../features/region/ItemsCommand.java | 11 -------- .../features/region/ProtectCommand.java | 7 ----- .../features/region/RegionCommand.java | 26 +++++-------------- .../features/region/ResetCommand.java | 7 ----- .../bausystem/features/region/TNTCommand.java | 7 ----- .../features/region/TestblockCommand.java | 5 ---- .../features/region/items/FireBauGuiItem.java | 2 +- .../region/items/FreezeBauGuiItem.java | 2 +- .../region/items/ProtectBauGuiItem.java | 2 +- .../region/items/ResetBauGuiItem.java | 2 +- .../region/items/TestblockBauGuiItem.java | 2 +- .../features/region/items/TntBauGuiItem.java | 2 +- .../features/script/ScriptCommand.java | 2 +- .../features/script/ScriptListener.java | 4 +++ .../script/event/CommandListener.java | 2 ++ .../features/script/event/EventListener.java | 11 ++++++++ .../features/script/event/HotkeyListener.java | 2 ++ .../shieldprinting/ShieldPrintingCommand.java | 5 ++-- .../features/simulator/SimulatorCommand.java | 7 ----- .../features/simulator/SimulatorCursor.java | 2 ++ .../slaves/laufbau/LaufbauCommand.java | 7 ----- .../slaves/panzern/PanzernCommand.java | 7 ----- .../smartplace/SmartPlaceListener.java | 4 +++ .../features/techhider/TechHiderCommand.java | 2 +- .../testblock/blockcounter/BlockCounter.java | 3 +++ .../features/tpslimit/TPSSystem.java | 22 +--------------- .../features/tracer/TraceCommand.java | 11 -------- .../features/tracer/TracerBauGuiItem.java | 2 +- .../bausystem/features/util/BindCommand.java | 4 ++- .../features/util/BookReplaceCommand.java | 4 +-- .../features/util/DebugStickCommand.java | 2 +- .../features/util/KillAllCommand.java | 4 +-- .../features/util/SelectCommand.java | 7 ----- .../bausystem/features/util/SkullCommand.java | 2 +- .../features/util/StructureVoidCommand.java | 2 +- .../features/util/TNTClickListener.java | 7 ++--- .../bausystem/features/util/TimeCommand.java | 7 ----- .../util/items/DebugstickBauGuiItem.java | 2 +- .../util/items/KillAllBauGuiItem.java | 2 +- .../util/items/NavWandBauGuiItem.java | 2 +- .../features/util/items/SchemBauGuiItem.java | 2 +- .../features/util/items/SelectBauGuiItem.java | 2 +- .../features/util/items/SkullBauGuiItem.java | 2 +- .../util/items/WorldEditBauGuiItem.java | 2 +- 68 files changed, 107 insertions(+), 205 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java index 11cacde1..689be980 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributeRemoveCommand.java @@ -44,7 +44,7 @@ public class AttributeRemoveCommand extends SWCommand { @Register({"all"}) @Register({"*"}) - public void genericCommand(Player player) { + public void genericCommand(@Validator Player player) { ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.setLore(new ArrayList<>()); @@ -53,7 +53,7 @@ public class AttributeRemoveCommand extends SWCommand { } @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(); ItemMeta itemMeta = itemStack.getItemMeta(); if (itemMeta == null) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java index 01d652b4..808ca339 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesCopyCommand.java @@ -41,7 +41,7 @@ public class AttributesCopyCommand extends SWCommand { } @Register - public void genericCommand(Player player) { + public void genericCommand(@Validator Player player) { Block block = player.getTargetBlockExact(8, FluidCollisionMode.ALWAYS); if (block == null) return; ItemStack mainHand = player.getInventory().getItemInMainHand(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java index de4b192a..965d8bad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/attributescopy/AttributesPlaceListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.attributescopy; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -40,6 +41,7 @@ public class AttributesPlaceListener implements Listener { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ItemStack itemStack = event.getItemInHand(); ItemMeta itemMeta = itemStack.getItemMeta(); if (itemMeta == null) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java index 8e2b8c1a..3401267e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java @@ -32,7 +32,7 @@ public class AutoStartCommand extends SWCommand { } @Register(description = "AUTOSTART_COMMAND_HELP") - public void genericCommand(Player p) { + public void genericCommand(@Validator Player p) { SWUtils.giveItemToPlayer(p, AutostartListener.getWandItem(p)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java index a66e3785..f622d70b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java @@ -50,6 +50,6 @@ public class AutoStartGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.MEMBER; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index 7da0fea1..28fb7f94 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.autostart; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; @@ -66,6 +67,7 @@ public class AutostartListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!ItemUtils.isItem(event.getItem(), "autostart")) { return; } @@ -83,6 +85,7 @@ public class AutostartListener implements Listener { if (!(event.getPlayer() instanceof Player)) { return; } + if(!Permission.BUILD.hasPermission((Player) event.getPlayer())) return; if (!ItemUtils.isItem(event.getPlayer().getInventory().getItemInMainHand(), "autostart")) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java index ba7035dc..f4194a4e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -140,13 +140,6 @@ public class BackupCommand extends SWCommand { return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender)); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator backupValidator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "BACKUP_NO_PERMS"); - }; - } - private List listBackup(Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java index bafa3206..35a7fa7a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -45,7 +45,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener { private Map designEndStoneMap = new HashMap<>(); @Register(description = "DESIGN_ENDSTONE_COMMAND_HELP") - public void genericCommand(Player player) { + public void genericCommand(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); if (!region.hasType(RegionType.BUILD)) { BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java index 2207ce45..3f633663 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java @@ -47,6 +47,6 @@ public class DetonatorBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.MEMBER; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java index bb71245d..c8d493bd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java @@ -58,12 +58,12 @@ public class DetonatorCommand extends SWCommand { } @Register(value = "wand", description = "DETONATOR_HELP_WAND") - public void giveWand(Player p) { + public void giveWand(@Validator Player p) { SWUtils.giveItemToPlayer(p, getWAND(p)); } @Register(value = "click", description = "DETONATOR_HELP_CLICK") - public void clickDetonator(Player p) { + public void clickDetonator(@Validator Player p) { Detonator.activateDetonator(new ItemStorage(p)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java index be8e8ce9..0ea3c469 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.detonator; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; import de.steamwar.bausystem.features.detonator.storage.ItemStorage; @@ -65,6 +66,7 @@ public class DetonatorListener implements Listener { @EventHandler public void onBlockBreak(BlockBreakEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; Player p = event.getPlayer(); if (Detonator.isDetonator(p.getInventory().getItemInMainHand())) { event.setCancelled(true); @@ -75,6 +77,7 @@ public class DetonatorListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Detonator.isDetonator(event.getItem())) { return; } @@ -89,6 +92,7 @@ public class DetonatorListener implements Listener { @EventHandler(ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) { if (Detonator.hasActiveDetonatorShow(event.getPlayer())) { Detonator.hideDetonator(event.getPlayer()); @@ -110,6 +114,7 @@ public class DetonatorListener implements Listener { @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) { HAS_UPDATED.add(event.getPlayer()); } @@ -117,6 +122,7 @@ public class DetonatorListener implements Listener { @EventHandler public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem())) { HAS_UPDATED.add(event.getPlayer()); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java index 9b52890c..77a13716 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java @@ -35,7 +35,7 @@ public class HotbarCommand extends SWCommand { } @Register(value = "load", description = "HOTBAR_HELP_LOAD") - public void loadHotbar(Player p) { + public void loadHotbar(@Validator Player p) { DefaultHotbar.setHotbar(p); BauSystem.MESSAGE.send("HOTBAR_LOADED", p); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java index de00331f..8a4c78de 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.hotbar; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -30,6 +31,7 @@ public class HotbarListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onPlayerJoin(PlayerJoinEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (allNull(event.getPlayer().getInventory().getContents()) && allNull(event.getPlayer().getInventory().getArmorContents())) { DefaultHotbar.setHotbar(event.getPlayer()); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java index f72d08f2..d69e3410 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.inventoryfiller; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; @@ -38,6 +39,7 @@ public class InventoryFiller implements Listener { @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!event.getPlayer().isSneaking()) return; Block block = event.getPlayer().getTargetBlockExact(5); @@ -59,6 +61,7 @@ public class InventoryFiller implements Listener { */ @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("inventoryfill", false)) return; if (!event.getPlayer().isSneaking()) return; ItemStack itemStack = event.getPlayer().getInventory().getItemInMainHand(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java index 1340f1c1..bbba61ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java @@ -54,7 +54,7 @@ public class KillcheckerCommand extends SWCommand implements Listener { } @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()); KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService)); killcheckerVisualizer.recalc(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java index 22e0df02..266cd65b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.loader; 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.LoaderInteractionElement; import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT; @@ -70,6 +71,7 @@ public class Loader implements Listener { BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { if (stage != Stage.RUNNING) return; + if(!Permission.BUILD.hasPermission(p)) return; if (waitTime > 0) { waitTime--; return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index b065c3d2..55264ec2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -101,11 +101,4 @@ public class LoaderCommand extends SWCommand { BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay); loader.setTicksBetweenBlocks(delay); } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator loaderValidator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "LOADER_PERMS"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java index b3e2ba2f..fdcda57a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderScoreboardElement.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; @@ -40,6 +41,7 @@ public class LoaderScoreboardElement implements ScoreboardElement { @Override public String get(Region region, Player p) { + if(!Permission.BUILD.hasPermission(p)) return null; Loader loader = Loader.getLoader(p); if (loader == null) return null; if (loader.getStage() == Loader.Stage.RUNNING) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java index 42d5175c..503c1b47 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java @@ -32,12 +32,12 @@ public class LoadtimerCommand extends SWCommand { } @Register(value = "start", description = "LOADTIMER_HELP_START_1") - public void start(Player p) { + public void start(@Validator Player p) { start(p, TimerMode.HALF); } @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()); if (r.isGlobal()) return; if (!Loadtimer.hasTimer(r)) @@ -45,7 +45,7 @@ public class LoadtimerCommand extends SWCommand { } @Register(value = "stop", description = "LOADTIMER_HELP_STOP") - public void stop(Player p) { + public void stop(@Validator Player p) { Region r = Region.getRegion(p.getLocation()); if (r.isGlobal()) return; if (Loadtimer.hasTimer(r)) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java index fd0df724..dbd3e48a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -52,7 +53,7 @@ public class ObserverTracerCommand extends SWCommand { } @Register(value = "retrace", description = "OBSERVER_HELP_RETRACE") - public void retrace(Player p) { + public void retrace(@Validator Player p) { if (ObserverTracerListener.observerTracerMap.containsKey(p)) { BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO_TRACE", p); return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java index b841755b..801f9ce0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -55,6 +56,7 @@ public class ObserverTracerListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!enabled.contains(event.getPlayer())) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java index 543d8727..7c60aef2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -85,7 +85,7 @@ public class ColorCommand extends SWCommand { @ClassValidator(value = Player.class, local = true) public TypeValidator validator() { 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"); }; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java index da5b2665..3a0d4403 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java @@ -46,10 +46,6 @@ public class FireCommand extends SWCommand { } } - private String getNoPermMessage() { - return "REGION_FIRE_NO_PERMS"; - } - private String getEnableMessage() { return "REGION_FIRE_ENABLED"; } @@ -69,11 +65,4 @@ public class FireCommand extends SWCommand { return false; } } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage()); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java index 339ea122..d154ce66 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java @@ -46,10 +46,6 @@ public class FreezeCommand extends SWCommand { } } - private String getNoPermMessage() { - return "REGION_FREEZE_NO_PERMS"; - } - private String getEnableMessage(){ return "REGION_FREEZE_ENABLED"; } @@ -69,11 +65,4 @@ public class FreezeCommand extends SWCommand { return true; } } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage()); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java index d1709dc7..8c4452cb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ItemsCommand.java @@ -49,10 +49,6 @@ public class ItemsCommand extends SWCommand { } } - private String getNoPermMessage() { - return "REGION_ITEMS_NO_PERMS"; - } - private String getEnableMessage(){ return "REGION_ITEMS_ENABLED"; } @@ -72,11 +68,4 @@ public class ItemsCommand extends SWCommand { return true; } } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), getNoPermMessage()); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java index 3793d3ec..4fc33cf0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java @@ -54,13 +54,6 @@ public class ProtectCommand extends SWCommand { } } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_PROTECT_NO_PERMS"); - }; - } - private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); if (region.getFloorLevel() == 0) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index 5caf0af3..28da6094 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -71,7 +71,7 @@ public class RegionCommand extends SWCommand { } @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()); if (checkGlobalRegion(region, p)) return; @@ -83,7 +83,7 @@ public class RegionCommand extends SWCommand { } @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()); if (checkGlobalRegion(region, p)) { return; @@ -97,7 +97,7 @@ public class RegionCommand extends SWCommand { } @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()); if(checkGlobalRegion(region, p)) return; @@ -114,7 +114,7 @@ public class RegionCommand extends SWCommand { } @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()); if (checkGlobalRegion(region, p)) return; @@ -176,7 +176,7 @@ public class RegionCommand extends SWCommand { @Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE") @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()); if (checkGlobalRegion(region, p)) { return; @@ -210,7 +210,7 @@ public class RegionCommand extends SWCommand { @Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN") @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()); if (checkGlobalRegion(region, p)) { return; @@ -266,18 +266,4 @@ public class RegionCommand extends SWCommand { } }; } - - @Validator(value = "WORLD", local = true) - public TypeValidator 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 worldEditValidator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_REGION_NO_PERMS"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index 03a22027..680224a7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -97,13 +97,6 @@ public class ResetCommand extends SWCommand { } } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_RESET_NO_PERMS"); - }; - } - private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); if (region == GlobalRegion.getInstance()) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java index af9f3837..27dcbe8f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java @@ -157,11 +157,4 @@ public class TNTCommand extends SWCommand { break; } } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "REGION_TNT_NO_PERMS"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java index 3572cf71..6b319062 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java @@ -157,11 +157,6 @@ public class TestblockCommand extends SWCommand { }; } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "REGION_TB_NO_PERMS"); - } - private Region regionCheck(Player player) { Region region = Region.getRegion(player.getLocation()); if (!region.hasType(RegionType.TESTBLOCK)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java index 01714fba..79101ee9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java @@ -57,6 +57,6 @@ public class FireBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLD; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java index 43d1903f..1406638c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java @@ -57,6 +57,6 @@ public class FreezeBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLD; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java index 652c2fb2..a11e508d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java @@ -58,6 +58,6 @@ public class ProtectBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java index 79f6537a..e5295b2e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java @@ -65,6 +65,6 @@ public class ResetBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java index 7b0f25e0..355b5209 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java @@ -64,6 +64,6 @@ public class TestblockBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java index 673a9295..38f1b04a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java @@ -116,6 +116,6 @@ public class TntBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLD; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java index 9d640d52..0194514f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java @@ -31,7 +31,7 @@ public class ScriptCommand extends SWCommand { } @Register - public void genericCommand(Player player) { + public void genericCommand(@Validator Player player) { ScriptGUI.open(player); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java index 61b8862d..ed88d2ee 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.script; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -42,6 +43,8 @@ public class ScriptListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onLeftClick(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; + ItemStack item = event.getItem(); if (item == null || FlatteningWrapper.impl.isNoBook(item) || item.getItemMeta() == null) { return; @@ -68,6 +71,7 @@ public class ScriptListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ScriptRunner.updateGlobalScript(event.getPlayer()); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java index 77bd991e..da5f1f21 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/CommandListener.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.script.event; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -41,6 +42,7 @@ public class CommandListener implements Listener { @EventHandler public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; String[] split = event.getMessage().split(" "); if (calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).contains(split[0])) { return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java index 89f9667e..9f38c219 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/EventListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.script.event; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin; import de.steamwar.bausystem.features.script.lua.libs.StorageLib; @@ -64,17 +65,20 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL, event); } @EventHandler(priority = EventPriority.HIGH) public void onPlayerQuit(PlayerQuitEvent event) { StorageLib.removePlayer(event.getPlayer()); + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event); } @EventHandler(priority = EventPriority.HIGH) public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (LAST_FS.containsKey(event.getPlayer())) { Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL, event); @@ -86,6 +90,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onBlockPlace(BlockPlaceEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; LuaTable table = new LuaTable(); table.set("x", event.getBlock().getX()); table.set("y", event.getBlock().getY()); @@ -96,6 +101,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onBlockBreak(BlockBreakEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; LuaTable table = new LuaTable(); table.set("x", event.getBlock().getX()); table.set("y", event.getBlock().getY()); @@ -108,6 +114,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.LOW) public void onPlayerInteract(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (ignore.remove(event.getPlayer())) { return; } @@ -144,6 +151,7 @@ public class EventListener implements Listener { Region tntRegion = Region.getRegion(event.getLocation()); for (Player player : Bukkit.getOnlinePlayers()) { + if(!Permission.BUILD.hasPermission(player)) continue; if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { 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)); for (Player player : Bukkit.getOnlinePlayers()) { + if(!Permission.BUILD.hasPermission(player)) continue; if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) { ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event); if (inBuild) { @@ -176,6 +185,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onPlayerDropItem(PlayerDropItemEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ignore.add(event.getPlayer()); LuaTable table = new LuaTable(); table.set("type", event.getItemDrop().getItemStack().getType().name()); @@ -185,6 +195,7 @@ public class EventListener implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onEntityDeath(EntityDeathEvent event) { for (Player player : Bukkit.getOnlinePlayers()) { + if(!Permission.BUILD.hasPermission(player)) continue; LuaTable table = new LuaTable(); table.set("type", event.getEntityType().name()); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.EntityDeath, table, event); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java index d27a314e..52843f79 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.script.event; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Plain; @@ -36,6 +37,7 @@ public class HotkeyListener implements PluginMessageListener, Plain { @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { + if(!Permission.BUILD.hasPermission(player)) return; if (!channel.equals("sw:hotkeys")) return; if (message.length < 5) return; int action = message[4] & 0xFF; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java index d1b60349..20bbd8df 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrintingCommand.java @@ -108,8 +108,8 @@ public class ShieldPrintingCommand extends SWCommand implements Listener { @ClassValidator(value = Player.class, local = true) public TypeValidator validator() { return (commandSender, player, messageSender) -> { - if (!Permission.hasPermission(player, Permission.WORLD)) { - messageSender.send("SHIELD_PRINTING_DISALLOWED", player); + if (!Permission.BUILD.hasPermission(player)) { + messageSender.send("NO_PERMISSION", player); return false; } Region region = Region.getRegion(player.getLocation()); @@ -123,6 +123,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (event.getClickedBlock() == null) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java index 56991431..06af3e68 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java @@ -102,11 +102,4 @@ public class SimulatorCommand extends SWCommand { } }; } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "SIMULATOR_NO_PERMS"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index 6ff78e19..5dd31b6a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.SimulatorElement; @@ -148,6 +149,7 @@ public class SimulatorCursor implements Listener { } return; } + if(!Permission.BUILD.hasPermission(player)) return; Simulator simulator = SimulatorStorage.getSimulator(player); SimulatorWatcher.show(simulator, player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java index 86585417..daff9d87 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java @@ -78,11 +78,4 @@ public class LaufbauCommand extends SWCommand { public void laufbauSettings(@Validator Player player) { new LaufbauSettings(player); } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "LAUFBAU_NO_PERM"); - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java index 3bb2379e..8d83d3dd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java @@ -91,13 +91,6 @@ public class PanzernCommand extends SWCommand { }.runTaskTimer(BauSystem.getInstance(), 1, 1); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "PANZERN_NO_PERM"); - }; - } - @Mapper(value = "block", local = true) private TypeMapper blockMapper() { Set strings = new HashSet<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index f3ab68bf..ea6faa46 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.smartplace; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; @@ -90,6 +91,7 @@ public class SmartPlaceListener implements Plain, Listener { public SmartPlaceListener() { TinyProtocol.instance.addFilter(useItem, (player, packet) -> { + if(!Permission.BUILD.hasPermission(player)) return packet; if (!Config.getInstance().get(player).getPlainValueOrDefault("smartPlace", false)) return packet; 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())); @@ -116,6 +118,7 @@ public class SmartPlaceListener implements Plain, Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; WAS_EXECUTED.add(event.getPlayer()); if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; @@ -134,6 +137,7 @@ public class SmartPlaceListener implements Plain, Listener { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; if (!SMART_PLACING.contains(event.getPlayer())) { if (CONTAINERS.contains(event.getBlockAgainst().getType())) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index b6c6975e..731b583a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -55,7 +55,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE public XrayCommand xrayCommand; @Register(description = "TECHHIDER_HELP") - public void toggleHider(Player player) { + public void toggleHider(@Validator Player player) { Region region = Region.getRegion(player.getLocation()); if (region.isGlobal()) { BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java index cf34f6f1..8b0796b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.testblock.blockcounter; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.region.Region; import lombok.experimental.UtilityClass; @@ -49,6 +50,8 @@ public class BlockCounter { } 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 countPerTick = (double) count / Math.max((lastTick - tick), 1); if (isActive(player)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java index 43eb40da..b801e324 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java @@ -143,16 +143,6 @@ public class TPSSystem implements Plain { }.runTaskTimer(BauSystem.getInstance(), 1, 1); } - public TypeValidator 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 TPSBaseCommand() { @@ -160,11 +150,6 @@ public class TPSSystem implements Plain { setMessage(BauSystem.MESSAGE); addDefaultHelpMessage("TPSLIMIT_HELP"); } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator player() { - return TPSSystem.this.player(); - } } @AbstractSWCommand.PartOf(TPSBaseCommand.class) @@ -230,11 +215,6 @@ public class TPSSystem implements Plain { super("tick"); setMessage(BauSystem.MESSAGE); } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator player() { - return TPSSystem.this.player(); - } } @AbstractSWCommand.PartOf(TickBaseCommand.class) @@ -403,7 +383,7 @@ public class TPSSystem implements Plain { @Override public Permission permission() { - return Permission.WORLD; + return Permission.BUILD; } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 366cc7a3..004f841b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -243,15 +243,4 @@ public class TraceCommand extends SWCommand { } }; } - - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - if (!Permission.hasPermission(player, Permission.WORLD)) { - messageSender.send("TRACE_MESSAGE_DISALLOWED", player); - return false; - } - return true; - }; - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index 5df27f45..5df2ce7b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -96,6 +96,6 @@ public class TracerBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLD; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java index ab213c83..820b20b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.script.ScriptCommand; import de.steamwar.bausystem.features.script.ScriptRunner; @@ -62,7 +63,7 @@ public class BindCommand extends SWCommand implements Listener { } @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); } @@ -91,6 +92,7 @@ public class BindCommand extends SWCommand implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!event.hasItem()) return; + if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ItemStack itemStack = event.getItem(); ItemMeta meta = itemStack.getItemMeta(); if (meta == null) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java index 290223a2..c534e38d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java @@ -17,7 +17,7 @@ public class BookReplaceCommand extends SWCommand { } @Register("color") - public void color(Player player) { + public void color(@Validator Player player) { ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemMeta itemMeta = itemStack.getItemMeta(); if (itemMeta instanceof BookMeta) { @@ -29,7 +29,7 @@ public class BookReplaceCommand extends SWCommand { } @Register("uncolor") - public void uncolor(Player player) { + public void uncolor(@Validator Player player) { ItemStack itemStack = player.getInventory().getItemInMainHand(); ItemMeta itemMeta = itemStack.getItemMeta(); if (itemMeta instanceof BookMeta) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java index e2de740f..5b87464c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java @@ -34,7 +34,7 @@ public class DebugStickCommand extends SWCommand { } @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)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index 49654a05..e08b40c0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -45,12 +45,12 @@ public class KillAllCommand extends SWCommand { } @Register(description = "OTHER_KILLALL_HELP_SELF") - public void genericCommand(Player player) { + public void genericCommand(@Validator Player player) { genericCommand(player, RegionSelectionType.LOCAL); } @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()); AtomicLong count = new AtomicLong(0); if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java index bd8566ea..e9c2c09a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java @@ -45,13 +45,6 @@ public class SelectCommand extends SWCommand { baurahmenCommand(p, RegionType.TESTBLOCK, regionExtensionType); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator 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) { Point minPoint = region.getMinPoint(regionType, regionExtensionType); Point maxPoint = region.getMaxPoint(regionType, regionExtensionType); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java index 9bb2331d..1f50a2ae 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java @@ -43,7 +43,7 @@ public class SkullCommand extends SWCommand { } @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(); SkullMeta sm = (SkullMeta) is.getItemMeta(); assert sm != null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java index 277eb59a..44bae130 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java @@ -34,7 +34,7 @@ public class StructureVoidCommand extends SWCommand { } @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)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java index 9bb8368f..85f73e04 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; @@ -34,9 +35,9 @@ public class TNTClickListener implements Listener { @EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - if (event.getHand() != EquipmentSlot.HAND) { - return; - } + if (event.getHand() != EquipmentSlot.HAND) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())); + Entity entity = event.getRightClicked(); if (event.getRightClicked() instanceof TNTPrimed) { TNTPrimed tntPrimed = (TNTPrimed) entity; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java index 15f48590..249f4072 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java @@ -66,13 +66,6 @@ public class TimeCommand extends SWCommand { }, s -> tabCompletions); } - @ClassValidator(value = Player.class, local = true) - public TypeValidator validator() { - return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "OTHER_TIME_NO_PERM"); - }; - } - public enum Time { NIGHT(18000), DAY(6000), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java index 725d75b1..c6341818 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java @@ -50,6 +50,6 @@ public class DebugstickBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.MEMBER; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java index 42a4588a..a5f76346 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java @@ -62,6 +62,6 @@ public class KillAllBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.MEMBER; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java index 30ac88a2..6b9b6775 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java @@ -39,7 +39,7 @@ public class NavWandBauGuiItem extends BauGuiItem { } @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.MEMBER; } @Override public ItemStack getItem(Player player) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SchemBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SchemBauGuiItem.java index dc5569e4..027d6c9c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SchemBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SchemBauGuiItem.java @@ -18,7 +18,7 @@ public class SchemBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.BUILD; } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java index 2e90be13..b0feb305 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java @@ -88,7 +88,7 @@ public class SelectBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.BUILD; } @AllArgsConstructor diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java index f9ec57c8..c7e500db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java @@ -54,6 +54,6 @@ public class SkullBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.MEMBER; + return Permission.BUILD; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java index ddfa66d7..9ef2400f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java @@ -40,7 +40,7 @@ public class WorldEditBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.BUILD; } @Override From 78f7e4262979b8ef744afbc4427af26a217840df Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 16:52:59 +0100 Subject: [PATCH 10/29] Fix Permission --- .../src/de/steamwar/bausystem/Permission.java | 17 ++++--- .../bausystem/features/bau/InfoCommand.java | 23 +++++----- .../countingwand/CountingwandGuiItem.java | 2 +- .../bausystem/features/gui/BauGUI.java | 17 +------ .../features/world/SpectatorListener.java | 44 +++++++++++++------ 5 files changed, 58 insertions(+), 45 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 40978989..b25e0fb1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.config.BauServer; import de.steamwar.sql.BauweltMember; +import de.steamwar.sql.SteamwarUser; import lombok.AllArgsConstructor; import org.bukkit.entity.Player; @@ -29,11 +30,9 @@ import java.util.function.Predicate; @AllArgsConstructor public enum Permission { - OWNER(bauweltMember -> { - return bauweltMember.getBauweltID() == BauServer.getInstance().getOwnerID(); - }), + OWNER(bauweltMember -> false), SUPERVISOR(bauweltMember -> { - return OWNER.permissionPredicate.test(bauweltMember); // TODO: Needs to be changed later on + return false; // TODO: Needs to be changed later on }), BUILD(bauweltMember -> { return bauweltMember.isWorld() || bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); @@ -47,9 +46,17 @@ public enum Permission { private final Predicate permissionPredicate; + public boolean hasPermission(BauweltMember bauweltMember) { + if (bauweltMember == null) return false; + return permissionPredicate.test(bauweltMember); + } + public boolean hasPermission(Player member) { + if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) { + return this != SPECTATOR; + } BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauweltMember == null) return this != SPECTATOR; + if (bauweltMember == null) return false; return permissionPredicate.test(bauweltMember); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index 345dc1b3..cdd481ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.features.bau; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; @@ -24,12 +25,7 @@ public class InfoCommand extends SWCommand { super("bauinfo"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - BauSystem.MESSAGE.send("BAU_INFO_COMMAND_HELP", p); - } - - @Register + @Register(description = "BAU_INFO_COMMAND_HELP") public void genericCommand(Player p) { sendBauInfo(p); } @@ -52,11 +48,16 @@ public class InfoCommand extends SWCommand { membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); for (BauweltMember member : members) { - membermessage.append(BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_INFO", p, - SteamwarUser.get(member.getMemberID()).getUserName(), - member.isWorldEdit() ? BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WE_ALLOW", p) : BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WE_DISALLOW", p), - member.isWorld() ? BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WORLD_ALLOW", p) : BauSystem.MESSAGE.parse("BAU_INFO_MEMBER_WORLD_DISALLOW", p) - )); + if (!membermessage.isEmpty()) { + membermessage.append(", "); + } + if (Permission.SUPERVISOR.hasPermission(member)) { + membermessage.append("§c").append(SteamwarUser.get(member.getMemberID()).getUserName()); + } else if (Permission.BUILD.hasPermission(member)) { + membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()); + } else { + membermessage.append("§7").append(SteamwarUser.get(member.getMemberID()).getUserName()); + } } p.sendMessage(membermessage.toString()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java index 7772f9c7..dbeae70d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java @@ -48,6 +48,6 @@ public class CountingwandGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLDEDIT; + return Permission.MEMBER; } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java index 74a915da..92289699 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -108,26 +108,13 @@ public class BauGUI { if (!permission.hasPermission(p)) { List lore = meta.getLore(); if (lore == null) { - lore = Collections.singletonList(BauSystem.MESSAGE.parse(permissionString(permission), p)); + lore = Collections.singletonList(BauSystem.MESSAGE.parse("NO_PERMISSION", p)); } else { - lore.add(BauSystem.MESSAGE.parse(permissionString(permission), p)); + lore.add(BauSystem.MESSAGE.parse("NO_PERMISSION", p)); } meta.setLore(lore); } itemStack.setItemMeta(meta); return itemStack; } - - private static String permissionString(Permission permission) { - switch (permission) { - case OWNER: - return "GUI_NO_OWNER"; - case WORLD: - return "GUI_NO_WORLD"; - case WORLDEDIT: - return "GUI_NO_WORLDEDIT"; - default: - return "GUI_NO_MEMBER"; - } - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 942d8eb7..f80661aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -19,11 +19,10 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -45,8 +44,13 @@ public class SpectatorListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + if (Permission.SUPERVISOR.hasPermission(event.getPlayer())) { + return; + } if (!anySupervisorOnline(null)) { - event.getPlayer().kickPlayer(""); + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + event.getPlayer().kickPlayer(""); + }, 1); } if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { Player p = event.getPlayer(); @@ -60,6 +64,15 @@ public class SpectatorListener implements Listener { } } + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + if (!anySupervisorOnline(event.getPlayer())) { + Bukkit.getOnlinePlayers().forEach(player -> { + player.kickPlayer(""); + }); + } + } + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { ItemStack itemStack = event.getCurrentItem(); @@ -82,15 +95,6 @@ public class SpectatorListener implements Listener { } } - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - if (!anySupervisorOnline(event.getPlayer())) { - Bukkit.getOnlinePlayers().forEach(player -> { - player.kickPlayer(""); - }); - } - } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (event.getMessage().startsWith("/schem save") || event.getMessage().startsWith("//schem save") || event.getMessage().startsWith("/schematic save") || event.getMessage().startsWith("//schematic save")) { @@ -138,7 +142,21 @@ public class SpectatorListener implements Listener { } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onPlayerBucket(PlayerBucketEvent event) { + public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerBucketEntity(PlayerBucketEntityEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerBucketFill(PlayerBucketFillEvent event) { if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { event.setCancelled(true); } From a61f1e2c8c6f002aacb401e0aee06dd0a9efa7a6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 18:08:48 +0100 Subject: [PATCH 11/29] Fix Permission for ServerLib.getBlockAt and setBlockAt and exec --- BauSystem_Main/src/de/steamwar/bausystem/Permission.java | 2 +- .../de/steamwar/bausystem/features/bau/InfoCommand.java | 5 +++-- .../bausystem/features/script/lua/SteamWarLuaPlugin.java | 1 + .../bausystem/features/script/lua/libs/ServerLib.java | 7 +++++++ .../bausystem/features/world/AxiomPermissionCheck.java | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index b25e0fb1..50251be3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -56,7 +56,7 @@ public enum Permission { return this != SPECTATOR; } BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauweltMember == null) return false; + if (bauweltMember == null) return this == SPECTATOR; return permissionPredicate.test(bauweltMember); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index cdd481ea..1a7e1551 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -47,10 +47,11 @@ public class InfoCommand extends SWCommand { StringBuilder membermessage = new StringBuilder(); membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); - for (BauweltMember member : members) { - if (!membermessage.isEmpty()) { + for (int i = 0; i < members.size(); i++) { + if (i != 0) { membermessage.append(", "); } + BauweltMember member = members.get(i); if (Permission.SUPERVISOR.hasPermission(member)) { membermessage.append("§c").append(SteamwarUser.get(member.getMemberID()).getUserName()); } else if (Permission.BUILD.hasPermission(member)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java index b2bf51cc..4aefce8f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java @@ -123,6 +123,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction { return LuaValue.NIL; } + command = preprocessEvent.getMessage().substring(1); Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); String[] commandSplit = command.split(" "); if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java index 80134fba..be55dcdd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.script.lua.libs; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.core.TPSWatcher; import de.steamwar.inventory.SWItem; @@ -50,6 +51,9 @@ public class ServerLib implements LuaLib { serverLib.set("getBlockAt", new OneArgFunction() { @Override public LuaValue call(LuaValue arg1) { + if (!Permission.SUPERVISOR.hasPermission(player)) { + return LuaValue.NIL; + } LuaTable pos = arg1.checktable(); return valueOf(player.getWorld().getBlockAt(pos.get("x").checkint(), pos.get("y").checkint(), pos.get("z").checkint()).getType().name()); } @@ -57,6 +61,9 @@ public class ServerLib implements LuaLib { serverLib.set("setBlockAt", new TwoArgFunction() { @Override public LuaValue call(LuaValue arg1, LuaValue arg2) { + if (!Permission.SUPERVISOR.hasPermission(player)) { + return LuaValue.NIL; + } LuaTable pos = arg1.checktable(); LuaString material = arg2.checkstring(); Material mat = SWItem.getMaterial(material.tojstring()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java index e006e184..bdfe3d40 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java @@ -32,7 +32,7 @@ public class AxiomPermissionCheck implements Listener { @EventHandler public void onAxiomHandshake(AxiomHandshakeEvent event) { - if (Permission.BUILD.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; event.setCancelled(true); } } From 6305453e1588e961334edd99b448c7f19493dac2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 21:34:29 +0100 Subject: [PATCH 12/29] Fix Permission for SignEdit and other stuff --- .../src/de/steamwar/bausystem/Permission.java | 4 +-- .../bausystem/features/bau/InfoCommand.java | 33 ++++++++++--------- .../features/world/SignEditFrom20.java | 2 ++ .../features/world/SignEditUntil19.java | 2 ++ .../features/world/SpectatorListener.java | 26 ++++++++++++--- 5 files changed, 45 insertions(+), 22 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 50251be3..8e51d97d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -32,10 +32,10 @@ public enum Permission { OWNER(bauweltMember -> false), SUPERVISOR(bauweltMember -> { - return false; // TODO: Needs to be changed later on + return bauweltMember.isWorld(); }), BUILD(bauweltMember -> { - return bauweltMember.isWorld() || bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); + return bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); }), SPECTATOR(bauweltMember -> { return !BUILD.permissionPredicate.test(bauweltMember); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index 1a7e1551..9f53f563 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -43,24 +43,27 @@ public class InfoCommand extends SWCommand { } } - List members = BauweltMember.getMembers(bauServer.getOwnerID()); - StringBuilder membermessage = new StringBuilder(); - membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); + if (Permission.BUILD.hasPermission(p)) { + List members = BauweltMember.getMembers(bauServer.getOwnerID()); + StringBuilder membermessage = new StringBuilder(); + membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); - for (int i = 0; i < members.size(); i++) { - if (i != 0) { - membermessage.append(", "); - } - BauweltMember member = members.get(i); - if (Permission.SUPERVISOR.hasPermission(member)) { - membermessage.append("§c").append(SteamwarUser.get(member.getMemberID()).getUserName()); - } else if (Permission.BUILD.hasPermission(member)) { - membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()); - } else { - membermessage.append("§7").append(SteamwarUser.get(member.getMemberID()).getUserName()); + for (int i = 0; i < members.size(); i++) { + if (i != 0) { + membermessage.append("§8, "); + } + BauweltMember member = members.get(i); + if (Permission.SUPERVISOR.hasPermission(member)) { + membermessage.append("§e"); + } else if (Permission.BUILD.hasPermission(member)) { + membermessage.append("§6"); + } else { + membermessage.append("§7"); + } + membermessage.append(SteamwarUser.get(member.getMemberID()).getUserName()); } + p.sendMessage(membermessage.toString()); } - p.sendMessage(membermessage.toString()); StringBuilder tpsMessage = new StringBuilder(); tpsMessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_TPS", p)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java index 7956a3ef..df4935dc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.world; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.PlaceItemUtils; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; @@ -81,6 +82,7 @@ public class SignEditFrom20 implements Listener { } private void edit(Player player, Block block) { + if (Permission.SPECTATOR.hasPermission(player)) return; Sign sign = (Sign) block.getState(); Side side = signSide(player, block); SignSide signSide = sign.getSide(side); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java index 19184032..89a4120d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.world; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MaxVersion; import org.bukkit.Bukkit; @@ -68,6 +69,7 @@ public class SignEditUntil19 implements Listener { } private void edit(Player player, Block block) { + if (Permission.SPECTATOR.hasPermission(player)) return; Sign sign = (org.bukkit.block.Sign) block.getState(); String[] lines = sign.getLines(); for (int i = 0; i < lines.length; i++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index f80661aa..a15c1e4f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -27,10 +27,11 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockCanBuildEvent; -import org.bukkit.event.block.BlockMultiPlaceEvent; -import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.*; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityEnterBlockEvent; +import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; @@ -73,7 +74,7 @@ public class SpectatorListener implements Listener { } } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler public void onInventoryClick(InventoryClickEvent event) { ItemStack itemStack = event.getCurrentItem(); if (itemStack == null || !itemStack.hasItemMeta()) { @@ -161,4 +162,19 @@ public class SpectatorListener implements Listener { event.setCancelled(true); } } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onPlayerDropItem(PlayerDropItemEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onEntityPickupItem(EntityPickupItemEvent event) { + if (!(event.getEntity() instanceof Player)) return; + if (Permission.SPECTATOR.hasPermission((Player) event.getEntity())) { + event.setCancelled(true); + } + } } From 5556bd7875548bc5210989cb1dacc006bf894b44 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 21:39:25 +0100 Subject: [PATCH 13/29] Update SimulatorBauGuiItem Permission --- .../bausystem/features/simulator/SimulatorBauGuiItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java index 86476fe6..d03dc55c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java @@ -55,6 +55,6 @@ public class SimulatorBauGuiItem extends BauGuiItem { @Override public Permission permission() { - return Permission.WORLD; + return Permission.BUILD; } } From f5e4d725fe2ef6eac3d45d8755cf907588156324 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 22 Dec 2023 16:55:41 +0100 Subject: [PATCH 14/29] Add BauMemberUpdate and BauMemberUpdateEvent --- .../features/world/BauMemberUpdate.java | 50 +++++++++++++++++++ .../bausystem/utils/BauMemberUpdateEvent.java | 36 +++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java new file mode 100644 index 00000000..fe90be02 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -0,0 +1,50 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.world; + +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import de.steamwar.network.packets.PacketHandler; +import de.steamwar.network.packets.server.BaumemberUpdatePacket; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +@Linked +public class BauMemberUpdate extends PacketHandler { + + @Handler + public void baumemberUpdate(BaumemberUpdatePacket baumemberUpdatePacket) { + Bukkit.getPluginManager().callEvent(new BauMemberUpdateEvent()); + } + + @Linked + public static class TestCommand extends SWCommand { // TODO: Remove before merge + + public TestCommand() { + super("test"); + } + + @Register + public void test(Player player) { + PacketHandler.handlePacket(new BaumemberUpdatePacket()); + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java new file mode 100644 index 00000000..4d26dc6f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java @@ -0,0 +1,36 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.utils; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class BauMemberUpdateEvent extends Event { + + private static final HandlerList handlers = new HandlerList(); + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} From b00babdcbd208a920c01b3d916df030916109e1b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 23 Dec 2023 08:01:38 +0100 Subject: [PATCH 15/29] Fix permission messages --- BauSystem_Main/src/BauSystem.properties | 50 ------------------- BauSystem_Main/src/BauSystem_de.properties | 50 ------------------- .../bausystem/features/gui/BauGUI.java | 2 +- .../features/world/SpectatorListener.java | 50 +++++-------------- .../bausystem/features/world/StopCommand.java | 2 +- .../features/world/WorldEditListener.java | 2 +- 6 files changed, 16 insertions(+), 140 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 0231d101..3928e0f4 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -119,7 +119,6 @@ BACKUP_HELP_LOAD=§8/§ebackup load §8[§7BackupName§8] §8- §7Load a region BACKUP_HELP_LIST=§8/§ebackup list §8- §7List all region backups BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Open the backup GUI BACKUP_REGION_NO_REGION=§cYou are not inside any region -BACKUP_NO_PERMS=§You do not have permission to use the backup system BACKUP_CREATE_SUCCESS=§7Backup created BACKUP_CREATE_FAILURE=§cBackup failed BACKUP_CREATE_NO_CHANGE=§7No changes to save @@ -133,11 +132,6 @@ BACKUP_LORE=§eClick to load # Bau BAU_COMMAND_HELP_INFO = §8/§ebau info §8- §7Alias for §8/§ebauinfo -BAU_COMMAND_HELP_TOGGLEWE = §8/§ebau togglewe §8[§7Player§8] §8- §7Edit the WorldEdit permissions of a player -BAU_COMMAND_HELP_TOGGLEWORLD = §8/§ebau toggleworld §8[§7Player§8] §8- §7Edit the World permissions of a player -BAU_UNKNOWN_PLAYER = §cUnknown Player -BAU_NO_PLAYER = §cThe player is no member of your world! -BAU_NO_WORLD = §cThis is not your world! BAU_INFO_ITEM_NAME = §eBau-Management ## This is used in BauInfoBauGuiItem.java @@ -151,11 +145,6 @@ BAU_INFO_ITEM_LORE_ITEMS = §7Items§8: §e{0} BAU_INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Information regarding this build server BAU_INFO_COMMAND_OWNER = §7Owner§8: §e{0} BAU_INFO_COMMAND_MEMBER = §7Member §8[§7{0}§8]§8: §e -BAU_INFO_MEMBER_INFO = §e{0}§8[{1}§8,{2}§8] §8 -BAU_INFO_MEMBER_WE_ALLOW = §aWE -BAU_INFO_MEMBER_WE_DISALLOW = §cWE -BAU_INFO_MEMBER_WORLD_ALLOW = §aW -BAU_INFO_MEMBER_WORLD_DISALLOW = §cW BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1} BAU_INFO_COMMAND_TPS = §7TPS§8:§e @@ -214,11 +203,6 @@ HOTBAR_INVENTORY=Standard hotbar # GUI GUI_EDITOR_ITEM_NAME=§eGui editor GUI_NAME=Bau GUI -GUI_NO_PERMISSION=§cYou do not have enough permissions for this -GUI_NO_OWNER=§cYou are not the owner of this World -GUI_NO_WORLD=§cYou do not have permissions to change the World -GUI_NO_WORLDEDIT=§cYou do not have permissions to use WorldEdit -GUI_NO_MEMBER=§cYou need to be a member of this World GUI_ITEM_LORE1=§7Use this item to open the bau gui GUI_ITEM_LORE2=§7or press swap hands twice. GUI_EDITOR_TITLE=Bau GUI Editor @@ -269,7 +253,6 @@ SHIELD_PRINTING_HELP_STEP_7 = §87. §7Apply the shield printing with §8/§eshi SHIELD_PRINTING_NO_REGION = §cYou are not in a region. SHIELD_PRINTING_NOT_RUNNING = §cThe shield printing is not running. -SHIELD_PRINTING_DISALLOWED = §cYou are not allowed to use shield printing here. SHIELD_PRINTING_BOSSBAR = §fMovements: {0} SHIELD_PRINTING_BOSSBAR_COPIED = §fMovements: {0} Copied: {1} @@ -306,7 +289,6 @@ SIMULATOR_CHANGE_HELP = §8/§esimulator change §8-§7 Change your simulator wa SIMULATOR_DELETE_HELP = §8/§esimulator delete §8[§7name§8] §8-§7 Deletes the simulator SIMULATOR_START_HELP = §8/§esimulator start §8[§7name§8] §8-§7 Starts the simulator SIMULATOR_COPY_HELP = §8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Copy the simulator -SIMULATOR_NO_PERMS = §cYou are not allowed to use the simulator here SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator @@ -485,7 +467,6 @@ TPSLIMIT_GUI_ITEM_NAME = §eTPS limiter TPSLIMIT_GUI_ITEM_LORE = §7Currently: §e{0} TPSLIMIT_ANVIL_GUI = New TPS limit TPSLIMIT_CURRENT = §7Current TPS limit§8: §e{0} -TPSLIMIT_NO_PERMS = §cYou are not allowed to use the TPS-Limiter here TPSLIMIT_SET = §eSet TPS limit to {0} TPSLIMIT_FROZEN = §eTPS frozen @@ -511,7 +492,6 @@ TRACE_MESSAGE_DELETE = §cAll TNT-positions deleted TRACE_MESSAGE_SHOW = §aAll TNT-positions shown TRACE_MESSAGE_HIDE = §cAll TNT-positions hidden TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate -TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here TRACE_MESSAGE_SHOW_AT = §aTNT-positions shown with {0} at {1} TRACE_MESSAGE_SHOW_FROM = §aAll TNT-positions shown with {0} from {1} TRACE_MESSAGE_SHOW_FROM_TO = §aAll TNT-positions shown with {0} from {1} to {2} @@ -700,7 +680,6 @@ OTHER_CLEAR_HELP_PLAYER=§8/§eclear §8[§7Player§8] §8- §7Clears a player i OTHER_CLEAR_CLEARED=Your inventory was cleared. OTHER_CLEAR_FROM=Your invetnory was cleared by {0}. OTHER_CLEAR_TO=The inventory of {0} §7was cleared. -OTHER_CLEAR_NO_PERMS=§cYou are not allowed to clear other's inventory here. OTHER_DECLUTTER_HELP=§8/§edeclutter §8- §7Organise your inventory OTHER_DECLUTTER_DONE=§aYour inventory was organised. OTHER_GAMEMODE_UNKNOWN=§cUnknown gamemode. @@ -716,7 +695,6 @@ OTHER_TELEPORT_SELF_2=§cBlocks left to travel: 0; ETA: 0:00 OTHER_TELEPORT_SELF_3=§cA little Movement is important. OTHER_TELEPORT_SELF_4=§cFor such a distance? OTHER_TIME_HELP=§8/§etime §8<§7Time 0=Morining§8, §76000=Midday§8, §718000=Midnight§8> - §7Sets the time on the Build -OTHER_TIME_NO_PERM=§cYou are not allowed to change the time here OTHER_TIME_INVALID=§cPlease input a time between 0 and 24000 OTHER_TIME_RESULT=§7§oWhooosh OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m @@ -782,17 +760,6 @@ MATERIAL_FLAMMABLE=§8- §eFlammable block MATERIAL_BURNABLE=§8- §eBurnable block MATERIAL_WATERLOGGABLE=§8- §eWaterloggable block MATERIAL_UNMOVABLE=§8- §eUnmovable block -# Redstonetester -RT_HELP=§8/§eredstonetester §8-§7 Gives you the redstone tester -RT_GIVEN=§7Measure the time between activation of components -RT_ITEM_NAME=§eRedstonetester -RT_ITEM_LORE_1=§eLeftclick block §8-§7 Sets the 1. Position -RT_ITEM_LORE_2=§eRightclick block §8-§7 Sets the 2. Position -RT_ITEM_LORE_3=§eShift-rightclick in air §8-§7 Reset -RT_LOC=§8: §e{0} {1} {2} -RT_INVALID_LOC=§cUnknown Position -RT_RESULT=§7Difference§8: §e{0}§7 Ticks §8,§7 R-Ticks §e{1} -RT_ACTIVATE=§7Positions deleted§8. # Region Items REGION_ITEM_COLOR=§7Color: §e{0} REGION_ITEM_COLOR_CHOOSE=Choose color @@ -818,24 +785,18 @@ REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of REGION_COLOR_HELP_COLOR_TYPE=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Sets the color of the region or globally REGION_COLOR_GLOBAL=§7All regions color set to §e{0} REGION_COLOR_NO_REGION=§cYou are currently not in any region -REGION_COLOR_NO_PERMS=§cThis is not your world! REGION_FIRE_HELP=§8/§efire §8- §7Toggle fire damage -REGION_FIRE_NO_PERMS=§cYou are not allowed to toggle fire damage here REGION_FIRE_ENABLED=§cFire damage deactivated in this region REGION_FIRE_DISABLED=§aFire damage activated in this region REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze -REGION_FREEZE_NO_PERMS=§cYou are not allowed to freeze this world REGION_FREEZE_ENABLED=§cRegion frozen REGION_FREEZE_DISABLED=§aRegion thawed REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items -REGION_ITEMS_NO_PERMS=§cYou are not allowed to toggle items in this world REGION_ITEMS_ENABLED=§aItems enabled in this region -REGION_ITEMS_DISABLED_GLOBAL=§cItems disabled in this world REGION_ITEMS_DISABLED=§cItems disabled in this region REGION_PROTECT_HELP=§8/§eprotect §8- §7Protect the region REGION_PROTECT_DISABLE=§cProtection disabled REGION_PROTECT_ENABLE=§aProtection enabled -REGION_PROTECT_NO_PERMS=§cYou are not allowed to protect the floor here REGION_PROTECT_FALSE_REGION=§cYou are not currently in a (M)WG-region REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7undo the last 20 /testblock or /reset REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7redo the last 20 §8/§7rg undo @@ -860,7 +821,6 @@ REGION_REGION_TP_COPY=§7Teleported to the copy point REGION_REGION_TP_TEST_BLOCK=§7Teleported to the tesblock REGION_REGION_TP_UNKNOWN=§cUndefined teleport point REGION_REGION_NO_REGION=§cYou are not inside any region -REGION_REGION_NO_PERMS=§cYou are not allowed to change the region REGION_REGION_CHANGETYPE_INFO=§7RRegion type is §e{0} REGION_REGION_CHANGETYPE_UNKNOWN=§cRegion type is invalid REGION_REGION_CHANGETYPE_INVALID=§cRegion type is not allowed here @@ -878,7 +838,6 @@ REGION_RESET_HELP_RESET=§8/§ereset §8- §7Resets the region REGION_RESET_HELP_SCHEMATIC=§8/§ereset §8[§7Schematic§8] §8- §7Resets the region using a schematic REGION_RESET_RESETED=§7Region reset REGION_RESET_ERROR=§cError reseting the region -REGION_RESET_NO_PERMS=§cYou are not allowed to reset the region here REGION_RESET_NO_REGION=§cYou are currently not in any region REGION_TB_HELP_RESET=§8/§etestblock §8- §7Reset the dummy REGION_TB_HELP_RESET_EXTENSION=§8/§etestblock §8[§7ExtensionType§8] §8- §7Reset the dummy @@ -886,7 +845,6 @@ REGION_TB_HELP_SCHEMATIC=§8/§etestblock §8[§7Schematic§8] §8- §7Reset the REGION_TB_HELP_SCHEMATIC_EXTENSION=§8/§etestblock §8[§7Schematic§8] §8[§7ExtensionType§8] §8- §7Reset the dummy using a schematic REGION_TB_DONE=§7Dummy reset REGION_TB_ERROR=§cError resetting the dummy -REGION_TB_NO_PERMS=§cYou are not allowed to reset the dummy here REGION_TB_NO_REGION=§cYou are currently not in any region REGION_TB_NO_SCHEMSHARING=§cYou currently cannot share schematics until {0}. REGION_TB_NO_SCHEMRECEIVING=§cThe Owner of this build server cannot receive any schematics until {0}. @@ -896,7 +854,6 @@ REGION_TNT_ON=§aTNT-Damage activated REGION_TNT_OFF=§cTNT-Damage deactivated REGION_TNT_TB=§aTNT-Damage activated outside the building area REGION_TNT_BUILD=§aTNT-Damage activated outside the testblok area -REGION_TNT_NO_PERMS=§cYou are not allowed to toggle tnt damage here REGION_TNT_BUILD_DESTROY=§cAn explosion would have destroyed blocks in the building area REGION_TNT_TB_DESTROY=§cAn explosion would have destroyed blocks in the testblock area @@ -915,7 +872,6 @@ PANZERN_PREPARE1 = §71. Check, if barrels reach until border of armor. PANZERN_PREPARE2 = §72. Carpet on the floor in walkways helps with armoring. PANZERN_PREPARE3 = §73. Shieldtechnology should be encased. PANZERN_PREPARE4 = §74. Standing in the region that is being armored can improve armoring. -PANZERN_NO_PERM = §cYou are not allowed to use the armoring system here PANZERN_NO_WORLDEDIT = §cYou have no WorldEdit selcetion PANZERN_PROGRESS = §e{0} §7Blocks left, §e{1} §7Blocks per second, §e{2} §7block delta PANZERN_DONE = §aDone @@ -925,7 +881,6 @@ LAUFBAU_HELP = §8/§elaufbau §8[§7smallest§8|§7blastresistant§8] §8- §7B LAUFBAU_HELP_SETTINGS = §8/§elaufbau settings §8- §7Opens the settings GUI LAUFBAU_PREPARE1 = §71. Trace the cannons as often as necessary, in all modes. LAUFBAU_PREPARE2 = §72. Try to delete all fails from the traces. -LAUFBAU_NO_PERM = §cYou are not allowed to use the barrel building system here LAUFBAU_NO_WORLDEDIT = §cYou don't have a WorldEdit selection LAUFBAU_STATE_FILTERING_TRACES = Filtering traces LAUFBAU_STATE_PROCESSING_TRACES = Connnecting traces @@ -1037,7 +992,6 @@ LAUFBAU_TILT_PARTIAL = §8-§7 Tilt partial # UTILS SELECT_HELP = §8/§eselect §8[§7RegionsTyp§8] §8- §7Select a region type SELECT_EXTENSION_HELP = §8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension -SELECT_NO_PERMS = §cYou are not allowed to use the slection tool here SELECT_GLOBAL_REGION = §cThe global region cannot be selected SELECT_NO_TYPE = §cThis region has no {0} SELECT_NO_EXTENSION = §cThis region has no extension @@ -1091,7 +1045,6 @@ PISTON_HELP_3 = §7Count is yellow, if too many blocks are present. PISTON_INFO = §7Moved Blocks {0}{1}§8/§712 # Warp -WARP_DISALLOWED = §cYou are not allowed to use the warp here WARP_LOC_X = §7X§8: §e{0} WARP_LOC_Y = §7Y§8: §e{0} WARP_LOC_Z = §7Z§8: §e{0} @@ -1117,12 +1070,9 @@ WARP_HELP_LIST=§8/§ewarp list §8- §7List all warps # WORLD STOP_HELP = §8/§estop §8- §7Stops the server -STOP_NO_PERMS = §cYou do not have the permission to stop the server STOP_MESSAGE = §eServer is stopping -WORLD_EDIT_NO_PERMS = §cYou do not have the permission to use WorldEdit KICKALL_HELP = §8/§ekickall §8- §7Kick all players from the server except the owner -KICKALL_NO_PERM = §cThis is not your world! # Techhider TECHHIDER_HELP = §8/§etechhider §8- §7Toggle Techhider diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index f81caadd..ecb3deae 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -118,7 +118,6 @@ BACKUP_HELP_LOAD=§8/§ebackup load §8[§7BackupName§8] §8- §7 Lade ein Back BACKUP_HELP_LIST=§8/§ebackup list §8- §7Liste alle Backups der Region auf BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Öffne die Backups in einer GUI BACKUP_REGION_NO_REGION=§cDu bist in keiner Region -BACKUP_NO_PERMS=§cDu darfst hier nicht das Backup System verwenden BACKUP_CREATE_SUCCESS=§7Das Backup wurde erstellt BACKUP_CREATE_FAILURE=§cDas Backup erstellen ist schiefgegangen BACKUP_CREATE_NO_CHANGE=§7Die Region hat keine Veränderung @@ -132,11 +131,6 @@ BACKUP_LORE=§eKlicken zum Laden # Bau BAU_COMMAND_HELP_INFO = §8/§ebau info §8- §7Alias für §8/§ebauinfo -BAU_COMMAND_HELP_TOGGLEWE = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers -BAU_COMMAND_HELP_TOGGLEWORLD = §8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Welt Rechte eines Spielers -BAU_UNKNOWN_PLAYER = §cUnbekannter Spieler -BAU_NO_PLAYER = §cDer Spieler ist kein Mitglied deiner Welt! -BAU_NO_WORLD = §cDies ist nicht deine Welt! BAU_INFO_ITEM_NAME = §eBau-Management ## This is used in BauInfoBauGuiItem.java @@ -150,11 +144,6 @@ BAU_INFO_ITEM_LORE_PROTECT = §7Protect§8: §e{0} BAU_INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Gibt Informationen über den Bau BAU_INFO_COMMAND_OWNER = §7Besitzer§8: §e{0} BAU_INFO_COMMAND_MEMBER = §7Mitglieder §8[§7{0}§8]§8: §e -BAU_INFO_MEMBER_INFO = §e{0}§8[{1}§8,{2}§8] §8 -BAU_INFO_MEMBER_WE_ALLOW = §aWE -BAU_INFO_MEMBER_WE_DISALLOW = §cWE -BAU_INFO_MEMBER_WORLD_ALLOW = §aW -BAU_INFO_MEMBER_WORLD_DISALLOW = §cW BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1} BAU_INFO_COMMAND_TPS = §7TPS§8:§e @@ -213,11 +202,6 @@ HOTBAR_INVENTORY=Standard Hotbar # GUI GUI_EDITOR_ITEM_NAME=§eGui Editor GUI_NAME=Bau GUI -GUI_NO_PERMISSION=§cDu hast nicht genug Rechte um dies zu tun -GUI_NO_OWNER=§cDas ist nicht deine Bauwelt -GUI_NO_WORLD=§cDu darfst hier die Welt nicht einstellen -GUI_NO_WORLDEDIT=§cDu darfst hier kein Worldedit benutzen -GUI_NO_MEMBER=§cDu musst ein Member der Bauwelt sein GUI_ITEM_LORE1=§7Du kannst dieses Item zum Öffnen der BauGUI nutzen GUI_ITEM_LORE2=§7oder Doppel F (Swap hands) drücken. GUI_EDITOR_TITLE=Bau GUI Editor @@ -261,7 +245,6 @@ SHIELD_PRINTING_HELP_STEP_7 = §87. §7Wende das gedruckte mit §8/§eshieldprin SHIELD_PRINTING_NO_REGION = §cDu bist in keiner Region. SHIELD_PRINTING_NOT_RUNNING = §cShield printing ist nicht aktiv. -SHIELD_PRINTING_DISALLOWED = §cDu darfst Shield printing nicht benutzen. SHIELD_PRINTING_BOSSBAR = §fBewegungen: {0} SHIELD_PRINTING_BOSSBAR_COPIED = §fBewegungen: {0} Kopiert: {1} @@ -298,7 +281,6 @@ SIMULATOR_CHANGE_HELP = §8/§esimulator change §8-§7 Wechsel zu einem anderen SIMULATOR_DELETE_HELP = §8/§esimulator delete §8[§7name§8] §8-§7 Löscht den Simulator SIMULATOR_START_HELP = §8/§esimulator start §8[§7name§8] §8-§7 Startet die Simulation SIMULATOR_COPY_HELP = §8/§esimulator copy §8[§7to-copy§8] §8[§7name§8] §8-§7 Kopiert einen Simulator -SIMULATOR_NO_PERMS = §cDu darfst hier nicht den Simulator nutzen SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator @@ -454,7 +436,6 @@ TPSLIMIT_GUI_ITEM_NAME = §eTPS Limiter TPSLIMIT_GUI_ITEM_LORE = §7Aktuell: §e{0} TPSLIMIT_ANVIL_GUI = Neues TPS Limit TPSLIMIT_CURRENT = §7Jetziges TPS limit§8: §e{0} -TPSLIMIT_NO_PERMS = §cDu darfst hier nicht den TPS-Limiter nutzen TPSLIMIT_SET = §eTPS limit auf {0} gesetzt. TPSLIMIT_FROZEN = §eTPS eingefroren. @@ -480,7 +461,6 @@ TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt TRACE_MESSAGE_HIDE = §cAlle TNT-Positionen ausgeblendet TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden -TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen TRACE_MESSAGE_SHOW_AT = §aTNT-positions angezeigt mit {0} bei {1} TRACE_MESSAGE_SHOW_FROM = §aAll TNT-positions angezeigt mit {0} von {1} TRACE_MESSAGE_SHOW_FROM_TO = §aAll TNT-positions angezeigt mit {0} von {1} bis {2} @@ -667,7 +647,6 @@ OTHER_CLEAR_HELP_PLAYER=§8/§eclear §8[§7Player§8] §8- §7Leere ein Spieler OTHER_CLEAR_CLEARED=Dein Inventar wurde geleert. OTHER_CLEAR_FROM=Dein Inventar wurde von {0} §7geleert. OTHER_CLEAR_TO=Das Inventar von {0} §7wurde geleert. -OTHER_CLEAR_NO_PERMS=§cDu darfst hier keine fremden Inventare leeren. OTHER_DECLUTTER_HELP=§8/§edeclutter §8- §7Räume dein Inventar auf OTHER_DECLUTTER_DONE=§aDein Inventar wurde aufgeräumt. OTHER_GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus. @@ -683,7 +662,6 @@ OTHER_TELEPORT_SELF_2=§cNoch zu reisende Blöcke: 0; ETA: 0:00 OTHER_TELEPORT_SELF_3=§cEin wenig bewegung muss ein. OTHER_TELEPORT_SELF_4=§cFür eine solche Distanz? OTHER_TIME_HELP=§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> - §7Setzt die Zeit auf dem Bau -OTHER_TIME_NO_PERM=§cDu darfst hier nicht die Zeit ändern OTHER_TIME_INVALID=§cBitte gib eine Zahl zwischen 0 und 24000 an OTHER_TIME_RESULT=§7§oWhooosh OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m @@ -745,17 +723,6 @@ MATERIAL_INTERACTABLE=§8- §eInterargierbarer Block MATERIAL_FLAMMABLE=§8- §eFlammbarer Block MATERIAL_BURNABLE=§8- §eBrennbarer Block MATERIAL_WATERLOGGABLE=§8- §eWasserspeicherbarer Block -# Redstonetester -RT_HELP=§8/§eredstonetester §8-§7 Gibt den RedstoneTester -RT_GIVEN=§7Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten -RT_ITEM_NAME=§eRedstonetester -RT_ITEM_LORE_1=§eLinksklick Block §8-§7 Setzt die 1. Position -RT_ITEM_LORE_2=§eRechtsklick Block §8-§7 Setzt die 2. Position -RT_ITEM_LORE_3=§eShift-Rechtsklick Luft §8-§7 Zurücksetzten -RT_LOC=§8: §e{0} {1} {2} -RT_INVALID_LOC=§cUnbekannte Position -RT_RESULT=§7Differenz§8: §e{0}§7 Ticks §8,§7 R-Ticks §e{1} -RT_ACTIVATE=§7Positionen gelöscht§8. # Region Items REGION_ITEM_COLOR=§7Color: §e{0} REGION_ITEM_COLOR_CHOOSE=Farbe Wählen @@ -781,24 +748,18 @@ REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe de REGION_COLOR_HELP_COLOR_TYPE=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global REGION_COLOR_GLOBAL=§7Alle Regions farben auf §e{0}§7 gesetzt REGION_COLOR_NO_REGION=§cDu befindest dich derzeit in keiner Region -REGION_COLOR_NO_PERMS=§cDies ist nicht deine Welt! REGION_FIRE_HELP=§8/§efire §8- §7Toggle Feuerschaden -REGION_FIRE_NO_PERMS=§cDu darfst hier nicht Feuerschaden (de-)aktivieren REGION_FIRE_ENABLED=§cRegions Feuerschaden deaktiviert REGION_FIRE_DISABLED=§aRegions Feuerschaden aktiviert REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze -REGION_FREEZE_NO_PERMS=§cDu darfst diese Welt nicht einfrieren REGION_FREEZE_ENABLED=§cRegion eingefroren REGION_FREEZE_DISABLED=§aRegion aufgetaut REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items -REGION_ITEMS_NO_PERMS=§cDu darfst hier nicht Items (de-)aktivieren REGION_ITEMS_ENABLED=§aItems aktiviert in dieser Region REGION_ITEMS_DISABLED=§cItems deaktiviert in dieser Region -REGION_ITEMS_DISABLED_GLOBAL=§cItems sind auf dem Server deaktiviert. REGION_PROTECT_HELP=§8/§eprotect §8- §7Schütze die Region REGION_PROTECT_DISABLE=§cBoden Schutz aufgehoben REGION_PROTECT_ENABLE=§aBoden geschützt -REGION_PROTECT_NO_PERMS=§cDu darfst hier nicht den Boden schützen REGION_PROTECT_FALSE_REGION=§cDu befindest dich derzeit in keiner (M)WG-Region REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo @@ -823,7 +784,6 @@ REGION_REGION_TP_COPY=§7Zum Kopierpunkt teleportiert REGION_REGION_TP_TEST_BLOCK=§7Zum Testblock teleportiert REGION_REGION_TP_UNKNOWN=§cNicht definierter Teleportierpunkt REGION_REGION_NO_REGION=§cDu bist in keiner Region -REGION_REGION_NO_PERMS=§cDu darfst hier nicht die Region verändern REGION_REGION_CHANGETYPE_INFO=§7Regions Type ist §e{0} REGION_REGION_CHANGETYPE_UNKNOWN=§cRegions Type ist nicht valide REGION_REGION_CHANGETYPE_INVALID=§cRegions Type ist nicht erlaubt hier @@ -841,7 +801,6 @@ REGION_RESET_HELP_RESET=§8/§ereset §8- §7Setzte die Region zurück REGION_RESET_HELP_SCHEMATIC=§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück REGION_RESET_RESETED=§7Region zurückgesetzt REGION_RESET_ERROR=§cFehler beim Zurücksetzen der Region -REGION_RESET_NO_PERMS=§cDu darfst hier nicht die Region zurücksetzen REGION_RESET_NO_REGION=§cDu befindest dich derzeit in keiner Region REGION_TB_HELP_RESET=§8/§etestblock §8- §7Setzte den Testblock zurück REGION_TB_HELP_RESET_EXTENSION=§8/§etestblock §8[§7ExtensionType§8] §8- §7Setzte den Testblock zurück @@ -849,7 +808,6 @@ REGION_TB_HELP_SCHEMATIC=§8/§etestblock §8[§7Schematic§8] §8- §7Setzte de REGION_TB_HELP_SCHEMATIC_EXTENSION=§8/§etestblock §8[§7Schematic§8] §8[§7ExtensionType§8] §8- §7Setzte den Testblock mit einer Schematic zurück REGION_TB_DONE=§7Testblock zurückgesetzt REGION_TB_ERROR=§cFehler beim Zurücksetzen des Testblocks -REGION_TB_NO_PERMS=§cDu darfst hier nicht den Testblock zurücksetzen REGION_TB_NO_REGION=§cDu befindest dich derzeit in keiner Region REGION_TB_NO_SCHEMSHARING=§cDu kannst aktuell keine Schematics teilen bis {0}. REGION_TB_NO_SCHEMRECEIVING=§cDer Besitzer dieses Bauservers kann keine Schematics erhalten bis {0}. @@ -858,7 +816,6 @@ REGION_TNT_HELP_MODE=§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten REGION_TNT_ON=§aTNT-Schaden aktiviert REGION_TNT_OFF=§cTNT-Schaden deaktiviert REGION_TNT_TB=§aTNT-Schaden außerhalb Baurahmen aktiviert -REGION_TNT_NO_PERMS=§cDu darfst hier nicht TNT-Schaden (de-)aktivieren REGION_TNT_BUILD_DESTROY=§cEine Explosion hätte Blöcke im Baubereich zerstört REGION_TNT_TB_DESTROY=§cEine Explosion hätte Blöcke im Testblockbereich zerstört AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert. @@ -876,7 +833,6 @@ PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze PANZERN_PREPARE2 = §72. Teppich in Gänge auf dem Boden vereinfacht das panzern. PANZERN_PREPARE3 = §73. Schildtechnik sollte explizit eingeschlossen sein. PANZERN_PREPARE4 = §74. Innerhalb der zu panzernden Region zu stehen, beim Befehlausführen kann das Panzern verbessern. -PANZERN_NO_PERM = §cDu darfst hier nicht das Panzern System verwenden PANZERN_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection PANZERN_PROGRESS = §e{0} §7Blöcke übrig, §e{1} §7Blöcke pro Sekunde, §e{2} §7Block Delta PANZERN_DONE = §aZuende gepanzert @@ -886,7 +842,6 @@ LAUFBAU_HELP = §8/§elaufbau §8[§7smallest§8|§7blastresistant§8] §8- §7B LAUFBAU_HELP_SETTINGS = §8/§elaufbau settings §8- §7Öffnet die Settings GUI LAUFBAU_PREPARE1 = §71. Trace die Kanonen so oft wie nötig, in allen Modi. LAUFBAU_PREPARE2 = §72. Versuche alle Fails aus dem Trace zu löschen. -LAUFBAU_NO_PERM = §cDu darfst hier nicht das Laufbau System verwenden LAUFBAU_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection LAUFBAU_STATE_FILTERING_TRACES = Traces filtern LAUFBAU_STATE_PROCESSING_TRACES = Traces verbinden @@ -994,7 +949,6 @@ LAUFBAU_TILT_PARTIAL = §8-§7 Neigung teilweise # UTILS SELECT_HELP = §8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus SELECT_EXTENSION_HELP = §8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension -SELECT_NO_PERMS = §cDu darfst hier nicht den Select Befehl verwenden SELECT_GLOBAL_REGION = §cDie globale Region kannst du nicht auswählen SELECT_NO_TYPE = §cDiese Region hat keinen {0} SELECT_NO_EXTENSION = §cDiese Region hat keine Ausfahrmaße @@ -1046,7 +1000,6 @@ PISTON_HELP_3 = §7Die Anzahl ist Gelb, wenn zu viele Blöcke vorhanden sind. PISTON_INFO = §7Bewegte Blöcke {0}{1}§8/§712 # Warp -WARP_DISALLOWED = §cDu darfst hier nicht das Warp System nutzen WARP_LOC_X = §7X§8: §e{0} WARP_LOC_Y = §7Y§8: §e{0} WARP_LOC_Z = §7Z§8: §e{0} @@ -1072,12 +1025,9 @@ WARP_HELP_LIST=§8/§ewarp list §8- §7Liste alle Warp-Punkt auf # WORLD STOP_HELP = §8/§estop §8- §7Stoppt den Server -STOP_NO_PERMS = §cDu hast keine Rechte den Server zu stoppen STOP_MESSAGE = §eDer Server wird gestoppt -WORLD_EDIT_NO_PERMS = §cDu darfst hier kein WorldEdit benutzen KICKALL_HELP = §8/§ekickall §8- §7Kickt alle Spieler vom Server außer den Owner -KICKALL_NO_PERM = §cDies ist nicht deine Welt! # Techhider TECHHIDER_HELP = §8/§etechhider §8- §7Techhider umschalten diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java index 92289699..3b8dc600 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -81,7 +81,7 @@ public class BauGUI { } } else { p.closeInventory(); - BauSystem.MESSAGE.send("GUI_NO_PERMISSION", p); + BauSystem.MESSAGE.send("NO_PERMISSION", p); } }); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index a15c1e4f..163bec3c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -21,20 +21,19 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.*; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.EntityEnterBlockEvent; -import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockCanBuildEvent; +import org.bukkit.event.block.BlockMultiPlaceEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityPickupItemEvent; -import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.*; -import org.bukkit.inventory.ItemStack; @Linked public class SpectatorListener implements Listener { @@ -53,15 +52,14 @@ public class SpectatorListener implements Listener { event.getPlayer().kickPlayer(""); }, 1); } - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { - Player p = event.getPlayer(); - ItemStack[] content = event.getPlayer().getInventory().getContents(); - for (int i = 0; i < content.length; i++) { - if (content[i] == null) continue; - if (checkItemStack(content[i])) { - p.getInventory().setItem(i, null); - } - } + } + + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + if (!anySupervisorOnline(null)) { + Bukkit.getOnlinePlayers().forEach(player -> { + player.kickPlayer(""); + }); } } @@ -74,28 +72,6 @@ public class SpectatorListener implements Listener { } } - @EventHandler - public void onInventoryClick(InventoryClickEvent event) { - ItemStack itemStack = event.getCurrentItem(); - if (itemStack == null || !itemStack.hasItemMeta()) { - return; - } - if (checkItemStack(itemStack)) { - event.setCancelled(true); - event.setCurrentItem(null); - } - } - - private boolean checkItemStack(ItemStack itemStack) { - switch (itemStack.getType()) { - case WOODEN_AXE: - case DEBUG_STICK: - return true; - default: - return false; - } - } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (event.getMessage().startsWith("/schem save") || event.getMessage().startsWith("//schem save") || event.getMessage().startsWith("/schematic save") || event.getMessage().startsWith("//schematic save")) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java index 479cd9ad..68f618db 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java @@ -58,7 +58,7 @@ public class StopCommand extends SWCommand { if (user.hasPerm(UserPerm.ADMINISTRATION)) { return true; } - messageSender.send("STOP_NO_PERMS"); + messageSender.send("NO_PERMISSION"); return false; }; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java index 6cda80be..a377db87 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java @@ -41,7 +41,7 @@ public class WorldEditListener implements Listener { Player p = e.getPlayer(); if (!Permission.BUILD.hasPermission(e.getPlayer())) { - BauSystem.MESSAGE.send("WORLD_EDIT_NO_PERMS", p); + BauSystem.MESSAGE.send("NO_PERMISSION", p); e.setCancelled(true); e.setMessage("/"); } From 0ac735c30f936108c7bd99a51c8374729eb0c234 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 23 Dec 2023 13:02:44 +0100 Subject: [PATCH 16/29] Add ForceSpectatorCommand Add TechHiderCommand.toggleHider for spectators --- .../src/de/steamwar/bausystem/BauSystem.java | 10 +++ .../src/de/steamwar/bausystem/Permission.java | 42 ++++++++- .../bausystem/features/bau/BauCommand.java | 41 --------- .../features/bau/ForceSpectatorCommand.java | 73 ++++++++++++++++ .../bausystem/features/bau/InfoCommand.java | 4 - .../features/techhider/TechHiderCommand.java | 33 +++++++ .../features/world/BauMemberUpdate.java | 86 ++++++++++++++++++- .../features/world/SpectatorListener.java | 44 ++++++++++ .../bausystem/utils/BauMemberUpdateEvent.java | 24 ++++++ 9 files changed, 305 insertions(+), 52 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index ad5790a0..2d2773b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -95,6 +95,16 @@ public class BauSystem extends JavaPlugin implements Listener { } return true; }); + SWCommandUtils.addValidator("supervisor", (commandSender, object, messageSender) -> { + if (commandSender instanceof Player) { + if (Permission.SUPERVISOR.hasPermission((Player) commandSender)) { + return true; + } + messageSender.send("NO_PERMISSION"); + return false; + } + return true; + }); LinkageUtils.link(); RamUsage.init(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 8e51d97d..2d642ac1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -20,11 +20,16 @@ package de.steamwar.bausystem; import de.steamwar.bausystem.config.BauServer; +import de.steamwar.bausystem.features.world.BauMemberUpdate; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import lombok.AllArgsConstructor; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.HashSet; +import java.util.Set; import java.util.function.Predicate; @AllArgsConstructor @@ -32,10 +37,17 @@ public enum Permission { OWNER(bauweltMember -> false), SUPERVISOR(bauweltMember -> { - return bauweltMember.isWorld(); + return bauweltMember.isSupervisor(); }), BUILD(bauweltMember -> { - return bauweltMember.isWorldEdit() || SUPERVISOR.permissionPredicate.test(bauweltMember); + if (isTempOnlySpectator(bauweltMember)) return false; + return bauweltMember.isBuild() || SUPERVISOR.permissionPredicate.test(bauweltMember); + }), + /** + * Only used for {@link BauMemberUpdate} + */ + REAL_SPECTATOR(bauweltMember -> { + return !bauweltMember.isBuild() && !bauweltMember.isSupervisor(); }), SPECTATOR(bauweltMember -> { return !BUILD.permissionPredicate.test(bauweltMember); @@ -44,6 +56,28 @@ public enum Permission { return true; }); + private static final Set TEMP_ONLY_SPECTATOR = new HashSet<>(); + + private static boolean isTempOnlySpectator(BauweltMember bauweltMember) { + return TEMP_ONLY_SPECTATOR.contains(bauweltMember.getMemberID()); + } + + public static boolean isTempOnlySpectator(Player player) { + return TEMP_ONLY_SPECTATOR.contains(SteamwarUser.get(player.getUniqueId()).getId()); + } + + public static void forceOnlySpectator(Player player) { + TEMP_ONLY_SPECTATOR.add(SteamwarUser.get(player.getUniqueId()).getId()); + BauMemberUpdate.baumemberUpdate(); + } + + /** + * Only used by {@link BauMemberUpdate} + */ + public static void removeForceOnlySpectator(Player player) { + TEMP_ONLY_SPECTATOR.remove(SteamwarUser.get(player.getUniqueId()).getId()); + } + private final Predicate permissionPredicate; public boolean hasPermission(BauweltMember bauweltMember) { @@ -53,10 +87,10 @@ public enum Permission { public boolean hasPermission(Player member) { if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) { - return this != SPECTATOR; + return this != SPECTATOR && this != REAL_SPECTATOR; } BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauweltMember == null) return this == SPECTATOR; + if (bauweltMember == null) return this == SPECTATOR || this == REAL_SPECTATOR; return permissionPredicate.test(bauweltMember); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java deleted file mode 100644 index 69ee7af8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.bau; - -import de.steamwar.command.SWCommand; -import de.steamwar.linkage.Linked; -import de.steamwar.linkage.LinkedInstance; -import org.bukkit.entity.Player; - -@Linked -public class BauCommand extends SWCommand { - - @LinkedInstance - public InfoCommand infoCommand; - - public BauCommand() { - super("bau", "b", "gs"); - } - - @Register(value = "info", description = "BAU_COMMAND_HELP_INFO") - public void infoCommand(Player p) { - infoCommand.sendBauInfo(p); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java new file mode 100644 index 00000000..7bef91df --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/ForceSpectatorCommand.java @@ -0,0 +1,73 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.bau; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.command.PreviousArguments; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; +import de.steamwar.techhider.TechHider; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Collection; +import java.util.stream.Collectors; + +@Linked +public class ForceSpectatorCommand extends SWCommand { + + public ForceSpectatorCommand() { + super("forcespectator"); + } + + @Register + public void forceSpectator(@Validator("supervisor") Player player, @Mapper("builder") Player other) { + Permission.forceOnlySpectator(other); + } + + @Mapper("builder") + public TypeMapper spectatorMapper() { + return new TypeMapper<>() { + @Override + public Player map(CommandSender commandSender, String[] previousArguments, String s) { + Player player = Bukkit.getPlayer(s); + if (player == null) { + return null; + } + if (Permission.BUILD.hasPermission(player) && !Permission.SUPERVISOR.hasPermission(player)) { + return player; + } + return null; + } + + @Override + public Collection tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { + return Bukkit.getOnlinePlayers().stream() + .filter(Permission.BUILD::hasPermission) + .filter(player -> !Permission.SUPERVISOR.hasPermission(player)) + .map(Player::getName) + .collect(Collectors.toList()); + } + }; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index 9f53f563..19d8aab5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -27,10 +27,6 @@ public class InfoCommand extends SWCommand { @Register(description = "BAU_INFO_COMMAND_HELP") public void genericCommand(Player p) { - sendBauInfo(p); - } - - public void sendBauInfo(Player p) { BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName()); Region region = Region.getRegion(p.getLocation()); for (Flag flag : Flag.getFlags()) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 731b583a..612cf8cb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -20,16 +20,22 @@ package de.steamwar.bausystem.features.techhider; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.features.world.SpectatorListener; import de.steamwar.bausystem.features.xray.XrayCommand; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeMapper; import de.steamwar.core.CraftbukkitWrapper; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import de.steamwar.techhider.TechHider; import net.md_5.bungee.api.ChatMessageType; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -104,6 +110,33 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE }); } + @Register + public void toggleHider(@Validator("supervisor") Player player, @Mapper("spectator") Player other) { + SpectatorListener.toggleNoTechHider(other); + } + + @Mapper("spectator") + public TypeMapper spectatorMapper() { + return new TypeMapper<>() { + @Override + public Player map(CommandSender commandSender, String[] previousArguments, String s) { + Player player = Bukkit.getPlayer(s); + if (player != null && Permission.REAL_SPECTATOR.hasPermission(player)) { + return player; + } + return null; + } + + @Override + public Collection tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { + return Bukkit.getOnlinePlayers().stream() + .filter(Permission.REAL_SPECTATOR::hasPermission) + .map(Player::getName) + .collect(Collectors.toList()); + } + }; + } + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { hidden.values().forEach(set -> set.remove(event.getPlayer())); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index fe90be02..576b4fa1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -19,6 +19,8 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; @@ -26,15 +28,93 @@ import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.server.BaumemberUpdatePacket; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashSet; +import java.util.Set; @Linked -public class BauMemberUpdate extends PacketHandler { +public class BauMemberUpdate extends PacketHandler implements Listener { + + private static final Set SPECTATORS = new HashSet<>(); @Handler public void baumemberUpdate(BaumemberUpdatePacket baumemberUpdatePacket) { - Bukkit.getPluginManager().callEvent(new BauMemberUpdateEvent()); + baumemberUpdate(); } - + + public static void baumemberUpdate() { + Set newSpectator = new HashSet<>(); + Set newBuilder = new HashSet<>(); + Bukkit.getOnlinePlayers().forEach(player -> { + if (Permission.REAL_SPECTATOR.hasPermission(player)) { + if (!SPECTATORS.contains(player)) { + SPECTATORS.add(player); + Permission.removeForceOnlySpectator(player); + newSpectator.add(player); + player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); + } + } else { + if (Permission.SUPERVISOR.hasPermission(player)) { + Permission.removeForceOnlySpectator(player); + } + if (SPECTATORS.contains(player)) { + SPECTATORS.remove(player); + newBuilder.add(player); + player.removePotionEffect(PotionEffectType.GLOWING); + } + } + }); + Bukkit.getPluginManager().callEvent(new BauMemberUpdateEvent(newSpectator, newBuilder)); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + SPECTATORS.add(event.getPlayer()); + event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + SPECTATORS.remove(event.getPlayer()); + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) { + event.setDeathMessage(null); + if (SPECTATORS.contains(event.getEntity())) { + event.getDrops().clear(); + } + } + + @EventHandler + public void onPlayerRespawn(PlayerRespawnEvent event) { + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + if (SPECTATORS.contains(event.getPlayer())) { + event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false, false, false)); + } + }, 1); + } + + @EventHandler + public void onPlayerItemConsume(PlayerItemConsumeEvent event) { + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + if (SPECTATORS.contains(event.getPlayer())) { + event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); + } + }, 1); + } + @Linked public static class TestCommand extends SWCommand { // TODO: Remove before merge diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 163bec3c..68bb465a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -22,8 +22,12 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; +import de.steamwar.core.CraftbukkitWrapper; import de.steamwar.linkage.Linked; +import de.steamwar.techhider.TechHider; import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -35,9 +39,41 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.player.*; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + @Linked public class SpectatorListener implements Listener { + private static final Set NO_TECHHIDER = new HashSet<>(); + + static { + TechHider techHider = new TechHider((player, i, i1) -> { + return Permission.BUILD.hasPermission(player) || Permission.isTempOnlySpectator(player) || NO_TECHHIDER.contains(player); + }, Material.END_STONE, new HashSet<>(Arrays.asList(Material.REDSTONE_WIRE)), new HashSet<>()); + techHider.enable(); + } + + public static void toggleNoTechHider(Player player) { + if (NO_TECHHIDER.contains(player)) { + NO_TECHHIDER.remove(player); + } else { + NO_TECHHIDER.add(player); + } + resendChunks(player); + } + + private static void resendChunks(Player player) { + int distance = player.getClientViewDistance(); + Location location = player.getLocation(); + for (int x = (int) Math.floor(location.getX() / 16.0) - distance; x <= (int) Math.ceil(location.getX() / 16.0) + distance; x++) { + for (int z = (int) Math.floor(location.getZ() / 16.0) - distance; z <= (int) Math.ceil(location.getZ() / 16.0) + distance; z++) { + CraftbukkitWrapper.impl.sendChunk(player, x, z); + } + } + } + private boolean anySupervisorOnline(Player player) { return Bukkit.getOnlinePlayers().stream().filter(p -> p != player).anyMatch(Permission.SUPERVISOR::hasPermission); } @@ -60,11 +96,19 @@ public class SpectatorListener implements Listener { Bukkit.getOnlinePlayers().forEach(player -> { player.kickPlayer(""); }); + return; } + + event.getChanged().forEach(player -> { + NO_TECHHIDER.remove(player); + if (Permission.isTempOnlySpectator(player)) return; + resendChunks(player); + }); } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { + NO_TECHHIDER.remove(event.getPlayer()); if (!anySupervisorOnline(event.getPlayer())) { Bukkit.getOnlinePlayers().forEach(player -> { player.kickPlayer(""); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java index 4d26dc6f..77f2ba3e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/BauMemberUpdateEvent.java @@ -19,11 +19,35 @@ package de.steamwar.bausystem.utils; +import lombok.Getter; +import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + public class BauMemberUpdateEvent extends Event { + @Getter + private final Set changed; + + @Getter + private final Set newSpectator; + + @Getter + private final Set newBuilder; + + public BauMemberUpdateEvent(Set newSpectator, Set newBuilder) { + this.newSpectator = Collections.unmodifiableSet(newSpectator); + this.newBuilder = Collections.unmodifiableSet(newBuilder); + Set changed = new HashSet<>(); + changed.addAll(newSpectator); + changed.addAll(newBuilder); + this.changed = Collections.unmodifiableSet(changed); + } + private static final HandlerList handlers = new HandlerList(); public HandlerList getHandlers() { From 2a55f607d31610ba2c2c71118638e16766bb7e88 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 23 Dec 2023 14:18:32 +0100 Subject: [PATCH 17/29] Add dynamic spectator disable --- BauSystem_Main/src/BauSystem.properties | 8 --- BauSystem_Main/src/BauSystem_de.properties | 8 --- .../design/endstone/DesignEndStone.java | 9 ++-- .../endstone/DesignEndStoneCommand.java | 24 ++++++--- .../features/detonator/DetonatorListener.java | 3 +- .../killchecker/KillcheckerCommand.java | 19 ++++--- .../killchecker/KillcheckerVisualizer.java | 32 ++---------- .../features/loader/LoaderCommand.java | 14 +++++- .../observer/ObserverTracerCommand.java | 2 +- .../observer/ObserverTracerListener.java | 6 +++ .../features/region/RegionCommand.java | 50 ------------------- .../features/script/ScriptListener.java | 7 +++ .../shieldprinting/ShieldPrinting.java | 7 +++ .../features/simulator/SimulatorCursor.java | 13 ++++- .../tracer/show/TraceShowManager.java | 14 +++++- .../features/util/NoClipCommand.java | 13 ++++- .../features/util/PistonCalculator.java | 2 + .../util/PistonCalculatorCommand.java | 2 +- .../bausystem/features/util/SlotCommand.java | 6 +-- .../features/util/TNTClickListener.java | 2 +- .../features/world/BauMemberUpdate.java | 2 + .../features/world/ItemFrameListener.java | 2 +- .../features/world/WorldEditListener.java | 2 +- 23 files changed, 118 insertions(+), 129 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 3928e0f4..d34ae1ef 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -804,8 +804,6 @@ REGION_REGION_HELP_RESTORE=§8/§eregion restore §8- §7Resets the region, with REGION_REGION_HELP_RESTORE_SCHEMATIC=§8/§eregion restore §8[§7Schematic§8] §8- §7Resets the region, withoout removing your builds REGION_REGION_HELP_COPYPOINT=§8/§eregion copypoint §8- §7Teleport to the regions copy point REGION_REGION_HELP_TESTBLOCKPOINT=§8/§eregion testblockpoint §8- §7Teleport to the regions dummy point -REGION_REGION_HELP_CHANGETYPE_INFO=§8/§eregion changetype §8- §7Returns the region type -REGION_REGION_HELP_CHANGETYPE=§8/§eregion changetype §8[§7Type§8] §8- §8Sets the region type REGION_REGION_HELP_CHANGESKIN_INFO=§8/§eregion changeskin §8- §7Returns the region skin REGION_REGION_HELP_CHANGESKIN=§8/§eregion changeskin §8[§7Skin§8] §8- §8Sets the region skin REGION_REGION_NOTHING_UNDO=§cNothing left to undo @@ -821,12 +819,6 @@ REGION_REGION_TP_COPY=§7Teleported to the copy point REGION_REGION_TP_TEST_BLOCK=§7Teleported to the tesblock REGION_REGION_TP_UNKNOWN=§cUndefined teleport point REGION_REGION_NO_REGION=§cYou are not inside any region -REGION_REGION_CHANGETYPE_INFO=§7RRegion type is §e{0} -REGION_REGION_CHANGETYPE_UNKNOWN=§cRegion type is invalid -REGION_REGION_CHANGETYPE_INVALID=§cRegion type is not allowed here -REGION_REGION_CHANGETYPE_CHANGE=§7Region type changed to §e{0} -REGION_REGION_CHANGETYPE_CHANGE_UPDATE=§7Click §e§lHERE §7to change the region type -REGION_REGION_CHANGETYPE_CHANGE_UPDATE_HOVER=§8/§ereset REGION_REGION_CHANGESKIN_INFO=§7Region skin is §e{0} REGION_REGION_CHANGESKIN_INFO_CREATOR=§7Skin created by §e{0} REGION_REGION_CHANGESKIN_UNKNOWN=§cRegion skin is invalid diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index ecb3deae..535caa3f 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -767,8 +767,6 @@ REGION_REGION_HELP_RESTORE=§8/§eregion restore §8- §7Setzte die Region zurü REGION_REGION_HELP_RESTORE_SCHEMATIC=§8/§eregion restore §8[§7Schematic§8] §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen REGION_REGION_HELP_COPYPOINT=§8/§eregion copypoint §8- §7Teleportiere dich zum Regions Kopierpunkt REGION_REGION_HELP_TESTBLOCKPOINT=§8/§eregion testblockpoint §8- §7Teleportiere dich zum Regions Testblockpunkt -REGION_REGION_HELP_CHANGETYPE_INFO=§8/§eregion changetype §8- §7Gebe den Regions Type aus -REGION_REGION_HELP_CHANGETYPE=§8/§eregion changetype §8[§7Type§8] §8- §8Setzte den Regions Type REGION_REGION_HELP_CHANGESKIN_INFO=§8/§eregion changeskin §8- §7Gebe den Regions Skin aus REGION_REGION_HELP_CHANGESKIN=§8/§eregion changeskin §8[§7Skin§8] §8- §8Setzte den Regions Skin REGION_REGION_NOTHING_UNDO=§cNichts zum rückgängig machen @@ -784,12 +782,6 @@ REGION_REGION_TP_COPY=§7Zum Kopierpunkt teleportiert REGION_REGION_TP_TEST_BLOCK=§7Zum Testblock teleportiert REGION_REGION_TP_UNKNOWN=§cNicht definierter Teleportierpunkt REGION_REGION_NO_REGION=§cDu bist in keiner Region -REGION_REGION_CHANGETYPE_INFO=§7Regions Type ist §e{0} -REGION_REGION_CHANGETYPE_UNKNOWN=§cRegions Type ist nicht valide -REGION_REGION_CHANGETYPE_INVALID=§cRegions Type ist nicht erlaubt hier -REGION_REGION_CHANGETYPE_CHANGE=§7Regions Type ist auf §e{0}§7 geändert -REGION_REGION_CHANGETYPE_CHANGE_UPDATE=§7Klicke §e§lHIER §7um den Type anzuwenden -REGION_REGION_CHANGETYPE_CHANGE_UPDATE_HOVER=§8/§ereset REGION_REGION_CHANGESKIN_INFO=§7Regions Skin ist §e{0} REGION_REGION_CHANGESKIN_INFO_CREATOR=§7Skin erstellt von §e{0} REGION_REGION_CHANGESKIN_UNKNOWN=§cRegions Skin ist nicht valide diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java index fd9899f8..0fa990aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java @@ -44,7 +44,6 @@ public class DesignEndStone { private REntityServer entityServer = new REntityServer(); private List entities = new ArrayList<>(); private Set locations = new HashSet<>(); - private List players = new ArrayList<>(); public DesignEndStone(Region region) { this.minX = region.getMinPointBuild().getX(); @@ -95,12 +94,10 @@ public class DesignEndStone { } public void toggle(Player player) { - if (players.contains(player)) { - players.remove(player); + if (entityServer.getPlayers().contains(player)) { entityServer.removePlayer(player); BauSystem.MESSAGE.sendPrefixless("DESIGN_ENDSTONE_DISABLE", player, ChatMessageType.ACTION_BAR); } else { - players.add(player); entityServer.addPlayer(player); calc(); BauSystem.MESSAGE.sendPrefixless("DESIGN_ENDSTONE_ENABLE", player, ChatMessageType.ACTION_BAR); @@ -108,7 +105,7 @@ public class DesignEndStone { } public boolean removePlayer(Player player) { - players.remove(player); - return players.isEmpty(); + entityServer.removePlayer(player); + return entityServer.getPlayers().isEmpty(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java index 35a7fa7a..92934c23 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.design.endstone; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import org.bukkit.Location; @@ -33,6 +34,7 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerQuitEvent; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; @Linked @@ -56,14 +58,20 @@ public class DesignEndStoneCommand extends SWCommand implements Listener { @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - Region region = Region.getRegion(event.getPlayer().getLocation()); - DesignEndStone designEndStone = designEndStoneMap.get(region); - if (designEndStone == null) { - return; - } - if (designEndStone.removePlayer(event.getPlayer())) { - designEndStoneMap.remove(region); - } + disableDesignEndStone(event.getPlayer()); + } + + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(this::disableDesignEndStone); + } + + private void disableDesignEndStone(Player player) { + new HashSet<>(designEndStoneMap.entrySet()).forEach(regionDesignEndStoneEntry -> { + if (regionDesignEndStoneEntry.getValue().removePlayer(player)) { + designEndStoneMap.remove(regionDesignEndStoneEntry.getKey()); + } + }); } @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java index 0ea3c469..cabe00c6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java @@ -92,8 +92,7 @@ public class DetonatorListener implements Listener { @EventHandler(ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { - if(!Permission.BUILD.hasPermission(event.getPlayer())) return; - if (!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) { + if (!Permission.BUILD.hasPermission(event.getPlayer()) ||!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) { if (Detonator.hasActiveDetonatorShow(event.getPlayer())) { Detonator.hideDetonator(event.getPlayer()); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java index bbba61ea..9ca7a480 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerCommand.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.killchecker; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; @@ -74,16 +75,22 @@ public class KillcheckerCommand extends SWCommand implements Listener { BauSystem.MESSAGE.send("KILLCHECKER_DISABLE", player); } + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(this::hide); + } + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - Player player = event.getPlayer(); - Set regions = new HashSet<>(); - visualizers.forEach((region, visualizer) -> { - if (visualizer.disconnect(player)) { - regions.add(region); + hide(event.getPlayer()); + } + + private void hide(Player player) { + new HashSet<>(visualizers.entrySet()).forEach(regionKillcheckerVisualizerEntry -> { + if (regionKillcheckerVisualizerEntry.getValue().hide(player)) { + visualizers.remove(regionKillcheckerVisualizerEntry.getKey()); } }); - regions.forEach(visualizers::remove); } private void recalc(Block block) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java index d7c89254..c68ad901 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/killchecker/KillcheckerVisualizer.java @@ -57,9 +57,6 @@ public class KillcheckerVisualizer { private final int zArea; private final int xArea; - private final Set players = new HashSet<>(); - private final Set areaPlayers = new HashSet<>(); - private final Region region; private final BossBarService bossBarService; @@ -261,7 +258,7 @@ public class KillcheckerVisualizer { double zPercent = xCount / (double) zArea; percent = (xPercent + yPercent + zPercent) / 3; kills = zKills + yKills + xKills; - players.forEach(this::updateBossBar); + outline.getPlayers().forEach(this::updateBossBar); Set pointSet = new HashSet<>(killCount.keySet()); Set outlinePointsCacheLast = new HashSet<>(outlinePointsCache); @@ -356,40 +353,21 @@ public class KillcheckerVisualizer { return new Cuboid(minX, minY, minZ, maxX, maxY, maxZ); } - public boolean show(Player player, boolean onlyOutline) { + public void show(Player player, boolean onlyOutline) { outline.addPlayer(player); if (!onlyOutline) { inner.addPlayer(player); - areaPlayers.add(player); - } else if (areaPlayers.contains(player)) { + } else { inner.removePlayer(player); - areaPlayers.remove(player); } updateBossBar(player); - return players.add(player); } public boolean hide(Player player) { outline.removePlayer(player); - if (areaPlayers.contains(player)) { - inner.removePlayer(player); - } - players.remove(player); - areaPlayers.remove(player); + inner.removePlayer(player); bossBarService.remove(player, region, "killchecker"); - if (players.isEmpty()) { - outline.close(); - inner.close(); - return true; - } - return false; - } - - public boolean disconnect(Player player) { - players.remove(player); - areaPlayers.remove(player); - bossBarService.remove(player, region, "killchecker"); - if (players.isEmpty()) { + if (outline.getPlayers().isEmpty() && inner.getPlayers().isEmpty()) { outline.close(); inner.close(); return true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index 55264ec2..ffe27e64 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -21,13 +21,16 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; @Linked -public class LoaderCommand extends SWCommand { +public class LoaderCommand extends SWCommand implements Listener { public LoaderCommand() { super("loader"); @@ -101,4 +104,13 @@ public class LoaderCommand extends SWCommand { BauSystem.MESSAGE.send("LOADER_NEW_LOAD_TIME", p, delay); loader.setTicksBetweenBlocks(delay); } + + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(player -> { + Loader loader = Loader.getLoader(player); + if (loader == null) return; + loader.stop(); + }); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java index dbd3e48a..531eda68 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java @@ -47,7 +47,7 @@ public class ObserverTracerCommand extends SWCommand { } @Register(value = "delete", description = "OBSERVER_HELP_DELETE") - public void delete(Player p) { + public void delete(@Validator Player p) { ObserverTracerListener.observerTracerMap.remove(p); BauSystem.MESSAGE.send("OBSERVER_DELETE", p); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java index 801f9ce0..a2d9c991 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -89,6 +90,11 @@ public class ObserverTracerListener implements Listener { } } + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(observerTracerMap::remove); + } + @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { enabled.add(event.getPlayer()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index 28da6094..efad26fd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -164,36 +164,6 @@ public class RegionCommand extends SWCommand { BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p); } - @Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE_INFO") - @Register("type") - public void changeTypeCommand(Player p) { - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) { - return; - } - BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_INFO", p, region.getPrototype().getDisplayName()); - } - - @Register(value = "changetype", description = "REGION_REGION_HELP_CHANGETYPE") - @Register("type") - public void changeTypeCommand(@Validator Player p, @Mapper("regionTypeMapper") String s) { - Region region = Region.getRegion(p.getLocation()); - if (checkGlobalRegion(region, p)) { - return; - } - Prototype prototype = Prototype.getByDisplayName(s); - if (prototype == null) { - BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_UNKNOWN", p); - } else { - if (region.setPrototype(prototype)) { - BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_CHANGE", p, s); - BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGETYPE_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset")); - } else { - BauSystem.MESSAGE.send("REGION_REGION_CHANGETYPE_INVALID", p); - } - } - } - @Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO") @Register("skin") public void changeSkinCommand(Player p) { @@ -227,26 +197,6 @@ public class RegionCommand extends SWCommand { } } - @Mapper(value = "regionTypeMapper", local = true) - private TypeMapper regionTypeMapper() { - return new TypeMapper() { - @Override - public List tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) { - Player p = (Player) commandSender; - Region region = Region.getRegion(p.getLocation()); - if (region.isGlobal()) { - return Collections.emptyList(); - } - return region.getPrototypes().stream().map(Prototype::getByName).map(Prototype::getDisplayName).map(c -> c.replace(' ', '_')).collect(Collectors.toList()); - } - - @Override - public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) { - return s.replace('_', ' '); - } - }; - } - @Mapper(value = "skinTypeMapper", local = true) private TypeMapper skinTypeMapper() { return new TypeMapper() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java index ed88d2ee..14f8d983 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.script; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; @@ -74,4 +75,10 @@ public class ScriptListener implements Listener { if(!Permission.BUILD.hasPermission(event.getPlayer())) return; ScriptRunner.updateGlobalScript(event.getPlayer()); } + + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(ScriptRunner::remove); + event.getNewBuilder().forEach(ScriptRunner::updateGlobalScript); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java b/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java index 197300d0..1e3fd6e1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/shieldprinting/ShieldPrinting.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.shieldprinting; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.shieldprinting.impl.*; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.inventory.SWItem; @@ -273,6 +274,12 @@ public class ShieldPrinting implements Listener { updateBossbar(event.getPlayer()); } + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(player -> BossBarService.instance.remove(player, region, "shieldprinting")); + event.getNewBuilder().forEach(this::updateBossbar); + } + private void updateBossbars() { for (Player player : Bukkit.getOnlinePlayers()) { updateBossbar(player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index 5dd31b6a..bc09a7b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -35,6 +35,7 @@ import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor; import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui; import de.steamwar.bausystem.features.simulator.gui.SimulatorGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.bausystem.utils.RayTraceUtils; import de.steamwar.entity.REntity; @@ -95,6 +96,7 @@ public class SimulatorCursor implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { calcCursor(event.getPlayer()); }, 0); @@ -102,16 +104,23 @@ public class SimulatorCursor implements Listener { @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; calcCursor(event.getPlayer()); } @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { calcCursor(event.getPlayer()); }, 1); } + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getChanged().forEach(this::calcCursor); + } + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { cursorType.remove(event.getPlayer()); @@ -143,13 +152,12 @@ public class SimulatorCursor implements Listener { } public synchronized void calcCursor(Player player) { - if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) { + if (Permission.SPECTATOR.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) { if (removeCursor(player) || SimulatorWatcher.show(null, player)) { SWUtils.sendToActionbar(player, ""); } return; } - if(!Permission.BUILD.hasPermission(player)) return; Simulator simulator = SimulatorStorage.getSimulator(player); SimulatorWatcher.show(simulator, player); @@ -316,6 +324,7 @@ public class SimulatorCursor implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; if (!ItemUtils.isItem(event.getItem(), "simulator")) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 695c8115..7c335052 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -131,12 +132,21 @@ public class TraceShowManager implements Listener { @EventHandler public void onLeave(PlayerQuitEvent event) { + hideComplete(event.getPlayer()); + } + + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(this::hideComplete); + } + + private void hideComplete(Player player) { showModes.forEach((region, playerShowModeMap) -> { - ShowMode showMode = playerShowModeMap.remove(event.getPlayer()); + ShowMode showMode = playerShowModeMap.remove(player); if (showMode != null) showMode.hide(); }); showFilters.forEach((region, playerPredicateMap) -> { - playerPredicateMap.remove(event.getPlayer()); + playerPredicateMap.remove(player); }); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index ba5d5000..867ad83d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -24,6 +24,7 @@ import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.command.SWCommand; import de.steamwar.core.ProtocolWrapper; @@ -97,7 +98,7 @@ public class NoClipCommand extends SWCommand implements Listener { } @Register(help = true) - public void genericCommand(Player player, String... args) { + public void genericCommand(@Validator Player player) { if (NOCLIPS.contains(player)) { NOCLIPS.remove(player); player.setGameMode(GameMode.CREATIVE); @@ -116,6 +117,16 @@ public class NoClipCommand extends SWCommand implements Listener { } } + @EventHandler + public void onBauMemberUpdate(BauMemberUpdateEvent event) { + event.getNewSpectator().forEach(player -> { + if (NOCLIPS.contains(player)) { + NOCLIPS.remove(player); + player.setGameMode(GameMode.CREATIVE); + } + }); + } + @EventHandler(ignoreCancelled = true) public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) { if (NOCLIPS.contains(event.getPlayer())) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java index 0f1cfe5e..6703bd5c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.entity.REntityServer; import de.steamwar.entity.RFallingBlockEntity; import de.steamwar.linkage.Linked; @@ -49,6 +50,7 @@ public class PistonCalculator implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (!event.hasItem() || event.getItem().getType() != Material.SLIME_BALL) return; if (event.getClickedBlock() == null) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java index 8aef617f..71fefaa4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java @@ -32,7 +32,7 @@ public class PistonCalculatorCommand extends SWCommand { } @Register - public void help(Player player) { + public void help(@Validator Player player) { BauSystem.MESSAGE.send("PISTON_HELP_1", player); BauSystem.MESSAGE.send("PISTON_HELP_2", player); BauSystem.MESSAGE.send("PISTON_HELP_3", player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java index 4ea5d62b..37ff3b89 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java @@ -41,7 +41,7 @@ public class SlotCommand extends SWCommand { } @Register - public void slotCommand(Player player, Integer slot) { + public void slotCommand(@Validator Player player, Integer slot) { if (slot < 1 || slot > 9) { BauSystem.MESSAGE.send("OTHER_SLOT_INVALID_SLOT", player); return; @@ -50,7 +50,7 @@ public class SlotCommand extends SWCommand { } @Register(value = "pick", description = "OTHER_NOCLIP_SLOT_HELP_PICK") - public void eyedropBlock(Player player) { + public void eyedropBlock(@Validator Player player) { Block block = player.getTargetBlockExact(6); ItemStack itemStack; if (block == null) { @@ -61,7 +61,7 @@ public class SlotCommand extends SWCommand { } @Register(value = "drop", description = "OTHER_NOCLIP_SLOT_HELP_DROP") - public void dropBlock(Player player) { + public void dropBlock(@Validator Player player) { player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java index 85f73e04..19cede21 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java @@ -35,8 +35,8 @@ public class TNTClickListener implements Listener { @EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { + if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; if (event.getHand() != EquipmentSlot.HAND) return; - if (!Permission.BUILD.hasPermission(event.getPlayer())); Entity entity = event.getRightClicked(); if (event.getRightClicked() instanceof TNTPrimed) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index 576b4fa1..b48ccad5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -81,6 +81,8 @@ public class BauMemberUpdate extends PacketHandler implements Listener { if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { SPECTATORS.add(event.getPlayer()); event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); + } else { + event.getPlayer().removePotionEffect(PotionEffectType.GLOWING); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java index 535551ab..13cf0d0c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java @@ -42,7 +42,7 @@ public class ItemFrameListener implements Listener { return; } - if(!Permission.BUILD.hasPermission((Player) event.getDamager())) return; + if(Permission.SPECTATOR.hasPermission((Player) event.getDamager())) return; event.setCancelled(true); ItemFrame itemFrame = (ItemFrame) event.getEntity(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java index a377db87..40e32eda 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java @@ -40,7 +40,7 @@ public class WorldEditListener implements Listener { if (!isWorldEditCommand(e.getMessage().split(" ")[0])) return; Player p = e.getPlayer(); - if (!Permission.BUILD.hasPermission(e.getPlayer())) { + if (Permission.SPECTATOR.hasPermission(e.getPlayer())) { BauSystem.MESSAGE.send("NO_PERMISSION", p); e.setCancelled(true); e.setMessage("/"); From 6e9693d8384eca93160f11c175bebd55eb5dba47 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 23 Dec 2023 15:06:49 +0100 Subject: [PATCH 18/29] Update Techhider of Spectators --- .../features/world/SpectatorListener.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 68bb465a..10fd30ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.core.CraftbukkitWrapper; +import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import de.steamwar.techhider.TechHider; import org.bukkit.Bukkit; @@ -49,9 +50,56 @@ public class SpectatorListener implements Listener { private static final Set NO_TECHHIDER = new HashSet<>(); static { + Set materials = new HashSet<>(); + materials.add(Material.REDSTONE_WIRE); + materials.add(Material.REDSTONE_TORCH); + materials.add(Material.REDSTONE_BLOCK); + materials.add(Material.REPEATER); + materials.add(Material.COMPARATOR); + materials.add(Material.LEVER); + for (Material value : Material.values()) { + if (value.name().endsWith("_BUTTON")) { + materials.add(value); + } + if (value.name().endsWith("_PRESSURE_PLATE")) { + materials.add(value); + } + if (value.name().endsWith("_SIGN")) { + materials.add(value); + } + } + materials.add(SWItem.getMaterial("SCULK_SENSOR")); + materials.add(SWItem.getMaterial("CALIBRATED_SCULK_SENSOR")); + materials.add(SWItem.getMaterial("SCULK_SHRIEKER")); + materials.add(SWItem.getMaterial("AMETHYST_BLOCK")); + materials.add(SWItem.getMaterial("AMETHYST_CLUSTER")); + materials.add(SWItem.getMaterial("SMALL_AMETHYST_BUG")); + materials.add(SWItem.getMaterial("MEDIUM_AMETHYST_BUG")); + materials.add(SWItem.getMaterial("LARGE_AMETHYST_BUG")); + materials.add(Material.TRIPWIRE_HOOK); + materials.add(Material.TRIPWIRE); + materials.add(Material.DAYLIGHT_DETECTOR); + materials.add(SWItem.getMaterial("LIGHTNING_ROD")); + materials.add(Material.PISTON); + materials.add(Material.PISTON_HEAD); + materials.add(Material.MOVING_PISTON); + materials.add(Material.STICKY_PISTON); + materials.add(Material.SLIME_BLOCK); + materials.add(Material.HONEY_BLOCK); + materials.add(Material.OBSERVER); + materials.add(Material.RAIL); + materials.add(Material.POWERED_RAIL); + materials.add(Material.DETECTOR_RAIL); + materials.add(Material.ACTIVATOR_RAIL); + materials.add(Material.TNT); + materials.add(Material.REDSTONE_ORE); + materials.add(SWItem.getMaterial("SCAFFOLDING")); + materials.add(Material.WATER); + materials.remove(Material.BARRIER); + materials.remove(Material.STONE); TechHider techHider = new TechHider((player, i, i1) -> { return Permission.BUILD.hasPermission(player) || Permission.isTempOnlySpectator(player) || NO_TECHHIDER.contains(player); - }, Material.END_STONE, new HashSet<>(Arrays.asList(Material.REDSTONE_WIRE)), new HashSet<>()); + }, Material.END_STONE, materials, new HashSet<>()); techHider.enable(); } From 96b84a798b76b3f24b60eb7cfdd67c729230879c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 23 Dec 2023 16:45:48 +0100 Subject: [PATCH 19/29] Update BauMemberUpdate --- BauSystem_Main/src/BauSystem.properties | 1 + BauSystem_Main/src/BauSystem_de.properties | 1 + .../features/world/BauMemberUpdate.java | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index d34ae1ef..1878486b 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -29,6 +29,7 @@ LIST_NEXT_PAGE=§eNext page # Permissions NO_PERMISSION = You are not allowed to use that here +SPECTATOR = §fSpectator # Scoreboard SCOREBOARD_TIME = Time diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 535caa3f..ff2cfe89 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -29,6 +29,7 @@ LIST_NEXT_PAGE=§eNächste Seite # Permission NO_PERMISSION = Du darfst dies hier nicht nutzen +SPECTATOR = §fZuschauer # Scoreboard SCOREBOARD_TIME = Uhrzeit diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index b48ccad5..86742974 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -21,12 +21,18 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; +import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; +import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.server.BaumemberUpdatePacket; import org.bukkit.Bukkit; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -61,6 +67,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener { Permission.removeForceOnlySpectator(player); newSpectator.add(player); player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); + showSpectatorNotice(player); } } else { if (Permission.SUPERVISOR.hasPermission(player)) { @@ -70,6 +77,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener { SPECTATORS.remove(player); newBuilder.add(player); player.removePotionEffect(PotionEffectType.GLOWING); + BossBarService.instance.remove(player, GlobalRegion.getInstance(), "spectator"); } } }); @@ -81,11 +89,20 @@ public class BauMemberUpdate extends PacketHandler implements Listener { if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { SPECTATORS.add(event.getPlayer()); event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); + showSpectatorNotice(event.getPlayer()); } else { event.getPlayer().removePotionEffect(PotionEffectType.GLOWING); } } + private static void showSpectatorNotice(Player player) { + BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "spectator"); + bossbar.setTitle(BauSystem.MESSAGE.parse("SPECTATOR", player)); + bossbar.setColor(BarColor.WHITE); + bossbar.setStyle(BarStyle.SOLID); + bossbar.setProgress(1.0); + } + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { SPECTATORS.remove(event.getPlayer()); From 2c5a50bff3d17e22eeb7c09a3dd860a3e0c8fad6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 23 Dec 2023 17:54:54 +0100 Subject: [PATCH 20/29] Update BauMemberUpdate --- .../de/steamwar/bausystem/features/world/BauMemberUpdate.java | 1 - 1 file changed, 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index 86742974..be3bb44b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; From da1ea27f610c3337eb931d2203f7740d51c00e12 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 19 Jan 2024 17:02:57 +0100 Subject: [PATCH 21/29] Remove Permission.SPECTATOR --- .../src/de/steamwar/bausystem/BauSystem.java | 44 +++++++------------ .../src/de/steamwar/bausystem/Permission.java | 10 ++--- .../features/simulator/SimulatorCursor.java | 10 ++--- .../features/util/PistonCalculator.java | 2 +- .../features/util/TNTClickListener.java | 2 +- .../features/world/BauMemberUpdate.java | 2 +- .../features/world/ItemFrameListener.java | 2 +- .../features/world/SignEditFrom20.java | 2 +- .../features/world/SignEditUntil19.java | 2 +- .../features/world/SpectatorListener.java | 20 ++++----- .../features/world/WorldEditListener.java | 2 +- 11 files changed, 44 insertions(+), 54 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index b0548ced..0bda77c1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -28,6 +28,7 @@ import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.Updater; import de.steamwar.bausystem.utils.TickListener; import de.steamwar.bausystem.worlddata.WorldData; +import de.steamwar.command.AbstractValidator; import de.steamwar.command.SWCommandUtils; import de.steamwar.message.Message; import lombok.Getter; @@ -77,38 +78,27 @@ public class BauSystem extends JavaPlugin implements Listener { new Updater(PrototypeLoader.file, PrototypeLoader::load); new Updater(RegionLoader.file, RegionLoader::load); - SWCommandUtils.addValidator(Player.class, (player, object, messageSender) -> { - if (Permission.BUILD.hasPermission(player)) { - return true; - } - messageSender.send("NO_PERMISSION"); - return false; - }); - SWCommandUtils.addValidator(CommandSender.class, (commandSender, object, messageSender) -> { - if (commandSender instanceof Player) { - if (Permission.BUILD.hasPermission((Player) commandSender)) { - return true; - } - messageSender.send("NO_PERMISSION"); - return false; - } - return true; - }); - SWCommandUtils.addValidator("supervisor", (commandSender, object, messageSender) -> { - if (commandSender instanceof Player) { - if (Permission.SUPERVISOR.hasPermission((Player) commandSender)) { - return true; - } - messageSender.send("NO_PERMISSION"); - return false; - } - return true; - }); + SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD)); + SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD)); + SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR)); LinkageUtils.link(); TickListener.impl.init(); } + private AbstractValidator validator(Permission permission) { + return (commandSender, object, messageSender) -> { + if (commandSender instanceof Player) { + if (permission.hasPermission((Player) commandSender)) { + return true; + } + messageSender.send("NO_PERMISSION"); + return false; + } + return true; + }; + } + @Override public void onDisable() { LinkageUtils.unlink(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index 2d642ac1..0985a62d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -49,9 +49,9 @@ public enum Permission { REAL_SPECTATOR(bauweltMember -> { return !bauweltMember.isBuild() && !bauweltMember.isSupervisor(); }), - SPECTATOR(bauweltMember -> { - return !BUILD.permissionPredicate.test(bauweltMember); - }), + /** + * Primarily used for {@link de.steamwar.bausystem.linkage.specific.GuiItem} + */ MEMBER(bauweltMember -> { return true; }); @@ -87,10 +87,10 @@ public enum Permission { public boolean hasPermission(Player member) { if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) { - return this != SPECTATOR && this != REAL_SPECTATOR; + return this != REAL_SPECTATOR; } BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauweltMember == null) return this == SPECTATOR || this == REAL_SPECTATOR; + if (bauweltMember == null) return this == REAL_SPECTATOR; return permissionPredicate.test(bauweltMember); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index 0c335c02..a7664158 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -96,7 +96,7 @@ public class SimulatorCursor implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { calcCursor(event.getPlayer()); }, 0); @@ -104,13 +104,13 @@ public class SimulatorCursor implements Listener { @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; calcCursor(event.getPlayer()); } @EventHandler public void onPlayerItemHeld(PlayerItemHeldEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { calcCursor(event.getPlayer()); }, 1); @@ -159,7 +159,7 @@ public class SimulatorCursor implements Listener { if (calculating.contains(player)) return; calculating.add(player); } - if (Permission.SPECTATOR.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) { + if (!Permission.BUILD.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) { if (removeCursor(player) || SimulatorWatcher.show(null, player)) { SWUtils.sendToActionbar(player, ""); } @@ -344,7 +344,7 @@ public class SimulatorCursor implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!ItemUtils.isItem(event.getItem(), "simulator")) { return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java index 6703bd5c..de9ea34a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java @@ -50,7 +50,7 @@ public class PistonCalculator implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (!event.hasItem() || event.getItem().getType() != Material.SLIME_BALL) return; if (event.getClickedBlock() == null) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java index 19cede21..3284876a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java @@ -35,7 +35,7 @@ public class TNTClickListener implements Listener { @EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; if (event.getHand() != EquipmentSlot.HAND) return; Entity entity = event.getRightClicked(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java index be3bb44b..46c10ef1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauMemberUpdate.java @@ -85,7 +85,7 @@ public class BauMemberUpdate extends PacketHandler implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { SPECTATORS.add(event.getPlayer()); event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, -1, 1, false,false, false)); showSpectatorNotice(event.getPlayer()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java index 13cf0d0c..535551ab 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java @@ -42,7 +42,7 @@ public class ItemFrameListener implements Listener { return; } - if(Permission.SPECTATOR.hasPermission((Player) event.getDamager())) return; + if(!Permission.BUILD.hasPermission((Player) event.getDamager())) return; event.setCancelled(true); ItemFrame itemFrame = (ItemFrame) event.getEntity(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java index df4935dc..1ccfb014 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditFrom20.java @@ -82,7 +82,7 @@ public class SignEditFrom20 implements Listener { } private void edit(Player player, Block block) { - if (Permission.SPECTATOR.hasPermission(player)) return; + if (!Permission.BUILD.hasPermission(player)) return; Sign sign = (Sign) block.getState(); Side side = signSide(player, block); SignSide signSide = sign.getSide(side); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java index 89a4120d..7aebd4e9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEditUntil19.java @@ -69,7 +69,7 @@ public class SignEditUntil19 implements Listener { } private void edit(Player player, Block block) { - if (Permission.SPECTATOR.hasPermission(player)) return; + if (!Permission.BUILD.hasPermission(player)) return; Sign sign = (org.bukkit.block.Sign) block.getState(); String[] lines = sign.getLines(); for (int i = 0; i < lines.length; i++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 10fd30ea..43b04d2c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -176,7 +176,7 @@ public class SpectatorListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockMultiPlace(BlockMultiPlaceEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @@ -184,56 +184,56 @@ public class SpectatorListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockCanBuild(BlockCanBuildEvent event) { if (event.getPlayer() == null) return; - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setBuildable(false); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerBucketEntity(PlayerBucketEntityEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerDropItem(PlayerDropItemEvent event) { - if (Permission.SPECTATOR.hasPermission(event.getPlayer())) { + if (!Permission.BUILD.hasPermission(event.getPlayer())) { event.setCancelled(true); } } @@ -241,7 +241,7 @@ public class SpectatorListener implements Listener { @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEntityPickupItem(EntityPickupItemEvent event) { if (!(event.getEntity() instanceof Player)) return; - if (Permission.SPECTATOR.hasPermission((Player) event.getEntity())) { + if (!Permission.BUILD.hasPermission((Player) event.getEntity())) { event.setCancelled(true); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java index 40e32eda..a377db87 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java @@ -40,7 +40,7 @@ public class WorldEditListener implements Listener { if (!isWorldEditCommand(e.getMessage().split(" ")[0])) return; Player p = e.getPlayer(); - if (Permission.SPECTATOR.hasPermission(e.getPlayer())) { + if (!Permission.BUILD.hasPermission(e.getPlayer())) { BauSystem.MESSAGE.send("NO_PERMISSION", p); e.setCancelled(true); e.setMessage("/"); From ea5df6cee37b848c5d96edff0f1204023209325b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 19 Jan 2024 17:08:11 +0100 Subject: [PATCH 22/29] Fix SteamWarLuaPlugin --- .../bausystem/features/script/lua/SteamWarLuaPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java index 06a6334b..0105abad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java @@ -128,7 +128,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction { Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); String[] commandSplit = command.split(" "); if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) { - if (!Permission.WORLDEDIT.hasPermission(player)) { + if (!Permission.BUILD.hasPermission(player)) { return NIL; } EditSession editSession = WorldEditUtils.getEditSession(player); From 775d428671ed6eace044e93ed2519645a8dbadc9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 19 Jan 2024 20:33:27 +0100 Subject: [PATCH 23/29] Fix SpectatorListener --- .../bausystem/features/world/SpectatorListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 43b04d2c..0fd30b13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -21,10 +21,12 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.utils.BauMemberUpdateEvent; import de.steamwar.core.CraftbukkitWrapper; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; +import de.steamwar.sql.BauweltMember; import de.steamwar.techhider.TechHider; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -128,6 +130,11 @@ public class SpectatorListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), event.getPlayer().getUniqueId()); + if (bauweltMember == null) { + event.getPlayer().kickPlayer(""); + return; + } if (Permission.SUPERVISOR.hasPermission(event.getPlayer())) { return; } From 94bf2f3ae6ae96d80f42815e02b4db2a22040cfb Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 20 Jan 2024 20:35:19 +0100 Subject: [PATCH 24/29] Hotfix SpectatorListener --- .../steamwar/bausystem/features/world/SpectatorListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java index 0fd30b13..51eb1fe5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SpectatorListener.java @@ -130,6 +130,9 @@ public class SpectatorListener implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + if (event.getPlayer().getUniqueId().equals(BauServer.getInstance().getOwner())) { + return; + } BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), event.getPlayer().getUniqueId()); if (bauweltMember == null) { event.getPlayer().kickPlayer(""); From e77680d25a283338d9f9d8a21f22fc42fa1ef592 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 23 Jan 2024 10:11:19 +0100 Subject: [PATCH 25/29] Fix AxiomPermissionCheck --- .../bausystem/features/simulator/data/tnt/TNTPhase.java | 1 - .../bausystem/features/world/AxiomPermissionCheck.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java index 2e913bdd..4c03ac9b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/tnt/TNTPhase.java @@ -24,7 +24,6 @@ import de.steamwar.bausystem.features.simulator.execute.SimulatorAction; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; -import de.steamwar.bausystem.region.tags.Tag; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java index bdfe3d40..c6cecb2b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.world; import com.moulberry.axiom.event.AxiomHandshakeEvent; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.config.BauServer; import de.steamwar.linkage.Linked; import de.steamwar.linkage.PluginCheck; import org.bukkit.event.EventHandler; @@ -32,7 +33,7 @@ public class AxiomPermissionCheck implements Listener { @EventHandler public void onAxiomHandshake(AxiomHandshakeEvent event) { - if (!Permission.BUILD.hasPermission(event.getPlayer())) return; + if (Permission.BUILD.hasPermission(event.getPlayer()) || BauServer.getInstance().getOwner().equals(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } } From d1afb344d9d7f4ca3bd5bba07654c12168e53742 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 30 Jan 2024 16:06:53 +0100 Subject: [PATCH 26/29] Fix SimulatorSaver --- .../data/redstone/RedstonePhase.java | 2 +- .../features/tpslimit/TPSSystem.java | 66 ++++++++++--------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/redstone/RedstonePhase.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/redstone/RedstonePhase.java index f2b99d36..614be659 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/redstone/RedstonePhase.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/redstone/RedstonePhase.java @@ -54,7 +54,7 @@ public final class RedstonePhase extends SimulatorPhase { block.setType(Material.REDSTONE_BLOCK); } }); - tickEnd.accept(tickOffset + lifetime, new SimulatorAction(0, 1) { + tickStart.accept(tickOffset + lifetime, new SimulatorAction(ORDER_LIMIT + 1, 1) { @Override public void accept(World world) { BlockState state = blockState.get(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java index b801e324..aa25a433 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java @@ -26,33 +26,31 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.bausystem.utils.TickEndEvent; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; -import de.steamwar.command.TypeValidator; import de.steamwar.core.Core; import de.steamwar.core.TPSWarpUtils; import de.steamwar.core.TPSWatcher; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.api.Plain; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.boss.BarColor; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.scheduler.BukkitTask; import java.util.Arrays; -import java.util.concurrent.atomic.AtomicInteger; @Linked -public class TPSSystem implements Plain { +public class TPSSystem implements Listener { @Getter private double currentTPSLimit = 20; @@ -87,12 +85,9 @@ public class TPSSystem implements Plain { instance = this; } - private BukkitTask stepper = null; - private void setTPS(double tps) { - if (stepper != null) { - stepper.cancel(); - stepper = null; + if (currentlyStepping) { + currentlyStepping = false; Bukkit.getOnlinePlayers().forEach(player -> { BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep"); }); @@ -120,27 +115,34 @@ public class TPSSystem implements Plain { }); } - private void setSkip(int steps, double tpsLimitToUse) { - double currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit; - setTPS(tpsLimitToUse); - stepper = new BukkitRunnable() { - AtomicInteger stepsLeft = new AtomicInteger(steps); + private boolean currentlyStepping = false; + private double currentLimit; + private int stepsTotal; + private int stepsLeft; - @Override - public void run() { - if (steps > 1) { - Bukkit.getOnlinePlayers().forEach(player -> { - BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep"); - bossbar.setColor(BarColor.YELLOW); - bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (steps - stepsLeft.get()), steps)); - bossbar.setProgress((steps - stepsLeft.get()) / (double) steps); - }); - } - if (stepsLeft.decrementAndGet() < 0) { - setTPS(currentLimit); - } - } - }.runTaskTimer(BauSystem.getInstance(), 1, 1); + private void setSkip(int steps, double tpsLimitToUse) { + currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit; + setTPS(tpsLimitToUse); + stepsLeft = steps; + stepsTotal = steps; + currentlyStepping = true; + } + + @EventHandler + public void onTickEnd(TickEndEvent event) { + if (!currentlyStepping) return; + if (stepsTotal > 1) { + Bukkit.getOnlinePlayers().forEach(player -> { + BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep"); + bossbar.setColor(BarColor.YELLOW); + bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (stepsTotal - stepsLeft), stepsTotal)); + bossbar.setProgress((stepsTotal - stepsLeft) / (double) stepsTotal); + }); + } + stepsLeft--; + if (stepsLeft <= 0) { + setTPS(currentLimit); + } } private class TPSBaseCommand extends SWCommand { @@ -321,7 +323,7 @@ public class TPSSystem implements Plain { @Override public String get(Region region, Player p) { - if (TPSSystem.getInstance().stepper != null) { + if (TPSSystem.getInstance().currentlyStepping) { long time = System.currentTimeMillis() % 1000; if (time < 250) { return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••"; From 953db6942513bdf0b5156c714fed58cf4c086cd8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 16 Feb 2024 08:09:40 +0100 Subject: [PATCH 27/29] Fix BackupCommand --- .../steamwar/bausystem/features/backup/BackupCommand.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java index f4194a4e..6e04d2a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -62,7 +62,7 @@ public class BackupCommand extends SWCommand { } @Register(value = "create", description = "BACKUP_HELP_CREATE") - public void backupCreate(@Validator Player p) { + public void backupCreate(@Validator("supervisor") Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; @@ -79,7 +79,7 @@ public class BackupCommand extends SWCommand { } @Register(value = "load", description = "BACKUP_HELP_LOAD") - public void backupLoad(@Validator Player p, @Mapper("backupName") String backupName) { + public void backupLoad(@Validator("supervisor") Player p, @Mapper("backupName") String backupName) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; @@ -130,7 +130,7 @@ public class BackupCommand extends SWCommand { } SWListInv swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> { p.getOpenInventory().close(); - backupLoad(p, s); + p.performCommand("backup load " + s); }); swListInv.open(); } From 21e7bd89afa75eb943e8c757f66ff643e81d5ba5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 16 Feb 2024 08:24:42 +0100 Subject: [PATCH 28/29] Fix BindCommand and SteamWarLuaPlugin --- .../features/script/lua/SteamWarLuaPlugin.java | 3 --- .../bausystem/features/util/BindCommand.java | 18 ++++++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java index 0105abad..36cf05e3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java @@ -128,9 +128,6 @@ public class SteamWarLuaPlugin extends TwoArgFunction { Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); String[] commandSplit = command.split(" "); if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) { - if (!Permission.BUILD.hasPermission(player)) { - return NIL; - } EditSession editSession = WorldEditUtils.getEditSession(player); Actor actor = BukkitAdapter.adapt(player); WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java index c3acab82..9a93977e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BindCommand.java @@ -117,23 +117,21 @@ public class BindCommand extends SWCommand implements Listener { event.setCancelled(true); Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - PlayerCommandPreprocessEvent playerCommandPreprocessEvent = new PlayerCommandPreprocessEvent(event.getPlayer(), "/" + command); - Bukkit.getPluginManager().callEvent(playerCommandPreprocessEvent); - if (playerCommandPreprocessEvent.isCancelled()) return; + PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(event.getPlayer(), "/" + command); + Bukkit.getPluginManager().callEvent(preprocessEvent); + if (preprocessEvent.isCancelled()) return; - Bukkit.getLogger().log(Level.INFO, event.getPlayer().getName() + " dispatched command: " + command); - String[] commandSplit = command.split(" "); + String processedCommand = preprocessEvent.getMessage().substring(1); + Bukkit.getLogger().log(Level.INFO, event.getPlayer().getName() + " dispatched command: " + processedCommand); + String[] commandSplit = processedCommand.split(" "); if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) { - if (!Permission.WORLDEDIT.hasPermission(event.getPlayer())) { - return; - } EditSession editSession = WorldEditUtils.getEditSession(event.getPlayer()); Actor actor = BukkitAdapter.adapt(event.getPlayer()); - WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession)); + WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, processedCommand, editSession)); editSession.flushSession(); WorldEditUtils.addToPlayer(event.getPlayer(), editSession); } else { - Bukkit.getServer().dispatchCommand(event.getPlayer(), command); + Bukkit.getServer().dispatchCommand(event.getPlayer(), processedCommand); } }, 1); } From de084883713e4e23c8150535a0b73307252d498c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Feb 2024 08:36:51 +0100 Subject: [PATCH 29/29] Fix AxiomPermissionCheck --- .../steamwar/bausystem/features/world/AxiomPermissionCheck.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java index c88ae5cd..587c8d59 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java @@ -33,7 +33,7 @@ public class AxiomPermissionCheck implements Listener { @EventHandler public void onAxiomHandshake(AxiomHandshakeEvent event) { - if (Permission.BUILD.hasPermission(event.getPlayer()) || BauServer.getInstance().getOwner().equals(event.getPlayer().getUniqueId())) { + if (Permission.SUPERVISOR.hasPermission(event.getPlayer()) || BauServer.getInstance().getOwner().equals(event.getPlayer().getUniqueId())) { event.setMaxBufferSize(Short.MAX_VALUE); return; }