Merge pull request #97 from Athar42/main

Update for 1.21.6 - 1.21.7
This commit is contained in:
Navoei
2025-07-03 00:21:50 -05:00
committed by GitHub
5 changed files with 60 additions and 42 deletions

View File

@@ -1,12 +1,17 @@
plugins {
id 'java'
id "com.gradleup.shadow" version "8.3.5"
id "com.gradleup.shadow" version "8.3.6"
}
sourceCompatibility = JavaLanguageVersion.of(java_version as int)
targetCompatibility = JavaLanguageVersion.of(java_version as int)
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
base {
archivesName = archives_base_name
}
archivesBaseName = archives_base_name
version = plugin_version
group = maven_group
@@ -39,13 +44,16 @@ dependencies {
implementation "io.papermc.paper:paper-api:${bukkit_version}"
implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}"
shadow "dev.jorel:commandapi-bukkit-shade:${command_api_version}"
// Next two are for testing of an upcoming CommandAPI change - Not yet available.
//shadow "dev.jorel:commandapi-paper-shade:${command_api_version}"
//shadow "dev.jorel:commandapi-paper-shade-mojang-mapped:${command_api_version}"
compileOnly group: "com.comphenix.protocol", name: "ProtocolLib", version: "5.3.0";
compileOnly group: "com.comphenix.protocol", name: "ProtocolLib", version: "5.3.0"
}
repositories {
mavenCentral()
maven { url "https://repo.dmulloy2.net/repository/public/" }
maven { url = "https://repo.dmulloy2.net/repository/public/" }
maven {
name = "henkelmax.public"
url = 'https://maven.maxhenkel.de/repository/public'
@@ -55,7 +63,6 @@ repositories {
name = "papermc"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven { url "https://repo.dmulloy2.net/repository/public/" }
maven { url = "https://repo.codemc.org/repository/maven-public/" }
mavenLocal()

View File

@@ -5,13 +5,13 @@ java_version=21
mp3spi_version=1.9.5.4
bukkit_api_version=1.21
bukkit_version=1.21.5-R0.1-SNAPSHOT
bukkit_version=1.21.7-R0.1-SNAPSHOT
mod_id=customdiscsplugin
# Target an older API to make it compatible with older versions of Simple Voice Chat
voicechat_api_version=2.3.3
command_api_version=10.0.1
command_api_version=10.1.1
plugin_version=4.4
plugin_version=4.5
maven_group=me.Navoei.customdiscsplugin
archives_base_name=custom-discs

View File

@@ -1,6 +1,6 @@
#Sun Aug 11 17:52:06 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,4 +1,4 @@
# Custom Discs v4.4 for Paper 1.21.5
# Custom Discs v4.5 for Paper 1.21.6 and 1.21.7
A Paper fork of henkelmax's Audio Player. Special thanks to Athar42 for maintaining this plugin.
- Play custom music discs using the Simple Voice Chat API. (The voice chat mod is required on the client and server.)
@@ -21,7 +21,7 @@ Permission Nodes (Required to run the commands. Playing discs does not require a
- ```customdiscs.range``` to set the range of the disc
Dependencies:
- This plugin depends on the latest version of ProtocolLib for 1.21.5 and SimpleVoiceChatBukkit version 2.5.30.
- This plugin depends on the latest version of ProtocolLib available for your Paper version and SimpleVoiceChatBukkit (2.5.33 is recommended).
https://user-images.githubusercontent.com/64107368/178426026-c454ac66-5133-4f3a-9af9-7f674e022423.mp4

View File

@@ -16,7 +16,10 @@ import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.nio.file.Path;
import java.util.Objects;
@@ -45,16 +48,20 @@ public class DownloadSubCommand extends CommandAPICommand {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
URL fileURL = new URL(Objects.requireNonNull(arguments.getByClass("url", String.class)));
try {
URI uri = new URI(Objects.requireNonNull(arguments.getByClass("url", String.class)));
URL fileURL = uri.toURL();
String filename = Objects.requireNonNull(arguments.getByClass("filename", String.class));
if (filename.contains("../")) {
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FILENAME.toString()));
return;
}
System.out.println(filename);
//DEBUG
//System.out.println(filename);
if (!getFileExtension(filename).equals("wav") && !getFileExtension(filename).equals("mp3") && !getFileExtension(filename).equals("flac")) {
String fileExtension = getFileExtension(filename);
if (!fileExtension.equals("wav") && !fileExtension.equals("mp3") && !fileExtension.equals("flac")) {
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FORMAT.toString()));
return;
}
@@ -71,11 +78,15 @@ public class DownloadSubCommand extends CommandAPICommand {
}
Path downloadPath = Path.of(this.plugin.getDataFolder().getPath(), "musicdata", filename);
File downloadFile = new File(downloadPath.toUri());
File downloadFile = downloadPath.toFile();
FileUtils.copyURLToFile(fileURL, downloadFile);
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.SUCCESSFUL_DOWNLOAD.toString().replace("%file_path%", "plugins/CustomDiscs/musicdata/" + filename)));
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_DISC.toString().replace("%filename%", filename)));
} catch (URISyntaxException | MalformedURLException e) {
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.DOWNLOAD_ERROR.toString()));
e.printStackTrace();
}
} catch (IOException e) {
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.DOWNLOAD_ERROR.toString()));
e.printStackTrace();