From 48f11d3285f3ba12f2347bfcefd49e2aa2ede919 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 4 Jul 2024 08:36:43 +0200 Subject: [PATCH 1/6] Fix SWCommand with 0 args, help WV, -1 ping, TICKET_LOG Signed-off-by: Lixfel --- CommonCore | 2 +- src/de/steamwar/command/SWCommand.java | 12 ++-------- .../steamwar/messages/BungeeCore.properties | 24 +++++++++---------- .../messages/BungeeCore_de.properties | 1 - .../steamwar/velocitycore/ServerStarter.java | 2 +- .../velocitycore/commands/HelpCommand.java | 2 +- .../listeners/DiscordTicketHandler.java | 2 +- .../velocitycore/tablist/Tablist.java | 4 +++- 8 files changed, 20 insertions(+), 29 deletions(-) diff --git a/CommonCore b/CommonCore index 20c22c4..e76473e 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 20c22c47f940c4510de17594b28eb0a96cb9da0c +Subproject commit e76473e0beffe3df5c6d1c3430f62332b7371579 diff --git a/src/de/steamwar/command/SWCommand.java b/src/de/steamwar/command/SWCommand.java index db9421b..9b931a3 100644 --- a/src/de/steamwar/command/SWCommand.java +++ b/src/de/steamwar/command/SWCommand.java @@ -20,17 +20,16 @@ package de.steamwar.command; import com.velocitypowered.api.command.SimpleCommand; -import de.steamwar.velocitycore.VelocityCore; -import de.steamwar.velocitycore.discord.DiscordBot; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; import de.steamwar.sql.UserPerm; +import de.steamwar.velocitycore.VelocityCore; +import de.steamwar.velocitycore.discord.DiscordBot; import lombok.Getter; import net.kyori.adventure.text.event.ClickEvent; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; @@ -84,9 +83,6 @@ public class SWCommand extends AbstractSWCommand { @Override public List suggest(Invocation invocation) { - if(invocation.arguments().length == 0) - return Collections.emptyList(); - return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), invocation.arguments()); } @@ -104,8 +100,6 @@ public class SWCommand extends AbstractSWCommand { VelocityCore.getProxy().getCommandManager().unregister(name); DiscordBot.getCommands().remove(name); - for(String alias : aliases) - DiscordBot.getCommands().remove(alias); } @Override @@ -115,8 +109,6 @@ public class SWCommand extends AbstractSWCommand { VelocityCore.getProxy().getCommandManager().register(VelocityCore.getProxy().getCommandManager().metaBuilder(name).aliases(aliases).plugin(VelocityCore.get()).build(), command); DiscordBot.getCommands().put(name, this); - for(String alias : aliases) - DiscordBot.getCommands().put(alias, this); } @Override diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 5983f53..870d580 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -48,7 +48,6 @@ HELP_TESTBLOCK=§8/§7testblock §8- §7Resets the dummy HELP_RESET=§8/§7reset §8- §7Resets the current region HELP_SPEED=§8/§7speed §8- §7Changes flight and walking speed HELP_NV=§8/§7nv §8- §7(de)activates night vision -HELP_WV=§8/§7wv §8- §7(de)activates underwater vision HELP_TRACE=§8/§7trace §8- §7Gives help regarding the tnt tracer HELP_TPSLIMIT=§8/§7tpslimit §8- §7Gives help regarding the TPS limiter HELP_LOADER=§8/§7loader §8- §7Use the automatic cannon loader @@ -57,7 +56,7 @@ HELP_FREEZE=§8/§7freeze §8- §7Stops block updates HELP_SKULL=§8/§7skull §8- §7Gives you a player head HELP_DEBUGSTICK=§8/§7debugstick §8- §7Gives you a debugstick HELP_BAUINFO=§8/§7buildinfo §8- §7Information about the current build server -HELP_SCHEMSUBMIT=§7For a Tutorial about unlocking your AirShip§8/§7MiniWarGear§8/§7WarGear§8/§7WarShip click §ehere§8! +HELP_SCHEMSUBMIT=§7For a Tutorial about submitting your AirShip§8/§7MiniWarGear§8/§7WarGear§8/§7WarShip click §ehere§8! HELP_SCHEMSUBMIT_HOVER=§ehttps://www.youtube.com/watch?v=9QrQ3UBWveE HELP_WE_POS1=§8//§71 §7» §8//§7pos1 @@ -233,7 +232,7 @@ BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server. #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8] -CHALLENGE_OFFLINE=§cThe challenged player isn't online. + CHALLENGE_OFFLINE=§cThe challenged player isn\'t online. CHALLENGE_SELF=§cSchizophrenia? CHALLENGE_IGNORED=§cThe challenged player has blocked you. CHALLENGE_INARENA=§cThe challenged player is already in an arena. @@ -539,16 +538,16 @@ CHAT_YOYONOW_2=I would like to recommend you the command "/bug ".. CHAT_YOYONOW_3=Thank you. CHAT_YOYONOW_4=I wish you still a smooth gaming experience. CHAT_CHAOSCAOT_1=You called me! -CHAT_CHAOSCAOT_2=If something is broken, just say it's a feature. -CHAT_CHAOSCAOT_3=And if it is a feature, just then it can't be broken. -CHAT_CHAOSCAOT_4=Broken is just a definition. So if you define it as a feature, it's not broken. +CHAT_CHAOSCAOT_2=If something is broken, just say it\'s a feature. +CHAT_CHAOSCAOT_3=And if it is a feature, just then it can\'t be broken. +CHAT_CHAOSCAOT_4=Broken is just a definition. So if you define it as a feature, it\'s not broken. CHAT_CHAOSCAOT_5=And if you define it as broken, then tell us using the command "/bug ". CHAT_CHAOSCAOT_6=Thank you and goodbye. CHAT_RECEIVE=§cTo be able to send chat messages, you must also receive them! CHAT_NO_LINKS=§cYou may not send links. CHAT_BC_USAGE=§8/§7bc §8[§emessage§8] CHAT_NO_RECEIVER=§cNobody receives your message -CHAT_EMPTY=§cDon't write meaningless empty messages. +CHAT_EMPTY=§cDon\'t write meaningless empty messages. CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2} CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2} @@ -712,11 +711,10 @@ DC_UNLINKED=For this action your Discord account has to be linked to your Minecr DC_TITLE_SCHEMINFO=Schematic Info DC_SCHEM_ACCEPT=Your schematic **{0}** has been accepted. DC_SCHEM_DECLINE=Your schematic **{0}** has been declined.\n**Reason:**{1} -DC_AUTH_SUCCESS=:white_check_mark: You're Discord account has been linked with **{0}**. -DC_ROLE_ADDED=:tada: You're getting {0} now. -DC_ROLE_REMOVED=You're not getting {0} anymore. - -DC_TICKET_CREATED=You're Ticket {0} has been created. +DC_AUTH_SUCCESS=:white_check_mark: You\'re Discord account has been linked with **{0}**. +DC_ROLE_ADDED=:tada: Your getting {0} now. +DC_ROLE_REMOVED=Your not getting {0} anymore. +DC_TICKET_CREATED=Your Ticket {0} has been created. DC_TICKET_TITLE=SteamWar Ticket DC_TICKETINTRO_REPORT=Please answer for the punishment of the misconduct the following questions as accurately as possible and attach evidence whenever possible:\n - Which player(s)?\n - On which Server?\n - At what time?\n - Type and nature of the misconduct? DC_TICKETINTRO_IDEA=Describe your idea as detailed as possible. Hereto belongs: What, Why, How, Where? @@ -725,7 +723,7 @@ DC_TICKETINTRO_QUESTION=Please ask your question. A staff member will address th DC_TICKETINTRO_APPEAL=Asking creates wonders. DC_TICKET_CLOSE=Close -DC_SCHEMUPLOAD_NOPERM=You're not allowed to upload schematics. +DC_SCHEMUPLOAD_NOPERM=You\'re not allowed to upload schematics. DC_SCHEMUPLOAD_IGNORED=Skipping `{0}`, not a schematic file. DC_SCHEMUPLOAD_INVCHAR=`{0}` has invalid characters in its name. DC_SCHEMUPLOAD_SUCCESS=`{0}` was uploaded successfully. diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 8d4ddca..c61446e 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -44,7 +44,6 @@ HELP_TESTBLOCK=§8/§7testblock §8- §7Erneuert den nächsten Testblock HELP_RESET=§8/§7reset §8- §7Setzt die derzeitige Region zurück HELP_SPEED=§8/§7speed §8- §7Ändert deine Fluggeschwindigkeit HELP_NV=§8/§7nv §8- §7(de)aktiviert Nachtsicht -HELP_WV=§8/§7wv §8- §7(de)aktiviert Unterwassersicht HELP_TRACE=§8/§7trace §8- §7Gibt einen Überblick über den TNT-Tracer HELP_TPSLIMIT=§8/§7tpslimit §8- §7Gibt einen Überblick über den TPS-Limiter HELP_LOADER=§8/§7loader §8- §7Nutze den automatischen Kanonenlader diff --git a/src/de/steamwar/velocitycore/ServerStarter.java b/src/de/steamwar/velocitycore/ServerStarter.java index 43ae472..aa7e14f 100644 --- a/src/de/steamwar/velocitycore/ServerStarter.java +++ b/src/de/steamwar/velocitycore/ServerStarter.java @@ -214,7 +214,7 @@ public class ServerStarter { directory = version.getServerDirectory("Builder"); worldDir = version.getWorldFolder(BUILDER_BASE_PATH); worldName = map; - serverNameProvider = port -> "⛏" + map; + serverNameProvider = port -> map + "⛏"; checkpoint = true; constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback); diff --git a/src/de/steamwar/velocitycore/commands/HelpCommand.java b/src/de/steamwar/velocitycore/commands/HelpCommand.java index 4a22749..8cb6fda 100644 --- a/src/de/steamwar/velocitycore/commands/HelpCommand.java +++ b/src/de/steamwar/velocitycore/commands/HelpCommand.java @@ -53,7 +53,7 @@ public class HelpCommand extends SWCommand { @Register({"build","player"}) public void buildPlayer(Chatter sender) { - printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER"); + printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER"); } @Register({"build","worldedit"}) diff --git a/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java b/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java index dbb2155..914355d 100644 --- a/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java +++ b/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java @@ -149,7 +149,7 @@ public class DiscordTicketHandler extends ListenerAdapter { if(event.getAuthor().isBot()) return; - ChatterGroup receivers = Chatter.serverteam(); + ChatterGroup receivers = new ChatterGroup(Chatter.allStream().filter(player -> player.user().hasPerm(UserPerm.TICKET_LOG))); try { SteamwarUser user = SteamwarUser.get(Long.parseLong(channel.getTopic())); if(user != null && !user.perms().contains(UserPerm.TEAM)) diff --git a/src/de/steamwar/velocitycore/tablist/Tablist.java b/src/de/steamwar/velocitycore/tablist/Tablist.java index 59bba3b..4d68702 100644 --- a/src/de/steamwar/velocitycore/tablist/Tablist.java +++ b/src/de/steamwar/velocitycore/tablist/Tablist.java @@ -235,7 +235,9 @@ public class Tablist extends ChannelInboundHandlerAdapter { private String ping() { long ping = player.getPing(); - if (ping < 50) { + if (ping == -1) { + return "§7?"; + } else if (ping < 50) { return "§a" + ping; } else if (ping < 150) { return "§e" + ping; From bacf3666432f861cc0cf014b753c927205840eb6 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 4 Jul 2024 09:04:38 +0200 Subject: [PATCH 2/6] Fix SWCommand with 0 args Signed-off-by: Lixfel --- src/de/steamwar/command/SWCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/command/SWCommand.java b/src/de/steamwar/command/SWCommand.java index 9b931a3..52845d2 100644 --- a/src/de/steamwar/command/SWCommand.java +++ b/src/de/steamwar/command/SWCommand.java @@ -83,7 +83,11 @@ public class SWCommand extends AbstractSWCommand { @Override public List suggest(Invocation invocation) { - return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), invocation.arguments()); + String[] args = invocation.arguments(); + if(args.length == 0) + args = new String[]{""}; + + return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), args); } @Override From d09f8edfa2fc7f3eff4c9dcc5452f3ad6740f05a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 5 Jul 2024 10:09:29 +0200 Subject: [PATCH 3/6] Fix BauLock, 1.15 - 1.20.1 Tablist, Builderserver, BugCommand Signed-off-by: Lixfel --- CommonCore | 2 +- .../steamwar/messages/BungeeCore.properties | 2 +- .../messages/BungeeCore_de.properties | 2 +- .../steamwar/velocitycore/ServerStarter.java | 2 +- .../velocitycore/commands/BauCommand.java | 16 ++++-- .../velocitycore/commands/BugCommand.java | 4 +- .../velocitycore/commands/TpCommand.java | 4 +- .../velocitycore/tablist/Tablist.java | 53 +++++++++++++++++++ .../velocitycore/tablist/TablistManager.java | 2 +- .../steamwar/velocitycore/util/BauLock.java | 9 +--- 10 files changed, 75 insertions(+), 21 deletions(-) diff --git a/CommonCore b/CommonCore index e76473e..1237a69 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit e76473e0beffe3df5c6d1c3430f62332b7371579 +Subproject commit 1237a699ba244ecfac65478df34e714afbe2366e diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 870d580..0e45249 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -184,7 +184,7 @@ UNNOTEAMSERVER=§e{0} §7may now set §e§lteam servers§7 again§8. NOTE_TEAM={0} §e{1} §7received a §e§lnote§7 from §e{2} {3}: §f{4} #BugCommand -BUG_MESSAGE=§7Your bugreport was saved. +BUG_MESSAGE=§7Please describe the issue in a Discord ticket with the bug ID §e{0} §7further§8. #IgnoreCommand IGNORE_YOURSELF=§cHow are you going to ignore yourself? diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index c61446e..c52b6a9 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -168,7 +168,7 @@ UNNOTEAMSERVER=§e{0} §7darf nun wieder §e§lTeamserver§7 setzen§8. NOTE_TEAM={0} §e{1} §7erhielt von §e{2} {3} §7die §e§lNotiz§7§8: §f{4} #BugCommand -BUG_MESSAGE=§7Dein Bugreport wurde gespeichert. +BUG_MESSAGE=§7Bitte beschreibe das Problem in einem Discordticket genauer und gebe dabei die Bug-ID §e{0} §7an§8. #IgnoreCommand IGNORE_YOURSELF=§cWie willst du dich selber ignorieren? diff --git a/src/de/steamwar/velocitycore/ServerStarter.java b/src/de/steamwar/velocitycore/ServerStarter.java index aa7e14f..75edf04 100644 --- a/src/de/steamwar/velocitycore/ServerStarter.java +++ b/src/de/steamwar/velocitycore/ServerStarter.java @@ -214,7 +214,7 @@ public class ServerStarter { directory = version.getServerDirectory("Builder"); worldDir = version.getWorldFolder(BUILDER_BASE_PATH); worldName = map; - serverNameProvider = port -> map + "⛏"; + serverNameProvider = port -> "*" + map; checkpoint = true; constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback); diff --git a/src/de/steamwar/velocitycore/commands/BauCommand.java b/src/de/steamwar/velocitycore/commands/BauCommand.java index d53b2e9..037b4ab 100644 --- a/src/de/steamwar/velocitycore/commands/BauCommand.java +++ b/src/de/steamwar/velocitycore/commands/BauCommand.java @@ -93,17 +93,23 @@ public class BauCommand extends SWCommand { @Validator(value = "teleportTarget", local = true) public TypeValidator teleportTargetValidator() { - return (sender, value, messageSender) -> { - if (value == null) { + return (sender, owner, messageSender) -> { + if (owner == null) { messageSender.send("UNKNOWN_PLAYER"); return false; } - if (sender.user().getId() != value.getId() && BauweltMember.getBauMember(value.getId(), sender.user().getId()) == null) { - SubserverSystem.sendDeniedMessage(sender, value.getUUID()); + if (sender.user().getId() != owner.getId() && BauweltMember.getBauMember(owner.getId(), sender.user().getId()) == null) { + SubserverSystem.sendDeniedMessage(sender, owner.getUUID()); messageSender.send("BAU_TP_NOALLOWED"); return false; } - return !BauLock.checkNotifyLocked(value, sender); + + if (BauLock.isLocked(owner, sender.user())) { + messageSender.send("BAU_LOCKED_NOALLOWED"); + Chatter.of(owner.getUUID()).system("BAU_LOCK_BLOCKED", sender); + return false; + } + return true; }; } diff --git a/src/de/steamwar/velocitycore/commands/BugCommand.java b/src/de/steamwar/velocitycore/commands/BugCommand.java index 58172a0..22c9f39 100644 --- a/src/de/steamwar/velocitycore/commands/BugCommand.java +++ b/src/de/steamwar/velocitycore/commands/BugCommand.java @@ -30,10 +30,10 @@ public class BugCommand extends SWCommand { @Register public void bugMessage(Chatter sender, String... message) { - SWException.log( + int id = SWException.logGetId( String.join(" ", message), sender.withPlayerOrOffline(player -> player.getCurrentServer().map(connection -> connection.getServerInfo().getName()).orElse("offline"), () -> "offline") + " " + sender.user().getUserName() + " " + sender.user().getId() ); - sender.system("BUG_MESSAGE"); + sender.system("BUG_MESSAGE", id); } } diff --git a/src/de/steamwar/velocitycore/commands/TpCommand.java b/src/de/steamwar/velocitycore/commands/TpCommand.java index 8bd203c..031e2ba 100644 --- a/src/de/steamwar/velocitycore/commands/TpCommand.java +++ b/src/de/steamwar/velocitycore/commands/TpCommand.java @@ -124,7 +124,9 @@ public class TpCommand extends SWCommand { sender.system("JOIN_PLAYER_BLOCK"); return; } - } else if (BauLock.checkNotifyLocked(SteamwarUser.get(bauserver.getOwner()), sender)) { + } else if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) { + sender.system("BAU_LOCKED_NOALLOWED"); + Chatter.of(bauserver.getOwner()).system("BAU_LOCK_BLOCKED", sender); return; } else if (!bauserver.getOwner().equals(sender.user().getUUID()) && BauweltMember.getBauMember(bauserver.getOwner(), sender.user().getUUID()) == null) { SubserverSystem.sendDeniedMessage(sender, bauserver.getOwner()); diff --git a/src/de/steamwar/velocitycore/tablist/Tablist.java b/src/de/steamwar/velocitycore/tablist/Tablist.java index 4d68702..31c404b 100644 --- a/src/de/steamwar/velocitycore/tablist/Tablist.java +++ b/src/de/steamwar/velocitycore/tablist/Tablist.java @@ -19,12 +19,14 @@ package de.steamwar.velocitycore.tablist; +import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.network.Connections; import com.velocitypowered.proxy.protocol.MinecraftPacket; +import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket; import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket; import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket; import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder; @@ -205,6 +207,40 @@ public class Tablist extends ChannelInboundHandlerAdapter { directTabItems.remove(uuid); } } + } else if(msg instanceof LegacyPlayerListItemPacket packet) { + if(packet.getAction() == LegacyPlayerListItemPacket.ADD_PLAYER) { + for(LegacyPlayerListItemPacket.Item entry : packet.getItems()) { + entry.setLatency(1).setPlayerKey(null); + + if (!Storage.teamServers.containsValue(connection.getServerInfo())) { + entry.setDisplayName(Component.empty()); + } else if (entry.getDisplayName() == null) { + entry.setDisplayName(Component.text(entry.getName()).color(NamedTextColor.GRAY)); + } + + UpsertPlayerInfoPacket.Entry newEntry = new UpsertPlayerInfoPacket.Entry(entry.getUuid()); + newEntry.setProfile(new GameProfile(entry.getUuid(), entry.getName(), entry.getProperties())); + newEntry.setDisplayName(new ComponentHolder(player.getProtocolVersion(), entry.getDisplayName())); + newEntry.setListed(true); + synchronized (directTabItems) { + directTabItems.put(entry.getUuid(), newEntry); + } + } + } else if(packet.getAction() == LegacyPlayerListItemPacket.UPDATE_GAMEMODE) { + for(LegacyPlayerListItemPacket.Item entry : packet.getItems()) { + if(!player.getUniqueId().equals(entry.getUuid()) && entry.getGameMode() == 3) + entry.setGameMode(1); + } + } else if(packet.getAction() == LegacyPlayerListItemPacket.REMOVE_PLAYER) { + for(LegacyPlayerListItemPacket.Item entry : packet.getItems()) { + synchronized (directTabItems) { + directTabItems.remove(entry.getUuid()); + } + } + } else { + ReferenceCountUtil.release(msg); + return; + } } ctx.fireChannelRead(msg); @@ -214,6 +250,23 @@ public class Tablist extends ChannelInboundHandlerAdapter { if(items.isEmpty()) return; + if(player.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_19_3)) { + int legacyAction = LegacyPlayerListItemPacket.REMOVE_PLAYER; + if(action == UpsertPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME) + legacyAction = LegacyPlayerListItemPacket.UPDATE_DISPLAY_NAME; + else if (action == UpsertPlayerInfoPacket.Action.ADD_PLAYER) + legacyAction = LegacyPlayerListItemPacket.ADD_PLAYER; + + sendPacket(player, new LegacyPlayerListItemPacket(legacyAction, items.stream().map(item -> new LegacyPlayerListItemPacket + .Item(item.getProfileId()) + .setName(item.getProfile().getName()) + .setProperties(item.getProfile().getProperties()) + .setDisplayName(item.getDisplayName().getComponent()) + .setLatency(item.getLatency()) + .setGameMode(item.getGameMode())).toList())); + return; + } + if(action == null) { //REMOVE sendPacket(player, new RemovePlayerInfoPacket(items.stream().map(item -> item.getProfile().getId()).toList())); return; diff --git a/src/de/steamwar/velocitycore/tablist/TablistManager.java b/src/de/steamwar/velocitycore/tablist/TablistManager.java index 4a8c621..5189f4c 100644 --- a/src/de/steamwar/velocitycore/tablist/TablistManager.java +++ b/src/de/steamwar/velocitycore/tablist/TablistManager.java @@ -61,10 +61,10 @@ public class TablistManager extends BasicListener { @Subscribe public void onJoin(PostLoginEvent event) { - Tablist.sendPacket(event.getPlayer(), createTeamPacket); synchronized (tablists) { tablists.put(event.getPlayer(), new Tablist(event.getPlayer())); } + Tablist.sendPacket(event.getPlayer(), createTeamPacket); } @Subscribe diff --git a/src/de/steamwar/velocitycore/util/BauLock.java b/src/de/steamwar/velocitycore/util/BauLock.java index 1352d95..03bc431 100644 --- a/src/de/steamwar/velocitycore/util/BauLock.java +++ b/src/de/steamwar/velocitycore/util/BauLock.java @@ -34,8 +34,7 @@ public class BauLock { owner.system("BAU_LOCKED_" + state.name()); } - public static boolean checkNotifyLocked(SteamwarUser owner, Chatter sender) { - SteamwarUser target = sender.user(); + public static boolean isLocked(SteamwarUser owner, SteamwarUser target) { if (owner.getId() == target.getId()) return false; @@ -62,12 +61,6 @@ public class BauLock { locked = false; } - if(locked) { - sender.system("BAU_LOCKED_NOALLOWED"); - Chatter.of(owner.getUUID()).system("BAU_LOCK_BLOCKED", sender); - } - return locked; } - } From 7224428345d6c562a2587f5a51554f23adc36c16 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 5 Jul 2024 10:19:18 +0200 Subject: [PATCH 4/6] Fix 1.20.2+ Tablist vanishing after server switch Signed-off-by: Lixfel --- src/de/steamwar/velocitycore/tablist/Tablist.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/de/steamwar/velocitycore/tablist/Tablist.java b/src/de/steamwar/velocitycore/tablist/Tablist.java index 31c404b..e87948a 100644 --- a/src/de/steamwar/velocitycore/tablist/Tablist.java +++ b/src/de/steamwar/velocitycore/tablist/Tablist.java @@ -138,6 +138,9 @@ public class Tablist extends ChannelInboundHandlerAdapter { synchronized (directTabItems) { directTabItems.clear(); } + + if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) + current.clear(); } private void injection() { From e2024a481b1d022aad8c2c8c7caaaf7b837d8122 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 5 Jul 2024 10:32:16 +0200 Subject: [PATCH 5/6] Fix 1.20.2+ Tablist order after server switch, Test fix commands Signed-off-by: Lixfel --- .../velocitycore/listeners/ChatListener.java | 5 ++++- src/de/steamwar/velocitycore/tablist/Tablist.java | 9 ++++++--- .../velocitycore/tablist/TablistManager.java | 13 ++++++------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/de/steamwar/velocitycore/listeners/ChatListener.java b/src/de/steamwar/velocitycore/listeners/ChatListener.java index ccec6ed..74429c1 100644 --- a/src/de/steamwar/velocitycore/listeners/ChatListener.java +++ b/src/de/steamwar/velocitycore/listeners/ChatListener.java @@ -74,7 +74,7 @@ public class ChatListener extends BasicListener { public void logCommands(CommandExecuteEvent e) { String command = e.getCommand(); int space = command.indexOf(' '); - if(e.getResult().isAllowed() && VelocityCore.getProxy().getCommandManager().hasCommand(space != -1 ? command.substring(0, space) : command)) { + if(VelocityCore.getProxy().getCommandManager().hasCommand(space != -1 ? command.substring(0, space) : command)) { CommandSource source = e.getCommandSource(); String name; if(source instanceof Player player) @@ -85,6 +85,9 @@ public class ChatListener extends BasicListener { name = source.toString(); cmdLogger.log(Level.INFO, "%s -> executed command /%s".formatted(name, command)); + } else if (e.getCommandSource() instanceof Player player) { + player.spoofChatInput("/" + command); + e.setResult(CommandExecuteEvent.CommandResult.denied()); } } diff --git a/src/de/steamwar/velocitycore/tablist/Tablist.java b/src/de/steamwar/velocitycore/tablist/Tablist.java index e87948a..f8dc178 100644 --- a/src/de/steamwar/velocitycore/tablist/Tablist.java +++ b/src/de/steamwar/velocitycore/tablist/Tablist.java @@ -28,6 +28,7 @@ import com.velocitypowered.proxy.network.Connections; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.packet.LegacyPlayerListItemPacket; import com.velocitypowered.proxy.protocol.packet.RemovePlayerInfoPacket; +import com.velocitypowered.proxy.protocol.packet.UpdateTeamsPacket; import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket; import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder; import de.steamwar.messages.Chatter; @@ -48,8 +49,8 @@ import java.util.stream.IntStream; public class Tablist extends ChannelInboundHandlerAdapter { private static final UUID[] swUuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new); - public static final String[] swNames = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new); - public static final String TAB_TEAM = "zzzzzsw-tab"; + private static final String[] swNames = IntStream.range(0, 80).mapToObj(i -> " »SW« " + String.format("%02d", i)).toArray(String[]::new); + public static final UpdateTeamsPacket createTeamPacket = new UpdateTeamsPacket("zzzzzsw-tab", UpdateTeamsPacket.Mode.CREATE, Component.empty(), Component.empty(), Component.empty(), UpdateTeamsPacket.NameTagVisibility.NEVER, UpdateTeamsPacket.CollisionRule.ALWAYS, 21, (byte)0x00, Arrays.stream(Tablist.swNames).toList()); private final Map directTabItems; private final List current = new ArrayList<>(); @@ -139,8 +140,10 @@ public class Tablist extends ChannelInboundHandlerAdapter { directTabItems.clear(); } - if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) + if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) { current.clear(); + sendPacket(player, createTeamPacket); + } } private void injection() { diff --git a/src/de/steamwar/velocitycore/tablist/TablistManager.java b/src/de/steamwar/velocitycore/tablist/TablistManager.java index 5189f4c..2b8b47b 100644 --- a/src/de/steamwar/velocitycore/tablist/TablistManager.java +++ b/src/de/steamwar/velocitycore/tablist/TablistManager.java @@ -25,16 +25,17 @@ import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.server.RegisteredServer; -import com.velocitypowered.proxy.protocol.packet.UpdateTeamsPacket; +import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.persistent.Servertype; import de.steamwar.persistent.Storage; import de.steamwar.persistent.Subserver; import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.listeners.BasicListener; -import de.steamwar.network.packets.common.FightInfoPacket; -import net.kyori.adventure.text.Component; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; public class TablistManager extends BasicListener { @@ -46,8 +47,6 @@ public class TablistManager extends BasicListener { fightInfos.keySet().removeIf(serverInfo -> serverInfo.getPlayersConnected().isEmpty()); } - private static final UpdateTeamsPacket createTeamPacket = new UpdateTeamsPacket(Tablist.TAB_TEAM, UpdateTeamsPacket.Mode.CREATE, Component.empty(), Component.empty(), Component.empty(), UpdateTeamsPacket.NameTagVisibility.NEVER, UpdateTeamsPacket.CollisionRule.ALWAYS, 21, (byte)0x00, Arrays.stream(Tablist.swNames).toList()); - private final Map tablists = new HashMap<>(); private int seconds = 0; @@ -64,7 +63,7 @@ public class TablistManager extends BasicListener { synchronized (tablists) { tablists.put(event.getPlayer(), new Tablist(event.getPlayer())); } - Tablist.sendPacket(event.getPlayer(), createTeamPacket); + Tablist.sendPacket(event.getPlayer(), Tablist.createTeamPacket); } @Subscribe From dd07603fe3cd22905cfcdb0a88cdc5ba6db492bc Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 6 Jul 2024 15:13:08 +0200 Subject: [PATCH 6/6] Fix /bug, Discord Commands Signed-off-by: Lixfel --- CommonCore | 2 +- .../discord/listeners/ChannelListener.java | 12 ++++++------ .../discord/listeners/DiscordTicketHandler.java | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CommonCore b/CommonCore index 1237a69..d000b86 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 1237a699ba244ecfac65478df34e714afbe2366e +Subproject commit d000b8687d93eb43520bbf6685281099055eab9f diff --git a/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java b/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java index 2fffa1a..7665c40 100644 --- a/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java +++ b/src/de/steamwar/velocitycore/discord/listeners/ChannelListener.java @@ -74,17 +74,17 @@ public class ChannelListener extends ListenerAdapter { if(sender.user().getDiscordId() == null) return; - VelocityCore.getLogger().log(Level.INFO, "%s -> executed Discord command /%s %s".formatted(sender.user().getUserName(), event.getName(), event.getOption(DiscordBot.ARGUMENT_NAME).getAsString())); - SWCommand command = DiscordBot.getCommands().get(event.getName()); - UserPerm permission = command.getPermission(); - if(permission != null && !sender.user().perms().contains(permission)) - return; - OptionMapping option = event.getOption(DiscordBot.ARGUMENT_NAME); String args = ""; if(option != null) args = option.getAsString(); + VelocityCore.getLogger().log(Level.INFO, "%s -> executed Discord command /%s %s".formatted(sender.user().getUserName(), event.getName(), args)); + SWCommand command = DiscordBot.getCommands().get(event.getName()); + UserPerm permission = command.getPermission(); + if(permission != null && !sender.user().perms().contains(permission)) + return; + command.execute(sender, args.split(" ")); }); } diff --git a/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java b/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java index 914355d..692d475 100644 --- a/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java +++ b/src/de/steamwar/velocitycore/discord/listeners/DiscordTicketHandler.java @@ -32,6 +32,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Emoji; +import net.dv8tion.jda.api.entities.MessageChannel; import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; @@ -83,8 +84,8 @@ public class DiscordTicketHandler extends ListenerAdapter { @Override public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) { - TextChannel channel = event.getTextChannel(); - if(channel.getParent() != null && channel.getParent().getId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) { + MessageChannel messageChannel = event.getChannel(); + if(messageChannel instanceof TextChannel channel && channel.getParent() != null && channel.getParent().getId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) { LinkedList messages = channel.getIterableHistory().complete().stream() .filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot()) .map(message -> {