SteamWar/BungeeCore
Archiviert
13
2

Merge remote-tracking branch 'origin/master'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-07-17 08:04:20 +02:00
Commit 83e1a33af5
15 geänderte Dateien mit 123 neuen und 65 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 20c22c47f940c4510de17594b28eb0a96cb9da0c Subproject commit d000b8687d93eb43520bbf6685281099055eab9f

Datei anzeigen

@ -20,17 +20,16 @@
package de.steamwar.command; package de.steamwar.command;
import com.velocitypowered.api.command.SimpleCommand; 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.Chatter;
import de.steamwar.messages.Message; import de.steamwar.messages.Message;
import de.steamwar.sql.UserPerm; import de.steamwar.sql.UserPerm;
import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.discord.DiscordBot;
import lombok.Getter; import lombok.Getter;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -84,10 +83,11 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
@Override @Override
public List<String> suggest(Invocation invocation) { public List<String> suggest(Invocation invocation) {
if(invocation.arguments().length == 0) String[] args = invocation.arguments();
return Collections.emptyList(); if(args.length == 0)
args = new String[]{""};
return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), invocation.arguments()); return SWCommand.this.tabComplete(Chatter.of(invocation.source()), invocation.alias(), args);
} }
@Override @Override
@ -104,8 +104,6 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
VelocityCore.getProxy().getCommandManager().unregister(name); VelocityCore.getProxy().getCommandManager().unregister(name);
DiscordBot.getCommands().remove(name); DiscordBot.getCommands().remove(name);
for(String alias : aliases)
DiscordBot.getCommands().remove(alias);
} }
@Override @Override
@ -115,8 +113,6 @@ public class SWCommand extends AbstractSWCommand<Chatter> {
VelocityCore.getProxy().getCommandManager().register(VelocityCore.getProxy().getCommandManager().metaBuilder(name).aliases(aliases).plugin(VelocityCore.get()).build(), command); VelocityCore.getProxy().getCommandManager().register(VelocityCore.getProxy().getCommandManager().metaBuilder(name).aliases(aliases).plugin(VelocityCore.get()).build(), command);
DiscordBot.getCommands().put(name, this); DiscordBot.getCommands().put(name, this);
for(String alias : aliases)
DiscordBot.getCommands().put(alias, this);
} }
@Override @Override

Datei anzeigen

