Skip to content

Commit

Permalink
Add the requested API and config features
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed Jan 28, 2025
1 parent 50da9f7 commit f096ea6
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 18 deletions.
24 changes: 24 additions & 0 deletions api/src/main/java/com/craftmend/openaudiomc/api/VoiceApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,29 @@ static VoiceApi getInstance() {
*/
boolean isChannelNameValid(String s);

/**
* Check if a client has voicechat moderation enabled
* @param client the client to check
* @return true if the client has moderation enabled
* @since 6.10.9
*/
boolean isClientModerating(Client client);

/**
* Start a moderation session for a client, bypassing permission checks.
* Moderation will still have to be enabled in the config, otherwise this method will return false and do nothing.
* Moderation mode isn't permanent, it will only last for the duration you have configured in the config, but you can call this method again to extend the duration.
* @param client the client to enable or disable moderation for
* @return true if the client is now moderating
* @since 6.10.9
*/
boolean startClientModeration(Client client);

/**
* Stop a moderation session for a client
* @param client the client to stop moderation for
* @since 6.10.9
*/
void stopClientModeration(Client client);

}
2 changes: 1 addition & 1 deletion modules/mapdb-migrator/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>com.craftmend.openaudiomc</groupId>
<artifactId>openaudiomc</artifactId>
<version>6.10.8</version>
<version>6.10.9</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion modules/parties-module/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>com.craftmend.openaudiomc</groupId>
<artifactId>openaudiomc</artifactId>
<version>6.10.8</version>
<version>6.10.9</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion modules/skywars-module/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<dependency>
<groupId>com.craftmend.openaudiomc</groupId>
<artifactId>openaudiomc</artifactId>
<version>6.10.8</version>
<version>6.10.9</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion modules/vistas-client/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<dependency>
<groupId>com.craftmend.openaudiomc</groupId>
<artifactId>openaudiomc</artifactId>
<version>6.10.8</version>
<version>6.10.9</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion modules/voice-join-permission/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<dependency>
<groupId>com.craftmend.openaudiomc</groupId>
<artifactId>openaudiomc</artifactId>
<version>6.10.8</version>
<version>6.10.9</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion plugin/protocol/static-resources/project_status.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"response": {
"versioning": {
"version_tag": "6.10.7",
"version_tag": "6.10.9",
"build_number": 700,
"version_importance": "&e&aHighly Recommended",
"version_update_message": "Migrated to a new platform, free CDN, settings, routing, and much more! Please read the changelog for more information and a guide on how to migrate."
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/bash/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1521"
BUILD_NUM="1523"
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.craftmend.openaudiomc.generic.networking.packets.client.voice.PacketClientVoiceOptionsUpdate;
import com.craftmend.openaudiomc.generic.networking.payloads.client.voice.ClientVoiceOptionsPayload;
import com.craftmend.openaudiomc.generic.platform.Platform;
import com.craftmend.openaudiomc.generic.storage.enums.StorageKey;
import com.craftmend.openaudiomc.spigot.modules.voicechat.VoiceChannelService;
import com.craftmend.openaudiomc.spigot.modules.voicechat.filters.FilterService;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -183,4 +184,27 @@ public void deleteChannel(VoiceChannel channel) {
public boolean isChannelNameValid(String s) {
return OpenAudioMc.getService(VoiceChannelService.class).isChannelNameValid(s);
}

@Override
public boolean isClientModerating(Client client) {
ClientConnection clientConnection = (ClientConnection) client;
return clientConnection.getSession().isModerating();
}

@Override
public boolean startClientModeration(Client client) {
ClientConnection clientConnection = (ClientConnection) client;
if (!StorageKey.SETTINGS_VC_MOD_ENABLED.getBoolean()) {
return false;
}

clientConnection.setModerating(true);
return true;
}

@Override
public void stopClientModeration(Client client) {
ClientConnection clientConnection = (ClientConnection) client;
clientConnection.setModerating(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ public void kick(Runnable callback) {
*/
public void setModerating(boolean state) {
if (state) {
session.setModerating(true);
session.setModerationTimeRemaining(OpenAudioMc.getInstance().getConfiguration().getInt(StorageKey.SETTINGS_MODERATION_TIMER));
session.setResetVc(true);
sendPacket(new PacketClientModerationStatus(true));
if (!session.isModerating()) {
session.setResetVc(true);
sendPacket(new PacketClientModerationStatus(true));
}
session.setModerating(true);
} else {
session.setModerating(false);
session.setModerationTimeRemaining(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void handleMigrations() {
new AddConfigKeyMigration(SETTINGS_SPEAKER_MAX_RANGE, "Add max range config value"),
new AddConfigKeyMigration(SETTINGS_STATIC_CHANNELS_SHOW_IN_WEB_UI, "Add a setting to show the channels web UI"),
new AddConfigKeyMigration(SETTINGS_SPEAKER_SKIN_UUID, "Add a setting for the speaker skin textures"),
new AddConfigKeyMigration(SETTINGS_TRAINCARTS_MUTE_REGIONS, "Add a setting to mute regions and speakers in traincarts"),
};

for (SimpleMigration migration : migrations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public enum StorageKey {
SETTINGS_IGNORE_REGIONS_WHILE_IN_VEHICLE(false, "options.ignore-regions-on-vehicles", StorageLocation.CONFIG_FILE),
SETTINGS_HYDRATE_REGIONS_ON_BOOT(false, "options.hydrate-regions-on-boot", StorageLocation.CONFIG_FILE),

SETTINGS_TRAINCARTS_MUTE_REGIONS(false, "options.traincarts-mute-regions", StorageLocation.CONFIG_FILE),
SETTINGS_TRAINCARTS_MUTE_SPEAKERS(false, "options.traincarts-mute-speakers", StorageLocation.CONFIG_FILE),

SETTINGS_STATIC_CHANNELS_ENABLED(false, "static-channels.enabled", StorageLocation.CONFIG_FILE),
SETTINGS_STATIC_CHANNELS_SHOW_IN_WEB_UI(false, "static-channels.show-in-webclient", StorageLocation.CONFIG_FILE),
SETTINGS_STATIC_CHANNELS_BASE(false, "static-channels.list", StorageLocation.CONFIG_FILE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void run() {
possiblyFilterLimits(setSize, this.speakerService
.getSpeakerMap()
.values().stream()
.filter(Speaker::getRequiresHealthCheck)
.filter(speaker -> speaker != null && speaker.getRequiresHealthCheck())
.filter(speaker -> !speaker.getValidated())
.skip(fractionStart)
).collect(Collectors.toList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.craftmend.openaudiomc.OpenAudioMc;
import com.craftmend.openaudiomc.api.media.Media;
import com.craftmend.openaudiomc.generic.media.time.TimeService;
import com.craftmend.openaudiomc.generic.storage.enums.StorageKey;
import lombok.Data;

import java.time.Instant;
Expand All @@ -20,6 +21,9 @@ public TrainMedia(String source) {
this.media.setDoPickup(true);
this.media.setMediaId("train_audio");
this.media.setLoop(false);

this.media.setMuteRegions(StorageKey.SETTINGS_TRAINCARTS_MUTE_REGIONS.getBoolean());
this.media.setMuteSpeakers(StorageKey.SETTINGS_TRAINCARTS_MUTE_SPEAKERS.getBoolean());
}

public Media toMedia() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Plugin(
id = "openaudiomc",
name = "OpenAudioMc Bungee Plugin Port for Velocity",
version = "6.10.8",
version = "6.10.9",
authors = {"Mindgamesnl", "fluse1367"},
description = "OpenAudioMc: Proximity voice chat & audio plugin for Minecraft, no mods needed. Supports Bungeecord, Velocity, Spigot & more.",
url = "https://openaudiomc.net/"
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: OpenAudioMc
version: 6.10.7
version: 6.10.9
main: com.craftmend.openaudiomc.bungee.OpenAudioMcBungee
author: Mindgamesnl
authors: [Mindgamesnl]
Expand Down
6 changes: 6 additions & 0 deletions plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ options:
# This is useful for when you have a bad connection, but it can be disabled if its causing issues.
auto-reconnect: true

# This setting determines if the media played in a train should overwrite any media from regions
traincarts-mute-regions: false

# This setting determines if the media played in a train should overwrite any media from speakers
traincarts-mute-speakers: false

# Voicechat filters define requirements that players both have to meet before they will be able to hear eachother.
# You can implement custom filters through the API, or enable some of the default ones below.
vc-filter:
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1521"
BUILD_NUM="1523"
4 changes: 2 additions & 2 deletions plugin/src/main/resources/openaudiomc-build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD_VERSION="1521"
BUILD_COMMIT="91938ed8d427753d44da69a41757873cbd5451cf"
BUILD_VERSION="1523"
BUILD_COMMIT="50da9f7890c067f107178548078bfdf0d3a3aaf3"
BUILD_AUTHOR="Mats"
2 changes: 1 addition & 1 deletion plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: OpenAudioMc
version: 6.10.7
version: 6.10.9
softdepend: [WorldGuard, Train_Carts, LiteBans, Essentials, PlaceholderAPI]
main: com.craftmend.openaudiomc.spigot.OpenAudioMcSpigot
api-version: 1.13
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<description>The OpenAudioMc Java plugin and Api</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oa.version>6.10.8</oa.version>
<oa.version>6.10.9</oa.version>

<!-- dev deps -->
<deps.lombok.version>1.18.36</deps.lombok.version>
Expand Down

0 comments on commit f096ea6

Please sign in to comment.