mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-10 13:30:24 +05:00
Added Prefixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package me.Navoei.customdiscsplugin;
|
||||
|
||||
import me.Navoei.customdiscsplugin.language.Lang;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@@ -40,9 +41,10 @@ public class HopperManager implements Listener {
|
||||
|
||||
Component songNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(0).asComponent();
|
||||
String songName = PlainTextComponentSerializer.plainText().serialize(songNameComponent);
|
||||
|
||||
String content = Lang.NOW_PLAYING.toString().replace("%song_name%", songName);
|
||||
|
||||
TextComponent customActionBarSongPlaying = Component.text()
|
||||
.content("Now Playing: " + songName)
|
||||
.content(content)
|
||||
.color(NamedTextColor.GOLD)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class CreateCommand extends SubCommand {
|
||||
if (args.length >= 3) {
|
||||
|
||||
if (!player.hasPermission("customdiscs.create")) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NO_PERMISSION.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NO_PERMISSION.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
@@ -57,13 +57,13 @@ public class CreateCommand extends SubCommand {
|
||||
String song_name = "";
|
||||
String filename = args[1];
|
||||
if (filename.contains("../")) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.INVALID_FILENAME.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FILENAME.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (customName(readQuotes(args)).equalsIgnoreCase("")) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NO_DISC_NAME_PROVIDED.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NO_DISC_NAME_PROVIDED.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
@@ -74,12 +74,12 @@ public class CreateCommand extends SubCommand {
|
||||
if (getFileExtension(filename).equals("wav") || getFileExtension(filename).equals("mp3") || getFileExtension(filename).equals("flac")) {
|
||||
song_name = args[1];
|
||||
} else {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.INVALID_FORMAT.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FORMAT.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.FILE_NOT_FOUND.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.FILE_NOT_FOUND.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
@@ -102,16 +102,16 @@ public class CreateCommand extends SubCommand {
|
||||
|
||||
player.getInventory().getItemInMainHand().setItemMeta(meta);
|
||||
|
||||
Component textComponentFileName = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.CREATE_FILENAME.toString().replace("%filename%", song_name));
|
||||
Component textComponentCustomName = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.CREATE_CUSTOM_NAME.toString().replace("%custom_name%", customName(readQuotes(args))));
|
||||
Component textComponentFileName = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_FILENAME.toString().replace("%filename%", song_name));
|
||||
Component textComponentCustomName = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_CUSTOM_NAME.toString().replace("%custom_name%", customName(readQuotes(args))));
|
||||
player.sendMessage(textComponentFileName);
|
||||
player.sendMessage(textComponentCustomName);
|
||||
} else {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.INVALID_ARGUMENTS.toString().replace("%command_syntax", getSyntax()));
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_ARGUMENTS.toString().replace("%command_syntax", getSyntax()));
|
||||
player.sendMessage(textComponent);
|
||||
}
|
||||
} else {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NOT_HOLDING_DISC.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NOT_HOLDING_DISC.toString());
|
||||
player.sendMessage(textComponent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ public class DownloadCommand extends SubCommand {
|
||||
// [0] [1] [2]
|
||||
|
||||
if (!player.hasPermission("customdiscs.download")) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.NO_PERMISSION.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NO_PERMISSION.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length!=3) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.INVALID_ARGUMENTS.toString().replace("%command_syntax", getSyntax()));
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_ARGUMENTS.toString().replace("%command_syntax", getSyntax()));
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class DownloadCommand extends SubCommand {
|
||||
URL fileURL = new URL(args[1]);
|
||||
String filename = args[2];
|
||||
if (filename.contains("../")) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.INVALID_FILENAME.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FILENAME.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
@@ -65,12 +65,12 @@ public class DownloadCommand extends SubCommand {
|
||||
System.out.println(filename);
|
||||
|
||||
if (!getFileExtension(filename).equals("wav") && !getFileExtension(filename).equals("mp3") && !getFileExtension(filename).equals("flac")) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.INVALID_FORMAT.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.INVALID_FORMAT.toString());
|
||||
player.sendMessage(textComponent);
|
||||
return;
|
||||
}
|
||||
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.DOWNLOADING_FILE.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.DOWNLOADING_FILE.toString());
|
||||
player.sendMessage(textComponent);
|
||||
Path downloadPath = Path.of(customDiscs.getDataFolder().getPath(), "musicdata", filename);
|
||||
File downloadFile = new File(downloadPath.toUri());
|
||||
@@ -80,7 +80,7 @@ public class DownloadCommand extends SubCommand {
|
||||
if (connection != null) {
|
||||
long size = connection.getContentLengthLong() / 1048576;
|
||||
if (size > customDiscs.getConfig().getInt("max-download-size", 50)) {
|
||||
Component textComponent2 = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.FILE_TOO_LARGE.toString().replace("%max_download_size%", String.valueOf(customDiscs.getConfig().getInt("max-download-size", 50))));
|
||||
Component textComponent2 = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.FILE_TOO_LARGE.toString().replace("%max_download_size%", String.valueOf(customDiscs.getConfig().getInt("max-download-size", 50))));
|
||||
player.sendMessage(textComponent2);
|
||||
return;
|
||||
}
|
||||
@@ -88,13 +88,13 @@ public class DownloadCommand extends SubCommand {
|
||||
|
||||
FileUtils.copyURLToFile(fileURL, downloadFile);
|
||||
|
||||
Component fileDownloaded = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.SUCCESSFUL_DOWNLOAD.toString().replace("%file_path%", "plugins/CustomDiscs/musicdata/" + filename));
|
||||
Component createDisc = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.CREATE_DISC.toString().replace("%filename%", filename));
|
||||
Component fileDownloaded = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.SUCCESSFUL_DOWNLOAD.toString().replace("%file_path%", "plugins/CustomDiscs/musicdata/" + filename));
|
||||
Component createDisc = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.CREATE_DISC.toString().replace("%filename%", filename));
|
||||
|
||||
player.sendMessage(fileDownloaded);
|
||||
player.sendMessage(createDisc);
|
||||
} catch (IOException e) {
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.DOWNLOAD_ERROR.toString());
|
||||
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.DOWNLOAD_ERROR.toString());
|
||||
player.sendMessage(textComponent);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user