From 11a8d0a6126b0f55981cd7b823492064bfee224d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Aug 2023 22:01:54 +0200 Subject: [PATCH] UserPerm Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/commands/AkCommand.java | 4 ++-- .../de/steamwar/fightsystem/commands/InfoCommand.java | 3 ++- .../fightsystem/commands/LockschemCommand.java | 11 ++--------- .../src/de/steamwar/fightsystem/listener/Check.java | 11 ++--------- .../de/steamwar/fightsystem/listener/TestJoin.java | 3 ++- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java index d3b33be..27e6b79 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java @@ -26,7 +26,7 @@ import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.UserPerm; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -47,7 +47,7 @@ public class AkCommand implements CommandExecutor { if(!player.isOp()) return false; - if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer && Core.getInstance() != FightSystem.getPlugin()){ + if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()){ return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java index 3024a65..4cd6c19 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/InfoCommand.java @@ -28,6 +28,7 @@ import de.steamwar.fightsystem.states.StateDependentCommand; import de.steamwar.fightsystem.utils.FightStatistics; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -45,7 +46,7 @@ public class InfoCommand implements CommandExecutor { return false; Player player = (Player) sender; - if(!SteamwarUser.get(player.getUniqueId()).getUserGroup().isTeamGroup()) + if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false; FightSystem.getMessage().send("INFO_RANKED", player, !FightStatistics.isUnranked()); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java index 2880acd..9f9bd62 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java @@ -25,10 +25,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCommand; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.*; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -47,13 +44,9 @@ public class LockschemCommand implements CommandExecutor { return false; Player player = (Player) sender; - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - UserGroup userGroup = steamwarUser.getUserGroup(); - - if(!userGroup.isCheckSchematics()) + if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK)) return false; - if(args.length != 1) { FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player); return false; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java index a33d52c..f6efd8c 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java @@ -26,7 +26,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.UserPerm; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -47,7 +47,7 @@ public class Check implements Listener { Player player = e.getPlayer(); SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if(allowedToCheck(user)) + if(user.hasPerm(UserPerm.CHECK)) return; SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID); @@ -68,11 +68,4 @@ public class Check implements Listener { FightSystem.getMessage().send("CHECK_COMMAND_LOCKED", player); Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!"); } - - private boolean allowedToCheck(SteamwarUser user) { - return user.getUserGroup() == UserGroup.Supporter || - user.getUserGroup() == UserGroup.Developer || - user.getUserGroup() == UserGroup.Moderator || - user.getUserGroup() == UserGroup.Admin; - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java index dc65ffd..28ca60f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -43,7 +44,7 @@ public class TestJoin implements Listener { Player player = event.getPlayer(); FightTeam fightTeam = Fight.getPlayerTeam(player); - if(Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).getUserGroup().isAdminGroup()) { + if(Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION)) { FightSystem.getMessage().send("CHECK_JOIN_DENIED", player); player.kickPlayer(""); return;