SteamWar/BungeeCore
Archiviert
13
2

Rework of the Codesite Group System #139

Manuell gemergt
Lixfel hat 11 Commits von change-color nach master 2020-10-31 10:47:43 +01:00 zusammengeführt
4 geänderte Dateien mit 78 neuen und 61 gelöschten Zeilen
Nur Änderungen aus Commit 6483729608 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Warum kann die Zeile nicht einfach bei der alten Zeile bleiben?

Warum kann die Zeile nicht einfach bei der alten Zeile bleiben?
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;
}
}
}

Datei anzeigen

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