From f4aa1c803b58144c02744a966944236f21256c5d Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 09:16:38 +0200 Subject: [PATCH 01/13] Refactoring --- .../generic/node/enums/CommandProxy.html | 2 +- module-src/require-module/.gitignore | 5 + module-src/require-module/pom.xml | 153 ++++++++++++++++++ .../modules/require/RequireModule.java | 30 ++++ .../src/main/resources/type.info | 1 + .../subcommand/BungeeAliasCommand.java | 4 +- .../BungeePersonalsettingsCommand.java | 4 +- .../subcommand/BungeeRegionCommand.java | 4 +- .../subcommand/BungeeShowCommand.java | 4 +- .../subcommand/BungeeSpeakerCommand.java | 4 +- .../subcommand/BungeeVoiceCommand.java | 4 +- .../generic/client/session/SessionData.java | 1 + ...{CommandProxy.java => ProxiedCommand.java} | 2 +- .../generic/rd/RestDirectService.java | 1 + .../proxy/listeners/BukkitPacketListener.java | 2 +- .../proxy/objects/CommandProxyPayload.java | 4 +- .../subcommand/VelocityAliasCommand.java | 4 +- .../subcommand/VelocityRegionCommand.java | 4 +- .../subcommand/VelocityShowCommand.java | 4 +- .../subcommand/VelocitySpeakerCommand.java | 4 +- pom.xml | 1 + 21 files changed, 217 insertions(+), 25 deletions(-) create mode 100644 module-src/require-module/.gitignore create mode 100644 module-src/require-module/pom.xml create mode 100644 module-src/require-module/src/main/java/com/craftmend/openaudiomc/modules/require/RequireModule.java create mode 100644 module-src/require-module/src/main/resources/type.info rename plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/{CommandProxy.java => ProxiedCommand.java} (83%) diff --git a/docs/javadoc/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.html b/docs/javadoc/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.html index 16659fd3d..265dbec44 100644 --- a/docs/javadoc/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.html +++ b/docs/javadoc/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.html @@ -102,7 +102,7 @@

