1.2.1 Update
This commit is contained in:
1 parent
e7e40197aa
commit
a64da4ac91
14 files changed
+186
-83
No files matched your search
@@ -40,11 +40,15 @@ In your issue report, please include as much information as possible including:
|
||||
|
||||
- Add a config option to change the currency symbol, and its placement.
|
||||
|
||||
- Uppercase color code support.
|
||||
|
||||
## Changelog:
|
||||
|
||||
1.2.0:
|
||||
**1.2.1:**
|
||||
|
||||
- Uppercase color code support.
|
||||
|
||||
- Fixed NullPointerException with unrecognized commands.
|
||||
|
||||
**1.2.0:**
|
||||
|
||||
- 1.19.4 Support.
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ java {
|
||||
}
|
||||
|
||||
group = "dev.mylesmor.sudosigns" // Declare bundle identifier.
|
||||
version = "1.2.0" // Declare plugin version (will be in .jar).
|
||||
version = "1.2.1" // Declare plugin version (will be in .jar).
|
||||
|
||||
def apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ public class Commands implements CommandExecutor {
|
||||
Map<String, BiConsumer<Player, String[]>> commands = new HashMap<>();
|
||||
|
||||
public Commands() {
|
||||
|
||||
commands.put("help", Help::help);
|
||||
commands.put("near", Near::near);
|
||||
commands.put("list", List::list);
|
||||
@@ -36,36 +37,68 @@ public class Commands implements CommandExecutor {
|
||||
commands.put("purge", Purge::purge);
|
||||
commands.put("confirmpurge", Purge::confirmPurge);
|
||||
commands.put("fix", Fix::fix);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if ((sender instanceof Player)) {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
|
||||
final Player p = (Player) sender;
|
||||
SudoSigns.users.computeIfAbsent(p.getUniqueId(), k -> new SudoUser(p));
|
||||
try {
|
||||
|
||||
BiConsumer<Player, String[]> command = commands.get(args[0].toLowerCase());
|
||||
if (args.length > 1) {
|
||||
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
command.accept(p, newArgs);
|
||||
|
||||
if(command != null) {
|
||||
|
||||
if (args.length > 1) {
|
||||
|
||||
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
command.accept(p, newArgs);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
try {
|
||||
|
||||
command.accept(p, null);
|
||||
|
||||
}
|
||||
catch(CommandException error) {
|
||||
|
||||
invalidCommandError(p);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
||||
command.accept(p, null);
|
||||
|
||||
}
|
||||
catch(CommandException error) {
|
||||
|
||||
Util.sudoSignsMessage(p, "&cERROR: Invalid command! &6Type &d/ss help &6for a list of valid commands.");
|
||||
|
||||
}
|
||||
|
||||
invalidCommandError(p);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
Util.sudoSignsMessage(p, "&cERROR: Invalid command! &6Type &d/ss help &6for a list of valid commands.");
|
||||
|
||||
invalidCommandError(p);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private void invalidCommandError(Player p) {
|
||||
|
||||
Util.sudoSignsMessage(p, "&cERROR: Invalid command! &6Type &d/ss help &6for a list of valid commands.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class ConfigManager {
|
||||
if (! signConfig.contains("version")) {
|
||||
|
||||
signConfig.createSection("version");
|
||||
signConfig.set("version", "1.2.0");
|
||||
signConfig.set("version", "1.2.1");
|
||||
|
||||
save();
|
||||
fixConfig();
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import dev.mylesmor.sudosigns.SudoSigns;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
|
||||
public class InvalidEntriesManager {
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public class InvalidEntriesManager {
|
||||
List<String> lines = getSignText(s);
|
||||
int i = 0;
|
||||
for (String line : lines) {
|
||||
newSign.line(i, LegacyComponentSerializer.legacyAmpersand().deserialize(line));
|
||||
newSign.line(i, Util.legacySerializerAnyCase(line));
|
||||
i++;
|
||||
}
|
||||
newSign.update();
|
||||
@@ -104,7 +104,7 @@ public class InvalidEntriesManager {
|
||||
public List<String> getSignText(String name) {
|
||||
List<String> signSec = config.getStringList("signs." + name + ".text");
|
||||
for (String item : signSec) {
|
||||
item = LegacyComponentSerializer.legacyAmpersand().deserialize(item).content();
|
||||
item = Util.legacySerializerAnyCase(item).content();
|
||||
}
|
||||
if (signSec.size() != 0) {
|
||||
return signSec;
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import dev.mylesmor.sudosigns.SudoSigns;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
@@ -102,7 +101,7 @@ public class SudoSign {
|
||||
String line = PlainTextComponentSerializer.plainText().serialize(sign.line(i));
|
||||
|
||||
text.add(line.replaceAll("§", "&"));
|
||||
sign.line(i, LegacyComponentSerializer.legacyAmpersand().deserialize(line));
|
||||
sign.line(i, Util.legacySerializerAnyCase(line));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import dev.mylesmor.sudosigns.data.SudoUser;
|
||||
import dev.mylesmor.sudosigns.menus.SignEditor;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
|
||||
|
||||
@@ -45,7 +44,7 @@ public class ChatListener implements Listener {
|
||||
user.removeTextInput();
|
||||
|
||||
}
|
||||
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
@@ -230,7 +229,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setText(LegacyComponentSerializer.legacyAmpersand().deserialize(PlainTextComponentSerializer.plainText().serialize(e.message()))), editor::goToMain);
|
||||
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setText(Util.legacySerializerAnyCase(PlainTextComponentSerializer.plainText().serialize(e.message()))), editor::goToMain);
|
||||
|
||||
break;
|
||||
case SET_PRICE:
|
||||
@@ -271,6 +270,7 @@ public class ChatListener implements Listener {
|
||||
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setPrice(finalPrice), editor::goToMain);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import dev.mylesmor.sudosigns.data.SudoUser;
|
||||
import dev.mylesmor.sudosigns.util.Permissions;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class CommandOptionsMenu {
|
||||
|
||||
@@ -77,10 +76,10 @@ public class CommandOptionsMenu {
|
||||
}
|
||||
|
||||
private void createCommandOptionsMenu() {
|
||||
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("Command options: /" + sc.getCommand());
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("Command options: /" + sc.getCommand());
|
||||
|
||||
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
for (int i = 0; i < menu.getSize(); i++) {
|
||||
@@ -93,21 +92,21 @@ public class CommandOptionsMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
ItemStack clock = new ItemStack(Material.CLOCK);
|
||||
ItemMeta clockMeta = clock.getItemMeta();
|
||||
|
||||
lore.add("&eChange the delay after which the command executes");
|
||||
clockMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dChange Delay"));
|
||||
clockMeta.displayName(Util.legacySerializerAnyCase("&r&dChange Delay"));
|
||||
clockMeta.lore(Util.convertToTextComponents(lore));
|
||||
clock.setItemMeta(clockMeta);
|
||||
|
||||
ItemStack barrier = new ItemStack(Material.BARRIER);
|
||||
ItemMeta barrierMeta = barrier.getItemMeta();
|
||||
|
||||
barrierMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&cDelete Command"));
|
||||
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&cDelete Command"));
|
||||
barrier.setItemMeta(barrierMeta);
|
||||
|
||||
if (p.hasPermission(Permissions.COMMAND_OPTIONS) && p.hasPermission(Permissions.DELETE_COMMAND)) {
|
||||
|
||||
@@ -22,7 +22,6 @@ import dev.mylesmor.sudosigns.data.SudoUser;
|
||||
import dev.mylesmor.sudosigns.util.Permissions;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class CommandsMenu {
|
||||
|
||||
@@ -53,7 +52,7 @@ public class CommandsMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("Commands: " + sign.getName());
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("Commands: " + sign.getName());
|
||||
|
||||
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
for (int i = 0; i < menu.getSize(); i++) {
|
||||
@@ -65,7 +64,7 @@ public class CommandsMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
if (p.hasPermission(Permissions.ADD_COMMAND)) {
|
||||
@@ -73,7 +72,7 @@ public class CommandsMenu {
|
||||
ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
|
||||
ItemMeta bqMeta = bookQuill.getItemMeta();
|
||||
|
||||
bqMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&2Add new command"));
|
||||
bqMeta.displayName(Util.legacySerializerAnyCase("&r&2Add new command"));
|
||||
bookQuill.setItemMeta(bqMeta);
|
||||
|
||||
menu.setItem(40, bookQuill);
|
||||
@@ -83,13 +82,13 @@ public class CommandsMenu {
|
||||
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
|
||||
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
|
||||
|
||||
cmdBlockMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Console Commands"));
|
||||
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&5Console Commands"));
|
||||
cmdBlock.setItemMeta(cmdBlockMeta);
|
||||
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
ItemMeta headMeta = head.getItemMeta();
|
||||
|
||||
headMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&d Player Commands"));
|
||||
headMeta.displayName(Util.legacySerializerAnyCase("&r&d Player Commands"));
|
||||
head.setItemMeta(headMeta);
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
@@ -108,7 +107,7 @@ public class CommandsMenu {
|
||||
ItemMeta bookMeta = book.getItemMeta();
|
||||
|
||||
lore.add("&6Player Command");
|
||||
bookMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&6/" + sc.getCommand()));
|
||||
bookMeta.displayName(Util.legacySerializerAnyCase("&r&6/" + sc.getCommand()));
|
||||
lore.add("&6Delay: &e" + (sc.getDelay() / 1000) + "s");
|
||||
|
||||
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
|
||||
@@ -144,7 +143,7 @@ public class CommandsMenu {
|
||||
ItemMeta bookMeta = book.getItemMeta();
|
||||
|
||||
lore.add("&6Console Command");
|
||||
bookMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&6/" + sc.getCommand()));
|
||||
bookMeta.displayName(Util.legacySerializerAnyCase("&r&6/" + sc.getCommand()));
|
||||
lore.add("&6Delay: &e" + (sc.getDelay() / 1000) + "s");
|
||||
|
||||
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
|
||||
@@ -180,7 +179,7 @@ public class CommandsMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("Player or Console command?");
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("Player or Console command?");
|
||||
|
||||
Inventory choiceInv = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
for (int i = 0; i < choiceInv.getSize(); i++) {
|
||||
@@ -192,7 +191,7 @@ public class CommandsMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
@@ -200,13 +199,13 @@ public class CommandsMenu {
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
lore.add("&cThe player must have permission to run the command!");
|
||||
headMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dPlayer Command"));
|
||||
headMeta.displayName(Util.legacySerializerAnyCase("&r&dPlayer Command"));
|
||||
headMeta.lore(Util.convertToTextComponents(lore));
|
||||
head.setItemMeta(headMeta);
|
||||
|
||||
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
|
||||
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
|
||||
cmdBlockMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dConsole Command"));
|
||||
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&dConsole Command"));
|
||||
cmdBlock.setItemMeta(cmdBlockMeta);
|
||||
|
||||
if (p.hasPermission(Permissions.CONSOLE_COMMAND)) {
|
||||
|
||||
@@ -17,7 +17,6 @@ import dev.mylesmor.sudosigns.data.SudoSign;
|
||||
import dev.mylesmor.sudosigns.util.Permissions;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class MainMenu {
|
||||
|
||||
@@ -46,7 +45,7 @@ public class MainMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("&r&2Editing: &e" + sign.getName());
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("&r&2Editing: &e" + sign.getName());
|
||||
|
||||
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
for (int i = 0; i < menu.getSize(); i++) {
|
||||
@@ -64,7 +63,7 @@ public class MainMenu {
|
||||
ItemStack nametag = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta ntMeta = nametag.getItemMeta();
|
||||
|
||||
ntMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Rename Sign"));
|
||||
ntMeta.displayName(Util.legacySerializerAnyCase("&r&5Rename Sign"));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("&eChange the text that refers");
|
||||
@@ -83,7 +82,7 @@ public class MainMenu {
|
||||
ItemStack book = new ItemStack(Material.WRITABLE_BOOK);
|
||||
ItemMeta bookMeta = book.getItemMeta();
|
||||
|
||||
bookMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Edit Sign Text"));
|
||||
bookMeta.displayName(Util.legacySerializerAnyCase("&r&5Edit Sign Text"));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("&eChange the text that displays");
|
||||
@@ -102,7 +101,7 @@ public class MainMenu {
|
||||
ItemStack barrier = new ItemStack(Material.BARRIER);
|
||||
ItemMeta barrierMeta = barrier.getItemMeta();
|
||||
|
||||
barrierMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dPermissions"));
|
||||
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&dPermissions"));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("&ePlayers must have all permissions");
|
||||
@@ -126,7 +125,7 @@ public class MainMenu {
|
||||
lore.add("&ewhen a player uses the sign.");
|
||||
|
||||
cmdBlockMeta.lore(Util.convertToTextComponents(lore));
|
||||
cmdBlockMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Commands"));
|
||||
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&5Commands"));
|
||||
cmdBlock.setItemMeta(cmdBlockMeta);
|
||||
|
||||
items.add(cmdBlock);
|
||||
@@ -138,7 +137,7 @@ public class MainMenu {
|
||||
ItemStack signBlock = new ItemStack(Material.OAK_SIGN);
|
||||
ItemMeta signMeta = signBlock.getItemMeta();
|
||||
|
||||
signMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Messages"));
|
||||
signMeta.displayName(Util.legacySerializerAnyCase("&r&5Messages"));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("&eMessages listed here will be shown");
|
||||
@@ -183,7 +182,7 @@ public class MainMenu {
|
||||
|
||||
goldNuggetItemMeta.lore(Util.convertToTextComponents(lore));
|
||||
goldNuggetItemMeta
|
||||
.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dPrice"));
|
||||
.displayName(Util.legacySerializerAnyCase("&r&dPrice"));
|
||||
goldNugget.setItemMeta(goldNuggetItemMeta);
|
||||
|
||||
items.add(goldNugget);
|
||||
|
||||
@@ -22,7 +22,6 @@ import dev.mylesmor.sudosigns.data.SudoUser;
|
||||
import dev.mylesmor.sudosigns.util.Permissions;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class MessageOptionsMenu {
|
||||
|
||||
@@ -80,7 +79,7 @@ public class MessageOptionsMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("&6Message options");
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Message options");
|
||||
|
||||
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
|
||||
@@ -95,21 +94,21 @@ public class MessageOptionsMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
ItemStack clock = new ItemStack(Material.CLOCK);
|
||||
ItemMeta clockMeta = clock.getItemMeta();
|
||||
|
||||
lore.add("&eChange the delay after which the message is sent");
|
||||
clockMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dChange Delay"));
|
||||
clockMeta.displayName(Util.legacySerializerAnyCase("&r&dChange Delay"));
|
||||
clockMeta.lore(Util.convertToTextComponents(lore));
|
||||
clock.setItemMeta(clockMeta);
|
||||
|
||||
ItemStack barrier = new ItemStack(Material.BARRIER);
|
||||
ItemMeta barrierMeta = barrier.getItemMeta();
|
||||
|
||||
barrierMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dDelete Message"));
|
||||
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&dDelete Message"));
|
||||
barrier.setItemMeta(barrierMeta);
|
||||
|
||||
if (p.hasPermission(Permissions.MESSAGE_OPTIONS) && p.hasPermission(Permissions.DELETE_MESSAGE)) {
|
||||
|
||||
@@ -22,7 +22,6 @@ import dev.mylesmor.sudosigns.data.SudoUser;
|
||||
import dev.mylesmor.sudosigns.util.Permissions;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class MessagesMenu {
|
||||
|
||||
@@ -50,7 +49,7 @@ public class MessagesMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("&6Messages: " + sign.getName());
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Messages: " + sign.getName());
|
||||
|
||||
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
|
||||
@@ -63,7 +62,7 @@ public class MessagesMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
if (p.hasPermission(Permissions.ADD_MESSAGE)) {
|
||||
@@ -71,7 +70,7 @@ public class MessagesMenu {
|
||||
ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
|
||||
ItemMeta bqMeta = bookQuill.getItemMeta();
|
||||
|
||||
bqMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&2Add new message"));
|
||||
bqMeta.displayName(Util.legacySerializerAnyCase("&r&2Add new message"));
|
||||
bookQuill.setItemMeta(bqMeta);
|
||||
|
||||
menu.setItem(40, bookQuill);
|
||||
@@ -92,7 +91,7 @@ public class MessagesMenu {
|
||||
|
||||
ItemMeta signMeta = signItem.getItemMeta();
|
||||
|
||||
signMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dMessages"));
|
||||
signMeta.displayName(Util.legacySerializerAnyCase("&r&dMessages"));
|
||||
signItem.setItemMeta(signMeta);
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
@@ -110,7 +109,7 @@ public class MessagesMenu {
|
||||
ItemMeta bookMeta = book.getItemMeta();
|
||||
|
||||
lore.clear();
|
||||
bookMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&dMessage:"));
|
||||
bookMeta.displayName(Util.legacySerializerAnyCase("&dMessage:"));
|
||||
lore.add("&r&f" + sm.getMessage());
|
||||
lore.add("");
|
||||
lore.add("");
|
||||
|
||||
@@ -18,7 +18,6 @@ import dev.mylesmor.sudosigns.data.SudoUser;
|
||||
import dev.mylesmor.sudosigns.util.Permissions;
|
||||
import dev.mylesmor.sudosigns.util.Util;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class PermissionsMenu {
|
||||
|
||||
@@ -52,7 +51,7 @@ public class PermissionsMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("&6Default or Custom?");
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Default or Custom?");
|
||||
|
||||
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
for (int i = 0; i < menu.getSize(); i++) {
|
||||
@@ -64,13 +63,13 @@ public class PermissionsMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
ItemStack barrier = new ItemStack(Material.BARRIER);
|
||||
ItemMeta barrierMeta = barrier.getItemMeta();
|
||||
|
||||
barrierMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Permissions"));
|
||||
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&5Permissions"));
|
||||
barrier.setItemMeta(barrierMeta);
|
||||
|
||||
if (p.hasPermission(Permissions.ADD_PERMISSION)) {
|
||||
@@ -78,7 +77,7 @@ public class PermissionsMenu {
|
||||
ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
|
||||
ItemMeta bqMeta = bookQuill.getItemMeta();
|
||||
|
||||
bqMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&aAdd new permission"));
|
||||
bqMeta.displayName(Util.legacySerializerAnyCase("&aAdd new permission"));
|
||||
bookQuill.setItemMeta(bqMeta);
|
||||
menu.setItem(40, bookQuill);
|
||||
|
||||
@@ -96,7 +95,7 @@ public class PermissionsMenu {
|
||||
|
||||
ItemStack book = new ItemStack(Material.BOOK);
|
||||
ItemMeta bookMeta = book.getItemMeta();
|
||||
bookMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&6" + perm));
|
||||
bookMeta.displayName(Util.legacySerializerAnyCase("&r&6" + perm));
|
||||
if (p.hasPermission(Permissions.DELETE_PERMISSION)) {
|
||||
|
||||
lore.add("");
|
||||
@@ -127,7 +126,7 @@ public class PermissionsMenu {
|
||||
|
||||
Inventory playersInventory = p.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize("&6Default or Custom?");
|
||||
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Default or Custom?");
|
||||
Inventory choiceInv = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
|
||||
|
||||
int inventorySize = choiceInv.getSize();
|
||||
@@ -144,7 +143,7 @@ public class PermissionsMenu {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW);
|
||||
ItemMeta arrowMeta = arrow.getItemMeta();
|
||||
|
||||
arrowMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dBACK"));
|
||||
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
|
||||
arrow.setItemMeta(arrowMeta);
|
||||
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
@@ -152,14 +151,14 @@ public class PermissionsMenu {
|
||||
List<String> loreString = new ArrayList<>();
|
||||
|
||||
loreString.add("&6sudosigns.sign." + sign.getName());
|
||||
headMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&dDefault Permission"));
|
||||
headMeta.displayName(Util.legacySerializerAnyCase("&r&dDefault Permission"));
|
||||
headMeta.lore(Util.convertToTextComponents(loreString));
|
||||
head.setItemMeta(headMeta);
|
||||
|
||||
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
|
||||
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
|
||||
|
||||
cmdBlockMeta.displayName(LegacyComponentSerializer.legacyAmpersand().deserialize("&r&5Custom Permission"));
|
||||
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&5Custom Permission"));
|
||||
cmdBlock.setItemMeta(cmdBlockMeta);
|
||||
|
||||
choiceInv.setItem(21, head);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Util {
|
||||
// Send the sign selection menu according to permissions.
|
||||
public static void sendSelectMenus(Player p, String name) {
|
||||
|
||||
selectMenuParser(p, Util.chatPrefix, "&e-----", name, "", "&2True&4OG&a's Fork of &BSudoSigns&a.");
|
||||
selectMenuParser(p, chatPrefix, "&e-----", name, "", "&2True&4OG&a's Fork of &BSudoSigns&a.");
|
||||
|
||||
if (p.hasPermission(Permissions.VIEW)) {
|
||||
|
||||
@@ -62,10 +62,10 @@ public class Util {
|
||||
public static void selectMenuParser(Player p, String prefix, String prompt, String name, String command, String hoverMessage) {
|
||||
|
||||
// The clickable part of the confirmation message.
|
||||
TextComponent button = LegacyComponentSerializer.legacyAmpersand().deserialize(prefix);
|
||||
TextComponent button = legacySerializerAnyCase(prefix);
|
||||
|
||||
// Add a hover dialogue to the clickable confirmation text.
|
||||
button.hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, LegacyComponentSerializer.legacyAmpersand().deserialize(hoverMessage)));
|
||||
button.hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, legacySerializerAnyCase(hoverMessage)));
|
||||
|
||||
// Make sure that a command is intended to be run.
|
||||
if(! command.equals("")) {
|
||||
@@ -74,14 +74,87 @@ public class Util {
|
||||
}
|
||||
|
||||
// Send the prompt and clickable confirmation button to the player.
|
||||
Util.sudoSignsPrompt(p, (prompt + " "), button);
|
||||
sudoSignsPrompt(p, (prompt + " "), button);
|
||||
|
||||
}
|
||||
|
||||
public static TextComponent legacySerializerAnyCase(String subject) {
|
||||
|
||||
int count = 0;
|
||||
// Count the number of '&' characters to determine the size of the array
|
||||
for (char c : subject.toCharArray()) {
|
||||
|
||||
if (c == '&') {
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create an array to store the positions of '&' characters
|
||||
int[] positions = new int[count];
|
||||
int index = 0;
|
||||
// Find the positions of '&' characters and store in the array
|
||||
for (int i = 0; i < subject.length(); i++) {
|
||||
|
||||
if (subject.charAt(i) == '&') {
|
||||
|
||||
if (isUpperBukkitCode(subject.charAt(i + 1))) {
|
||||
|
||||
subject = replaceCharAtIndex(subject, (i + 1), Character.toLowerCase(subject.charAt(i + 1)));
|
||||
|
||||
}
|
||||
|
||||
positions[index++] = i;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(subject);
|
||||
|
||||
}
|
||||
|
||||
private static boolean isUpperBukkitCode(char input) {
|
||||
|
||||
char[] bukkitColorCodes = {'A', 'B', 'C', 'D', 'E', 'F', 'K', 'L', 'M', 'N', 'O', 'R'};
|
||||
boolean match = false;
|
||||
|
||||
// Loop through each character in the array.
|
||||
for (char c : bukkitColorCodes) {
|
||||
// Check if the current character in the array is equal to the input character.
|
||||
if (c == input) {
|
||||
|
||||
match = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return match;
|
||||
|
||||
}
|
||||
|
||||
private static String replaceCharAtIndex(String original, int index, char newChar) {
|
||||
|
||||
// Check if the index is valid
|
||||
if (index >= 0 && index < original.length()) {
|
||||
|
||||
// Create a new string with the replaced character
|
||||
return original.substring(0, index) + newChar + original.substring(index + 1);
|
||||
|
||||
}
|
||||
|
||||
// If the index is invalid, return the original string
|
||||
return original;
|
||||
|
||||
}
|
||||
|
||||
// Sends a formatted message to the player.
|
||||
public static void sudoSignsMessage(Player p, String message) {
|
||||
|
||||
p.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(chatPrefix + message));
|
||||
p.sendMessage(legacySerializerAnyCase(chatPrefix + message));
|
||||
|
||||
}
|
||||
|
||||
@@ -101,7 +174,7 @@ public class Util {
|
||||
// Sends a formatted message without a prefix to the player.
|
||||
public static void sudoSignsMessageNoPrefix(Player p, String message) {
|
||||
|
||||
p.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(message));
|
||||
p.sendMessage(legacySerializerAnyCase(message));
|
||||
|
||||
}
|
||||
|
||||
@@ -115,7 +188,7 @@ public class Util {
|
||||
// Sends a formatted prompt and clickable chat button to the player.
|
||||
public static void sudoSignsPrompt(Player player, String prompt, TextComponent button) {
|
||||
|
||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(prompt).append(button));
|
||||
player.sendMessage(legacySerializerAnyCase(prompt).append(button));
|
||||
|
||||
}
|
||||
|
||||
@@ -152,7 +225,7 @@ public class Util {
|
||||
|
||||
for (String str : stringList) {
|
||||
|
||||
TextComponent textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(str);
|
||||
TextComponent textComponent = legacySerializerAnyCase(str);
|
||||
textComponents.add(textComponent);
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user