From 7a85f7456de9252fd855666a1be4cf1d8b3b2b3b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Aug 2023 21:57:12 +0200 Subject: [PATCH] UserPerm --- src/de/steamwar/lobby/command/FlyCommand.java | 7 +++---- src/de/steamwar/lobby/command/ModifyCommand.java | 5 +++-- src/de/steamwar/lobby/command/PortalCommand.java | 3 ++- src/de/steamwar/lobby/map/CustomMapCommand.java | 8 +++----- src/de/steamwar/lobby/particle/ParticleListener.java | 3 ++- src/de/steamwar/lobby/particle/ParticleRequirement.java | 7 ++----- src/de/steamwar/lobby/team/TeamPlayer.java | 4 +++- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/de/steamwar/lobby/command/FlyCommand.java b/src/de/steamwar/lobby/command/FlyCommand.java index 5d04741..e16c674 100644 --- a/src/de/steamwar/lobby/command/FlyCommand.java +++ b/src/de/steamwar/lobby/command/FlyCommand.java @@ -22,7 +22,7 @@ package de.steamwar.lobby.command; import de.steamwar.command.SWCommand; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.UserPerm; import org.bukkit.entity.Player; public class FlyCommand extends SWCommand { @@ -33,10 +33,9 @@ public class FlyCommand extends SWCommand { @Register public void genericCommand(Player player) { - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - UserGroup userGroup = steamwarUser.getUserGroup(); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if (userGroup == UserGroup.Member || steamwarUser.getUserName().equals("joschi1")) { + if (!user.hasPerm(UserPerm.TEAM)) { player.sendMessage("§cUnbekannter Befehl."); return; } diff --git a/src/de/steamwar/lobby/command/ModifyCommand.java b/src/de/steamwar/lobby/command/ModifyCommand.java index f27d07f..49297a2 100644 --- a/src/de/steamwar/lobby/command/ModifyCommand.java +++ b/src/de/steamwar/lobby/command/ModifyCommand.java @@ -23,6 +23,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.HumanEntity; @@ -50,7 +51,7 @@ public class ModifyCommand extends SWCommand implements Listener { @Register public void modify(Player player) { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if(!user.getUserGroup().isTeamGroup() && !user.getUserName().equals("joschi1")) + if(!user.hasPerm(UserPerm.BUILD)) return; if(modifying(player)) { @@ -78,7 +79,7 @@ public class ModifyCommand extends SWCommand implements Listener { @Register("waitinghallspawn") public void setWaitingHallSpawn(Player player) { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - if(!user.getUserGroup().isTeamGroup()) + if(!user.hasPerm(UserPerm.BUILD)) return; LobbySystem.config().setWaitingHallSpawn(player.getLocation()); diff --git a/src/de/steamwar/lobby/command/PortalCommand.java b/src/de/steamwar/lobby/command/PortalCommand.java index dbed310..b7773e5 100644 --- a/src/de/steamwar/lobby/command/PortalCommand.java +++ b/src/de/steamwar/lobby/command/PortalCommand.java @@ -11,6 +11,7 @@ import de.steamwar.command.TypeMapper; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.portal.*; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import lombok.Data; import org.bukkit.Location; import org.bukkit.World; @@ -29,7 +30,7 @@ public class PortalCommand extends SWCommand { public static boolean noPermissions(Player player) { SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - return !steamwarUser.getUserGroup().isTeamGroup(); + return !steamwarUser.hasPerm(UserPerm.BUILD); } @Register(help = true) diff --git a/src/de/steamwar/lobby/map/CustomMapCommand.java b/src/de/steamwar/lobby/map/CustomMapCommand.java index 2bb13e2..c0489d9 100644 --- a/src/de/steamwar/lobby/map/CustomMapCommand.java +++ b/src/de/steamwar/lobby/map/CustomMapCommand.java @@ -23,7 +23,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.UserPerm; import lombok.SneakyThrows; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -41,7 +41,7 @@ public class CustomMapCommand extends SWCommand { @Register @SneakyThrows public void render(@Validator Player p, File file) { - if (SteamwarUser.get(p.getUniqueId()).getUserGroup() != UserGroup.Developer) { + if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION)) { return; } if (!file.exists()) { @@ -53,9 +53,7 @@ public class CustomMapCommand extends SWCommand { @ClassValidator(value = Player.class, local = true) public TypeValidator getGuardChecker() { - return (commandSender, player, messageSender) -> { - return SteamwarUser.get(player.getUniqueId()).getUserGroup() == UserGroup.Developer; - }; + return (commandSender, player, messageSender) -> SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION); } @ClassMapper(value = File.class, local = true) diff --git a/src/de/steamwar/lobby/particle/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java index 0757cc2..535ebd0 100644 --- a/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -25,6 +25,7 @@ import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -111,6 +112,6 @@ public class ParticleListener extends BasicListener { public static boolean disabled(Player player) { SteamwarUser user = SteamwarUser.get(player.getUniqueId()); if (Bukkit.getOnlinePlayers().size() > SERVER_TEAM_MAX_SIZE) return true; - return Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE && !user.getUserGroup().isTeamGroup(); + return Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE && !user.hasPerm(UserPerm.TEAM); } } diff --git a/src/de/steamwar/lobby/particle/ParticleRequirement.java b/src/de/steamwar/lobby/particle/ParticleRequirement.java index d388f9a..80e6099 100644 --- a/src/de/steamwar/lobby/particle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/particle/ParticleRequirement.java @@ -3,10 +3,7 @@ package de.steamwar.lobby.particle; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.special.easter.EggDifficulty; import de.steamwar.lobby.special.easter.EggHunt; -import de.steamwar.sql.Event; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.Team; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.*; import org.bukkit.entity.Player; import java.util.HashSet; @@ -29,7 +26,7 @@ public interface ParticleRequirement { @Override public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { - return user.getUserGroup() != UserGroup.Member; + return user.hasPerm(UserPerm.TEAM); } }; diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 75ddff8..296b1d6 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -23,6 +23,7 @@ import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.display.NPC; import de.steamwar.lobby.listener.BasicListener; import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; import lombok.AllArgsConstructor; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -150,7 +151,8 @@ public class TeamPlayer extends BasicListener { } SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName()); String message = strings.get(random.nextInt(strings.size())); - LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), user.getUserGroup().getColorCode() + user.getUserGroup().name()); + UserPerm.Prefix prefix = user.prefix(); + LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), prefix.getColorCode() + prefix.getChatPrefix()); } @EventHandler -- 2.39.5