@ -48,7 +48,6 @@ HELP_TESTBLOCK=§8/§7testblock §8- §7Resets the dummy
HELP_RESET=§8/§7reset §8- §7Resets the current region HELP_RESET=§8/§7reset §8- §7Resets the current region
HELP_SPEED=§8/§7speed §8- §7Changes flight and walking speed HELP_SPEED=§8/§7speed §8- §7Changes flight and walking speed
HELP_NV=§8/§7nv §8- §7(de)activates night vision 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_TRACE=§8/§7trace §8- §7Gives help regarding the tnt tracer
HELP_TPSLIMIT=§8/§7tpslimit §8- §7Gives help regarding the TPS limiter HELP_TPSLIMIT=§8/§7tpslimit §8- §7Gives help regarding the TPS limiter
HELP_LOADER=§8/§7loader §8- §7Use the automatic cannon loader 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_SKULL=§8/§7skull §8- §7Gives you a player head
HELP_DEBUGSTICK=§8/§7debugstick §8- §7Gives you a debugstick HELP_DEBUGSTICK=§8/§7debugstick §8- §7Gives you a debugstick
HELP_BAUINFO=§8/§7buildinfo §8- §7Information about the current build server 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_SCHEMSUBMIT_HOVER=§ehttps://www.youtube.com/watch?v=9QrQ3UBWveE
HELP_WE_POS1=§8//§71 §7» §8//§7pos1 HELP_WE_POS1=§8//§71 §7» §8//§7pos1
@ -186,7 +185,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} NOTE_TEAM={0} §e{1} §7received a §e§lnote§7 from §e{2} {3}: §f{4}
#BugCommand #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 #IgnoreCommand
IGNORE_YOURSELF=§cHow are you going to ignore yourself? IGNORE_YOURSELF=§cHow are you going to ignore yourself?
@ -234,7 +233,7 @@ BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server.
#ChallengeCommand #ChallengeCommand
CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8] 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_SELF=§cSchizophrenia?
CHALLENGE_IGNORED=§cThe challenged player has blocked you. CHALLENGE_IGNORED=§cThe challenged player has blocked you.
CHALLENGE_INARENA=§cThe challenged player is already in an arena. CHALLENGE_INARENA=§cThe challenged player is already in an arena.
@ -540,16 +539,16 @@ CHAT_YOYONOW_2=I would like to recommend you the command "/bug <MESSAGE>"..
CHAT_YOYONOW_3=Thank you. CHAT_YOYONOW_3=Thank you.
CHAT_YOYONOW_4=I wish you still a smooth gaming experience. CHAT_YOYONOW_4=I wish you still a smooth gaming experience.
CHAT_CHAOSCAOT_1=You called me! CHAT_CHAOSCAOT_1=You called me!
CHAT_CHAOSCAOT_2=If something is broken, just say it's a feature. 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_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_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 <MESSAGE>". CHAT_CHAOSCAOT_5=And if you define it as broken, then tell us using the command "/bug <MESSAGE>".
CHAT_CHAOSCAOT_6=Thank you and goodbye. CHAT_CHAOSCAOT_6=Thank you and goodbye.
CHAT_RECEIVE=§cTo be able to send chat messages, you must also receive them! CHAT_RECEIVE=§cTo be able to send chat messages, you must also receive them!
CHAT_NO_LINKS=§cYou may not send links. CHAT_NO_LINKS=§cYou may not send links.
CHAT_BC_USAGE=§8/§7bc §8[§emessage§8] CHAT_BC_USAGE=§8/§7bc §8[§emessage§8]
CHAT_NO_RECEIVER=§cNobody receives your message 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_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2} CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}
@ -713,11 +712,10 @@ DC_UNLINKED=For this action your Discord account has to be linked to your Minecr
DC_TITLE_SCHEMINFO=Schematic Info DC_TITLE_SCHEMINFO=Schematic Info
DC_SCHEM_ACCEPT=Your schematic **{0}** has been accepted. DC_SCHEM_ACCEPT=Your schematic **{0}** has been accepted.
DC_SCHEM_DECLINE=Your schematic **{0}** has been declined.\n**Reason:**{1} 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_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_ADDED=:tada: Your getting {0} now.
DC_ROLE_REMOVED=You're not getting {0} anymore. DC_ROLE_REMOVED=Your not getting {0} anymore.
DC_TICKET_CREATED=Your Ticket {0} has been created.
DC_TICKET_CREATED=You're Ticket {0} has been created.
DC_TICKET_TITLE=SteamWar Ticket 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_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? DC_TICKETINTRO_IDEA=Describe your idea as detailed as possible. Hereto belongs: What, Why, How, Where?
@ -726,7 +724,7 @@ DC_TICKETINTRO_QUESTION=Please ask your question. A staff member will address th
DC_TICKETINTRO_APPEAL=Asking creates wonders. DC_TICKETINTRO_APPEAL=Asking creates wonders.
DC_TICKET_CLOSE=Close 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_IGNORED=Skipping `{0}`, not a schematic file.
DC_SCHEMUPLOAD_INVCHAR=`{0}` has invalid characters in its name. DC_SCHEMUPLOAD_INVCHAR=`{0}` has invalid characters in its name.
DC_SCHEMUPLOAD_SUCCESS=`{0}` was uploaded successfully. DC_SCHEMUPLOAD_SUCCESS=`{0}` was uploaded successfully.

Datei anzeigen

