SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'master' into StatCommand

Dieser Commit ist enthalten in:
YoyoNow 2021-07-12 09:06:35 +02:00
Commit e3893ce7d4
2 geänderte Dateien mit 46 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -157,7 +157,7 @@ public class ChatListener extends BasicListener {
String name = sender.getDisplayName();
String chatcolor = user.getUserGroup().getChatColorCode();
if(user.getUserGroup() != UserGroup.Member)
if(user.getUserGroup() != UserGroup.Member || user.getTeam() == 12 || user.getTeam() == 285 || user.getTeam() == 54)
message = ChatColor.translateAlternateColorCodes('&', message);
String msg = name + "§7»" + chatcolor + " " + message;

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
@ -70,13 +71,9 @@ public class TablistManager extends BasicListener {
private void calculateSize() {
size = -1;
for(Map.Entry<String, List<ProxiedPlayer>> server : playerMap.entrySet())
size += 2 + server.getValue().size();
size += playerMap.size() * 2 + ProxyServer.getInstance().getPlayers().size();
size = (size + 19) / 20;
if(size > 5)
size = 5;
if(size > 5) size = 5;
}
private synchronized void updateCustomTablist(){
@ -173,17 +170,10 @@ public class TablistManager extends BasicListener {
server = Message.parse("TABLIST_BAU", player);
setSlot(i%20, i/20, gray, "§7§l" + server, 1000);
i++;
for (ProxiedPlayer p : playerMap.get(server)){
boolean sameServer = currentServer == p.getServer().getInfo();
setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p, sameServer), (sameServer ? 1 : 500));
i++;
}
i = update(currentServer, playerMap.get(server), i);
}
while (i < size*20){
setSlot(i%20, i/20, darkGray, "", 1000);
i++;
}
finish(i);
}catch(IndexOutOfBoundsException | NullPointerException e){
//Ignore IndexOutOfBoundsException
//Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting
@ -200,17 +190,23 @@ public class TablistManager extends BasicListener {
i++;
}
spacer = true;
Team team = getTeam(player);
List<ProxiedPlayer> players = playerMap.get(server)
.stream()
.filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member)
.filter(p -> p.getServer().getInfo() == currentServer || SteamwarUser.get(p).getUserGroup() != UserGroup.Member || (team != null && team == getTeam(p)))
.collect(Collectors.toList());
if (server.equals("Bau")) {
Subserver subserver = Subserver.getSubserver(player);
if (server.equals("Bau")) {
if (subserver != null && subserver.getType() == Servertype.BAUSERVER) {
players = playerMap.get(server);
}
server = Message.parse("TABLIST_BAU", player);
}
if (subserver != null && subserver.getType() == Servertype.ARENA && playerMap.get(server).size() == 1) {
players = playerMap.get(server);
}
int increment = playerMap.get(server).size() - players.size();
if (players.isEmpty()) {
server += " §7(" + increment + ")";
@ -221,24 +217,38 @@ public class TablistManager extends BasicListener {
setSlot(i%20, i/20, gray, "§7§l" + server, 1000);
i++;
for (ProxiedPlayer p : players){
boolean sameServer = currentServer == p.getServer().getInfo();
setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p, sameServer), (sameServer ? 1 : 500));
i++;
}
i = update(currentServer, players, i);
}
while (i < size*20){
setSlot(i%20, i/20, darkGray, "", 1000);
i++;
}
finish(i);
}catch(IndexOutOfBoundsException | NullPointerException e){
//Ignore IndexOutOfBoundsException
//Ignore NPE, happens sometimes (only 1s long) when somebody is joining, server switching or disconnecting
}
}
private String getTablistName(ProxiedPlayer p, boolean sameServer) {
private int update(ServerInfo currentServer, List<ProxiedPlayer> players, int i) {
for (ProxiedPlayer p : players){
boolean sameServer = currentServer == p.getServer().getInfo();
setSlot(i % 20, i / 20, BungeeTabListPlusAPI.getIconFromPlayer(p), getTablistName(p), (sameServer ? 1 : 500));
i++;
}
return i;
}
private void finish(int i) {
while (i < size*20){
setSlot(i%20, i/20, darkGray, "", 1000);
i++;
}
}
private Team getTeam(ProxiedPlayer p) {
Team team = Team.get(SteamwarUser.get(p).getTeam());
return team.getTeamId() <= 0 ? null : team;
}
private String getTablistName(ProxiedPlayer p) {
Subserver server = Subserver.getSubserver(p);
if(server != null){
String tablistName = server.getTablistNames().get(p);
@ -249,13 +259,14 @@ public class TablistManager extends BasicListener {
StringBuilder st = new StringBuilder();
UserGroup group = SteamwarUser.get(p).getUserGroup();
//else st.append("§7");
if(group == UserGroup.Member && sameServer)
st.append("§f");
else
if (group == UserGroup.Member) {
Team team = getTeam(player);
if (team != null && team == getTeam(p)) st.append("§f");
else st.append("§7");
} else {
st.append(group.getColorCode());
}
// if (!sameServer) st.append("§o");
return st.append(p.getName()).toString();
}
}