Skip to content

Commit

Permalink
Merge pull request #291 from Mindgamesnl/feature/voicechat-moderation
Browse files Browse the repository at this point in the history
WIP: Voicechat moderation support
  • Loading branch information
Mindgamesnl authored Sep 16, 2022
2 parents 3dfd8b0 + 575d83b commit dbaab49
Show file tree
Hide file tree
Showing 39 changed files with 246 additions and 88 deletions.
2 changes: 1 addition & 1 deletion client/build/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1217"
BUILD_NUM="1228"
1 change: 1 addition & 0 deletions client/src/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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 while 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.
Expand Down
15 changes: 14 additions & 1 deletion client/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
</div>
<div class="header-notice">
<a class="menu-link-main soft-text" href="https://openaudiomc.net/">
&copy; OpenAudioMc 2016-2021. All Rights Reserved.</a>
&copy; OpenAudioMc 2016-2022. All Rights Reserved.</a>
<img class="logo-img" src="assets/logo.png" alt="">
</div>
</div>
Expand Down Expand Up @@ -313,6 +313,19 @@ <h1 class="volume-pill"><label for="volume-slider">{{ oam.volume }}</label></h1>
<div class="tab-content">
<div class="content-wrapper">
<div class="content-section voice-section" style="display: none;" id="voice-settings-container">

<div class="content-section" style="display: none;" hs="{{ oam.hidden_unless_vc_mod }}">
<div class="content-wrapper-box audio-content full bg-red-800">
<div class="content-wrapper-context full">
<div class="content-text full">
<div style="text-align: center;">
<p class="soft-text">{% vc.voiceModerationEnabled %}</p>
</div>
</div>
</div>
</div>
</div>

<div class="content-section-title">{% vc.settings %}</div>
<div class="content-card-collection items-stretch">
<div class="content-card small-card order-2 2xl:order-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {OpenAudioEnv} from "../../../OpenAudioMc";
import {EnableDebugMode} from "../../../debug";
import {OpenModal} from "../../../helpers/modal";
import {AlertBox} from "../../ui/Notification";
import {replaceProperty} from "../../../helpers/domhelper";

export function HandleVoiceUnlock(openAudioMc, data) {

Expand All @@ -23,6 +24,13 @@ export function HandleVoiceUnlock(openAudioMc, data) {

openAudioMc.voiceModule.enable(data.streamServer, data.streamKey, data.radius)

// has mod?
let hasModeration = data.hasModeration;

if (hasModeration) {
replaceProperty("{{ oam.hidden_unless_vc_mod }}", "", "style")
}

new AlertBox('#alert-area', {
closeTime: 60000,
persistent: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h2 title="Enum CommandProxy" class="title">Enum CommandProxy</h2>
<li>java.lang.Enum&lt;<a href="../../../../../../com/craftmend/openaudiomc/generic/node/enums/CommandProxy.html" title="enum in com.craftmend.openaudiomc.generic.node.enums">CommandProxy</a>&gt;</li>
<li>
<ul class="inheritance">
<li>com.craftmend.openaudiomc.generic.node.enums.CommandProxy</li>
<li>com.craftmend.openaudiomc.generic.node.enums.ProxiedCommand</li>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/production-client/target/OpenAudioMc.bundle.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions docs/production-client/target/de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ navbar.free=kostenlos
navbar.premium=premium

home.activate=Sitzung starten
home.activateText=Diese Webseite wird verwendet, um deinen Ton und deine Stimme während deines Besuchs abzuspielen. Bitte klicke auf die Schaltfläche unten, um zu beginnen.
home.activateHeader=Willkommen zu unserem Audio-Client!
home.activateText=Diese persönliche Webseite wird dazu verwendet, deinen Ton und deine Stimme während deines Besuchs abzuspielen. Bitte klicke auf eine beliebige Stelle auf dieser Seite, um zu beginnen.
home.clickAnywhere=Klicke auf eine beliebige Stelle, um zu beginnen.
home.activateHeader=Klicke hier um dich zu verbinden!
home.welcome=Willkommen, %player!
home.header=Willkommen zu unserem Audio-Client! Halte diesen Tab im Hintergrund geöffnet um die passenden Musik und Effekte zu erleben. Du kannst während deiner Sitzung jederzeit zurückkehren um deine Lautstärke und Einstellungen anzupassen.
home.volumeContext=Dieser Regler kontrolliert die Lautstärke deiner Musik und Effekte. Du kannst auch <pre>/volume &lt;Lautstärke&gt;</pre> nutzen, um deine Lautstärke jederzeit vom Spiel aus zu ändern. Du kannst sie auch auf 0 setzen um alle Sounds stummzuschalten.
Expand Down Expand Up @@ -103,6 +104,15 @@ settings.mix-and-fade.button=Aktiviere das Mischen
settings.preload.title=Automatisches Vorladen von Audiodateien
settings.preload.body=Wenn diese Option aktiviert ist, lädt OpenAudioMc automatisch Dateien vor, die in der Umgebung deines Spielstandorts häufig verwendet werden. Dies macht Audio reaktionsschneller, verbraucht aber mehr Daten.
settings.preload.button=Aktiviere Vorladen
settings.rolloff.title=3D-Audio-Wiedergabe
settings.rolloff.body=Dies steuert die Menge der Dämpfung, die auf 3D-Audio angewendet wird, basierend auf der Entfernung. 0% bedeutet keine Dämpfung, 100% bedeutet volle Dämpfung. Dies gilt sowohl für die Lautsprecher als auch für den Voice-Chat.
settings.rolloff.01=1% (minimal)
settings.rolloff.5=50%
settings.rolloff.8=80%
settings.rolloff.1=100% (normal)
settings.rolloff.12=120%
settings.rolloff.15=150% (extrem)


settings.spatial.title=Räumliche Rendering-Engine
settings.spatial.body=Wähle aus, welche Rendering-Engine du verwenden möchtest. Die moderne Engine ist von höherer Qualität und etwas schneller, befindet sich jedoch noch in aktiver Entwicklung.
Expand Down
1 change: 1 addition & 0 deletions docs/production-client/target/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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 while 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.
Expand Down
23 changes: 18 additions & 5 deletions docs/production-client/target/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<meta name="twitter:card" content="summary">

<!-- Includes -->
<link rel="stylesheet" href="css/winter.css?Enable=1217"/>
<link rel="stylesheet" href="css/winter.css?Enable=1228"/>
<script src="libs/sweetalert2.all.js"></script>
<link rel="stylesheet" href="css/reactive-sweetalert.css?Enable=1217"/>
<link rel="stylesheet" href="css/reactive-sweetalert.css?Enable=1228"/>
<link rel="stylesheet" href="css/tailwind.min.css"/>
<script defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "44aa80ee6e6d48c8b54452fee61f2541"}'></script>
Expand Down Expand Up @@ -83,7 +83,7 @@
<p style="display: none;" hs="{{ oam.loading_tagline_style }}"
class="text-sm text-gray-300 leading-none mt-1">
{{ oam.loading_tagline_text }}</p> <small class="text-gray-500" style="display: inline;">Build
1217</small>
1228</small>
</div>
</div>
</div>
Expand Down Expand Up @@ -168,7 +168,7 @@
</div>
<div class="header-notice">
<a class="menu-link-main soft-text" href="https://openaudiomc.net/">
&copy; OpenAudioMc 2016-2021. All Rights Reserved.</a>
&copy; OpenAudioMc 2016-2022. All Rights Reserved.</a>
<img class="logo-img" src="assets/logo.png" alt="">
</div>
</div>
Expand Down Expand Up @@ -313,6 +313,19 @@ <h1 class="volume-pill"><label for="volume-slider">{{ oam.volume }}</label></h1>
<div class="tab-content">
<div class="content-wrapper">
<div class="content-section voice-section" style="display: none;" id="voice-settings-container">

<div class="content-section" style="display: none;" hs="{{ oam.hidden_unless_vc_mod }}">
<div class="content-wrapper-box audio-content full bg-red-800">
<div class="content-wrapper-context full">
<div class="content-text full">
<div style="text-align: center;">
<p class="soft-text">{% vc.voiceModerationEnabled %}</p>
</div>
</div>
</div>
</div>
</div>

<div class="content-section-title">{% vc.settings %}</div>
<div class="content-card-collection items-stretch">
<div class="content-card small-card order-2 2xl:order-1">
Expand Down Expand Up @@ -595,6 +608,6 @@ <h3>{% hue.light3 %}</h3>
</div>
</div>

<script src="OpenAudioMc.bundle.js?version=1217"></script>
<script src="OpenAudioMc.bundle.js?version=1228"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,8 @@ public class BungeeVoiceCommand extends SubCommand {
public BungeeVoiceCommand() {
super("voice");
registerArguments(
new Argument("mod <username>", "Open the moderation menu to view the status of a player or ban them")
new Argument("mod", "Toggle moderation mode for voicechat"),
new Argument("inspect <username>", "Open the moderation menu to view the status of a player or ban them")
);
}

Expand All @@ -32,7 +33,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.VOICE);

OpenAudioMc.resolveDependency(UserHooks.class).sendPacket(sender, new CommandProxyPacket(payload));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class SessionData {

private final transient ClientConnection client;

private boolean resetVc = true;
private boolean isModerating = false;
private boolean isWaitingToken = false;
private boolean sessionUpdated = false;
private boolean hasHueLinked = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class ClientVoiceChatUnlockPayload extends AbstractPacketPayload {
private String streamKey;
private String streamServer;
private int radius;
private boolean hasModeration;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.craftmend.openaudiomc.generic.node.enums;

public enum CommandProxy {
public enum ProxiedCommand {

REGION,
SPEAKER,
Expand Down
Loading

0 comments on commit dbaab49

Please sign in to comment.