SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'master' into BuilderCloud

Dieser Commit ist enthalten in:
Lixfel 2022-08-27 14:27:50 +02:00
Commit d17a4f882e
26 geänderte Dateien mit 251 neuen und 316 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 21e77c55f023261d3a63d5c6200d28b2f6f6fc4c Subproject commit 3701f6f5ff10fa97d6816d5f57c85f7213f7fb3e

Datei anzeigen

@ -48,6 +48,7 @@ import net.md_5.bungee.config.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -57,12 +58,10 @@ import java.util.logging.Level;
public class BungeeCore extends Plugin { public class BungeeCore extends Plugin {
public static boolean MAIN_SERVER;
public static String CHAT_PREFIX; public static String CHAT_PREFIX;
public static String WORLD_FOLDER;
public static String BAUWELT_PROTOTYP;
public static String LOBBY_SERVER; public static String LOBBY_SERVER;
public static String USERWORLDS15;
public static String BAUWELT15;
public static boolean EVENT_MODE; public static boolean EVENT_MODE;
private static BungeeCore instance; private static BungeeCore instance;
@ -75,6 +74,15 @@ public class BungeeCore extends Plugin {
@Override @Override
public void onEnable(){ public void onEnable(){
getProxy().registerChannel("sw:bridge");
getProxy().registerChannel("fabricmodsender:mods");
setInstance(this);
MAIN_SERVER = ProxyServer.getInstance().getConfig().getListeners().stream().anyMatch(info -> ((InetSocketAddress) info.getSocketAddress()).getPort() == 25565);
loadConfig();
errorLogger = new ErrorLogger();
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, CommandSender, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() { SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, CommandSender, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
@Override @Override
public Object map(CommandSender commandSender, String[] previousArguments, String s) { public Object map(CommandSender commandSender, String[] previousArguments, String s) {
@ -88,13 +96,6 @@ public class BungeeCore extends Plugin {
}); });
BungeeCord.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS); BungeeCord.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS);
getProxy().registerChannel("sw:bridge");
getProxy().registerChannel("fabricmodsender:mods");
setInstance(this);
loadConfig();
errorLogger = new ErrorLogger();
new ConnectionListener(); new ConnectionListener();
new Forge(); new Forge();
new Forge12(); new Forge12();
@ -164,7 +165,7 @@ public class BungeeCore extends Plugin {
if(!EVENT_MODE){ if(!EVENT_MODE){
new BauCommand(); new BauCommand();
new WebregisterCommand(); new WebpasswordCommand();
new FightCommand(); new FightCommand();
new ChallengeCommand(); new ChallengeCommand();
new HistoricCommand(); new HistoricCommand();
@ -295,21 +296,13 @@ public class BungeeCore extends Plugin {
} }
CHAT_PREFIX = config.getString("prefix"); CHAT_PREFIX = config.getString("prefix");
WORLD_FOLDER = config.getString("worldfolder");
BAUWELT_PROTOTYP = config.getString("bauweltprototyp");
LOBBY_SERVER = config.getString("lobbyserver"); LOBBY_SERVER = config.getString("lobbyserver");
USERWORLDS15 = config.getString("userworlds15");
BAUWELT15 = config.getString("bauwelt15");
EVENT_MODE = config.getBoolean("eventmode"); EVENT_MODE = config.getBoolean("eventmode");
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1])); Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers")); PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
Persistent.setChatPrefix(CHAT_PREFIX); Persistent.setChatPrefix(CHAT_PREFIX);
Persistent.setLobbyServer(LOBBY_SERVER); Persistent.setLobbyServer(LOBBY_SERVER);
if (config.contains("discord")) {
SteamwarDiscordBotConfig.loadConfig(config.getSection("discord"));
}
final Configuration servers = config.getSection("servers"); final Configuration servers = config.getSection("servers");
for(final String serverName : servers.getKeys()){ for(final String serverName : servers.getKeys()){
final Configuration server = servers.getSection(serverName); final Configuration server = servers.getSection(serverName);
@ -326,6 +319,15 @@ public class BungeeCore extends Plugin {
ModLoaderBlocker.addServer(serverName); ModLoaderBlocker.addServer(serverName);
} }
} }
File discordFile = new File(System.getProperty("user.home"), "discord.yml");
if(discordFile.exists()) {
try {
SteamwarDiscordBotConfig.loadConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(discordFile));
} catch (IOException e) {
get().getLogger().log(Level.SEVERE, "Could not load discord bot configuration", e);
}
}
} }
private static void setInstance(BungeeCore core){ private static void setInstance(BungeeCore core){

Datei anzeigen

@ -90,6 +90,7 @@ public class ErrorLogger extends Handler {
contains.add("No client connected for pending server"); contains.add("No client connected for pending server");
contains.add("Error occurred processing connection for"); contains.add("Error occurred processing connection for");
contains.add("Server is online mode!"); contains.add("Server is online mode!");
contains.add(" took ");
ignoreContains = Collections.unmodifiableList(contains); ignoreContains = Collections.unmodifiableList(contains);
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.Tutorial; import de.steamwar.bungeecore.sql.Tutorial;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.File; import java.io.File;
@ -17,16 +16,17 @@ import java.util.stream.Collectors;
public class ServerStarter { public class ServerStarter {
private static final boolean MAIN_SERVER = ProxyServer.getInstance().getConfig().getListeners().stream().anyMatch(info -> ((InetSocketAddress) info.getSocketAddress()).getPort() == 25565); private static final Portrange BAU_PORTS = BungeeCore.MAIN_SERVER ? new Portrange(10100, 20000) : new Portrange(2100, 2200);
private static final Portrange BAU_PORTS = MAIN_SERVER ? new Portrange(10100, 20000) : new Portrange(2100, 2200); private static final Portrange ARENA_PORTS = BungeeCore.MAIN_SERVER ? new Portrange(3000, 3100) : (BungeeCore.EVENT_MODE ? new Portrange(4000, 5000) : BAU_PORTS);
private static final Portrange ARENA_PORTS = MAIN_SERVER ? new Portrange(3000, 3100) : (BungeeCore.EVENT_MODE ? new Portrange(4000, 5000) : BAU_PORTS);
private static final String BACKBONE = "/home/minecraft/"; private static final String SERVER_PATH = "/servers/";
private static final String SERVER_PATH = BACKBONE + "server/"; private static final String USER_HOME = System.getProperty("user.home") + "/";
private static final String EVENT_PATH = BACKBONE + "event/"; private static final String EVENT_PATH = USER_HOME + "event/";
public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/"; public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/";
public static final String TUTORIAL_PATH = BACKBONE + "tutorials/"; public static final String TUTORIAL_PATH = USER_HOME + "tutorials/";
public static final String WORLDS19_PATH = BACKBONE + "userworlds19/"; public static final String WORLDS12_PATH = USER_HOME + "userworlds/";
public static final String WORLDS15_PATH = USER_HOME + "userworlds15/";
public static final String WORLDS19_PATH = USER_HOME + "userworlds19/";
public static final String BUILDER15_PATH = BACKBONE + "builder15/"; public static final String BUILDER15_PATH = BACKBONE + "builder15/";
public static final String BUILDER19_PATH = BACKBONE + "builder19/"; public static final String BUILDER19_PATH = BACKBONE + "builder19/";
@ -122,7 +122,7 @@ public class ServerStarter {
public ServerStarter build19(UUID owner) { public ServerStarter build19(UUID owner) {
directory = new File(SERVER_PATH, "Bau19"); directory = new File(SERVER_PATH, "Bau19");
serverJar = "paper-1.19.jar"; serverJar = "paper-1.19.2.jar";
worldDir = WORLDS19_PATH; worldDir = WORLDS19_PATH;
worldName = String.valueOf(SteamwarUser.get(owner).getId()); worldName = String.valueOf(SteamwarUser.get(owner).getId());
buildWithWorld(owner, new File(directory, "Bauwelt").getPath()); buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
@ -131,19 +131,19 @@ public class ServerStarter {
public ServerStarter build15(UUID owner) { public ServerStarter build15(UUID owner) {
directory = new File(SERVER_PATH, "Bau15"); directory = new File(SERVER_PATH, "Bau15");
worldDir = BungeeCore.USERWORLDS15; worldDir = WORLDS15_PATH;
worldName = String.valueOf(SteamwarUser.get(owner).getId()); worldName = String.valueOf(SteamwarUser.get(owner).getId());
buildWithWorld(owner, BungeeCore.BAUWELT15); buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
return this; return this;
} }
public ServerStarter build12(UUID owner) { public ServerStarter build12(UUID owner) {
directory = new File(SERVER_PATH, "UserBau"); directory = new File(SERVER_PATH, "Bau12");
serverJar = "spigot-1.12.2.jar"; serverJar = "spigot-1.12.2.jar";
xmx = "256M"; xmx = "256M";
worldDir = BungeeCore.WORLD_FOLDER; worldDir = WORLDS12_PATH;
worldName = owner.toString(); worldName = owner.toString();
buildWithWorld(owner, BungeeCore.BAUWELT_PROTOTYP); buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
return this; return this;
} }

Datei anzeigen

@ -19,33 +19,53 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.Subserver;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class ArenaCommand extends BasicCommand { import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
public class ArenaCommand extends SWCommand {
public ArenaCommand() { public ArenaCommand() {
super("arena", null); super("arena");
}
@Register
public void arenaJoin(ProxiedPlayer player, Subserver server) {
TpCommand.teleport(player, server.getServer());
}
@ClassMapper(value = Subserver.class, local = true)
public TypeMapper<Subserver> serverInfoTypeMapper() {
return new TypeMapper<Subserver>() {
@Override
public Subserver map(CommandSender commandSender, String[] previousArguments, String s) {
return Subserver.getSubserver(ProxyServer.getInstance().getServerInfo(s));
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public boolean validate(CommandSender sender, Subserver value, MessageSender messageSender) {
if(!(sender instanceof ProxiedPlayer)) if (value == null || value.getType() != Servertype.ARENA) {
return; messageSender.send("ARENA_NOT_FOUND");
ProxiedPlayer player = (ProxiedPlayer) sender; return false;
}
ServerInfo server = ProxyServer.getInstance().getServerInfo(String.join(" ", args)); return true;
Subserver subserver = Subserver.getSubserver(server);
if(server == null || subserver == null || subserver.getType() != Servertype.ARENA) {
Message.send("ARENA_NOT_FOUND", player);
return;
} }
TpCommand.teleport(player, server); @Override
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
List<Subserver> subserverList = Subserver.getServerList();
synchronized (subserverList) {
return subserverList.stream().filter(subserver -> subserver.getType() == Servertype.ARENA).map(subserver -> subserver.getServer().getName()).collect(Collectors.toList());
}
}
};
} }
} }

Datei anzeigen

@ -139,7 +139,9 @@ public class BauCommand extends BasicCommand {
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run19, Runnable run15, Runnable run12, Runnable runElse) { private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run19, Runnable run15, Runnable run12, Runnable runElse) {
if(args.length <= pos) { if(args.length <= pos) {
int version = p.getPendingConnection().getVersion(); int version = p.getPendingConnection().getVersion();
if(version > 340) { // Version > 1.12.2 if(version > 578) { // Version > 1.15.2
run19.run();
} else if(version > 340) { // Version > 1.12.2
run15.run(); run15.run();
} else { } else {
run12.run(); run12.run();
@ -150,16 +152,14 @@ public class BauCommand extends BasicCommand {
switch (args[pos].toLowerCase()) { switch (args[pos].toLowerCase()) {
case "19": case "19":
case "1.19": case "1.19":
case "18": case "mwg":
case "1.18": case "miniwargear":
run19.run(); run19.run();
break; break;
case "ws": case "ws":
case "warship": case "warship":
case "as": case "as":
case "airship": case "airship":
case "mwg":
case "miniwargear":
case "wg": case "wg":
case "wargear": case "wargear":
case "15": case "15":
@ -236,8 +236,8 @@ public class BauCommand extends BasicCommand {
SteamwarUser user = SteamwarUser.get(p.getUniqueId()); SteamwarUser user = SteamwarUser.get(p.getUniqueId());
versionSelector(p, args, 1, versionSelector(p, args, 1,
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS12_PATH + p.getUniqueId().toString())),
() -> HelpCommand.sendBauHelp(ChatSender.of(p))); () -> HelpCommand.sendBauHelp(ChatSender.of(p)));
} }
@ -246,9 +246,10 @@ public class BauCommand extends BasicCommand {
inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click -> inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click ->
inventory.close() inventory.close()
); );
inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> {
worldDeletion.run() worldDeletion.run();
); inventory.close();
});
inventory.open(); inventory.open();
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.*; import de.steamwar.command.*;
@ -42,7 +43,7 @@ public class DevCommand extends SWCommand {
} }
@Register @Register
public void simpleCommand(@Guard ProxiedPlayer player) { public void simpleCommand(@Validator ProxiedPlayer player) {
updateDevServers(); updateDevServers();
ChatSender sender = ChatSender.of(player); ChatSender sender = ChatSender.of(player);
if (devServers.isEmpty()) { if (devServers.isEmpty()) {
@ -63,7 +64,7 @@ public class DevCommand extends SWCommand {
} }
@Register @Register
public void selectedCommand(@Guard ProxiedPlayer player, @Mapper("dev") String name) { public void selectedCommand(@Validator ProxiedPlayer player, @Mapper("dev") String name) {
updateDevServers(); updateDevServers();
ChatSender sender = ChatSender.of(player); ChatSender sender = ChatSender.of(player);
ServerInfo info = devServers.get(name.toLowerCase()); ServerInfo info = devServers.get(name.toLowerCase());
@ -75,20 +76,16 @@ public class DevCommand extends SWCommand {
player.connect(info); player.connect(info);
} }
@ClassGuard(value = ProxiedPlayer.class, local = true) @ClassValidator(value = ProxiedPlayer.class, local = true)
public GuardChecker punishmentGuardChecker() { public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
return (commandSender, guardCheckType, previousArguments, s) -> { return (sender, value, messageSender) -> {
ChatSender sender = ChatSender.of(commandSender); SteamwarUser user = SteamwarUser.get(value);
if (guardCheckType == GuardCheckType.COMMAND) { if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoDevServer)) { Message message = user.punishmentMessage(Punishment.PunishmentType.NoDevServer);
return GuardResult.DENIED; messageSender.send(message.getFormat(), message.getParams());
return false;
} }
} else { return true;
if (sender.user().isPunished(Punishment.PunishmentType.NoDevServer)) {
return GuardResult.DENIED;
}
}
return GuardResult.ALLOWED;
}; };
} }

Datei anzeigen

@ -36,17 +36,17 @@ public class HelpCommand extends BasicCommand {
if (args.length < 1) { if (args.length < 1) {
printPage(sender, ClickEvent.Action.RUN_COMMAND, printPage(sender, ClickEvent.Action.RUN_COMMAND,
"HELP_LOBBY", "/l", "HELP_LOBBY", "/l",
"HELP_BAU", "/bau", "HELP_BAU", "/build",
"HELP_BAUSERVER", "/help bau", "HELP_BAUSERVER", "/help build",
"HELP_FIGHT", "/fight", "HELP_FIGHT", "/fight",
"HELP_CHALLENGE", "/challenge", "HELP_CHALLENGE", "/challenge",
"HELP_HISTORIC", "/historic", "HELP_HISTORIC", "/historic",
"HELP_TEAM", "/team", "HELP_TEAM", "/team",
"HELP_JOIN", "/join", "HELP_JOIN", "/join",
"HELP_LOCAL", "/local"); "HELP_LOCAL", "/local");
}else if (args[0].equalsIgnoreCase("bauserver")) { }else if (args[0].equalsIgnoreCase("buildserver")) {
sendBauHelp(sender); sendBauHelp(sender);
}else if (args[0].equalsIgnoreCase("bau")) { }else if (args[0].equalsIgnoreCase("build")) {
bauHelpGroup(sender, args); bauHelpGroup(sender, args);
} }
} }
@ -86,22 +86,22 @@ public class HelpCommand extends BasicCommand {
private static void sendBauHelpGroup(ChatSender sender) { private static void sendBauHelpGroup(ChatSender sender) {
printPage(sender, ClickEvent.Action.RUN_COMMAND, printPage(sender, ClickEvent.Action.RUN_COMMAND,
"HELP_BAU_GROUP_ADMIN", "/help bau admin", "HELP_BAU_GROUP_ADMIN", "/help build admin",
"HELP_BAU_GROUP_WORLD", "/help bau world", "HELP_BAU_GROUP_WORLD", "/help build world",
"HELP_BAU_GROUP_PLAYER", "/help bau player", "HELP_BAU_GROUP_PLAYER", "/help build player",
"HELP_BAU_GROUP_WE", "/help bau we", "HELP_BAU_GROUP_WE", "/help build we",
"HELP_BAU_GROUP_OTHER", "/help bau other"); "HELP_BAU_GROUP_OTHER", "/help build other");
} }
static void sendBauHelp(ChatSender sender) { static void sendBauHelp(ChatSender sender) {
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND, printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
"HELP_BAU_TP", "/bau tp ", "HELP_BAU_TP", "/build tp ",
"HELP_BAU_ADDMEMBER", "/bau addmember ", "HELP_BAU_ADDMEMBER", "/build addmember ",
"HELP_BAU_DELMEMBER", "/bau delmember ", "HELP_BAU_DELMEMBER", "/build delmember ",
"HELP_BAU_TOGGLEWE", "/bau togglewe ", "HELP_BAU_TOGGLEWE", "/build togglewe ",
"HELP_BAU_TOGGLEWORLD", "/bau toggleworld ", "HELP_BAU_TOGGLEWORLD", "/build toggleworld ",
"HELP_BAU_DELETE", "/bau delete ", "HELP_BAU_DELETE", "/build delete ",
"HELP_BAU_TESTARENA", "/bau testarena "); "HELP_BAU_TESTARENA", "/build testarena ");
} }
private static void printPage(ChatSender sender, ClickEvent.Action action, String... args) { private static void printPage(ChatSender sender, ClickEvent.Action action, String... args) {

Datei anzeigen

@ -23,11 +23,8 @@ import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.listeners.PollSystem; import de.steamwar.bungeecore.listeners.PollSystem;
import de.steamwar.bungeecore.sql.PollAnswer; import de.steamwar.bungeecore.sql.PollAnswer;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; import de.steamwar.command.TypeValidator;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class PollCommand extends SWCommand { public class PollCommand extends SWCommand {
@ -37,12 +34,12 @@ public class PollCommand extends SWCommand {
} }
@Register @Register
public void genericCommand(@Guard ProxiedPlayer player) { public void genericCommand(ProxiedPlayer player) {
PollSystem.sendPoll(player); PollSystem.sendPoll(player);
} }
@Register(noTabComplete = true) @Register(noTabComplete = true)
public void answerPoll(@Guard ProxiedPlayer player, String answerString) { public void answerPoll(@Validator ProxiedPlayer player, String answerString) {
int answer; int answer;
try { try {
answer = Integer.parseUnsignedInt(answerString); answer = Integer.parseUnsignedInt(answerString);
@ -62,16 +59,14 @@ public class PollCommand extends SWCommand {
pollAnswer.setAnswer(answer); pollAnswer.setAnswer(answer);
} }
@ClassGuard(value = ProxiedPlayer.class, local = true) @ClassValidator(value = ProxiedPlayer.class, local = true)
public GuardChecker noPoll() { public TypeValidator<ProxiedPlayer> noPoll() {
return (commandSender, guardCheckType, previousArguments, s) -> { return (sender, value, messageSender) -> {
if(PollSystem.noCurrentPoll()){ if(PollSystem.noCurrentPoll()){
if (guardCheckType == GuardCheckType.COMMAND) { messageSender.send("POLL_NO_POLL");
Message.send("POLL_NO_POLL", commandSender); return false;
} }
return GuardResult.DENIED; return true;
}
return GuardResult.ALLOWED;
}; };
} }
} }

Datei anzeigen

@ -22,10 +22,8 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.listeners.PollSystem; import de.steamwar.bungeecore.listeners.PollSystem;
import de.steamwar.bungeecore.sql.PollAnswer; import de.steamwar.bungeecore.sql.PollAnswer;
import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Map; import java.util.Map;
@ -37,7 +35,7 @@ public class PollresultCommand extends SWCommand {
} }
@Register @Register
public void genericCommand(@Guard ProxiedPlayer player) { public void genericCommand(@Validator ProxiedPlayer player) {
Map<String, Integer> voted = PollAnswer.getCurrentResults(); Map<String, Integer> voted = PollAnswer.getCurrentResults();
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion()); Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion());
for (Map.Entry<String, Integer> e: voted.entrySet()) { for (Map.Entry<String, Integer> e: voted.entrySet()) {
@ -45,16 +43,14 @@ public class PollresultCommand extends SWCommand {
} }
} }
@ClassGuard(value = ProxiedPlayer.class, local = true) @ClassValidator(value = ProxiedPlayer.class, local = true)
public GuardChecker noPoll() { public TypeValidator<ProxiedPlayer> noPoll() {
return (commandSender, guardCheckType, previousArguments, s) -> { return (sender, value, messageSender) -> {
if (PollSystem.noCurrentPoll()) { if (PollSystem.noCurrentPoll()) {
if (guardCheckType == GuardCheckType.COMMAND) { messageSender.send("POLL_NO_POLL");
Message.send("POLL_NO_POLL", commandSender); return false;
} }
return GuardResult.DENIED; return true;
}
return GuardResult.ALLOWED;
}; };
} }
} }

Datei anzeigen

@ -21,13 +21,12 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class RegelnCommand extends SWCommand { public class RegelnCommand extends SWCommand {
public RegelnCommand() { public RegelnCommand() {
super("regeln"); super("regeln", null, "rules");
} }
@Register @Register

Datei anzeigen

@ -56,14 +56,10 @@ public class TpCommand extends BasicCommand {
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo()); boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
//Give control of teleport command to server //Give control of teleport command to server
if (server == player.getServer().getInfo() || onTeamServer) { if (server == player.getServer().getInfo() || onTeamServer || server == null) {
Chat19.chat(player, "/tp " + String.join(" ", args)); Chat19.chat(player, "/tp " + String.join(" ", args));
return; return;
} }
if(server == null) {
sender.system("JOINME_PLAYER_OFFLINE");
return;
}
teleport(player, server); teleport(player, server);
} }

Datei anzeigen

@ -26,9 +26,8 @@ import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.bungeecore.inventory.SWStreamInv; import de.steamwar.bungeecore.inventory.SWStreamInv;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Tutorial; import de.steamwar.bungeecore.sql.Tutorial;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -78,22 +77,14 @@ public class TutorialCommand extends SWCommand {
} }
@Register("unreleased") @Register("unreleased")
public void unreleased(@Guard("unreleased") ProxiedPlayer player) { public void unreleased(@Validator("unreleased") ProxiedPlayer player) {
openInventory(player, false, false); openInventory(player, false, false);
} }
@Guard("unreleased") @Validator("unreleased")
public GuardChecker unreleasedChecker() { public TypeValidator<ProxiedPlayer> unreleasedChecker() {
return (commandSender, guardCheckType, previousArguments, s) -> { return (sender, value, messageSender) -> {
if (commandSender instanceof ProxiedPlayer) { return (SteamwarUser.get((value).getUniqueId()).getUserGroup().isTeamGroup());
if (SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup().isTeamGroup()) {
return GuardResult.ALLOWED;
} else {
return GuardResult.DENIED_WITH_HELP;
}
} else {
return GuardResult.ALLOWED;
}
}; };
} }

Datei anzeigen

@ -19,58 +19,45 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SWException;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
public class WebregisterCommand extends SWCommand { public class WebpasswordCommand extends SWCommand {
public WebregisterCommand() { public WebpasswordCommand() {
super("webregister", null, "web", "webpw"); super("webpassword", null, "webpw", "web");
} }
@Register(description = "WEB_USAGE") @Register(description = "WEB_USAGE")
public void genericCommand(ProxiedPlayer player, String email) { public void genericCommand(ProxiedPlayer player, String password) {
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), email); if(password.length() < 8) {
ChatSender.of(player).system("WEB_PASSWORD_LENGTH");
return;
}
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), password);
pb.redirectErrorStream(true); pb.redirectErrorStream(true);
try { try {
Process regProcess = pb.start(); Process regProcess = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(regProcess.getInputStream())); BufferedReader reader = new BufferedReader(new InputStreamReader(regProcess.getInputStream()));
String errorLine; String errorLine;
boolean error = false; if((errorLine = reader.readLine()) != null) {
while((errorLine = reader.readLine()) != null){ if ("updated".equals(errorLine)) {
switch(errorLine){ ChatSender.of(player).system("WEB_UPDATED");
case "username_exists":
Message.send("WEB_ALREADY", player);
break;
case "email_exists":
Message.send("WEB_ALREADY_EMAIL", player);
// SWException.log("Bungee", "Duplicate E-Mail", player.getName() + " " + args[0]);
break;
case "invalid_email":
Message.send("WEB_NOT_EMAIL", player);
break;
case "email_updated":
Message.send("WEB_EMAIL_REFRESH", player);
break;
default:
Message.send("WEB_INTERNAL_ERROR", player);
SWException.log("Bungee", "Unknown Wordpress User Creation Error", errorLine);
}
error = true;
}
if(error)
return; return;
} else {
throw new SecurityException("Could not create webaccount " + errorLine);
}
}
Message.send("WEB_EMAIL_SEND", player); ChatSender.of(player).system("WEB_CREATED");
} catch (IOException e) { } catch (IOException e) {
Message.send("WEB_INTERNAL_ERROR", player);
throw new SecurityException("Could not create webaccount", e); throw new SecurityException("Could not create webaccount", e);
} }
} }

Datei anzeigen

@ -44,7 +44,7 @@ public class WhoisCommand extends SWCommand {
} }
@Register(description = "WHOIS_USAGE") @Register(description = "WHOIS_USAGE")
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue({"-all", "-a", ""}) String displayAll) { public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue(value = {"", "-all", "-a"}, allowISE = true) boolean all) {
SteamwarUser user = SteamwarUser.get(target); SteamwarUser user = SteamwarUser.get(target);
if (user == null) { if (user == null) {
try { try {
@ -64,12 +64,10 @@ public class WhoisCommand extends SWCommand {
if (user == null) { if (user == null) {
Message.send("UNKNOWN_PLAYER", player); Message.send("UNKNOWN_PLAYER", player);
return; } else {
}
boolean all = displayAll.contains("-");
sendUserinfo(player, user, all); sendUserinfo(player, user, all);
} }
}
@Mapper(value = "player", local = true) @Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() { public TypeMapper<String> playerTypeMapper() {

Datei anzeigen

@ -56,19 +56,15 @@ public class ChatListener extends BasicListener {
ProxiedPlayer player = (ProxiedPlayer) e.getSender(); ProxiedPlayer player = (ProxiedPlayer) e.getSender();
String message = e.getMessage(); String message = e.getMessage();
if (message.contains("jndi:ldap")) {
e.setCancelled(true); e.setCancelled(true);
if (message.contains("jndi:ldap")) {
SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0); SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
return; return;
} }
message = sanitize7(message); if (isCommand(player, message))
return;
if (message.startsWith("/")) {
if(filteredCommand((CommandSender) e.getSender(), message))
e.setCancelled(true);
} else {
e.setCancelled(true);
Subserver subserver = Subserver.getSubserver(player); Subserver subserver = Subserver.getSubserver(player);
if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) { if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) {
@ -79,30 +75,45 @@ public class ChatListener extends BasicListener {
sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", null, message); sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", null, message);
} }
} }
private static boolean isCommand(ProxiedPlayer player, String message) {
String command = message.substring(1);
boolean isCommand = message.startsWith("/") || (message.startsWith("7") && command.split(" ", 2)[0].matches("[7/]?[A-Za-z]+"));
if(isCommand && !ProxyServer.getInstance().getPluginManager().dispatchCommand(player, command)) {
if(command.startsWith("7"))
command = "/" + command.substring(1);
message = "/" + command;
if(filteredCommand(player, message))
return true;
Chat19.chat(player, message);
}
return isCommand;
} }
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) { public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
String finalMessage = modifyFilter(sender, message);
if(finalMessage == null)
return;
SteamwarUser user = sender.user(); SteamwarUser user = sender.user();
final String coloredMessage = (user.getUserGroup() != UserGroup.Member || coloredTeams.contains(user.getTeam())) ? ChatColor.translateAlternateColorCodes('&', message) : message;
if(chatFilter(sender, coloredMessage))
return;
AtomicBoolean noReceiver = new AtomicBoolean(true); AtomicBoolean noReceiver = new AtomicBoolean(true);
receivers.filter(ChatSender::chatShown).forEach(player -> { receivers.filter(ChatSender::chatShown).forEach(player -> {
if(sender.user().getId() != player.user().getId()) if(sender.user().getId() != player.user().getId())
noReceiver.set(false); noReceiver.set(false);
chatToReciever(player, msgReceiver, user, format, finalMessage); chatToReciever(player, msgReceiver, user, format, coloredMessage);
}); });
chatToReciever(ChatSender.console(), msgReceiver, user, format, finalMessage); chatToReciever(ChatSender.console(), msgReceiver, user, format, coloredMessage);
if(format.equals("CHAT_GLOBAL")) { if(format.equals("CHAT_GLOBAL")) {
if (SteamwarDiscordBot.instance() != null) if (SteamwarDiscordBot.instance() != null)
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), msgReceiver, user, format, finalMessage); chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), msgReceiver, user, format, coloredMessage);
} else if (format.equals("CHAT_SERVERTEAM")) { } else if (format.equals("CHAT_SERVERTEAM")) {
if (SteamwarDiscordBot.instance() != null) if (SteamwarDiscordBot.instance() != null)
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), msgReceiver, user, format, finalMessage); chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), msgReceiver, user, format, coloredMessage);
} else if (noReceiver.get()) { } else if (noReceiver.get()) {
sender.system("CHAT_NO_RECEIVER"); sender.system("CHAT_NO_RECEIVER");
} }
@ -115,44 +126,42 @@ public class ChatListener extends BasicListener {
return; return;
} }
message = sanitize7(message);
if(ChatListener.filteredCommand(player, message)) if(ChatListener.filteredCommand(player, message))
return; return;
if(!message.startsWith("/")) {
message = modifyFilter(sender, message); if(!message.startsWith("/") && chatFilter(sender, message))
if(message == null)
return; return;
}
Chat19.chat(player, message); Chat19.chat(player, message);
} }
private static String modifyFilter(ChatSender sender, String message) { private static boolean chatFilter(ChatSender sender, String message) {
if(!sender.chatShown()) { if(!sender.chatShown()) {
sender.system("CHAT_RECEIVE"); sender.system("CHAT_RECEIVE");
return null; return true;
}
if(message.replace("§[a-f0-9klmno]", "").trim().isEmpty()) {
sender.system("CHAT_EMPTY");
return true;
} }
SteamwarUser user = sender.user(); SteamwarUser user = sender.user();
UserGroup group = user.getUserGroup(); UserGroup group = user.getUserGroup();
if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){ if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
sender.system("CHAT_NO_LINKS"); sender.system("CHAT_NO_LINKS");
return null; return true;
} }
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
return null; return true;
if(group != UserGroup.Member || coloredTeams.contains(user.getTeam()))
message = ChatColor.translateAlternateColorCodes('&', message);
if (message.contains("LIXFEL")) if (message.contains("LIXFEL"))
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15); specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
if (message.contains("YOYONOW")) if (message.contains("YOYONOW"))
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12); specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
return message; return false;
} }
private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) { private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) {
@ -168,17 +177,6 @@ public class ChatListener extends BasicListener {
group.getChatColorCode())); group.getChatColorCode()));
} }
private static String sanitize7(String message) {
String begin = message.split(" ", 2)[0];
if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){
message = "/" + message.substring(1);
}else if((begin.startsWith("77") || begin.startsWith("7/") || begin.startsWith("/7")) && begin.substring(2).matches("[A-Za-z]+")){
message = "//" + message.substring(2);
}
return message;
}
private static boolean filteredCommand(CommandSender sender, String message) { private static boolean filteredCommand(CommandSender sender, String message) {
String command = message.split(" ", 2)[0]; String command = message.split(" ", 2)[0];
if(command.startsWith("/") && command.contains(":")) { if(command.startsWith("/") && command.contains(":")) {

Datei anzeigen

@ -105,6 +105,9 @@ public class ConnectionListener extends BasicListener {
@EventHandler @EventHandler
public void onServerKickEvent(ServerKickEvent ev) public void onServerKickEvent(ServerKickEvent ev)
{ {
if(!ev.getPlayer().isConnected())
return;
ServerInfo kickedFrom; ServerInfo kickedFrom;
if (ev.getPlayer().getServer() != null){ if (ev.getPlayer().getServer() != null){

Datei anzeigen

@ -44,7 +44,7 @@ public class Statement implements AutoCloseable {
private static final String PASSWORD; private static final String PASSWORD;
static { static {
File file = new File(BungeeCore.get().getDataFolder(), "MySQL.yml"); File file = new File(System.getProperty("user.home"), "MySQL.yml");
Configuration config; Configuration config;
try { try {
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file); config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);

Datei anzeigen

@ -22,7 +22,7 @@ package de.steamwar.bungeecore.sql;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.commands.WebregisterCommand; import de.steamwar.bungeecore.commands.WebpasswordCommand;
import de.steamwar.bungeecore.listeners.ConnectionListener; import de.steamwar.bungeecore.listeners.ConnectionListener;
import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
@ -121,7 +121,7 @@ public class SteamwarUser {
String userName = connection.getName(); String userName = connection.getName();
if (!user.userName.equals(userName)) { if (!user.userName.equals(userName)) {
updateName.update(userName, user.id); updateName.update(userName, user.id);
WebregisterCommand.changeUsername(user.userName, userName); WebpasswordCommand.changeUsername(user.userName, userName);
user.userName = userName; user.userName = userName;
} }
} else { } else {

Datei anzeigen

@ -62,7 +62,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
this.player = player; this.player = player;
this.viewer = ChatSender.of(player); this.viewer = ChatSender.of(player);
this.directTabItems = Storage.directTabItems.computeIfAbsent(player, p -> new HashMap<>()); this.directTabItems = Storage.directTabItems.computeIfAbsent(player, p -> new HashMap<>());
onServerSwitch(); injection();
} }
public void update(TablistPart global, int seconds) { public void update(TablistPart global, int seconds) {
@ -145,12 +145,17 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
} }
public void onServerSwitch() { public void onServerSwitch() {
connection = (ServerConnection) player.getServer(); injection();
synchronized (directTabItems) { synchronized (directTabItems) {
sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true); sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true);
directTabItems.clear(); directTabItems.clear();
npcs.clear(); npcs.clear();
} }
}
private void injection() {
connection = (ServerConnection) player.getServer();
if(connection != null) { if(connection != null) {
ChannelPipeline pipeline = connection.getCh().getHandle().pipeline(); ChannelPipeline pipeline = connection.getCh().getHandle().pipeline();
@ -205,6 +210,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
for (PlayerListItem.Item item : list.getItems()) { for (PlayerListItem.Item item : list.getItems()) {
item.setPing(1); item.setPing(1);
item.setDisplayName(ComponentSerializer.toString(TextComponent.fromLegacyText(""))); item.setDisplayName(ComponentSerializer.toString(TextComponent.fromLegacyText("")));
item.setPublicKey(null);
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3) if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
item.setGamemode(1); item.setGamemode(1);

Datei anzeigen

@ -51,8 +51,10 @@ public class TablistManager extends BasicListener {
public TablistManager() { public TablistManager() {
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS); ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
synchronized (tablists) {
ProxyServer.getInstance().getPlayers().forEach(player -> tablists.put(player, new Tablist(player))); ProxyServer.getInstance().getPlayers().forEach(player -> tablists.put(player, new Tablist(player)));
} }
}
@EventHandler @EventHandler
public void onJoin(PostLoginEvent event) { public void onJoin(PostLoginEvent event) {

Datei anzeigen

@ -19,49 +19,26 @@
package de.steamwar.bungeecore.util; package de.steamwar.bungeecore.util;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.ServerConnection; import net.md_5.bungee.ServerConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.ChatChain;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.packet.ClientChat;
import net.md_5.bungee.protocol.packet.Chat; import net.md_5.bungee.protocol.packet.ClientCommand;
import java.time.Instant; import java.util.Collections;
public class Chat19 extends Chat { public class Chat19 {
private Chat19(){}
public static void chat(ProxiedPlayer p, String message) { public static void chat(ProxiedPlayer p, String message) {
if(p.getPendingConnection().getVersion() >= 759) { if(p.getPendingConnection().getVersion() >= 759) {
Chat19 packet = new Chat19(message); if(message.startsWith("/")) {
((ServerConnection) p.getServer()).getCh().write(new ClientCommand(message.substring(1), System.currentTimeMillis(), 0, Collections.emptyMap(), false, new ChatChain(Collections.emptyList(), null)));
ByteBuf buf = Unpooled.buffer(); } else {
writeVarInt(0x04, buf); ((ServerConnection) p.getServer()).getCh().write(new ClientChat(message, System.currentTimeMillis(), 0, new byte[0], false, new ChatChain(Collections.emptyList(), null)));
packet.write(buf, ProtocolConstants.Direction.TO_SERVER, p.getPendingConnection().getVersion()); }
((ServerConnection) p.getServer()).getCh().write(new PacketWrapper(packet, buf));
} else { } else {
p.chat(message); p.chat(message);
} }
} }
private final Instant timestamp = Instant.now();
private final long salt = 0L;
private final byte[] signature = new byte[0];
private final boolean signedPreview = false;
public Chat19 (String message) {
super(message);
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
if (direction == ProtocolConstants.Direction.TO_CLIENT || protocolVersion != 759)
throw new UnsupportedOperationException();
writeString(getMessage(), buf);
buf.writeLong(timestamp.toEpochMilli());
buf.writeLong(salt);
writeArray(signature, buf);
buf.writeBoolean(signedPreview);
}
} }

Datei anzeigen

@ -1,30 +0,0 @@
/*
* 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.command;
import net.md_5.bungee.api.CommandSender;
@FunctionalInterface
public interface GuardChecker extends AbstractGuardChecker<CommandSender> {
/**
* While guarding the first parameter of the command the parameter s of this method is {@code null}
*/
GuardResult guard(CommandSender commandSender, GuardCheckType guardCheckType, String[] previousArguments, String s);
}

Datei anzeigen

@ -149,7 +149,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
} }
if (args.length == 0 || atomicInteger.get() == commandList.size()) { if (args.length == 0 || atomicInteger.get() == commandList.size()) {
commandList.forEach(subCommand -> { commandList.forEach(subCommand -> {
if (subCommand.guardChecker == null || subCommand.guardChecker.guard(p, GuardCheckType.TAB_COMPLETE, new String[0], null) == GuardResult.ALLOWED) { if (subCommand.validator == null || subCommand.validator.validate(p, p, (s, args1) -> {})) {
send(chatSender, subCommand); send(chatSender, subCommand);
} }
}); });

Datei anzeigen

@ -20,7 +20,7 @@ DISABLED=§cCurrently disabled.
#ModLoader blocker #ModLoader blocker
MODLOADER_INSTALLED=§7You play with §e{0} §7client. Therefore you can't join arenas. MODLOADER_INSTALLED=§7You play with §e{0} §7client. Therefore you can't join arenas.
MODLOADER_INSTALLED_FABRIC=§7You play with §e{0} §7client. You can only join arenas with the SteamWar Modsender installed. MODLOADER_INSTALLED_FABRIC=§7You play with §e{0} §7client. You can join arenas only with the FabricModSender https://steamwar.de/downloads installed.
MODLOADER_DENIED=§cYou cannot join arenas with Fabric and LiteLoader. MODLOADER_DENIED=§cYou cannot join arenas with Fabric and LiteLoader.
#Help command #Help command
@ -498,13 +498,10 @@ UNIGNORE_NOT_IGNORED=§cYou are not ignoring this player.
UNIGNORE_UNIGNORED=§7You ignored §e{0}§8. UNIGNORE_UNIGNORED=§7You ignored §e{0}§8.
#WebregisterCommand #WebregisterCommand
WEB_USAGE=§8/§7webregister §8[§eE-Mail§8] WEB_USAGE=§8/§7webpassword §8[§epassword§8]
WEB_ALREADY=§cYou already have a webaccount. WEB_UPDATED=§7Your password was updated.
WEB_ALREADY_EMAIL=§cYou already used this E-Mail address on another account... WEB_CREATED=§7Your webaccount was created.
WEB_NOT_EMAIL=§c[E-Mail], not [free text]! WEB_PASSWORD_LENGTH=§cYour password is shorter than 8 characters.
WEB_EMAIL_REFRESH=§aYour E-Mail was updated.
WEB_INTERNAL_ERROR=§cAn internal error occurred, please contact a developer.
WEB_EMAIL_SEND=§aAn E-Mail to reset your password has been sent.
#ChatListener #ChatListener
CHAT_LIXFEL_ACTION_BAR=§4§lTechnical problems? CHAT_LIXFEL_ACTION_BAR=§4§lTechnical problems?
@ -521,6 +518,7 @@ CHAT_RECEIVE=§cTo be able to send chat messages, you must also receive them!
CHAT_NO_LINKS=§cYou may not send links. CHAT_NO_LINKS=§cYou may not send links.
CHAT_BC_USAGE=§8/§7bc §8[§emessage§8] CHAT_BC_USAGE=§8/§7bc §8[§emessage§8]
CHAT_NO_RECEIVER=§cNobody receives your message CHAT_NO_RECEIVER=§cNobody receives your message
CHAT_EMPTY=§cDon't write meaningless empty messages.
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2} CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2} CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}

Datei anzeigen

@ -16,7 +16,7 @@ DISABLED=§cDerzeit deaktiviert.
#ModLoader blocker #ModLoader blocker
MODLOADER_INSTALLED=§7Du spielst mit §e{0} §7Client. Daher kannst du keinen Arenen beitreten. MODLOADER_INSTALLED=§7Du spielst mit §e{0} §7Client. Daher kannst du keinen Arenen beitreten.
MODLOADER_INSTALLED_FABRIC=§7Du spielst mit §e{0} §7Client. Nur mit dem SteamWarModSender kannst du Arenen beitreten. MODLOADER_INSTALLED_FABRIC=§7Du spielst mit §e{0} §7Client. Nur mit dem FabricModSender https://steamwar.de/downloads kannst du Arenen beitreten.
MODLOADER_DENIED=§cMit Fabric und LiteLoader kannst du keinen Arenen beitreten. MODLOADER_DENIED=§cMit Fabric und LiteLoader kannst du keinen Arenen beitreten.
#Help command #Help command
@ -477,13 +477,10 @@ UNIGNORE_NOT_IGNORED=§cDu ignorierst diesen Spieler nicht.
UNIGNORE_UNIGNORED=§7Du empfängst nun wieder Nachrichten von §e{0}§8. UNIGNORE_UNIGNORED=§7Du empfängst nun wieder Nachrichten von §e{0}§8.
#WebregisterCommand #WebregisterCommand
WEB_USAGE=§8/§7webregister §8[§eE-Mail§8] WEB_USAGE=§8/§7webpassword §8[§ePasswort§8]
WEB_ALREADY=§cDu hast bereits einen Webaccount. WEB_UPDATED=§7Dein Passwort wurde aktualisiert.
WEB_ALREADY_EMAIL=§cDie E-Mail hast du bereits für einen anderen Account verwendet... WEB_CREATED=§7Dein Webaccount wurde erstellt.
WEB_NOT_EMAIL=§c[E-Mail], nicht [Freitext]! WEB_PASSWORD_LENGTH=§cDein Passwort ist kürzer als 8 Zeichen.
WEB_EMAIL_REFRESH=§aDeine E-Mail-Adresse wurde aktualisiert.
WEB_INTERNAL_ERROR=§cEin interner Fehler ist aufgetreten, bitte wende dich an einen Developer.
WEB_EMAIL_SEND=§aEine E-Mail zum Setzen des Passworts wurde gesendet.
#ChatListener #ChatListener
CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme? CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme?
@ -500,6 +497,7 @@ CHAT_RECEIVE=§cUm Chatnachrichten versenden zu können, musst du auch welche em
CHAT_NO_LINKS=§cDu darfst keine Links versenden. CHAT_NO_LINKS=§cDu darfst keine Links versenden.
CHAT_BC_USAGE=§8/§7bc §8[§eNachricht§8] CHAT_BC_USAGE=§8/§7bc §8[§eNachricht§8]
CHAT_NO_RECEIVER=§cNiemand empfängt deine Nachricht CHAT_NO_RECEIVER=§cNiemand empfängt deine Nachricht
CHAT_EMPTY=§cSchreibe keine inhaltslosen Nachrichten.
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2} CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2} CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}