SteamWar/BungeeCore
Archiviert
13
2

Make it use more mod loader + add modloader + color coding
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
zOnlyKroks 2023-01-02 23:54:24 +01:00
Ursprung b6365d32f7
Commit ed55af8952
9 geänderte Dateien mit 45 neuen und 43 gelöschten Zeilen

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
import com.google.common.reflect.TypeParameter;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Storage;
import de.steamwar.bungeecore.listeners.mods.Utils;
import de.steamwar.bungeecore.sql.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
@ -108,15 +109,18 @@ public class WhoisCommand extends SWCommand {
Team team = Team.get(user.getTeam());
Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
if(parameterTypes.contains(WhoisParameterTypes.MOD)) {
if(!user.getActiveMods().isEmpty()) {
Message.send("WHOIS_ACTIVE_MODS",player);
StringBuilder msg = new StringBuilder();
for(Mod mod : user.getActiveMods()) {
msg.append(mod.getModName()).append(",");
if(Utils.synchronizedPlayerModMap.containsKey(user.getUuid())) {
Mod.Platform modPlatform = Utils.synchronizedPlayerModMap.get(user.getUuid()).get(0).getPlatform();
Message.send("WHOIS_PLATFORM",player,modPlatform.toString());
}
msg.deleteCharAt(msg.length() - 1);
Message.send("WHOIS_ACTIVE_MOD", player,msg.toString());
if(parameterTypes.contains(WhoisParameterTypes.MOD)) {
List<Mod> activeMods = Utils.synchronizedPlayerModMap.get(user.getUuid());
if(!activeMods.isEmpty()) {
Message.send("WHOIS_ACTIVE_MODS",player);
String result = activeMods.stream().map(mod -> mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, "));
Message.send("WHOIS_ACTIVE_MOD", player,result);
}else {
Message.send("WHOIS_NO_ACTIVE_MODS",player);
}
@ -143,13 +147,13 @@ public class WhoisCommand extends SWCommand {
}
@ClassMapper(value = WhoisParameterTypes.class, local = true)
public TypeMapper<WhoisParameterTypes> argument() {
public TypeMapper<WhoisParameterTypes> argumentTypeMapper() {
WhoisParameterTypes[] values = WhoisParameterTypes.values();
return new TypeMapper<WhoisParameterTypes>() {
@Override
public WhoisParameterTypes map(CommandSender commandSender, String[] previousArguments, String s) {
UserGroup userGroup = (commandSender instanceof ConsoleCommandSender) ? UserGroup.Admin : SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup();
UserGroup userGroup = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup();
return Stream.of(values)
.filter(p -> p.userGroupSet.contains(userGroup))
.filter(p -> p.getTabCompletes().contains(s))
@ -159,7 +163,7 @@ public class WhoisCommand extends SWCommand {
@Override
public Collection<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
UserGroup userGroup = (commandSender instanceof ConsoleCommandSender) ? UserGroup.Admin : SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup();
UserGroup userGroup = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup();
return Stream.of(values)
.filter(p -> p.userGroupSet.contains(userGroup))
.flatMap(p -> p.getTabCompletes().stream())

Datei anzeigen

@ -28,8 +28,10 @@ import de.steamwar.bungeecore.bot.util.DiscordRanks;
import de.steamwar.bungeecore.commands.ChallengeCommand;
import de.steamwar.bungeecore.commands.CheckCommand;
import de.steamwar.bungeecore.commands.MsgCommand;
import de.steamwar.bungeecore.listeners.mods.Utils;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserGroup;
import net.md_5.bungee.Util;
import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
@ -135,6 +137,7 @@ public class ConnectionListener extends BasicListener {
public void onDisconnect(PlayerDisconnectEvent e){
ChallengeCommand.remove(e.getPlayer());
MsgCommand.remove(e.getPlayer());
Utils.synchronizedPlayerModMap.remove(e.getPlayer().getUniqueId());
}
@EventHandler

Datei anzeigen

@ -89,7 +89,7 @@ public class Fabric extends BasicListener {
}
Storage.fabricExpectPluginMessage.remove(player);
ArrayList<Mod> mods = new ArrayList<>();
List<Mod> mods = new ArrayList<>();
Utils.VarInt varInt = Utils.readVarInt(data,0);
@ -127,8 +127,6 @@ public class Fabric extends BasicListener {
return;
}
user.setActiveMods(mods);
if(Utils.handleMods(player,mods)) {
if (Storage.fabricCheckedPlayers.containsKey(player)) {
long current = Storage.fabricCheckedPlayers.get(player);

Datei anzeigen

@ -33,10 +33,7 @@ import net.md_5.bungee.event.EventHandler;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.*;
public class LabyMod extends BasicListener {

Datei anzeigen

@ -33,15 +33,15 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import java.util.*;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.stream.Collectors;
class Utils {
public class Utils {
public static final Map<UUID,List<Mod>> synchronizedPlayerModMap = new HashMap<>();
private Utils(){}
static VarInt readVarInt(byte[] array, int startPos) {
@ -69,6 +69,7 @@ class Utils {
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
SteamwarUser user = SteamwarUser.get(uuid);
boolean privileged = user.getUserGroup().privilegedMods();
synchronizedPlayerModMap.put(uuid,new ArrayList<>(mods));
ModType max = ModType.YELLOW;
Iterator<Mod> it = mods.iterator();
@ -80,8 +81,10 @@ class Utils {
max = ModType.RED;
}
if(mods.isEmpty())
if(mods.isEmpty()) {
return true;
}
ModType finalMax = max;
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));

Datei anzeigen

@ -74,11 +74,11 @@ public class Mod {
}
public enum ModType {
UNKLASSIFIED(0),
GREEN(1),
YELLOW(2),
RED(3),
YOUTUBER_ONLY(4);
UNKLASSIFIED(0,"§7 "),
GREEN(1,"§a "),
YELLOW(2,"§e "),
RED(3,"§c "),
YOUTUBER_ONLY(4,"§6 ");
static ModType valueOf(int value){
for(ModType mt : values()){
@ -88,9 +88,15 @@ public class Mod {
throw new EnumConstantNotPresentException(ModType.class, Integer.toString(value));
}
ModType(int value){
ModType(int value,String colorcode){
this.value = value;
this.colorcode = colorcode;
}
int value;
String colorcode;
public String getColorCode() {
return colorcode;
}
}
}

Datei anzeigen

@ -81,8 +81,6 @@ public class SteamwarUser {
private Locale locale;
private boolean manualLocale;
private List<Mod> activeMods = new CopyOnWriteArrayList<>();
static {
try {
LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43});
@ -395,13 +393,4 @@ public class SteamwarUser {
updateLocale.update(locale.toLanguageTag(), manualLocale, id);
NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(id));
}
public void setActiveMods(List<Mod> activeMods) {
this.activeMods.clear();
this.activeMods.addAll(activeMods);
}
public List<Mod> getActiveMods() {
return new ArrayList<>(activeMods);
}
}

Datei anzeigen

@ -598,7 +598,8 @@ WHOIS_NO_PUNISHMENT=§a✓ §7This player has no active punishment.
WHOIS_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet.
WHOIS_ACTIVE_MODS=§7Active Mods:
WHOIS_NO_ACTIVE_MODS=§7This player has no active mods.
WHOIS_ACTIVE_MOD=§7{0}
WHOIS_ACTIVE_MOD={0}
WHOIS_PLATFORM=§7Modloader: §e{0}
#VerifyCommand
VERIFY_USAGE=§c/verify [Code]

Datei anzeigen

@ -577,7 +577,8 @@ WHOIS_NO_PUNISHMENT=§a✓ §7Der Spieler hat keine aktiven Strafen.
WHOIS_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan.
WHOIS_ACTIVE_MODS=§7Aktive Mods:
WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven Mods.
WHOIS_ACTIVE_MOD=§7{0}
WHOIS_ACTIVE_MOD={0}
WHOIS_PLATFORM=§7Modloader:§e{0}
#VerifyCommand
VERIFY_USAGE=§c/verify [Code]