Seemless Update Release

This commit is contained in:
Navoei
2022-08-28 15:02:22 -05:00
parent ad351a0ed6
commit 64c075ec55
6 changed files with 40 additions and 16 deletions

View File

@@ -11,6 +11,6 @@ mod_id=customdiscsplugin
# Target an older API to make it compatible with older versions of Simple Voice Chat
voicechat_api_version=2.3.3
plugin_version=2.1.1
plugin_version=2.2
maven_group=me.Navoei.customdiscsplugin
archives_base_name=custom-discs

View File

@@ -212,6 +212,7 @@ public class HopperManager implements Listener {
if (blockState instanceof Jukebox) {
if (!PlayerManager.instance().isAudioPlayerPlaying(blockState.getLocation())) {
itemJukeboxToHopper(blockState.getBlock());
getNextDiscFromHopperIntoJukebox(blockState.getBlock());
}
}
}

View File

@@ -6,14 +6,17 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class CommandManager implements CommandExecutor {
public class CommandManager implements CommandExecutor, TabCompleter {
private ArrayList<SubCommand> subCommands = new ArrayList<>();
private final ArrayList<SubCommand> subCommands = new ArrayList<>();
public CommandManager() {
subCommands.add(new CreateCommand());
@@ -37,17 +40,31 @@ public class CommandManager implements CommandExecutor {
}
}
} else {
player.sendMessage(ChatColor.AQUA + "---[ Custom Discs ]---");
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(ChatColor.AQUA + "----------------------");
player.sendMessage(ChatColor.AQUA + "---------------------");
return true;
}
return false;
return true;
}
public ArrayList<SubCommand> getSubCommands() {
return subCommands;
}
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length == 1) {
List<String> arguments = new ArrayList<>();
for (int i = 0; i < getSubCommands().size(); i++) {
arguments.add(getSubCommands().get(i).getName());
}
return arguments;
}
return null;
}
}

View File

@@ -36,6 +36,11 @@ public class ConvertCommand extends SubCommand {
@Override
public void perform(Player player, String[] args) {
if (!player.hasPermission("customdiscs.convert")) {
player.sendMessage(ChatColor.RED + "You do not have permission to execute this command!");
return;
}
if (isOldCustomMusicDisc(player.getInventory().getItemInMainHand())) {
ItemMeta customDiscMeta = player.getInventory().getItemInMainHand().getItemMeta();
@@ -54,6 +59,8 @@ public class ConvertCommand extends SubCommand {
player.getInventory().getItemInMainHand().setItemMeta(customDiscMeta);
player.sendMessage(ChatColor.GREEN + "The new format has been applied.");
} else {
player.sendMessage(ChatColor.RED + "The new format could not be applied.");
}

View File

@@ -43,7 +43,13 @@ public class CreateCommand extends SubCommand {
if (isMusicDisc(player)) {
if (args.length == 3) {
if (!player.hasPermission("customdiscs.create")) {
player.sendMessage(ChatColor.RED + "You do not have permission to execute this command!");
return;
}
// /cd create test.mp3 "test"
// [0] [1] [2]
//Find file, if file not there then say "file not there"
String songname = "";
String filename = args[1];
@@ -88,7 +94,7 @@ public class CreateCommand extends SubCommand {
player.sendMessage("Your filename is: " + ChatColor.GRAY + songname);
player.sendMessage("Your custom name is: " + ChatColor.GRAY + customName(readQuotes(args)));
} else if (args.length <= 3) {
} else if (args.length < 3) {
player.sendMessage(ChatColor.RED + "Insufficient arguments! ( /customdisc create <filename> \"Custom Lore\" )");
} else {
player.sendMessage(ChatColor.RED + "Too many arguments! ( /customdisc create <filename> \"Custom Lore\" )");
@@ -152,7 +158,7 @@ public class CreateCommand extends SubCommand {
private boolean isMusicDisc(Player p) {
if ( p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_13) ||
return p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_13) ||
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_CAT) ||
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_BLOCKS) ||
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_CHIRP) ||
@@ -166,13 +172,7 @@ public class CreateCommand extends SubCommand {
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_WAIT) ||
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_OTHERSIDE) ||
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_5) ||
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_PIGSTEP)
)
{
return true;
}
return false;
p.getInventory().getItemInMainHand().getType().equals(Material.MUSIC_DISC_PIGSTEP);
}
}

View File

@@ -9,6 +9,5 @@ depend: [ voicechat, ProtocolLib ]
commands:
customdisc:
permission: customdiscs.command
description: The custom discs command.
aliases: cd