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
3 geänderte Dateien mit 26 neuen und 24 gelöschten Zeilen
Nur Änderungen aus Commit edd81c6ca6 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.comms.packets.PingPacket;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.ProxyServer;
@ -158,22 +159,10 @@ public class ChatListener extends BasicListener {
private void publicChat(SteamwarUser user, ProxiedPlayer sender, String message){
String name = sender.getDisplayName();
String chatcolor = "§7";
String chatcolor = user.getUserGroup().getChatColorCode();
message = message.replace('§', '&');
if(sender.hasPermission("bungeecore.group.admin")){
chatcolor = "§e";
if(user.getUserGroup() != UserGroup.Member)
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(
sender.hasPermission("bungeecore.group.developer") ||
sender.hasPermission("bungeecore.group.moderator") ||
sender.hasPermission("bungeecore.group.supporter") ||
sender.hasPermission("bungeecore.group.builder")){
chatcolor = "§r";
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(sender.hasPermission("bungeecore.group.youtuber")){
message = ChatColor.translateAlternateColorCodes('&', message);
}
String msg = name + "§7»" + chatcolor + " " + message;
if(user.getTeam() != 0){

Datei anzeigen

@ -68,7 +68,7 @@ public class SteamwarUser {
id = rs.getInt("id");
uuid = UUID.fromString(rs.getString("UUID"));
userName = rs.getString("UserName");
userGroup = UserGroup.valueOf(rs.getString("UserGroup").toUpperCase());
userGroup = UserGroup.getUsergroup(rs.getString("UserGroup"));
Review

Das gibt NPEs.

Das gibt NPEs.
banTime = rs.getTimestamp("BanTime");
banReason = rs.getString("BanReason");
team = rs.getInt("Team");
@ -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.Member.name());
SQL.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, 'Member')", connection.getUniqueId().toString(), connection.getName());
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");

Datei anzeigen

@ -19,23 +19,28 @@
package de.steamwar.bungeecore.sql;
import java.util.Arrays;
import java.util.stream.Collectors;
public enum UserGroup {
Admin("§4", true, true, true),
Developer("§3", true, true, true),
Moderator("§c", true, true, true),
Supporter("§6", false, true, true),
Builder("§2", false, true, false),
Youtuber("§5", false, false, false),
Member("§7", false, false, false);
Admin("§4", "§e", true, true, true),
Developer("§3", "§f", true, true, true),
Moderator("§c", "§f", true, true, true),
Supporter("§6", "§f", false, true, true),
Builder("§2", "§f", false, true, false),
Youtuber("§5", "§7", false, false, false),
Member("§7", "§7", false, false, false);
private final String colorCode;
private final String chatColorCode;
private final boolean adminGroup;
private final boolean teamGroup;
private final boolean checkSchematics;
UserGroup(String colorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics) {
UserGroup(String colorCode, String chatColorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics) {
this.colorCode = colorCode;
this.chatColorCode = chatColorCode;
this.adminGroup = adminGroup;
this.teamGroup = teamGroup;
this.checkSchematics = checkSchematics;
@ -56,4 +61,12 @@ public enum UserGroup {
public boolean isCheckSchematics() {
return checkSchematics;
}
public String getChatColorCode() {
return chatColorCode;
}
public static UserGroup getUsergroup(String name) {
return Arrays.stream(UserGroup.values()).filter(userGroup -> userGroup.name().equalsIgnoreCase(name)).collect(Collectors.toList()).get(0);
}
}