From efa794c9795dd1da169d78b7b46acfff1ce8fd89 Mon Sep 17 00:00:00 2001 From: nulli0n Date: Wed, 27 Nov 2024 18:54:40 +0500 Subject: [PATCH] v2.7.2 --- .../nightexpress/nightcore/core/CoreLang.java | 7 +------ .../nightexpress/nightcore/core/CorePerms.java | 1 + .../nightcore/core/command/CoreCommands.java | 18 ++++++++++++++++++ .../nightcore/menu/MenuViewer.java | 3 ++- .../nightcore/menu/impl/ConfigMenu.java | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/java/su/nightexpress/nightcore/core/CoreLang.java b/src/main/java/su/nightexpress/nightcore/core/CoreLang.java index d0a3c41..e270385 100644 --- a/src/main/java/su/nightexpress/nightcore/core/CoreLang.java +++ b/src/main/java/su/nightexpress/nightcore/core/CoreLang.java @@ -52,6 +52,7 @@ public class CoreLang { public static final LangString COMMAND_HELP_DESC = LangString.of("Command.Help.Desc", "Show help page."); public static final LangString COMMAND_CHECKPERM_DESC = LangString.of("Command.CheckPerm.Desc", "Print player permission info."); + public static final LangString COMMAND_DUMPITEM_DESC = LangString.of("Command.DumpItem.Desc", "Print item components info."); public static final LangString COMMAND_RELOAD_DESC = LangString.of("Command.Reload.Desc", "Reload the plugin."); public static final LangText COMMAND_RELOAD_DONE = LangText.of("Command.Reload.Done", @@ -160,12 +161,6 @@ public class CoreLang { public static final LangItem EDITOR_ITEM_NEXT_PAGE = LangItem.of("Editor.Generic.NextPage", LIGHT_GRAY.enclose("Next Page →")); public static final LangItem EDITOR_ITEM_PREVIOUS_PAGE = LangItem.of("Editor.Generic.PreviousPage", LIGHT_GRAY.enclose("← Previous Page")); -// public static final LangString NUMBER_SHORT_THOUSAND = LangString.of("Number.Thousand", "k"); -// public static final LangString NUMBER_SHORT_MILLION = LangString.of("Number.Million", "m"); -// public static final LangString NUMBER_SHORT_BILLION = LangString.of("Number.Billion", "b"); -// public static final LangString NUMBER_SHORT_TRILLION = LangString.of("Number.Trillion", "t"); -// public static final LangString NUMBER_SHORT_QUADRILLION = LangString.of("Number.Quadrillion", "q"); - @NotNull public static String getYesOrNo(boolean value) { return (value ? OTHER_YES : OTHER_NO).getString(); diff --git a/src/main/java/su/nightexpress/nightcore/core/CorePerms.java b/src/main/java/su/nightexpress/nightcore/core/CorePerms.java index 52770f0..8e2fc65 100644 --- a/src/main/java/su/nightexpress/nightcore/core/CorePerms.java +++ b/src/main/java/su/nightexpress/nightcore/core/CorePerms.java @@ -6,6 +6,7 @@ public class CorePerms { public static final UniPermission COMMAND_RELOAD = new UniPermission("nightcore.command.reload"); public static final UniPermission COMMAND_CHECK_PERM = new UniPermission("nightcore.command.checkperm"); + public static final UniPermission COMMAND_DUMP_ITEM = new UniPermission("nightcore.command.dumpitem"); public static final UniPermission COMMAND_FLAGS = new UniPermission("nightcore.command.flags"); } diff --git a/src/main/java/su/nightexpress/nightcore/core/command/CoreCommands.java b/src/main/java/su/nightexpress/nightcore/core/command/CoreCommands.java index 727f162..849e6fa 100644 --- a/src/main/java/su/nightexpress/nightcore/core/command/CoreCommands.java +++ b/src/main/java/su/nightexpress/nightcore/core/command/CoreCommands.java @@ -1,6 +1,7 @@ package su.nightexpress.nightcore.core.command; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import su.nightexpress.nightcore.NightCore; import su.nightexpress.nightcore.command.experimental.CommandContext; @@ -13,6 +14,7 @@ import su.nightexpress.nightcore.core.CorePerms; import su.nightexpress.nightcore.integration.VaultHook; import su.nightexpress.nightcore.util.Colorizer; +import su.nightexpress.nightcore.util.ItemNbt; import su.nightexpress.nightcore.util.Plugins; import su.nightexpress.nightcore.util.text.NightMessage; @@ -37,6 +39,13 @@ public static void load(@NotNull NightCore core) { ); } + root.addChildren(DirectNode.builder(core, "dumpitem") + .playerOnly() + .permission(CorePerms.COMMAND_DUMP_ITEM) + .description(CoreLang.COMMAND_DUMPITEM_DESC) + .executes(CoreCommands::dumpItem) + ); + root.addChildren(ReloadCommand.builder(core, CorePerms.COMMAND_RELOAD)); } @@ -55,4 +64,13 @@ private static boolean checkPermissions(@NotNull CommandContext context, @NotNul NightMessage.create(builder).send(context.getSender()); return true; } + + private static boolean dumpItem(@NotNull CommandContext context, @NotNull ParsedArguments arguments) { + Player player = context.getPlayerOrThrow(); + ItemStack itemStack = player.getInventory().getItemInMainHand(); + player.sendMessage("=".repeat(10) + " DUMP ITEM " + "=".repeat(10)); + player.sendMessage(String.valueOf(ItemNbt.getTagString(itemStack))); + + return true; + } } diff --git a/src/main/java/su/nightexpress/nightcore/menu/MenuViewer.java b/src/main/java/su/nightexpress/nightcore/menu/MenuViewer.java index 71c968c..ab566eb 100644 --- a/src/main/java/su/nightexpress/nightcore/menu/MenuViewer.java +++ b/src/main/java/su/nightexpress/nightcore/menu/MenuViewer.java @@ -5,6 +5,7 @@ import org.bukkit.inventory.InventoryView; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import su.nightexpress.nightcore.util.Version; public class MenuViewer { @@ -30,7 +31,7 @@ public void openInventory(@NotNull Inventory inventory) { public void flushInventory(@NotNull MenuOptions options) { this.inventory.clear(); - if (this.isUpdateTitle()) { + if (this.isUpdateTitle() && Version.isAtLeast(Version.MC_1_21_3)) { this.view.setTitle(options.getTitleFormatted()); this.setUpdateTitle(false); } diff --git a/src/main/java/su/nightexpress/nightcore/menu/impl/ConfigMenu.java b/src/main/java/su/nightexpress/nightcore/menu/impl/ConfigMenu.java index 71b31f3..24cf41e 100644 --- a/src/main/java/su/nightexpress/nightcore/menu/impl/ConfigMenu.java +++ b/src/main/java/su/nightexpress/nightcore/menu/impl/ConfigMenu.java @@ -196,7 +196,7 @@ protected MenuItem readItem(@NotNull String path) { protected void writeItem(@NotNull MenuItem menuItem, @NotNull String path) { this.cfg.set(path + ".Priority", menuItem.getPriority()); - this.cfg.set(path + ".Item", menuItem.getItem()); + this.cfg.setItem(path + ".Item", menuItem.getItemStack()); this.cfg.setIntArray(path + ".Slots", menuItem.getSlots()); this.cfg.set(path + ".Type", menuItem.getHandler().getName()); }