Improve StreamingCommand

This commit is contained in:
2025-09-29 08:17:49 +02:00
parent 524ce0c579
commit 5fe62d67d9
6 changed files with 17 additions and 17 deletions
@@ -21,22 +21,18 @@ package de.steamwar.velocitycore.commands;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.Chatter;
import de.steamwar.persistent.Storage;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import java.util.HashSet;
import java.util.Set;
public class StreamingCommand extends SWCommand {
private static final Set<Integer> streaming = new HashSet<>();
public static boolean isNotStreaming(Chatter sender) {
return isNotStreaming(sender.user());
}
public static boolean isNotStreaming(SteamwarUser user) {
return !streaming.contains(user.getId());
return !Storage.streamingPlayers.contains(user.getId());
}
public StreamingCommand() {
@@ -46,11 +42,11 @@ public class StreamingCommand extends SWCommand {
@Register
public void toggleStreamingMode(Chatter sender) {
int userId = sender.user().getId();
if (streaming.contains(userId)) {
streaming.remove(userId);
if (Storage.streamingPlayers.contains(userId)) {
Storage.streamingPlayers.remove(userId);
sender.system("STREAMING_DISABLE");
} else {
streaming.add(userId);
Storage.streamingPlayers.add(userId);
sender.system("STREAMING_ENABLE");
}
}
@@ -316,9 +316,10 @@ public class TeamCommand extends SWCommand {
StringBuilder st = new StringBuilder();
if (VelocityCore.getProxy().getPlayer(user.getUUID()).isPresent()) {
if (!StreamingCommand.isNotStreaming(user)) {
st.append("§5");
st.append("§5");
} else {
st.append("§a");
}
st.append("§a");
} else {
st.append("§e");
}
@@ -34,7 +34,6 @@ import de.steamwar.sql.CheckedSchematic;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import de.steamwar.velocitycore.EventStarter;
import de.steamwar.velocitycore.commands.*;
import de.steamwar.velocitycore.discord.DiscordBot;
import de.steamwar.velocitycore.discord.util.DiscordRanks;
@@ -45,7 +44,6 @@ import net.kyori.adventure.text.event.ClickEvent;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.function.BiConsumer;
public class ConnectionListener extends BasicListener {
@@ -105,6 +103,10 @@ public class ConnectionListener extends BasicListener {
newPlayers.remove(player.getUniqueId());
}
if (!StreamingCommand.isNotStreaming(user)) {
chatter.system("JOIN_STREAMING");
}
DiscordBot.withBot(bot -> DiscordRanks.update(user));
if (player.getProtocolVersion().noLessThan(ProtocolVersion.MINECRAFT_1_20_5)) {