@ -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_RESET=§8/§7reset §8- §7Setzt die derzeitige Region zurück
HELP_SPEED=§8/§7speed §8- §7Ändert deine Fluggeschwindigkeit HELP_SPEED=§8/§7speed §8- §7Ändert deine Fluggeschwindigkeit
HELP_NV=§8/§7nv §8- §7(de)aktiviert Nachtsicht 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_TRACE=§8/§7trace §8- §7Gibt einen Überblick über den TNT-Tracer
HELP_TPSLIMIT=§8/§7tpslimit §8- §7Gibt einen Überblick über den TPS-Limiter HELP_TPSLIMIT=§8/§7tpslimit §8- §7Gibt einen Überblick über den TPS-Limiter
HELP_LOADER=§8/§7loader §8- §7Nutze den automatischen Kanonenlader HELP_LOADER=§8/§7loader §8- §7Nutze den automatischen Kanonenlader
@ -170,7 +169,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} NOTE_TEAM={0} §e{1} §7erhielt von §e{2} {3} §7die §e§lNotiz§7§8: §f{4}
#BugCommand #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 #IgnoreCommand
IGNORE_YOURSELF=§cWie willst du dich selber ignorieren? IGNORE_YOURSELF=§cWie willst du dich selber ignorieren?

Datei anzeigen

@ -214,7 +214,7 @@ public class ServerStarter {
directory = version.getServerDirectory("Builder"); directory = version.getServerDirectory("Builder");
worldDir = version.getWorldFolder(BUILDER_BASE_PATH); worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
worldName = map; worldName = map;
serverNameProvider = port -> "" + map; serverNameProvider = port -> "*" + map;
checkpoint = true; checkpoint = true;
constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback); constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback);

Datei anzeigen

@ -93,17 +93,23 @@ public class BauCommand extends SWCommand {
@Validator(value = "teleportTarget", local = true) @Validator(value = "teleportTarget", local = true)
public TypeValidator<SteamwarUser> teleportTargetValidator() { public TypeValidator<SteamwarUser> teleportTargetValidator() {
return (sender, value, messageSender) -> { return (sender, owner, messageSender) -> {
if (value == null) { if (owner == null) {
messageSender.send("UNKNOWN_PLAYER"); messageSender.send("UNKNOWN_PLAYER");
return false; return false;
} }
if (sender.user().getId() != value.getId() && BauweltMember.getBauMember(value.getId(), sender.user().getId()) == null) { if (sender.user().getId() != owner.getId() && BauweltMember.getBauMember(owner.getId(), sender.user().getId()) == null) {
SubserverSystem.sendDeniedMessage(sender, value.getUUID()); SubserverSystem.sendDeniedMessage(sender, owner.getUUID());
messageSender.send("BAU_TP_NOALLOWED"); messageSender.send("BAU_TP_NOALLOWED");
return false; 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;
}; };
} }

Datei anzeigen

@ -30,10 +30,10 @@ public class BugCommand extends SWCommand {
@Register @Register
public void bugMessage(Chatter sender, String... message) { public void bugMessage(Chatter sender, String... message) {
SWException.log( int id = SWException.logGetId(
String.join(" ", message), String.join(" ", message),
sender.withPlayerOrOffline(player -> player.getCurrentServer().map(connection -> connection.getServerInfo().getName()).orElse("offline"), () -> "offline") + " " + sender.user().getUserName() + " " + sender.user().getId() 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);
} }
} }

Datei anzeigen

@ -53,7 +53,7 @@ public class HelpCommand extends SWCommand {
@Register({"build","player"}) @Register({"build","player"})
public void buildPlayer(Chatter sender) { 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"}) @Register({"build","worldedit"})

Datei anzeigen

@ -124,7 +124,9 @@ public class TpCommand extends SWCommand {
sender.system("JOIN_PLAYER_BLOCK"); sender.system("JOIN_PLAYER_BLOCK");
return; 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; return;
} else if (!bauserver.getOwner().equals(sender.user().getUUID()) && BauweltMember.getBauMember(bauserver.getOwner(), sender.user().getUUID()) == null) { } else if (!bauserver.getOwner().equals(sender.user().getUUID()) && BauweltMember.getBauMember(bauserver.getOwner(), sender.user().getUUID()) == null) {
SubserverSystem.sendDeniedMessage(sender, bauserver.getOwner()); SubserverSystem.sendDeniedMessage(sender, bauserver.getOwner());

Datei anzeigen

@ -74,17 +74,17 @@ public class ChannelListener extends ListenerAdapter {
if(sender.user().getDiscordId() == null) if(sender.user().getDiscordId() == null)
return; 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); OptionMapping option = event.getOption(DiscordBot.ARGUMENT_NAME);
String args = ""; String args = "";
if(option != null) if(option != null)
args = option.getAsString(); 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(" ")); command.execute(sender, args.split(" "));
}); });
} }

Datei anzeigen

@ -32,6 +32,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Emoji; 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.TextChannel;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
@ -83,8 +84,8 @@ public class DiscordTicketHandler extends ListenerAdapter {
@Override @Override
public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) { public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
TextChannel channel = event.getTextChannel(); MessageChannel messageChannel = event.getChannel();
if(channel.getParent() != null && channel.getParent().getId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) { if(messageChannel instanceof TextChannel channel && channel.getParent() != null && channel.getParent().getId().equals(TICKET_CATEGORY) && event.getComponentId().startsWith("close-")) {
LinkedList<StringBuilder> messages = channel.getIterableHistory().complete().stream() LinkedList<StringBuilder> messages = channel.getIterableHistory().complete().stream()
.filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot()) .filter(message -> !message.getAuthor().isSystem() && !message.getAuthor().isBot())
.map(message -> { .map(message -> {
@ -149,7 +150,7 @@ public class DiscordTicketHandler extends ListenerAdapter {
if(event.getAuthor().isBot()) if(event.getAuthor().isBot())
return; return;
ChatterGroup receivers = Chatter.serverteam(); ChatterGroup receivers = new ChatterGroup(Chatter.allStream().filter(player -> player.user().hasPerm(UserPerm.TICKET_LOG)));
try { try {
SteamwarUser user = SteamwarUser.get(Long.parseLong(channel.getTopic())); SteamwarUser user = SteamwarUser.get(Long.parseLong(channel.getTopic()));
if(user != null && !user.perms().contains(UserPerm.TEAM)) if(user != null && !user.perms().contains(UserPerm.TEAM))

Datei anzeigen

@ -74,7 +74,7 @@ public class ChatListener extends BasicListener {
public void logCommands(CommandExecuteEvent e) { public void logCommands(CommandExecuteEvent e) {
String command = e.getCommand(); String command = e.getCommand();
int space = command.indexOf(' '); 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(); CommandSource source = e.getCommandSource();
String name; String name;
if(source instanceof Player player) if(source instanceof Player player)
@ -85,6 +85,9 @@ public class ChatListener extends BasicListener {
name = source.toString(); name = source.toString();
cmdLogger.log(Level.INFO, "%s -> executed command /%s".formatted(name, command)); 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());
} }
} }

Datei anzeigen

@ -19,13 +19,16 @@
package de.steamwar.velocitycore.tablist; package de.steamwar.velocitycore.tablist;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.util.GameProfile; import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.network.Connections; import com.velocitypowered.proxy.network.Connections;
import com.velocitypowered.proxy.protocol.MinecraftPacket; 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.RemovePlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.UpdateTeamsPacket;
import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket; import com.velocitypowered.proxy.protocol.packet.UpsertPlayerInfoPacket;
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder; import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
import de.steamwar.messages.Chatter; import de.steamwar.messages.Chatter;
@ -46,8 +49,8 @@ import java.util.stream.IntStream;
public class Tablist extends ChannelInboundHandlerAdapter { public class Tablist extends ChannelInboundHandlerAdapter {
private static final UUID[] swUuids = IntStream.range(0, 80).mapToObj(i -> UUID.randomUUID()).toArray(UUID[]::new); 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); private 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"; 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<UUID, UpsertPlayerInfoPacket.Entry> directTabItems; private final Map<UUID, UpsertPlayerInfoPacket.Entry> directTabItems;
private final List<UpsertPlayerInfoPacket.Entry> current = new ArrayList<>(); private final List<UpsertPlayerInfoPacket.Entry> current = new ArrayList<>();
@ -136,6 +139,11 @@ public class Tablist extends ChannelInboundHandlerAdapter {
synchronized (directTabItems) { synchronized (directTabItems) {
directTabItems.clear(); directTabItems.clear();
} }
if(player.getProtocolVersion().greaterThan(ProtocolVersion.MINECRAFT_1_20)) {
current.clear();
sendPacket(player, createTeamPacket);
}
} }
private void injection() { private void injection() {
@ -205,6 +213,40 @@ public class Tablist extends ChannelInboundHandlerAdapter {
directTabItems.remove(uuid); 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); ctx.fireChannelRead(msg);
@ -214,6 +256,23 @@ public class Tablist extends ChannelInboundHandlerAdapter {
if(items.isEmpty()) if(items.isEmpty())
return; 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 if(action == null) { //REMOVE
sendPacket(player, new RemovePlayerInfoPacket(items.stream().map(item -> item.getProfile().getId()).toList())); sendPacket(player, new RemovePlayerInfoPacket(items.stream().map(item -> item.getProfile().getId()).toList()));
return; return;
@ -235,7 +294,9 @@ public class Tablist extends ChannelInboundHandlerAdapter {
private String ping() { private String ping() {
long ping = player.getPing(); long ping = player.getPing();
if (ping < 50) { if (ping == -1) {
return "§7?";
} else if (ping < 50) {
return "§a" + ping; return "§a" + ping;
} else if (ping < 150) { } else if (ping < 150) {
return "§e" + ping; return "§e" + ping;

Datei anzeigen

@ -25,16 +25,17 @@ import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer; 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.Servertype;
import de.steamwar.persistent.Storage; import de.steamwar.persistent.Storage;
import de.steamwar.persistent.Subserver; import de.steamwar.persistent.Subserver;
import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.listeners.BasicListener; 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; import java.util.concurrent.TimeUnit;
public class TablistManager extends BasicListener { public class TablistManager extends BasicListener {
@ -46,8 +47,6 @@ public class TablistManager extends BasicListener {
fightInfos.keySet().removeIf(serverInfo -> serverInfo.getPlayersConnected().isEmpty()); 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<Player, Tablist> tablists = new HashMap<>(); private final Map<Player, Tablist> tablists = new HashMap<>();
private int seconds = 0; private int seconds = 0;
@ -61,10 +60,10 @@ public class TablistManager extends BasicListener {
@Subscribe @Subscribe
public void onJoin(PostLoginEvent event) { public void onJoin(PostLoginEvent event) {
Tablist.sendPacket(event.getPlayer(), createTeamPacket);
synchronized (tablists) { synchronized (tablists) {
tablists.put(event.getPlayer(), new Tablist(event.getPlayer())); tablists.put(event.getPlayer(), new Tablist(event.getPlayer()));
} }
Tablist.sendPacket(event.getPlayer(), Tablist.createTeamPacket);
} }
@Subscribe @Subscribe

Datei anzeigen

@ -34,8 +34,7 @@ public class BauLock {
owner.system("BAU_LOCKED_" + state.name()); owner.system("BAU_LOCKED_" + state.name());
} }
public static boolean checkNotifyLocked(SteamwarUser owner, Chatter sender) { public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
SteamwarUser target = sender.user();
if (owner.getId() == target.getId()) if (owner.getId() == target.getId())
return false; return false;
@ -62,12 +61,6 @@ public class BauLock {
locked = false; locked = false;
} }
if(locked) {
sender.system("BAU_LOCKED_NOALLOWED");
Chatter.of(owner.getUUID()).system("BAU_LOCK_BLOCKED", sender);
}
return locked; return locked;
} }
} }