13
0

UserPerm #37

Zusammengeführt
Lixfel hat 1 Commits von userPerm nach master 2023-08-30 12:08:21 +02:00 zusammengeführt
7 geänderte Dateien mit 18 neuen und 19 gelöschten Zeilen
Nur Änderungen aus Commit 7a85f7456d werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -22,7 +22,7 @@ package de.steamwar.lobby.command;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.lobby.util.LobbyPlayer;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup; import de.steamwar.sql.UserPerm;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class FlyCommand extends SWCommand { public class FlyCommand extends SWCommand {
@ -33,10 +33,9 @@ public class FlyCommand extends SWCommand {
@Register @Register
public void genericCommand(Player player) { public void genericCommand(Player player) {
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (userGroup == UserGroup.Member || steamwarUser.getUserName().equals("joschi1")) { if (!user.hasPerm(UserPerm.TEAM)) {
player.sendMessage("§cUnbekannter Befehl."); player.sendMessage("§cUnbekannter Befehl.");
return; return;
} }

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.command.SWCommand;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.lobby.listener.PlayerSpawn;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
@ -50,7 +51,7 @@ public class ModifyCommand extends SWCommand implements Listener {
@Register @Register
public void modify(Player player) { public void modify(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!user.getUserGroup().isTeamGroup() && !user.getUserName().equals("joschi1")) if(!user.hasPerm(UserPerm.BUILD))
return; return;
if(modifying(player)) { if(modifying(player)) {
@ -78,7 +79,7 @@ public class ModifyCommand extends SWCommand implements Listener {
@Register("waitinghallspawn") @Register("waitinghallspawn")
public void setWaitingHallSpawn(Player player) { public void setWaitingHallSpawn(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!user.getUserGroup().isTeamGroup()) if(!user.hasPerm(UserPerm.BUILD))
return; return;
LobbySystem.config().setWaitingHallSpawn(player.getLocation()); LobbySystem.config().setWaitingHallSpawn(player.getLocation());

Datei anzeigen

@ -11,6 +11,7 @@ import de.steamwar.command.TypeMapper;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.portal.*; import de.steamwar.lobby.portal.*;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import lombok.Data; import lombok.Data;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -29,7 +30,7 @@ public class PortalCommand extends SWCommand {
public static boolean noPermissions(Player player) { public static boolean noPermissions(Player player) {
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
return !steamwarUser.getUserGroup().isTeamGroup(); return !steamwarUser.hasPerm(UserPerm.BUILD);
} }
@Register(help = true) @Register(help = true)

Datei anzeigen

@ -23,7 +23,7 @@ import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator; import de.steamwar.command.TypeValidator;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup; import de.steamwar.sql.UserPerm;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -41,7 +41,7 @@ public class CustomMapCommand extends SWCommand {
@Register @Register
@SneakyThrows @SneakyThrows
public void render(@Validator Player p, File file) { 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; return;
} }
if (!file.exists()) { if (!file.exists()) {
@ -53,9 +53,7 @@ public class CustomMapCommand extends SWCommand {
@ClassValidator(value = Player.class, local = true) @ClassValidator(value = Player.class, local = true)
public TypeValidator<Player> getGuardChecker() { public TypeValidator<Player> getGuardChecker() {
return (commandSender, player, messageSender) -> { return (commandSender, player, messageSender) -> SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION);
return SteamwarUser.get(player.getUniqueId()).getUserGroup() == UserGroup.Developer;
};
} }
@ClassMapper(value = File.class, local = true) @ClassMapper(value = File.class, local = true)

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.lobby.listener.PlayerSpawn;
import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.lobby.util.LobbyPlayer;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -111,6 +112,6 @@ public class ParticleListener extends BasicListener {
public static boolean disabled(Player player) { public static boolean disabled(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (Bukkit.getOnlinePlayers().size() > SERVER_TEAM_MAX_SIZE) return true; 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);
} }
} }

Datei anzeigen

@ -3,10 +3,7 @@ package de.steamwar.lobby.particle;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.special.easter.EggDifficulty; import de.steamwar.lobby.special.easter.EggDifficulty;
import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.lobby.special.easter.EggHunt;
import de.steamwar.sql.Event; import de.steamwar.sql.*;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.UserGroup;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.HashSet; import java.util.HashSet;
@ -29,7 +26,7 @@ public interface ParticleRequirement {
@Override @Override
public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) { public boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig) {
return user.getUserGroup() != UserGroup.Member; return user.hasPerm(UserPerm.TEAM);
} }
}; };

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.display.NPC; import de.steamwar.lobby.display.NPC;
import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -150,7 +151,8 @@ public class TeamPlayer extends BasicListener {
} }
SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName()); SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName());
String message = strings.get(random.nextInt(strings.size())); 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 @EventHandler