SteamWar/BungeeCore
Archiviert
13
2

Add Chatcolor to UserGroup

Dieser Commit ist enthalten in:
Chaoscaot 2020-10-30 22:34:29 +01:00
Ursprung f1bac4c9d2
Commit edd81c6ca6
3 geänderte Dateien mit 26 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.comms.packets.PingPacket; import de.steamwar.bungeecore.comms.packets.PingPacket;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team; 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.ChatColor;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.ProxyServer; 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){ private void publicChat(SteamwarUser user, ProxiedPlayer sender, String message){
String name = sender.getDisplayName(); String name = sender.getDisplayName();
String chatcolor = "§7"; String chatcolor = user.getUserGroup().getChatColorCode();
message = message.replace('§', '&'); if(user.getUserGroup() != UserGroup.Member)
if(sender.hasPermission("bungeecore.group.admin")){
chatcolor = "§e";
message = ChatColor.translateAlternateColorCodes('&', message); 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; String msg = name + "§7»" + chatcolor + " " + message;
if(user.getTeam() != 0){ if(user.getTeam() != 0){

Datei anzeigen

@ -68,7 +68,7 @@ public class SteamwarUser {
id = rs.getInt("id"); id = rs.getInt("id");
uuid = UUID.fromString(rs.getString("UUID")); uuid = UUID.fromString(rs.getString("UUID"));
userName = rs.getString("UserName"); userName = rs.getString("UserName");
userGroup = UserGroup.valueOf(rs.getString("UserGroup").toUpperCase()); userGroup = UserGroup.getUsergroup(rs.getString("UserGroup"));
banTime = rs.getTimestamp("BanTime"); banTime = rs.getTimestamp("BanTime");
banReason = rs.getString("BanReason"); banReason = rs.getString("BanReason");
team = rs.getInt("Team"); team = rs.getInt("Team");
@ -90,7 +90,7 @@ public class SteamwarUser {
user.userName = userName; user.userName = userName;
} }
}else{ }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());
user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString())); user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString()));
if(user == null) if(user == null)
throw new SecurityException("user == null"); throw new SecurityException("user == null");

Datei anzeigen

@ -19,23 +19,28 @@
package de.steamwar.bungeecore.sql; package de.steamwar.bungeecore.sql;
import java.util.Arrays;
import java.util.stream.Collectors;
public enum UserGroup { public enum UserGroup {
Admin("§4", true, true, true), Admin("§4", "§e", true, true, true),
Developer("§3", true, true, true), Developer("§3", "§f", true, true, true),
Moderator("§c", true, true, true), Moderator("§c", "§f", true, true, true),
Supporter("§6", false, true, true), Supporter("§6", "§f", false, true, true),
Builder("§2", false, true, false), Builder("§2", "§f", false, true, false),
Youtuber("§5", false, false, false), Youtuber("§5", "§7", false, false, false),
Member("§7", false, false, false); Member("§7", "§7", false, false, false);
private final String colorCode; private final String colorCode;
private final String chatColorCode;
private final boolean adminGroup; private final boolean adminGroup;
private final boolean teamGroup; private final boolean teamGroup;
private final boolean checkSchematics; 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.colorCode = colorCode;
this.chatColorCode = chatColorCode;
this.adminGroup = adminGroup; this.adminGroup = adminGroup;
this.teamGroup = teamGroup; this.teamGroup = teamGroup;
this.checkSchematics = checkSchematics; this.checkSchematics = checkSchematics;
@ -56,4 +61,12 @@ public enum UserGroup {
public boolean isCheckSchematics() { public boolean isCheckSchematics() {
return checkSchematics; 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);
}
} }