Skip to content

Commit

Permalink
v2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nulli0n committed Nov 27, 2024
1 parent 90db0b7 commit efa794c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/main/java/su/nightexpress/nightcore/core/CoreLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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));
}

Expand All @@ -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;
}
}
3 changes: 2 additions & 1 deletion src/main/java/su/nightexpress/nightcore/menu/MenuViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit efa794c

Please sign in to comment.