diff --git a/api/src/main/java/com/craftmend/openaudiomc/api/MediaApi.java b/api/src/main/java/com/craftmend/openaudiomc/api/MediaApi.java index 65865b062..7d20578e7 100644 --- a/api/src/main/java/com/craftmend/openaudiomc/api/MediaApi.java +++ b/api/src/main/java/com/craftmend/openaudiomc/api/MediaApi.java @@ -123,4 +123,21 @@ static MediaApi getInstance() { */ void stopFor(@NotNull String id, @NotNull Client... clients); + /** + * Stop a specific media by ID for a client + * + * @param id Media ID + * @param fadeTime Fade time in milliseconds + * @param clients Target clients + */ + void stopFor(@NotNull String id, int fadeTime, @NotNull Client... clients); + + /** + * Stop all media (except regions and speakers) for a client + * + * @param fadeTime Fade time in milliseconds + * @param clients Target clients + */ + void stopFor(int fadeTime, @NotNull Client... clients); + } diff --git a/api/src/main/java/com/craftmend/openaudiomc/api/VoiceApi.java b/api/src/main/java/com/craftmend/openaudiomc/api/VoiceApi.java index 31f43dc46..c41787d5c 100644 --- a/api/src/main/java/com/craftmend/openaudiomc/api/VoiceApi.java +++ b/api/src/main/java/com/craftmend/openaudiomc/api/VoiceApi.java @@ -1,9 +1,12 @@ package com.craftmend.openaudiomc.api; +import com.craftmend.openaudiomc.api.channels.VoiceChannel; import com.craftmend.openaudiomc.api.clients.Client; import com.craftmend.openaudiomc.api.voice.CustomPlayerFilter; import com.craftmend.openaudiomc.api.voice.VoicePeerOptions; +import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -105,4 +108,47 @@ static VoiceApi getInstance() { */ List getCustomPlayerFilters(); + /** + * Get a list of all registered channels + * @return a list of all registered channels + * @since 6.10.1 + */ + Collection getChannels(); + + /** + * Get a channel by its name + * @param name the name of the channel + * @return the channel, or null if the channel does not exist + * @since 6.10.1 + */ + @Nullable + VoiceChannel getChannel(String name); + + /** + * Create a new channel + * @param name the name of the channel + * @param creator the creator of the channel + * @param requiresPermission if the channel requires permission to join + * @param requiredPermission the permission required to join the channel + * @return the created channel + * @since 6.10.1 + */ + VoiceChannel createChannel(String name, Client creator, boolean requiresPermission, @Nullable String requiredPermission); + + /** + * Delete a channel + * @param channel the channel to delete + * @since 6.10.1 + */ + void deleteChannel(VoiceChannel channel); + + /** + * Check if a channel name is valid + * @param s the name to check + * @return true if the name is valid + * @since 6.10.1 + */ + boolean isChannelNameValid(String s); + + } diff --git a/api/src/main/java/com/craftmend/openaudiomc/api/channels/ChannelJoinResponse.java b/api/src/main/java/com/craftmend/openaudiomc/api/channels/ChannelJoinResponse.java new file mode 100644 index 000000000..7f4d1c440 --- /dev/null +++ b/api/src/main/java/com/craftmend/openaudiomc/api/channels/ChannelJoinResponse.java @@ -0,0 +1,19 @@ +package com.craftmend.openaudiomc.api.channels; + +public enum ChannelJoinResponse { + + /** + * The client is allowed to join the channel + */ + ALLOWED, + + /** + * The client is only allowed to join this channel if they are invited + */ + INVITE_ONLY, + + /** + * The client is not allowed to join this channel + */ + NO_PERMISSION, +} diff --git a/api/src/main/java/com/craftmend/openaudiomc/api/channels/VoiceChannel.java b/api/src/main/java/com/craftmend/openaudiomc/api/channels/VoiceChannel.java new file mode 100644 index 000000000..6e58105de --- /dev/null +++ b/api/src/main/java/com/craftmend/openaudiomc/api/channels/VoiceChannel.java @@ -0,0 +1,76 @@ +package com.craftmend.openaudiomc.api.channels; + +import com.craftmend.openaudiomc.api.basic.Actor; +import com.craftmend.openaudiomc.api.clients.Client; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.UUID; + +public interface VoiceChannel { + + /** + * Get the name of the channel + * @return the name of the channel + */ + String getName(); + + /** + * Get the members of the channel + * @return the members of the channel + */ + Collection getMembers(); + + /** + * Get the creator of the channel + * @return the creator of the channel, or null if the channel is not a user channel + */ + @Nullable + Actor getCreator(); + + /** + * If this channel requires permission to join + * @return true if the channel requires permission to join + */ + boolean requiresPermission(); + + /** + * Get the required permission to join this channel + * @return the required permission to join this channel, or null if the channel does not require permission + */ + @Nullable + String getRequiredPermission(); + + /** + * Check if a client is a member of this channel + * @param actor the actor to check + * @return true if the actor is a member of this channel + */ + boolean isMember(Actor actor); + + /** + * Check if a client is a member of this channel + * @param uuid the uuid of the actor to check + * @return true if the actor is a member of this channel + */ + boolean isMember(UUID uuid); + + /** + * Check if a client would be allowed to join this channel + * @param client the client to check + * @return the response of the join check + */ + ChannelJoinResponse joinPreconditionCheck(Client client); + + /** + * Add a member to the channel + * @param client the client to add + */ + void addMember(Client client); + + /** + * Remove a member from the channel + * @param client the client to remove + */ + void removeMember(Client client); +} diff --git a/api/src/main/java/com/craftmend/openaudiomc/api/media/Media.java b/api/src/main/java/com/craftmend/openaudiomc/api/media/Media.java index 7cfca3545..a2006828b 100644 --- a/api/src/main/java/com/craftmend/openaudiomc/api/media/Media.java +++ b/api/src/main/java/com/craftmend/openaudiomc/api/media/Media.java @@ -16,7 +16,8 @@ public class Media { /** * Source value for the media. Typically, a web compatible web link or translatable OA value */ - private final String source; + @Setter + private String source; /** * The unique id of the media, used by the client to keep track of media pools. diff --git a/client/public/metadata.json b/client/public/metadata.json index 0dab3aecb..8e58d76ea 100644 --- a/client/public/metadata.json +++ b/client/public/metadata.json @@ -1 +1 @@ -{"buildMajor":1,"buildMinor":125,"buildRevision":239,"buildTag":"dev","buildDate":"Sun Mar 31 2024","build":"1.125.239 dev"} \ No newline at end of file +{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"} \ No newline at end of file diff --git a/client/src/client/login/ClientTokenSet.jsx b/client/src/client/login/ClientTokenSet.jsx index ccd1e87e6..c4e38ad35 100644 --- a/client/src/client/login/ClientTokenSet.jsx +++ b/client/src/client/login/ClientTokenSet.jsx @@ -87,6 +87,17 @@ export default class ClientTokenSet { return; } + if (body.status === 409) { + setGlobalState({ + isLoading: false, + isBlocked: true, + isValidationError: true, + }); + ReportError('Invalid token', window.tokenCache.name); + resolve(null); + return; + } + body.json().then((sessionValidationResponse) => { if (sessionValidationResponse.errors.length > 0) { if (this.attempts < 3) { diff --git a/client/src/metadata.json b/client/src/metadata.json index 0dab3aecb..8e58d76ea 100644 --- a/client/src/metadata.json +++ b/client/src/metadata.json @@ -1 +1 @@ -{"buildMajor":1,"buildMinor":125,"buildRevision":239,"buildTag":"dev","buildDate":"Sun Mar 31 2024","build":"1.125.239 dev"} \ No newline at end of file +{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"} \ No newline at end of file diff --git a/client/src/state/store.jsx b/client/src/state/store.jsx index 9e7d94f61..5f2877399 100644 --- a/client/src/state/store.jsx +++ b/client/src/state/store.jsx @@ -122,6 +122,7 @@ const initialState = { isLoading: true, isBlocked: false, // whenever an account is temporarily blocked (rate-limiting, abuse) isPersonalBlock: false, // whenever this user is personally rate-limited or blocked (due to for example, dmca abuse) + isValidationError: false, // whenever the client is not whitelisted to be used on this server loadingState: 'Preparing to load OpenAudioMc', fixedFooter: null, navbarDetails: true, diff --git a/client/src/views/login/BlockedLoginView.jsx b/client/src/views/login/BlockedLoginView.jsx index 47bc4dc2f..b71d87dd5 100644 --- a/client/src/views/login/BlockedLoginView.jsx +++ b/client/src/views/login/BlockedLoginView.jsx @@ -10,7 +10,7 @@ function BlockedLoginView(props) {
- {props.isPersonalBlock ? ( + {!props.isValidationError && props.isPersonalBlock ? (

You are currently blocked from using OpenAudioMc. Please contact support at {' '} @@ -20,7 +20,7 @@ function BlockedLoginView(props) {

) : null} - {!props.isPersonalBlock && ( + {!props.isValidationError && !props.isPersonalBlock && (

This server/account is (temporarily) blocked from using OpenAudioMc. If you're the owner of this server, please contact support at @@ -30,6 +30,13 @@ function BlockedLoginView(props) { to appeal.

)} + + {props.isValidationError ? ( +

+ This client is not whitelisted to be used on this server. Please set this client as your base url in + your account and try again. +

+ ) : null}
@@ -40,11 +47,14 @@ function BlockedLoginView(props) { BlockedLoginView.propTypes = { isPersonalBlock: PropTypes.bool.isRequired, + isValidationError: PropTypes.bool.isRequired, }; export default connect(mapStateToProps)(BlockedLoginView); + function mapStateToProps(state) { return { isPersonalBlock: state.isPersonalBlock, + isValidationError: state.isValidationError, }; } diff --git a/dev-resources/spawn-test-spigot.sh b/dev-resources/spawn-test-spigot.sh index 33279310a..1cafb0a56 100755 --- a/dev-resources/spawn-test-spigot.sh +++ b/dev-resources/spawn-test-spigot.sh @@ -1,4 +1,4 @@ -export JAVA_HOME=`/usr/libexec/java_home -v 17` +export JAVA_HOME=`/usr/libexec/java_home -v 18` mkdir -p test-server-spigot/plugins/ mkdir -p test-server-spigot/plugins/OpenAudioMc/ echo "Building new OpenAudioMc jar without unit tests.." @@ -29,4 +29,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.20.2.jar nogui \ No newline at end of file +java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar paper-1.20.6-49.jar nogui diff --git a/dev-resources/spawn-test-velocity-docker.sh b/dev-resources/spawn-test-velocity-docker.sh new file mode 100755 index 000000000..8910e002e --- /dev/null +++ b/dev-resources/spawn-test-velocity-docker.sh @@ -0,0 +1,17 @@ +export JAVA_HOME=`/usr/libexec/java_home -v 17` +mkdir -p test-server-spigot/plugins/ +mkdir -p test-server-spigot/plugins/OpenAudioMc/ +echo "Building new OpenAudioMc jar without unit tests.." + +cd plugin +./src/main/bash/post-build.sh +cd .. + +mvn -T 4.5C clean install -Dmaven.test.skip=true + +# permission workaround +rm -rf dev-resources/velocity-test/plugins/openaudiomc-*.jar +mkdir -p dev-resources/velocity-test/plugins/ +cp plugin/target/openaudiomc-*.jar dev-resources/velocity-test/plugins/ +cd dev-resources/velocity-test/ +docker-compose up --build diff --git a/dev-resources/velocity-test/.gitignore b/dev-resources/velocity-test/.gitignore new file mode 100644 index 000000000..9b321c163 --- /dev/null +++ b/dev-resources/velocity-test/.gitignore @@ -0,0 +1 @@ +plugins/* \ No newline at end of file diff --git a/dev-resources/velocity-test/docker-compose.yml b/dev-resources/velocity-test/docker-compose.yml new file mode 100644 index 000000000..68132c28a --- /dev/null +++ b/dev-resources/velocity-test/docker-compose.yml @@ -0,0 +1,44 @@ +version: '3' + +services: + velocity-paper1: + restart: on-failure + image: itzg/minecraft-server + environment: + - EULA=TRUE + - ONLINE_MODE=FALSE + - TYPE=PAPER + - SPIGOT_BUNGEE=true + - BUNGEECORD_IP=0.0.0.0 + - VERSION=1.20.2 + #- BUILD_FROM_SOURCE=true + volumes: + - ./velocity-spigot1:/data + - ./plugins:/plugins + + velocity-paper2: + restart: on-failure + image: itzg/minecraft-server + environment: + - EULA=TRUE + - ONLINE_MODE=FALSE + - TYPE=PAPER + - SPIGOT_BUNGEE=true + - BUNGEECORD_IP=0.0.0.0 + - VERSION=1.20.2 + # - BUILD_FROM_SOURCE=true + volumes: + - ./velocity-spigot2:/data + - ./plugins:/plugins + + velocity: + restart: on-failure + image: itzg/bungeecord + ports: + - 25565:25565 + environment: + - TYPE=VELOCITY + - EULA=TRUE + volumes: + - ./plugins:/plugins + - ./velocity:/config \ No newline at end of file diff --git a/dev-resources/velocity-test/plugins/autoperms-1.0-SNAPSHOT.jar b/dev-resources/velocity-test/plugins/autoperms-1.0-SNAPSHOT.jar new file mode 100644 index 000000000..7cb4ad366 Binary files /dev/null and b/dev-resources/velocity-test/plugins/autoperms-1.0-SNAPSHOT.jar differ diff --git a/dev-resources/velocity-test/velocity-spigot1/forwarding.secret b/dev-resources/velocity-test/velocity-spigot1/forwarding.secret new file mode 100644 index 000000000..bcc8d2eb7 --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot1/forwarding.secret @@ -0,0 +1 @@ +big L \ No newline at end of file diff --git a/dev-resources/velocity-test/velocity-spigot1/ops.json b/dev-resources/velocity-test/velocity-spigot1/ops.json new file mode 100644 index 000000000..8d92d023f --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot1/ops.json @@ -0,0 +1,14 @@ +[ + { + "uuid": "88243ba3-382f-4eb0-874f-c5831eb3c0a6", + "name": "ToetMats", + "level": 4, + "bypassesPlayerLimit": false + }, + { + "uuid": "f0c8657b-f384-4df6-9d66-e9f36c36ce8a", + "name": "Mindgamesnl", + "level": 4, + "bypassesPlayerLimit": false + } +] \ No newline at end of file diff --git a/dev-resources/velocity-test/velocity-spigot1/server.properties b/dev-resources/velocity-test/velocity-spigot1/server.properties new file mode 100644 index 000000000..2c5183a96 --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot1/server.properties @@ -0,0 +1,61 @@ +#Minecraft server properties +#Sat May 04 20:01:11 UTC 2024 +enable-jmx-monitoring=false +rcon.port=25575 +level-seed= +gamemode=survival +enable-command-block=false +enable-query=false +generator-settings={} +enforce-secure-profile=false +level-name=world +motd=A Minecraft Server +query.port=25565 +velocity-enabled=true +pvp=true +generate-structures=true +max-chained-neighbor-updates=1000000 +difficulty=easy +network-compression-threshold=256 +max-tick-time=60000 +require-resource-pack=false +use-native-transport=true +max-players=20 +online-mode=false +enable-status=true +allow-flight=false +initial-disabled-packs= +broadcast-rcon-to-ops=true +view-distance=10 +server-ip= +resource-pack-prompt= +allow-nether=true +server-port=25565 +enable-rcon=true +sync-chunk-writes=true +op-permission-level=4 +prevent-proxy-connections=false +hide-online-players=false +resource-pack= +entity-broadcast-range-percentage=100 +simulation-distance=10 +rcon.password=94230c4fc4e48fa28a4242ef +player-idle-timeout=0 +debug=false +force-gamemode=false +rate-limit=0 +hardcore=false +white-list=false +broadcast-console-to-ops=true +spawn-npcs=true +spawn-animals=true +log-ips=true +function-permission-level=2 +initial-enabled-packs=vanilla +level-type=minecraft\:normal +text-filtering-config= +spawn-monsters=true +enforce-whitelist=false +spawn-protection=16 +resource-pack-sha1= +max-world-size=29999984 diff --git a/dev-resources/velocity-test/velocity-spigot1/spigot.yml b/dev-resources/velocity-test/velocity-spigot1/spigot.yml new file mode 100644 index 000000000..44449af8a --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot1/spigot.yml @@ -0,0 +1,177 @@ +# This is the main configuration file for Spigot. +# As you can see, there's tons to configure. Some options may impact gameplay, so use +# with caution, and make sure you know what each option does before configuring. +# For a reference for any variable inside this file, check out the Spigot wiki at +# http://www.spigotmc.org/wiki/spigot-configuration/ +# +# If you need help with the configuration or have any questions related to Spigot, +# join us at the Discord or drop by our forums and leave a post. +# +# Discord: https://www.spigotmc.org/go/discord +# Forums: http://www.spigotmc.org/ + +messages: + whitelist: You are not whitelisted on this server! + unknown-command: Unknown command. Type "/help" for help. + server-full: The server is full! + outdated-client: Outdated client! Please use {0} + outdated-server: Outdated server! I'm still on {0} + restart: Server is restarting +commands: + replace-commands: + - setblock + - summon + - testforblock + - tellraw + spam-exclusions: + - /skill + silent-commandblock-console: false + log: true + tab-complete: 0 + send-namespaced: true +advancements: + disable-saving: false + disabled: + - minecraft:story/disabled +players: + disable-saving: false +world-settings: + default: + seed-ancientcity: 20083232 + seed-trailruins: 83469867 + seed-buriedtreasure: 10387320 + seed-mineshaft: default + seed-stronghold: default + below-zero-generation-in-existing-chunks: true + verbose: true + entity-activation-range: + water: 16 + villagers: 32 + flying-monsters: 32 + wake-up-inactive: + animals-max-per-tick: 4 + animals-every: 1200 + animals-for: 100 + monsters-max-per-tick: 8 + monsters-every: 400 + monsters-for: 100 + villagers-max-per-tick: 4 + villagers-every: 600 + villagers-for: 100 + flying-monsters-max-per-tick: 8 + flying-monsters-every: 200 + flying-monsters-for: 100 + villagers-work-immunity-after: 100 + villagers-work-immunity-for: 20 + villagers-active-for-panic: true + animals: 32 + monsters: 32 + raiders: 48 + misc: 16 + tick-inactive-villagers: true + ignore-spectators: false + entity-tracking-range: + players: 48 + animals: 48 + monsters: 48 + misc: 32 + display: 128 + other: 64 + ticks-per: + hopper-transfer: 8 + hopper-check: 1 + hopper-amount: 1 + hopper-can-load-chunks: false + merge-radius: + exp: 3.0 + item: 2.5 + mob-spawn-range: 6 + growth: + torchflower-modifier: 100 + glowberry-modifier: 100 + pitcherplant-modifier: 100 + cactus-modifier: 100 + cane-modifier: 100 + melon-modifier: 100 + mushroom-modifier: 100 + pumpkin-modifier: 100 + sapling-modifier: 100 + beetroot-modifier: 100 + carrot-modifier: 100 + potato-modifier: 100 + wheat-modifier: 100 + netherwart-modifier: 100 + vine-modifier: 100 + cocoa-modifier: 100 + bamboo-modifier: 100 + sweetberry-modifier: 100 + kelp-modifier: 100 + twistingvines-modifier: 100 + weepingvines-modifier: 100 + cavevines-modifier: 100 + dragon-death-sound-radius: 0 + seed-village: 10387312 + seed-desert: 14357617 + seed-igloo: 14357618 + seed-jungle: 14357619 + seed-swamp: 14357620 + seed-monument: 10387313 + seed-shipwreck: 165745295 + seed-ocean: 14357621 + seed-outpost: 165745296 + seed-endcity: 10387313 + seed-slime: 987234911 + seed-nether: 30084232 + seed-mansion: 10387319 + seed-fossil: 14357921 + seed-portal: 34222645 + hunger: + jump-walk-exhaustion: 0.05 + jump-sprint-exhaustion: 0.2 + combat-exhaustion: 0.1 + regen-exhaustion: 6.0 + swim-multiplier: 0.01 + sprint-multiplier: 0.1 + other-multiplier: 0.0 + max-tnt-per-tick: 100 + max-tick-time: + tile: 50 + entity: 50 + item-despawn-rate: 6000 + view-distance: default + simulation-distance: default + thunder-chance: 100000 + enable-zombie-pigmen-portal-spawns: true + arrow-despawn-rate: 1200 + trident-despawn-rate: 1200 + wither-spawn-sound-radius: 0 + end-portal-sound-radius: 0 + hanging-tick-frequency: 100 + zombie-aggressive-towards-villager: true + nerf-spawner-mobs: false +settings: + debug: false + sample-count: 12 + player-shuffle: 0 + user-cache-size: 1000 + save-user-cache-on-stop-only: false + moved-wrongly-threshold: 0.0625 + moved-too-quickly-multiplier: 10.0 + timeout-time: 60 + restart-on-crash: true + restart-script: ./start.sh + netty-threads: 4 + attribute: + maxHealth: + max: 2048.0 + movementSpeed: + max: 2048.0 + attackDamage: + max: 2048.0 + log-villager-deaths: true + log-named-deaths: true + bungeecord: true +config-version: 12 +stats: + disable-saving: false + forced-stats: {} diff --git a/dev-resources/velocity-test/velocity-spigot2/forwarding.secret b/dev-resources/velocity-test/velocity-spigot2/forwarding.secret new file mode 100644 index 000000000..bcc8d2eb7 --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot2/forwarding.secret @@ -0,0 +1 @@ +big L \ No newline at end of file diff --git a/dev-resources/velocity-test/velocity-spigot2/ops.json b/dev-resources/velocity-test/velocity-spigot2/ops.json new file mode 100644 index 000000000..8d92d023f --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot2/ops.json @@ -0,0 +1,14 @@ +[ + { + "uuid": "88243ba3-382f-4eb0-874f-c5831eb3c0a6", + "name": "ToetMats", + "level": 4, + "bypassesPlayerLimit": false + }, + { + "uuid": "f0c8657b-f384-4df6-9d66-e9f36c36ce8a", + "name": "Mindgamesnl", + "level": 4, + "bypassesPlayerLimit": false + } +] \ No newline at end of file diff --git a/dev-resources/velocity-test/velocity-spigot2/server.properties b/dev-resources/velocity-test/velocity-spigot2/server.properties new file mode 100644 index 000000000..78ec1a6cf --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot2/server.properties @@ -0,0 +1,60 @@ +#Minecraft server properties +#Sat May 04 20:01:11 UTC 2024 +enable-jmx-monitoring=false +rcon.port=25575 +level-seed= +gamemode=survival +enable-command-block=false +enable-query=false +generator-settings={} +enforce-secure-profile=true +level-name=world +motd=A Minecraft Server +query.port=25565 +pvp=true +generate-structures=true +max-chained-neighbor-updates=1000000 +difficulty=easy +network-compression-threshold=256 +max-tick-time=60000 +require-resource-pack=false +use-native-transport=true +max-players=20 +online-mode=false +enable-status=true +allow-flight=false +initial-disabled-packs= +broadcast-rcon-to-ops=true +view-distance=10 +server-ip= +resource-pack-prompt= +allow-nether=true +server-port=25565 +enable-rcon=true +sync-chunk-writes=true +op-permission-level=4 +prevent-proxy-connections=false +hide-online-players=false +resource-pack= +entity-broadcast-range-percentage=100 +simulation-distance=10 +rcon.password=8f1c895282b5083a77fc2a9f +player-idle-timeout=0 +debug=false +force-gamemode=false +rate-limit=0 +hardcore=false +white-list=false +broadcast-console-to-ops=true +spawn-npcs=true +spawn-animals=true +log-ips=true +function-permission-level=2 +initial-enabled-packs=vanilla +level-type=minecraft\:normal +text-filtering-config= +spawn-monsters=true +enforce-whitelist=false +spawn-protection=16 +resource-pack-sha1= +max-world-size=29999984 diff --git a/dev-resources/velocity-test/velocity-spigot2/spigot.yml b/dev-resources/velocity-test/velocity-spigot2/spigot.yml new file mode 100644 index 000000000..44449af8a --- /dev/null +++ b/dev-resources/velocity-test/velocity-spigot2/spigot.yml @@ -0,0 +1,177 @@ +# This is the main configuration file for Spigot. +# As you can see, there's tons to configure. Some options may impact gameplay, so use +# with caution, and make sure you know what each option does before configuring. +# For a reference for any variable inside this file, check out the Spigot wiki at +# http://www.spigotmc.org/wiki/spigot-configuration/ +# +# If you need help with the configuration or have any questions related to Spigot, +# join us at the Discord or drop by our forums and leave a post. +# +# Discord: https://www.spigotmc.org/go/discord +# Forums: http://www.spigotmc.org/ + +messages: + whitelist: You are not whitelisted on this server! + unknown-command: Unknown command. Type "/help" for help. + server-full: The server is full! + outdated-client: Outdated client! Please use {0} + outdated-server: Outdated server! I'm still on {0} + restart: Server is restarting +commands: + replace-commands: + - setblock + - summon + - testforblock + - tellraw + spam-exclusions: + - /skill + silent-commandblock-console: false + log: true + tab-complete: 0 + send-namespaced: true +advancements: + disable-saving: false + disabled: + - minecraft:story/disabled +players: + disable-saving: false +world-settings: + default: + seed-ancientcity: 20083232 + seed-trailruins: 83469867 + seed-buriedtreasure: 10387320 + seed-mineshaft: default + seed-stronghold: default + below-zero-generation-in-existing-chunks: true + verbose: true + entity-activation-range: + water: 16 + villagers: 32 + flying-monsters: 32 + wake-up-inactive: + animals-max-per-tick: 4 + animals-every: 1200 + animals-for: 100 + monsters-max-per-tick: 8 + monsters-every: 400 + monsters-for: 100 + villagers-max-per-tick: 4 + villagers-every: 600 + villagers-for: 100 + flying-monsters-max-per-tick: 8 + flying-monsters-every: 200 + flying-monsters-for: 100 + villagers-work-immunity-after: 100 + villagers-work-immunity-for: 20 + villagers-active-for-panic: true + animals: 32 + monsters: 32 + raiders: 48 + misc: 16 + tick-inactive-villagers: true + ignore-spectators: false + entity-tracking-range: + players: 48 + animals: 48 + monsters: 48 + misc: 32 + display: 128 + other: 64 + ticks-per: + hopper-transfer: 8 + hopper-check: 1 + hopper-amount: 1 + hopper-can-load-chunks: false + merge-radius: + exp: 3.0 + item: 2.5 + mob-spawn-range: 6 + growth: + torchflower-modifier: 100 + glowberry-modifier: 100 + pitcherplant-modifier: 100 + cactus-modifier: 100 + cane-modifier: 100 + melon-modifier: 100 + mushroom-modifier: 100 + pumpkin-modifier: 100 + sapling-modifier: 100 + beetroot-modifier: 100 + carrot-modifier: 100 + potato-modifier: 100 + wheat-modifier: 100 + netherwart-modifier: 100 + vine-modifier: 100 + cocoa-modifier: 100 + bamboo-modifier: 100 + sweetberry-modifier: 100 + kelp-modifier: 100 + twistingvines-modifier: 100 + weepingvines-modifier: 100 + cavevines-modifier: 100 + dragon-death-sound-radius: 0 + seed-village: 10387312 + seed-desert: 14357617 + seed-igloo: 14357618 + seed-jungle: 14357619 + seed-swamp: 14357620 + seed-monument: 10387313 + seed-shipwreck: 165745295 + seed-ocean: 14357621 + seed-outpost: 165745296 + seed-endcity: 10387313 + seed-slime: 987234911 + seed-nether: 30084232 + seed-mansion: 10387319 + seed-fossil: 14357921 + seed-portal: 34222645 + hunger: + jump-walk-exhaustion: 0.05 + jump-sprint-exhaustion: 0.2 + combat-exhaustion: 0.1 + regen-exhaustion: 6.0 + swim-multiplier: 0.01 + sprint-multiplier: 0.1 + other-multiplier: 0.0 + max-tnt-per-tick: 100 + max-tick-time: + tile: 50 + entity: 50 + item-despawn-rate: 6000 + view-distance: default + simulation-distance: default + thunder-chance: 100000 + enable-zombie-pigmen-portal-spawns: true + arrow-despawn-rate: 1200 + trident-despawn-rate: 1200 + wither-spawn-sound-radius: 0 + end-portal-sound-radius: 0 + hanging-tick-frequency: 100 + zombie-aggressive-towards-villager: true + nerf-spawner-mobs: false +settings: + debug: false + sample-count: 12 + player-shuffle: 0 + user-cache-size: 1000 + save-user-cache-on-stop-only: false + moved-wrongly-threshold: 0.0625 + moved-too-quickly-multiplier: 10.0 + timeout-time: 60 + restart-on-crash: true + restart-script: ./start.sh + netty-threads: 4 + attribute: + maxHealth: + max: 2048.0 + movementSpeed: + max: 2048.0 + attackDamage: + max: 2048.0 + log-villager-deaths: true + log-named-deaths: true + bungeecord: true +config-version: 12 +stats: + disable-saving: false + forced-stats: {} diff --git a/dev-resources/velocity-test/velocity/forwarding.secret b/dev-resources/velocity-test/velocity/forwarding.secret new file mode 100644 index 000000000..bcc8d2eb7 --- /dev/null +++ b/dev-resources/velocity-test/velocity/forwarding.secret @@ -0,0 +1 @@ +big L \ No newline at end of file diff --git a/dev-resources/velocity-test/velocity/velocity.toml b/dev-resources/velocity-test/velocity/velocity.toml new file mode 100644 index 000000000..a55919d61 --- /dev/null +++ b/dev-resources/velocity-test/velocity/velocity.toml @@ -0,0 +1,115 @@ +config-version = "2.6" +# What port should the proxy be bound to? By default, we'll bind to all addresses on port 25565. +bind = "0.0.0.0:25565" +# What should be the MOTD? This gets displayed when the player adds your server to +# their server list. Only MiniMessage format is accepted. +motd = "<#09add3>A Velocity Server" +# What should we display for the maximum number of players? (Velocity does not support a cap +# on the number of players online.) +show-max-players = 500 +# Should we authenticate players with Mojang? By default, this is on. +online-mode = true +# Should the proxy enforce the new public key security standard? By default, this is on. +force-key-authentication = false +# If client's ISP/AS sent from this proxy is different from the one from Mojang's +# authentication server, the player is kicked. This disallows some VPN and proxy +# connections but is a weak form of protection. +prevent-client-proxy-connections = false +# Should we forward IP addresses and other data to backend servers? +# Available options: +# - "none": No forwarding will be done. All players will appear to be connecting +# from the proxy and will have offline-mode UUIDs. +# - "legacy": Forward player IPs and UUIDs in a BungeeCord-compatible format. Use this +# if you run servers using Minecraft 1.12 or lower. +# - "bungeeguard": Forward player IPs and UUIDs in a format supported by the BungeeGuard +# plugin. Use this if you run servers using Minecraft 1.12 or lower, and are +# unable to implement network level firewalling (on a shared host). +# - "modern": Forward player IPs and UUIDs as part of the login process using +# Velocity's native forwarding. Only applicable for Minecraft 1.13 or higher. +player-info-forwarding-mode = "legacy" +# If you are using modern or BungeeGuard IP forwarding, configure a file that contains a unique secret here. +# The file is expected to be UTF-8 encoded and not empty. +forwarding-secret-file = "forwarding.secret" +# Announce whether or not your server supports Forge. If you run a modded server, we +# suggest turning this on. +# +# If your network runs one modpack consistently, consider using ping-passthrough = "mods" +# instead for a nicer display in the server list. +announce-forge = false +# If enabled (default is false) and the proxy is in online mode, Velocity will kick +# any existing player who is online if a duplicate connection attempt is made. +kick-existing-players = false +# Should Velocity pass server list ping requests to a backend server? +# Available options: +# - "disabled": No pass-through will be done. The velocity.toml and server-icon.png +# will determine the initial server list ping response. +# - "mods": Passes only the mod list from your backend server into the response. +# The first server in your try list (or forced host) with a mod list will be +# used. If no backend servers can be contacted, Velocity won't display any +# mod information. +# - "description": Uses the description and mod list from the backend server. The first +# server in the try (or forced host) list that responds is used for the +# description and mod list. +# - "all": Uses the backend server's response as the proxy response. The Velocity +# configuration is used if no servers could be contacted. +ping-passthrough = "DISABLED" +# If not enabled (default is true) player IP addresses will be replaced by in logs +enable-player-address-logging = true +forwarding-secret = "r5i6NQQhaSiW" + +[servers] +# Configure your servers here. Each key represents the server's name, and the value +# represents the IP address of the server to connect to. +server1 = "velocity-paper1:25565" +server2 = "velocity-paper2:25565" +# In what order we should try servers when a player logs in or is kicked from a server. +try = ["server1"] + +[forced-hosts] + + +[advanced] + # How large a Minecraft packet has to be before we compress it. Setting this to zero will + # compress all packets, and setting it to -1 will disable compression entirely. + compression-threshold = 256 + # How much compression should be done (from 0-9). The default is -1, which uses the + # default level of 6. + compression-level = -1 + # How fast (in milliseconds) are clients allowed to connect after the last connection? By + # default, this is three seconds. Disable this by setting this to 0. + login-ratelimit = 3000 + # Specify a custom timeout for connection timeouts here. The default is five seconds. + connection-timeout = 5000 + # Specify a read timeout for connections here. The default is 30 seconds. + read-timeout = 30000 + # Enables compatibility with HAProxy's PROXY protocol. If you don't know what this is for, then + # don't enable it. + haproxy-protocol = false + # Enables TCP fast open support on the proxy. Requires the proxy to run on Linux. + tcp-fast-open = false + # Enables BungeeCord plugin messaging channel support on Velocity. + bungee-plugin-message-channel = true + # Shows ping requests to the proxy from clients. + show-ping-requests = false + # By default, Velocity will attempt to gracefully handle situations where the user unexpectedly + # loses connection to the server without an explicit disconnect message by attempting to fall the + # user back, except in the case of read timeouts. BungeeCord will disconnect the user instead. You + # can disable this setting to use the BungeeCord behavior. + failover-on-unexpected-server-disconnect = true + # Declares the proxy commands to 1.13+ clients. + announce-proxy-commands = true + # Enables the logging of commands + log-command-executions = false + # Enables logging of player connections when connecting to the proxy, switching servers + # and disconnecting from the proxy. + log-player-connections = true + +[query] + # Whether to enable responding to GameSpy 4 query responses or not. + enabled = false + # If query is enabled, on what port should the query protocol listen on? + port = 25565 + # This is the map name that is reported to the query services. + map = "Velocity" + show-plugins = false + diff --git a/modules/mapdb-migrator/dependency-reduced-pom.xml b/modules/mapdb-migrator/dependency-reduced-pom.xml index cc7e2cc9b..9a4ad754f 100644 --- a/modules/mapdb-migrator/dependency-reduced-pom.xml +++ b/modules/mapdb-migrator/dependency-reduced-pom.xml @@ -107,7 +107,7 @@ com.craftmend.openaudiomc openaudiomc - 6.10.0 + 6.10.1 provided diff --git a/modules/parties-module/dependency-reduced-pom.xml b/modules/parties-module/dependency-reduced-pom.xml index abefa1289..e5a25f57e 100644 --- a/modules/parties-module/dependency-reduced-pom.xml +++ b/modules/parties-module/dependency-reduced-pom.xml @@ -112,7 +112,7 @@ com.craftmend.openaudiomc openaudiomc - 6.10.0 + 6.10.1 provided diff --git a/modules/skywars-module/dependency-reduced-pom.xml b/modules/skywars-module/dependency-reduced-pom.xml index 8f075e42c..238a2f4e2 100644 --- a/modules/skywars-module/dependency-reduced-pom.xml +++ b/modules/skywars-module/dependency-reduced-pom.xml @@ -112,7 +112,7 @@ com.craftmend.openaudiomc openaudiomc - 6.10.0 + 6.10.1 provided diff --git a/modules/vistas-client/dependency-reduced-pom.xml b/modules/vistas-client/dependency-reduced-pom.xml index b2d79d853..b358603d7 100644 --- a/modules/vistas-client/dependency-reduced-pom.xml +++ b/modules/vistas-client/dependency-reduced-pom.xml @@ -115,7 +115,7 @@ com.craftmend.openaudiomc openaudiomc - 6.10.0 + 6.10.1 provided diff --git a/modules/vistas-server/dependency-reduced-pom.xml b/modules/vistas-server/dependency-reduced-pom.xml index 3cb256284..922179d83 100644 --- a/modules/vistas-server/dependency-reduced-pom.xml +++ b/modules/vistas-server/dependency-reduced-pom.xml @@ -174,12 +174,6 @@ junit 4.13.2 test - - - hamcrest-core - org.hamcrest - - diff --git a/modules/voice-join-permission/dependency-reduced-pom.xml b/modules/voice-join-permission/dependency-reduced-pom.xml index 563c23578..8401fbced 100644 --- a/modules/voice-join-permission/dependency-reduced-pom.xml +++ b/modules/voice-join-permission/dependency-reduced-pom.xml @@ -108,7 +108,7 @@ com.craftmend.openaudiomc openaudiomc - 6.10.0 + 6.10.1 provided diff --git a/plugin/protocol/static-resources/project_status.json b/plugin/protocol/static-resources/project_status.json index 38fe87a3c..9ff971c86 100644 --- a/plugin/protocol/static-resources/project_status.json +++ b/plugin/protocol/static-resources/project_status.json @@ -1,7 +1,7 @@ { "response": { "versioning": { - "version_tag": "6.10.0", + "version_tag": "6.10.1", "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." diff --git a/plugin/src/main/bash/data.bin b/plugin/src/main/bash/data.bin index 3c583fd2e..e453fb011 100755 --- a/plugin/src/main/bash/data.bin +++ b/plugin/src/main/bash/data.bin @@ -1 +1 @@ -BUILD_NUM="1402" +BUILD_NUM="1430" diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/OpenAudioMc.java b/plugin/src/main/java/com/craftmend/openaudiomc/OpenAudioMc.java index 8352049e8..c657b500c 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/OpenAudioMc.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/OpenAudioMc.java @@ -18,7 +18,11 @@ import com.craftmend.openaudiomc.generic.migrations.MigrationWorker; import com.craftmend.openaudiomc.generic.modules.ModuleLoaderService; import com.craftmend.openaudiomc.generic.mojang.MojangLookupService; +import com.craftmend.openaudiomc.generic.networking.abstracts.AbstractPacket; +import com.craftmend.openaudiomc.generic.networking.interfaces.Authenticatable; +import com.craftmend.openaudiomc.generic.networking.interfaces.INetworkingEvents; import com.craftmend.openaudiomc.generic.networking.interfaces.NetworkingService; +import com.craftmend.openaudiomc.generic.networking.payloads.client.interfaces.SourceHolder; import com.craftmend.openaudiomc.generic.oac.OpenaudioAccountService; import com.craftmend.openaudiomc.generic.platform.Platform; import com.craftmend.openaudiomc.generic.platform.interfaces.OpenAudioInvoker; diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/MediaApiImpl.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/MediaApiImpl.java index e4d9a95b7..c5e737e25 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/MediaApiImpl.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/MediaApiImpl.java @@ -84,4 +84,18 @@ public void stopFor(@NotNull String id, @NotNull Client... clients) { OpenAudioMc.getService(NetworkingService.class).send(validateClient(client), new PacketClientDestroyMedia(id)); } } + + @Override + public void stopFor(@NotNull String id, int fadeTime, @NotNull Client... clients) { + for (Client client : clients) { + OpenAudioMc.getService(NetworkingService.class).send(validateClient(client), new PacketClientDestroyMedia(id, fadeTime)); + } + } + + @Override + public void stopFor(int fadeTime, @NotNull Client... clients) { + for (Client client : clients) { + OpenAudioMc.getService(NetworkingService.class).send(validateClient(client), new PacketClientDestroyMedia(null, fadeTime)); + } + } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/VoiceApiImpl.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/VoiceApiImpl.java index da89d97ad..9fb48f29e 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/VoiceApiImpl.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/api/implementaions/VoiceApiImpl.java @@ -1,8 +1,13 @@ package com.craftmend.openaudiomc.generic.api.implementaions; import com.craftmend.openaudiomc.OpenAudioMc; +import com.craftmend.openaudiomc.api.EventApi; import com.craftmend.openaudiomc.api.VoiceApi; +import com.craftmend.openaudiomc.api.channels.VoiceChannel; import com.craftmend.openaudiomc.api.clients.Client; +import com.craftmend.openaudiomc.api.events.client.ClientPeerAddEvent; +import com.craftmend.openaudiomc.api.events.client.ClientPeerRemovedEvent; +import com.craftmend.openaudiomc.api.interfaces.AudioApi; import com.craftmend.openaudiomc.api.voice.CustomPlayerFilter; import com.craftmend.openaudiomc.api.voice.VoicePeerOptions; import com.craftmend.openaudiomc.generic.client.objects.ClientConnection; @@ -10,11 +15,11 @@ 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.spigot.modules.voicechat.VoiceChannelService; import com.craftmend.openaudiomc.spigot.modules.voicechat.filters.FilterService; +import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.Objects; -import java.util.UUID; +import java.util.*; public class VoiceApiImpl implements VoiceApi { @@ -93,13 +98,17 @@ public void addStaticPeer(Client client, Client peerToAdd, boolean visible, bool throw new IllegalStateException("Both clients must be ready (connected and have voice chat enabled) before adding a peer"); } - if (isProximityPeer(client, peerToAdd)) { - updatePeerOptions(client, peerToAdd, options); - clientConnection.getRtcSessionManager().getCurrentGlobalPeers().add(peerToAdd.getActor().getUniqueId()); - clientConnection.getRtcSessionManager().getCurrentProximityPeers().remove(peerToAdd.getActor().getUniqueId()); - } else { - clientConnection.getRtcSessionManager().getCurrentGlobalPeers().add(peerToAdd.getActor().getUniqueId()); - clientConnection.getPeerQueue().addSubscribe(peerConnection, clientConnection, options); + // fire event + ClientPeerAddEvent event = (ClientPeerAddEvent) EventApi.getInstance().callEvent(new ClientPeerAddEvent(client, peerToAdd, options)); + if (!event.isCancelled()) { + if (isProximityPeer(client, peerToAdd)) { + updatePeerOptions(client, peerToAdd, options); + clientConnection.getRtcSessionManager().getCurrentGlobalPeers().add(peerToAdd.getActor().getUniqueId()); + clientConnection.getRtcSessionManager().getCurrentProximityPeers().remove(peerToAdd.getActor().getUniqueId()); + } else { + clientConnection.getRtcSessionManager().getCurrentGlobalPeers().add(peerToAdd.getActor().getUniqueId()); + clientConnection.getPeerQueue().addSubscribe(peerConnection, clientConnection, options); + } } if (mutual) { @@ -113,6 +122,8 @@ public void removeStaticPeer(Client client, Client peerToRemove, boolean mutual) throw new IllegalStateException("This method is only available on the spigot platform"); } + EventApi.getInstance().callEvent(new ClientPeerRemovedEvent(client, peerToRemove)); + if (isGlobalPeer(client, peerToRemove)) { ClientConnection clientConnection = (ClientConnection) client; ClientConnection peerConnection = (ClientConnection) peerToRemove; @@ -134,4 +145,30 @@ public void addFilterFunction(CustomPlayerFilter customPlayerFilter) { public List getCustomPlayerFilters() { return OpenAudioMc.getService(FilterService.class).getCustomPlayerFilters(); } + + @Override + public Collection getChannels() { + return new ArrayList<>(OpenAudioMc.getService(VoiceChannelService.class).getChannels()); + } + + @Nullable + @Override + public VoiceChannel getChannel(String name) { + return OpenAudioMc.getService(VoiceChannelService.class).getChannel(name); + } + + @Override + public VoiceChannel createChannel(String name, Client creator, boolean requiresPermission, @Nullable String requiredPermission) { + return OpenAudioMc.getService(VoiceChannelService.class).createChannel(name, creator, requiresPermission, requiredPermission); + } + + @Override + public void deleteChannel(VoiceChannel channel) { + OpenAudioMc.getService(VoiceChannelService.class).deleteChannel(channel.getName()); + } + + @Override + public boolean isChannelNameValid(String s) { + return OpenAudioMc.getService(VoiceChannelService.class).isChannelNameValid(s); + } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/authentication/AuthenticationService.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/authentication/AuthenticationService.java index 25a8bf176..472ee8d65 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/authentication/AuthenticationService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/authentication/AuthenticationService.java @@ -44,6 +44,13 @@ public void onEnable() { public void initialize() { driver = new AuthenticationDriver(this); registrationProvider = new RestRequest(RegistrationResponse.class, Endpoint.REGISTER); + + // add provisioning key, if we have it, look for it in the launch properties + String provisioningKey = System.getProperty("openaudio.provisioningKey"); + if (provisioningKey != null) { + registrationProvider.setQuery("provisioningKey", provisioningKey); + } + OpenAudioLogger.info("Starting authentication module"); loadData(); explicitParentPublicKey = serverKeySet.getPublicKey(); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/CommandService.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/CommandService.java index 236949619..77af4780f 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/CommandService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/CommandService.java @@ -147,7 +147,7 @@ public void invokeCommand(User sender, CommandContext context, String[] args, } } } else { - sender.sendMessage(MagicValue.COMMAND_PREFIX.get(String.class) + "You dont have the permissions to do this, sorry! (spigot)"); + sender.sendMessage(MagicValue.COMMAND_PREFIX.get(String.class) + "You dont have the permissions to do this, sorry! (" + OpenAudioMc.getInstance().getPlatform() + ")"); } } else { sender.sendMessage(MagicValue.COMMAND_PREFIX.get(String.class) + "Unknown sub command: " + args[0].toLowerCase()); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/interfaces/SubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/interfaces/SubCommand.java index ff384128b..81c4497a1 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/interfaces/SubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/interfaces/SubCommand.java @@ -71,9 +71,11 @@ protected void message(User sender, String message) { */ public boolean isAllowed(User commandSender) { if (ignorePermissions) return true; + return commandSender.hasPermission(permissionScope + command) || commandSender.hasPermission(permissionScope + "*") - || commandSender.hasPermission("openaudiomc.*"); + || commandSender.hasPermission("openaudiomc.*") + || commandSender.isAdministrator(); } protected void registerSubCommands(SubCommand... commands) { diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/AcceptSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/AcceptSubCommand.java index b13baa48a..08e10390b 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/AcceptSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/AcceptSubCommand.java @@ -4,6 +4,7 @@ import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.environment.MagicValue; +import com.craftmend.openaudiomc.generic.platform.interfaces.TaskService; import com.craftmend.openaudiomc.generic.user.User; import com.craftmend.openaudiomc.generic.storage.interfaces.Configuration; import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; @@ -27,7 +28,7 @@ public void onExecute(User sender, String[] args) { sender.sendMessage(MagicValue.COMMAND_PREFIX.get(String.class) + "Welcome to OpenAudioMc! you accepted the terms, enjoy the service!"); - service.connectIfDown(); + OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> service.connectIfDown()); for (ClientConnection client : service.getClients()) { client.getAuth().publishSessionUrl(); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/LinkSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/LinkSubCommand.java index f00eaa14f..0d0e82fcf 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/LinkSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/LinkSubCommand.java @@ -6,6 +6,7 @@ import com.craftmend.openaudiomc.generic.commands.objects.Argument; import com.craftmend.openaudiomc.generic.networking.interfaces.NetworkingService; import com.craftmend.openaudiomc.generic.platform.OaColor; +import com.craftmend.openaudiomc.generic.platform.interfaces.TaskService; import com.craftmend.openaudiomc.generic.rest.RestRequest; import com.craftmend.openaudiomc.generic.rest.routes.Endpoint; import com.craftmend.openaudiomc.generic.rest.types.ClaimCodeResponse; @@ -28,7 +29,7 @@ public void onExecute(User sender, String[] args) { } // init connection so we receive the event - OpenAudioMc.getService(NetworkingService.class).connectIfDown(); + OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> OpenAudioMc.getService(NetworkingService.class).connectIfDown()); message(sender, OaColor.GRAY + "Generating link..."); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/ReloadSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/ReloadSubCommand.java index bd5378ab1..16d326fb6 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/ReloadSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/commands/subcommands/ReloadSubCommand.java @@ -9,6 +9,7 @@ import com.craftmend.openaudiomc.generic.client.objects.ClientConnection; import com.craftmend.openaudiomc.generic.networking.interfaces.NetworkingService; import com.craftmend.openaudiomc.generic.platform.Platform; +import com.craftmend.openaudiomc.generic.platform.interfaces.TaskService; import com.craftmend.openaudiomc.generic.user.User; public class ReloadSubCommand extends SubCommand { @@ -33,7 +34,7 @@ public void onExecute(User sender, String[] args) { OpenAudioMc.getService(NetworkingService.class).stop(); message(sender, Platform.makeColor("RED") + "Re-activating account..."); - OpenAudioMc.getService(NetworkingService.class).connectIfDown(); + OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> OpenAudioMc.getService(NetworkingService.class).connectIfDown()); EventApi.getInstance().callEvent(new SystemReloadEvent()); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/environment/MagicValue.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/environment/MagicValue.java index 69d2a2e85..5d7370f35 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/environment/MagicValue.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/environment/MagicValue.java @@ -20,6 +20,7 @@ public enum MagicValue { DYNAMIC_REGISTRATIONS(false), PARENT_PLATFORM(Platform.UNKNOWN), PLATFORM_FORCE_LATE_FIND(false), + FORCE_DISABLE_CLIENT_NET_LOOKUP(false), COMMAND_PREFIX("[OpenAudioMc - Magic]"); private static final EnumMap tempValues = new EnumMap<>(MagicValue.class); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/events/EventService.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/events/EventService.java index 829f20ff6..cd8263d45 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/events/EventService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/events/EventService.java @@ -16,10 +16,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class EventService extends Service implements EventApi { - private final Map, List> eventHandlers = new HashMap<>(); + private final Map, List> eventHandlers = new ConcurrentHashMap<>(); public EventService() { // register register events 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 55b83d830..fa46f719e 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 @@ -62,6 +62,7 @@ public void handleMigrations() { new AddConfigKeyMigration(SETTINGS_VOICE_FILTERS_CHANNEL, "Add migrations for the new voicechat channel filter"), new AddConfigKeyMigration(SETTINGS_PRELOAD_REPLENISH_POOL, "Add config value for better pool management"), new AddConfigKeyMigration(SETTINGS_AUTO_RECONNECT, "Add a migration setting for auto reconnect"), + new AddConfigKeyMigration(SETTINGS_SPEAKER_MAX_RANGE, "Add max range config value"), }; for (SimpleMigration migration : migrations) { diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/DefaultNetworkingService.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/DefaultNetworkingService.java index 7922c5a4e..f4aa56233 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/DefaultNetworkingService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/DefaultNetworkingService.java @@ -32,6 +32,9 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; public class DefaultNetworkingService extends NetworkingService { @@ -42,6 +45,7 @@ public class DefaultNetworkingService extends NetworkingService { private final PacketQueue packetQueue = new PacketQueue(); private SocketConnection socketConnection; private int packetThroughput = 0; + private Lock connectLock = new ReentrantLock(); public DefaultNetworkingService() { this.onModuleLoad(); @@ -69,7 +73,7 @@ public void onModuleLoad() { EventApi.getInstance().registerHandler(ClientAuthenticationEvent.class, event -> { // get Client from event ClientConnection client = getClient(event.getActor().getUniqueId()); - if (client == null) { + if (client == null) { event.setCancelled(true); return; } @@ -113,14 +117,23 @@ private void init() { */ @Override public void connectIfDown() { - if (!OpenAudioMc.getService(StateService.class).getCurrentState().canConnect()) { - // health check for voice + try { + if (!connectLock.tryLock(30, TimeUnit.SECONDS)) + return; + + if (!OpenAudioMc.getService(StateService.class).getCurrentState().canConnect()) { + // health check for voice + OpenAudioMc.getService(OpenaudioAccountService.class).startVoiceHandshake(); + return; + } + // update state OpenAudioMc.getService(OpenaudioAccountService.class).startVoiceHandshake(); - return; + socketConnection.setupConnection(); + } catch (InterruptedException e) { + // ignore - its okay + } finally { + connectLock.unlock(); } - // update state - OpenAudioMc.getService(OpenaudioAccountService.class).startVoiceHandshake(); - OpenAudioMc.resolveDependency(TaskService.class).runAsync(() -> socketConnection.setupConnection()); } /** @@ -275,7 +288,7 @@ public Set getEvents() { public void addEventHandler(INetworkingEvents events) { eventHandlers.add(events); } - + public void discardQueue() { this.packetQueue.clearAll(); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/interfaces/SourceHolder.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/interfaces/SourceHolder.java index 0db6987dc..437f27785 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/interfaces/SourceHolder.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/interfaces/SourceHolder.java @@ -3,4 +3,5 @@ public interface SourceHolder { String getSource(); + void setSource(String source); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/media/ClientCreateMediaPayload.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/media/ClientCreateMediaPayload.java index baa292d05..44a310100 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/media/ClientCreateMediaPayload.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/media/ClientCreateMediaPayload.java @@ -24,4 +24,11 @@ public ClientCreateMediaPayload(Media media) { public String getSource() { return media.getSource(); } + + @Override + public void setSource(String source) { + media.setSource(source); + } + + } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/speakers/ClientSpeakerCreatePayload.java b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/speakers/ClientSpeakerCreatePayload.java index a6d9ef850..999574d4d 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/speakers/ClientSpeakerCreatePayload.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/generic/networking/payloads/client/speakers/ClientSpeakerCreatePayload.java @@ -14,4 +14,9 @@ public class ClientSpeakerCreatePayload extends AbstractPacketPayload implements public String getSource() { return clientSpeaker.getSource(); } + + @Override + public void setSource(String source) { + clientSpeaker.setSource(source); + } } 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 6f0e05431..cda4533d3 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 @@ -87,6 +87,7 @@ public enum StorageKey { SETTINGS_REGIONS_SYNC(false, "options.sync-regions", StorageLocation.CONFIG_FILE), SETTINGS_SPEAKER_SYNC(false, "options.sync-speakers", StorageLocation.CONFIG_FILE), SETTINGS_SPEAKER_RANGE(false, "options.speaker-radius", StorageLocation.CONFIG_FILE), + SETTINGS_SPEAKER_MAX_RANGE(false, "options.max-speaker-radius", StorageLocation.CONFIG_FILE), SETTINGS_SEND_URL_ON_JOIN(false, "options.send-on-join", StorageLocation.CONFIG_FILE), SETTINGS_SEND_URL_ON_JOIN_DELAY(false, "options.send-on-join-delay", StorageLocation.CONFIG_FILE), SETTINGS_USE_WG_PRIORITY(false, "options.use-region-priority", StorageLocation.CONFIG_FILE), diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/speaker/SpeakerGiveSubCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/speaker/SpeakerGiveSubCommand.java index 016a45ad4..9e6f3437a 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/speaker/SpeakerGiveSubCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/commands/subcommands/speaker/SpeakerGiveSubCommand.java @@ -5,6 +5,7 @@ import com.craftmend.openaudiomc.generic.commands.objects.CommandError; import com.craftmend.openaudiomc.generic.media.MediaService; import com.craftmend.openaudiomc.generic.media.utils.Validation; +import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; import com.craftmend.openaudiomc.generic.user.User; import com.craftmend.openaudiomc.spigot.modules.commands.subcommands.SpeakersSubCommand; import com.craftmend.openaudiomc.spigot.modules.speakers.utils.SpeakerUtils; @@ -33,6 +34,10 @@ public void onExecute(User sender, String[] args) { radius = Integer.valueOf(args[1]); } + if (radius > StorageKey.SETTINGS_SPEAKER_MAX_RANGE.getInt()) { + throw new CommandError("The radius is too large. The maximum radius is " + StorageKey.SETTINGS_SPEAKER_MAX_RANGE.getInt()); + } + if (Validation.isStringInvalid(args[0])) { throw new CommandError("Invalid source url."); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/configuration/SpigotConfiguration.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/configuration/SpigotConfiguration.java index d29d52f0f..ae10b459c 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/configuration/SpigotConfiguration.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/configuration/SpigotConfiguration.java @@ -21,7 +21,7 @@ public class SpigotConfiguration implements Configuration, Listener { private FileConfiguration mainConfig; - private final FileConfiguration dataConfig; + private FileConfiguration dataConfig; private final Map cachedConfigStrings = new ConcurrentHashMap<>(); @@ -285,6 +285,7 @@ public void reloadConfig() { this.cachedConfigStrings.clear(); OpenAudioMcSpigot.getInstance().reloadConfig(); mainConfig = OpenAudioMcSpigot.getInstance().getConfig(); + dataConfig = YamlConfiguration.loadConfiguration(new File(OpenAudioMcSpigot.getInstance().getDataFolder(), "data.yml")); this.loadSettings(); } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/players/objects/SpigotConnection.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/players/objects/SpigotConnection.java index 50f7562be..2124df094 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/players/objects/SpigotConnection.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/players/objects/SpigotConnection.java @@ -20,6 +20,7 @@ import com.craftmend.openaudiomc.spigot.modules.speakers.objects.ApplicableSpeaker; import com.craftmend.openaudiomc.spigot.modules.speakers.objects.SpeakerSettings; +import com.craftmend.openaudiomc.spigot.modules.voicechat.VoiceChannelService; import com.craftmend.openaudiomc.spigot.services.utils.DataWatcher; import lombok.Getter; import lombok.Setter; @@ -117,6 +118,8 @@ public SpigotConnection(Player player, ClientConnection clientConnection) { OpenAudioMc.resolveDependency(TaskService.class).runSync(() -> { Bukkit.getServer().getPluginManager().callEvent(new ClientDisconnectEvent(player)); }); + + OpenAudioMc.getService(VoiceChannelService.class).handleUserDisconnect(clientConnection); }); } @@ -147,6 +150,7 @@ public void onDestroy() { this.locationDataWatcher.stop(); this.currentSpeakers.clear(); this.currentRegions.clear(); + OpenAudioMc.getService(VoiceChannelService.class).handleUserDisconnect(clientConnection); } /** diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/adapters/ModernRegionAdapter.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/adapters/ModernRegionAdapter.java index 884a929db..99858be5c 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/adapters/ModernRegionAdapter.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/adapters/ModernRegionAdapter.java @@ -35,7 +35,7 @@ public Set getRegionsAtLocation(Location location) { RegionQuery query = container.createQuery(); ApplicableRegionSet set = query.getApplicableRegions(BukkitAdapter.adapt(location)); - int highestPriority = 0; + Integer highestPriority = Integer.MIN_VALUE; Set regions = set.getRegions() .stream() .map(ApiRegion::wrapWorldGuard) diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/interfaces/RegionAdapterBase.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/interfaces/RegionAdapterBase.java index deca96b76..8e50bf935 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/interfaces/RegionAdapterBase.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/interfaces/RegionAdapterBase.java @@ -56,7 +56,7 @@ public List getAudioRegions(Location location) { } @NotNull - protected Set prioritySort(Set regions, int highestPriority, boolean usePriority) { + protected Set prioritySort(Set regions, Integer highestPriority, boolean usePriority) { ApiRegion highestRegion = null; if (usePriority) { for (ApiRegion region : regions) { diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/users/adapters/SpigotUserAdapter.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/users/adapters/SpigotUserAdapter.java index edd02cc25..4abbf5510 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/users/adapters/SpigotUserAdapter.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/users/adapters/SpigotUserAdapter.java @@ -1,5 +1,6 @@ package com.craftmend.openaudiomc.spigot.modules.users.adapters; +import com.craftmend.openaudiomc.generic.environment.MagicValue; import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; import com.craftmend.openaudiomc.generic.user.User; import lombok.AllArgsConstructor; @@ -125,6 +126,10 @@ public UUID getUniqueId() { @Override public String getIpAddress() { if (player instanceof Player) { + if (!StorageKey.SETTINGS_TOKEN_AUTO_LOGIN.getBoolean() && !MagicValue.FORCE_DISABLE_CLIENT_NET_LOOKUP.get(Boolean.class)) { + return "unknown"; + } + Player p = (Player) player; if (p.getAddress() == null) return "unknown"; String ip = p.getAddress().getHostName(); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/VoiceChannelService.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/VoiceChannelService.java index 49220c5fe..2ddb258e8 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/VoiceChannelService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/VoiceChannelService.java @@ -1,6 +1,8 @@ package com.craftmend.openaudiomc.spigot.modules.voicechat; import com.craftmend.openaudiomc.api.EventApi; +import com.craftmend.openaudiomc.api.channels.VoiceChannel; +import com.craftmend.openaudiomc.api.clients.Client; import com.craftmend.openaudiomc.api.events.client.ClientDisconnectEvent; import com.craftmend.openaudiomc.generic.client.objects.ClientConnection; import com.craftmend.openaudiomc.generic.commands.CommandService; @@ -10,7 +12,6 @@ import com.craftmend.openaudiomc.generic.service.Inject; import com.craftmend.openaudiomc.generic.service.Service; import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; -import com.craftmend.openaudiomc.generic.storage.interfaces.Configuration; import com.craftmend.openaudiomc.generic.user.User; import com.craftmend.openaudiomc.spigot.modules.voicechat.channels.Channel; import com.craftmend.openaudiomc.spigot.modules.voicechat.commands.*; @@ -20,10 +21,11 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class VoiceChannelService extends Service { - private Map channelMap = new HashMap<>(); + private Map channelMap = new ConcurrentHashMap<>(); @Inject public VoiceChannelService( @@ -114,14 +116,14 @@ public boolean createUserChannel(String name, User creator) { channelMap.put(name, previous); return false; } - + created.addMember(creator); // success return true; } - private boolean isChannelNameValid(String s) { + public boolean isChannelNameValid(String s) { if (s.isEmpty()) return false; if (s.contains(" ")) return false; if (channelMap.containsKey(s)) return false; @@ -144,4 +146,22 @@ public boolean deleteChannel(String name) { return deleted != null; } + public void handleUserDisconnect(ClientConnection player) { + // find any channel the player is in + channelMap.values().forEach(channel -> { + if (channel.isMember(player.getUser().getUniqueId())) { + channel.removeMember(player.getUser()); + } + }); + } + + public VoiceChannel createChannel(String name, Client creator, boolean requiresPermission, String requiredPermission) { + if (!isChannelNameValid(name)) return null; + Channel channel = new Channel(name, requiresPermission ? requiredPermission : null, this); + if (creator != null) { + channel.addMember(creator); + } + channelMap.put(name, channel); + return channel; + } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/Channel.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/Channel.java index b2ddbb2aa..3ad9e218d 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/Channel.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/Channel.java @@ -1,6 +1,10 @@ package com.craftmend.openaudiomc.spigot.modules.voicechat.channels; import com.craftmend.openaudiomc.api.VoiceApi; +import com.craftmend.openaudiomc.api.basic.Actor; +import com.craftmend.openaudiomc.api.channels.ChannelJoinResponse; +import com.craftmend.openaudiomc.api.channels.VoiceChannel; +import com.craftmend.openaudiomc.api.clients.Client; import com.craftmend.openaudiomc.generic.client.objects.ClientConnection; import com.craftmend.openaudiomc.generic.platform.Platform; import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; @@ -9,12 +13,9 @@ import lombok.Getter; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import java.util.*; -public class Channel { +public class Channel implements VoiceChannel { @Nullable @Getter private User creator; @@ -108,6 +109,10 @@ public void removeMember(User user) { checkAbandonment(); } + public boolean isMember(UUID uuid) { + return members.containsKey(uuid); + } + private void checkAbandonment() { if (type != ChannelType.USER_CHANNEL) return; if (members.size() < 2) { @@ -128,7 +133,38 @@ public void drainMembers() { members.clear(); } - public Collection getMembers() { - return members.values(); + public Collection getMembers() { + return new ArrayList<>(members.values()); + } + + @Override + public boolean requiresPermission() { + return requiredPermission != null; + } + + @Nullable + @Override + public String getRequiredPermission() { + return requiredPermission; + } + + @Override + public boolean isMember(Actor actor) { + return members.containsKey(actor.getUniqueId()); + } + + @Override + public ChannelJoinResponse joinPreconditionCheck(Client client) { + return attemptEnter(((ClientConnection) client).getUser()).getApiValue(); + } + + @Override + public void addMember(Client client) { + addMember(((ClientConnection) client).getUser()); + } + + @Override + public void removeMember(Client client) { + removeMember(((ClientConnection) client).getUser()); } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/ChannelEnterResponse.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/ChannelEnterResponse.java index 801bb0a94..ee866aa83 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/ChannelEnterResponse.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/channels/ChannelEnterResponse.java @@ -1,18 +1,21 @@ package com.craftmend.openaudiomc.spigot.modules.voicechat.channels; +import com.craftmend.openaudiomc.api.channels.ChannelJoinResponse; import com.craftmend.openaudiomc.generic.storage.enums.StorageKey; import lombok.Getter; public enum ChannelEnterResponse { - OK(StorageKey.MESSAGE_VOICE_CHANNEL_JOINED.getString()), - INVITE_ONLY(StorageKey.MESSAGE_VOICE_CHANNEL_INVITE_ONLY.getString()), - NO_PERMISSION(StorageKey.MESSAGE_VOICE_CHANNEL_NO_PERMISSION_TO_JOIN.getString()); + OK(StorageKey.MESSAGE_VOICE_CHANNEL_JOINED.getString(), ChannelJoinResponse.ALLOWED), + INVITE_ONLY(StorageKey.MESSAGE_VOICE_CHANNEL_INVITE_ONLY.getString(), ChannelJoinResponse.INVITE_ONLY), + NO_PERMISSION(StorageKey.MESSAGE_VOICE_CHANNEL_NO_PERMISSION_TO_JOIN.getString(), ChannelJoinResponse.NO_PERMISSION); @Getter private final String message; + @Getter private final ChannelJoinResponse apiValue; - ChannelEnterResponse(String message) { + ChannelEnterResponse(String message, ChannelJoinResponse apiValue) { this.message = message; + this.apiValue = apiValue; } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelInviteCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelInviteCommand.java index 5afd06800..2f3d8e7ff 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelInviteCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelInviteCommand.java @@ -109,8 +109,8 @@ public void onExecute(User sender, String[] args) { } // is the target already in a channel? - for (ClientConnection member : channel.getMembers()) { - if (member.getOwner().getUniqueId().equals(target.getUniqueId())) { + for (Client member : channel.getMembers()) { + if (member.getActor().getUniqueId().equals(target.getUniqueId())) { throw new CommandError(StorageKey.MESSAGE_VOICE_CHANNEL_TARGET_ALREADY_MEMBER.getString()); } } diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelListCommand.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelListCommand.java index a8643e508..811888ca3 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelListCommand.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/commands/ChannelListCommand.java @@ -1,5 +1,6 @@ package com.craftmend.openaudiomc.spigot.modules.voicechat.commands; +import com.craftmend.openaudiomc.api.clients.Client; import com.craftmend.openaudiomc.generic.client.objects.ClientConnection; import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand; import com.craftmend.openaudiomc.generic.commands.objects.Argument; @@ -39,14 +40,14 @@ public void onExecute(User sender, String[] args) { for (Channel channel : channels) { StringBuilder readableOccupants; - Collection occupants = channel.getMembers(); + Collection occupants = channel.getMembers(); if (occupants.isEmpty()) { readableOccupants = new StringBuilder(OaColor.RED + "[empty]"); } else { int size = occupants.size(); int i = 0; readableOccupants = new StringBuilder(OaColor.GREEN + "["); - for (ClientConnection occupant : occupants) { + for (Client occupant : occupants) { readableOccupants.append(occupant.getActor().getName()); if (i < size - 1) { readableOccupants.append(", "); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerPeerTicker.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerPeerTicker.java index c0eb5acba..e147ac71c 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerPeerTicker.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/voicechat/tasks/PlayerPeerTicker.java @@ -90,12 +90,13 @@ public void run() { Stream pre = Stream.of(allClients) .filter((c) -> !c.getSession().isResetVc()) // don't check players that are resetting .filter((c) -> c.getOwner().getUniqueId() != client.getOwner().getUniqueId()) // don't check yourself + // only run these checks if we're either both not moderating, or I am but the other isn't + .filter((c) -> client.isModerating() == c.isModerating() || client.isModerating() && !c.isModerating()) // mark checked, prior to filtering, because if someone isn't // applicable, then they should still be marked as checked to prevent // future checks .filter((c) -> combinationChecker.getAndPutIfAbsent(client.getUser().getUniqueId(), c.getUser().getUniqueId(), false) == CombinationChecker.NOT_CHECKED) // don't check combinations that failed .filter(c -> !client.getRtcSessionManager().getCurrentGlobalPeers().contains(c.getOwner().getUniqueId())) // exempt global peers - .filter((c) -> c.isModerating() == client.isModerating()) // only allow equal moderation states ; // execute API filters diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/server/ServerService.java b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/server/ServerService.java index 94b9e1d3e..367364880 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/server/ServerService.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/spigot/services/server/ServerService.java @@ -24,7 +24,14 @@ public void onEnable() { return; } - String versionString = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].replace("v", ""); + String[] packageParts = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(","); + if (packageParts.length < 4) { + // paper removed package versioning, so we can't detect it, but it's modern + version = ServerVersion.MODERN; + return; + } + + String versionString = packageParts[3].replace("v", ""); versionString = versionString.replace("1_", "").replaceAll("_R\\d", "").replaceAll("[^\\d.]", ""); int subVersion = Integer.parseInt(versionString); diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/OpenAudioMcVelocity.java b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/OpenAudioMcVelocity.java index 701f1ae0f..29c114f89 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/OpenAudioMcVelocity.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/OpenAudioMcVelocity.java @@ -37,7 +37,7 @@ @Plugin( id = "openaudiomc", name = "OpenAudioMc Bungee Plugin Port for Velocity", - version = "6.10.0", + version = "6.10.1", authors = {"Mindgamesnl", "fluse1367"}, description = "OpenAudioMc: Proximity voice chat & audio plugin for Minecraft, no mods needed. Supports Bungeecord, Velocity, Spigot & more.", url = "https://openaudiomc.net/" diff --git a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/player/listeners/PlayerConnectionListener.java b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/player/listeners/PlayerConnectionListener.java index 9b6ed0585..7f0780369 100644 --- a/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/player/listeners/PlayerConnectionListener.java +++ b/plugin/src/main/java/com/craftmend/openaudiomc/velocity/modules/player/listeners/PlayerConnectionListener.java @@ -12,6 +12,9 @@ import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.PostLoginEvent; import com.velocitypowered.api.event.player.ServerConnectedEvent; +import com.velocitypowered.api.event.player.ServerPostConnectEvent; +import com.velocitypowered.api.proxy.ServerConnection; +import com.velocitypowered.api.proxy.server.RegisteredServer; import lombok.SneakyThrows; public class PlayerConnectionListener { @@ -28,14 +31,20 @@ public void onLogout(DisconnectEvent event) { } @Subscribe - public void onSwitch(ServerConnectedEvent event) { + public void onSwitch(ServerPostConnectEvent event) { VelocityProxyNode from = null; - if (event.getPreviousServer().isPresent()) { - from = new VelocityProxyNode(event.getPreviousServer().get()); + if (event.getPreviousServer() != null) { + from = new VelocityProxyNode(event.getPreviousServer()); } - new VelocityProxyNode(event.getServer()).sendPacket( + ServerConnection currentServer = null; + + if (event.getPlayer().getCurrentServer().isPresent()) { + currentServer = event.getPlayer().getCurrentServer().get(); + } + + new VelocityProxyNode(currentServer.getServer()).sendPacket( new AnnouncePlatformPacket( OpenAudioMc.getService(AuthenticationService.class).getServerKeySet().getPublicKey().getValue(), Platform.VELOCITY @@ -44,7 +53,7 @@ public void onSwitch(ServerConnectedEvent event) { OpenAudioMc.getService(ProxyHostService.class).onServerSwitch( new VelocityUserAdapter(event.getPlayer()), from, - new VelocityProxyNode(event.getServer()) + new VelocityProxyNode(currentServer.getServer()) ); } diff --git a/plugin/src/main/resources/bungee.yml b/plugin/src/main/resources/bungee.yml index ad88ac73b..bf02cbf2a 100644 --- a/plugin/src/main/resources/bungee.yml +++ b/plugin/src/main/resources/bungee.yml @@ -1,5 +1,5 @@ name: OpenAudioMc -version: 6.10.0 +version: 6.10.1 main: com.craftmend.openaudiomc.bungee.OpenAudioMcBungee author: Mindgamesnl authors: [Mindgamesnl] @@ -12,4 +12,4 @@ commands: volume: aliases: [setvolume, vol] openaudiomc: - aliases: [oam, oa, openaudio] \ No newline at end of file + aliases: [oam, oa, openaudio] diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index b70940426..97a7f6547 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -192,6 +192,9 @@ options: # If default radius for speakers (in blocks) speaker-radius: 10 + # This is the maximum radius speakers can have when spawned in through the command. + max-speaker-radius: 75 + # If set to true, speakers will sync their timecodes sync-speakers: true diff --git a/plugin/src/main/resources/data.bin b/plugin/src/main/resources/data.bin index 3c583fd2e..e453fb011 100755 --- a/plugin/src/main/resources/data.bin +++ b/plugin/src/main/resources/data.bin @@ -1 +1 @@ -BUILD_NUM="1402" +BUILD_NUM="1430" diff --git a/plugin/src/main/resources/openaudiomc-build.properties b/plugin/src/main/resources/openaudiomc-build.properties index cf8f79f66..963f39491 100644 --- a/plugin/src/main/resources/openaudiomc-build.properties +++ b/plugin/src/main/resources/openaudiomc-build.properties @@ -1,3 +1,3 @@ -BUILD_VERSION="1402" -BUILD_COMMIT="11331e565e9287a13f2938ac31f2a6c3fd857334" +BUILD_VERSION="1430" +BUILD_COMMIT="0f58745da86bedcc0dd4ec12109fa5c6fd3a5c8e" BUILD_AUTHOR="Mats" diff --git a/plugin/src/main/resources/plugin.yml b/plugin/src/main/resources/plugin.yml index 9887b5eb5..215cc55d1 100644 --- a/plugin/src/main/resources/plugin.yml +++ b/plugin/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: OpenAudioMc -version: 6.10.0 +version: 6.10.1 softdepend: [WorldGuard, Train_Carts, LiteBans, Essentials, PlaceholderAPI] main: com.craftmend.openaudiomc.spigot.OpenAudioMcSpigot api-version: 1.13 diff --git a/pom.xml b/pom.xml index 1aecd6e44..3fb9d3c8b 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ The OpenAudioMc Java plugin and Api UTF-8 - 6.10.0 + 6.10.1 1.18.30 @@ -26,7 +26,7 @@ 4.7.0 3.0.1 e1f961b - 2.12.0 + 2.12.4 b23a51825e