Enum CommandProxy

  • java.lang.Enum<CommandProxy>
  • diff --git a/module-src/require-module/.gitignore b/module-src/require-module/.gitignore new file mode 100644 index 000000000..a8463100e --- /dev/null +++ b/module-src/require-module/.gitignore @@ -0,0 +1,5 @@ +target/ +target/* +.DS_Store +test-storage/ +test-server/ \ No newline at end of file diff --git a/module-src/require-module/pom.xml b/module-src/require-module/pom.xml new file mode 100644 index 000000000..f392ecb46 --- /dev/null +++ b/module-src/require-module/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + + com.craftmend.openaudiomc + OpenAudioMc-require + ${oa.version} + + OpenAudioMc-require + + + com.craftmend.openaudiomc + OpenAudioMc-Parent + ../../pom.xml + 1.1 + + + + 1.8 + UTF-8 + + + + vistas-client + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + de.tr7zw.changeme.nbtapi + com.craftmend.thirdparty.nbt + + + io. + com.craftmend.thirdparty.io + + + org.json. + com.craftmend.thirdparty.json + + + reactor. + com.craftmend.thirdparty.reactor + + + okhttp3 + com.craftmend.thirdparty.okhttp3 + + + okio + com.craftmend.thirdparty.okio + + + org.projectlombok + com.craftmend.thirdparty.org + + + org.mapdb + com.craftmend.thirdparty.mapdb + + + kotlin + com.craftmend.thirdparty.kotlin + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + alessiodp-repo + https://repo.alessiodp.com/releases/ + + + jitpack.io + https://jitpack.io + + + + + + com.craftmend.openaudiomc + openaudiomc + ${oa.version} + provided + + + + org.spigotmc + spigot-api + 1.8.8-R0.1-SNAPSHOT + provided + + + org.projectlombok + lombok + 1.18.22 + compile + + + + \ No newline at end of file diff --git a/module-src/require-module/src/main/java/com/craftmend/openaudiomc/modules/require/RequireModule.java b/module-src/require-module/src/main/java/com/craftmend/openaudiomc/modules/require/RequireModule.java new file mode 100644 index 000000000..03afb177c --- /dev/null +++ b/module-src/require-module/src/main/java/com/craftmend/openaudiomc/modules/require/RequireModule.java @@ -0,0 +1,30 @@ +package com.craftmend.openaudiomc.modules.require; + +import com.craftmend.openaudiomc.api.enums.ModuleEvent; +import com.craftmend.openaudiomc.api.interfaces.ExternalModule; +import org.bukkit.event.Listener; + +public final class RequireModule extends ExternalModule implements Listener { + + private boolean isVoicechatActive = false; + + @Override + public String getName() { + return "RequireModule"; + } + + @Override + public String getDescription() { + return "Require end-users to use OpenAudioMc"; + } + + @Override + public void onInitialize() { + + } + + @Override + public void on(ModuleEvent event) { + + } +} diff --git a/module-src/require-module/src/main/resources/type.info b/module-src/require-module/src/main/resources/type.info new file mode 100644 index 000000000..dc2e2762b --- /dev/null +++ b/module-src/require-module/src/main/resources/type.info @@ -0,0 +1 @@ +main: com.craftmend.openaudiomc.modules.require.RequireModule \ No newline at end of file diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeAliasCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeAliasCommand.java index c7c7a6c8b..2dd8939e9 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeAliasCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeAliasCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -39,7 +39,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.ALIAS); + payload.setProxiedCommand(ProxiedCommand.ALIAS); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeePersonalsettingsCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeePersonalsettingsCommand.java index 211a774d3..bbf71e3ce 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeePersonalsettingsCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeePersonalsettingsCommand.java @@ -3,7 +3,7 @@ import com.craftmend.openaudiomc.OpenAudioMc; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -37,7 +37,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.PERSONALSETTINGS); + payload.setProxiedCommand(ProxiedCommand.PERSONALSETTINGS); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeRegionCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeRegionCommand.java index c54c692a5..ec783580d 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeRegionCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeRegionCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -41,7 +41,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.REGION); + payload.setProxiedCommand(ProxiedCommand.REGION); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeShowCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeShowCommand.java index 3cca94d78..25a0bc2c1 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeShowCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeShowCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -57,7 +57,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.SHOW); + payload.setProxiedCommand(ProxiedCommand.SHOW); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeSpeakerCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeSpeakerCommand.java index 7acfb76c6..33fc44981 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeSpeakerCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeSpeakerCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -44,7 +44,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.SPEAKER); + payload.setProxiedCommand(ProxiedCommand.SPEAKER); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender,new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeVoiceCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeVoiceCommand.java index 662041b6c..cc71ccf4f 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeVoiceCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/bungee/modules/commands/subcommand/BungeeVoiceCommand.java @@ -3,7 +3,7 @@ import com.craftmend.openaudiomc.OpenAudioMc; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -32,7 +32,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(sender.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.ALIAS); + payload.setProxiedCommand(ProxiedCommand.ALIAS); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java index 942ac9203..edfb7f802 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java @@ -23,6 +23,7 @@ public class SessionData { private final transient ClientConnection client; + private boolean isModerating = false; private boolean isWaitingToken = false; private boolean sessionUpdated = false; private boolean hasHueLinked = false; diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/ProxiedCommand.java similarity index 83% rename from plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.java rename to plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/ProxiedCommand.java index 15f8bcbae..012daceeb 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/CommandProxy.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/node/enums/ProxiedCommand.java @@ -1,6 +1,6 @@ package com.craftmend.openaudiomc.generic.node.enums; -public enum CommandProxy { +public enum ProxiedCommand { REGION, SPEAKER, diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/rd/RestDirectService.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/rd/RestDirectService.java index 694e8ee71..7a8558388 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/rd/RestDirectService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/rd/RestDirectService.java @@ -61,6 +61,7 @@ public RestDirectServer attemptServerBoot() { } if (StorageKey.CDN_IP_OVERWRITE.getString() != null && !StorageKey.CDN_IP_OVERWRITE.getString().equals("none")) { + OpenAudioLogger.toConsole("Attempting to use IP overwrite with " + StorageKey.CDN_IP_OVERWRITE.getString()); ip = StorageKey.CDN_IP_OVERWRITE.getString(); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/listeners/BukkitPacketListener.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/listeners/BukkitPacketListener.java index 0ef8b92dd..307fa6a80 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/listeners/BukkitPacketListener.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/listeners/BukkitPacketListener.java @@ -80,7 +80,7 @@ public void onCommand(User user, CommandProxyPacket packet) { User player = OpenAudioMc.resolveDependency(UserHooks.class).byUuid(packet.getCommandProxy().getExecutor()); if (player == null) return; OpenAudioMc.getService(CommandService.class) - .getSubCommand(packet.getCommandProxy().getCommandProxy().toString().toLowerCase()) + .getSubCommand(packet.getCommandProxy().getProxiedCommand().toString().toLowerCase()) .onExecute(player, packet.getCommandProxy().getArgs()); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/objects/CommandProxyPayload.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/objects/CommandProxyPayload.java index 96aa94109..d1edda91d 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/objects/CommandProxyPayload.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/proxy/objects/CommandProxyPayload.java @@ -1,6 +1,6 @@ package com.craftmend.openaudiomc.spigot.modules.proxy.objects; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -12,7 +12,7 @@ @AllArgsConstructor public class CommandProxyPayload { - private CommandProxy commandProxy; + private ProxiedCommand proxiedCommand; private String[] args; private UUID executor; diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityAliasCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityAliasCommand.java index 0eb1719d4..ddf30ad88 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityAliasCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityAliasCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.OpenAudioMc; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -30,7 +30,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(sender.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.ALIAS); + payload.setProxiedCommand(ProxiedCommand.ALIAS); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityRegionCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityRegionCommand.java index 0bf481163..e5383632e 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityRegionCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityRegionCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.OpenAudioMc; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -33,7 +33,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.REGION); + payload.setProxiedCommand(ProxiedCommand.REGION); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityShowCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityShowCommand.java index 258401d77..bb6d79b5f 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityShowCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocityShowCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.OpenAudioMc; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -47,7 +47,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(sender.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.SHOW); + payload.setProxiedCommand(ProxiedCommand.SHOW); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocitySpeakerCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocitySpeakerCommand.java index 9897e2aa5..8734e6fed 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocitySpeakerCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/commands/subcommand/VelocitySpeakerCommand.java @@ -4,7 +4,7 @@ import com.craftmend.openaudiomc.OpenAudioMc; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; -import com.craftmend.openaudiomc.generic.node.enums.CommandProxy; +import com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand; import com.craftmend.openaudiomc.generic.node.packets.CommandProxyPacket; import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks; import com.craftmend.openaudiomc.generic.user.User; @@ -36,7 +36,7 @@ public void onExecute(User sender, String[] args) { CommandProxyPayload payload = new CommandProxyPayload(); payload.setExecutor(player.getUniqueId()); payload.setArgs(args); - payload.setCommandProxy(CommandProxy.SPEAKER); + payload.setProxiedCommand(ProxiedCommand.SPEAKER); OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload)); } diff --git a/pom.xml b/pom.xml index 8f878b7e6..03da08d46 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,7 @@ module-src/jutils plugin + module-src/require-module module-src/vistas-client module-src/vistas-server module-src/rinaorc-legacy From f25e525b46808c62e65110cb88e7c36242e3a779 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 09:22:33 +0200 Subject: [PATCH 02/13] Rename the old gui menu to 'inspect' --- .../modules/commands/subcommands/VoiceSubCommand.java | 6 +++--- ...{VoiceModSubCommand.java => VoiceInspectSubCommand.java} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/{VoiceModSubCommand.java => VoiceInspectSubCommand.java} (95%) diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java index ccd9c6935..0721f3e17 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java @@ -3,18 +3,18 @@ import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; import com.craftmend.openaudiomc.generic.user.User; -import com.craftmend.openaudiomc.spigot.modules.commands.subcommands.voice.VoiceModSubCommand; +import com.craftmend.openaudiomc.spigot.modules.commands.subcommands.voice.VoiceInspectSubCommand; public class VoiceSubCommand extends SubCommand { public VoiceSubCommand() { super("voice", "vc", "voicechat", "proximity", "pv"); registerSubCommands( - new VoiceModSubCommand() + new VoiceInspectSubCommand() ); registerArguments( - new Argument("mod ", "Open the moderation menu to view the status of a player or ban them") + new Argument("inspect ", "Open the moderation menu to view the status of a player or ban them") ); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java similarity index 95% rename from plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java rename to plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java index 4be72419a..1700f1be6 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java @@ -13,10 +13,10 @@ import java.util.UUID; -public class VoiceModSubCommand extends SubCommand { +public class VoiceInspectSubCommand extends SubCommand { - public VoiceModSubCommand() { - super("mod"); + public VoiceInspectSubCommand() { + super("inspect"); this.trimArguments = true; } From a9d95775f4ce8e526ef0940259afd2c95cee7f86 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 09:26:56 +0200 Subject: [PATCH 03/13] Implement command and add config option: --- .../generic/migrations/MigrationWorker.java | 1 + .../migrations/AddVcModConfigMigration.java | 21 ++++++++++++++++ .../generic/storage/enums/StorageKey.java | 1 + .../commands/subcommands/VoiceSubCommand.java | 10 +++++++- ...{VoiceModGui.java => VoiceInspectGui.java} | 6 ++--- .../voice/VoiceInspectSubCommand.java | 6 ++--- .../subcommands/voice/VoiceModSubCommand.java | 24 +++++++++++++++++++ plugin/src/main/resources/config.yml | 4 ++++ 8 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/migrations/AddVcModConfigMigration.java rename plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/{VoiceModGui.java => VoiceInspectGui.java} (95%) create mode 100644 plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/MigrationWorker.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/MigrationWorker.java index e1bd130cf..7820ee8fa 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/MigrationWorker.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/MigrationWorker.java @@ -47,6 +47,7 @@ public void handleMigrations() { new AddRDTimeoutMigration(), // configurable timeout new AddPapiMigration(), // add placeholder api values new AddRDIpMigration(), // add rd ip config + new AddVcModConfigMigration(), // adds the option to enable/disable moderation support }; for (SimpleMigration migration : migrations) { diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/migrations/AddVcModConfigMigration.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/migrations/AddVcModConfigMigration.java new file mode 100644 index 000000000..4ff28cc21 --- /dev/null +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/migrations/migrations/AddVcModConfigMigration.java @@ -0,0 +1,21 @@ +package com.craftmend.openaudiomc.generic.migrations.migrations; + +import com.craftmend.openaudiomc.OpenAudioMc; +import com.craftmend.openaudiomc.generic.migrations.MigrationWorker; +import com.craftmend.openaudiomc.generic.migrations.interfaces.SimpleMigration; +import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; +import com.craftmend.openaudiomc.generic.storage.interfaces.Configuration; + +public class AddVcModConfigMigration extends SimpleMigration { + + @Override + public boolean shouldBeRun(MigrationWorker migrationWorker) { + Configuration config = OpenAudioMc.getInstance().getConfiguration(); + return !config.hasStorageKey(StorageKey.SETTINGS_VC_MOD_ENABLED); + } + + @Override + public void execute(MigrationWorker migrationWorker) { + migrateFilesFromResources(); + } +} diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/storage/enums/StorageKey.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/storage/enums/StorageKey.java index 731b41c09..281edad00 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/storage/enums/StorageKey.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/storage/enums/StorageKey.java @@ -34,6 +34,7 @@ public enum StorageKey { SETTING_VC_LEFT_MUTED_REGION(false, "messages.voice-reenabled-here", StorageLocation.CONFIG_FILE), SETTINGS_VC_ANNOUNCEMENTS(false, "options.voicechat-announcements", StorageLocation.CONFIG_FILE), SETTINGS_VC_PROCESS_OBSTRUCTIONS(false, "options.voicechat-obstructions", StorageLocation.CONFIG_FILE), + SETTINGS_VC_MOD_ENABLED(false, "options.voicechat-moderation-support", StorageLocation.CONFIG_FILE), SETTINGS_REMIND_TO_CONNECT(false, "options.remind-to-connect", StorageLocation.CONFIG_FILE), SETTINGS_REMIND_TO_CONNECT_INTERVAL(false, "options.remind-to-connect-interval", StorageLocation.CONFIG_FILE), diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java index 0721f3e17..a71c293ae 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/VoiceSubCommand.java @@ -4,16 +4,19 @@ import com.craftmend.openaudiomc.generic.commands.objects.Argument; import com.craftmend.openaudiomc.generic.user.User; import com.craftmend.openaudiomc.spigot.modules.commands.subcommands.voice.VoiceInspectSubCommand; +import com.craftmend.openaudiomc.spigot.modules.commands.subcommands.voice.VoiceModSubCommand; public class VoiceSubCommand extends SubCommand { public VoiceSubCommand() { super("voice", "vc", "voicechat", "proximity", "pv"); registerSubCommands( + new VoiceModSubCommand(), new VoiceInspectSubCommand() ); registerArguments( + new Argument("mod", "Toggle moderation mode for voicechat"), new Argument("inspect ", "Open the moderation menu to view the status of a player or ban them") ); } @@ -26,11 +29,16 @@ public void onExecute(User sender, String[] args) { return; } - if (args[0].equalsIgnoreCase("mod") && args.length == 2) { + if (args[0].equalsIgnoreCase("mod")) { delegateTo("mod", sender, args); return; } + if (args[0].equalsIgnoreCase("inspect")) { + delegateTo("inspect", sender, args); + return; + } + sender.makeExecuteCommand("oa help " + getCommand()); } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModGui.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectGui.java similarity index 95% rename from plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModGui.java rename to plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectGui.java index f99486d82..7bd3e5914 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModGui.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectGui.java @@ -19,9 +19,9 @@ import java.util.List; import java.util.UUID; -public class VoiceModGui extends Menu { +public class VoiceInspectGui extends Menu { - public VoiceModGui(Player moderator, ClientDataStore targetData, UUID targetId, String targetName) { + public VoiceInspectGui(Player moderator, ClientDataStore targetData, UUID targetId, String targetName) { super(OaColor.GOLD + targetName + "'s voice profile", 9); // three items @@ -89,7 +89,7 @@ private void toggleBan(Player moderator, ClientDataStore targetData, UUID target } } OpenAudioMc.getService(ClientDataService.class).save(targetData, targetId); - new VoiceModGui(moderator, targetData, targetId, targetName); + new VoiceInspectGui(moderator, targetData, targetId, targetName); } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java index 1700f1be6..6bdb9adf5 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceInspectSubCommand.java @@ -49,15 +49,15 @@ public void onExecute(User sender, String[] args) { })); clientDataRequest.setWhenFinished(clientDataStore -> { - handleMod(sender, args, clientDataStore, mojangProfile.getUuid(), mojangProfile.getName()); + handleInspect(sender, args, clientDataStore, mojangProfile.getUuid(), mojangProfile.getName()); }); }); } - public void handleMod(User sender, String[] args, ClientDataStore target, UUID targetId, String targetName) { + public void handleInspect(User sender, String[] args, ClientDataStore target, UUID targetId, String targetName) { message(sender, OaColor.GREEN + "Opening profile"); resolveDependency(TaskService.class).runSync(() -> { - new VoiceModGui((Player) sender.getOriginal(), target, targetId, targetName); + new VoiceInspectGui((Player) sender.getOriginal(), target, targetId, targetName); }); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java new file mode 100644 index 000000000..9fe5f0afa --- /dev/null +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java @@ -0,0 +1,24 @@ +package com.craftmend.openaudiomc.spigot.modules.commands.subcommands.voice; + +import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; +import com.craftmend.openaudiomc.generic.user.User; +import org.bukkit.entity.Player; + +public class VoiceModSubCommand extends SubCommand { + + public VoiceModSubCommand() { + super("mod"); + this.trimArguments = true; + } + + @Override + public void onExecute(User sender, String[] args) { + if (!(sender.getOriginal() instanceof Player)) { + message(sender, "Only players can open moderation menu's."); + return; + } + + + } + +} diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index f37944e91..89729d315 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -127,6 +127,10 @@ options: # Automatically request a free voicechat license when the server starts voicechat-autoclaim-on-start: true + # Enable/disable voicechat moderation. Disabled by default to prevent abuse. Setting this value to true will enable the + # "/oa voice mod" command + voicechat-moderation-support: false + # PlaceholderAPI papi: From e66b005ca46e2184638afb69886f6a2662b78906 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 09:34:23 +0200 Subject: [PATCH 04/13] Toggle moderation status and log it to users --- .../subcommands/voice/VoiceModSubCommand.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java index 9fe5f0afa..22cc43a2f 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java @@ -1,6 +1,10 @@ package com.craftmend.openaudiomc.spigot.modules.commands.subcommands.voice; +import com.craftmend.openaudiomc.generic.client.objects.ClientConnection; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; +import com.craftmend.openaudiomc.generic.logging.OpenAudioLogger; +import com.craftmend.openaudiomc.generic.networking.interfaces.NetworkingService; +import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; import com.craftmend.openaudiomc.generic.user.User; import org.bukkit.entity.Player; @@ -18,7 +22,30 @@ public void onExecute(User sender, String[] args) { return; } + if (!StorageKey.SETTINGS_VC_MOD_ENABLED.getBoolean()) { + message(sender, "Moderation is disabled in the config for security"); + return; + } + // toggle mod status + ClientConnection client = (ClientConnection) sender.findClient().get(); + client.getSession().setModerating(!client.getSession().isModerating()); + + if (client.getSession().isModerating()) { + OpenAudioLogger.toConsole(sender.getName() + " started moderating"); + bcToStaff(sender.getName() + " started moderating"); + } else { + OpenAudioLogger.toConsole(sender.getName() + " stopped moderating"); + bcToStaff(sender.getName() + " stopped moderating"); + } + } + + private void bcToStaff(String string) { + for (ClientConnection client : getService(NetworkingService.class).getClients()) { + if (isAllowed(client.getUser())) { + message(client.getUser(), string); + } + } } } From 4190845fbec25d3a929cf630730be0795995c136 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 09:40:51 +0200 Subject: [PATCH 05/13] Implement filter --- .../client/session/RtcSessionManager.java | 17 +++++++++++++---- .../voicechat/tasks/PlayerProximityTicker.java | 5 +++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/RtcSessionManager.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/RtcSessionManager.java index 1637d9aca..903e6dbd9 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/RtcSessionManager.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/RtcSessionManager.java @@ -82,14 +82,23 @@ public boolean linkTo(ClientConnection peer) { if (peer.getRtcSessionManager().subscriptions.contains(clientConnection.getOwner().getUniqueId())) return false; - peer.getRtcSessionManager().getSubscriptions().add(clientConnection.getOwner().getUniqueId()); + boolean skipPeer = false; + + // are we moderating? if so, and the other user isn't, we should force a one-sided subscription + if (clientConnection.getSession().isModerating() && !peer.getSession().isModerating()) { + skipPeer = true; + } + subscriptions.add(peer.getOwner().getUniqueId()); - peer.sendPacket(new PacketClientSubscribeToVoice(ClientVoiceSubscribePayload.fromClient(clientConnection, Vector3.from(peer)))); + if (!skipPeer) { + peer.getRtcSessionManager().getSubscriptions().add(clientConnection.getOwner().getUniqueId()); + peer.sendPacket(new PacketClientSubscribeToVoice(ClientVoiceSubscribePayload.fromClient(clientConnection, Vector3.from(peer)))); + AudioApi.getInstance().getEventDriver().fire(new PlayerEnterVoiceProximityEvent(clientConnection, peer, VoiceEventCause.NORMAL)); + } + clientConnection.sendPacket(new PacketClientSubscribeToVoice(ClientVoiceSubscribePayload.fromClient(peer, Vector3.from(clientConnection)))); - // throw events in both ways, since the two users are listening to eachother - AudioApi.getInstance().getEventDriver().fire(new PlayerEnterVoiceProximityEvent(clientConnection, peer, VoiceEventCause.NORMAL)); AudioApi.getInstance().getEventDriver().fire(new PlayerEnterVoiceProximityEvent(peer, clientConnection, VoiceEventCause.NORMAL)); updateLocationWatcher(); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java index ded37de23..0df6f948c 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java @@ -58,6 +58,11 @@ public void run() { // clear the applicable players if i'm disabled myself if (!client.getRtcSessionManager().getBlockReasons().isEmpty()) applicableClients.clear(); + // remove moderators, if I'm not moderating myself + if (!client.getSession().isModerating()) { + applicableClients.removeIf(other -> other.getSession().isModerating()); + } + // find players that we don't have yet applicableClients .stream() From cbca7e12312057a86237b91f8093d279959308e9 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 12:20:16 +0200 Subject: [PATCH 06/13] Pass value to the client --- .../openaudiomc/generic/client/objects/ClientConnection.java | 2 -- .../generic/networking/abstracts/PacketChannel.java | 1 + .../payloads/client/voice/ClientVoiceChatUnlockPayload.java | 1 + .../openaudiomc/generic/voicechat/bus/VoiceApiConnection.java | 3 ++- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/objects/ClientConnection.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/objects/ClientConnection.java index b06374f07..26312c602 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/objects/ClientConnection.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/objects/ClientConnection.java @@ -95,9 +95,7 @@ public void onConnect() { OpenAudioMc.resolveDependency(TaskService.class).schduleSyncDelayedTask(() -> { OpenAudioMc.getService(NetworkingService.class).send(this, new PacketClientProtocolRevisionPacket()); - session.getOngoingMedia().forEach(this::sendMedia); - connectHandlers.forEach(a -> a.run()); }, 3 diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/abstracts/PacketChannel.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/abstracts/PacketChannel.java index 839fd27a8..8b71c6fbc 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/abstracts/PacketChannel.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/abstracts/PacketChannel.java @@ -22,6 +22,7 @@ public enum PacketChannel { CLIENT_OUT_CREATE_MEDIA, CLIENT_OUT_UPDATE_MEDIA, CLIENT_OUT_SET_PROTOCOL_VERSION, + CLIENT_OUT_ENABLE_MODERATION, CLIENT_OUT_DESTROY_MEDIA, CLIENT_OUT_PREFETCH, CLIENT_OUT_PUSH_NOTIFICATION, diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/voice/ClientVoiceChatUnlockPayload.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/voice/ClientVoiceChatUnlockPayload.java index 9af53ba3a..df6fbf016 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/voice/ClientVoiceChatUnlockPayload.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/voice/ClientVoiceChatUnlockPayload.java @@ -11,5 +11,6 @@ public class ClientVoiceChatUnlockPayload extends AbstractPacketPayload { private String streamKey; private String streamServer; private int radius; + private boolean hasModeration; } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/voicechat/bus/VoiceApiConnection.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/voicechat/bus/VoiceApiConnection.java index 1b34760d1..ca5ba4614 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/voicechat/bus/VoiceApiConnection.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/voicechat/bus/VoiceApiConnection.java @@ -76,7 +76,8 @@ public VoiceApiConnection() { clientConnection.sendPacket(new PacketClientUnlockVoiceChat(new ClientVoiceChatUnlockPayload( clientConnection.getRtcSessionManager().getStreamKey(), this.host, - StorageKey.SETTINGS_VC_RADIUS.getInt() + StorageKey.SETTINGS_VC_RADIUS.getInt(), + StorageKey.SETTINGS_VC_MOD_ENABLED.getBoolean() ))); } }); From 97f65be703107ee72eaad4baf56857ff21d53ccc Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 12 Sep 2022 12:30:53 +0200 Subject: [PATCH 07/13] Primitive web ui banner --- client/build/data.bin | 2 +- client/src/en.lang | 1 + client/src/index.html | 13 ++++++++++++ .../socket/handlers/HandleVoicechatUnlock.js | 8 +++++++ .../target/OpenAudioMc.bundle.js | 2 +- docs/production-client/target/de.lang | 14 +++++++++++-- docs/production-client/target/en.lang | 1 + docs/production-client/target/index.html | 21 +++++++++++++++---- 8 files changed, 54 insertions(+), 8 deletions(-) diff --git a/client/build/data.bin b/client/build/data.bin index ad566e090..9179a5acf 100755 --- a/client/build/data.bin +++ b/client/build/data.bin @@ -1 +1 @@ -BUILD_NUM="1217" +BUILD_NUM="1226" diff --git a/client/src/en.lang b/client/src/en.lang index 27a25f614..7273f93e8 100644 --- a/client/src/en.lang +++ b/client/src/en.lang @@ -24,6 +24,7 @@ home.audioControls=Audio controls home.notificationsTitle=Notifications home.notificationsEmpty=You don't have any notifications at the moment +vc.voiceModerationEnabled=This server has moderation enabled. Select staff may be listening in when your mic is active. vc.notice=Notice vc.startingPopupTitle=Logging into voice chat... vc.startingPopup=Please wait while we get you setup with a voice server... hold on tight, this shouldn't take too long. diff --git a/client/src/index.html b/client/src/index.html index a04a2aec4..3db6a3c51 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -313,6 +313,19 @@

    @@ -313,6 +313,19 @@

    - © OpenAudioMc 2016-2021. All Rights Reserved. + © OpenAudioMc 2016-2022. All Rights Reserved.
    diff --git a/docs/production-client/target/OpenAudioMc.bundle.js b/docs/production-client/target/OpenAudioMc.bundle.js index 29cbd7d7a..ece8952de 100644 --- a/docs/production-client/target/OpenAudioMc.bundle.js +++ b/docs/production-client/target/OpenAudioMc.bundle.js @@ -1 +1 @@ -!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(i,r,function(t){return e[t]}.bind(null,r));return i},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=334)}([function(e,t,n){var i=n(1),r=n(7),o=n(14),s=n(11),a=n(17),u="prototype",c=function(e,t,n){var l,h,d,f,p=e&c.F,g=e&c.G,m=e&c.S,v=e&c.P,y=e&c.B,b=g?i:m?i[t]||(i[t]={}):(i[t]||{})[u],w=g?r:r[t]||(r[t]={}),S=w[u]||(w[u]={});for(l in g&&(n=t),n)d=((h=!p&&b&&void 0!==b[l])?b:n)[l],f=y&&h?a(d,i):v&&"function"==typeof d?a(Function.call,d):d,b&&s(b,l,d,e&c.U),w[l]!=d&&o(w,l,f),v&&S[l]!=d&&(S[l]=d)};i.core=r,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)},function(e){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){var i=n(4);e.exports=function(e){if(!i(e))throw TypeError(e+" is not an object!");return e}},function(e){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){var i=n(48)("wks"),r=n(29),o=n(1).Symbol,s="function"==typeof o;(e.exports=function(e){return i[e]||(i[e]=s&&o[e]||(s?o:r)("Symbol."+e))}).store=i},function(e,t,n){var i=n(19),r=Math.min;e.exports=function(e){return 0"+r+""};e.exports=function(e,t){var n={};n[e]=t(a),i(i.P+i.F*r((function(){var t=""[e]('"');return t!==t.toLowerCase()||3y;y++)if((5==e||c||y in g)&&(f=m(d=g[y],y,p),e))if(n)b[y]=f;else if(f)switch(e){case 3:return!0;case 5:return d;case 6:return y;case 2:b.push(d)}else if(u)return!1;return c?-1:3==e||u?u:b}}},function(e){var t={}.toString;e.exports=function(e){return t.call(e).slice(8,-1)}},function(e){e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){"use strict";if(n(8)){var i=n(30),r=n(1),o=n(2),s=n(0),a=n(59),u=n(86),c=n(17),l=n(42),h=n(28),d=n(14),f=n(43),p=n(19),g=n(6),m=n(117),v=n(32),y=n(26),b=n(13),w=n(46),S=n(4),M=n(10),E=n(78),x=n(33),k=n(35),C=n(34).f,_=n(80),O=n(29),T=n(5),A=n(22),I=n(49),P=n(47),N=n(82),R=n(40),F=n(52),L=n(41),B=n(81),D=n(108),j=n(9),U=n(20),V=j.f,z=U.f,G=r.RangeError,H=r.TypeError,W=r.Uint8Array,K="ArrayBuffer",J="Shared"+K,q="BYTES_PER_ELEMENT",Y="prototype",X=Array[Y],$=u.ArrayBuffer,Q=u.DataView,Z=A(0),ee=A(2),te=A(3),ne=A(4),ie=A(5),re=A(6),oe=I(!0),se=I(!1),ae=N.values,ue=N.keys,ce=N.entries,le=X.lastIndexOf,he=X.reduce,de=X.reduceRight,fe=X.join,pe=X.sort,ge=X.slice,me=X.toString,ve=X.toLocaleString,ye=T("iterator"),be=T("toStringTag"),we=O("typed_constructor"),Se=O("def_constructor"),Me=a.CONSTR,Ee=a.TYPED,xe=a.VIEW,ke="Wrong length!",Ce=A(1,(function(e,t){return Ie(P(e,e[Se]),t)})),_e=o((function(){return 1===new W(new Uint16Array([1]).buffer)[0]})),Oe=!!W&&!!W[Y].set&&o((function(){new W(1).set({})})),Te=function(e,t){var n=p(e);if(0>n||n%t)throw G("Wrong offset!");return n},Ae=function(e){if(S(e)&&Ee in e)return e;throw H(e+" is not a typed array!")},Ie=function(e,t){if(!S(e)||!(we in e))throw H("It is not a typed array constructor!");return new e(t)},Pe=function(e,t){return Ne(P(e,e[Se]),t)},Ne=function(e,t){for(var n=0,i=t.length,r=Ie(e,i);i>n;)r[n]=t[n++];return r},Re=function(e,t,n){V(e,t,{get:function(){return this._d[n]}})},Fe=function(e){var t,n,i,r,o,s,a=M(e),u=arguments.length,l=1t;t++)r[t]=h?l(a[t],t):a[t];return r},Le=function(){for(var e=0,t=arguments.length,n=Ie(this,t);t>e;)n[e]=arguments[e++];return n},Be=!!W&&o((function(){ve.call(new W(1))})),De=function(){return ve.apply(Be?ge.call(Ae(this)):Ae(this),arguments)},je={copyWithin:function(e,t){return D.call(Ae(this),e,t,2n)throw G(ke);for(;o(r=Math.round(r))?0:255(s=v-p))throw G(ke)}else if((s=g(r)*t)+p>v)throw G(ke);a=s/t}else a=m(n),o=new $(s=a*t);for(d(e,"_d",{b:o,o:p,l:s,e:a,v:new Q(o)});f(e=i(e))?r(e+t,0):o(e,t)}},function(e,t,n){var i=n(3),r=n(93),o=n(65),s=n(64)("IE_PROTO"),a=function(){},u="prototype",c=function(){var e,t=n(62)("iframe"),i=o.length;for(t.style.display="none",n(66).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write(" - + @@ -83,7 +83,7 @@ Build - 1226 + 1228
    @@ -168,7 +168,7 @@
    - © OpenAudioMc 2016-2021. All Rights Reserved. + © OpenAudioMc 2016-2022. All Rights Reserved.
    @@ -608,6 +608,6 @@

    {% hue.light3 %}

    - + From 575d83b981a3b2943f9427cb2565234d3e2a4a0f Mon Sep 17 00:00:00 2001 From: Mats Date: Fri, 16 Sep 2022 17:58:12 +0200 Subject: [PATCH 13/13] Test server & full implementation --- .../openaudiomc/generic/client/session/SessionData.java | 1 + .../commands/subcommands/voice/VoiceModSubCommand.java | 2 ++ .../modules/voicechat/tasks/PlayerProximityTicker.java | 7 ++++++- spawn-test-spigot.sh | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java index edfb7f802..0467ee8bd 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/client/session/SessionData.java @@ -23,6 +23,7 @@ public class SessionData { private final transient ClientConnection client; + private boolean resetVc = true; private boolean isModerating = false; private boolean isWaitingToken = false; private boolean sessionUpdated = false; diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java index 22cc43a2f..cbbf665b7 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/voice/VoiceModSubCommand.java @@ -32,9 +32,11 @@ public void onExecute(User sender, String[] args) { client.getSession().setModerating(!client.getSession().isModerating()); if (client.getSession().isModerating()) { + client.getSession().setResetVc(true); OpenAudioLogger.toConsole(sender.getName() + " started moderating"); bcToStaff(sender.getName() + " started moderating"); } else { + client.getSession().setResetVc(true); OpenAudioLogger.toConsole(sender.getName() + " stopped moderating"); bcToStaff(sender.getName() + " stopped moderating"); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java index 0df6f948c..0b96cd726 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerProximityTicker.java @@ -67,6 +67,7 @@ public void run() { applicableClients .stream() .filter(peer -> !client.getRtcSessionManager().getSubscriptions().contains(peer.getOwner().getUniqueId())) + .filter(peer -> !client.getSession().isResetVc()) // we might need to drop everything .forEach(peer -> { // connect with these client.getRtcSessionManager().linkTo(peer); @@ -80,7 +81,7 @@ public void run() { for (UUID uuid : client.getRtcSessionManager().getSubscriptions() .stream() .filter(p -> p != client.getOwner().getUniqueId()) - .filter(uuid -> !applicableClients.stream().anyMatch(apc -> apc.getOwner().getUniqueId() == uuid)) + .filter(uuid -> client.getSession().isResetVc() || !applicableClients.stream().anyMatch(apc -> apc.getOwner().getUniqueId() == uuid)) .collect(Collectors.toSet())) { // unsubscribe these @@ -98,6 +99,10 @@ public void run() { client.getRtcSessionManager().updateLocationWatcher(); peer.getRtcSessionManager().updateLocationWatcher(); } + + if (client.getSession().isResetVc()) { + client.getSession().setResetVc(false); + } } AudioApi.getInstance().getEventDriver().fire(new VoiceChatPeerTickEvent(TickEventType.AFTER_TICK)); diff --git a/spawn-test-spigot.sh b/spawn-test-spigot.sh index f179983eb..bdfc48be4 100755 --- a/spawn-test-spigot.sh +++ b/spawn-test-spigot.sh @@ -5,8 +5,8 @@ echo "Building new OpenAudioMc jar without unit tests.." mvn clean install -Dmaven.test.skip=true -rm test-server-spigot/plugins/OpenAudioMc-* -cp plugin/target/OpenAudioMc-* test-server-spigot/plugins/ +rm test-server-spigot/plugins/openaudiomc-* +cp plugin/target/openaudiomc-* test-server-spigot/plugins/ cp dev-resources/bukkit.yml test-server-spigot/ cp dev-resources/ops.json test-server-spigot/