Archiviert
1
0

Unified Color and Groups for Tablist and Chat

Dieser Commit ist enthalten in:
Chaoscaot 2020-10-28 19:26:18 +01:00
Ursprung 790d37300e
Commit 02d1845582
3 geänderte Dateien mit 82 neuen und 58 gelöschten Zeilen

Datei anzeigen

@ -58,53 +58,24 @@ public class ConnectionListener extends BasicListener {
public void onPostLogin(PostLoginEvent event) {
ProxiedPlayer player = event.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
player.removeGroups("Admin", "team");
switch(user.getUserGroup()){
case "Admin":
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.admin", true);
player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§4Admin " + player.getName() + "§r");
break;
case "Developer":
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.developer", true);
player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§3Developer " + player.getName() + "§r");
break;
case "Moderator":
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
player.setPermission("bungeecore.group.moderator", true);
player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§bModerator " + player.getName() + "§r");
break;
case "Supporter":
player.addGroups(TEAM_GROUP);
player.setPermission("bungeecore.group.supporter", true);
player.setPermission(CHECK_PERMISSION, true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§1Supporter " + player.getName() + "§r");
break;
case "Builder":
player.addGroups(TEAM_GROUP);
player.setPermission("bungeecore.group.builder", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§2Architekt " + player.getName() + "§r");
break;
case "Youtuber":
player.setPermission("bungeecore.group.youtuber", true);
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName("§5Youtuber " + player.getName() + "§r");
break;
case "Member":
default:
player.setDisplayName(player.getName());
break;
}
player.removeGroups("Admin", "team");
player.setDisplayName(player.getName());
if(user.getUserGroup().isAdminGroup())
player.addGroups(ADMIN_GROUP, TEAM_GROUP);
if(user.getUserGroup().isTeamGroup())
player.addGroups(TEAM_GROUP);
if(user.getUserGroup().isCheckSchematics())
player.setPermission(CHECK_PERMISSION, true);
if(user.getUserGroup() != SteamwarUser.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);
}
for(Subserver subserver : Subserver.getServerList()){
if(subserver.getType() == Servertype.ARENA){

Datei anzeigen

@ -25,6 +25,7 @@ import codecrafter47.bungeetablistplus.tablist.DefaultCustomTablist;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -197,15 +198,13 @@ public class TablistManager extends BasicListener {
private String getTablistName(ProxiedPlayer p, boolean sameServer) {
StringBuilder st = new StringBuilder();
if (p.hasPermission("bungeecore.group.admin")) st.append("§4");
else if (p.hasPermission("bungeecore.group.developer")) st.append("§3");
else if (p.hasPermission("bungeecore.group.moderator")) st.append("§b");
else if (p.hasPermission("bungeecore.group.supporter")) st.append("§1");
else if (p.hasPermission("bungeecore.group.builder")) st.append("§2");
else if (p.hasPermission("bungeecore.group.youtuber")) st.append("§5");
SteamwarUser.UserGroup group = SteamwarUser.UserGroup.getUserGroupByPermission(p);
//else st.append("§7");
else if (sameServer) st.append("§f");
else st.append("§7");
if(group == SteamwarUser.UserGroup.MEMBER && sameServer)
st.append("§f");
else
st.append(group.getColorCode());
// if (!sameServer) st.append("§o");
return st.append(p.getName()).toString();

Datei anzeigen

@ -42,7 +42,7 @@ public class SteamwarUser {
private final int id;
private final UUID uuid;
private String userName;
private String userGroup;
private UserGroup userGroup;
private Timestamp banTime;
private String banReason;
private int team;
@ -68,7 +68,7 @@ public class SteamwarUser {
id = rs.getInt("id");
uuid = UUID.fromString(rs.getString("UUID"));
userName = rs.getString("UserName");
userGroup = rs.getString("UserGroup");
userGroup = UserGroup.valueOf(rs.getString("UserGroup").toUpperCase());
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 (?, ?, 'Member')", connection.getUniqueId().toString(), connection.getName());
SQL.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES (?, ?, ?)", connection.getUniqueId().toString(), connection.getName(), UserGroup.STANDARD_GROUP.getDisplayName());
user = dbInit(SQL.select("SELECT * FROM UserData WHERE UUID = ?", connection.getUniqueId().toString()));
if(user == null)
throw new SecurityException("user == null");
@ -148,7 +148,7 @@ public class SteamwarUser {
return userName;
}
public String getUserGroup() {
public UserGroup getUserGroup() {
return userGroup;
}
@ -254,4 +254,58 @@ 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", "§b", true, true, true),
SUPPORTER("Supporter", "§1", 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;
}
}
}