Skip to content

Commit

Permalink
Add the requested API and config features (#469)
Browse files Browse the repository at this point in the history
* Add the requested API and config features

* some more fixes
  • Loading branch information
Mindgamesnl authored Feb 1, 2025
1 parent 50da9f7 commit d13759a
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java adoptopenjdk-8.0.332+9
java openjdk-21
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 dev-resources/spawn-test-spigot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ echo "Starting server.."
rm world/session.lock
rm world_the_end/session.lock
rm world_nether/session.lock
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.21.4.jar nogui
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar paper-1.20.4-499.jar nogui
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="1531"
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 @@ -12,6 +12,7 @@
import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.inventory.ItemStack;
Expand All @@ -28,6 +29,10 @@ public class SpeakerUtils {
public static final String speakerSkin = SETTINGS_SPEAKER_SKIN_NAME.getString();
public static final UUID speakerUUID = UUID.fromString(SETTINGS_SPEAKER_SKIN_UUID.getString());
public static final String textureValue;
private static OfflinePlayer FAKE_SKULL_OWNER = new ClassMocker<OfflinePlayer>(OfflinePlayer.class)
.addReturnValue("getUniqueId", speakerUUID)
.addReturnValue("getName", speakerSkin)
.createProxy();

static {
String rawUrl = SETTINGS_SPEAKER_SKIN_TEXTURE.getString();
Expand Down Expand Up @@ -56,7 +61,6 @@ public static boolean isSpeakerSkull(Block block) {
}
return valid;
}

return skull.getOwningPlayer().getUniqueId().equals(speakerUUID);
} else {
if (skull.getOwner() == null) return false;
Expand All @@ -70,13 +74,25 @@ public static ItemStack getSkull(String source, int radius) {
ItemStack skull = new ItemStack(SPEAKER_SERVICE.getPlayerSkullItem());
skull.setDurability((short) 3);

SkullMeta sm = (SkullMeta) skull.getItemMeta();
if (sm != null) {
sm.setDisplayName(ChatColor.AQUA + "OpenAudioMc Speaker");
sm.setOwningPlayer(FAKE_SKULL_OWNER);
sm.setLore(Arrays.asList(
ChatColor.AQUA + "I'm a super cool speaker!",
ChatColor.AQUA + "Simply place me in your world",
ChatColor.AQUA + "and I'll play your customized music",
"",
ChatColor.AQUA + "SRC: " + ChatColor.GREEN + source,
ChatColor.AQUA + "Radius: " + ChatColor.GREEN + radius
));
skull.setItemMeta(sm);
}

// For Minecraft 1.20.4 and below
NBT.modify(skull, nbt -> {
ReadWriteNBT skullOwnerCompound = nbt.getOrCreateCompound("SkullOwner");

// The owner UUID. Note that skulls with the same UUID but different textures will misbehave and only one texture will load.
// They will share the texture. To avoid this limitation, it is recommended to use a random UUID.
skullOwnerCompound.setUUID("Id", UUID.randomUUID());
skullOwnerCompound.setUUID("Id", speakerUUID);

skullOwnerCompound.getOrCreateCompound("Properties")
.getCompoundList("textures")
Expand All @@ -100,20 +116,6 @@ public static ItemStack getSkull(String source, int radius) {
}
}

SkullMeta sm = (SkullMeta) skull.getItemMeta();
if (sm != null) {
sm.setDisplayName(ChatColor.AQUA + "OpenAudioMc Speaker");
sm.setLore(Arrays.asList(
ChatColor.AQUA + "I'm a super cool speaker!",
ChatColor.AQUA + "Simply place me in your world",
ChatColor.AQUA + "and I'll play your customized music",
"",
ChatColor.AQUA + "SRC: " + ChatColor.GREEN + source,
ChatColor.AQUA + "Radius: " + ChatColor.GREEN + radius
));
skull.setItemMeta(sm);
}

NBTItem nbti = new NBTItem(skull);
nbti.setString("oa-src", source);
nbti.setInteger("oa-radius", radius);
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 @@ -91,7 +91,6 @@ public void setPauseRuns(int pauseRuns) {

public void stop() {
running = false;
this.thread.stop();
}

}
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="1531"
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="1531"
BUILD_COMMIT="f096ea69ea9b8334f56c8eae16b41d0efba888a4"
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 d13759a

Please sign in to comment.