SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'master' into tablist
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Lixfel 2022-06-16 13:34:56 +02:00
Commit 7b06c64118
30 geänderte Dateien mit 461 neuen und 532 gelöschten Zeilen

Datei anzeigen

@ -21,49 +21,28 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
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.CommandSender;
public class AlertCommand extends BasicCommand {
public class AlertCommand extends SWCommand {
public AlertCommand() {
super("alert", "bungeecore.alert", "broadcast", "bbc");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length == 0){
Message.send("USAGE_ALERT", sender);
@Register(description = "USAGE_ALERT")
public void broadcast(CommandSender sender, @OptionalValue("") @StaticValue("-discord") String sendToDiscord, String... message) {
if (message.length == 0) {
ChatSender.of(sender).system(new Message("USAGE_ALERT"));
return;
}
String s;
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);
}
String s = String.join(" ", message);
Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s));
if (discordAnnounce && SteamwarDiscordBot.instance() != null) {
if ("-discord".equals(sendToDiscord) && SteamwarDiscordBot.instance() != null) {
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

@ -19,27 +19,22 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SWException;
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;
public class BugCommand extends BasicCommand {
public class BugCommand extends SWCommand {
public BugCommand() {
super("bug", null);
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
@Register
public void bugMessage(ProxiedPlayer player, String... message) {
String server = player.getServer().getInfo().getName();
String message = String.join(" ", args);
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SWException.log(server, message, player.getName() + " " + user.getId());
Message.send("BUG_MESSAGE", player);
SWException.log(server, String.join(" ", message), player.getName() + " " + user.getId());
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.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -41,7 +42,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
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>> 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());
}
@Override
public void execute(CommandSender sender, String[] args) {
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) {
@Register(value = "list", description = "CHECK_HELP_LIST")
public void list(ProxiedPlayer player) {
List<SchematicNode> schematicList = getSchemsToCheck();
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)){
Message.send("CHECK_SCHEMATIC_ALREADY_CHECKING", player);
return;
@ -171,6 +126,57 @@ public class CheckCommand extends BasicCommand {
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){
if(!isChecking(player)){
Message.send("CHECK_NOT_CHECKING", player);
@ -184,9 +190,9 @@ public class CheckCommand extends BasicCommand {
return;
int rank = 0;
if(args.length > 1){
if(args.length > 0){
try{
rank = Integer.parseInt(args[1]);
rank = Integer.parseInt(args[0]);
}catch(NumberFormatException e){
Message.send("CHECK_INVALID_RANK", player);
return;
@ -196,37 +202,6 @@ public class CheckCommand extends BasicCommand {
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 final ProxiedPlayer checker;
private final SchematicNode schematic;

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.*;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -34,32 +35,27 @@ import java.util.HashMap;
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 Map<String, ServerInfo> devServers = new HashMap<>();
public DevCommand() {
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;
super("dev");
}
@Register
public void simpleCommand(@Guard ProxiedPlayer player) {
updateDevServers();
if(devServers.isEmpty()) {
ChatSender sender = ChatSender.of(player);
if (devServers.isEmpty()) {
sender.system("DEV_NO_SERVER");
return;
} else if (devServers.size() == 1) {
player.connect(devServers.values().stream().findAny().get());
} else if (args.length == 0) {
return;
}
ServerInfo info = devServers.get(player.getName().toLowerCase());
if (info == null) {
sender.system("DEV_UNKNOWN_SERVER");
@ -67,8 +63,13 @@ public class DevCommand extends BasicCommand {
}
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) {
sender.system("DEV_NO_SERVER");
return;
@ -76,34 +77,45 @@ public class DevCommand extends BasicCommand {
player.connect(info);
}
@ClassGuard(value = GuardChecker.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
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
if (!(sender instanceof ProxiedPlayer) || args.length > 1) {
return Collections.emptyList();
}
@Mapper(value = "dev", local = true)
public TypeMapper<String> devServers() {
return SWCommandUtils.createMapper(s -> s, s -> {
updateDevServers();
return devServers.keySet().stream().filter(s -> {
if (args.length == 0) return true;
return s.startsWith(args[0].toLowerCase());
}).collect(Collectors.toList());
return devServers.keySet();
});
}
private void updateDevServers() {
String[] serverFiles = devServerDir.list();
Map<String, Integer> devServerFiles = new HashMap<>();
if(serverFiles != null) {
for(String serverFile : serverFiles) {
if (serverFiles != null) {
for (String serverFile : serverFiles) {
String[] server = serverFile.split("\\.");
devServerFiles.put(server[0], Integer.parseInt(server[1]));
}
}
devServers.entrySet().removeIf(entry -> {
if(!devServerFiles.containsKey(entry.getKey())) {
if (!devServerFiles.containsKey(entry.getKey())) {
ProxyServer.getInstance().getServers().remove(entry.getValue().getName());
return true;
}

Datei anzeigen

@ -23,35 +23,29 @@ import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.Event;
import de.steamwar.bungeecore.sql.EventFight;
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.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date;
import java.util.List;
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() {
super("eventreschedule", "bungeecore.softreload");
}
@Override
public void execute(CommandSender sender, String[] args) {
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]);
@Register
public void reschedule(ProxiedPlayer player, Team teamBlue, Team teamRed) {
Event event = Event.get();
if(teamBlue == null || teamRed == null || event == null){
if(event == null){
Message.send("EVENTRESCHEDULE_UNKNOWN_TEAM", player);
return;
}
@ -74,4 +68,22 @@ public class EventRescheduleCommand extends BasicCommand {
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;
import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
public class EventreloadCommand extends BasicCommand {
public class EventreloadCommand extends SWCommand {
public EventreloadCommand() {
super("eventreload", "bungeecore.softreload");
}
@Override
public void execute(CommandSender sender, String[] args) {
@Register
public void execute(CommandSender sender) {
EventFight.loadAllComingFights();
}
}

Datei anzeigen

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

Datei anzeigen

@ -22,28 +22,26 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.IgnoreSystem;
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.connection.ProxiedPlayer;
public class IgnoreCommand extends BasicCommand {
import java.util.stream.Collectors;
public class IgnoreCommand extends SWCommand {
public IgnoreCommand() {
super("ignore", null);
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length < 1) {
Message.send("USAGE_IGNORE", sender);
return;
}
if (!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer p = (ProxiedPlayer) sender;
@Register(description = "USAGE_IGNORE")
public void genericCommand(ProxiedPlayer p, @Mapper("player") String toIgnore) {
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
SteamwarUser target = SteamwarUser.get(args[0]);
SteamwarUser target = SteamwarUser.get(toIgnore);
if(target == null){
Message.send("UNKNOWN_PLAYER", p);
return;
@ -60,4 +58,9 @@ public class IgnoreCommand extends BasicCommand {
IgnoreSystem.ignore(user, target);
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.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.ProxyServer;
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() {
super("kick", "bungeecore.kick");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length == 0){
Message.send("KICK_USAGE", sender);
return;
}
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
@Register(description = "KICK_USAGE")
public void genericCommand(CommandSender sender, @Mapper("player") String player, String... message) {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(player);
if(target == null){
Message.send("KICK_OFFLINE", sender);
return;
}
if(args.length == 1){
if (message.length == 0) {
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
}else{
StringBuilder msgBuilder = new StringBuilder();
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()));
} else {
target.disconnect(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
}
Message.send("KICK_CONFIRM", sender, target.getName());
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1)
return allPlayers(args[0]);
return new ArrayList<>();
@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

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

Datei anzeigen

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

Datei anzeigen

@ -21,34 +21,23 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.command.SWCommand;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;
import static de.steamwar.bungeecore.Storage.lastChats;
public class MsgCommand extends BasicCommand {
public class MsgCommand extends SWCommand {
public MsgCommand() {
super("msg", "", "w", "tell");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
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));
@Register(description = "MSG_USAGE")
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, String... message) {
msg(sender, target, message);
}
public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) {
@ -69,14 +58,6 @@ public class MsgCommand extends BasicCommand {
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){
lastChats.remove(player);
}

Datei anzeigen

@ -20,20 +20,17 @@
package de.steamwar.bungeecore.commands;
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;
public class PingCommand extends BasicCommand {
public class PingCommand extends SWCommand {
public PingCommand() {
super("ping", "");
super("ping");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender;
@Register
public void genericCommand(ProxiedPlayer player) {
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.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.apache.commons.lang3.LocaleUtils;
@ -29,21 +30,18 @@ import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
public class PlaytimeCommand extends BasicCommand{
public class PlaytimeCommand extends SWCommand {
public PlaytimeCommand() {
super("playtime", null);
super("playtime");
}
@Override
public void execute(CommandSender sender, String[] strings) {
if(!(sender instanceof ProxiedPlayer))
return;
NumberFormat format = NumberFormat.getNumberInstance(((ProxiedPlayer)sender).getLocale());
@Register
public void genericCommand(ProxiedPlayer player) {
NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
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.sql.PollAnswer;
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.connection.ProxiedPlayer;
public class PollCommand extends BasicCommand {
public class PollCommand extends SWCommand {
public PollCommand() {
super("poll", "");
super("poll");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(PollSystem.noCurrentPoll()){
Message.send("POLL_NO_POLL", player);
return;
}
if(args.length == 0){
@Register
public void genericCommand(@Guard ProxiedPlayer player) {
PollSystem.sendPoll(player);
return;
}
@Register(noTabComplete = true)
public void answerPoll(@Guard ProxiedPlayer player, String answerString) {
int answer;
try {
answer = Integer.parseUnsignedInt(args[0]);
answer = Integer.parseUnsignedInt(answerString);
if(answer < 1 || answer > PollSystem.answers())
throw new NumberFormatException();
}catch(NumberFormatException e){
@ -67,4 +61,17 @@ public class PollCommand extends BasicCommand {
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.listeners.PollSystem;
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 java.util.Map;
public class PollresultCommand extends BasicCommand {
public class PollresultCommand extends SWCommand {
public PollresultCommand() {
super("pollresult", "bungeecore.pollresults");
}
@Override
public void execute(CommandSender sender, String[] strings) {
if(!(sender instanceof ProxiedPlayer))
return;
if(PollSystem.noCurrentPoll()) {
Message.send("POLLRESULT_NOPOLL", sender);
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
@Register
public void genericCommand(@Guard ProxiedPlayer player) {
Map<String, Integer> voted = PollAnswer.getCurrentResults();
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion());
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.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -34,65 +35,67 @@ import java.util.Date;
public class PunishmentCommand {
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
new BasicCommand(command, "bungeecore.ban") {
@Override
public void execute(CommandSender sender, String[] args) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) {
return;
}
if (args.length < 3) {
Message.send("PUNISHMENT_USAGE", sender, command);
new SWCommand(command, "bungeecore.ban") {
@Register(description = "PUNISHMENT_USAGE")
public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
return;
}
SteamwarUser target = unsafeUser(sender, args[0]);
SteamwarUser target = unsafeUser(player, toPunish);
if (target == null)
return;
Timestamp banTime = parseTime(sender, args[1]);
Timestamp banTime = parseTime(player, date);
if (banTime == null)
return;
StringBuilder reason = new StringBuilder();
for (int i = 2; i < args.length; i++) {
reason.append(args[i]).append(" ");
}
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);
boolean isPerma = date.equalsIgnoreCase("perma");
String msg = String.join(" ", message);
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);
}
};
if (punishmentType.getUnpunishmentMessage() == null) {
return;
}
String antiCommand = "un" + command;
new BasicCommand(antiCommand, "bungeecore.ban") {
@Override
public void execute(CommandSender sender, String[] args) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get((ProxiedPlayer) sender).getUserGroup().isAdminGroup()) {
return;
}
if (args.length < 1) {
Message.send("UNPUNISHMENT_USAGE", sender, antiCommand);
new SWCommand(antiCommand, "bungeecore.ban") {
@Register(description = "PUNISHMENT_USAGE")
public void genericCommand(ProxiedPlayer player, String toUnpunish) {
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
return;
}
SteamwarUser target = existingUser(sender, args[0]);
SteamwarUser target = existingUser(player, toUnpunish);
if (target == null)
return;
if (!target.isPunished(punishmentType)) {
Message.send(punishmentType.getUsageNotPunished(), sender);
Message.send(punishmentType.getUsageNotPunished(), player);
return;
}
Message.send(punishmentType.getUnpunishmentMessage(), sender, target.getUserName());
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(sender.getName()).getId(), false);
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
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) {
if (arg.equalsIgnoreCase("perma")) {
return Punishment.PERMA_TIME;

Datei anzeigen

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

Datei anzeigen

@ -23,32 +23,36 @@ import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.SteamwarUser;
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.connection.ProxiedPlayer;
import java.util.Optional;
import java.util.stream.Collectors;
public class RankCommand extends BasicCommand {
public class RankCommand extends SWCommand {
public RankCommand() {
super("rank", null);
super("rank");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
@Register
public void ownRank(ProxiedPlayer player) {
rank(player, player.getName());
}
ProxiedPlayer player = (ProxiedPlayer) sender;
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (args.length > 0) {
SteamwarUser nUser = SteamwarUser.get(args[0]);
if (nUser == null) {
@Register
public void rank(ProxiedPlayer player, @Mapper("player") String s) {
SteamwarUser user = SteamwarUser.get(s);
if (user == null) {
Message.send("RANK_PLAYER_NOT_FOUND", player);
return;
}
Message.send("RANK_PLAYER_FOUND", player, nUser.getUserName());
user = nUser;
if (!player.getName().equals(s)) {
Message.send("RANK_PLAYER_FOUND", player, user.getUserName());
}
for(ArenaMode mode : ArenaMode.getAllModes()) {
if (!mode.isRanked())
@ -67,4 +71,9 @@ public class RankCommand extends BasicCommand {
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;
import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class RegelnCommand extends BasicCommand {
public class RegelnCommand extends SWCommand {
public RegelnCommand() {
super("regeln", null);
super("regeln");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
@Register
public void genericCommand(ProxiedPlayer 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_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.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -35,18 +36,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ReplayCommand extends BasicCommand {
public class ReplayCommand extends SWCommand {
public ReplayCommand() {
super("replay", null);
super("replay");
}
@Override
public void execute(CommandSender s, String[] args) {
if(!(s instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) s;
@Register
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
ChatSender sender = ChatSender.of(player);
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
return;
@ -57,8 +54,8 @@ public class ReplayCommand extends BasicCommand {
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
String map = mode.getRandomMap();
if (args.length > 0) {
String tMap = mode.hasMap(args[0]);
if (!optionalMap.equals("")) {
String tMap = mode.hasMap(optionalMap);
if (tMap != null) map = tMap;
}

Datei anzeigen

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

Datei anzeigen

@ -20,23 +20,24 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
public class ServerTeamchatCommand extends BasicCommand {
public class ServerTeamchatCommand extends SWCommand {
public ServerTeamchatCommand() {
super("stc", "bungeecore.teamchat","serverteamchat");
}
@Override
public void execute(CommandSender s, String[] args) {
ChatSender sender = ChatSender.of(s);
if(args.length == 0) {
@Register(description = "STC_USAGE")
public void genericCommand(CommandSender commandSender, String... message) {
ChatSender sender = ChatSender.of(commandSender);
if(message.length == 0) {
sender.system("STC_USAGE");
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;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Objects;
public class SetLocaleCommand extends BasicCommand {
public class SetLocaleCommand extends SWCommand {
public SetLocaleCommand() {
super("setlocale", null, "setlanguage");
}
@Override
public void execute(CommandSender s, String[] strings) {
if (!(s instanceof ProxiedPlayer))
return;
ChatSender sender = ChatSender.of(s);
sender.user().setLocale(Objects.requireNonNull(((ProxiedPlayer) s).getLocale()), true);
@Register
public void genericCommand(ProxiedPlayer player) {
ChatSender sender = ChatSender.of(player);
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
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.Node;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.CommandSender;
import java.io.BufferedReader;
@ -28,14 +29,14 @@ import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class StatCommand extends BasicCommand {
public class StatCommand extends SWCommand {
public StatCommand() {
super("stat", "bungeecore.softreload", "stats");
}
@Override
public void execute(CommandSender sender, String[] args) {
@Register
public void genericCommand(CommandSender sender) {
Map<String, Integer> serverCount = new HashMap<>();
try {
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)));
}
}

Datei anzeigen

@ -26,7 +26,9 @@ import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.bungeecore.inventory.SWStreamInv;
import de.steamwar.bungeecore.sql.SteamwarUser;
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.connection.ProxiedPlayer;
@ -38,38 +40,26 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class TutorialCommand extends BasicCommand {
public class TutorialCommand extends SWCommand {
public TutorialCommand() {
super("tutorial", null);
addDefaultHelpMessage("TUTORIAL_CREATE_HELP");
addDefaultHelpMessage("TUTORIAL_OWN_HELP");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0) {
@Register
public void genericCommand(ProxiedPlayer player) {
openInventory(player, true, false);
return;
}
switch(args[0].toLowerCase()) {
case "rate":
if(args.length < 2) {
@Register("rate")
public void rate(ProxiedPlayer player) {
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);
if(tutorial == null) {
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with nonexistent id: " + id);
@ -77,27 +67,36 @@ public class TutorialCommand extends BasicCommand {
}
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());
break;
case "own":
@Register(value = "create", description = "TUTORIAL_CREATE_HELP")
public void create(ProxiedPlayer player, String material, String... name) {
create(player, String.join(" ", name), material.toUpperCase());
}
@Register("own")
public void own(ProxiedPlayer player) {
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);
break;
}
default:
Message.send("TUTORIAL_CREATE_HELP", player);
Message.send("TUTORIAL_OWN_HELP", player);
@Guard("unreleased")
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) {

Datei anzeigen

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

Datei anzeigen

@ -23,27 +23,25 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.bot.AuthManager;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import jdk.nashorn.internal.runtime.Property;
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;
public class VerifyCommand extends BasicCommand {
public class VerifyCommand extends SWCommand {
public VerifyCommand() {
super("verify", "");
}
@Override
public void execute(CommandSender sender, String[] strings) {
if(strings.length < 1) {
Message.send("VERIFY_USAGE", sender);
return;
super("verify");
}
@Register(description = "VERIFY_USAGE")
public void genericCommand(ProxiedPlayer sender, String code) {
byte[] bytes;
try {
bytes = Base64.getDecoder().decode(strings[0]);
bytes = Base64.getDecoder().decode(code);
} catch (IllegalArgumentException e) {
Message.send("VERIFY_INVALID", sender);
return;
@ -54,7 +52,7 @@ public class VerifyCommand extends BasicCommand {
return;
}
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) {
BungeeCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
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.sql.SWException;
import net.md_5.bungee.api.CommandSender;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WebregisterCommand extends BasicCommand {
public class WebregisterCommand extends SWCommand {
public WebregisterCommand() {
super("webregister", null, "web", "webpw");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
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]);
@Register(description = "WEB_USAGE")
public void genericCommand(ProxiedPlayer player, String email) {
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), email);
pb.redirectErrorStream(true);
try {
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.SteamwarUser;
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.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -32,50 +36,44 @@ import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class WhoisCommand extends BasicCommand {
public WhoisCommand(){
public class WhoisCommand extends SWCommand {
public WhoisCommand() {
super("whois", "bungeecore.teamchat");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){
Message.send("WHOIS_USAGE", player);
return;
}
SteamwarUser user = SteamwarUser.get(args[0]);
if(user == null){
@Register("WHOIS_USAGE")
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue({"-all", "-a", ""}) String displayAll) {
SteamwarUser user = SteamwarUser.get(target);
if (user == null) {
try {
int id = Integer.parseInt(args[0]);
int id = Integer.parseInt(target);
user = SteamwarUser.get(id);
}catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
}
}
if (user == null) {
try {
long id = Long.parseLong(args[0]);
long id = Long.parseLong(target);
user = SteamwarUser.get(id);
} catch (NumberFormatException ignored) {
// Ignored
}
}
if(user == null) {
if (user == null) {
Message.send("UNKNOWN_PLAYER", player);
return;
}
boolean all = false;
if(args.length > 1 && args[1].startsWith("-")) {
all = args[1].contains("a");
boolean all = displayAll.contains("-");
sendUserinfo(player, user, all);
}
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) {
@ -86,7 +84,7 @@ public class WhoisCommand extends BasicCommand {
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
}
Timestamp firstJoin = user.getFirstjoin();
if(firstJoin == null)
if (firstJoin == null)
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
else
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());