geforkt von SteamWar/BungeeCore
Make it use more mod loader + add modloader + color coding
Dieser Commit ist enthalten in:
Ursprung
b6365d32f7
Commit
ed55af8952
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import com.google.common.reflect.TypeParameter;
|
import com.google.common.reflect.TypeParameter;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.Storage;
|
import de.steamwar.bungeecore.Storage;
|
||||||
|
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
@ -108,15 +109,18 @@ public class WhoisCommand extends SWCommand {
|
|||||||
Team team = Team.get(user.getTeam());
|
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());
|
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(Utils.synchronizedPlayerModMap.containsKey(user.getUuid())) {
|
||||||
|
Mod.Platform modPlatform = Utils.synchronizedPlayerModMap.get(user.getUuid()).get(0).getPlatform();
|
||||||
|
Message.send("WHOIS_PLATFORM",player,modPlatform.toString());
|
||||||
|
}
|
||||||
|
|
||||||
if(parameterTypes.contains(WhoisParameterTypes.MOD)) {
|
if(parameterTypes.contains(WhoisParameterTypes.MOD)) {
|
||||||
if(!user.getActiveMods().isEmpty()) {
|
List<Mod> activeMods = Utils.synchronizedPlayerModMap.get(user.getUuid());
|
||||||
Message.send("WHOIS_ACTIVE_MODS",player);
|
|
||||||
StringBuilder msg = new StringBuilder();
|
if(!activeMods.isEmpty()) {
|
||||||
for(Mod mod : user.getActiveMods()) {
|
Message.send("WHOIS_ACTIVE_MODS",player);
|
||||||
msg.append(mod.getModName()).append(",");
|
String result = activeMods.stream().map(mod -> mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, "));
|
||||||
}
|
Message.send("WHOIS_ACTIVE_MOD", player,result);
|
||||||
msg.deleteCharAt(msg.length() - 1);
|
|
||||||
Message.send("WHOIS_ACTIVE_MOD", player,msg.toString());
|
|
||||||
}else {
|
}else {
|
||||||
Message.send("WHOIS_NO_ACTIVE_MODS",player);
|
Message.send("WHOIS_NO_ACTIVE_MODS",player);
|
||||||
}
|
}
|
||||||
@ -143,13 +147,13 @@ public class WhoisCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = WhoisParameterTypes.class, local = true)
|
@ClassMapper(value = WhoisParameterTypes.class, local = true)
|
||||||
public TypeMapper<WhoisParameterTypes> argument() {
|
public TypeMapper<WhoisParameterTypes> argumentTypeMapper() {
|
||||||
WhoisParameterTypes[] values = WhoisParameterTypes.values();
|
WhoisParameterTypes[] values = WhoisParameterTypes.values();
|
||||||
|
|
||||||
return new TypeMapper<WhoisParameterTypes>() {
|
return new TypeMapper<WhoisParameterTypes>() {
|
||||||
@Override
|
@Override
|
||||||
public WhoisParameterTypes map(CommandSender commandSender, String[] previousArguments, String s) {
|
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)
|
return Stream.of(values)
|
||||||
.filter(p -> p.userGroupSet.contains(userGroup))
|
.filter(p -> p.userGroupSet.contains(userGroup))
|
||||||
.filter(p -> p.getTabCompletes().contains(s))
|
.filter(p -> p.getTabCompletes().contains(s))
|
||||||
@ -159,7 +163,7 @@ public class WhoisCommand extends SWCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
|
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)
|
return Stream.of(values)
|
||||||
.filter(p -> p.userGroupSet.contains(userGroup))
|
.filter(p -> p.userGroupSet.contains(userGroup))
|
||||||
.flatMap(p -> p.getTabCompletes().stream())
|
.flatMap(p -> p.getTabCompletes().stream())
|
||||||
|
@ -28,8 +28,10 @@ import de.steamwar.bungeecore.bot.util.DiscordRanks;
|
|||||||
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||||
|
import de.steamwar.bungeecore.listeners.mods.Utils;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
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.AbstractReconnectHandler;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -135,6 +137,7 @@ public class ConnectionListener extends BasicListener {
|
|||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
ChallengeCommand.remove(e.getPlayer());
|
ChallengeCommand.remove(e.getPlayer());
|
||||||
MsgCommand.remove(e.getPlayer());
|
MsgCommand.remove(e.getPlayer());
|
||||||
|
Utils.synchronizedPlayerModMap.remove(e.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -89,7 +89,7 @@ public class Fabric extends BasicListener {
|
|||||||
}
|
}
|
||||||
Storage.fabricExpectPluginMessage.remove(player);
|
Storage.fabricExpectPluginMessage.remove(player);
|
||||||
|
|
||||||
ArrayList<Mod> mods = new ArrayList<>();
|
List<Mod> mods = new ArrayList<>();
|
||||||
|
|
||||||
Utils.VarInt varInt = Utils.readVarInt(data,0);
|
Utils.VarInt varInt = Utils.readVarInt(data,0);
|
||||||
|
|
||||||
@ -127,8 +127,6 @@ public class Fabric extends BasicListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setActiveMods(mods);
|
|
||||||
|
|
||||||
if(Utils.handleMods(player,mods)) {
|
if(Utils.handleMods(player,mods)) {
|
||||||
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||||
long current = Storage.fabricCheckedPlayers.get(player);
|
long current = Storage.fabricCheckedPlayers.get(player);
|
||||||
|
@ -33,10 +33,7 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class LabyMod extends BasicListener {
|
public class LabyMod extends BasicListener {
|
||||||
|
|
||||||
|
@ -33,15 +33,15 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Iterator;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
public static final Map<UUID,List<Mod>> synchronizedPlayerModMap = new HashMap<>();
|
||||||
|
|
||||||
private Utils(){}
|
private Utils(){}
|
||||||
|
|
||||||
static VarInt readVarInt(byte[] array, int startPos) {
|
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){
|
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
|
||||||
SteamwarUser user = SteamwarUser.get(uuid);
|
SteamwarUser user = SteamwarUser.get(uuid);
|
||||||
boolean privileged = user.getUserGroup().privilegedMods();
|
boolean privileged = user.getUserGroup().privilegedMods();
|
||||||
|
synchronizedPlayerModMap.put(uuid,new ArrayList<>(mods));
|
||||||
|
|
||||||
ModType max = ModType.YELLOW;
|
ModType max = ModType.YELLOW;
|
||||||
Iterator<Mod> it = mods.iterator();
|
Iterator<Mod> it = mods.iterator();
|
||||||
@ -80,8 +81,10 @@ class Utils {
|
|||||||
max = ModType.RED;
|
max = ModType.RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mods.isEmpty())
|
if(mods.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ModType finalMax = max;
|
ModType finalMax = max;
|
||||||
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));
|
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));
|
||||||
|
@ -74,11 +74,11 @@ public class Mod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum ModType {
|
public enum ModType {
|
||||||
UNKLASSIFIED(0),
|
UNKLASSIFIED(0,"§7 "),
|
||||||
GREEN(1),
|
GREEN(1,"§a "),
|
||||||
YELLOW(2),
|
YELLOW(2,"§e "),
|
||||||
RED(3),
|
RED(3,"§c "),
|
||||||
YOUTUBER_ONLY(4);
|
YOUTUBER_ONLY(4,"§6 ");
|
||||||
|
|
||||||
static ModType valueOf(int value){
|
static ModType valueOf(int value){
|
||||||
for(ModType mt : values()){
|
for(ModType mt : values()){
|
||||||
@ -88,9 +88,15 @@ public class Mod {
|
|||||||
throw new EnumConstantNotPresentException(ModType.class, Integer.toString(value));
|
throw new EnumConstantNotPresentException(ModType.class, Integer.toString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
ModType(int value){
|
ModType(int value,String colorcode){
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.colorcode = colorcode;
|
||||||
}
|
}
|
||||||
int value;
|
int value;
|
||||||
|
String colorcode;
|
||||||
|
|
||||||
|
public String getColorCode() {
|
||||||
|
return colorcode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,6 @@ public class SteamwarUser {
|
|||||||
private Locale locale;
|
private Locale locale;
|
||||||
private boolean manualLocale;
|
private boolean manualLocale;
|
||||||
|
|
||||||
private List<Mod> activeMods = new CopyOnWriteArrayList<>();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
LIXFEL_DE = InetAddress.getByAddress(new byte[]{(byte) 195, (byte) 201, (byte) 242, 43});
|
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);
|
updateLocale.update(locale.toLanguageTag(), manualLocale, id);
|
||||||
NetworkSender.send(getPlayer(), new LocaleInvalidationPacket(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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_NO_ALL_PUNISHMENT=§a✓ §7The player has not done anything yet.
|
||||||
WHOIS_ACTIVE_MODS=§7Active Mods:
|
WHOIS_ACTIVE_MODS=§7Active Mods:
|
||||||
WHOIS_NO_ACTIVE_MODS=§7This player has no active 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
|
#VerifyCommand
|
||||||
VERIFY_USAGE=§c/verify [Code]
|
VERIFY_USAGE=§c/verify [Code]
|
||||||
|
@ -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_NO_ALL_PUNISHMENT=§a✓ §7Der Spieler hat noch nichts getan.
|
||||||
WHOIS_ACTIVE_MODS=§7Aktive Mods:
|
WHOIS_ACTIVE_MODS=§7Aktive Mods:
|
||||||
WHOIS_NO_ACTIVE_MODS=§7Der Spieler hat keine aktiven 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
|
#VerifyCommand
|
||||||
VERIFY_USAGE=§c/verify [Code]
|
VERIFY_USAGE=§c/verify [Code]
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren