SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'master' into CommandArena

Dieser Commit ist enthalten in:
yoyosource 2022-07-17 20:34:19 +02:00
Commit 93757ff86e
59 geänderte Dateien mit 1258 neuen und 962 gelöschten Zeilen

3
.gitignore vendored
Datei anzeigen

@ -10,6 +10,3 @@ steamwar.properties
# IntelliJ IDEA # IntelliJ IDEA
.idea .idea
*.iml *.iml
# Other
lib

Datei anzeigen

@ -1,23 +0,0 @@
# Building
Building SteamWar.de software requires certain libraries,
which cannot be provided over traditional ways (like maven)
due to copyright issues with compiled Spigot packages.
For building these libraries have to be named in a lib
directory named like in the following list.
A subset of the following libraries is required to build this software
(this is the list for being able to build all SteamWar.de software):
- BungeeCord.jar https://ci.md-5.net/job/BungeeCord/
- BungeeTabListPlus.jar https://www.spigotmc.org/resources/bungeetablistplus.313/
- PersistentBungeeCore.jar https://steamwar.de/devlabs/SteamWar/PersistentBungeeCore
- ProtocolLib.jar https://www.spigotmc.org/resources/protocollib.1997/
- Spigot-1.8.jar https://hub.spigotmc.org/jenkins/job/BuildTools/ (1.8.9)
- Spigot-1.9.jar https://hub.spigotmc.org/jenkins/job/BuildTools/ (1.9.4)
- Spigot-1.10.jar https://hub.spigotmc.org/jenkins/job/BuildTools/ (1.10.2)
- Spigot-1.12.jar https://hub.spigotmc.org/jenkins/job/BuildTools/ (1.12.2)
- Spigot-1.14.jar https://hub.spigotmc.org/jenkins/job/BuildTools/ (1.14.4)
- Spigot-1.15.jar https://hub.spigotmc.org/jenkins/job/BuildTools/ (1.15.2)
- SpigotCore.jar https://steamwar.de/devlabs/SteamWar/SpigotCore
- WorldEdit-1.12.jar https://dev.bukkit.org/projects/worldedit/files (6.1.9)
- WorldEdit-1.15.jar https://dev.bukkit.org/projects/worldedit/files (newest)

@ -1 +1 @@
Subproject commit 8dbab5b132d2fd84db202d691fd1f817f91579d6 Subproject commit 21e77c55f023261d3a63d5c6200d28b2f6f6fc4c

Datei anzeigen

@ -18,9 +18,8 @@
*/ */
import org.apache.tools.ant.taskdefs.condition.Os
import java.util.function.BiConsumer import org.apache.tools.ant.taskdefs.condition.Os
plugins { plugins {
// Adding the base plugin fixes the following gradle warnings in IntelliJ: // Adding the base plugin fixes the following gradle warnings in IntelliJ:
@ -84,6 +83,10 @@ repositories {
maven { maven {
url 'https://m2.dv8tion.net/releases' url 'https://m2.dv8tion.net/releases'
} }
maven {
url = uri('https://steamwar.de/maven')
}
} }
dependencies { dependencies {
@ -92,9 +95,8 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
compileOnly files("${projectDir}/lib/BungeeCord.jar") compileOnly 'de.steamwar:waterfall:RELEASE'
compileOnly files("${projectDir}/lib/PersistentBungeeCore.jar") compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
compileOnly files("${projectDir}/lib/BungeeTabListPlus.jar")
implementation("net.dv8tion:JDA:4.3.0_299") { implementation("net.dv8tion:JDA:4.3.0_299") {
exclude module: 'opus-java' exclude module: 'opus-java'
} }

Datei anzeigen

@ -27,9 +27,12 @@ import de.steamwar.bungeecore.listeners.mods.*;
import de.steamwar.bungeecore.network.BungeeNetworkHandler; import de.steamwar.bungeecore.network.BungeeNetworkHandler;
import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.sql.*;
import de.steamwar.bungeecore.tablist.TablistManager;
import de.steamwar.command.SWCommandUtils; import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.SWTypeMapperCreator; import de.steamwar.command.SWTypeMapperCreator;
import de.steamwar.command.TabCompletionCache;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeMapper;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
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;
@ -68,6 +71,7 @@ public class BungeeCore extends Plugin {
public static final Map<String, String> commands = new HashMap<>(); public static final Map<String, String> commands = new HashMap<>();
private ErrorLogger errorLogger; private ErrorLogger errorLogger;
private TablistManager tablistManager;
@Override @Override
public void onEnable(){ public void onEnable(){
@ -82,6 +86,7 @@ public class BungeeCore extends Plugin {
return tabCompleter.apply(sender, s); return tabCompleter.apply(sender, s);
} }
}); });
BungeeCord.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS);
getProxy().registerChannel("sw:bridge"); getProxy().registerChannel("sw:bridge");
getProxy().registerChannel("fabricmodsender:mods"); getProxy().registerChannel("fabricmodsender:mods");
@ -175,7 +180,7 @@ public class BungeeCore extends Plugin {
new SessionManager(); new SessionManager();
new NetworkReceiver(); new NetworkReceiver();
BungeeNetworkHandler.register(); BungeeNetworkHandler.register();
new TablistManager(); tablistManager = new TablistManager();
new SettingsChangedListener(); new SettingsChangedListener();
getProxy().getScheduler().schedule(this, () -> { getProxy().getScheduler().schedule(this, () -> {
@ -203,6 +208,8 @@ public class BungeeCore extends Plugin {
} }
} }
if(tablistManager != null)
tablistManager.disable();
errorLogger.unregister(); errorLogger.unregister();
Statement.closeAll(); Statement.closeAll();
} }

Datei anzeigen

@ -21,49 +21,28 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
public class AlertCommand extends BasicCommand { public class AlertCommand extends SWCommand {
public AlertCommand() { public AlertCommand() {
super("alert", "bungeecore.alert", "broadcast", "bbc"); super("alert", "bungeecore.alert", "broadcast", "bbc");
} }
@Override @Register(description = "USAGE_ALERT")
public void execute(CommandSender sender, String[] args) { public void broadcast(CommandSender sender, @OptionalValue("") @StaticValue("-discord") String sendToDiscord, String... message) {
if(args.length == 0){ if (message.length == 0) {
Message.send("USAGE_ALERT", sender); ChatSender.of(sender).system(new Message("USAGE_ALERT"));
return; return;
} }
String s; String s = String.join(" ", message);
boolean discordAnnounce = false;
if (args[0].equals("-discord")) {
if (args.length == 1) {
Message.send("USAGE_ALERT", sender);
return;
}
discordAnnounce = true;
s = join(1, args);
} else {
s = join(0, args);
}
Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s)); Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s));
if (discordAnnounce && SteamwarDiscordBot.instance() != null) { if ("-discord".equals(sendToDiscord) && SteamwarDiscordBot.instance() != null) {
SteamwarDiscordBot.instance().getAnnouncementListener().announce(s); SteamwarDiscordBot.instance().getAnnouncementListener().announce(s);
} }
} }
private String join(int startIndex, String... strings) {
StringBuilder st = new StringBuilder();
for (int i = startIndex; i < strings.length; i++) {
if (i != startIndex) {
st.append(" ");
}
st.append(strings[i]);
}
return st.toString();
}
} }

Datei anzeigen

@ -25,6 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.server.BaumemberUpdatePacket; import de.steamwar.network.packets.server.BaumemberUpdatePacket;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
@ -60,7 +61,7 @@ public class BauCommand extends BasicCommand {
teleport(p, args); teleport(p, args);
break; break;
case "info": case "info":
p.chat("/bauinfo"); Chat19.chat(p, "/bauinfo");
break; break;
case "togglewe": case "togglewe":
togglewe(p, args); togglewe(p, args);

Datei anzeigen

@ -19,27 +19,22 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SWException; import de.steamwar.bungeecore.sql.SWException;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender; 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;
public class BugCommand extends BasicCommand { public class BugCommand extends SWCommand {
public BugCommand() { public BugCommand() {
super("bug", null); super("bug", null);
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void bugMessage(ProxiedPlayer player, String... message) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
String server = player.getServer().getInfo().getName(); String server = player.getServer().getInfo().getName();
String message = String.join(" ", args);
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SWException.log(server, message, player.getName() + " " + user.getId()); SWException.log(server, String.join(" ", message), player.getName() + " " + user.getId());
Message.send("BUG_MESSAGE", player); ChatSender.of(player).system("BUG_MESSAGE");
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.bungeecore.sql.CheckedSchematic;
import de.steamwar.bungeecore.sql.SchematicNode; import de.steamwar.bungeecore.sql.SchematicNode;
import de.steamwar.bungeecore.sql.SchematicType; import de.steamwar.bungeecore.sql.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
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;
@ -41,7 +42,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
public class CheckCommand extends BasicCommand { public class CheckCommand extends SWCommand {
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>(); private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
private static Map<SchematicType, List<String>> ranks = new HashMap<>(); private static Map<SchematicType, List<String>> ranks = new HashMap<>();
@ -77,55 +78,8 @@ public class CheckCommand extends BasicCommand {
Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size()); Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size());
} }
@Override @Register(value = "list", description = "CHECK_HELP_LIST")
public void execute(CommandSender sender, String[] args) { public void list(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){
help(sender);
return;
}
switch(args[0].toLowerCase()){
case "list":
list(player);
break;
case "schematic":
schematic(player, args[1]);
break;
case "next":
case "accept":
next(player, args);
break;
case "cancel":
abort(player);
break;
case "decline":
decline(player, args);
break;
default:
help(player);
}
}
public static List<SchematicNode> getSchemsToCheck(){
List<SchematicNode> schematicList = new LinkedList<>();
for (SchematicType type : SchematicType.values()) {
if (type.check())
schematicList.addAll(SchematicNode.getAllSchematicsOfType(type.toDB()));
}
return schematicList;
}
public static String getChecker(SchematicNode schematic) {
if (currentSchems.get(schematic.getId()) == null) return null;
return currentSchems.get(schematic.getId()).checker.getName();
}
private void list(ProxiedPlayer player) {
List<SchematicNode> schematicList = getSchemsToCheck(); List<SchematicNode> schematicList = getSchemsToCheck();
Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size()); Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size());
@ -153,7 +107,8 @@ public class CheckCommand extends BasicCommand {
} }
} }
private void schematic(ProxiedPlayer player, String schemID){ @Register(value = "schematic", noTabComplete = true)
public void schematic(ProxiedPlayer player, String schemID) {
if(isChecking(player)){ if(isChecking(player)){
Message.send("CHECK_SCHEMATIC_ALREADY_CHECKING", player); Message.send("CHECK_SCHEMATIC_ALREADY_CHECKING", player);
return; return;
@ -171,6 +126,57 @@ public class CheckCommand extends BasicCommand {
new CheckSession(player, schem); new CheckSession(player, schem);
} }
@Register(value = "cancel", description = "CHECK_HELP_CANCEL")
@Register("abort")
public void abortCommand(ProxiedPlayer player) {
abort(player);
}
public static void abort(ProxiedPlayer player) {
if(notChecking(player))
return;
Message.send("CHECK_ABORT", player);
currentCheckers.get(player.getUniqueId()).abort();
}
@Register(value = "next", description = "CHECK_HELP_NEXT")
public void next(ProxiedPlayer player) {
next(player, new String[0]);
}
@Register(value = "accept")
public void accept(ProxiedPlayer player, @OptionalValue("") String rank) {
if (rank.equals("")) {
next(player, new String[0]);
} else {
next(player, new String[]{rank});
}
}
@Register(value = "decline", description = "CHECK_HELP_DECLINE")
public void decline(ProxiedPlayer player, String... message) {
if(notChecking(player))
return;
currentCheckers.get(player.getUniqueId()).decline(String.join(" ", message));
}
public static List<SchematicNode> getSchemsToCheck(){
List<SchematicNode> schematicList = new LinkedList<>();
for (SchematicType type : SchematicType.values()) {
if (type.check())
schematicList.addAll(SchematicNode.getAllSchematicsOfType(type.toDB()));
}
return schematicList;
}
public static String getChecker(SchematicNode schematic) {
if (currentSchems.get(schematic.getId()) == null) return null;
return currentSchems.get(schematic.getId()).checker.getName();
}
private static boolean notChecking(ProxiedPlayer player){ private static boolean notChecking(ProxiedPlayer player){
if(!isChecking(player)){ if(!isChecking(player)){
Message.send("CHECK_NOT_CHECKING", player); Message.send("CHECK_NOT_CHECKING", player);
@ -184,9 +190,9 @@ public class CheckCommand extends BasicCommand {
return; return;
int rank = 0; int rank = 0;
if(args.length > 1){ if(args.length > 0){
try{ try{
rank = Integer.parseInt(args[1]); rank = Integer.parseInt(args[0]);
}catch(NumberFormatException e){ }catch(NumberFormatException e){
Message.send("CHECK_INVALID_RANK", player); Message.send("CHECK_INVALID_RANK", player);
return; return;
@ -196,37 +202,6 @@ public class CheckCommand extends BasicCommand {
currentCheckers.get(player.getUniqueId()).next(rank); currentCheckers.get(player.getUniqueId()).next(rank);
} }
public static void abort(ProxiedPlayer player){
if(notChecking(player))
return;
Message.send("CHECK_ABORT", player);
currentCheckers.get(player.getUniqueId()).abort();
}
private void decline(ProxiedPlayer player, String[] args){
if(notChecking(player))
return;
if(args.length < 2) {
help(player);
return;
}
StringBuilder message = new StringBuilder();
for (int i = 1; i < args.length; i++)
message.append(args[i]).append(" ");
currentCheckers.get(player.getUniqueId()).decline(message.toString());
}
private void help(CommandSender sender){
Message.sendPrefixless("CHECK_HELP_LIST", sender);
Message.sendPrefixless("CHECK_HELP_NEXT", sender);
Message.sendPrefixless("CHECK_HELP_DECLINE", sender);
Message.sendPrefixless("CHECK_HELP_CANCEL", sender);
}
private static class CheckSession{ private static class CheckSession{
private final ProxiedPlayer checker; private final ProxiedPlayer checker;
private final SchematicNode schematic; private final SchematicNode schematic;

Datei anzeigen

@ -21,45 +21,38 @@ package de.steamwar.bungeecore.commands;
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.messages.ChatSender; import de.steamwar.messages.ChatSender;
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.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.File; import java.io.File;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
public class DevCommand extends BasicCommand { public class DevCommand extends SWCommand {
private final File devServerDir = new File("/configs/DevServer"); private final File devServerDir = new File("/configs/DevServer");
private final Map<String, ServerInfo> devServers = new HashMap<>(); private final Map<String, ServerInfo> devServers = new HashMap<>();
public DevCommand() { public DevCommand() {
super("dev", ""); super("dev");
}
@Override
public void execute(CommandSender s, String[] args) {
if (!(s instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) s;
ChatSender sender = ChatSender.of(player);
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoDevServer)) {
return;
} }
@Register
public void simpleCommand(@Guard ProxiedPlayer player) {
updateDevServers(); updateDevServers();
if(devServers.isEmpty()) { ChatSender sender = ChatSender.of(player);
if (devServers.isEmpty()) {
sender.system("DEV_NO_SERVER"); sender.system("DEV_NO_SERVER");
return;
} else if (devServers.size() == 1) { } else if (devServers.size() == 1) {
player.connect(devServers.values().stream().findAny().get()); player.connect(devServers.values().stream().findAny().get());
} else if (args.length == 0) { return;
}
ServerInfo info = devServers.get(player.getName().toLowerCase()); ServerInfo info = devServers.get(player.getName().toLowerCase());
if (info == null) { if (info == null) {
sender.system("DEV_UNKNOWN_SERVER"); sender.system("DEV_UNKNOWN_SERVER");
@ -67,8 +60,13 @@ public class DevCommand extends BasicCommand {
} }
player.connect(info); player.connect(info);
} else { }
ServerInfo info = devServers.get(args[0].toLowerCase());
@Register
public void selectedCommand(@Guard ProxiedPlayer player, @Mapper("dev") String name) {
updateDevServers();
ChatSender sender = ChatSender.of(player);
ServerInfo info = devServers.get(name.toLowerCase());
if (info == null) { if (info == null) {
sender.system("DEV_NO_SERVER"); sender.system("DEV_NO_SERVER");
return; return;
@ -76,34 +74,45 @@ public class DevCommand extends BasicCommand {
player.connect(info); player.connect(info);
} }
@ClassGuard(value = ProxiedPlayer.class, local = true)
public GuardChecker punishmentGuardChecker() {
return (commandSender, guardCheckType, previousArguments, s) -> {
ChatSender sender = ChatSender.of(commandSender);
if (guardCheckType == GuardCheckType.COMMAND) {
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoDevServer)) {
return GuardResult.DENIED;
}
} else {
if (sender.user().isPunished(Punishment.PunishmentType.NoDevServer)) {
return GuardResult.DENIED;
}
}
return GuardResult.ALLOWED;
};
} }
@Override @Mapper(value = "dev", local = true)
public Iterable<String> onTabComplete(CommandSender sender, String[] args) { public TypeMapper<String> devServers() {
if (!(sender instanceof ProxiedPlayer) || args.length > 1) { return SWCommandUtils.createMapper(s -> s, s -> {
return Collections.emptyList();
}
updateDevServers(); updateDevServers();
return devServers.keySet().stream().filter(s -> { return devServers.keySet();
if (args.length == 0) return true; });
return s.startsWith(args[0].toLowerCase());
}).collect(Collectors.toList());
} }
private void updateDevServers() { private void updateDevServers() {
String[] serverFiles = devServerDir.list(); String[] serverFiles = devServerDir.list();
Map<String, Integer> devServerFiles = new HashMap<>(); Map<String, Integer> devServerFiles = new HashMap<>();
if(serverFiles != null) { if (serverFiles != null) {
for(String serverFile : serverFiles) { for (String serverFile : serverFiles) {
String[] server = serverFile.split("\\."); String[] server = serverFile.split("\\.");
devServerFiles.put(server[0], Integer.parseInt(server[1])); devServerFiles.put(server[0], Integer.parseInt(server[1]));
} }
} }
devServers.entrySet().removeIf(entry -> { devServers.entrySet().removeIf(entry -> {
if(!devServerFiles.containsKey(entry.getKey())) { if (!devServerFiles.containsKey(entry.getKey())) {
ProxyServer.getInstance().getServers().remove(entry.getValue().getName()); ProxyServer.getInstance().getServers().remove(entry.getValue().getName());
return true; return true;
} }

Datei anzeigen

@ -20,10 +20,7 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.Event; import de.steamwar.bungeecore.sql.*;
import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.TeamTeilnahme;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -84,6 +81,13 @@ public class EventCommand extends BasicCommand {
if(now.isBefore(e.getDeadline().toInstant())) { if(now.isBefore(e.getDeadline().toInstant())) {
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline()); Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
} }
String schemType = e.getSchemType();
if (schemType != null) {
SchematicType schematicType = SchematicType.fromDB(schemType);
if (schematicType != null && schematicType.deadline() != null && now.isBefore(schematicType.deadline().toInstant())) {
Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline());
}
}
if(!teams.isEmpty()){ if(!teams.isEmpty()){
StringBuilder tline = new StringBuilder(); StringBuilder tline = new StringBuilder();
for(Team t : teams){ for(Team t : teams){

Datei anzeigen

@ -23,35 +23,29 @@ import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Event; import de.steamwar.bungeecore.sql.Event;
import de.steamwar.bungeecore.sql.EventFight; import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.Team;
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.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class EventRescheduleCommand extends BasicCommand { public class EventRescheduleCommand extends SWCommand {
public EventRescheduleCommand() { public EventRescheduleCommand() {
super("eventreschedule", "bungeecore.softreload"); super("eventreschedule", "bungeecore.softreload");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void reschedule(ProxiedPlayer player, Team teamBlue, Team teamRed) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length != 2){
Message.send("EVENTRESCHEDULE_USAGE", player);
return;
}
Team teamBlue = Team.get(args[0]);
Team teamRed = Team.get(args[1]);
Event event = Event.get(); Event event = Event.get();
if(teamBlue == null || teamRed == null || event == null){ if(event == null){
Message.send("EVENTRESCHEDULE_UNKNOWN_TEAM", player); Message.send("EVENTRESCHEDULE_UNKNOWN_TEAM", player);
return; return;
} }
@ -74,4 +68,22 @@ public class EventRescheduleCommand extends BasicCommand {
Message.send("EVENTRESCHEDULE_NO_FIGHT", player); Message.send("EVENTRESCHEDULE_NO_FIGHT", player);
} }
@Register
public TypeMapper<Team> teamTypeMapper() {
return new TypeMapper<Team>() {
@Override
public Team map(CommandSender commandSender, String[] previousArguments, String s) {
return Team.get(s);
}
@Override
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
Event event = Event.get();
if (event == null) return null;
List<EventFight> fights = EventFight.getEvent(event.getEventID());
return fights.stream().flatMap(fight -> Stream.of(fight.getTeamBlue(), fight.getTeamRed())).map(Team::get).map(Team::getTeamKuerzel).distinct().collect(Collectors.toList());
}
};
}
} }

Datei anzeigen

@ -20,15 +20,16 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.sql.EventFight; import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
public class EventreloadCommand extends BasicCommand { public class EventreloadCommand extends SWCommand {
public EventreloadCommand() { public EventreloadCommand() {
super("eventreload", "bungeecore.softreload"); super("eventreload", "bungeecore.softreload");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender) {
EventFight.loadAllComingFights(); EventFight.loadAllComingFights();
} }
} }

Datei anzeigen

@ -4,6 +4,7 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Statement; import de.steamwar.bungeecore.sql.Statement;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -12,19 +13,20 @@ import java.io.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
public class GDPRQuery extends BasicCommand { public class GDPRQuery extends SWCommand {
public GDPRQuery() { public GDPRQuery() {
super("gdprquery", "bungeecore.softreload"); super("gdprquery", "bungeecore.softreload");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void generate(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer)) generate(player, player);
return; }
ProxiedPlayer player = (ProxiedPlayer) sender; @Register
SteamwarUser user = args.length == 0 ? SteamwarUser.get(player.getUniqueId()) : SteamwarUser.get(args[0]); public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
SteamwarUser user = SteamwarUser.get(forPlayer);
if(user == null) { if(user == null) {
Message.send("UNKNOWN_PLAYER", player); Message.send("UNKNOWN_PLAYER", player);
return; return;

Datei anzeigen

@ -22,28 +22,26 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.IgnoreSystem; import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class IgnoreCommand extends BasicCommand { import java.util.stream.Collectors;
public class IgnoreCommand extends SWCommand {
public IgnoreCommand() { public IgnoreCommand() {
super("ignore", null); super("ignore", null);
} }
@Override @Register(description = "USAGE_IGNORE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer p, @Mapper("player") String toIgnore) {
if(args.length < 1) {
Message.send("USAGE_IGNORE", sender);
return;
}
if (!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer p = (ProxiedPlayer) sender;
SteamwarUser user = SteamwarUser.get(p.getUniqueId()); SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SteamwarUser target = SteamwarUser.get(args[0]); SteamwarUser target = SteamwarUser.get(toIgnore);
if(target == null){ if(target == null){
Message.send("UNKNOWN_PLAYER", p); Message.send("UNKNOWN_PLAYER", p);
return; return;
@ -60,4 +58,9 @@ public class IgnoreCommand extends BasicCommand {
IgnoreSystem.ignore(user, target); IgnoreSystem.ignore(user, target);
Message.send("IGNORE_MESSAGE", p, target.getUserName()); Message.send("IGNORE_MESSAGE", p, target.getUserName());
} }
@Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
}
} }

Datei anzeigen

@ -21,48 +21,40 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.BungeeCord;
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.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList; import java.util.stream.Collectors;
public class KickCommand extends BasicCommand { public class KickCommand extends SWCommand {
public KickCommand() { public KickCommand() {
super("kick", "bungeecore.kick"); super("kick", "bungeecore.kick");
} }
@Override @Register(description = "KICK_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(CommandSender sender, @Mapper("player") String player, String... message) {
if(args.length == 0){ ProxiedPlayer target = ProxyServer.getInstance().getPlayer(player);
Message.send("KICK_USAGE", sender);
return;
}
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null){ if(target == null){
Message.send("KICK_OFFLINE", sender); Message.send("KICK_OFFLINE", sender);
return; return;
} }
if(args.length == 1){ if (message.length == 0) {
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target)); target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
}else{ } else {
StringBuilder msgBuilder = new StringBuilder(); target.disconnect(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
msgBuilder.append(BungeeCore.CHAT_PREFIX).append("§c");
for (int i = 1; i < args.length; i++){
msgBuilder.append(args[i]).append(" ");
}
target.disconnect(BungeeCore.stringToText(msgBuilder.toString()));
} }
Message.send("KICK_CONFIRM", sender, target.getName()); Message.send("KICK_CONFIRM", sender, target.getName());
} }
@Override @Mapper(value = "player", local = true)
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public TypeMapper<String> playerTypeMapper() {
if(args.length == 1) return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
return allPlayers(args[0]);
return new ArrayList<>();
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; 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 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.config.ServerInfo;
@ -33,7 +34,7 @@ import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ListCommand extends BasicCommand { public class ListCommand extends SWCommand {
public ListCommand() { public ListCommand() {
super("list", ""); super("list", "");
@ -60,8 +61,8 @@ public class ListCommand extends BasicCommand {
return playerMap; return playerMap;
} }
@Override @Register
public void execute(CommandSender commandSender, String[] strings) { public void genericCommand(CommandSender commandSender) {
TreeMap<String, List<ProxiedPlayer>> playerMap = getCustomTablist(); TreeMap<String, List<ProxiedPlayer>> playerMap = getCustomTablist();
for (String server : playerMap.navigableKeySet()) { for (String server : playerMap.navigableKeySet()) {
String serverName = server; String serverName = server;

Datei anzeigen

@ -20,20 +20,18 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener; import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class LocalCommand extends BasicCommand { public class LocalCommand extends SWCommand {
public LocalCommand() { public LocalCommand() {
super("local", null, "bc", "bauchat"); super("local", null, "bc", "bauchat");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player, String... message) {
if(!(sender instanceof ProxiedPlayer)) ChatListener.localChat(player, String.join(" ", message));
return;
ChatListener.localChat((ProxiedPlayer) sender, String.join(" ", args));
} }
} }

Datei anzeigen

@ -21,34 +21,23 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener; import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.bungeecore.sql.IgnoreSystem; import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
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.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream; import java.util.stream.Stream;
import static de.steamwar.bungeecore.Storage.lastChats; import static de.steamwar.bungeecore.Storage.lastChats;
public class MsgCommand extends BasicCommand { public class MsgCommand extends SWCommand {
public MsgCommand() { public MsgCommand() {
super("msg", "", "w", "tell"); super("msg", "", "w", "tell");
} }
@Override @Register(description = "MSG_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
if(!(sender instanceof ProxiedPlayer)) msg(sender, target, message);
return;
if (args.length < 2) {
ChatSender.of(sender).system("MSG_USAGE");
return;
}
msg((ProxiedPlayer) sender, ProxyServer.getInstance().getPlayer(args[0]), Arrays.copyOfRange(args, 1, args.length));
} }
public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) { public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) {
@ -69,14 +58,6 @@ public class MsgCommand extends BasicCommand {
lastChats.put(target, player); lastChats.put(target, player);
} }
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){
return allPlayers(args[0]);
}
return new ArrayList<>();
}
public static void remove(ProxiedPlayer player){ public static void remove(ProxiedPlayer player){
lastChats.remove(player); lastChats.remove(player);
} }

Datei anzeigen

@ -20,20 +20,17 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import net.md_5.bungee.api.CommandSender; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class PingCommand extends BasicCommand { public class PingCommand extends SWCommand {
public PingCommand() { public PingCommand() {
super("ping", ""); super("ping");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player) {
if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender;
Message.send("PING_RESPONSE", player, player.getPing()); Message.send("PING_RESPONSE", player, player.getPing());
} }
}
} }

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.apache.commons.lang3.LocaleUtils; import org.apache.commons.lang3.LocaleUtils;
@ -29,21 +30,18 @@ import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Locale; import java.util.Locale;
public class PlaytimeCommand extends BasicCommand{ public class PlaytimeCommand extends SWCommand {
public PlaytimeCommand() { public PlaytimeCommand() {
super("playtime", null); super("playtime");
} }
@Override @Register
public void execute(CommandSender sender, String[] strings) { public void genericCommand(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer)) NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
return;
NumberFormat format = NumberFormat.getNumberInstance(((ProxiedPlayer)sender).getLocale());
format.setMaximumFractionDigits(2); format.setMaximumFractionDigits(2);
String formattedText = format.format((SteamwarUser.get((ProxiedPlayer) sender).getOnlinetime() / (double) 3600)); String formattedText = format.format((SteamwarUser.get(player).getOnlinetime() / (double) 3600));
Message.send("HOURS_PLAYED", sender, formattedText); Message.send("HOURS_PLAYED", player, formattedText);
} }
} }

Datei anzeigen

@ -23,35 +23,29 @@ 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 net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class PollCommand extends BasicCommand { public class PollCommand extends SWCommand {
public PollCommand() { public PollCommand() {
super("poll", ""); super("poll");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(@Guard ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(PollSystem.noCurrentPoll()){
Message.send("POLL_NO_POLL", player);
return;
}
if(args.length == 0){
PollSystem.sendPoll(player); PollSystem.sendPoll(player);
return;
} }
@Register(noTabComplete = true)
public void answerPoll(@Guard ProxiedPlayer player, String answerString) {
int answer; int answer;
try { try {
answer = Integer.parseUnsignedInt(args[0]); answer = Integer.parseUnsignedInt(answerString);
if(answer < 1 || answer > PollSystem.answers()) if(answer < 1 || answer > PollSystem.answers())
throw new NumberFormatException(); throw new NumberFormatException();
}catch(NumberFormatException e){ }catch(NumberFormatException e){
@ -67,4 +61,17 @@ public class PollCommand extends BasicCommand {
pollAnswer.setAnswer(answer); pollAnswer.setAnswer(answer);
} }
@ClassGuard(value = ProxiedPlayer.class, local = true)
public GuardChecker noPoll() {
return (commandSender, guardCheckType, previousArguments, s) -> {
if(PollSystem.noCurrentPoll()){
if (guardCheckType == GuardCheckType.COMMAND) {
Message.send("POLL_NO_POLL", commandSender);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
}
} }

Datei anzeigen

@ -22,33 +22,39 @@ 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 net.md_5.bungee.api.CommandSender; import de.steamwar.command.GuardCheckType;
import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Map; import java.util.Map;
public class PollresultCommand extends BasicCommand { public class PollresultCommand extends SWCommand {
public PollresultCommand() { public PollresultCommand() {
super("pollresult", "bungeecore.pollresults"); super("pollresult", "bungeecore.pollresults");
} }
@Override @Register
public void execute(CommandSender sender, String[] strings) { public void genericCommand(@Guard ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer))
return;
if(PollSystem.noCurrentPoll()) {
Message.send("POLLRESULT_NOPOLL", sender);
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
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()) {
Message.send("POLLRESULT_LIST", sender, e.getKey(), e.getValue()); Message.send("POLLRESULT_LIST", player, e.getKey(), e.getValue());
} }
} }
@ClassGuard(value = ProxiedPlayer.class, local = true)
public GuardChecker noPoll() {
return (commandSender, guardCheckType, previousArguments, s) -> {
if(PollSystem.noCurrentPoll()){
if (guardCheckType == GuardCheckType.COMMAND) {
Message.send("POLL_NO_POLL", commandSender);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
}
} }

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; 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.SWCommand;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -34,65 +35,67 @@ import java.util.Date;
public class PunishmentCommand { public class PunishmentCommand {
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) { public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
new BasicCommand(command, "bungeecore.ban") { new SWCommand(command, "bungeecore.ban") {
@Override @Register(description = "PUNISHMENT_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) { if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
return;
}
if (args.length < 3) {
Message.send("PUNISHMENT_USAGE", sender, command);
return; return;
} }
SteamwarUser target = unsafeUser(sender, args[0]); SteamwarUser target = unsafeUser(player, toPunish);
if (target == null) if (target == null)
return; return;
Timestamp banTime = parseTime(sender, args[1]); Timestamp banTime = parseTime(player, date);
if (banTime == null) if (banTime == null)
return; return;
StringBuilder reason = new StringBuilder(); boolean isPerma = date.equalsIgnoreCase("perma");
for (int i = 2; i < args.length; i++) { String msg = String.join(" ", message);
reason.append(args[i]).append(" "); target.punish(punishmentType, banTime, msg, SteamwarUser.get(player.getName()).getId(), isPerma);
} Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
boolean isPerma = args[1].equalsIgnoreCase("perma");
String msg = reason.toString();
target.punish(punishmentType, banTime, msg, SteamwarUser.get(sender.getName()).getId(), isPerma);
Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), sender.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
} }
}; };
if (punishmentType.getUnpunishmentMessage() == null) { if (punishmentType.getUnpunishmentMessage() == null) {
return; return;
} }
String antiCommand = "un" + command; String antiCommand = "un" + command;
new BasicCommand(antiCommand, "bungeecore.ban") { new SWCommand(antiCommand, "bungeecore.ban") {
@Override @Register(description = "PUNISHMENT_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player, String toUnpunish) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) { if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
return;
}
if (args.length < 1) {
Message.send("UNPUNISHMENT_USAGE", sender, antiCommand);
return; return;
} }
SteamwarUser target = existingUser(sender, args[0]); SteamwarUser target = existingUser(player, toUnpunish);
if (target == null) if (target == null)
return; return;
if (!target.isPunished(punishmentType)) { if (!target.isPunished(punishmentType)) {
Message.send(punishmentType.getUsageNotPunished(), sender); Message.send(punishmentType.getUsageNotPunished(), player);
return; return;
} }
Message.send(punishmentType.getUnpunishmentMessage(), sender, target.getUserName()); Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(sender.getName()).getId(), false); target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
} }
}; };
} }
protected SteamwarUser existingUser(CommandSender sender, String arg){
SteamwarUser target = SteamwarUser.get(arg);
if(target == null)
Message.send("UNKNOWN_PLAYER", sender);
return target;
}
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
if(target == null)
Message.send("UNKNOWN_PLAYER", sender);
return target;
}
public static Timestamp parseTime(CommandSender sender, String arg) { public static Timestamp parseTime(CommandSender sender, String arg) {
if (arg.equalsIgnoreCase("perma")) { if (arg.equalsIgnoreCase("perma")) {
return Punishment.PERMA_TIME; return Punishment.PERMA_TIME;

Datei anzeigen

@ -19,28 +19,19 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.messages.ChatSender; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import static de.steamwar.bungeecore.Storage.lastChats; import static de.steamwar.bungeecore.Storage.lastChats;
public class RCommand extends BasicCommand { public class RCommand extends SWCommand {
public RCommand() { public RCommand() {
super("r", "", "reply"); super("r", "", "reply");
} }
@Override @Register(description = "R_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "R_USAGE", allowEAs = false) String... message) {
if(!(sender instanceof ProxiedPlayer)) MsgCommand.msg(player, lastChats.get(player), message);
return;
if(args.length == 0){
ChatSender.of(sender).system("R_USAGE");
return;
}
MsgCommand.msg((ProxiedPlayer) sender, lastChats.get(sender), args);
} }
} }

Datei anzeigen

@ -23,32 +23,36 @@ import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.UserElo; import de.steamwar.bungeecore.sql.UserElo;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
public class RankCommand extends BasicCommand { public class RankCommand extends SWCommand {
public RankCommand() { public RankCommand() {
super("rank", null); super("rank");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void ownRank(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer)) rank(player, player.getName());
return; }
ProxiedPlayer player = (ProxiedPlayer) sender; @Register
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); public void rank(ProxiedPlayer player, @Mapper("player") String s) {
if (args.length > 0) { SteamwarUser user = SteamwarUser.get(s);
SteamwarUser nUser = SteamwarUser.get(args[0]); if (user == null) {
if (nUser == null) {
Message.send("RANK_PLAYER_NOT_FOUND", player); Message.send("RANK_PLAYER_NOT_FOUND", player);
return; return;
} }
Message.send("RANK_PLAYER_FOUND", player, nUser.getUserName()); if (!player.getName().equals(s)) {
user = nUser; Message.send("RANK_PLAYER_FOUND", player, user.getUserName());
} }
for(ArenaMode mode : ArenaMode.getAllModes()) { for(ArenaMode mode : ArenaMode.getAllModes()) {
if (!mode.isRanked()) if (!mode.isRanked())
@ -67,4 +71,9 @@ public class RankCommand extends BasicCommand {
Message.send("RANK_EMBLEM", player, UserElo.getEmblemProgression(player, mode.getChatName(), user.getId())); Message.send("RANK_EMBLEM", player, UserElo.getEmblemProgression(player, mode.getChatName(), user.getId()));
} }
} }
@Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
}
} }

Datei anzeigen

@ -20,21 +20,18 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; 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 BasicCommand { public class RegelnCommand extends SWCommand {
public RegelnCommand() { public RegelnCommand() {
super("regeln", null); super("regeln");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
Message.send("REGELN_RULES", player); Message.send("REGELN_RULES", player);
Message.sendPrefixless("REGELN_AS", player, Message.parse("REGELN_AS_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_AS_URL", player))); Message.sendPrefixless("REGELN_AS", player, Message.parse("REGELN_AS_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_AS_URL", player)));
Message.sendPrefixless("REGELN_MWG", player, Message.parse("REGELN_MWG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_MWG_URL", player))); Message.sendPrefixless("REGELN_MWG", player, Message.parse("REGELN_MWG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_MWG_URL", player)));

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.bungeecore.sql.Fight;
import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SchematicType; import de.steamwar.bungeecore.sql.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -35,18 +36,14 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ReplayCommand extends BasicCommand { public class ReplayCommand extends SWCommand {
public ReplayCommand() { public ReplayCommand() {
super("replay", null); super("replay");
} }
@Override @Register
public void execute(CommandSender s, String[] args) { public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
if(!(s instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) s;
ChatSender sender = ChatSender.of(player); ChatSender sender = ChatSender.of(player);
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
return; return;
@ -57,8 +54,8 @@ public class ReplayCommand extends BasicCommand {
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player); ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
String map = mode.getRandomMap(); String map = mode.getRandomMap();
if (args.length > 0) { if (!optionalMap.equals("")) {
String tMap = mode.hasMap(args[0]); String tMap = mode.hasMap(optionalMap);
if (tMap != null) map = tMap; if (tMap != null) map = tMap;
} }

Datei anzeigen

@ -19,12 +19,13 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.command.SWCommand;
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.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class ServerSwitchCommand extends BasicCommand { public class ServerSwitchCommand extends SWCommand {
private String serverName; private String serverName;
@ -33,12 +34,9 @@ public class ServerSwitchCommand extends BasicCommand {
serverName = name; serverName = name;
} }
@Override @Register
public void execute(CommandSender sender, String[] strings) { public void genericCommand(ProxiedPlayer player) {
if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender;
ServerInfo target = ProxyServer.getInstance().getServerInfo(serverName); ServerInfo target = ProxyServer.getInstance().getServerInfo(serverName);
player.connect(target); player.connect(target);
} }
}
} }

Datei anzeigen

@ -20,23 +20,24 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener; import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
public class ServerTeamchatCommand extends BasicCommand { public class ServerTeamchatCommand extends SWCommand {
public ServerTeamchatCommand() { public ServerTeamchatCommand() {
super("stc", "bungeecore.teamchat","serverteamchat"); super("stc", "bungeecore.teamchat","serverteamchat");
} }
@Override @Register(description = "STC_USAGE")
public void execute(CommandSender s, String[] args) { public void genericCommand(CommandSender commandSender, String... message) {
ChatSender sender = ChatSender.of(s); ChatSender sender = ChatSender.of(commandSender);
if(args.length == 0) { if(message.length == 0) {
sender.system("STC_USAGE"); sender.system("STC_USAGE");
return; return;
} }
ChatListener.sendChat(sender, ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", null, String.join(" ", args)); ChatListener.sendChat(sender, ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", null, String.join(" ", message));
} }
} }

Datei anzeigen

@ -19,25 +19,22 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Objects; import java.util.Objects;
public class SetLocaleCommand extends BasicCommand { public class SetLocaleCommand extends SWCommand {
public SetLocaleCommand() { public SetLocaleCommand() {
super("setlocale", null, "setlanguage"); super("setlocale", null, "setlanguage");
} }
@Override @Register
public void execute(CommandSender s, String[] strings) { public void genericCommand(ProxiedPlayer player) {
if (!(s instanceof ProxiedPlayer)) ChatSender sender = ChatSender.of(player);
return; sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
ChatSender sender = ChatSender.of(s);
sender.user().setLocale(Objects.requireNonNull(((ProxiedPlayer) s).getLocale()), true);
sender.system("LOCK_LOCALE_CHANGED"); sender.system("LOCK_LOCALE_CHANGED");
} }
} }

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Node; import de.steamwar.bungeecore.Node;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -28,14 +29,14 @@ import java.io.InputStreamReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class StatCommand extends BasicCommand { public class StatCommand extends SWCommand {
public StatCommand() { public StatCommand() {
super("stat", "bungeecore.softreload", "stats"); super("stat", "bungeecore.softreload", "stats");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(CommandSender sender) {
Map<String, Integer> serverCount = new HashMap<>(); Map<String, Integer> serverCount = new HashMap<>();
try { try {
Process process = new ProcessBuilder("ps", "x").start(); Process process = new ProcessBuilder("ps", "x").start();
@ -53,5 +54,4 @@ public class StatCommand extends BasicCommand {
Node.forEach(node -> Message.send("STAT_SERVER", sender, node.getName(), node.getLoad(), serverCount.getOrDefault(node.getName(), 0))); Node.forEach(node -> Message.send("STAT_SERVER", sender, node.getName(), node.getLoad(), serverCount.getOrDefault(node.getName(), 0)));
} }
} }

Datei anzeigen

@ -564,11 +564,6 @@ public class TeamCommand extends BasicCommand {
} }
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if (!user.getUserGroup().isAdminGroup()) {
Message.send("DISABLED", player);
return;
}
if(args.length == 1){ if(args.length == 1){
if(notInTeam(player, user)) if(notInTeam(player, user))
return; return;
@ -615,11 +610,6 @@ public class TeamCommand extends BasicCommand {
} }
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if (!user.getUserGroup().isAdminGroup()) {
Message.send("DISABLED", player);
return;
}
if(notLeader(player, user, team)) if(notLeader(player, user, team))
return; return;
if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) { if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {

Datei anzeigen

@ -52,13 +52,18 @@ public class TpCommand extends BasicCommand {
return; return;
} }
ServerInfo server = getTarget(player, args[0]); ServerInfo server = getTarget(args[0]);
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
//Give control of teleport command to server //Give control of teleport command to server
if(server == null) { if (server == player.getServer().getInfo() || onTeamServer) {
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);
} }
@ -110,7 +115,7 @@ public class TpCommand extends BasicCommand {
} }
} }
private static ServerInfo getTarget(ProxiedPlayer player, String arg) { private static ServerInfo getTarget(String arg) {
ServerInfo server = null; ServerInfo server = null;
//Get target player server //Get target player server
@ -128,9 +133,6 @@ public class TpCommand extends BasicCommand {
} }
} }
if(server == player.getServer().getInfo())
server = null;
return server; return server;
} }
} }

Datei anzeigen

@ -26,7 +26,9 @@ 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 net.md_5.bungee.api.CommandSender; import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
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;
@ -38,38 +40,24 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TutorialCommand extends BasicCommand { public class TutorialCommand extends SWCommand {
public TutorialCommand() { public TutorialCommand() {
super("tutorial", null); super("tutorial", null);
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0) {
openInventory(player, true, false); openInventory(player, true, false);
return;
} }
switch(args[0].toLowerCase()) { @Register("rate")
case "rate": public void rate(ProxiedPlayer player) {
if(args.length < 2) {
player.chat("/tutorial rate"); player.chat("/tutorial rate");
return;
}
int id;
try {
id = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with non number: " + args[1]);
return;
} }
@Register("rate")
public void rate(ProxiedPlayer player, int id) {
Tutorial tutorial = Tutorial.get(id); Tutorial tutorial = Tutorial.get(id);
if(tutorial == null) { if(tutorial == null) {
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with nonexistent id: " + id); BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with nonexistent id: " + id);
@ -77,27 +65,36 @@ public class TutorialCommand extends BasicCommand {
} }
rate(player, tutorial); rate(player, tutorial);
break;
case "create":
if(args.length < 3) {
Message.send("TUTORIAL_CREATE_HELP", player);
return;
} }
create(player, Arrays.stream(args).skip(2).collect(Collectors.joining(" ")), args[1].toUpperCase()); @Register(value = "create", description = "TUTORIAL_CREATE_HELP")
break; public void create(ProxiedPlayer player, String material, String... name) {
case "own": create(player, String.join(" ", name), material.toUpperCase());
}
@Register("own")
public void own(ProxiedPlayer player) {
openInventory(player, false, true); openInventory(player, false, true);
break; }
case "unreleased":
if (SteamwarUser.get(player.getUniqueId()).getUserGroup().isTeamGroup()) { @Register("unreleased")
public void unreleased(@Guard("unreleased") ProxiedPlayer player) {
openInventory(player, false, false); openInventory(player, false, false);
break;
} }
default:
Message.send("TUTORIAL_CREATE_HELP", player); @Guard("unreleased")
Message.send("TUTORIAL_OWN_HELP", player); public GuardChecker unreleasedChecker() {
return (commandSender, guardCheckType, previousArguments, s) -> {
if (commandSender instanceof ProxiedPlayer) {
if (SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup().isTeamGroup()) {
return GuardResult.ALLOWED;
} else {
return GuardResult.DENIED_WITH_HELP;
} }
} else {
return GuardResult.ALLOWED;
}
};
} }
private void openInventory(ProxiedPlayer player, boolean released, boolean own) { private void openInventory(ProxiedPlayer player, boolean released, boolean own) {

Datei anzeigen

@ -22,28 +22,20 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.IgnoreSystem; import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class UnIgnoreCommand extends BasicCommand { public class UnIgnoreCommand extends SWCommand {
public UnIgnoreCommand() { public UnIgnoreCommand() {
super("unignore", null); super("unignore");
} }
@Override @Register(description = "UNIGNORE_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer p, String toUnIgnore) {
if(args.length < 1) {
Message.send("UNIGNORE_USAGE", sender);
return;
}
if (!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer p = (ProxiedPlayer) sender;
SteamwarUser user = SteamwarUser.get(p.getUniqueId()); SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SteamwarUser target = SteamwarUser.get(args[0]); SteamwarUser target = SteamwarUser.get(toUnIgnore);
if(target == null){ if(target == null){
Message.send("UNIGNORE_NOT_PLAYER", p); Message.send("UNIGNORE_NOT_PLAYER", p);
return; return;
@ -55,5 +47,4 @@ public class UnIgnoreCommand extends BasicCommand {
IgnoreSystem.unIgnore(user, target); IgnoreSystem.unIgnore(user, target);
Message.send("UNIGNORE_UNIGNORED", p, target.getUserName()); Message.send("UNIGNORE_UNIGNORED", p, target.getUserName());
} }
} }

Datei anzeigen

@ -23,27 +23,23 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.bot.AuthManager; import de.steamwar.bungeecore.bot.AuthManager;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Base64; import java.util.Base64;
public class VerifyCommand extends BasicCommand { public class VerifyCommand extends SWCommand {
public VerifyCommand() { public VerifyCommand() {
super("verify", ""); super("verify");
}
@Override
public void execute(CommandSender sender, String[] strings) {
if(strings.length < 1) {
Message.send("VERIFY_USAGE", sender);
return;
} }
@Register(description = "VERIFY_USAGE")
public void genericCommand(ProxiedPlayer sender, String code) {
byte[] bytes; byte[] bytes;
try { try {
bytes = Base64.getDecoder().decode(strings[0]); bytes = Base64.getDecoder().decode(code);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Message.send("VERIFY_INVALID", sender); Message.send("VERIFY_INVALID", sender);
return; return;
@ -54,7 +50,7 @@ public class VerifyCommand extends BasicCommand {
return; return;
} }
if(bytes[0] == 'D' && bytes[1] == 'C') { if(bytes[0] == 'D' && bytes[1] == 'C') {
Member member = AuthManager.connectAuth(SteamwarUser.get(sender.getName()), strings[0]); Member member = AuthManager.connectAuth(SteamwarUser.get(sender.getName()), code);
if(member != null) { if(member != null) {
BungeeCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong()); BungeeCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
Message.send("VERIFY_SUCCESS", sender, member.getUser().getAsTag()); Message.send("VERIFY_SUCCESS", sender, member.getUser().getAsTag());

Datei anzeigen

@ -21,31 +21,22 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SWException; import de.steamwar.bungeecore.sql.SWException;
import net.md_5.bungee.api.CommandSender; import de.steamwar.command.SWCommand;
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 BasicCommand { public class WebregisterCommand extends SWCommand {
public WebregisterCommand() { public WebregisterCommand() {
super("webregister", null, "web", "webpw"); super("webregister", null, "web", "webpw");
} }
@Override @Register(description = "WEB_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player, String email) {
if(!(sender instanceof ProxiedPlayer)) ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), email);
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length != 1){
Message.send("WEB_USAGE", player);
return;
}
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), args[0]);
pb.redirectErrorStream(true); pb.redirectErrorStream(true);
try { try {
Process regProcess = pb.start(); Process regProcess = pb.start();

Datei anzeigen

@ -23,6 +23,10 @@ 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.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.Team;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; 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;
@ -32,50 +36,44 @@ import java.text.DecimalFormat;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
public class WhoisCommand extends BasicCommand { public class WhoisCommand extends SWCommand {
public WhoisCommand(){ public WhoisCommand() {
super("whois", "bungeecore.teamchat"); super("whois", "bungeecore.teamchat");
} }
@Override @Register(description = "WHOIS_USAGE")
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue({"-all", "-a", ""}) String displayAll) {
if(!(sender instanceof ProxiedPlayer)) SteamwarUser user = SteamwarUser.get(target);
return; if (user == null) {
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){
Message.send("WHOIS_USAGE", player);
return;
}
SteamwarUser user = SteamwarUser.get(args[0]);
if(user == null){
try { try {
int id = Integer.parseInt(args[0]); int id = Integer.parseInt(target);
user = SteamwarUser.get(id); user = SteamwarUser.get(id);
}catch (NumberFormatException ignored) {} } catch (NumberFormatException ignored) {
}
} }
if (user == null) { if (user == null) {
try { try {
long id = Long.parseLong(args[0]); long id = Long.parseLong(target);
user = SteamwarUser.get(id); user = SteamwarUser.get(id);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
// Ignored // Ignored
} }
} }
if(user == null) { if (user == null) {
Message.send("UNKNOWN_PLAYER", player); Message.send("UNKNOWN_PLAYER", player);
return; return;
} }
boolean all = false; boolean all = displayAll.contains("-");
if(args.length > 1 && args[1].startsWith("-")) { sendUserinfo(player, user, all);
all = args[1].contains("a");
} }
sendUserinfo(player, user, all); @Mapper(value = "player", local = true)
public TypeMapper<String> playerTypeMapper() {
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
} }
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, boolean all) { private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, boolean all) {
@ -86,7 +84,7 @@ public class WhoisCommand extends BasicCommand {
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId()); Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
} }
Timestamp firstJoin = user.getFirstjoin(); Timestamp firstJoin = user.getFirstjoin();
if(firstJoin == null) if (firstJoin == null)
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00"); Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
else else
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());

Datei anzeigen

@ -82,27 +82,26 @@ public class ChatListener extends BasicListener {
} }
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");
} }
@ -119,40 +118,40 @@ public class ChatListener extends BasicListener {
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) {

Datei anzeigen

@ -1,335 +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.bungeecore.listeners;
import codecrafter47.bungeetablistplus.api.bungee.BungeeTabListPlusAPI;
import codecrafter47.bungeetablistplus.api.bungee.Icon;
import codecrafter47.bungeetablistplus.tablist.DefaultCustomTablist;
import de.steamwar.bungeecore.BungeeCore;
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.UserGroup;
import net.md_5.bungee.BungeeCord;
import de.steamwar.network.packets.common.FightInfoPacket;
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.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class TablistManager extends BasicListener {
private static final Map<ProxiedPlayer, Tablist> tablists = new HashMap<>();
@EventHandler
public synchronized void onJoin(PostLoginEvent e){
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
if (e.getPlayer().isConnected()) {
tablists.put(e.getPlayer(), new Tablist(e.getPlayer()));
}
}, 1, TimeUnit.SECONDS);
}
@EventHandler
public synchronized void onLeave(PlayerDisconnectEvent e){
tablists.remove(e.getPlayer());
}
private static final Map<ServerInfo, FightInfoPacket> fightInfos = new HashMap<>();
public static synchronized void newFightInfo(ServerInfo info, FightInfoPacket packet) {
fightInfos.put(info, packet);
fightInfos.keySet().removeIf(serverInfo -> serverInfo.getPlayers().isEmpty());
}
private static Icon darkGray;
private static Icon gray;
private int seconds = 0;
private int size;
private TablistGroup tablist;
public TablistManager(){
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
try{
BungeeTabListPlusAPI.createIcon(ImageIO.read(new File("/configs/BungeeTabListPlus/heads/colors/dark_gray.png")), (icon) -> darkGray = icon);
BungeeTabListPlusAPI.createIcon(ImageIO.read(new File("/configs/BungeeTabListPlus/heads/colors/gray.png")), (icon) -> gray = icon);
}catch(IOException e){
throw new SecurityException("Could not load icons", e);
}
ProxyServer.getInstance().getPlayers().forEach(p -> tablists.put(p, new Tablist(p)));
}
private synchronized void updateTablist(){
//Calculate server-player-map
tablist = new TablistGroup(true, "");
TablistGroup bau = new TablistGroup(false, "Bau");
for (ServerInfo server : new ArrayList<>(ProxyServer.getInstance().getServers().values())){
if(server.getPlayers().isEmpty())
continue;
Subserver subserver = Subserver.getSubserver(server);
if(subserver != null && subserver.getType() == Servertype.BAUSERVER)
bau.addSubTablist(new TablistServer(server));
else if(fightInfos.containsKey(server))
tablist.addSubTablist(new TablistServer(server, fightInfos.get(server)));
else
tablist.addSubTablist(new TablistServer(server));
}
if(bau.size() > 0)
tablist.addSubTablist(bau);
size = (int) Math.ceil((tablist.size() - 1) / 20.0);
tablists.values().forEach(Tablist::refresh);
seconds++;
}
private class Tablist extends DefaultCustomTablist {
private final ProxiedPlayer player;
private int pos = 0;
private Tablist(ProxiedPlayer player){
this.player = player;
BungeeTabListPlusAPI.setCustomTabList(player, this);
}
private String header(){
int phase = (seconds % 16) / 3;
switch(phase){
case 0:
return Message.parse("TABLIST_PHASE_1", player);
case 1:
return Message.parse("TABLIST_PHASE_2", player);
case 2:
default:
return Message.parse("TABLIST_PHASE_DEFAULT", player);
}
}
private String ping(){
int ping = player.getPing();
if(ping < 50){
return "§a" + ping;
}else if(ping < 150){
return "§e" + ping;
}else{
return "§c" + ping;
}
}
private void refresh(){
if (player.getServer() == null) {
return;
}
pos = 0;
setHeader(header());
setFooter(Message.parse("TABLIST_FOOTER", player, player.getServer().getInfo().getName(), ping(), ProxyServer.getInstance().getPlayers().size()));
int currentSize = size > 4 ? tablist.slimSize(player) : size;
setSize(currentSize, 20);
tablist.print(this, size > 4);
while (pos < currentSize*20){
setSlot(darkGray, "", 1000);
}
}
private void setSlot(Icon icon, String name, int ping){
if(pos / 20 >= getColumns())
return;
setSlot(pos % 20, pos / 20, icon, name, ping);
pos++;
}
}
private interface TablistPart {
int size();
int slimSize(ProxiedPlayer viewer);
String name();
void print(Tablist viewer, boolean slim);
}
private static class TablistGroup implements TablistPart {
private final boolean withHeaders;
private final String orderName;
private final List<TablistPart> subTablists = new ArrayList<>();
private TablistGroup(boolean withHeaders, String orderName) {
this.withHeaders = withHeaders;
this.orderName = orderName;
}
private void addSubTablist(TablistPart tablist){
subTablists.add(tablist);
subTablists.sort((t1, t2) -> t1.name().compareToIgnoreCase(t2.name()));
}
@Override
public int size() {
return slimSize(null);
}
@Override
public int slimSize(ProxiedPlayer viewer) {
return subTablists.stream().mapToInt(tPart -> viewer == null ? tPart.size() : tPart.slimSize(viewer)).map(size -> {
size += withHeaders ? 1 : 0; // Space for header
size += withHeaders && size > 1 ? 1 : 0; // Space for footer
return size;
}).sum();
}
@Override
public String name() {
return orderName;
}
@Override
public void print(Tablist viewer, boolean slim) {
for (int i = 0; i < subTablists.size(); i++) {
TablistPart tPart = subTablists.get(i);
String name = tPart.name();
if (name.equals("Bau")) {
name = Message.parse("TABLIST_BAU", viewer.player);
}
boolean withoutFooter = i == subTablists.size() - 1;
if (withHeaders) {
if (slim) {
int slimSize = tPart.slimSize(viewer.player);
int size = tPart.size();
if (size == slimSize) {
viewer.setSlot(gray, "§7§l" + name, 1000);
} else if (slimSize == 0) {
viewer.setSlot(gray, "§7§l" + name + " §8(§7" + size + "§8)", 1000);
withoutFooter = true;
} else {
viewer.setSlot(gray, "§7§l" + name + " §8(§7+" + (size - slimSize) + "§8)", 1000);
}
} else {
viewer.setSlot(gray, "§7§l" + name, 1000);
}
}
tPart.print(viewer, slim);
if (withHeaders && !withoutFooter) {
viewer.setSlot(darkGray, "", 1000);
}
}
}
}
private static class TablistServer implements TablistPart {
private static class TablistPlayer {
private final ProxiedPlayer player;
private final String defaultName;
private TablistPlayer(ProxiedPlayer player, String defaultName) {
this.player = player;
this.defaultName = defaultName;
}
}
private final List<TablistPlayer> players = new ArrayList<>();
private final ServerInfo info;
private final Subserver subserver;
private TablistServer(ServerInfo info, FightInfoPacket packet){
this.info = info;
subserver = Subserver.getSubserver(info);
Collection<ProxiedPlayer> onlinePlayers = info.getPlayers();
addPlayers(packet.getBlueName().substring(0, 2), packet.getBluePlayers(), onlinePlayers);
addPlayers(packet.getRedName().substring(0, 2), packet.getRedPlayers(), onlinePlayers);
addPlayers("§7", packet.getSpectators(), onlinePlayers);
}
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
teamPlayers.stream().map(SteamwarUser::get).map(
user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUuid())).findAny()
).filter(Optional::isPresent).map(Optional::get).sorted(
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
).forEachOrdered(player -> players.add(new TablistPlayer(player, prefix + player.getName())));
}
private TablistServer(ServerInfo info) {
this.info = info;
subserver = Subserver.getSubserver(info);
info.getPlayers().forEach(player -> players.add(new TablistPlayer(player, SteamwarUser.get(player.getUniqueId()).getUserGroup().getColorCode() + player.getName())));
players.sort((tp1, tp2) -> tp1.player.getName().compareToIgnoreCase(tp2.player.getName()));
}
private boolean displaySlim(ProxiedPlayer viewer, ProxiedPlayer player){
if(viewer.getServer().getInfo() == info)
return true;
if(subserver != null && subserver.getType() == Servertype.ARENA && info.getPlayers().size() == 1)
return true;
SteamwarUser user = SteamwarUser.get(player);
if(user.getUserGroup() != UserGroup.Member)
return true;
return user.getTeam() != 0 && SteamwarUser.get(viewer).getTeam() == user.getTeam();
}
@Override
public int size() {
return players.size();
}
@Override
public int slimSize(ProxiedPlayer viewer) {
if(viewer.getServer().getInfo() == info)
return size();
return players.stream().mapToInt(player -> displaySlim(viewer, player.player) ? 1 : 0).sum();
}
@Override
public String name() {
return info.getName();
}
@Override
public void print(Tablist viewer, boolean slim) {
boolean sameServer = viewer.player.getServer().getInfo() == info;
SteamwarUser user = SteamwarUser.get(viewer.player.getUniqueId());
for(TablistPlayer player : players){
if(slim && !displaySlim(viewer.player, player.player))
continue;
int ping = sameServer ? 1 : 1000;
String name = player.defaultName.startsWith("§7") && user.getTeam() != 0 && user.getTeam() == SteamwarUser.get(player.player.getUniqueId()).getTeam() ? "§f" + player.player.getName() : player.defaultName;
viewer.setSlot(BungeeTabListPlusAPI.getIconFromPlayer(player.player), name, ping);
}
}
}
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.commands.TeamCommand; import de.steamwar.bungeecore.commands.TeamCommand;
import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.network.packets.NetworkPacket; import de.steamwar.network.packets.NetworkPacket;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
@ -51,6 +52,6 @@ public class NetworkReceiver extends BasicListener {
if(!(event.getSender() instanceof Server)) if(!(event.getSender() instanceof Server))
return; return;
NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData()); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> NetworkPacket.handle(new ServerMetaInfo(((Server) event.getSender()).getInfo()), event.getData()));
} }
} }

Datei anzeigen

@ -19,10 +19,9 @@
package de.steamwar.bungeecore.network.handlers; package de.steamwar.bungeecore.network.handlers;
import de.steamwar.bungeecore.listeners.TablistManager;
import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.network.ServerMetaInfo; import de.steamwar.bungeecore.network.ServerMetaInfo;
import de.steamwar.bungeecore.tablist.TablistManager;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;

Datei anzeigen

@ -41,6 +41,7 @@ public class Event {
private final boolean publicSchemsOnly; private final boolean publicSchemsOnly;
private final boolean spectateSystem; private final boolean spectateSystem;
private final Timestamp deadline; private final Timestamp deadline;
private final String schemType;
private static Event current = null; private static Event current = null;
@ -53,6 +54,7 @@ public class Event {
this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly"); this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly");
this.spectateSystem = rs.getBoolean("SpectateSystem"); this.spectateSystem = rs.getBoolean("SpectateSystem");
this.deadline = rs.getTimestamp("Deadline"); this.deadline = rs.getTimestamp("Deadline");
this.schemType = rs.getString("SchemType");
} }
public static Event get(){ public static Event get(){
@ -123,4 +125,7 @@ public class Event {
public Timestamp getDeadline() { public Timestamp getDeadline() {
return deadline; return deadline;
} }
public String getSchemType() {
return schemType;
}
} }

Datei anzeigen

@ -27,10 +27,12 @@ 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.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
public class SchematicType { public class SchematicType {
public static final SchematicType Normal = new SchematicType("Normal", "", null, Type.NORMAL, null); //Has to stay publicly availible public static final SchematicType Normal = new SchematicType("Normal", "", null, Type.NORMAL, null, null); //Has to stay publicly availible
private static final Map<String, SchematicType> fromDB; private static final Map<String, SchematicType> fromDB;
private static final Map<SchematicType, SchematicType> fightType; private static final Map<SchematicType, SchematicType> fightType;
@ -68,13 +70,26 @@ public class SchematicType {
SchematicType checktype = null; SchematicType checktype = null;
if(!config.getStringList("CheckQuestions").isEmpty()) { if(!config.getStringList("CheckQuestions").isEmpty()) {
checktype = new SchematicType("C" + type, "C" + shortcut, material, Type.CHECK_TYPE, null); checktype = new SchematicType("C" + type, "C" + shortcut, material, Type.CHECK_TYPE, null, null);
tmpTypes.add(checktype); tmpTypes.add(checktype);
tmpFromDB.put(checktype.toDB(), checktype); tmpFromDB.put(checktype.toDB(), checktype);
CheckCommand.setCheckQuestions(checktype, config); CheckCommand.setCheckQuestions(checktype, config);
} }
SchematicType current = new SchematicType(type, shortcut, material, config.getKeys().contains("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype); Date deadline;
String deadlineString = config.getString("deadline", null);
if (deadlineString != null) {
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
deadline = dateFormat.parse(deadlineString);
} catch (ParseException e) {
throw new SecurityException(e.getMessage(), e);
}
} else {
deadline = null;
}
SchematicType current = new SchematicType(type, shortcut, material, config.getKeys().contains("Server") ? Type.FIGHT_TYPE : Type.NORMAL, checktype, deadline);
if(checktype != null) if(checktype != null)
tmpFightType.put(checktype, current); tmpFightType.put(checktype, current);
tmpFromDB.put(type.toLowerCase(), current); tmpFromDB.put(type.toLowerCase(), current);
@ -91,13 +106,15 @@ public class SchematicType {
private final String material; private final String material;
private final Type type; private final Type type;
private final SchematicType checkType; private final SchematicType checkType;
private final Date deadline;
private SchematicType(String name, String kuerzel, String material, Type type, SchematicType checkType){ private SchematicType(String name, String kuerzel, String material, Type type, SchematicType checkType, Date deadline){
this.name = name; this.name = name;
this.kuerzel = kuerzel; this.kuerzel = kuerzel;
this.material = material != null && !"".equals(material) ? material : "STONE_BUTTON"; this.material = material != null && !"".equals(material) ? material : "STONE_BUTTON";
this.type = type; this.type = type;
this.checkType = checkType; this.checkType = checkType;
this.deadline = deadline;
} }
public boolean isAssignable(){ public boolean isAssignable(){
@ -140,6 +157,10 @@ public class SchematicType {
return name.toLowerCase(); return name.toLowerCase();
} }
public Date deadline() {
return deadline;
}
public static SchematicType fromDB(String input){ public static SchematicType fromDB(String input){
return fromDB.getOrDefault(input.toLowerCase(), null); return fromDB.getOrDefault(input.toLowerCase(), null);
} }

Datei anzeigen

@ -0,0 +1,273 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.tablist;
import de.steamwar.bungeecore.Storage;
import de.steamwar.messages.ChatSender;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.md_5.bungee.ServerConnection;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.PacketWrapper;
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.Team;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@ChannelHandler.Sharable
public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
private static final UUID[] uuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new);
private static final String[] names = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new);
private static final String TAB_TEAM = "»SW-Tab";
private static final Team teamPacket = new Team(TAB_TEAM, (byte) 0, ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), ComponentSerializer.toString(TextComponent.fromLegacyText("")), "always", "always", 21, (byte)0x00, names);
private final Map<UUID, PlayerListItem.Item> directTabItems;
private final Set<UUID> npcs = new HashSet<>();
private final List<PlayerListItem.Item> current = new ArrayList<>();
private final ProxiedPlayer player;
private final ChatSender viewer;
private ServerConnection connection;
public Tablist(ProxiedPlayer player) {
this.player = player;
this.viewer = ChatSender.of(player);
this.directTabItems = Storage.directTabItems.computeIfAbsent(player, p -> new HashMap<>());
onServerSwitch();
}
public void update(TablistPart global, int seconds) {
if (connection == null)
return;
player.unsafe().sendPacket(new PlayerListHeaderFooter(
ComponentSerializer.toString(header(viewer, seconds)),
ComponentSerializer.toString(viewer.parse(false, "TABLIST_FOOTER", connection.getInfo().getName(), ping(), ProxyServer.getInstance().getPlayers().size()))
));
List<TablistPart.Item> tablist = new ArrayList<>();
List<TablistPart.Item> direct = new ArrayList<>();
global.print(viewer, player, tablist, direct);
// NPC handling
List<String> addNpc = new ArrayList<>();
List<String> removeNpc = new ArrayList<>();
List<PlayerListItem.Item> update = new ArrayList<>();
Set<UUID> nonNPCs = direct.stream().map(TablistPart.Item::getUuid).collect(Collectors.toSet());
synchronized (directTabItems) {
for (TablistPart.Item item : direct) {
PlayerListItem.Item tabItem = directTabItems.get(item.getUuid());
if(npcs.remove(item.getUuid()))
removeNpc.add(tabItem.getUsername());
if(tabItem == null) {
tablist.add(0, item);
} else if(!tabItem.getDisplayName().equals(item.getDisplayName())) {
tabItem.setDisplayName(item.getDisplayName());
update.add(tabItem);
}
}
for(PlayerListItem.Item item : directTabItems.values()) {
if(!nonNPCs.contains(item.getUuid()) && !npcs.contains(item.getUuid())) {
npcs.add(item.getUuid());
addNpc.add(item.getUsername());
}
}
}
sendNpcPacket(addNpc, false);
sendNpcPacket(removeNpc, true);
// Main list handling
int i = 0;
List<PlayerListItem.Item> add = new ArrayList<>();
for (; i < tablist.size() && i < 80; i++) {
PlayerListItem.Item tabItem;
if(current.size() > i) {
tabItem = current.get(i);
} else {
tabItem = new PlayerListItem.Item();
tabItem.setUuid(uuids[i]);
tabItem.setUsername(names[i]);
tabItem.setGamemode(1);
tabItem.setPing(1000);
current.add(tabItem);
}
TablistPart.Item item = tablist.get(i);
if(!Arrays.equals(tabItem.getProperties(), item.getProperties())) {
tabItem.setProperties(item.getProperties());
tabItem.setDisplayName(item.getDisplayName());
add.add(tabItem);
} else if(!item.getDisplayName().equals(tabItem.getDisplayName())) {
tabItem.setDisplayName(item.getDisplayName());
update.add(tabItem);
}
}
sendTabPacket(update, PlayerListItem.Action.UPDATE_DISPLAY_NAME);
sendTabPacket(add, PlayerListItem.Action.ADD_PLAYER);
// Excess removal
List<PlayerListItem.Item> remove = new ArrayList<>();
while(i < current.size()) {
remove.add(current.remove(i));
}
sendTabPacket(remove, PlayerListItem.Action.REMOVE_PLAYER);
}
public void onServerSwitch() {
connection = (ServerConnection) player.getServer();
synchronized (directTabItems) {
sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true);
directTabItems.clear();
npcs.clear();
}
if(connection != null) {
ChannelPipeline pipeline = connection.getCh().getHandle().pipeline();
if(pipeline.get("steamwar-tablist") != null) //Catch unclean exit
pipeline.remove("steamwar-tablist");
pipeline.addBefore(PipelineUtils.BOSS_HANDLER, "steamwar-tablist", this);
player.unsafe().sendPacket(teamPacket);
}
}
public void disable() {
sendTabPacket(current, PlayerListItem.Action.REMOVE_PLAYER);
current.clear();
synchronized (directTabItems) {
sendNpcPacket(npcs.stream().map(npc -> directTabItems.get(npc).getUsername()).collect(Collectors.toList()), true);
npcs.clear();
}
if(connection != null)
connection.getCh().getHandle().pipeline().remove(this);
}
@Override
protected void decode(ChannelHandlerContext ctx, PacketWrapper packetWrapper, List<Object> out) {
if(!connection.isObsolete()) {
DefinedPacket packet = packetWrapper.packet;
if(packet instanceof PlayerListHeaderFooter) {
packetWrapper.trySingleRelease();
return;
}
if(packet instanceof PlayerListItem) {
PlayerListItem list = (PlayerListItem) packet;
PlayerListItem.Action action = list.getAction();
switch(action) {
case UPDATE_LATENCY:
case UPDATE_DISPLAY_NAME:
packetWrapper.trySingleRelease();
return;
case UPDATE_GAMEMODE:
for (PlayerListItem.Item item : list.getItems()) {
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(item.getUuid());
if(p != null && p != player && item.getGamemode() == 3) {
item.setGamemode(1);
}
}
break;
case ADD_PLAYER:
for (PlayerListItem.Item item : list.getItems()) {
item.setPing(1);
item.setDisplayName(ComponentSerializer.toString(TextComponent.fromLegacyText("")));
if(!player.getUniqueId().equals(item.getUuid()) && item.getGamemode() == 3)
item.setGamemode(1);
synchronized (directTabItems) {
directTabItems.put(item.getUuid(), item);
}
}
break;
case REMOVE_PLAYER:
List<String> names = new ArrayList<>();
for(PlayerListItem.Item item : list.getItems()) {
synchronized (directTabItems) {
PlayerListItem.Item directItem = directTabItems.remove(item.getUuid());
if(npcs.remove(item.getUuid()))
names.add(directItem.getUsername());
}
}
sendNpcPacket(names, true);
break;
}
}
}
out.add(packetWrapper);
}
private void sendTabPacket(List<PlayerListItem.Item> items, PlayerListItem.Action action) {
if(!items.isEmpty()) {
PlayerListItem packet = new PlayerListItem();
packet.setAction(action);
packet.setItems(items.toArray(new PlayerListItem.Item[0]));
player.unsafe().sendPacket(packet);
}
}
private void sendNpcPacket(List<String> names, boolean remove) {
if(!names.isEmpty()) {
Team packet = new Team(TAB_TEAM);
packet.setMode((byte) (remove ? 4 : 3));
packet.setPlayers(names.toArray(new String[0]));
player.unsafe().sendPacket(packet);
}
}
private BaseComponent[] header(ChatSender p, int seconds) {
int phase = (seconds % 16) / 3;
switch (phase) {
case 0:
return p.parse(false, "TABLIST_PHASE_1");
case 1:
return p.parse(false, "TABLIST_PHASE_2");
default:
return p.parse(false, "TABLIST_PHASE_DEFAULT");
}
}
private String ping() {
int ping = player.getPing();
if (ping < 50) {
return "§a" + ping;
} else if (ping < 150) {
return "§e" + ping;
} else {
return "§c" + ping;
}
}
}

Datei anzeigen

@ -0,0 +1,69 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.tablist;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class TablistBuild implements TablistPart {
private final List<ServerInfo> servers = new ArrayList<>();
private final Map<ServerInfo, List<Item>> players = new HashMap<>();
public TablistBuild() {
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
Subserver subserver = Subserver.getSubserver(server);
if(server.getPlayers().isEmpty() || subserver == null || subserver.getType() != Servertype.BAUSERVER)
continue;
servers.add(server);
players.put(server, server.getPlayers().stream().sorted(((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()))).map(Item::new).collect(Collectors.toList()));
}
servers.sort((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName()));
}
@Override
public String sortKey() {
return "Build";
}
@Override
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
ServerInfo server = player.getServer().getInfo();
if(players.keySet().stream().anyMatch(info -> server != info)) {
tablist.add(new Item(null, "", TablistServer.GRAY));
tablist.add(new Item(null, viewer.parseToLegacy("TABLIST_BAU"), TablistServer.LIGHT_GRAY));
}
for(ServerInfo info : servers) {
(server == info ? direct : tablist).addAll(players.get(info));
}
}
}

Datei anzeigen

@ -0,0 +1,45 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.tablist;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.List;
public class TablistGroup implements TablistPart {
private final List<TablistPart> sublists;
public TablistGroup(List<TablistPart> sublists) {
this.sublists = sublists;
}
@Override
public String sortKey() {
return "";
}
@Override
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
for (TablistPart sublist : sublists) {
sublist.print(viewer, player, tablist, direct);
}
}
}

Datei anzeigen

@ -0,0 +1,107 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.tablist;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Storage;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.network.packets.common.FightInfoPacket;
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.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class TablistManager extends BasicListener {
private static final Map<ServerInfo, FightInfoPacket> fightInfos = new HashMap<>();
public static synchronized void newFightInfo(ServerInfo info, FightInfoPacket packet) {
fightInfos.put(info, packet);
fightInfos.keySet().removeIf(serverInfo -> serverInfo.getPlayers().isEmpty());
}
private final Map<ProxiedPlayer, Tablist> tablists = new HashMap<>();
private int seconds = 0;
public TablistManager() {
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::updateTablist, 1, 1, TimeUnit.SECONDS);
ProxyServer.getInstance().getPlayers().forEach(player -> tablists.put(player, new Tablist(player)));
}
@EventHandler
public void onJoin(PostLoginEvent event) {
synchronized (tablists) {
tablists.put(event.getPlayer(), new Tablist(event.getPlayer()));
}
}
@EventHandler
public void onServerConnection(ServerSwitchEvent event) {
synchronized (tablists) {
tablists.get(event.getPlayer()).onServerSwitch();
}
}
@EventHandler
public void onLeave(PlayerDisconnectEvent event) {
synchronized (tablists) {
tablists.remove(event.getPlayer());
Storage.directTabItems.remove(event.getPlayer());
}
}
public void disable() {
synchronized (tablists) {
tablists.forEach((player, tablist) -> tablist.disable());
tablists.clear();
}
}
private void updateTablist() {
List<TablistPart> subservers = new ArrayList<>();
for (ServerInfo server : ProxyServer.getInstance().getServersCopy().values()){
if(server.getPlayers().isEmpty())
continue;
Subserver subserver = Subserver.getSubserver(server);
if(fightInfos.containsKey(server))
subservers.add(new TablistServer(server, fightInfos.get(server)));
else if(subserver == null || subserver.getType() != Servertype.BAUSERVER)
subservers.add(new TablistServer(server));
}
subservers.add(new TablistBuild());
subservers.sort((s1, s2) -> s1.sortKey().compareToIgnoreCase(s2.sortKey()));
TablistPart global = new TablistGroup(subservers);
synchronized (tablists) {
tablists.forEach((player, tablist) -> tablist.update(global, seconds));
}
seconds++;
}
}

Datei anzeigen

@ -0,0 +1,75 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.tablist;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.protocol.Property;
import java.util.List;
import java.util.UUID;
interface TablistPart {
String sortKey();
void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct);
class Item {
public static Property[] playerProperties(ProxiedPlayer player) {
return ((InitialHandler) player.getPendingConnection()).getLoginProfile().getProperties();
}
private final UUID uuid;
private final String displayName;
private final Property[] properties;
public Item(UUID uuid, String displayName, Property[] properties) {
this.uuid = uuid;
this.displayName = reformat(displayName);
this.properties = properties;
}
public Item(ProxiedPlayer player) {
this.uuid = player.getUniqueId();
this.displayName = reformat(SteamwarUser.get(player.getUniqueId()).getUserGroup().getColorCode() + player.getName());
this.properties = playerProperties(player);
}
public UUID getUuid() {
return uuid;
}
public String getDisplayName() {
return displayName;
}
public Property[] getProperties() {
return properties;
}
private String reformat(String string) {
return ComponentSerializer.toString(TextComponent.fromLegacyText(string));
}
}
}

Datei anzeigen

@ -0,0 +1,86 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.tablist;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.common.FightInfoPacket;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.Property;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class TablistServer implements TablistPart {
public static final Property[] GRAY = new Property[]{new Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU1NzQxMTk0MzMsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzZlNzJkMzE0NzczMmQ5NzFkZWZhZTIzMWIzOGQ5NDI0MTRiMDU3YTcxNTFjNTNjNWZkNjI5NmEzYjllZGEwYWIifX19", "ro/ZKHt7278yhCr+CFTcPp/q6wAUlef//85k2DzkfRaZqy0CtGgwisDs2U4pVKvQ2pfXvitzWgbJvD0bLeQ12xWi4c1Fc29LCArosVJoFmrJDHz7N2MlstHT+ynQROb9d2aiFA6uOXfLjPKb1noUZ/YQoZjqcPIvD5oFZtD5DHV5O4hYz0IvgHbIjDqjz6ITsTcKiBlbxNg2loTFxSlW1ZfnNCO+kcAmeyB5NFY3j0e+/AqVANiNoiC3OKsECM/yEx/acf+vKWcT8mQn4wRoIGtxfEU7ZjNtgdh73NvXXBygW+K9AiJ242g8Y06Xxuk8kaNEGmT6H/mM7nbwjZmQQXpi/Pao2gYqyeIofeCPfr8RsGXoDX3nXDAw8/LyhTCHgx+sp6IQYSfGcSMJtoNeTJ0liIFxqn1V9/zKmzOZAPzR6qrQPOjoRFljLAlv7rfzotaEqh/1ldd40GdS8tstczn7f29OQerNDaqvbDb00Gy0STdUr1bVyCDptA54XKjT9WFv7QpBikEculxqSppAXPxD2Fb/ZmphbZx8WEGfG6bVFhf6fQdDAUXlcv8BxjElNPwlolF86M2KJd5VquLluhrCjwID7OK/pffNultAVH+Lxw4QOAXmJqjUrA1KHgyG1S0Cwj/f4E2hdxZJBvkfVtq9qPkd9nignhEoTCTOHf0=")};
public static final Property[] LIGHT_GRAY = new Property[]{new Property("textures", "eyJ0aW1lc3RhbXAiOjE0NTU2MjU1OTM5NjIsInByb2ZpbGVJZCI6ImIzYjE4MzQ1MzViZjRiNzU4ZTBjZGJmMGY4MjA2NTZlIiwicHJvZmlsZU5hbWUiOiIxMDExMTEiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzc4Y2I3ZmMyMDhiMzM4NTUwNGE4MTQ0MjA0NDI4ZmRjZDYzMjRiZWIzMWNhMmNlODZjYzQyNGI5NjNkODVjIn19fQ==", "R/wZUZRC1dishRdM9a2SSxxW3oYa0XSb/MxHbQpEUA791HxyqjaKLDu0wFX2r2a8ZTeVjzXpNzkg3+PkrA11o8h7lt86MTD1pi/rQqj/WRuoqf2LP+ypbssKV+LU15cYez2cj3QQVcJDXgWEnfSLNuBv6NG8BDUpUAjTWldvu99NCJHUoD0jNMHxY/fu4k5vCgOjaBaKgkjVk2bmUhegusmtMwco+3pYx+y8+gUW8ptx5SnePG+dOwTqLyBFiOt2AQ+gSvbU/jP9aAXgxOwz/b1pMaBWtzVhFU865NHlIdSpIHg/sh3uNah3a7gTgtTvxPQv1OzM/KtqYKiamsrRzAQMzRcs4A7Tp0GakLuxEaz401IwvQ7UGVYLFzGUVLB2MyqtPgifiqQSQxZpiqj9sM5QadhsUw00nfX7mTdW46U0MtNIbby1rLrvgQKoj08zt6LJlhI3yjyawy4iZkgF4oc+PCNwZc93GIbVL9LJaGkXk3RVA+JpGwfMJrGVbL7hl8ibbAcUv7uCEWdkAgZCd6w75jEE4tlhDSPDD4rXbn+FeTZRg2n/PGKtnoTZRzbniiFaNoSAHDZSVRG39xvBDFvtmL3SPaKhzKaifiYrgNn453WtR3kymqdAtPf1GN9d1VltGZ/+vMPwqPJb6thcrlcU64UGHbg1olRkiyZHvY8=")};
private final ServerInfo server;
private final List<Item> players;
public TablistServer(ServerInfo server) {
this(server, server.getPlayers().stream().sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())).map(TablistPart.Item::new).collect(Collectors.toList()));
}
public TablistServer(ServerInfo server, FightInfoPacket info) {
this(server, new ArrayList<>());
Collection<ProxiedPlayer> onlinePlayers = server.getPlayers();
addPlayers(info.getBlueName().substring(0, 2), info.getBluePlayers(), onlinePlayers);
addPlayers(info.getRedName().substring(0, 2), info.getRedPlayers(), onlinePlayers);
addPlayers("§7", info.getSpectators(), onlinePlayers);
}
public TablistServer(ServerInfo server, List<Item> players) {
this.server = server;
this.players = players;
}
@Override
public String sortKey() {
return server.getName();
}
@Override
public void print(ChatSender viewer, ProxiedPlayer player, List<Item> tablist, List<Item> direct) {
boolean onServer = player.getServer().getInfo() == server;
List<Item> items = onServer ? direct : tablist;
if(!onServer) {
items.add(new Item(null, "", GRAY));
items.add(new Item(null, "§7§l" + server.getName(), LIGHT_GRAY));
}
items.addAll(players);
}
private void addPlayers(String prefix, List<Integer> teamPlayers, Collection<ProxiedPlayer> onlinePlayers){
teamPlayers.stream().map(SteamwarUser::get).map(
user -> onlinePlayers.stream().filter(player -> player.getUniqueId().equals(user.getUuid())).findAny()
).filter(Optional::isPresent).map(Optional::get).sorted(
(p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName())
).forEachOrdered(player -> players.add(new Item(player.getUniqueId(), prefix + player.getName(), Item.playerProperties(player))));
}
}

Datei anzeigen

@ -20,7 +20,9 @@
package de.steamwar.command; package de.steamwar.command;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender; 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;
@ -29,6 +31,7 @@ import net.md_5.bungee.api.plugin.TabExecutor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.logging.Level; import java.util.logging.Level;
@ -49,17 +52,23 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
} }
protected SWCommand(String command, String permission) { protected SWCommand(String command, String permission) {
super(CommandSender.class, command); this(command, permission, new String[0]);
this.permission = permission;
} }
protected SWCommand(String command, String permission, String... aliases) { protected SWCommand(String command, String permission, String... aliases) {
super(CommandSender.class, command, aliases); super(CommandSender.class, command, aliases);
this.permission = permission; this.permission = permission;
create = true;
createAndSafeCommand(command, aliases);
unregister();
register();
} }
private boolean create = false;
@Override @Override
protected void createAndSafeCommand(String command, String[] aliases) { protected void createAndSafeCommand(String command, String[] aliases) {
if (!create) return;
this.command = new TabCompletableCommand(command, permission, aliases) { this.command = new TabCompletableCommand(command, permission, aliases) {
@Override @Override
public void execute(CommandSender commandSender, String[] strings) { public void execute(CommandSender commandSender, String[] strings) {
@ -81,11 +90,13 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
@Override @Override
public void unregister() { public void unregister() {
if (command == null) return;
CommandRegistering.unregister(this.command); CommandRegistering.unregister(this.command);
} }
@Override @Override
public void register() { public void register() {
if (command == null) return;
CommandRegistering.register(this.command); CommandRegistering.register(this.command);
} }
@ -104,6 +115,11 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
defaultHelpMessages.add(message); defaultHelpMessages.add(message);
} }
@Override
protected void sendMessage(CommandSender sender, String message, Object[] args) {
ChatSender.of(sender).system(message, args);
}
@Register(help = true) @Register(help = true)
private void internalHelp(ProxiedPlayer p, String... args) { private void internalHelp(ProxiedPlayer p, String... args) {
ChatSender chatSender = ChatSender.of(p); ChatSender chatSender = ChatSender.of(p);
@ -145,7 +161,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
for (String s : subCommand.description) { for (String s : subCommand.description) {
String hover = "§8/§e" + command.getName() + " " + String.join(" ", subCommand.subCommand); String hover = "§8/§e" + command.getName() + " " + String.join(" ", subCommand.subCommand);
String suggest = "/" + command.getName() + " " + String.join(" ", subCommand.subCommand); String suggest = "/" + command.getName() + " " + String.join(" ", subCommand.subCommand);
chatSender.prefixless(s, hover, new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, suggest)); chatSender.prefixless(s, new Message("PLAIN_STRING", hover), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, suggest));
} }
} catch (Exception e) { } catch (Exception e) {
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e); BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);

Datei anzeigen

@ -0,0 +1,25 @@
/*
* 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;
public interface TypeValidator<T> extends AbstractValidator<CommandSender, T> {
}

Datei anzeigen

@ -238,6 +238,7 @@ EVENT_NO_CURRENT=§cThere is no event taking place currently
EVENT_COMING=§eUpcoming events§8: EVENT_COMING=§eUpcoming events§8:
EVENT_COMING_EVENT=§7{0}§8-§7{1}§8: §e{2} EVENT_COMING_EVENT=§7{0}§8-§7{1}§8: §e{2}
EVENT_COMING_DEADLINE=§7 Registration deadline§8: §7{0} EVENT_COMING_DEADLINE=§7 Registration deadline§8: §7{0}
EVENT_COMING_SCHEM_DEADLINE=§7 Submission deadline§8: §7{0}
EVENT_COMING_TEAMS=§7 With§8:{0} EVENT_COMING_TEAMS=§7 With§8:{0}
EVENT_COMING_TEAM= §{0}{1} EVENT_COMING_TEAM= §{0}{1}
EVENT_CURRENT_EVENT=§e§l{0} EVENT_CURRENT_EVENT=§e§l{0}
@ -520,6 +521,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}
@ -552,7 +554,7 @@ TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
TABLIST_FOOTER=§e{0} {1}§8ms §ePlayers§8: §7{2} TABLIST_FOOTER=§e{0} {1}§8ms §ePlayers§8: §7{2}
TABLIST_BAU=Build TABLIST_BAU=§7§lBuild
LIST_COMMAND=§e{0}§8: §7{1} LIST_COMMAND=§e{0}§8: §7{1}
#EventStarter #EventStarter

Datei anzeigen

@ -222,6 +222,7 @@ EVENT_NO_CURRENT=§cDerzeit findet kein Event statt
EVENT_COMING=§eKommende Events§8: EVENT_COMING=§eKommende Events§8:
EVENT_COMING_EVENT=§7{0}§8-§7{1}§8: §e{2} EVENT_COMING_EVENT=§7{0}§8-§7{1}§8: §e{2}
EVENT_COMING_DEADLINE=§7 Anmeldeschluss§8: §7{0} EVENT_COMING_DEADLINE=§7 Anmeldeschluss§8: §7{0}
EVENT_COMING_SCHEM_DEADLINE=§7 Einsendeschluss§8: §7{0}
EVENT_COMING_TEAMS=§7 Mit§8:{0} EVENT_COMING_TEAMS=§7 Mit§8:{0}
EVENT_COMING_TEAM= §{0}{1} EVENT_COMING_TEAM= §{0}{1}
EVENT_CURRENT_EVENT=§e§l{0} EVENT_CURRENT_EVENT=§e§l{0}
@ -499,6 +500,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}
@ -531,7 +533,7 @@ TABLIST_PHASE_1=§8Teamspeak: §eSteam§8War.de
TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord TABLIST_PHASE_2=§8Discord: §8https://§eSteam§8War.de/discord
TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de TABLIST_PHASE_DEFAULT=§8Website: https://§eSteam§8War.de
TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2} TABLIST_FOOTER=§e{0} {1}§8ms §eSpieler§8: §7{2}
TABLIST_BAU=Bau TABLIST_BAU=§7§lBau
LIST_COMMAND=§e{0}§8: §7{1} LIST_COMMAND=§e{0}§8: §7{1}
#EventStarter #EventStarter

Datei anzeigen

@ -115,6 +115,10 @@ public interface ChatSender {
return parseToComponent(false, message).toLegacyText(); return parseToComponent(false, message).toLegacyText();
} }
default BaseComponent[] parse(boolean prefixed, String format, Object... params) {
return parse(prefixed, new Message(format, params));
}
default BaseComponent[] parse(boolean prefixed, Message message) { default BaseComponent[] parse(boolean prefixed, Message message) {
Locale locale = getLocale(); Locale locale = getLocale();
ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale); ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);

Datei anzeigen

@ -35,7 +35,7 @@ public class SteamwarResourceBundle extends PropertyResourceBundle {
return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null))); return getResourceBundle(locale.toString(), getResourceBundle(locale.getLanguage(), getResourceBundle( "", null)));
} }
private static ResourceBundle getResourceBundle(String locale, ResourceBundle parent) { private static synchronized ResourceBundle getResourceBundle(String locale, ResourceBundle parent) {
return bundles.computeIfAbsent(locale, locale1 -> { return bundles.computeIfAbsent(locale, locale1 -> {
InputStream inputStream = Message.class.getResourceAsStream(BASE_PATH + ("".equals(locale) ? "" : "_" + locale) + ".properties"); InputStream inputStream = Message.class.getResourceAsStream(BASE_PATH + ("".equals(locale) ? "" : "_" + locale) + ".properties");
if(inputStream == null) if(inputStream == null)

Datei anzeigen

@ -2,4 +2,5 @@ name: BungeeCore
main: de.steamwar.bungeecore.BungeeCore main: de.steamwar.bungeecore.BungeeCore
version: 1.0 version: 1.0
author: Lixfel author: Lixfel
depends: [PersistentBungeeCore, BungeeTabListPlus] depends:
- PersistentBungeeCore

Datei anzeigen

@ -1,5 +1,4 @@
build: build:
- "ln -s /home/gitea/lib"
- "cp ~/gradle.properties ." - "cp ~/gradle.properties ."
- "./gradlew buildProject" - "./gradlew buildProject"