Refactored UserGroup
Dieser Commit ist enthalten in:
Ursprung
caeb47b3d2
Commit
6483729608
@ -25,6 +25,7 @@ import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserGroup;
|
||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -63,7 +64,7 @@ public class ConnectionListener extends BasicListener {
|
||||
player.setDisplayName(player.getName());
|
||||
|
||||
if(user.getUserGroup().isAdminGroup())
|
||||
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
|
||||
player.addGroups(ADMIN_GROUP);
|
||||
|
||||
if(user.getUserGroup().isTeamGroup())
|
||||
player.addGroups(TEAM_GROUP);
|
||||
@ -71,10 +72,10 @@ public class ConnectionListener extends BasicListener {
|
||||
if(user.getUserGroup().isCheckSchematics())
|
||||
player.setPermission(CHECK_PERMISSION, true);
|
||||
|
||||
if(user.getUserGroup() != SteamwarUser.UserGroup.MEMBER) {
|
||||
if(user.getUserGroup() != UserGroup.Member) {
|
||||
player.setPermission(YOUTUBER_MODS, true);
|
||||
player.setDisplayName(user.getUserGroup().getColorCode() + user.getUserGroup().getDisplayName() + " " + player.getName() + "§r");
|
||||
player.setPermission("bungeecore.group." + user.getUserGroup().getDisplayName().toLowerCase(), true);
|
||||
player.setDisplayName(user.getUserGroup().getColorCode() + user.getUserGroup().name() + " " + player.getName() + "§r");
|
||||
player.setPermission("bungeecore.group." + user.getUserGroup().name().toLowerCase(), true);
|
||||
}
|
||||
|
||||
for(Subserver subserver : Subserver.getServerList()){
|
||||
|
@ -26,6 +26,7 @@ import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.UserGroup;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@ -205,10 +206,10 @@ public class TablistManager extends BasicListener {
|
||||
}
|
||||
|
||||
StringBuilder st = new StringBuilder();
|
||||
SteamwarUser.UserGroup group = SteamwarUser.UserGroup.getUserGroupByPermission(p);
|
||||
UserGroup group = SteamwarUser.get(p).getUserGroup();
|
||||
|
||||
//else st.append("§7");
|
||||
if(group == SteamwarUser.UserGroup.MEMBER && sameServer)
|
||||
if(group == UserGroup.Member && sameServer)
|
||||
st.append("§f");
|
||||
else
|
||||
st.append(group.getColorCode());
|
||||
|
@ -90,7 +90,7 @@ public class SteamwarUser {
|
||||
user.userName = userName;
|
||||
}
|
||||
}else{
|
||||
SQL.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, ?)", connection.getUniqueId().toString(), connection.getName(), UserGroup.STANDARD_GROUP.getDisplayName());
|
||||
SQL.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, ?)", connection.getUniqueId().toString(), connection.getName(), UserGroup.Member.name());
|
||||
user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString()));
|
||||
if(user == null)
|
||||
throw new SecurityException("user == null");
|
||||
@ -254,58 +254,4 @@ public class SteamwarUser {
|
||||
throw new SecurityException("Could not load First Join");
|
||||
}
|
||||
}
|
||||
|
||||
public enum UserGroup {
|
||||
|
||||
ADMIN("Admin", "§4", true, true, true),
|
||||
DEVELOPER("Developer", "§3", true, true, true),
|
||||
MODERATOR("Moderator", "§c", true, true, true),
|
||||
SUPPORTER("Supporter", "§6", false, true, true),
|
||||
BUILDER("Builder", "§2", false, true, false),
|
||||
YOUTUBER("Youtuber", "§5", false, false, false),
|
||||
MEMBER("Member", "§7", false, false, false);
|
||||
|
||||
public static final UserGroup STANDARD_GROUP = UserGroup.MEMBER;
|
||||
|
||||
private final String displayName;
|
||||
private final String colorCode;
|
||||
private final boolean adminGroup;
|
||||
private final boolean teamGroup;
|
||||
private final boolean checkSchematics;
|
||||
|
||||
UserGroup(String displayName, String colorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics) {
|
||||
this.displayName = displayName;
|
||||
this.colorCode = colorCode;
|
||||
this.adminGroup = adminGroup;
|
||||
this.teamGroup = teamGroup;
|
||||
this.checkSchematics = checkSchematics;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getColorCode() {
|
||||
return colorCode;
|
||||
}
|
||||
|
||||
public boolean isAdminGroup() {
|
||||
return adminGroup;
|
||||
}
|
||||
|
||||
public boolean isTeamGroup() {
|
||||
return teamGroup;
|
||||
}
|
||||
|
||||
public boolean isCheckSchematics() {
|
||||
return checkSchematics;
|
||||
}
|
||||
|
||||
public static UserGroup getUserGroupByPermission(ProxiedPlayer p) {
|
||||
for (UserGroup group : UserGroup.values()) {
|
||||
if (p.hasPermission("bungeecore.group." + group.getDisplayName().toLowerCase())) return group;
|
||||
}
|
||||
return UserGroup.STANDARD_GROUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
69
src/de/steamwar/bungeecore/sql/UserGroup.java
Normale Datei
69
src/de/steamwar/bungeecore/sql/UserGroup.java
Normale Datei
@ -0,0 +1,69 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.sql;
|
||||
|
||||
public enum UserGroup {
|
||||
|
||||
Admin("§4", true, true, true, 6),
|
||||
Developer("§3", true, true, true, 5),
|
||||
Moderator("§c", true, true, true, 4),
|
||||
Supporter("§6", false, true, true, 3),
|
||||
Builder("§2", false, true, false, 2),
|
||||
Youtuber("§5", false, false, false, 1),
|
||||
Member("§7", false, false, false, 0);
|
||||
|
||||
private final String colorCode;
|
||||
private final boolean adminGroup;
|
||||
private final boolean teamGroup;
|
||||
private final boolean checkSchematics;
|
||||
private final int permissionlevel;
|
||||
|
||||
UserGroup(String colorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics, int permissionlevel) {
|
||||
this.colorCode = colorCode;
|
||||
this.adminGroup = adminGroup;
|
||||
this.teamGroup = teamGroup;
|
||||
this.checkSchematics = checkSchematics;
|
||||
this.permissionlevel = permissionlevel;
|
||||
}
|
||||
|
||||
public String getColorCode() {
|
||||
return colorCode;
|
||||
}
|
||||
|
||||
public boolean isAdminGroup() {
|
||||
return adminGroup;
|
||||
}
|
||||
|
||||
public boolean isTeamGroup() {
|
||||
return teamGroup;
|
||||
}
|
||||
|
||||
public boolean isCheckSchematics() {
|
||||
return checkSchematics;
|
||||
}
|
||||
|
||||
public int getPermissionlevel() {
|
||||
return permissionlevel;
|
||||
}
|
||||
|
||||
public boolean isHigherThen(UserGroup checkAgainst) {
|
||||
return permissionlevel >= checkAgainst.permissionlevel;
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren