mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 05:19:43 +05:00
Add range disc + fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'io.github.goooler.shadow' version '8.1.7'
|
id "com.gradleup.shadow" version "8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaLanguageVersion.of(java_version as int)
|
sourceCompatibility = JavaLanguageVersion.of(java_version as int)
|
||||||
@@ -62,7 +62,7 @@ repositories {
|
|||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
configurations = [project.configurations.shadow]
|
configurations = [project.configurations.shadow]
|
||||||
archiveClassifier.set("shadow-dev")
|
archiveClassifier.set("dev")
|
||||||
|
|
||||||
//relocate 'javazoom', "me.navoei.${mod_id}.javazoom"
|
//relocate 'javazoom', "me.navoei.${mod_id}.javazoom"
|
||||||
//relocate 'org.tritonus', "me.navoei.${mod_id}.tritonus"
|
//relocate 'org.tritonus', "me.navoei.${mod_id}.tritonus"
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ mod_id=customdiscsplugin
|
|||||||
|
|
||||||
# Target an older API to make it compatible with older versions of Simple Voice Chat
|
# Target an older API to make it compatible with older versions of Simple Voice Chat
|
||||||
voicechat_api_version=2.5.0
|
voicechat_api_version=2.5.0
|
||||||
command_api_version=9.5.2
|
command_api_version=9.5.3
|
||||||
|
|
||||||
plugin_version=3.0
|
plugin_version=3.1
|
||||||
maven_group=me.Navoei.customdiscsplugin
|
maven_group=me.Navoei.customdiscsplugin
|
||||||
archives_base_name=custom-discs
|
archives_base_name=custom-discs
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Sun Aug 11 17:52:06 EDT 2024
|
#Sun Aug 11 17:52:06 EDT 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
13
readme.md
13
readme.md
@@ -1,4 +1,4 @@
|
|||||||
# Custom Discs v3.0 for Paper 1.21
|
# Custom Discs v3.1 for Paper 1.21
|
||||||
|
|
||||||
A Paper fork of henkelmax's Audio Player.
|
A Paper fork of henkelmax's Audio Player.
|
||||||
- Play custom music discs using the Simple Voice Chat API. (The voice chat mod is required on the client and server.)
|
- Play custom music discs using the Simple Voice Chat API. (The voice chat mod is required on the client and server.)
|
||||||
@@ -11,9 +11,14 @@ Downloading Files:
|
|||||||
- Example: ```/cd download https://example.com/mysong mysong.mp3```
|
- Example: ```/cd download https://example.com/mysong mysong.mp3```
|
||||||
- Direct Google Drive links: https://lonedev6.github.io/gddl/
|
- Direct Google Drive links: https://lonedev6.github.io/gddl/
|
||||||
|
|
||||||
|
Set the range of a disc:
|
||||||
|
- To set the active range of a playable disc, just use the command ```/cd range <range>``` where <range> is between 1 and the max value set in the config file (default : 256)
|
||||||
|
- Example: ```/cd range 100```
|
||||||
|
|
||||||
Permission Nodes (Required to run the commands. Playing discs does not require a permission.):
|
Permission Nodes (Required to run the commands. Playing discs does not require a permission.):
|
||||||
- ```customdiscs.create``` to create a disc
|
- ```customdiscs.create``` to create a disc
|
||||||
- ```customdiscs.download``` to download a file
|
- ```customdiscs.download``` to download a file
|
||||||
|
- ```customdiscs.range``` to set the range of the disc
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
- This plugin depends on the latest version of ProtocolLib for 1.21 and SimpleVoiceChatBukkit version 2.5.16.
|
- This plugin depends on the latest version of ProtocolLib for 1.21 and SimpleVoiceChatBukkit version 2.5.16.
|
||||||
@@ -28,6 +33,9 @@ Default Config.yml:
|
|||||||
# The distance from which music discs can be heard in blocks.
|
# The distance from which music discs can be heard in blocks.
|
||||||
music-disc-distance: 16
|
music-disc-distance: 16
|
||||||
|
|
||||||
|
# The max distance from which music discs can be heard in blocks.
|
||||||
|
music-disc-max-distance: 256
|
||||||
|
|
||||||
# The master volume of music discs from 0-1. (You can set values like 0.5 for 50% volume).
|
# The master volume of music discs from 0-1. (You can set values like 0.5 for 50% volume).
|
||||||
music-disc-volume: 1
|
music-disc-volume: 1
|
||||||
|
|
||||||
@@ -38,6 +46,7 @@ max-download-size: 50
|
|||||||
help:
|
help:
|
||||||
- "&8-[&6CustomDiscs Help Page&8]-"
|
- "&8-[&6CustomDiscs Help Page&8]-"
|
||||||
- "&aAuthor&7: &6Navoei"
|
- "&aAuthor&7: &6Navoei"
|
||||||
|
- "&aContributors&7: &6alfw / &6Athar42"
|
||||||
- "&fGit&0Hub&7: &9&ohttps://github.com/Navoei/CustomDiscs"
|
- "&fGit&0Hub&7: &9&ohttps://github.com/Navoei/CustomDiscs"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -60,6 +69,8 @@ create-disc: "&aCreate a disc by doing &7/cd create %filename% \"Custom Lore\"&a
|
|||||||
download-error: "&cAn error has occurred while downloading."
|
download-error: "&cAn error has occurred while downloading."
|
||||||
now-playing: "&6Now playing: %song_name%"
|
now-playing: "&6Now playing: %song_name%"
|
||||||
disc-converted: "&aConverted disc to new format! &fThis is due to changes in newer Minecraft versions which introduced &7JukeboxPlayableComponent&f."
|
disc-converted: "&aConverted disc to new format! &fThis is due to changes in newer Minecraft versions which introduced &7JukeboxPlayableComponent&f."
|
||||||
|
invalid-range: "&cYou need to chose a range between 1 and %range_value%"
|
||||||
|
create-custom-range: "&7Your range is set to: &a\"%custom_range%\"."
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import me.Navoei.customdiscsplugin.event.JukeBox;
|
|||||||
import me.Navoei.customdiscsplugin.language.Lang;
|
import me.Navoei.customdiscsplugin.language.Lang;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.Jukebox;
|
import org.bukkit.block.Jukebox;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@@ -34,6 +35,7 @@ public final class CustomDiscs extends JavaPlugin {
|
|||||||
public static YamlConfiguration LANG;
|
public static YamlConfiguration LANG;
|
||||||
public static File LANG_FILE;
|
public static File LANG_FILE;
|
||||||
public float musicDiscDistance;
|
public float musicDiscDistance;
|
||||||
|
public float musicDiscMaxDistance;
|
||||||
public float musicDiscVolume;
|
public float musicDiscVolume;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -71,6 +73,7 @@ public final class CustomDiscs extends JavaPlugin {
|
|||||||
getServer().getPluginManager().registerEvents(new HopperManager(), this);
|
getServer().getPluginManager().registerEvents(new HopperManager(), this);
|
||||||
|
|
||||||
musicDiscDistance = getConfig().getInt("music-disc-distance");
|
musicDiscDistance = getConfig().getInt("music-disc-distance");
|
||||||
|
musicDiscMaxDistance = getConfig().getInt("music-disc-max-distance");
|
||||||
musicDiscVolume = Float.parseFloat(Objects.requireNonNull(getConfig().getString("music-disc-volume")));
|
musicDiscVolume = Float.parseFloat(Objects.requireNonNull(getConfig().getString("music-disc-volume")));
|
||||||
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
@@ -110,7 +113,11 @@ public final class CustomDiscs extends JavaPlugin {
|
|||||||
public static CustomDiscs getInstance() {
|
public static CustomDiscs getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMusicDisc(Player p) {
|
||||||
|
return p.getInventory().getItemInMainHand().getType().toString().contains("MUSIC_DISC");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the lang.yml file.
|
* Load the lang.yml file.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.components.JukeboxPlayableComponent;
|
import org.bukkit.inventory.meta.components.JukeboxPlayableComponent;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
@@ -43,6 +44,15 @@ public class HopperManager implements Listener {
|
|||||||
|
|
||||||
ItemMeta discMeta = event.getItem().getItemMeta();
|
ItemMeta discMeta = event.getItem().getItemMeta();
|
||||||
String soundFileName = discMeta.getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
String soundFileName = discMeta.getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
||||||
|
|
||||||
|
PersistentDataContainer persistentDataContainer = event.getItem().getItemMeta().getPersistentDataContainer();
|
||||||
|
float range = CustomDiscs.getInstance().musicDiscDistance;
|
||||||
|
NamespacedKey customSoundRangeKey = new NamespacedKey(customDiscs, "customsoundrange");
|
||||||
|
|
||||||
|
if(persistentDataContainer.has(customSoundRangeKey, PersistentDataType.FLOAT)) {
|
||||||
|
range = Math.min(persistentDataContainer.get(customSoundRangeKey, PersistentDataType.FLOAT), CustomDiscs.getInstance().musicDiscMaxDistance);
|
||||||
|
}
|
||||||
|
|
||||||
if (discMeta.getJukeboxPlayable().isShowInTooltip()) {
|
if (discMeta.getJukeboxPlayable().isShowInTooltip()) {
|
||||||
JukeboxPlayableComponent jpc = discMeta.getJukeboxPlayable();
|
JukeboxPlayableComponent jpc = discMeta.getJukeboxPlayable();
|
||||||
jpc.setShowInTooltip(false);
|
jpc.setShowInTooltip(false);
|
||||||
@@ -52,7 +62,7 @@ public class HopperManager implements Listener {
|
|||||||
|
|
||||||
Path soundFilePath = Path.of(customDiscs.getDataFolder().getPath(), "musicdata", soundFileName);
|
Path soundFilePath = Path.of(customDiscs.getDataFolder().getPath(), "musicdata", soundFileName);
|
||||||
assert VoicePlugin.voicechatServerApi != null;
|
assert VoicePlugin.voicechatServerApi != null;
|
||||||
playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, event.getDestination().getLocation().getBlock(), customActionBarSongPlaying);
|
playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, event.getDestination().getLocation().getBlock(), customActionBarSongPlaying, range);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import de.maxhenkel.voicechat.api.audiochannel.LocationalAudioChannel;
|
|||||||
import javazoom.spi.mpeg.sampled.convert.MpegFormatConversionProvider;
|
import javazoom.spi.mpeg.sampled.convert.MpegFormatConversionProvider;
|
||||||
import javazoom.spi.mpeg.sampled.file.MpegAudioFileReader;
|
import javazoom.spi.mpeg.sampled.file.MpegAudioFileReader;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -44,7 +44,7 @@ public class PlayerManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playLocationalAudio(VoicechatServerApi api, Path soundFilePath, Block block, Component actionbarComponent) {
|
public void playLocationalAudio(VoicechatServerApi api, Path soundFilePath, Block block, Component actionbarComponent, float range) {
|
||||||
UUID id = UUID.nameUUIDFromBytes(block.getLocation().toString().getBytes());
|
UUID id = UUID.nameUUIDFromBytes(block.getLocation().toString().getBytes());
|
||||||
|
|
||||||
LocationalAudioChannel audioChannel = api.createLocationalAudioChannel(id, api.fromServerLevel(block.getWorld()), api.createPosition(block.getLocation().getX() + 0.5d, block.getLocation().getY() + 0.5d, block.getLocation().getZ() + 0.5d));
|
LocationalAudioChannel audioChannel = api.createLocationalAudioChannel(id, api.fromServerLevel(block.getWorld()), api.createPosition(block.getLocation().getX() + 0.5d, block.getLocation().getY() + 0.5d, block.getLocation().getZ() + 0.5d));
|
||||||
@@ -52,7 +52,7 @@ public class PlayerManager {
|
|||||||
if (audioChannel == null) return;
|
if (audioChannel == null) return;
|
||||||
|
|
||||||
audioChannel.setCategory(VoicePlugin.MUSIC_DISC_CATEGORY);
|
audioChannel.setCategory(VoicePlugin.MUSIC_DISC_CATEGORY);
|
||||||
audioChannel.setDistance(CustomDiscs.getInstance().musicDiscDistance);
|
audioChannel.setDistance(range);
|
||||||
|
|
||||||
AtomicBoolean stopped = new AtomicBoolean();
|
AtomicBoolean stopped = new AtomicBoolean();
|
||||||
AtomicReference<de.maxhenkel.voicechat.api.audiochannel.AudioPlayer> player = new AtomicReference<>();
|
AtomicReference<de.maxhenkel.voicechat.api.audiochannel.AudioPlayer> player = new AtomicReference<>();
|
||||||
@@ -68,7 +68,7 @@ public class PlayerManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
executorService.execute(() -> {
|
executorService.execute(() -> {
|
||||||
Collection<ServerPlayer> playersInRange = api.getPlayersInRange(api.fromServerLevel(block.getWorld()), api.createPosition(block.getLocation().getX() + 0.5d, block.getLocation().getY() + 0.5d, block.getLocation().getZ() + 0.5d), CustomDiscs.getInstance().musicDiscDistance);
|
Collection<ServerPlayer> playersInRange = api.getPlayersInRange(api.fromServerLevel(block.getWorld()), api.createPosition(block.getLocation().getX() + 0.5d, block.getLocation().getY() + 0.5d, block.getLocation().getZ() + 0.5d), range);
|
||||||
|
|
||||||
de.maxhenkel.voicechat.api.audiochannel.AudioPlayer audioPlayer = playChannel(api, audioChannel, block, soundFilePath, playersInRange);
|
de.maxhenkel.voicechat.api.audiochannel.AudioPlayer audioPlayer = playChannel(api, audioChannel, block, soundFilePath, playersInRange);
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ public class PlayerManager {
|
|||||||
Bukkit.getLogger().info("Error Occurred At: " + block.getLocation());
|
Bukkit.getLogger().info("Error Occurred At: " + block.getLocation());
|
||||||
for (ServerPlayer serverPlayer : playersInRange) {
|
for (ServerPlayer serverPlayer : playersInRange) {
|
||||||
Player bukkitPlayer = (Player) serverPlayer.getPlayer();
|
Player bukkitPlayer = (Player) serverPlayer.getPlayer();
|
||||||
bukkitPlayer.sendMessage(ChatColor.RED + "An error has occurred while trying to play this disc.");
|
bukkitPlayer.sendMessage(NamedTextColor.RED + "An error has occurred while trying to play this disc.");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import dev.jorel.commandapi.executors.CommandArguments;
|
|||||||
import me.Navoei.customdiscsplugin.CustomDiscs;
|
import me.Navoei.customdiscsplugin.CustomDiscs;
|
||||||
import me.Navoei.customdiscsplugin.command.SubCommands.CreateSubCommand;
|
import me.Navoei.customdiscsplugin.command.SubCommands.CreateSubCommand;
|
||||||
import me.Navoei.customdiscsplugin.command.SubCommands.DownloadSubCommand;
|
import me.Navoei.customdiscsplugin.command.SubCommands.DownloadSubCommand;
|
||||||
|
import me.Navoei.customdiscsplugin.command.SubCommands.SetRangeSubCommand;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -23,6 +24,7 @@ public class CustomDiscCommand extends CommandAPICommand {
|
|||||||
|
|
||||||
this.withSubcommand(new CreateSubCommand(plugin));
|
this.withSubcommand(new CreateSubCommand(plugin));
|
||||||
this.withSubcommand(new DownloadSubCommand(plugin));
|
this.withSubcommand(new DownloadSubCommand(plugin));
|
||||||
|
this.withSubcommand(new SetRangeSubCommand(plugin));
|
||||||
|
|
||||||
this.executesPlayer(this::onCommandPlayer);
|
this.executesPlayer(this::onCommandPlayer);
|
||||||
this.executesConsole(this::onCommandConsole);
|
this.executesConsole(this::onCommandConsole);
|
||||||
@@ -38,7 +40,7 @@ public class CustomDiscCommand extends CommandAPICommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int onCommandConsole(ConsoleCommandSender executor, CommandArguments arguments) {
|
private int onCommandConsole(ConsoleCommandSender executor, CommandArguments arguments) {
|
||||||
executor.sendMessage(ChatColor.RED + "Only players can use this command!");
|
executor.sendMessage(NamedTextColor.RED + "Only players can use this command!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import net.kyori.adventure.text.TextComponent;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -36,7 +35,7 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
super("create");
|
super("create");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
this.withFullDescription(ChatColor.GRAY + "Creates a custom music disc.");
|
this.withFullDescription(NamedTextColor.GRAY + "Creates a custom music disc.");
|
||||||
this.withUsage("/customdisc create <filename> \"Custom Lore\"");
|
this.withUsage("/customdisc create <filename> \"Custom Lore\"");
|
||||||
|
|
||||||
this.withArguments(new StringArgument("filename").replaceSuggestions(ArgumentSuggestions.stringCollection((sender) -> {
|
this.withArguments(new StringArgument("filename").replaceSuggestions(ArgumentSuggestions.stringCollection((sender) -> {
|
||||||
@@ -60,7 +59,7 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int onCommandPlayer(Player player, CommandArguments arguments) {
|
private int onCommandPlayer(Player player, CommandArguments arguments) {
|
||||||
if (!isMusicDisc(player)) {
|
if (!CustomDiscs.isMusicDisc(player)) {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_DISC.toString()));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_DISC.toString()));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -113,7 +112,7 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int onCommandConsole(ConsoleCommandSender executor, CommandArguments arguments) {
|
private int onCommandConsole(ConsoleCommandSender executor, CommandArguments arguments) {
|
||||||
executor.sendMessage(ChatColor.RED + "Only players can use this command!");
|
executor.sendMessage(NamedTextColor.RED + "Only players can use this command!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +124,4 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMusicDisc(Player p) {
|
|
||||||
return p.getInventory().getItemInMainHand().getType().toString().contains("MUSIC_DISC");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import dev.jorel.commandapi.executors.CommandArguments;
|
|||||||
import me.Navoei.customdiscsplugin.CustomDiscs;
|
import me.Navoei.customdiscsplugin.CustomDiscs;
|
||||||
import me.Navoei.customdiscsplugin.language.Lang;
|
import me.Navoei.customdiscsplugin.language.Lang;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
@@ -27,7 +27,7 @@ public class DownloadSubCommand extends CommandAPICommand {
|
|||||||
super("download");
|
super("download");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
this.withFullDescription(ChatColor.GRAY + "Downloads a file from a given URL.");
|
this.withFullDescription(NamedTextColor.GRAY + "Downloads a file from a given URL.");
|
||||||
this.withUsage("/customdisc download <url> <filename.extension>");
|
this.withUsage("/customdisc download <url> <filename.extension>");
|
||||||
|
|
||||||
this.withArguments(new TextArgument("url"));
|
this.withArguments(new TextArgument("url"));
|
||||||
@@ -86,7 +86,7 @@ public class DownloadSubCommand extends CommandAPICommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int onCommandConsole(ConsoleCommandSender executor, CommandArguments arguments) {
|
private int onCommandConsole(ConsoleCommandSender executor, CommandArguments arguments) {
|
||||||
executor.sendMessage(ChatColor.RED + "Only players can use this command!");
|
executor.sendMessage(NamedTextColor.RED + "Only players can use this command!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import net.kyori.adventure.text.TextComponent;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@@ -26,6 +25,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.components.JukeboxPlayableComponent;
|
import org.bukkit.inventory.meta.components.JukeboxPlayableComponent;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -51,6 +51,15 @@ public class JukeBox implements Listener{
|
|||||||
|
|
||||||
ItemMeta discMeta = event.getItem().getItemMeta();
|
ItemMeta discMeta = event.getItem().getItemMeta();
|
||||||
String soundFileName = discMeta.getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
String soundFileName = discMeta.getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
||||||
|
|
||||||
|
PersistentDataContainer persistentDataContainer = event.getItem().getItemMeta().getPersistentDataContainer();
|
||||||
|
float range = CustomDiscs.getInstance().musicDiscDistance;
|
||||||
|
NamespacedKey customSoundRangeKey = new NamespacedKey(customDiscs, "customsoundrange");
|
||||||
|
|
||||||
|
if(persistentDataContainer.has(customSoundRangeKey, PersistentDataType.FLOAT)) {
|
||||||
|
range = Math.min(persistentDataContainer.get(customSoundRangeKey, PersistentDataType.FLOAT), CustomDiscs.getInstance().musicDiscMaxDistance);
|
||||||
|
}
|
||||||
|
|
||||||
if (discMeta.getJukeboxPlayable().isShowInTooltip()) {
|
if (discMeta.getJukeboxPlayable().isShowInTooltip()) {
|
||||||
JukeboxPlayableComponent jpc = discMeta.getJukeboxPlayable();
|
JukeboxPlayableComponent jpc = discMeta.getJukeboxPlayable();
|
||||||
jpc.setShowInTooltip(false);
|
jpc.setShowInTooltip(false);
|
||||||
@@ -69,9 +78,9 @@ public class JukeBox implements Listener{
|
|||||||
Component customActionBarSongPlaying = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NOW_PLAYING.toString().replace("%song_name%", songName));
|
Component customActionBarSongPlaying = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NOW_PLAYING.toString().replace("%song_name%", songName));
|
||||||
|
|
||||||
assert VoicePlugin.voicechatServerApi != null;
|
assert VoicePlugin.voicechatServerApi != null;
|
||||||
playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, block, customActionBarSongPlaying);
|
playerManager.playLocationalAudio(VoicePlugin.voicechatServerApi, soundFilePath, block, customActionBarSongPlaying, range);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "Sound file not found.");
|
player.sendMessage(NamedTextColor.RED + "Sound file not found.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
throw new FileNotFoundException("Sound file is missing!");
|
throw new FileNotFoundException("Sound file is missing!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package me.Navoei.customdiscsplugin.language;
|
package me.Navoei.customdiscsplugin.language;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public enum Lang {
|
public enum Lang {
|
||||||
@@ -19,7 +18,9 @@ public enum Lang {
|
|||||||
CREATE_DISC("create-disc", "&aCreate a disc by doing &7/cd create filename.extension \"Custom Lore\"&a."),
|
CREATE_DISC("create-disc", "&aCreate a disc by doing &7/cd create filename.extension \"Custom Lore\"&a."),
|
||||||
DOWNLOAD_ERROR("download-error", "&rAn error has occurred while downloading."),
|
DOWNLOAD_ERROR("download-error", "&rAn error has occurred while downloading."),
|
||||||
NOW_PLAYING("now-playing","&6Now playing: %song_name%"),
|
NOW_PLAYING("now-playing","&6Now playing: %song_name%"),
|
||||||
DISC_CONVERTED("disc-converted", "&aConverted disc to new format! &fThis is due to changes in newer Minecraft versions which introduced &7JukeboxPlayableComponent&f.");
|
DISC_CONVERTED("disc-converted", "&aConverted disc to new format! &fThis is due to changes in newer Minecraft versions which introduced &7JukeboxPlayableComponent&f."),
|
||||||
|
INVALID_RANGE("invalid-range","&rYou need to chose a range between 1 and %range_value%"),
|
||||||
|
CREATE_CUSTOM_RANGE("create-custom-range", "&7Your range is set to: &a\"%custom_range%\".");
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
private final String def;
|
private final String def;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
# The distance from which music discs can be heard in blocks.
|
# The distance from which music discs can be heard in blocks.
|
||||||
music-disc-distance: 16
|
music-disc-distance: 16
|
||||||
|
|
||||||
|
# The max distance from which music discs can be heard in blocks.
|
||||||
|
music-disc-max-distance: 256
|
||||||
|
|
||||||
# The master volume of music discs from 0-1. (You can set values like 0.5 for 50% volume).
|
# The master volume of music discs from 0-1. (You can set values like 0.5 for 50% volume).
|
||||||
music-disc-volume: 1
|
music-disc-volume: 1
|
||||||
|
|
||||||
@@ -13,4 +16,5 @@ max-download-size: 50
|
|||||||
help:
|
help:
|
||||||
- "&8-[&6CustomDiscs Help Page&8]-"
|
- "&8-[&6CustomDiscs Help Page&8]-"
|
||||||
- "&aAuthor&7: &6Navoei"
|
- "&aAuthor&7: &6Navoei"
|
||||||
|
- "&aContributors&7: &6alfw / &6Athar42"
|
||||||
- "&fGit&0Hub&7: &9&ohttps://github.com/Navoei/CustomDiscs"
|
- "&fGit&0Hub&7: &9&ohttps://github.com/Navoei/CustomDiscs"
|
||||||
@@ -15,3 +15,5 @@ create-disc: "&aCreate a disc by doing &7/cd create %filename% \"Custom Lore\"&a
|
|||||||
download-error: "&cAn error has occurred while downloading."
|
download-error: "&cAn error has occurred while downloading."
|
||||||
now-playing: "&6Now playing: %song_name%"
|
now-playing: "&6Now playing: %song_name%"
|
||||||
disc-converted: "&aConverted disc to new format! &fThis is due to changes in newer Minecraft versions which introduced &7JukeboxPlayableComponent&f."
|
disc-converted: "&aConverted disc to new format! &fThis is due to changes in newer Minecraft versions which introduced &7JukeboxPlayableComponent&f."
|
||||||
|
invalid-range: "&cYou need to chose a range between 1 and %range_value%"
|
||||||
|
create-custom-range: "&7Your range is set to: &a\"%custom_range%\"."
|
||||||
|
|||||||
Reference in New Issue
Block a user