From 8c098841ba8d35ee4ddb9a49866d4619d35e9725 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 28 Jun 2024 15:37:31 +0200 Subject: [PATCH] Fix double Discord command registration, ConnectionListener and bau member commands Signed-off-by: Lixfel --- src/de/steamwar/velocitycore/ErrorLogger.java | 3 ++- src/de/steamwar/velocitycore/commands/BauCommand.java | 2 +- src/de/steamwar/velocitycore/discord/DiscordBot.java | 3 --- src/de/steamwar/velocitycore/listeners/BanListener.java | 5 ++--- .../velocitycore/listeners/ConnectionListener.java | 9 +++------ 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/de/steamwar/velocitycore/ErrorLogger.java b/src/de/steamwar/velocitycore/ErrorLogger.java index a032b6c..714011f 100644 --- a/src/de/steamwar/velocitycore/ErrorLogger.java +++ b/src/de/steamwar/velocitycore/ErrorLogger.java @@ -73,7 +73,8 @@ public class ErrorLogger extends AbstractAppender { } private static final List filteredMessages = List.of( - "read timed out" + "read timed out", + "disconnected while connecting to Lobby" ); private static final List filteredStacktraces = List.of( "ErrorLogger", diff --git a/src/de/steamwar/velocitycore/commands/BauCommand.java b/src/de/steamwar/velocitycore/commands/BauCommand.java index 0ec2a92..5e37b99 100644 --- a/src/de/steamwar/velocitycore/commands/BauCommand.java +++ b/src/de/steamwar/velocitycore/commands/BauCommand.java @@ -175,7 +175,7 @@ public class BauCommand extends SWCommand { return new TypeMapper() { @Override public SteamwarUser map(Chatter sender, PreviousArguments previousArguments, String s) { - return sender.user(); + return SteamwarUser.get(s); } @Override diff --git a/src/de/steamwar/velocitycore/discord/DiscordBot.java b/src/de/steamwar/velocitycore/discord/DiscordBot.java index 17cdf6a..e0a8ef7 100644 --- a/src/de/steamwar/velocitycore/discord/DiscordBot.java +++ b/src/de/steamwar/velocitycore/discord/DiscordBot.java @@ -170,10 +170,7 @@ public class DiscordBot { } }).repeat(30, TimeUnit.SECONDS).schedule(); - Guild guild = getGuild(); commandSetup(jda.retrieveCommands(), jda.updateCommands()); - commandSetup(guild.retrieveCommands(), guild.updateCommands()); - jda.addEventListener( new DiscordTicketHandler(), new DiscordTeamEvent(), diff --git a/src/de/steamwar/velocitycore/listeners/BanListener.java b/src/de/steamwar/velocitycore/listeners/BanListener.java index f49323b..1d205cc 100644 --- a/src/de/steamwar/velocitycore/listeners/BanListener.java +++ b/src/de/steamwar/velocitycore/listeners/BanListener.java @@ -22,13 +22,12 @@ package de.steamwar.velocitycore.listeners; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.LoginEvent; import com.velocitypowered.api.proxy.Player; -import de.steamwar.velocitycore.commands.PunishmentCommand; -import de.steamwar.velocitycore.commands.WebpasswordCommand; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.sql.BannedUserIPs; import de.steamwar.sql.Punishment; import de.steamwar.sql.SteamwarUser; +import de.steamwar.velocitycore.commands.PunishmentCommand; import net.kyori.adventure.text.event.ClickEvent; import java.sql.Timestamp; @@ -42,7 +41,7 @@ public class BanListener extends BasicListener { @Subscribe public void onLogin(LoginEvent event) { Player player = event.getPlayer(); - SteamwarUser user = SteamwarUser.getOrCreate(player.getUniqueId(), player.getUsername(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername); + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); String ip = IPSanitizer.getTrueAddress(player).getHostAddress(); if (user.isPunished(Punishment.PunishmentType.Ban)) { BannedUserIPs.banIP(user.getId(), ip); diff --git a/src/de/steamwar/velocitycore/listeners/ConnectionListener.java b/src/de/steamwar/velocitycore/listeners/ConnectionListener.java index f73e54d..4fb3d0d 100644 --- a/src/de/steamwar/velocitycore/listeners/ConnectionListener.java +++ b/src/de/steamwar/velocitycore/listeners/ConnectionListener.java @@ -31,10 +31,7 @@ import de.steamwar.persistent.Servertype; import de.steamwar.persistent.Subserver; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; -import de.steamwar.velocitycore.commands.ChallengeCommand; -import de.steamwar.velocitycore.commands.CheckCommand; -import de.steamwar.velocitycore.commands.ModCommand; -import de.steamwar.velocitycore.commands.MsgCommand; +import de.steamwar.velocitycore.commands.*; import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.velocitycore.discord.util.DiscordRanks; import de.steamwar.velocitycore.mods.ModUtils; @@ -57,10 +54,10 @@ public class ConnectionListener extends BasicListener { @Subscribe public void onPermissionSetup(PermissionsSetupEvent event) { event.setProvider(subject -> { - if(!(subject instanceof Player)) + if(!(subject instanceof Player player)) return perm -> Tristate.TRUE; - Set perms = SteamwarUser.get(((Player) subject).getUniqueId()).perms(); + Set perms = SteamwarUser.getOrCreate(player.getUniqueId(), player.getUsername(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername).perms(); if(perms.contains(UserPerm.ADMINISTRATION)) return perm -> Tristate.TRUE; else if(perms.contains(UserPerm.TEAM))