forked from SteamWar/SteamWar
Add StreamingCommand for streaming mode
This commit is contained in:
@@ -623,6 +623,7 @@ SERVER_WORLD_ERROR=§cCreating the world failed.
|
|||||||
WHOIS_USAGE=§c/whois [player/ID] [-a/-m]
|
WHOIS_USAGE=§c/whois [player/ID] [-a/-m]
|
||||||
WHOIS_USERNAME=§7Username§8: §e{0}
|
WHOIS_USERNAME=§7Username§8: §e{0}
|
||||||
WHOIS_PREFIX=§7Chat-Prefix§8: {0}
|
WHOIS_PREFIX=§7Chat-Prefix§8: {0}
|
||||||
|
WHOIS_STREAMING=§7Streaming§8: §e{0}
|
||||||
WHOIS_UUID=§7UUID§8: §e{0}
|
WHOIS_UUID=§7UUID§8: §e{0}
|
||||||
WHOIS_UUID_HOVER=§eCopy UUID
|
WHOIS_UUID_HOVER=§eCopy UUID
|
||||||
WHOIS_ID=§7ID§8: §e{0}
|
WHOIS_ID=§7ID§8: §e{0}
|
||||||
@@ -735,6 +736,10 @@ INV_PAGE_NEXT=§{0}Seite vor
|
|||||||
#VersionAnnouncer
|
#VersionAnnouncer
|
||||||
SERVER_VERSION=§7This server runs on Minecraft version §e{0}
|
SERVER_VERSION=§7This server runs on Minecraft version §e{0}
|
||||||
|
|
||||||
|
#StreamingCommand
|
||||||
|
STREAMING_ENABLE=§7Streaming mode §aenabled§8.
|
||||||
|
STREAMING_DISABLE=§7Streaming mode §cdisabled§8.
|
||||||
|
|
||||||
#Discord
|
#Discord
|
||||||
DC_UNLINKED=For this action your Discord account has to be linked to your Minecraft account. To link your accounts go onto the SteamWar Discord to the `regeln-infos` Channel and click on `Minecraft Verknüpfen`.
|
DC_UNLINKED=For this action your Discord account has to be linked to your Minecraft account. To link your accounts go onto the SteamWar Discord to the `regeln-infos` Channel and click on `Minecraft Verknüpfen`.
|
||||||
DC_TITLE_SCHEMINFO=Schematic Info
|
DC_TITLE_SCHEMINFO=Schematic Info
|
||||||
|
|||||||
@@ -683,6 +683,10 @@ INV_PAGE_NEXT=§{0}Next page
|
|||||||
#VersionAnnouncer
|
#VersionAnnouncer
|
||||||
SERVER_VERSION=§7Dieser Server läuft auf Minecraft-Version §e{0}
|
SERVER_VERSION=§7Dieser Server läuft auf Minecraft-Version §e{0}
|
||||||
|
|
||||||
|
#StreamingCommand
|
||||||
|
STREAMING_ENABLE=§7Streaming Modus §aaktiviert§8.
|
||||||
|
STREAMING_DISABLE=§7Streaming Modus §cdeaktiviert§8.
|
||||||
|
|
||||||
#Discord
|
#Discord
|
||||||
DC_UNLINKED=Für diese Aktion muss dein Minecraftaccount mit deinem Discordaccount verknüpft sein, gehe dazu auf dem SteamWar-Discord in den `regeln-infos` Channel und Klicke auf `Minecraft Verknüpfen`.
|
DC_UNLINKED=Für diese Aktion muss dein Minecraftaccount mit deinem Discordaccount verknüpft sein, gehe dazu auf dem SteamWar-Discord in den `regeln-infos` Channel und Klicke auf `Minecraft Verknüpfen`.
|
||||||
DC_TITLE_SCHEMINFO=Schematicinfo
|
DC_TITLE_SCHEMINFO=Schematicinfo
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import de.steamwar.persistent.Subserver;
|
|||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
import de.steamwar.velocitycore.VelocityCore;
|
import de.steamwar.velocitycore.VelocityCore;
|
||||||
|
import de.steamwar.velocitycore.commands.StreamingCommand;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
@@ -68,7 +69,9 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ChatterGroup serverteam() {
|
static ChatterGroup serverteam() {
|
||||||
return new ChatterGroup(allStream().filter(player -> player.user().hasPerm(UserPerm.TEAM)));
|
return new ChatterGroup(allStream()
|
||||||
|
.filter(player -> player.user().hasPerm(UserPerm.TEAM))
|
||||||
|
.filter(StreamingCommand::isNotStreaming));
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user();
|
SteamwarUser user();
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.velocitycore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
public StreamingCommand() {
|
||||||
|
super("streaming", UserPerm.TEAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void toggleStreamingMode(Chatter sender) {
|
||||||
|
int userId = sender.user().getId();
|
||||||
|
if (streaming.contains(userId)) {
|
||||||
|
streaming.remove(userId);
|
||||||
|
sender.system("STREAMING_DISABLE");
|
||||||
|
} else {
|
||||||
|
streaming.add(userId);
|
||||||
|
sender.system("STREAMING_ENABLE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -312,7 +312,19 @@ public class TeamCommand extends SWCommand {
|
|||||||
private String getMemberList(List<SteamwarUser> users, boolean leaders) {
|
private String getMemberList(List<SteamwarUser> users, boolean leaders) {
|
||||||
return users.stream()
|
return users.stream()
|
||||||
.filter(user -> user.isLeader() == leaders)
|
.filter(user -> user.isLeader() == leaders)
|
||||||
.map(user -> (VelocityCore.getProxy().getPlayer(user.getUUID()).isPresent() ? "§a" : "§e") + user.getUserName())
|
.map(user -> {
|
||||||
|
StringBuilder st = new StringBuilder();
|
||||||
|
if (VelocityCore.getProxy().getPlayer(user.getUUID()).isPresent()) {
|
||||||
|
if (!StreamingCommand.isNotStreaming(user)) {
|
||||||
|
st.append("§5● ");
|
||||||
|
}
|
||||||
|
st.append("§a");
|
||||||
|
} else {
|
||||||
|
st.append("§e");
|
||||||
|
}
|
||||||
|
st.append(user.getUserName());
|
||||||
|
return st.toString();
|
||||||
|
})
|
||||||
.collect(Collectors.joining(" "));
|
.collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,6 @@ public class TeamchatCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatListener.sendChat(sender, new ChatterGroup(Chatter.allStream().filter(p -> p.user().getTeam() == user.getTeam())), "CHAT_TEAM", null, String.join(" ", args));
|
ChatListener.sendChat(sender, new ChatterGroup(Chatter.allStream().filter(p -> p.user().getTeam() == user.getTeam()).filter(StreamingCommand::isNotStreaming)), "CHAT_TEAM", null, String.join(" ", args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public class WhoisCommand extends SWCommand {
|
|||||||
if (!sender.user().hasPerm(UserPerm.TEAM))
|
if (!sender.user().hasPerm(UserPerm.TEAM))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sender.system("WHOIS_STREAMING", !StreamingCommand.isNotStreaming(user));
|
||||||
if (sender.user().hasPerm(UserPerm.MODERATION) || sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) {
|
if (sender.user().hasPerm(UserPerm.MODERATION) || sender.user().hasPerm(UserPerm.PREFIX_DEVELOPER)) {
|
||||||
sender.system("WHOIS_ID", user.getId());
|
sender.system("WHOIS_ID", user.getId());
|
||||||
sender.system("WHOIS_UUID", new Message("WHOIS_UUID_HOVER"), ClickEvent.copyToClipboard(user.getUUID().toString()), user.getUUID().toString());
|
sender.system("WHOIS_UUID", new Message("WHOIS_UUID_HOVER"), ClickEvent.copyToClipboard(user.getUUID().toString()), user.getUUID().toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user