geforkt von SteamWar/BungeeCore
Merge branch 'master' into tablist
Dieser Commit ist enthalten in:
Commit
7b06c64118
@ -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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -21,6 +21,7 @@ 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.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -34,32 +35,27 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
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 +63,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 +77,45 @@ public class DevCommand extends BasicCommand {
|
|||||||
|
|
||||||
player.connect(info);
|
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
|
@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;
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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, 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);
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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, 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)));
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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,26 @@ 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);
|
||||||
|
addDefaultHelpMessage("TUTORIAL_CREATE_HELP");
|
||||||
|
addDefaultHelpMessage("TUTORIAL_OWN_HELP");
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 +67,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) {
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,27 +23,25 @@ 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 jdk.nashorn.internal.runtime.Property;
|
||||||
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.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 +52,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());
|
||||||
|
@ -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();
|
||||||
|
@ -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("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());
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren