mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 13:30:24 +05:00
Seemless Update Request #6
This commit is contained in:
@@ -75,7 +75,7 @@ public final class CustomDiscs extends JavaPlugin {
|
||||
|
||||
if (!jukebox.getRecord().hasItemMeta()) return;
|
||||
|
||||
if (jukebox.getRecord().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(String.valueOf(this), "customdisc"), PersistentDataType.STRING)) {
|
||||
if (jukebox.getRecord().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(CustomDiscs.getInstance(), "customdisc"), PersistentDataType.STRING)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,7 @@ public class HopperManager implements Listener {
|
||||
hopper.getInventory().removeItem(event.getItem());
|
||||
}, 1L);
|
||||
|
||||
Component soundFileNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(1).asComponent();
|
||||
String soundFileName = PlainTextComponentSerializer.plainText().serialize(soundFileNameComponent);
|
||||
String soundFileName = event.getItem().getItemMeta().getPersistentDataContainer().get(new NamespacedKey(CustomDiscs.getInstance(), "customdisc"), PersistentDataType.STRING);
|
||||
|
||||
Path soundFilePath = Path.of(CustomDiscs.getInstance().getDataFolder().getPath(), "musicdata", soundFileName);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CommandManager implements CommandExecutor {
|
||||
} else {
|
||||
player.sendMessage(ChatColor.AQUA + "---[ Custom Discs ]---");
|
||||
for (int i = 0; i < getSubCommands().size(); i++) {
|
||||
player.sendMessage(getSubCommands().get(i).getSyntax() + ChatColor.DARK_GRAY + "-" + getSubCommands().get(i).getDescription());
|
||||
player.sendMessage(getSubCommands().get(i).getSyntax() + ChatColor.DARK_GRAY + " - " + getSubCommands().get(i).getDescription());
|
||||
}
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.List;
|
||||
|
||||
public class ConvertCommand extends SubCommand {
|
||||
|
||||
@@ -39,14 +39,17 @@ public class ConvertCommand extends SubCommand {
|
||||
if (isOldCustomMusicDisc(player.getInventory().getItemInMainHand())) {
|
||||
ItemMeta customDiscMeta = player.getInventory().getItemInMainHand().getItemMeta();
|
||||
|
||||
Component soundFileNameComponent = Objects.requireNonNull(customDiscMeta.lore()).get(1).asComponent();
|
||||
Component soundFileNameComponent = customDiscMeta.lore().get(1).asComponent();
|
||||
String soundFileName = PlainTextComponentSerializer.plainText().serialize(soundFileNameComponent);
|
||||
List<Component> songName = customDiscMeta.lore();
|
||||
|
||||
PersistentDataContainer data = customDiscMeta.getPersistentDataContainer();
|
||||
data.set(new NamespacedKey(CustomDiscs.getInstance(), "customdisc"), PersistentDataType.STRING, soundFileName);
|
||||
|
||||
customDiscMeta.lore().remove(1);
|
||||
customDiscMeta.removeItemFlags(ItemFlag.values());
|
||||
songName.remove(1);
|
||||
|
||||
customDiscMeta.lore(songName);
|
||||
|
||||
customDiscMeta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
|
||||
player.getInventory().getItemInMainHand().setItemMeta(customDiscMeta);
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
@@ -34,7 +35,7 @@ public class CreateCommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return ChatColor.GREEN + "/customdisc create <filename> \"Custom Lore\".";
|
||||
return ChatColor.GREEN + "/customdisc create <filename> \"Custom Lore\"";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +48,11 @@ public class CreateCommand extends SubCommand {
|
||||
String songname = "";
|
||||
String filename = args[1];
|
||||
|
||||
if (customName(readQuotes(args)).equalsIgnoreCase("")) {
|
||||
player.sendMessage(ChatColor.RED + "You must provide a name for your disc.");
|
||||
return;
|
||||
}
|
||||
|
||||
File getDirectory = new File(CustomDiscs.getInstance().getDataFolder(), "musicdata");
|
||||
File songFile = new File(getDirectory.getPath(), filename);
|
||||
if (songFile.exists()) {
|
||||
@@ -71,6 +77,7 @@ public class CreateCommand extends SubCommand {
|
||||
.color(NamedTextColor.GRAY)
|
||||
.build();
|
||||
itemLore.add(customLoreSong);
|
||||
meta.addItemFlags(ItemFlag.values());
|
||||
meta.lore(itemLore);
|
||||
|
||||
PersistentDataContainer data = meta.getPersistentDataContainer();
|
||||
|
||||
Reference in New Issue
Block a user