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