13
0

Merge pull request 'UserPerm' (#37) from userPerm into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #37
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Lixfel 2023-08-30 12:08:21 +02:00
Commit 6c3a735571
7 geänderte Dateien mit 18 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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());

Datei anzeigen

@ -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)

Datei anzeigen

@ -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<Player> 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)

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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<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.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