mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 05:19:43 +05:00
Prepare 5.0 release
This commit is contained in:
@@ -49,6 +49,7 @@ dependencies {
|
|||||||
//shadow "dev.jorel:commandapi-paper-shade-mojang-mapped:${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"
|
||||||
|
//compileOnly "com.github.retrooper:packetevents-spigot:2.9.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
package me.Navoei.customdiscsplugin;
|
package me.Navoei.customdiscsplugin;
|
||||||
|
|
||||||
import me.Navoei.customdiscsplugin.command.CustomDiscCommand;
|
|
||||||
import me.Navoei.customdiscsplugin.event.JukeBox;
|
|
||||||
import me.Navoei.customdiscsplugin.event.HeadPlay;
|
|
||||||
import me.Navoei.customdiscsplugin.event.HornPlay;
|
|
||||||
import me.Navoei.customdiscsplugin.language.Lang;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
@@ -13,6 +7,11 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import me.Navoei.customdiscsplugin.command.CustomDiscCommand;
|
||||||
|
import me.Navoei.customdiscsplugin.event.JukeBox;
|
||||||
|
import me.Navoei.customdiscsplugin.event.HeadPlay;
|
||||||
|
import me.Navoei.customdiscsplugin.event.HornPlay;
|
||||||
|
import me.Navoei.customdiscsplugin.language.Lang;
|
||||||
|
|
||||||
import de.maxhenkel.voicechat.api.BukkitVoicechatService;
|
import de.maxhenkel.voicechat.api.BukkitVoicechatService;
|
||||||
|
|
||||||
@@ -126,9 +125,7 @@ public final class CustomDiscs extends JavaPlugin {
|
|||||||
hornMaxCooldown = 1;
|
hornMaxCooldown = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
|
||||||
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.WORLD_EVENT) {
|
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.WORLD_EVENT) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
@@ -137,13 +134,13 @@ public final class CustomDiscs extends JavaPlugin {
|
|||||||
if (packet.getIntegers().read(0).toString().equals("1010")) {
|
if (packet.getIntegers().read(0).toString().equals("1010")) {
|
||||||
if (!isMusicDiscEnable()) { return; }
|
if (!isMusicDiscEnable()) { return; }
|
||||||
Jukebox jukebox = (Jukebox) packet.getBlockPositionModifier().read(0).toLocation(event.getPlayer().getWorld()).getBlock().getState();
|
Jukebox jukebox = (Jukebox) packet.getBlockPositionModifier().read(0).toLocation(event.getPlayer().getWorld()).getBlock().getState();
|
||||||
|
|
||||||
if (!jukebox.getRecord().hasItemMeta()) return;
|
if (!jukebox.getRecord().hasItemMeta()) return;
|
||||||
|
|
||||||
if (jukebox.getRecord().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(this.plugin, "customdisc"), PersistentDataType.STRING)) {
|
if (jukebox.getRecord().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(this.plugin, "customdisc"), PersistentDataType.STRING)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Start the jukebox state manager.
|
//Start the jukebox state manager.
|
||||||
//This keeps the jukebox powered while custom song is playing,
|
//This keeps the jukebox powered while custom song is playing,
|
||||||
//which perfectly emulates the vanilla behavior of discs.
|
//which perfectly emulates the vanilla behavior of discs.
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ package me.Navoei.customdiscsplugin;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Jukebox;
|
import org.bukkit.block.Jukebox;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class JukeboxStateManager {
|
public class JukeboxStateManager {
|
||||||
|
|
||||||
static CustomDiscs plugin = CustomDiscs.getInstance();
|
static CustomDiscs plugin = CustomDiscs.getInstance();
|
||||||
static PlayerManager playerManager = PlayerManager.instance();
|
static PlayerManager playerManager = PlayerManager.instance();
|
||||||
static List<Location> jukeboxLocations = new ArrayList<>();
|
static HashSet<Location> jukeboxLocations = new HashSet<>();
|
||||||
|
|
||||||
public static void start(Jukebox jukebox) {
|
public static void start(Jukebox jukebox) {
|
||||||
if (jukeboxLocations.contains(jukebox.getLocation()) || !playerManager.isAudioPlayerPlaying(jukebox.getLocation())) return;
|
if (jukeboxLocations.contains(jukebox.getLocation()) || !playerManager.isAudioPlayerPlaying(jukebox.getLocation())) return;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package me.Navoei.customdiscsplugin;
|
package me.Navoei.customdiscsplugin;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.MaterialTags;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@@ -14,7 +16,7 @@ public class TypeChecker {
|
|||||||
// MUSIC DISCS
|
// MUSIC DISCS
|
||||||
|
|
||||||
public static boolean isMusicDisc(ItemStack item) {
|
public static boolean isMusicDisc(ItemStack item) {
|
||||||
return item.getType().toString().contains("MUSIC_DISC");
|
return MaterialTags.MUSIC_DISCS.isTagged(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static boolean isMusicDiscPlayer(Player p) {
|
/*public static boolean isMusicDiscPlayer(Player p) {
|
||||||
@@ -24,7 +26,7 @@ public class TypeChecker {
|
|||||||
public static boolean isCustomMusicDisc(ItemStack itemStack) {
|
public static boolean isCustomMusicDisc(ItemStack itemStack) {
|
||||||
if (itemStack == null) return false;
|
if (itemStack == null) return false;
|
||||||
if (itemStack.getItemMeta() == null) return false;
|
if (itemStack.getItemMeta() == null) return false;
|
||||||
return itemStack.getType().toString().contains("MUSIC_DISC") && itemStack.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
return MaterialTags.MUSIC_DISCS.isTagged(itemStack.getType()) && itemStack.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static boolean isCustomMusicDiscPlayer(Player p) {
|
/*public static boolean isCustomMusicDiscPlayer(Player p) {
|
||||||
@@ -38,16 +40,16 @@ public class TypeChecker {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static boolean isGoatHornPlayer(Player p) {
|
public static boolean isGoatHornPlayer(Player p) {
|
||||||
return p.getInventory().getItemInMainHand().getType().toString().contains("GOAT_HORN");
|
return p.getInventory().getItemInMainHand().getType().equals(Material.GOAT_HORN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCustomGoatHorn(PlayerInteractEvent e) {
|
public static boolean isCustomGoatHorn(PlayerInteractEvent e) {
|
||||||
if (e.getItem()==null) return false;
|
if (e.getItem()==null) return false;
|
||||||
return e.getItem().getType().toString().contains("GOAT_HORN") && e.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customhorn"), PersistentDataType.STRING);
|
return e.getItem().getType().equals(Material.GOAT_HORN) && e.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customhorn"), PersistentDataType.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCustomGoatHornPlayer(Player p) {
|
public static boolean isCustomGoatHornPlayer(Player p) {
|
||||||
return p.getInventory().getItemInMainHand().getType().toString().contains("GOAT_HORN") && p.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customhorn"), PersistentDataType.STRING);
|
return p.getInventory().getItemInMainHand().getType().equals(Material.GOAT_HORN) && p.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customhorn"), PersistentDataType.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PLAYER HEADS
|
// PLAYER HEADS
|
||||||
@@ -57,7 +59,7 @@ public class TypeChecker {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static boolean isHeadPlayer(Player p) {
|
public static boolean isHeadPlayer(Player p) {
|
||||||
return p.getInventory().getItemInMainHand().getType().toString().contains("PLAYER_HEAD");
|
return p.getInventory().getItemInMainHand().getType().equals(Material.PLAYER_HEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static boolean isCustomHead(ItemStack itemStack) {
|
/*public static boolean isCustomHead(ItemStack itemStack) {
|
||||||
@@ -67,7 +69,7 @@ public class TypeChecker {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static boolean isCustomHeadPlayer(Player p) {
|
public static boolean isCustomHeadPlayer(Player p) {
|
||||||
return p.getInventory().getItemInMainHand().getType().toString().contains("PLAYER_HEAD") && p.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customhead"), PersistentDataType.STRING);
|
return p.getInventory().getItemInMainHand().getType().equals(Material.PLAYER_HEAD) && p.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customhead"), PersistentDataType.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -79,15 +79,13 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
|
|
||||||
if (!resultIsMusicDisc && !resultIsHorn && !resultIsHead) {
|
if (!resultIsMusicDisc && !resultIsHorn && !resultIsHead) {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_CORRECT_ITEM.toString()));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_CORRECT_ITEM.toString()));
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String filename = Objects.requireNonNull(arguments.getByClass("filename", String.class));
|
String filename = Objects.requireNonNull(arguments.getByClass("filename", String.class));
|
||||||
if (filename.contains("../")) {
|
if (filename.contains("../")) {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FILENAME.toString()));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FILENAME.toString()));
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
File getDirectory = new File(this.plugin.getDataFolder(), "musicdata");
|
File getDirectory = new File(this.plugin.getDataFolder(), "musicdata");
|
||||||
@@ -95,11 +93,11 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
if (songFile.exists()) {
|
if (songFile.exists()) {
|
||||||
if (!getFileExtension(filename).equals("wav") && !getFileExtension(filename).equals("mp3") && !getFileExtension(filename).equals("flac")) {
|
if (!getFileExtension(filename).equals("wav") && !getFileExtension(filename).equals("mp3") && !getFileExtension(filename).equals("flac")) {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FORMAT.toString()));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FORMAT.toString()));
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.FILE_NOT_FOUND.toString()));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.FILE_NOT_FOUND.toString()));
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
String song_name = Objects.requireNonNull(arguments.getByClass("song_name", String.class));
|
String song_name = Objects.requireNonNull(arguments.getByClass("song_name", String.class));
|
||||||
@@ -138,7 +136,8 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
PersistentDataContainer data = meta.getPersistentDataContainer();
|
PersistentDataContainer data = meta.getPersistentDataContainer();
|
||||||
data.set(new NamespacedKey(this.plugin, "customhorn"), PersistentDataType.STRING, filename);
|
data.set(new NamespacedKey(this.plugin, "customhorn"), PersistentDataType.STRING, filename);
|
||||||
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
||||||
} else if (resultIsHead) {
|
} else {
|
||||||
|
//Must be a player head.
|
||||||
if (!CustomDiscs.isCustomHeadEnable()) { player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CUSTOM_HEAD_DISABLED.toString())); return 1; }
|
if (!CustomDiscs.isCustomHeadEnable()) { player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CUSTOM_HEAD_DISABLED.toString())); return 1; }
|
||||||
final Component customLoreHead = Component.text().decoration(TextDecoration.ITALIC, false).content(song_name).color(NamedTextColor.GRAY).build();
|
final Component customLoreHead = Component.text().decoration(TextDecoration.ITALIC, false).content(song_name).color(NamedTextColor.GRAY).build();
|
||||||
String serialized = GsonComponentSerializer.gson().serialize(customLoreHead);
|
String serialized = GsonComponentSerializer.gson().serialize(customLoreHead);
|
||||||
@@ -154,10 +153,7 @@ public class CreateSubCommand extends CommandAPICommand {
|
|||||||
data.set(new NamespacedKey(this.plugin, "customhead"), PersistentDataType.STRING, filename);
|
data.set(new NamespacedKey(this.plugin, "customhead"), PersistentDataType.STRING, filename);
|
||||||
data.set(new NamespacedKey(this.plugin, "headlore"), PersistentDataType.STRING, serialized);
|
data.set(new NamespacedKey(this.plugin, "headlore"), PersistentDataType.STRING, serialized);
|
||||||
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_FILENAME.toString().replace("%filename%", filename)));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_FILENAME.toString().replace("%filename%", filename)));
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_CUSTOM_NAME.toString().replace("%custom_name%", song_name)));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_CUSTOM_NAME.toString().replace("%custom_name%", song_name)));
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.bukkit.persistence.PersistentDataContainer;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SetHornCooldownSubCommand extends CommandAPICommand {
|
public class SetHornCooldownSubCommand extends CommandAPICommand {
|
||||||
private final CustomDiscs plugin;
|
private final CustomDiscs plugin;
|
||||||
@@ -41,28 +42,28 @@ public class SetHornCooldownSubCommand extends CommandAPICommand {
|
|||||||
private int onCommandPlayer(Player player, CommandArguments arguments) {
|
private int onCommandPlayer(Player player, CommandArguments arguments) {
|
||||||
if (!TypeChecker.isCustomGoatHornPlayer(player)) {
|
if (!TypeChecker.isCustomGoatHornPlayer(player)) {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_MODIFIED_GOATHORN.toString()));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_MODIFIED_GOATHORN.toString()));
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TypeChecker.isCustomGoatHornPlayer(player)) {
|
if (TypeChecker.isCustomGoatHornPlayer(player)) {
|
||||||
if (!CustomDiscs.isMusicDiscEnable()) { player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CUSTOM_HORN_DISABLED.toString())); return 1; }
|
if (!CustomDiscs.isMusicDiscEnable()) { player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CUSTOM_HORN_DISABLED.toString())); return 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
int goatcooldown = Objects.requireNonNull(arguments.getByClass("goatcooldown", Integer.class));
|
int goatCooldown = Optional.ofNullable(arguments.getByClass("goatcooldown", Integer.class)).orElse(0);
|
||||||
|
|
||||||
if (goatcooldown <= 0 || goatcooldown > this.plugin.hornMaxCooldown) {
|
if (goatCooldown <= 0 || goatCooldown > this.plugin.hornMaxCooldown) {
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_COOLDOWN.toString().replace("%cooldown_value%", Integer.toString(this.plugin.hornMaxCooldown))));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_COOLDOWN.toString().replace("%cooldown_value%", Integer.toString(this.plugin.hornMaxCooldown))));
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack disc = new ItemStack(player.getInventory().getItemInMainHand());
|
ItemStack disc = new ItemStack(player.getInventory().getItemInMainHand());
|
||||||
ItemMeta meta = disc.getItemMeta();
|
ItemMeta meta = disc.getItemMeta();
|
||||||
PersistentDataContainer data = meta.getPersistentDataContainer();
|
PersistentDataContainer data = meta.getPersistentDataContainer();
|
||||||
|
|
||||||
data.set(new NamespacedKey(this.plugin, "customhorncoolodwn"), PersistentDataType.INTEGER, Math.min(goatcooldown, CustomDiscs.getInstance().hornMaxCooldown));
|
data.set(new NamespacedKey(this.plugin, "goat_horn_cooldown"), PersistentDataType.INTEGER, Math.min(goatCooldown, CustomDiscs.getInstance().hornMaxCooldown));
|
||||||
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
||||||
|
|
||||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_CUSTOM_GOAT_COOLDOWN.toString().replace("%custom_goat_cooldown%", Integer.toString(goatcooldown))));
|
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_CUSTOM_GOAT_COOLDOWN.toString().replace("%custom_goat_cooldown%", Integer.toString(goatCooldown))));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.bukkit.persistence.PersistentDataContainer;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class SetRangeSubCommand extends CommandAPICommand {
|
public class SetRangeSubCommand extends CommandAPICommand {
|
||||||
private final CustomDiscs plugin;
|
private final CustomDiscs plugin;
|
||||||
@@ -50,9 +51,9 @@ public class SetRangeSubCommand extends CommandAPICommand {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Float range = Objects.requireNonNull(arguments.getByClass("range", Float.class));
|
float range = Optional.ofNullable(arguments.getByClass("range", Float.class)).orElse(0f);
|
||||||
|
|
||||||
Float configMusicDiscMaxDistance;
|
float configMusicDiscMaxDistance;
|
||||||
if (resultIsCustomHorn) {
|
if (resultIsCustomHorn) {
|
||||||
if (!CustomDiscs.isCustomHornEnable()) { player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CUSTOM_HORN_DISABLED.toString())); return 1; }
|
if (!CustomDiscs.isCustomHornEnable()) { player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CUSTOM_HORN_DISABLED.toString())); return 1; }
|
||||||
configMusicDiscMaxDistance = this.plugin.customHornMaxDistance;
|
configMusicDiscMaxDistance = this.plugin.customHornMaxDistance;
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ public class HornPlay implements Listener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
int hornCooldown;
|
int hornCooldown;
|
||||||
NamespacedKey hornCooldownKey = new NamespacedKey(customDiscs, "customhorncoolodwn");
|
NamespacedKey hornCooldownKey = new NamespacedKey(customDiscs, "goat_horn_cooldown");
|
||||||
if(persistentDataContainer.has(hornCooldownKey, PersistentDataType.INTEGER)) {
|
if(persistentDataContainer.has(hornCooldownKey, PersistentDataType.INTEGER)) {
|
||||||
hornCooldown = Math.min(persistentDataContainer.get(hornCooldownKey, PersistentDataType.INTEGER), CustomDiscs.getInstance().hornMaxCooldown);
|
hornCooldown = Math.min(Optional.ofNullable(persistentDataContainer.get(hornCooldownKey, PersistentDataType.INTEGER)).orElse(0), CustomDiscs.getInstance().hornMaxCooldown);
|
||||||
} else {
|
} else {
|
||||||
hornCooldown = Math.min(CustomDiscs.getInstance().hornCooldown, CustomDiscs.getInstance().hornMaxCooldown);
|
hornCooldown = Math.min(CustomDiscs.getInstance().hornCooldown, CustomDiscs.getInstance().hornMaxCooldown);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ main: me.Navoei.customdiscsplugin.CustomDiscs
|
|||||||
api-version: '${bukkit_api_version}'
|
api-version: '${bukkit_api_version}'
|
||||||
prefix: CustomDiscs
|
prefix: CustomDiscs
|
||||||
authors: [ "Navoei", "Athar42", "alfw" ]
|
authors: [ "Navoei", "Athar42", "alfw" ]
|
||||||
description: A plugin which uses the Simple Voice Chat API to add custom music discs, goat horns and player's head.
|
description: A plugin which uses the Simple Voice Chat API to add custom music discs, goat horns and player heads.
|
||||||
depend: [ "voicechat", "ProtocolLib" ]
|
depend: [ "voicechat", "ProtocolLib" ]
|
||||||
dependencies:
|
dependencies:
|
||||||
server:
|
server:
|
||||||
|
|||||||
Reference in New Issue
Block a user