diff --git a/build.gradle b/build.gradle index dd9ed88..789fc21 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ dependencies { compileOnly 'de.steamwar:waterfall:RELEASE' compileOnly 'de.steamwar:persistentbungeecore:RELEASE' - implementation("net.dv8tion:JDA:4.3.0_299") { + implementation("net.dv8tion:JDA:4.4.0_352") { exclude module: 'opus-java' } diff --git a/src/de/steamwar/bungeecore/ArenaMode.java b/src/de/steamwar/bungeecore/ArenaMode.java index 9057691..abb6b77 100644 --- a/src/de/steamwar/bungeecore/ArenaMode.java +++ b/src/de/steamwar/bungeecore/ArenaMode.java @@ -94,6 +94,7 @@ public class ArenaMode { private final String serverJar; private final String config; private final List maps; + private final Map lowerToRealMapNames = new HashMap<>(); private final boolean historic; private final String internalName; @@ -106,6 +107,7 @@ public class ArenaMode { this.serverJar = config.getString("Server.ServerJar"); this.config = internalName + ".yml"; this.maps = config.getStringList("Server.Maps"); + maps.forEach(map -> lowerToRealMapNames.put(map.toLowerCase(), map)); this.displayName = config.getString("GameName", internalName); this.chatNames = config.getStringList("Server.ChatNames"); this.schemType = config.getString("Schematic.Type", "").toLowerCase(); @@ -155,6 +157,10 @@ public class ArenaMode { return maps; } + public String convertToRealMapName(String map){ + return lowerToRealMapNames.get(map.toLowerCase()); + } + public String getChatName(){ return chatNames.get(0); } diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java index 8f55731..c458e07 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java @@ -25,6 +25,9 @@ import de.steamwar.bungeecore.sql.SteamwarUser; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; + public class PrivateMessageListener extends BasicDiscordListener { @Override @@ -63,7 +66,9 @@ public class PrivateMessageListener extends BasicDiscordListener { } try { - node.saveFromStream(attachment.retrieveInputStream().get(), newFormat); + InputStream in = attachment.retrieveInputStream().get(); + node.saveFromStream(in, newFormat); + in.close(); event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue(); } catch (Exception e) { event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue(); diff --git a/src/de/steamwar/bungeecore/commands/TypeMappers.java b/src/de/steamwar/bungeecore/commands/TypeMappers.java index 94b27e4..3539a0d 100644 --- a/src/de/steamwar/bungeecore/commands/TypeMappers.java +++ b/src/de/steamwar/bungeecore/commands/TypeMappers.java @@ -79,9 +79,7 @@ public class TypeMappers { public String map(CommandSender commandSender, String[] previousArguments, String s) { if (previousArguments.length == 0) return null; if (s.equalsIgnoreCase("random")) return "random"; - ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]); - if (arenaMode.getMaps().contains(s)) return s; - return null; + return ArenaMode.getByChat(previousArguments[previousArguments.length - 1]).convertToRealMapName(s); } @Override diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java index 9e25ad2..bf016c3 100644 --- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; @@ -31,8 +32,10 @@ import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; +import java.net.InetSocketAddress; import java.sql.Timestamp; import java.text.DecimalFormat; +import java.time.Instant; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -78,15 +81,24 @@ public class WhoisCommand extends SWCommand { Message.send("WHOIS_USERNAME", player, user.getUserName()); Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString()); Message.send("WHOIS_ID", player, user.getId()); + Message.send("WHOIS_GROUP", player, user.getUserGroup().getColorCode(), user.getUserGroup().name()); if (user.getDiscordId() != null) { 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 + } else { Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString()); - Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)); + } + Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d)); + + if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) { + ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid()); + Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d)); + Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName()); + Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion()); + } Team team = Team.get(user.getTeam()); Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName()); diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index ab083a7..150ccf4 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -326,14 +326,14 @@ public class SteamwarUser { ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid); if (player != null) { - updateBanIP(player.getAddress().getAddress().getHostAddress()); ChatSender.disconnect(player).system(punishmentMessage(punishment)); for (BannedUserIPs banned : BannedUserIPs.get(player.getAddress().getAddress().getHostAddress())) { SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID()); - if (isPunished(punishment) && bannedUser.getPunishment(punishment).getEndTime().before(time)) { + if (bannedUser.isPunished(punishment) && bannedUser.getPunishment(punishment).getEndTime().before(time)) { bannedUser.punish(punishment, time, banReason, from, perma); } } + updateBanIP(player.getAddress().getAddress().getHostAddress()); } else { updateBanIP(""); } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 8339140..878ede1 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -583,9 +583,13 @@ WHOIS_USERNAME=§7Username§8: §e{0} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eCopy UUID WHOIS_ID=§7ID§8: §e{0} +WHOIS_GROUP=§7Group§8: {0}{1} WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0} WHOIS_JOINED_FIRST=§7Joined on§8: §e{0} WHOIS_HOURS_PLAYED=§7Online Time§8: §e{0}h +WHOIS_CURRENT_PLAYED=§7Current Online Time§8: §e{0}m +WHOIS_CURRENT_SERVER=§7Current Server§8: §e{0} +WHOIS_CURRENT_PROTOCOL=§7Current Protocol§8: §e{0} WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2} WHOIS_TEAM_HOVER=§eShow {0} WHOIS_PUNISHMENTS=§7Punish: diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 8367540..24f0a3d 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -559,12 +559,16 @@ SERVER_WORLD_ERROR=§cDas Erstellen der Welt ist fehlgeschlagen. #WhoisCommand WHOIS_USAGE=§c/whois [Spieler/ID] <-a> WHOIS_USERNAME=§7Username§8: §e{0} +WHOIS_GROUP=§7Gruppe§8: {0}{1} WHOIS_UUID=§7UUID§8: §e{0} WHOIS_UUID_HOVER=§eUUID Kopieren WHOIS_ID=§7ID§8: §e{0} WHOIS_DISCORD_ID=§7Discord-ID§8: §e{0} WHOIS_JOINED_FIRST=§7Beigetreten am§8: §e{0} WHOIS_HOURS_PLAYED=§7Spielzeit§8: §e{0}h +WHOIS_CURRENT_PLAYED=§7Aktuell online§8: §e{0}m +WHOIS_CURRENT_SERVER=§7Aktueller Server§8: §e{0} +WHOIS_CURRENT_PROTOCOL=§7Aktuelle Version§8: §e{0} WHOIS_TEAM=§7Team§8: §e[§{0}{1}§e] {2} WHOIS_TEAM_HOVER=§e{0} anzeigen WHOIS_PUNISHMENTS=§7Strafen: