SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Rework of the Codesite Group System' (#139) from change-color into master

Reviewed-by: YoyoNow <jwsteam@nidido.de>
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2020-10-31 10:47:42 +01:00
Commit ff1c72233b
5 geänderte Dateien mit 105 neuen und 71 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.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

@ -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;
@ -58,53 +59,25 @@ 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");
if(user.getUserGroup().isAdminGroup())
player.addGroups(ADMIN_GROUP);
if(user.getUserGroup().isTeamGroup())
player.addGroups(TEAM_GROUP);
if(user.getUserGroup().isCheckSchematics())
player.setPermission(CHECK_PERMISSION, true);
if(user.getUserGroup() != UserGroup.Member) {
player.setPermission(YOUTUBER_MODS, true);
player.setDisplayName(user.getUserGroup().getColorCode() + user.getUserGroup().name() + " " + player.getName() + "§r");
player.setPermission("bungeecore.group." + user.getUserGroup().name().toLowerCase(), true);
}else {
player.setDisplayName(player.getName());
}
for(Subserver subserver : Subserver.getServerList()){
if(subserver.getType() == Servertype.ARENA){

Datei anzeigen

@ -25,6 +25,8 @@ 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 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;
@ -204,15 +206,13 @@ public class TablistManager extends BasicListener {
}
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");
UserGroup group = SteamwarUser.get(p).getUserGroup();
//else st.append("§7");
else if (sameServer) st.append("§f");
else st.append("§7");
if(group == 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.getUsergroup(rs.getString("UserGroup"));
banTime = rs.getTimestamp("BanTime");
banReason = rs.getString("BanReason");
team = rs.getInt("Team");
@ -148,7 +148,7 @@ public class SteamwarUser {
return userName;
}
public String getUserGroup() {
public UserGroup getUserGroup() {
return userGroup;
}

Datei anzeigen

@ -0,0 +1,72 @@
/*
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;
import java.util.Arrays;
import java.util.stream.Collectors;
public enum UserGroup {
Admin("§4", "§e", true, true, true),
Developer("§3", "§f", true, true, true),
Moderator("§c", "§f", true, true, true),
Supporter("§9", "§f", false, true, true),
Builder("§2", "§f", false, true, false),
YouTuber("§5", "§f", 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, String chatColorCode, boolean adminGroup, boolean teamGroup, boolean checkSchematics) {
this.colorCode = colorCode;
this.chatColorCode = chatColorCode;
this.adminGroup = adminGroup;
this.teamGroup = teamGroup;
this.checkSchematics = checkSchematics;
}
public String getColorCode() {
return colorCode;
}
public boolean isAdminGroup() {
return adminGroup;
}
public boolean isTeamGroup() {
return teamGroup;
}
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);
}
}