From d826109b35b9281d67eee1475c2be47b3148d965 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 14:38:49 +0900 Subject: [PATCH 01/53] version: 4.4.0-SNAPSHOT --- README.md | 8 ++++---- gradle.properties | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index abe4db3e14..5030fb449f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Box v4.3.0 +# Box v4.4.0-SNAPSHOT ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/okocraft/Box) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/okocraft/Box/Maven%20Build) @@ -85,19 +85,19 @@ For snapshot version, use https://okocraft.github.io/Box/maven-snapshot/ net.okocraft.box api - 4.3.0 + 4.4.0-SNAPSHOT provided ``` ```gradle dependencies { - compileOnly 'net.okocraft.box:api:4.3.0' + compileOnly 'net.okocraft.box:api:4.4.0-SNAPSHOT' } ``` ```kotlin dependencies { - compileOnly("net.okocraft.box:api:4.3.0") + compileOnly("net.okocraft.box:api:4.4.0-SNAPSHOT") } ``` diff --git a/gradle.properties b/gradle.properties index c513a8b271..bc59335320 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.caching=true org.gradle.parallel=true group=net.okocraft.box -version=4.3.0 +version=4.4.0-SNAPSHOT From 858e06241b4de82f874ffb49a4cc2c633b9cceb7 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 15:26:52 +0900 Subject: [PATCH 02/53] change(gui): don't register storagemode, it's default mode --- .../java/net/okocraft/box/feature/gui/GuiFeature.java | 8 -------- .../box/feature/gui/api/mode/ClickModeRegistry.java | 11 +++++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java index bdf18d8046..1b872b3864 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java @@ -8,11 +8,9 @@ import net.okocraft.box.api.feature.Disableable; import net.okocraft.box.api.feature.Reloadable; import net.okocraft.box.feature.category.CategoryFeature; -import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import net.okocraft.box.feature.gui.internal.command.MenuOpenCommand; import net.okocraft.box.feature.gui.internal.holder.BoxInventoryHolder; import net.okocraft.box.feature.gui.internal.listener.InventoryListener; -import net.okocraft.box.feature.gui.internal.mode.StorageMode; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.HumanEntity; @@ -27,8 +25,6 @@ public class GuiFeature extends AbstractBoxFeature implements Disableable, Reloa private final MenuOpenCommand command = new MenuOpenCommand(); private final InventoryListener listener = new InventoryListener(); - private final StorageMode storageMode = new StorageMode(); - public GuiFeature() { super("gui"); } @@ -37,8 +33,6 @@ public GuiFeature() { public void enable() { var boxCommand = BoxProvider.get().getBoxCommand(); - ClickModeRegistry.register(storageMode); - boxCommand.changeNoArgumentCommand(command); boxCommand.getSubCommandHolder().register(command); @@ -49,8 +43,6 @@ public void enable() { public void disable() { var boxCommand = BoxProvider.get().getBoxCommand(); - ClickModeRegistry.unregister(storageMode); - boxCommand.changeNoArgumentCommand(null); boxCommand.getSubCommandHolder().unregister(command); diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java index 37c7ec68c7..38fd89e24d 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java @@ -1,5 +1,6 @@ package net.okocraft.box.feature.gui.api.mode; +import net.okocraft.box.feature.gui.internal.mode.StorageMode; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; @@ -7,11 +8,17 @@ import java.util.Collections; import java.util.List; -public class ClickModeRegistry { +public final class ClickModeRegistry { + + private static final BoxItemClickMode STORAGE_MODE = new StorageMode(); + private static final List REGISTERED_BOX_ITEM_CLICK_MODE = new ArrayList<>(List.of(STORAGE_MODE)); - private static final List REGISTERED_BOX_ITEM_CLICK_MODE = new ArrayList<>(); private static List COPIED_REGISTERED_BOX_ITEM_CLICK_MODE = Collections.emptyList(); + public static @NotNull BoxItemClickMode getStorageMode() { + return STORAGE_MODE; + } + public static @NotNull @Unmodifiable List getModes() { return COPIED_REGISTERED_BOX_ITEM_CLICK_MODE; } From 39996c136b9f5914536d4cda4e524ff1c2d7c69e Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 15:38:44 +0900 Subject: [PATCH 03/53] feat(gui): add BoxItemClickMode#canUse --- .../box/feature/gui/api/mode/BoxItemClickMode.java | 4 ++++ .../box/feature/gui/api/session/PlayerSession.java | 14 +++++++++++++- .../feature/gui/internal/button/ModeButton.java | 8 ++++---- .../gui/internal/command/MenuOpenCommand.java | 5 ++++- .../box/feature/gui/internal/mode/StorageMode.java | 5 +++++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/BoxItemClickMode.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/BoxItemClickMode.java index 2201e4c8be..24b7f33494 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/BoxItemClickMode.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/BoxItemClickMode.java @@ -26,6 +26,10 @@ public interface BoxItemClickMode { @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu); + default boolean canUse(@NotNull Player viewer) { + return true; + } + record Context(@NotNull Player clicker, @NotNull BoxItem item, @NotNull ClickType clickType, @Nullable Menu currentMenu) { } diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java index b937bc7283..bd8dbf43ab 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java @@ -6,8 +6,11 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -20,9 +23,10 @@ public class PlayerSession { return SESSION_MAP.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerSession()); } - private BoxItemClickMode currentClickMode = ClickModeRegistry.getModes().get(0); + private BoxItemClickMode currentClickMode = ClickModeRegistry.getStorageMode(); private final Map customNumberMap = new HashMap<>(); + private List availableClickModes; private @Nullable StockHolder stockHolder; private PlayerSession() { @@ -55,4 +59,12 @@ public void resetCustomNumbers() { public void setStockHolder(@Nullable StockHolder stockHolder) { this.stockHolder = stockHolder; } + + public @NotNull @Unmodifiable List getAvailableClickModes() { + return availableClickModes != null ? availableClickModes : Collections.emptyList(); + } + + public void setAvailableClickModes(@NotNull List availableClickModes) { + this.availableClickModes = Objects.requireNonNull(availableClickModes); + } } diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/button/ModeButton.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/button/ModeButton.java index 75f70e7c96..8d371c0c99 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/button/ModeButton.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/button/ModeButton.java @@ -3,7 +3,6 @@ import net.kyori.adventure.text.Component; import net.okocraft.box.feature.gui.api.button.RefreshableButton; import net.okocraft.box.feature.gui.api.lang.Styles; -import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import net.okocraft.box.feature.gui.api.session.PlayerSession; import net.okocraft.box.feature.gui.api.util.TranslationUtil; import net.okocraft.box.feature.gui.internal.lang.Displays; @@ -58,9 +57,9 @@ public int getSlot() { @Override public void onClick(@NotNull Player clicker, @NotNull ClickType clickType) { - var modes = ClickModeRegistry.getModes(); var session = PlayerSession.get(clicker); + var modes = session.getAvailableClickModes(); int nextIndex = modes.indexOf(session.getBoxItemClickMode()) + 1; if (modes.size() <= nextIndex) { @@ -77,9 +76,10 @@ public void onClick(@NotNull Player clicker, @NotNull ClickType clickType) { private @NotNull List createLore(@NotNull Player viewer) { var result = new ArrayList(); - var modes = ClickModeRegistry.getModes(); + var session = PlayerSession.get(viewer); - var currentMode = PlayerSession.get(viewer).getBoxItemClickMode(); + var modes = session.getAvailableClickModes(); + var currentMode = session.getBoxItemClickMode(); for (var mode : modes) { var style = currentMode == mode ? Styles.NO_DECORATION_AQUA : Styles.NO_DECORATION_GRAY; diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java index 85e9a7795f..7887e3e13e 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java @@ -42,9 +42,12 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { var session = PlayerSession.get(player); - session.setBoxItemClickMode(ClickModeRegistry.getModes().get(0)); + session.setBoxItemClickMode(ClickModeRegistry.getStorageMode()); session.resetCustomNumbers(); + var modes = ClickModeRegistry.getModes().stream().filter(mode -> mode.canUse(player)).toList(); + session.setAvailableClickModes(modes); + StockHolder stockHolder; if (1 < args.length) { diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java index 52edc3563f..cae3677b65 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java @@ -69,6 +69,11 @@ public boolean hasAdditionalButton() { return true; } + @Override + public final boolean canUse(@NotNull Player viewer) { + return true; // This is the default mode, so it must always be available to the player. + } + @Override public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { return new DepositAllButton(); From 3b19906af317c9320e3d75cedf15bb5af6d59b40 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 15:42:58 +0900 Subject: [PATCH 04/53] feat(autostore): checks autostore permission --- .../box/feature/autostore/gui/AutoStoreClickMode.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreClickMode.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreClickMode.java index 24176030f4..bbff34deb0 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreClickMode.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreClickMode.java @@ -86,6 +86,11 @@ public boolean hasAdditionalButton() { return true; } + @Override + public boolean canUse(@NotNull Player viewer) { + return viewer.hasPermission("box.autostore"); + } + @Override public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { if (AutoStoreSettingContainer.INSTANCE.isLoaded(viewer)) { From cec8d56c825509f12c7fb36d328a408c5148eff5 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 15:43:06 +0900 Subject: [PATCH 05/53] feat(craft): checks craft permission --- .../java/net/okocraft/box/feature/craft/mode/CraftMode.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/mode/CraftMode.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/mode/CraftMode.java index f0302c77a3..8f2daef26f 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/mode/CraftMode.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/mode/CraftMode.java @@ -80,6 +80,11 @@ public boolean hasAdditionalButton() { return false; } + @Override + public boolean canUse(@NotNull Player viewer) { + return viewer.hasPermission("box.craft"); + } + @Override public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { throw new UnsupportedOperationException(); From 1f41cb99eb1ee23fc46d49062ae679a857555d99 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 15:43:14 +0900 Subject: [PATCH 06/53] chore(bundle): add box.craft permission --- bundle/src/main/resources/plugin.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bundle/src/main/resources/plugin.yml b/bundle/src/main/resources/plugin.yml index d14228521a..13916a6158 100644 --- a/bundle/src/main/resources/plugin.yml +++ b/bundle/src/main/resources/plugin.yml @@ -14,6 +14,7 @@ permissions: children: - box.command - box.autostore + - box.craft - box.stick box.command: default: true @@ -44,6 +45,8 @@ permissions: default: true box.autostore: default: true + box.craft: + default: true box.stick: default: true children: From f0a83716cd134484cf4e84ea406fabba9e914c83 Mon Sep 17 00:00:00 2001 From: LazyGon Date: Thu, 20 Jan 2022 16:48:26 +0900 Subject: [PATCH 07/53] chore: update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0dfe9ded9a..ad86f76769 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ gradle-app.setting .vscode .settings .factorypath +**/bin/ # IntelliJ IDEA .idea From 94d21148ea4778561b2a718169fd2c09f81e12d5 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:25:54 +0900 Subject: [PATCH 08/53] feat(gui): add MenuEvents --- .../feature/gui/api/event/MenuClickEvent.java | 67 +++++++++++++++++++ .../box/feature/gui/api/event/MenuEvent.java | 35 ++++++++++ .../feature/gui/api/event/MenuOpenEvent.java | 46 +++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuClickEvent.java create mode 100644 features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuEvent.java create mode 100644 features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuOpenEvent.java diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuClickEvent.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuClickEvent.java new file mode 100644 index 0000000000..cc27f436ab --- /dev/null +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuClickEvent.java @@ -0,0 +1,67 @@ +package net.okocraft.box.feature.gui.api.event; + +import com.github.siroshun09.event4j.event.Cancellable; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import net.okocraft.box.feature.gui.api.menu.Menu; +import net.okocraft.box.feature.gui.api.menu.RenderedButton; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class MenuClickEvent extends MenuEvent implements Cancellable { + + private final RenderedButton clickedButton; + private final ClickType clickType; + private boolean cancelled; + + public MenuClickEvent(@NotNull Player viewer, @NotNull Menu menu, + @NotNull RenderedButton clickedButton, @NotNull ClickType clickType) { + super(viewer, menu); + this.clickedButton = Objects.requireNonNull(clickedButton); + this.clickType = Objects.requireNonNull(clickType); + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + public @NotNull RenderedButton getClickedButton() { + return clickedButton; + } + + public @NotNull ClickType getClickType() { + return clickType; + } + + @Override + public @NotNull String toDebugLog() { + return "MenuClickEvent{" + + "viewerUuid=" + getViewer().getUniqueId() + + ", viewerName=" + getViewer().getName() + + ", menuClass=" + getMenu().getClass().getSimpleName() + + ", menuTitle=" + PlainTextComponentSerializer.plainText().serialize(getMenu().getTitle()) + + ", buttonClass=" + getClickedButton().getClass().getSimpleName() + + ", clickType=" + getClickType() + + ", cancelled=" + isCancelled() + + '}'; + } + + @Override + public String toString() { + return "MenuClickEvent{" + + "viewer=" + getViewer() + + ", menu=" + getMenu() + + ", clickedButton=" + getClickedButton() + + ", clickType=" + getClickType() + + ", cancelled=" + isCancelled() + + '}'; + } +} diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuEvent.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuEvent.java new file mode 100644 index 0000000000..1aa2f8f6ca --- /dev/null +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuEvent.java @@ -0,0 +1,35 @@ +package net.okocraft.box.feature.gui.api.event; + +import net.okocraft.box.api.event.BoxEvent; +import net.okocraft.box.feature.gui.api.menu.Menu; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.Objects; + +public class MenuEvent extends BoxEvent { + + private final Player viewer; + private final Menu menu; + + public MenuEvent(@NotNull Player viewer, @NotNull Menu menu) { + this.viewer = Objects.requireNonNull(viewer); + this.menu = Objects.requireNonNull(menu); + } + + public @NotNull Player getViewer() { + return viewer; + } + + public @NotNull Menu getMenu() { + return menu; + } + + @Override + public String toString() { + return "MenuEvent{" + + "viewer=" + viewer + + ", menu=" + menu + + '}'; + } +} diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuOpenEvent.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuOpenEvent.java new file mode 100644 index 0000000000..36ba9090bf --- /dev/null +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/event/MenuOpenEvent.java @@ -0,0 +1,46 @@ +package net.okocraft.box.feature.gui.api.event; + +import com.github.siroshun09.event4j.event.Cancellable; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import net.okocraft.box.feature.gui.api.menu.Menu; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class MenuOpenEvent extends MenuEvent implements Cancellable { + + private boolean cancelled; + + public MenuOpenEvent(@NotNull Player viewer, @NotNull Menu menu) { + super(viewer, menu); + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @Override + public @NotNull String toDebugLog() { + return "MenuOpenEvent{" + + "viewerUuid=" + getViewer().getUniqueId() + + ", viewerName=" + getViewer().getName() + + ", menuClass=" + getMenu().getClass().getSimpleName() + + ", menuTitle=" + PlainTextComponentSerializer.plainText().serialize(getMenu().getTitle()) + + ", cancelled=" + isCancelled() + + '}'; + } + + @Override + public String toString() { + return "MenuOpenEvent{" + + "viewer=" + getViewer() + + ", menu=" + getMenu() + + ", cancelled=" + isCancelled() + + '}'; + } +} From 1e3328fce68a34833f33ab42768f4ecf28bd64dd Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:29:00 +0900 Subject: [PATCH 09/53] feat(gui): calls added events --- .../box/feature/gui/api/menu/AbstractMenu.java | 8 ++++++++ .../gui/internal/command/MenuOpenCommand.java | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/AbstractMenu.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/AbstractMenu.java index 8c5dbda1e5..e05bd0ebc4 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/AbstractMenu.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/AbstractMenu.java @@ -1,5 +1,7 @@ package net.okocraft.box.feature.gui.api.menu; +import net.okocraft.box.api.BoxProvider; +import net.okocraft.box.feature.gui.api.event.MenuClickEvent; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -36,6 +38,12 @@ public void clickMenu(@NotNull Player clicker, int slot, @NotNull ClickType clic return; } + var event = new MenuClickEvent(clicker, this, button, clickType); + + if (BoxProvider.get().getEventBus().callEvent(event).isCancelled()) { + return; + } + button.clickButton(clicker, clickType); if (button.shouldUpdate()) { diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java index 7887e3e13e..8b68f782d7 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java @@ -24,10 +24,16 @@ import static net.kyori.adventure.text.format.NamedTextColor.AQUA; import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; import static net.kyori.adventure.text.format.NamedTextColor.GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.RED; public class MenuOpenCommand extends AbstractCommand { private static final String OTHER_PLAYERS_GUI_PERMISSION = "box.admin.command.gui.other"; + private static final Component CANNOT_OPEN_MENU = translatable("box.gui.cannot-open-menu", RED); + private static final Component COMMAND_HELP = + translatable("box.gui.command-help.command-line", AQUA) + .append(text(" - ", DARK_GRAY)) + .append(translatable("box.gui.command-help.description", GRAY)); public MenuOpenCommand() { super("gui", "box.command.gui", Set.of("g", "menu", "m")); @@ -68,14 +74,20 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { session.setStockHolder(stockHolder); + var menu = new CategorySelectorMenu(); + var event = new MenuOpenEvent(player, menu); + + if (BoxProvider.get().getEventBus().callEvent(event).isCancelled()) { + sender.sendMessage(CANNOT_OPEN_MENU); + return; + } + MenuOpener.open(new CategorySelectorMenu(), player); } @Override public @NotNull Component getHelp() { - return translatable("box.gui.command-help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.gui.command-help.description", GRAY)); + return COMMAND_HELP; } @Override From 4291d488b8e29b97f36f0d184039f890093667e8 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:29:16 +0900 Subject: [PATCH 10/53] chore(bundle): add box.gui.cannot-open-menu message --- bundle/src/main/resources/en.yml | 1 + bundle/src/main/resources/ja_JP.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/bundle/src/main/resources/en.yml b/bundle/src/main/resources/en.yml index 7b32012c54..27dcd3aa08 100644 --- a/bundle/src/main/resources/en.yml +++ b/bundle/src/main/resources/en.yml @@ -275,6 +275,7 @@ box: gui: reloaded: "GUI feature has been reloaded." error-occurred: "An error occurred while click process. Error message: {0}" + cannot-open-menu: "You cannot open the menu now." command-help: command-line: "/box gui" description: "Opens Box menu" diff --git a/bundle/src/main/resources/ja_JP.yml b/bundle/src/main/resources/ja_JP.yml index 5701984b81..b29ed358a1 100644 --- a/bundle/src/main/resources/ja_JP.yml +++ b/bundle/src/main/resources/ja_JP.yml @@ -275,6 +275,7 @@ box: gui: reloaded: "GUI 機能を再読み込みしました。" error-occurred: "クリック処理中にエラーが発生しました。エラーメッセージ: {0}" + cannot-open-menu: "メニューを開くことができませんでした。" command-help: command-line: "/box gui" description: "Box のメニューを開く" From f798b8829d2125b8e299d9240e5658b3c7eca895 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:31:00 +0900 Subject: [PATCH 11/53] change(gui): checks if the available modes is not empty --- .../okocraft/box/feature/gui/api/session/PlayerSession.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java index bd8dbf43ab..2e60290cc7 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java @@ -8,7 +8,6 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -61,7 +60,8 @@ public void setStockHolder(@Nullable StockHolder stockHolder) { } public @NotNull @Unmodifiable List getAvailableClickModes() { - return availableClickModes != null ? availableClickModes : Collections.emptyList(); + return availableClickModes != null && !availableClickModes.isEmpty() ? + availableClickModes : List.of(ClickModeRegistry.getStorageMode()); } public void setAvailableClickModes(@NotNull List availableClickModes) { From 01bd4bfa786b961a1b2d80af2e806b869c0f04cb Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:32:48 +0900 Subject: [PATCH 12/53] change(gui): change the PlayerSession#setBoxItemClickMode argument to nullable --- .../box/feature/gui/api/session/PlayerSession.java | 9 ++++----- .../feature/gui/internal/command/MenuOpenCommand.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java index 2e60290cc7..912813d8c9 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/PlayerSession.java @@ -22,21 +22,20 @@ public class PlayerSession { return SESSION_MAP.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerSession()); } - private BoxItemClickMode currentClickMode = ClickModeRegistry.getStorageMode(); - private final Map customNumberMap = new HashMap<>(); private List availableClickModes; + private @Nullable BoxItemClickMode currentClickMode; private @Nullable StockHolder stockHolder; private PlayerSession() { } public @NotNull BoxItemClickMode getBoxItemClickMode() { - return currentClickMode; + return Objects.requireNonNullElse(currentClickMode, getAvailableClickModes().get(0)); } - public void setBoxItemClickMode(@NotNull BoxItemClickMode boxItemClickMode) { - this.currentClickMode = Objects.requireNonNull(boxItemClickMode); + public void setBoxItemClickMode(@Nullable BoxItemClickMode boxItemClickMode) { + this.currentClickMode = boxItemClickMode; } public @NotNull CustomNumberHolder getCustomNumberHolder(@NotNull String numberName) { diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java index 8b68f782d7..67fffb76d1 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java @@ -48,7 +48,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { var session = PlayerSession.get(player); - session.setBoxItemClickMode(ClickModeRegistry.getStorageMode()); + session.setBoxItemClickMode(null); session.resetCustomNumbers(); var modes = ClickModeRegistry.getModes().stream().filter(mode -> mode.canUse(player)).toList(); From 7f0a4437aa9ace8bc6a17a403179eb8f340832ef Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:33:23 +0900 Subject: [PATCH 13/53] fix(gui): add a missing import --- .../box/feature/gui/internal/command/MenuOpenCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java index 67fffb76d1..d94a9ac611 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java @@ -7,6 +7,7 @@ import net.okocraft.box.api.model.stock.StockHolder; import net.okocraft.box.api.util.TabCompleter; import net.okocraft.box.api.util.UserStockHolderOperator; +import net.okocraft.box.feature.gui.api.event.MenuOpenEvent; import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import net.okocraft.box.feature.gui.api.session.PlayerSession; import net.okocraft.box.feature.gui.api.util.MenuOpener; From 123b36701021c76acf47ca0d4d8ed7e513ef6fac Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 20 Jan 2022 23:37:01 +0900 Subject: [PATCH 14/53] change(gui): make processDeposit and processWithdraw public --- .../okocraft/box/feature/gui/internal/mode/StorageMode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java index cae3677b65..70cb582a0e 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java @@ -93,7 +93,7 @@ public final boolean canUse(@NotNull Player viewer) { ); } - private void processDeposit(@NotNull Context context) { + public void processDeposit(@NotNull Context context) { var player = context.clicker(); var session = PlayerSession.get(player); @@ -119,7 +119,7 @@ private void processDeposit(@NotNull Context context) { player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 100f, 1.0f); } - private void processWithdraw(@NotNull Context context) { + public void processWithdraw(@NotNull Context context) { var player = context.clicker(); var session = PlayerSession.get(player); From 667c5924637a70ed552659c58cad8ecca51cbdb4 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:18:04 +0900 Subject: [PATCH 15/53] change(gui): update to v4/develop --- .../okocraft/box/feature/gui/api/mode/ClickModeRegistry.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java index 38fd89e24d..800684fb31 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java @@ -10,12 +10,12 @@ public final class ClickModeRegistry { - private static final BoxItemClickMode STORAGE_MODE = new StorageMode(); + private static final StorageMode STORAGE_MODE = new StorageMode(); private static final List REGISTERED_BOX_ITEM_CLICK_MODE = new ArrayList<>(List.of(STORAGE_MODE)); private static List COPIED_REGISTERED_BOX_ITEM_CLICK_MODE = Collections.emptyList(); - public static @NotNull BoxItemClickMode getStorageMode() { + public static @NotNull StorageMode getStorageMode() { return STORAGE_MODE; } From 2eb91ad1eb5482f3aa56992d9249e44a9adc60c4 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:18:30 +0900 Subject: [PATCH 16/53] build(bemode): add bemode module --- features/bemode/build.gradle.kts | 8 ++++++++ settings.gradle.kts | 1 + 2 files changed, 9 insertions(+) create mode 100644 features/bemode/build.gradle.kts diff --git a/features/bemode/build.gradle.kts b/features/bemode/build.gradle.kts new file mode 100644 index 0000000000..74810222d8 --- /dev/null +++ b/features/bemode/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + id("box.feature-conventions") +} + +dependencies { + compileOnly(project(":api")) + compileOnly(project(":gui")) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 36be11c86c..05af2a8489 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,6 +15,7 @@ sequenceOf( // features sequenceOf( "autostore", + "bemode", "category", "command", "craft", From 79a0d41122ee2c3cf395dfaf2ea59d3f70e5bce3 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:21:34 +0900 Subject: [PATCH 17/53] feat(bemode): move BE features to bemode module --- .../box/feature/bemode/BEModeFeature.java | 48 +++++++++++ .../box/feature/bemode/lang/Displays.java | 47 +++++++++++ .../bemode/listener/MenuOpenListener.java | 26 ++++++ .../bemode/mode/StorageDepositMode.java | 84 +++++++++++++++++++ .../bemode/mode/StorageWithdrawMode.java | 84 +++++++++++++++++++ .../feature/bemode/util/BEPlayerChecker.java | 11 +++ 6 files changed, 300 insertions(+) create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/BEModeFeature.java create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/listener/MenuOpenListener.java create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/util/BEPlayerChecker.java diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/BEModeFeature.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/BEModeFeature.java new file mode 100644 index 0000000000..fbeaecf1ed --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/BEModeFeature.java @@ -0,0 +1,48 @@ +package net.okocraft.box.feature.bemode; + +import net.okocraft.box.api.BoxProvider; +import net.okocraft.box.api.feature.AbstractBoxFeature; +import net.okocraft.box.api.feature.BoxFeature; +import net.okocraft.box.feature.bemode.listener.MenuOpenListener; +import net.okocraft.box.feature.bemode.mode.StorageDepositMode; +import net.okocraft.box.feature.bemode.mode.StorageWithdrawMode; +import net.okocraft.box.feature.gui.GuiFeature; +import net.okocraft.box.feature.gui.api.event.MenuOpenEvent; +import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + +import java.util.Set; + +public class BEModeFeature extends AbstractBoxFeature { + + private final StorageDepositMode storageDepositMode = new StorageDepositMode(); + private final StorageWithdrawMode storageWithdrawMode = new StorageWithdrawMode(); + + public BEModeFeature() { + super("bemode"); + } + + @Override + public void enable() { + ClickModeRegistry.register(storageDepositMode); + ClickModeRegistry.register(storageWithdrawMode); + + BoxProvider.get().getEventBus() + .getHandlerList(MenuOpenEvent.class) + .subscribe(getListenerKey(), new MenuOpenListener()); + } + + @Override + public void disable() { + ClickModeRegistry.unregister(storageDepositMode); + ClickModeRegistry.unregister(storageWithdrawMode); + + BoxProvider.get().getEventBus().unsubscribeAll(getListenerKey()); + } + + @Override + public @NotNull @Unmodifiable Set> getDependencies() { + return Set.of(GuiFeature.class); + } +} diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java new file mode 100644 index 0000000000..ec70815603 --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java @@ -0,0 +1,47 @@ +package net.okocraft.box.feature.bemode.lang; + +import net.kyori.adventure.text.Component; +import net.okocraft.box.api.message.argument.SingleArgument; + +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.Component.translatable; +import static net.kyori.adventure.text.format.NamedTextColor.AQUA; +import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GRAY; + +public final class Displays { + + public static final Component STORAGE_DEPOSIT_MODE_DISPLAY_NAME = + translatable("box.bemode.storage-deposit-mode.display-name"); + + public static final Component STORAGE_WITHDRAW_MODE_DISPLAY_NAME = + translatable("box.bemode.storage-withdraw-mode.display-name"); + + + public static final SingleArgument STORAGE_DEPOSIT_MODE_CLICK_TO_DEPOSIT = + transactionUnit -> + translatable() + .key("box.bemode.storage-deposit-mode.click-to-deposit") + .args(text(transactionUnit, AQUA)) + .style(NO_DECORATION_GRAY) + .build(); + + public static final SingleArgument STORAGE_WITHDRAW_MODE_CLICK_TO_WITHDRAW = + transactionUnit -> + translatable() + .key("box.bemode.storage-withdraw-mode.click-to-withdraw") + .args(text(transactionUnit, AQUA)) + .style(NO_DECORATION_GRAY) + .build(); + + public static final SingleArgument STORAGE_MODE_CURRENT_STOCK = + stock -> + translatable() + .key("box.bemode.storage-mode.current-stock") + .args(text(stock, AQUA)) + .style(NO_DECORATION_GRAY) + .build(); + + private Displays() { + throw new UnsupportedOperationException(); + } +} diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/listener/MenuOpenListener.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/listener/MenuOpenListener.java new file mode 100644 index 0000000000..3550bdab49 --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/listener/MenuOpenListener.java @@ -0,0 +1,26 @@ +package net.okocraft.box.feature.bemode.listener; + +import com.github.siroshun09.event4j.listener.Listener; +import net.okocraft.box.feature.bemode.util.BEPlayerChecker; +import net.okocraft.box.feature.gui.api.event.MenuOpenEvent; +import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; +import net.okocraft.box.feature.gui.api.session.PlayerSession; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; + +public class MenuOpenListener implements Listener { + + @Override + public void handle(@NotNull MenuOpenEvent event) { + var viewer = event.getViewer(); + + if (BEPlayerChecker.isBEPlayer(viewer)) { + var session = PlayerSession.get(viewer); + + var copiedModes = new ArrayList<>(session.getAvailableClickModes()); + copiedModes.remove(ClickModeRegistry.getStorageMode()); + session.setAvailableClickModes(copiedModes); + } + } +} diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java new file mode 100644 index 0000000000..819a9853bb --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java @@ -0,0 +1,84 @@ +package net.okocraft.box.feature.bemode.mode; + +import net.kyori.adventure.text.Component; +import net.okocraft.box.api.model.item.BoxItem; +import net.okocraft.box.feature.bemode.lang.Displays; +import net.okocraft.box.feature.bemode.util.BEPlayerChecker; +import net.okocraft.box.feature.gui.api.menu.Menu; +import net.okocraft.box.feature.gui.api.mode.AdditionalButton; +import net.okocraft.box.feature.gui.api.mode.BoxItemClickMode; +import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; +import net.okocraft.box.feature.gui.api.session.PlayerSession; +import net.okocraft.box.feature.gui.api.util.TranslationUtil; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class StorageDepositMode implements BoxItemClickMode { + + private static final String TRANSACTION_AMOUNT_NAME = "transaction-amount"; + + @Override + public @NotNull String getName() { + return "storage-deposit"; + } + + @Override + public @NotNull Material getIconMaterial() { + return Material.CHEST; + } + + @Override + public @NotNull Component getDisplayName() { + return Displays.STORAGE_DEPOSIT_MODE_DISPLAY_NAME; + } + + @Override + public void onClick(@NotNull Context context) { + ClickModeRegistry.getStorageMode().processDeposit(context); + } + + @Override + public void applyIconMeta(@NotNull Player viewer, @NotNull BoxItem item, @NotNull ItemMeta target) { + var newLore = Optional.ofNullable(target.lore()).map(ArrayList::new).orElseGet(ArrayList::new); + + newLore.add(Component.empty()); + newLore.addAll(TranslationUtil.render(createLore(item, viewer), viewer)); + + target.lore(newLore); + } + + @Override + public boolean hasAdditionalButton() { + return false; + } + + @Override + public boolean canUse(@NotNull Player viewer) { + return BEPlayerChecker.isBEPlayer(viewer); + } + + @Override + public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { + throw new UnsupportedOperationException(); + } + + public @NotNull @Unmodifiable List createLore(@NotNull BoxItem item, @NotNull Player player) { + var session = PlayerSession.get(player); + + int currentStock = session.getStockHolder().getAmount(item); + int transactionAmount = session.getCustomNumberHolder(TRANSACTION_AMOUNT_NAME).getAmount(); + + return List.of( + Displays.STORAGE_DEPOSIT_MODE_CLICK_TO_DEPOSIT.apply(transactionAmount), + Component.empty(), + Displays.STORAGE_MODE_CURRENT_STOCK.apply(currentStock) + ); + } +} diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java new file mode 100644 index 0000000000..48248ef94b --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java @@ -0,0 +1,84 @@ +package net.okocraft.box.feature.bemode.mode; + +import net.kyori.adventure.text.Component; +import net.okocraft.box.api.model.item.BoxItem; +import net.okocraft.box.feature.bemode.lang.Displays; +import net.okocraft.box.feature.bemode.util.BEPlayerChecker; +import net.okocraft.box.feature.gui.api.menu.Menu; +import net.okocraft.box.feature.gui.api.mode.AdditionalButton; +import net.okocraft.box.feature.gui.api.mode.BoxItemClickMode; +import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; +import net.okocraft.box.feature.gui.api.session.PlayerSession; +import net.okocraft.box.feature.gui.api.util.TranslationUtil; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class StorageWithdrawMode implements BoxItemClickMode { + + private static final String TRANSACTION_AMOUNT_NAME = "transaction-amount"; + + @Override + public @NotNull String getName() { + return "storage-withdraw"; + } + + @Override + public @NotNull Material getIconMaterial() { + return Material.CHEST; + } + + @Override + public @NotNull Component getDisplayName() { + return Displays.STORAGE_WITHDRAW_MODE_DISPLAY_NAME; + } + + @Override + public void onClick(@NotNull Context context) { + ClickModeRegistry.getStorageMode().processWithdraw(context); + } + + @Override + public void applyIconMeta(@NotNull Player viewer, @NotNull BoxItem item, @NotNull ItemMeta target) { + var newLore = Optional.ofNullable(target.lore()).map(ArrayList::new).orElseGet(ArrayList::new); + + newLore.add(Component.empty()); + newLore.addAll(TranslationUtil.render(createLore(item, viewer), viewer)); + + target.lore(newLore); + } + + @Override + public boolean hasAdditionalButton() { + return false; + } + + @Override + public boolean canUse(@NotNull Player viewer) { + return BEPlayerChecker.isBEPlayer(viewer); + } + + @Override + public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { + throw new UnsupportedOperationException(); + } + + protected @NotNull @Unmodifiable List createLore(@NotNull BoxItem item, @NotNull Player player) { + var session = PlayerSession.get(player); + + int currentStock = session.getStockHolder().getAmount(item); + int transactionAmount = session.getCustomNumberHolder(TRANSACTION_AMOUNT_NAME).getAmount(); + + return List.of( + Displays.STORAGE_WITHDRAW_MODE_CLICK_TO_WITHDRAW.apply(transactionAmount), + Component.empty(), + Displays.STORAGE_MODE_CURRENT_STOCK.apply(currentStock) + ); + } +} diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/util/BEPlayerChecker.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/util/BEPlayerChecker.java new file mode 100644 index 0000000000..741460da48 --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/util/BEPlayerChecker.java @@ -0,0 +1,11 @@ +package net.okocraft.box.feature.bemode.util; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public final class BEPlayerChecker { + + public static boolean isBEPlayer(@NotNull Player player) { + return player.getUniqueId().toString().startsWith("00000000"); + } +} From f3f2e5b96348cae43ee09216fbba05448c98264d Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:21:40 +0900 Subject: [PATCH 18/53] chore(bundle): add bemode messages --- bundle/src/main/resources/en.yml | 7 +++++++ bundle/src/main/resources/ja_JP.yml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/bundle/src/main/resources/en.yml b/bundle/src/main/resources/en.yml index 27dcd3aa08..7958413eb3 100644 --- a/bundle/src/main/resources/en.yml +++ b/bundle/src/main/resources/en.yml @@ -43,6 +43,13 @@ box: left-click: "Press LMB to set all items to {0}" right-click: "Press RMB to set all items to {0}" recent: "Recent bulk change operation: {0}" + bemode: + storage-withdraw-mode: + display-name: "Storage mode (withdraw)" + click-to-withdraw: "Click to withdraw {0} items" + storage-deposit-mode: + display-name: "Storage mode (deposit)" + click-to-deposit: "Click to deposit {0} items" category: reloaded: "The category feature has been reloaded." name: diff --git a/bundle/src/main/resources/ja_JP.yml b/bundle/src/main/resources/ja_JP.yml index b29ed358a1..c0251660df 100644 --- a/bundle/src/main/resources/ja_JP.yml +++ b/bundle/src/main/resources/ja_JP.yml @@ -43,6 +43,13 @@ box: left-click: "左クリックですべて {0} にする" right-click: "右クリックですべて {0} にする" recent: "最近の一括変更操作: {0}" + bemode: + storage-withdraw-mode: + display-name: "収納モード (引き出し)" + click-to-withdraw: "クリックで {0} 個引き出す" + storage-deposit-mode: + display-name: "収納モード (預け入れ)" + click-to-deposit: "クリックで {0} 個預ける" category: reloaded: "カテゴリーを再読み込みしました。" name: From 815264c08b325a0749a9b79dbae96b257a46800c Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:22:17 +0900 Subject: [PATCH 19/53] build(bundle): include bemode module --- bundle/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/bundle/build.gradle.kts b/bundle/build.gradle.kts index 2e5cca8556..14e1e29ef5 100644 --- a/bundle/build.gradle.kts +++ b/bundle/build.gradle.kts @@ -9,6 +9,7 @@ dependencies { implementation(project(":api")) implementation(project(":core")) implementation(project(":autostore")) + implementation(project(":bemode")) implementation(project(":category")) implementation(project(":command")) implementation(project(":craft")) From 6766b41d032c9033bc17cb940e69d6299c04999e Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:23:22 +0900 Subject: [PATCH 20/53] feat(bundle): add bemode feature and reorder features --- .../src/main/java/net/okocraft/box/bundle/Bundled.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bundle/src/main/java/net/okocraft/box/bundle/Bundled.java b/bundle/src/main/java/net/okocraft/box/bundle/Bundled.java index 9b11f3c532..bd26bf7b91 100644 --- a/bundle/src/main/java/net/okocraft/box/bundle/Bundled.java +++ b/bundle/src/main/java/net/okocraft/box/bundle/Bundled.java @@ -2,20 +2,21 @@ import net.okocraft.box.api.feature.BoxFeature; import net.okocraft.box.feature.autostore.AutoStoreFeature; +import net.okocraft.box.feature.bemode.BEModeFeature; import net.okocraft.box.feature.category.CategoryFeature; import net.okocraft.box.feature.command.CommandFeature; import net.okocraft.box.feature.craft.CraftFeature; import net.okocraft.box.feature.gui.GuiFeature; -import net.okocraft.box.feature.stick.StickFeature; import net.okocraft.box.feature.notifier.NotifierFeature; +import net.okocraft.box.feature.stick.StickFeature; import java.util.List; final class Bundled { static final List FEATURES = - List.of(new CategoryFeature(), new CommandFeature(), new GuiFeature(), - new AutoStoreFeature(), new CraftFeature(), new StickFeature(), - new NotifierFeature()); + List.of(new CommandFeature(), new CategoryFeature(), new GuiFeature(), + new BEModeFeature(), new AutoStoreFeature(), new CraftFeature(), + new StickFeature(), new NotifierFeature()); } From 566108b9c407a72715c99b3cb27b1e7e8ebc92b7 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:52:26 +0900 Subject: [PATCH 21/53] change(bemode): change current-stock path --- bundle/src/main/resources/en.yml | 1 + bundle/src/main/resources/ja_JP.yml | 1 + .../java/net/okocraft/box/feature/bemode/lang/Displays.java | 4 ++-- .../okocraft/box/feature/bemode/mode/StorageDepositMode.java | 2 +- .../okocraft/box/feature/bemode/mode/StorageWithdrawMode.java | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bundle/src/main/resources/en.yml b/bundle/src/main/resources/en.yml index 7958413eb3..033b09201d 100644 --- a/bundle/src/main/resources/en.yml +++ b/bundle/src/main/resources/en.yml @@ -44,6 +44,7 @@ box: right-click: "Press RMB to set all items to {0}" recent: "Recent bulk change operation: {0}" bemode: + current-stock: "Current stock: {0}" storage-withdraw-mode: display-name: "Storage mode (withdraw)" click-to-withdraw: "Click to withdraw {0} items" diff --git a/bundle/src/main/resources/ja_JP.yml b/bundle/src/main/resources/ja_JP.yml index c0251660df..bf58235d5a 100644 --- a/bundle/src/main/resources/ja_JP.yml +++ b/bundle/src/main/resources/ja_JP.yml @@ -44,6 +44,7 @@ box: right-click: "右クリックですべて {0} にする" recent: "最近の一括変更操作: {0}" bemode: + current-stock: "現在の在庫数: {0} 個" storage-withdraw-mode: display-name: "収納モード (引き出し)" click-to-withdraw: "クリックで {0} 個引き出す" diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java index ec70815603..8dec46eab2 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java @@ -33,10 +33,10 @@ public final class Displays { .style(NO_DECORATION_GRAY) .build(); - public static final SingleArgument STORAGE_MODE_CURRENT_STOCK = + public static final SingleArgument CURRENT_STOCK = stock -> translatable() - .key("box.bemode.storage-mode.current-stock") + .key("box.bemode.current-stock") .args(text(stock, AQUA)) .style(NO_DECORATION_GRAY) .build(); diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java index 819a9853bb..e3dec03fbe 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java @@ -78,7 +78,7 @@ public boolean canUse(@NotNull Player viewer) { return List.of( Displays.STORAGE_DEPOSIT_MODE_CLICK_TO_DEPOSIT.apply(transactionAmount), Component.empty(), - Displays.STORAGE_MODE_CURRENT_STOCK.apply(currentStock) + Displays.CURRENT_STOCK.apply(currentStock) ); } } diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java index 48248ef94b..6e53dea576 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java @@ -78,7 +78,7 @@ public boolean canUse(@NotNull Player viewer) { return List.of( Displays.STORAGE_WITHDRAW_MODE_CLICK_TO_WITHDRAW.apply(transactionAmount), Component.empty(), - Displays.STORAGE_MODE_CURRENT_STOCK.apply(currentStock) + Displays.CURRENT_STOCK.apply(currentStock) ); } } From 458ae55381650cb8e9a64e9fe161e83ec6e7b6e3 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 00:52:37 +0900 Subject: [PATCH 22/53] feat(autostore): add double-click lore --- bundle/src/main/resources/en.yml | 4 +-- bundle/src/main/resources/ja_JP.yml | 8 +++--- .../autostore/gui/AutoStoreMenuDisplays.java | 26 ++++++++++--------- .../autostore/gui/AutoStoreSettingMenu.java | 19 +++++++------- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/bundle/src/main/resources/en.yml b/bundle/src/main/resources/en.yml index 033b09201d..270eeef692 100644 --- a/bundle/src/main/resources/en.yml +++ b/bundle/src/main/resources/en.yml @@ -40,8 +40,8 @@ box: toggle-button: "Click to set auto-store to {0}" bulk-editing: title: "Bulk change operation for per-item mode" - left-click: "Press LMB to set all items to {0}" - right-click: "Press RMB to set all items to {0}" + click: "Click to toggle all items to {0}" + double-click: "Double click to toggle all items to {0}" recent: "Recent bulk change operation: {0}" bemode: current-stock: "Current stock: {0}" diff --git a/bundle/src/main/resources/ja_JP.yml b/bundle/src/main/resources/ja_JP.yml index bf58235d5a..7fb28522d0 100644 --- a/bundle/src/main/resources/ja_JP.yml +++ b/bundle/src/main/resources/ja_JP.yml @@ -40,8 +40,8 @@ box: toggle-button: "クリックで自動収納機能を {0} にする" bulk-editing: title: "個別収納モード 一括変更" - left-click: "左クリックですべて {0} にする" - right-click: "右クリックですべて {0} にする" + click: "クリックですべて {0} に切り替え" + double-click: "ダブルクリックで {0} に切り替え" recent: "最近の一括変更操作: {0}" bemode: current-stock: "現在の在庫数: {0} 個" @@ -217,8 +217,8 @@ box: format: "{0} ({1}) {2} - ページを指定する" value: "<ページ数>" filter: - format: "{0} ({1}) {2} - アイテムを絞り込む" - value: "<アイテム名>" + format: "{0} ({1}) {2} - アイテムを絞り込む" + value: "<アイテム名>" set: success: sender: "プレイヤー {0} のアイテム {1} の在庫を {2} 個にセットしました。" diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java index 99f24dc985..a863ca8ea0 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java @@ -37,19 +37,21 @@ public class AutoStoreMenuDisplays { static final Component AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_TITLE = translatable("box.autostore.gui.setting-menu.bulk-editing.title", NO_DECORATION_GOLD); - static final Component AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_LEFT_CLICK = - translatable() - .key("box.autostore.gui.setting-menu.bulk-editing.left-click") - .args(AutoStoreMessage.ENABLED_NAME.apply(true)) - .style(NO_DECORATION_GRAY) - .build(); + static final SingleArgument AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_CLICK = + enabled -> + translatable() + .key("box.autostore.gui.setting-menu.bulk-editing.click") + .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .style(NO_DECORATION_GRAY) + .build(); - static final Component AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_RIGHT_CLICK = - translatable() - .key("box.autostore.gui.setting-menu.bulk-editing.right-click") - .args(AutoStoreMessage.ENABLED_NAME.apply(false)) - .style(NO_DECORATION_GRAY) - .build(); + static final SingleArgument AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_DOUBLE_CLICK = + enabled -> + translatable() + .key("box.autostore.gui.setting-menu.bulk-editing.double-click") + .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .style(NO_DECORATION_GRAY) + .build(); static final SingleArgument AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_RECENT = enabled -> diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java index 3f9842cb3f..1ad9184a83 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java @@ -184,8 +184,11 @@ public int getIconAmount() { var lore = new ArrayList(); lore.add(Component.empty()); - lore.add(AutoStoreMenuDisplays.AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_LEFT_CLICK); - lore.add(AutoStoreMenuDisplays.AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_RIGHT_CLICK); + + boolean nextClick = recent == null || !recent; + + lore.add(AutoStoreMenuDisplays.AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_CLICK.apply(nextClick)); + lore.add(AutoStoreMenuDisplays.AUTOSTORE_MODE_SETTING_MENU_BULK_EDITING_DOUBLE_CLICK.apply(!nextClick)); lore.add(Component.empty()); if (recent != null) { @@ -206,15 +209,13 @@ public int getSlot() { @Override public void onClick(@NotNull Player clicker, @NotNull ClickType clickType) { var perItemSetting = setting.getPerItemModeSetting(); - Sound sound = null; + Sound sound; - if (clickType.isLeftClick()) { + if (recent == null || !recent) { perItemSetting.setEnabledItems(BoxProvider.get().getItemManager().getBoxItemSet()); sound = Sound.BLOCK_WOODEN_DOOR_OPEN; recent = true; - } - - if (clickType.isRightClick()) { + } else { perItemSetting.setEnabledItems(Collections.emptyList()); sound = Sound.BLOCK_WOODEN_DOOR_CLOSE; recent = false; @@ -228,9 +229,7 @@ public void onClick(@NotNull Player clicker, @NotNull ClickType clickType) { setting.setAllMode(false); } - if (sound != null) { - clicker.playSound(clicker.getLocation(), sound, 100f, 1.5f); - } + clicker.playSound(clicker.getLocation(), sound, 100f, 1.5f); } } } From c2e6846a35d35e3274f9cd7449fb3de5332012e0 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 01:54:44 +0900 Subject: [PATCH 23/53] feat(bemode): add deposit-all button and create AbstractStorageMode --- .../box/feature/bemode/lang/Displays.java | 13 +- .../bemode/mode/AbstractStorageMode.java | 136 ++++++++++++++++++ .../bemode/mode/StorageDepositMode.java | 59 +------- .../bemode/mode/StorageWithdrawMode.java | 59 +------- 4 files changed, 154 insertions(+), 113 deletions(-) create mode 100644 features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/AbstractStorageMode.java diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java index 8dec46eab2..dd23ceb8d1 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java @@ -6,6 +6,7 @@ import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; import static net.kyori.adventure.text.format.NamedTextColor.AQUA; +import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GOLD; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GRAY; public final class Displays { @@ -40,7 +41,17 @@ public final class Displays { .args(text(stock, AQUA)) .style(NO_DECORATION_GRAY) .build(); - + + public static final Component DEPOSIT_ALL_BUTTON_DISPLAY_NAME = + translatable("box.bemode.deposit-all.display-name", NO_DECORATION_GOLD); + + public static final Component DEPOSIT_ALL_BUTTON_LORE = + translatable("box.bemode.deposit-all.lore", NO_DECORATION_GRAY); + + public static final Component DEPOSIT_ALL_BUTTON_CONFIRMATION = + translatable("box.bemode.deposit-all.confirmation", NO_DECORATION_GRAY); + + private Displays() { throw new UnsupportedOperationException(); } diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/AbstractStorageMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/AbstractStorageMode.java new file mode 100644 index 0000000000..26e652034b --- /dev/null +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/AbstractStorageMode.java @@ -0,0 +1,136 @@ +package net.okocraft.box.feature.bemode.mode; + +import net.kyori.adventure.text.Component; +import net.okocraft.box.api.BoxProvider; +import net.okocraft.box.api.model.item.BoxItem; +import net.okocraft.box.api.transaction.InventoryTransaction; +import net.okocraft.box.feature.bemode.lang.Displays; +import net.okocraft.box.feature.bemode.util.BEPlayerChecker; +import net.okocraft.box.feature.gui.api.button.RefreshableButton; +import net.okocraft.box.feature.gui.api.menu.Menu; +import net.okocraft.box.feature.gui.api.mode.AdditionalButton; +import net.okocraft.box.feature.gui.api.mode.BoxItemClickMode; +import net.okocraft.box.feature.gui.api.session.PlayerSession; +import net.okocraft.box.feature.gui.api.util.TranslationUtil; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public abstract class AbstractStorageMode implements BoxItemClickMode { + + protected static final String TRANSACTION_AMOUNT_NAME = "transaction-amount"; + + @Override + public @NotNull Material getIconMaterial() { + return Material.CHEST; + } + + @Override + public void applyIconMeta(@NotNull Player viewer, @NotNull BoxItem item, @NotNull ItemMeta target) { + var newLore = Optional.ofNullable(target.lore()).map(ArrayList::new).orElseGet(ArrayList::new); + + var session = PlayerSession.get(viewer); + var additionalLore = List.of( + Component.empty(), + getButtonInformationLore(session), + Component.empty(), + Displays.CURRENT_STOCK.apply(session.getStockHolder().getAmount(item)) + ); + + newLore.addAll(TranslationUtil.render(additionalLore, viewer)); + + target.lore(newLore); + } + + @Override + public boolean hasAdditionalButton() { + return true; + } + + @Override + public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { + return new DepositAllButton(); + } + + @Override + public boolean canUse(@NotNull Player viewer) { + return BEPlayerChecker.isBEPlayer(viewer); + } + + protected abstract @NotNull Component getButtonInformationLore(@NotNull PlayerSession session); + + private static class DepositAllButton extends AdditionalButton implements RefreshableButton { + + private boolean clicked; + + @Override + public @NotNull Material getIconMaterial() { + return Material.NETHER_STAR; + } + + @Override + public int getIconAmount() { + return 1; + } + + @Override + public @Nullable ItemMeta applyIconMeta(@NotNull Player viewer, @NotNull ItemMeta target) { + target.displayName(TranslationUtil.render(Displays.DEPOSIT_ALL_BUTTON_DISPLAY_NAME, viewer)); + + var lore = new ArrayList(); + + lore.add(Component.empty()); + lore.add(TranslationUtil.render(Displays.DEPOSIT_ALL_BUTTON_LORE, viewer)); + + if (clicked) { + lore.add(TranslationUtil.render(Displays.DEPOSIT_ALL_BUTTON_CONFIRMATION, viewer)); + } + + lore.add(Component.empty()); + + target.lore(lore); + + return target; + } + + @SuppressWarnings("DuplicatedCode") + @Override + public void onClick(@NotNull Player clicker, @NotNull ClickType clickType) { + if (clicked) { + clicked = false; + } else { + clicked = true; + return; + } + + var resultList = + BoxProvider.get().getTaskFactory() + .supply(() -> InventoryTransaction.depositItemsInInventory(clicker.getInventory())) + .join(); + + if (!resultList.getType().isModified()) { + clicker.playSound(clicker.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 100f, 1.5f); + return; + } + + var stockHolder = PlayerSession.get(clicker).getStockHolder(); + + resultList.getResultList() + .stream() + .filter(result -> result.getType().isModified()) + .forEach(result -> stockHolder.increase(result.getItem(), result.getAmount())); + + clicked = false; + + clicker.playSound(clicker.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 100f, 2.0f); + } + } +} diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java index e3dec03fbe..70ded14027 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageDepositMode.java @@ -1,39 +1,18 @@ package net.okocraft.box.feature.bemode.mode; import net.kyori.adventure.text.Component; -import net.okocraft.box.api.model.item.BoxItem; import net.okocraft.box.feature.bemode.lang.Displays; -import net.okocraft.box.feature.bemode.util.BEPlayerChecker; -import net.okocraft.box.feature.gui.api.menu.Menu; -import net.okocraft.box.feature.gui.api.mode.AdditionalButton; -import net.okocraft.box.feature.gui.api.mode.BoxItemClickMode; import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import net.okocraft.box.feature.gui.api.session.PlayerSession; -import net.okocraft.box.feature.gui.api.util.TranslationUtil; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public class StorageDepositMode implements BoxItemClickMode { - - private static final String TRANSACTION_AMOUNT_NAME = "transaction-amount"; +public class StorageDepositMode extends AbstractStorageMode { @Override public @NotNull String getName() { return "storage-deposit"; } - @Override - public @NotNull Material getIconMaterial() { - return Material.CHEST; - } - @Override public @NotNull Component getDisplayName() { return Displays.STORAGE_DEPOSIT_MODE_DISPLAY_NAME; @@ -45,40 +24,8 @@ public void onClick(@NotNull Context context) { } @Override - public void applyIconMeta(@NotNull Player viewer, @NotNull BoxItem item, @NotNull ItemMeta target) { - var newLore = Optional.ofNullable(target.lore()).map(ArrayList::new).orElseGet(ArrayList::new); - - newLore.add(Component.empty()); - newLore.addAll(TranslationUtil.render(createLore(item, viewer), viewer)); - - target.lore(newLore); - } - - @Override - public boolean hasAdditionalButton() { - return false; - } - - @Override - public boolean canUse(@NotNull Player viewer) { - return BEPlayerChecker.isBEPlayer(viewer); - } - - @Override - public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { - throw new UnsupportedOperationException(); - } - - public @NotNull @Unmodifiable List createLore(@NotNull BoxItem item, @NotNull Player player) { - var session = PlayerSession.get(player); - - int currentStock = session.getStockHolder().getAmount(item); + protected @NotNull Component getButtonInformationLore(@NotNull PlayerSession session) { int transactionAmount = session.getCustomNumberHolder(TRANSACTION_AMOUNT_NAME).getAmount(); - - return List.of( - Displays.STORAGE_DEPOSIT_MODE_CLICK_TO_DEPOSIT.apply(transactionAmount), - Component.empty(), - Displays.CURRENT_STOCK.apply(currentStock) - ); + return Displays.STORAGE_DEPOSIT_MODE_CLICK_TO_DEPOSIT.apply(transactionAmount); } } diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java index 6e53dea576..1b25c995b6 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/mode/StorageWithdrawMode.java @@ -1,39 +1,18 @@ package net.okocraft.box.feature.bemode.mode; import net.kyori.adventure.text.Component; -import net.okocraft.box.api.model.item.BoxItem; import net.okocraft.box.feature.bemode.lang.Displays; -import net.okocraft.box.feature.bemode.util.BEPlayerChecker; -import net.okocraft.box.feature.gui.api.menu.Menu; -import net.okocraft.box.feature.gui.api.mode.AdditionalButton; -import net.okocraft.box.feature.gui.api.mode.BoxItemClickMode; import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import net.okocraft.box.feature.gui.api.session.PlayerSession; -import net.okocraft.box.feature.gui.api.util.TranslationUtil; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -public class StorageWithdrawMode implements BoxItemClickMode { - - private static final String TRANSACTION_AMOUNT_NAME = "transaction-amount"; +public class StorageWithdrawMode extends AbstractStorageMode { @Override public @NotNull String getName() { return "storage-withdraw"; } - @Override - public @NotNull Material getIconMaterial() { - return Material.CHEST; - } - @Override public @NotNull Component getDisplayName() { return Displays.STORAGE_WITHDRAW_MODE_DISPLAY_NAME; @@ -45,40 +24,8 @@ public void onClick(@NotNull Context context) { } @Override - public void applyIconMeta(@NotNull Player viewer, @NotNull BoxItem item, @NotNull ItemMeta target) { - var newLore = Optional.ofNullable(target.lore()).map(ArrayList::new).orElseGet(ArrayList::new); - - newLore.add(Component.empty()); - newLore.addAll(TranslationUtil.render(createLore(item, viewer), viewer)); - - target.lore(newLore); - } - - @Override - public boolean hasAdditionalButton() { - return false; - } - - @Override - public boolean canUse(@NotNull Player viewer) { - return BEPlayerChecker.isBEPlayer(viewer); - } - - @Override - public @NotNull AdditionalButton createAdditionalButton(@NotNull Player viewer, @NotNull Menu currentMenu) { - throw new UnsupportedOperationException(); - } - - protected @NotNull @Unmodifiable List createLore(@NotNull BoxItem item, @NotNull Player player) { - var session = PlayerSession.get(player); - - int currentStock = session.getStockHolder().getAmount(item); + protected @NotNull Component getButtonInformationLore(@NotNull PlayerSession session) { int transactionAmount = session.getCustomNumberHolder(TRANSACTION_AMOUNT_NAME).getAmount(); - - return List.of( - Displays.STORAGE_WITHDRAW_MODE_CLICK_TO_WITHDRAW.apply(transactionAmount), - Component.empty(), - Displays.CURRENT_STOCK.apply(currentStock) - ); + return Displays.STORAGE_WITHDRAW_MODE_CLICK_TO_WITHDRAW.apply(transactionAmount); } } From 15a299839f4ef2a8e4d431be9d365263479a593f Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 01:55:08 +0900 Subject: [PATCH 24/53] change(gui): add `@SuppressWarnings("DuplicatedCode")` --- .../net/okocraft/box/feature/gui/internal/mode/StorageMode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java index 70cb582a0e..8e648130be 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/mode/StorageMode.java @@ -174,6 +174,7 @@ public int getIconAmount() { return target; } + @SuppressWarnings("DuplicatedCode") @Override public void onClick(@NotNull Player clicker, @NotNull ClickType clickType) { if (!clickType.isShiftClick()) { From 68d34838ac75da70739ac79fe52b93d3c261e118 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 01:55:29 +0900 Subject: [PATCH 25/53] chore(bundle): add deposit-all --- bundle/src/main/resources/en.yml | 4 ++++ bundle/src/main/resources/ja_JP.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/bundle/src/main/resources/en.yml b/bundle/src/main/resources/en.yml index 270eeef692..cd8c89b2f6 100644 --- a/bundle/src/main/resources/en.yml +++ b/bundle/src/main/resources/en.yml @@ -51,6 +51,10 @@ box: storage-deposit-mode: display-name: "Storage mode (deposit)" click-to-deposit: "Click to deposit {0} items" + deposit-all: + display-name: "Deposits all items" + lore: "Double click to deposit" + confirmation: "Please click again to confirm" category: reloaded: "The category feature has been reloaded." name: diff --git a/bundle/src/main/resources/ja_JP.yml b/bundle/src/main/resources/ja_JP.yml index 7fb28522d0..956f68a378 100644 --- a/bundle/src/main/resources/ja_JP.yml +++ b/bundle/src/main/resources/ja_JP.yml @@ -51,6 +51,10 @@ box: storage-deposit-mode: display-name: "収納モード (預け入れ)" click-to-deposit: "クリックで {0} 個預ける" + deposit-all: + display-name: "すべて預ける" + lore: "ダブルクリックですべて預ける" + confirmation: "確認のためもう一度クリックしてください" category: reloaded: "カテゴリーを再読み込みしました。" name: From de47d310226d5710c7fe261cb127957329de4b43 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 09:07:20 +0900 Subject: [PATCH 26/53] docs(api): add package-info.java --- .../net/okocraft/box/api/command/base/package-info.java | 5 +++++ .../java/net/okocraft/box/api/command/package-info.java | 4 ++++ .../net/okocraft/box/api/event/feature/package-info.java | 4 ++++ .../net/okocraft/box/api/event/general/package-info.java | 4 ++++ .../java/net/okocraft/box/api/event/item/package-info.java | 4 ++++ .../main/java/net/okocraft/box/api/event/package-info.java | 4 ++++ .../net/okocraft/box/api/event/player/package-info.java | 4 ++++ .../net/okocraft/box/api/event/stock/package-info.java | 4 ++++ .../okocraft/box/api/event/stockholder/package-info.java | 4 ++++ .../java/net/okocraft/box/api/feature/package-info.java | 4 ++++ .../okocraft/box/api/message/argument/package-info.java | 4 ++++ .../java/net/okocraft/box/api/message/package-info.java | 4 ++++ .../java/net/okocraft/box/api/model/data/package-info.java | 4 ++++ .../java/net/okocraft/box/api/model/item/package-info.java | 5 +++++ .../net/okocraft/box/api/model/manager/package-info.java | 7 +++++++ .../net/okocraft/box/api/model/stock/package-info.java | 4 ++++ .../java/net/okocraft/box/api/model/user/package-info.java | 4 ++++ api/src/main/java/net/okocraft/box/api/package-info.java | 4 ++++ .../java/net/okocraft/box/api/player/package-info.java | 5 +++++ .../net/okocraft/box/api/taskfactory/package-info.java | 4 ++++ .../net/okocraft/box/api/transaction/package-info.java | 4 ++++ .../main/java/net/okocraft/box/api/util/package-info.java | 4 ++++ 22 files changed, 94 insertions(+) create mode 100644 api/src/main/java/net/okocraft/box/api/command/base/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/command/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/feature/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/general/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/item/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/player/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/stock/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/event/stockholder/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/feature/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/message/argument/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/message/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/model/data/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/model/item/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/model/manager/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/model/stock/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/model/user/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/player/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/taskfactory/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/transaction/package-info.java create mode 100644 api/src/main/java/net/okocraft/box/api/util/package-info.java diff --git a/api/src/main/java/net/okocraft/box/api/command/base/package-info.java b/api/src/main/java/net/okocraft/box/api/command/base/package-info.java new file mode 100644 index 0000000000..d4d2f1a148 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/command/base/package-info.java @@ -0,0 +1,5 @@ +/** + * A package that includes {@link net.okocraft.box.api.command.base.BoxCommand} ({@code /box}) and + * {@link net.okocraft.box.api.command.base.BoxAdminCommand} ({@code /boxadmin}). + */ +package net.okocraft.box.api.command.base; diff --git a/api/src/main/java/net/okocraft/box/api/command/package-info.java b/api/src/main/java/net/okocraft/box/api/command/package-info.java new file mode 100644 index 0000000000..47f73fbc56 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/command/package-info.java @@ -0,0 +1,4 @@ +/** + * A package that includes command interfaces. + */ +package net.okocraft.box.api.command; diff --git a/api/src/main/java/net/okocraft/box/api/event/feature/package-info.java b/api/src/main/java/net/okocraft/box/api/event/feature/package-info.java new file mode 100644 index 0000000000..f71de80914 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/feature/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.feature.BoxFeature} related events. + */ +package net.okocraft.box.api.event.feature; diff --git a/api/src/main/java/net/okocraft/box/api/event/general/package-info.java b/api/src/main/java/net/okocraft/box/api/event/general/package-info.java new file mode 100644 index 0000000000..f438844786 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/general/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of general events. + */ +package net.okocraft.box.api.event.general; diff --git a/api/src/main/java/net/okocraft/box/api/event/item/package-info.java b/api/src/main/java/net/okocraft/box/api/event/item/package-info.java new file mode 100644 index 0000000000..b3948cfaca --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/item/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.model.item.BoxItem} related events. + */ +package net.okocraft.box.api.event.item; diff --git a/api/src/main/java/net/okocraft/box/api/event/package-info.java b/api/src/main/java/net/okocraft/box/api/event/package-info.java new file mode 100644 index 0000000000..3bba28665c --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/package-info.java @@ -0,0 +1,4 @@ +/** + * A package that includes Box's events. + */ +package net.okocraft.box.api.event; diff --git a/api/src/main/java/net/okocraft/box/api/event/player/package-info.java b/api/src/main/java/net/okocraft/box/api/event/player/package-info.java new file mode 100644 index 0000000000..fe04d58cf2 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/player/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.player.BoxPlayer} related events. + */ +package net.okocraft.box.api.event.player; diff --git a/api/src/main/java/net/okocraft/box/api/event/stock/package-info.java b/api/src/main/java/net/okocraft/box/api/event/stock/package-info.java new file mode 100644 index 0000000000..5512085856 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/stock/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of stock related events. + */ +package net.okocraft.box.api.event.stock; diff --git a/api/src/main/java/net/okocraft/box/api/event/stockholder/package-info.java b/api/src/main/java/net/okocraft/box/api/event/stockholder/package-info.java new file mode 100644 index 0000000000..bcc9420424 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/event/stockholder/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.model.stock.StockHolder} related events. + */ +package net.okocraft.box.api.event.stockholder; diff --git a/api/src/main/java/net/okocraft/box/api/feature/package-info.java b/api/src/main/java/net/okocraft/box/api/feature/package-info.java new file mode 100644 index 0000000000..8d517f4809 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/feature/package-info.java @@ -0,0 +1,4 @@ +/** + * A package that includes {@link net.okocraft.box.api.feature.BoxFeature} interfaces. + */ +package net.okocraft.box.api.feature; diff --git a/api/src/main/java/net/okocraft/box/api/message/argument/package-info.java b/api/src/main/java/net/okocraft/box/api/message/argument/package-info.java new file mode 100644 index 0000000000..54d663dc98 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/message/argument/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of interfaces to create {@link net.kyori.adventure.text.Component} from arguments. + */ +package net.okocraft.box.api.message.argument; diff --git a/api/src/main/java/net/okocraft/box/api/message/package-info.java b/api/src/main/java/net/okocraft/box/api/message/package-info.java new file mode 100644 index 0000000000..6029d82887 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/message/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.message.GeneralMessage}. + */ +package net.okocraft.box.api.message; diff --git a/api/src/main/java/net/okocraft/box/api/model/data/package-info.java b/api/src/main/java/net/okocraft/box/api/model/data/package-info.java new file mode 100644 index 0000000000..ed6273358b --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/model/data/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.model.data.CustomDataContainer}. + */ +package net.okocraft.box.api.model.data; diff --git a/api/src/main/java/net/okocraft/box/api/model/item/package-info.java b/api/src/main/java/net/okocraft/box/api/model/item/package-info.java new file mode 100644 index 0000000000..415feba7d7 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/model/item/package-info.java @@ -0,0 +1,5 @@ +/** + * A package of {@link net.okocraft.box.api.model.item.BoxItem} and + * {@link net.okocraft.box.api.model.item.BoxCustomItem}. + */ +package net.okocraft.box.api.model.item; diff --git a/api/src/main/java/net/okocraft/box/api/model/manager/package-info.java b/api/src/main/java/net/okocraft/box/api/model/manager/package-info.java new file mode 100644 index 0000000000..9855412a9a --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/model/manager/package-info.java @@ -0,0 +1,7 @@ +/** + * A package that includes manager interfaces of models + * such as {@link net.okocraft.box.api.model.user.BoxUser}, + * {@link net.okocraft.box.api.model.item.BoxItem}, + * and {@link net.okocraft.box.api.model.stock.StockHolder}. + */ +package net.okocraft.box.api.model.manager; diff --git a/api/src/main/java/net/okocraft/box/api/model/stock/package-info.java b/api/src/main/java/net/okocraft/box/api/model/stock/package-info.java new file mode 100644 index 0000000000..31c6969a80 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/model/stock/package-info.java @@ -0,0 +1,4 @@ +/** + * A package that includes interfaces that indicates the user's stock. + */ +package net.okocraft.box.api.model.stock; diff --git a/api/src/main/java/net/okocraft/box/api/model/user/package-info.java b/api/src/main/java/net/okocraft/box/api/model/user/package-info.java new file mode 100644 index 0000000000..d5b7159b2b --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/model/user/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of {@link net.okocraft.box.api.model.user.BoxUser}. + */ +package net.okocraft.box.api.model.user; diff --git a/api/src/main/java/net/okocraft/box/api/package-info.java b/api/src/main/java/net/okocraft/box/api/package-info.java new file mode 100644 index 0000000000..a0f14c607e --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/package-info.java @@ -0,0 +1,4 @@ +/** + * The root package of Box. + */ +package net.okocraft.box.api; diff --git a/api/src/main/java/net/okocraft/box/api/player/package-info.java b/api/src/main/java/net/okocraft/box/api/player/package-info.java new file mode 100644 index 0000000000..2018db751a --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/player/package-info.java @@ -0,0 +1,5 @@ +/** + * A package that includes {@link net.okocraft.box.api.player.BoxPlayer} and + * {@link net.okocraft.box.api.player.BoxPlayerMap}. + */ +package net.okocraft.box.api.player; diff --git a/api/src/main/java/net/okocraft/box/api/taskfactory/package-info.java b/api/src/main/java/net/okocraft/box/api/taskfactory/package-info.java new file mode 100644 index 0000000000..f4a0c9664b --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/taskfactory/package-info.java @@ -0,0 +1,4 @@ +/** + * A package that includes {@link net.okocraft.box.api.taskfactory.TaskFactory}. + */ +package net.okocraft.box.api.taskfactory; diff --git a/api/src/main/java/net/okocraft/box/api/transaction/package-info.java b/api/src/main/java/net/okocraft/box/api/transaction/package-info.java new file mode 100644 index 0000000000..47dfebd520 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/transaction/package-info.java @@ -0,0 +1,4 @@ +/** + * A package that includes classes for adding/removing items to/from the inventory. + */ +package net.okocraft.box.api.transaction; diff --git a/api/src/main/java/net/okocraft/box/api/util/package-info.java b/api/src/main/java/net/okocraft/box/api/util/package-info.java new file mode 100644 index 0000000000..e61d27c589 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/util/package-info.java @@ -0,0 +1,4 @@ +/** + * A package of utility classes. + */ +package net.okocraft.box.api.util; From 67c159bee4df4c5e3d7bea37bf5f91d1f6e60974 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 09:37:59 +0900 Subject: [PATCH 27/53] feat(api): add Components class to help reduce the code --- .../okocraft/box/api/message/Components.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 api/src/main/java/net/okocraft/box/api/message/Components.java diff --git a/api/src/main/java/net/okocraft/box/api/message/Components.java b/api/src/main/java/net/okocraft/box/api/message/Components.java new file mode 100644 index 0000000000..5d2c11dcc9 --- /dev/null +++ b/api/src/main/java/net/okocraft/box/api/message/Components.java @@ -0,0 +1,130 @@ +package net.okocraft.box.api.message; + +import net.kyori.adventure.text.Component; +import net.okocraft.box.api.model.item.BoxItem; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +import static net.kyori.adventure.text.Component.text; +import static net.kyori.adventure.text.Component.translatable; +import static net.kyori.adventure.text.format.NamedTextColor.AQUA; +import static net.kyori.adventure.text.format.NamedTextColor.BLACK; +import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.GRAY; +import static net.kyori.adventure.text.format.NamedTextColor.GREEN; +import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.kyori.adventure.text.format.NamedTextColor.WHITE; + +public final class Components { + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component grayText(@NotNull String text) { + return text(text, GRAY); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component aquaText(@NotNull String text) { + return text(text, AQUA); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component whiteText(@NotNull String text) { + return text(text, WHITE); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component grayText(int value) { + return text(value, GRAY); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component aquaText(int value) { + return text(value, AQUA); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component redText(int value) { + return text(value, RED); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component whiteText(int value) { + return text(value, WHITE); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component grayTranslatable(@NotNull String key) { + return translatable(key, GRAY); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component aquaTranslatable(@NotNull String key) { + return translatable(key, AQUA); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component redTranslatable(@NotNull String key) { + return translatable(key, RED); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component greenTranslatable(@NotNull String key) { + return translatable(key, GREEN); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component blackTranslatable(@NotNull String key) { + return translatable(key, BLACK); + } + + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull Component grayTranslatable(@NotNull String key, @NotNull Component... args) { + return translatable().key(key).args(args).color(GRAY).build(); + } + + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull Component aquaTranslatable(@NotNull String key, @NotNull Component... args) { + return translatable().key(key).args(args).color(AQUA).build(); + } + + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull Component redTranslatable(@NotNull String key, @NotNull Component... args) { + return translatable().key(key).args(args).color(RED).build(); + } + + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull Component greenTranslatable(@NotNull String key, @NotNull Component... args) { + return translatable().key(key).args(args).color(GREEN).build(); + } + + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull Component blackTranslatable(@NotNull String key, @NotNull Component... args) { + return translatable().key(key).args(args).color(BLACK).build(); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component aquaItemName(@NotNull BoxItem item) { + return item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component aquaItemName(@NotNull ItemStack item) { + return item.displayName().color(AQUA).hoverEvent(item); + } + + @Contract(value = "_ -> new", pure = true) + public static @NotNull Component commandHelp(@NotNull String keyPrefix) { + return commandHelp(keyPrefix, true); + } + + @Contract(value = "_, _ -> new", pure = true) + public static @NotNull Component commandHelp(@NotNull String keyPrefix, boolean appendHelp) { + keyPrefix = appendHelp ? keyPrefix + ".help" : keyPrefix; + return text() + .append(aquaTranslatable(keyPrefix + ".command-line")) + .append(text(" - ", DARK_GRAY)) + .append(grayTranslatable(keyPrefix + ".description")) + .build(); + } +} From 14fb5f8dd7844e1f7751e87990f095bf173929bd Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 09:38:08 +0900 Subject: [PATCH 28/53] refactor(*): refactor messages --- .../box/api/message/GeneralMessage.java | 53 +-- .../box/core/command/BoxAdminCommandImpl.java | 12 +- .../box/core/command/BoxCommandImpl.java | 12 +- .../box/core/message/ErrorMessages.java | 32 +- .../box/core/message/MicsMessages.java | 9 +- .../autostore/gui/AutoStoreMenuDisplays.java | 15 +- .../autostore/gui/AutoStoreSettingMenu.java | 2 +- .../autostore/message/AutoStoreMessage.java | 105 ++--- .../box/feature/bemode/lang/Displays.java | 9 +- .../box/feature/category/CategoryFeature.java | 5 +- .../command/message/BoxAdminMessage.java | 417 ++++++------------ .../feature/command/message/BoxMessage.java | 176 +++----- .../box/feature/craft/CraftFeature.java | 5 +- .../box/feature/craft/lang/Displays.java | 50 +-- .../okocraft/box/feature/gui/GuiFeature.java | 5 +- .../gui/internal/command/MenuOpenCommand.java | 15 +- .../feature/gui/internal/lang/Displays.java | 27 +- .../notifier/factory/NotificationFactory.java | 11 +- .../stick/command/CustomStickCommand.java | 35 +- .../feature/stick/command/StickCommand.java | 22 +- 20 files changed, 321 insertions(+), 696 deletions(-) diff --git a/api/src/main/java/net/okocraft/box/api/message/GeneralMessage.java b/api/src/main/java/net/okocraft/box/api/message/GeneralMessage.java index 83ec649d2a..2b516e0d44 100644 --- a/api/src/main/java/net/okocraft/box/api/message/GeneralMessage.java +++ b/api/src/main/java/net/okocraft/box/api/message/GeneralMessage.java @@ -5,10 +5,8 @@ import org.bukkit.World; import org.bukkit.entity.Player; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.redTranslatable; /** * A class that holds general messages @@ -19,83 +17,60 @@ public final class GeneralMessage { * A message sent when an executor don't have a permission. */ public static final SingleArgument ERROR_NO_PERMISSION = - node -> translatable("box.error.no-permission", RED).args(text(node, AQUA)); + node -> redTranslatable("box.error.no-permission", aquaText(node)); /** * A message sent when an executor of the command is not a player. */ - public static final Component ERROR_COMMAND_ONLY_PLAYER = translatable("box.error.command.only-player", RED); + public static final Component ERROR_COMMAND_ONLY_PLAYER = + redTranslatable("box.error.command.only-player"); /** * A message sent when the subcommand not found. */ public static final Component ERROR_COMMAND_SUBCOMMAND_NOT_FOUND = - translatable("box.error.command.subcommand-not-found", RED); + redTranslatable("box.error.command.subcommand-not-found"); /** * A message sent when arguments are not enough. */ public static final Component ERROR_COMMAND_NOT_ENOUGH_ARGUMENT = - translatable("box.error.command.not-enough-argument", RED); + redTranslatable("box.error.command.not-enough-argument"); /** * A message sent when the specified player was not found. */ public static final SingleArgument ERROR_COMMAND_PLAYER_NOT_FOUND = - playerName -> - translatable() - .key("box.error.command.player-not-found") - .args(text(playerName, AQUA)) - .color(RED) - .build(); + playerName -> redTranslatable("box.error.command.player-not-found", aquaText(playerName)); /** * A message sent when the specified item was not found. */ public static final SingleArgument ERROR_COMMAND_ITEM_NOT_FOUND = - itemName -> - translatable() - .key("box.error.command.item-not-found") - .args(text(itemName, AQUA)) - .color(RED) - .build(); + itemName -> redTranslatable("box.error.command.item-not-found", aquaText(itemName)); /** * A message sent when the specified number is invalid. */ public static final SingleArgument ERROR_COMMAND_INVALID_NUMBER = - invalid -> - translatable() - .key("box.error.command.invalid-number") - .args(text(invalid, AQUA)) - .color(RED) - .build(); + invalid -> redTranslatable("box.error.command.invalid-number", aquaText(invalid)); /** * A message sent when Box is disabled in that world. */ public static final SingleArgument ERROR_DISABLED_WORLD = - world -> - translatable() - .key("box.error.disabled-world") - .args(text(world.getName(), AQUA)) - .color(RED) - .build(); + world -> redTranslatable("box.error.disabled-world", aquaText(world.getName())); /** * A message sent when the player is not loaded. */ public static final Component ERROR_PLAYER_NOT_LOADED = - translatable("box.error.player-data.not-loaded.self", RED); + redTranslatable("box.error.player-data.not-loaded.self"); /** * A message sent when the targeted player is not loaded. */ public static final SingleArgument ERROR_TARGET_PLAYER_NOT_LOADED = - target -> - translatable() - .key("box.error.player-data.not-loaded.other") - .args(text(target.getName(), AQUA)) - .color(RED) - .build(); + target -> redTranslatable("box.error.player-data.not-loaded.other", aquaText(target.getName())); + } diff --git a/core/src/main/java/net/okocraft/box/core/command/BoxAdminCommandImpl.java b/core/src/main/java/net/okocraft/box/core/command/BoxAdminCommandImpl.java index 223b116874..7216bdee12 100644 --- a/core/src/main/java/net/okocraft/box/core/command/BoxAdminCommandImpl.java +++ b/core/src/main/java/net/okocraft/box/core/command/BoxAdminCommandImpl.java @@ -2,17 +2,12 @@ import net.kyori.adventure.text.Component; import net.okocraft.box.api.command.base.BoxAdminCommand; +import net.okocraft.box.api.message.Components; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; import java.util.Set; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; - public class BoxAdminCommandImpl extends BaseCommand implements BoxAdminCommand { @Override @@ -32,9 +27,6 @@ public class BoxAdminCommandImpl extends BaseCommand implements BoxAdminCommand @Override public @NotNull Component getHelp() { - return text().append(translatable("box.command.boxadmin.help.command-line", AQUA)) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.help.description", GRAY)) - .build(); + return Components.commandHelp("box.command.boxadmin"); } } diff --git a/core/src/main/java/net/okocraft/box/core/command/BoxCommandImpl.java b/core/src/main/java/net/okocraft/box/core/command/BoxCommandImpl.java index c442882e31..300102beb6 100644 --- a/core/src/main/java/net/okocraft/box/core/command/BoxCommandImpl.java +++ b/core/src/main/java/net/okocraft/box/core/command/BoxCommandImpl.java @@ -3,6 +3,7 @@ import net.kyori.adventure.text.Component; import net.okocraft.box.api.BoxProvider; import net.okocraft.box.api.command.base.BoxCommand; +import net.okocraft.box.api.message.Components; import net.okocraft.box.api.message.GeneralMessage; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,12 +12,6 @@ import java.util.Set; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; - public class BoxCommandImpl extends BaseCommand implements BoxCommand { @Override @@ -36,10 +31,7 @@ public class BoxCommandImpl extends BaseCommand implements BoxCommand { @Override public @NotNull Component getHelp() { - return text().append(translatable("box.command.box.help.command-line", AQUA)) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.help.description", GRAY)) - .build(); + return Components.commandHelp("box.command.box"); } @Override diff --git a/core/src/main/java/net/okocraft/box/core/message/ErrorMessages.java b/core/src/main/java/net/okocraft/box/core/message/ErrorMessages.java index 0d8012dcf8..2f1289f7ba 100644 --- a/core/src/main/java/net/okocraft/box/core/message/ErrorMessages.java +++ b/core/src/main/java/net/okocraft/box/core/message/ErrorMessages.java @@ -1,37 +1,35 @@ package net.okocraft.box.core.message; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.okocraft.box.api.message.argument.DoubleArgument; import net.okocraft.box.api.message.argument.SingleArgument; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.redTranslatable; +import static net.okocraft.box.api.message.Components.whiteText; + public final class ErrorMessages { public static final Component ERROR_LOAD_PLAYER_DATA_ON_JOIN = - Component.translatable("box.error.player-data.load-on-join", NamedTextColor.RED); + redTranslatable("box.error.player-data.load-on-join"); public static final Component ERROR_SAVE_PLAYER_DATA = - Component.translatable("box.error.player-data.save", NamedTextColor.RED); + redTranslatable("box.error.player-data.save"); public static final Component ERROR_COMMAND_NO_ARGUMENT = - Component.translatable("box.error.command.no-argument", NamedTextColor.RED); + redTranslatable("box.error.command.no-argument"); public static final DoubleArgument ERROR_RELOAD_FAILURE = (name, throwable) -> - Component.translatable() - .key("box.error.failed-to-reload-feature") - .args( - Component.text(name, NamedTextColor.AQUA), - Component.text(throwable.getMessage(), NamedTextColor.WHITE) - ) - .color(NamedTextColor.RED) - .build(); + redTranslatable( + "box.error.failed-to-reload-feature", + aquaText(name), whiteText(throwable.getMessage()) + ); public static final SingleArgument ERROR_WHILE_EXECUTING_COMMAND = throwable -> - Component.translatable() - .key("box.error.failed-to-execute-command") - .args(Component.text(throwable.getMessage(), NamedTextColor.WHITE)) - .color(NamedTextColor.RED) - .build(); + redTranslatable( + "box.error.failed-to-execute-command", + whiteText(throwable.getMessage()) + ); } diff --git a/core/src/main/java/net/okocraft/box/core/message/MicsMessages.java b/core/src/main/java/net/okocraft/box/core/message/MicsMessages.java index 91e77d25ab..b877eb47b2 100644 --- a/core/src/main/java/net/okocraft/box/core/message/MicsMessages.java +++ b/core/src/main/java/net/okocraft/box/core/message/MicsMessages.java @@ -1,15 +1,14 @@ package net.okocraft.box.core.message; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; + +import static net.okocraft.box.api.message.Components.grayTranslatable; public final class MicsMessages { - public static final Component CONFIG_RELOADED = - Component.translatable("box.mics.config-reloaded", NamedTextColor.GRAY); + public static final Component CONFIG_RELOADED = grayTranslatable("box.mics.config-reloaded"); - public static final Component LANGUAGES_RELOADED = - Component.translatable("box.mics.languages-reloaded", NamedTextColor.GRAY); + public static final Component LANGUAGES_RELOADED = grayTranslatable("box.mics.languages-reloaded"); private MicsMessages() { throw new UnsupportedOperationException(); diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java index a863ca8ea0..f3bd0cfd59 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreMenuDisplays.java @@ -5,7 +5,7 @@ import net.okocraft.box.feature.autostore.message.AutoStoreMessage; import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.BLACK; +import static net.okocraft.box.api.message.Components.blackTranslatable; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GOLD; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GRAY; @@ -18,12 +18,11 @@ public class AutoStoreMenuDisplays { enabled -> translatable() .key("box.autostore.gui.mode.lore") - .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .args(AutoStoreMessage.ENABLED_OR_DISABLED.apply(enabled)) .style(NO_DECORATION_GRAY) .build(); - static final Component AUTOSTORE_MODE_SETTING_MENU_TITLE = - translatable("box.autostore.gui.setting-menu.title", BLACK); + static final Component AUTOSTORE_MODE_SETTING_MENU_TITLE = blackTranslatable("box.autostore.gui.setting-menu.title"); static final Component AUTOSTORE_MODE_SETTING_MENU_CHANGE_MODE = translatable("box.autostore.gui.setting-menu.change-mode.display-name", NO_DECORATION_GOLD); @@ -41,7 +40,7 @@ public class AutoStoreMenuDisplays { enabled -> translatable() .key("box.autostore.gui.setting-menu.bulk-editing.click") - .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .args(AutoStoreMessage.ENABLED_OR_DISABLED.apply(enabled)) .style(NO_DECORATION_GRAY) .build(); @@ -49,7 +48,7 @@ public class AutoStoreMenuDisplays { enabled -> translatable() .key("box.autostore.gui.setting-menu.bulk-editing.double-click") - .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .args(AutoStoreMessage.ENABLED_OR_DISABLED.apply(enabled)) .style(NO_DECORATION_GRAY) .build(); @@ -57,7 +56,7 @@ public class AutoStoreMenuDisplays { enabled -> translatable() .key("box.autostore.gui.setting-menu.bulk-editing.recent") - .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .args(AutoStoreMessage.ENABLED_OR_DISABLED.apply(enabled)) .style(NO_DECORATION_GRAY) .build(); @@ -65,7 +64,7 @@ public class AutoStoreMenuDisplays { enabled -> translatable() .key("box.autostore.gui.setting-menu.toggle-button") - .args(AutoStoreMessage.ENABLED_NAME.apply(enabled)) + .args(AutoStoreMessage.ENABLED_OR_DISABLED.apply(enabled)) .style(NO_DECORATION_GRAY) .build(); } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java index 1ad9184a83..864ea33594 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/AutoStoreSettingMenu.java @@ -131,7 +131,7 @@ public int getIconAmount() { @Override public @Nullable ItemMeta applyIconMeta(@NotNull Player viewer, @NotNull ItemMeta target) { var displayName = - AutoStoreMessage.ENABLED_NAME.apply(setting.isEnabled()) + AutoStoreMessage.ENABLED_OR_DISABLED.apply(setting.isEnabled()) .decoration(TextDecoration.ITALIC, TextDecoration.State.FALSE); target.displayName(TranslationUtil.render(displayName, viewer)); diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/message/AutoStoreMessage.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/message/AutoStoreMessage.java index 3821ff9f68..542443eb64 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/message/AutoStoreMessage.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/message/AutoStoreMessage.java @@ -5,94 +5,59 @@ import net.okocraft.box.api.message.argument.SingleArgument; import net.okocraft.box.api.model.item.BoxItem; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GREEN; -import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.okocraft.box.api.message.Components.aquaItemName; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.aquaTranslatable; +import static net.okocraft.box.api.message.Components.commandHelp; +import static net.okocraft.box.api.message.Components.grayTranslatable; +import static net.okocraft.box.api.message.Components.greenTranslatable; +import static net.okocraft.box.api.message.Components.redTranslatable; public final class AutoStoreMessage { public static final Component ERROR_FAILED_TO_LOAD_SETTINGS = - translatable("box.autostore.error.failed-to-load-settings", RED); + redTranslatable("box.autostore.error.failed-to-load-settings"); - public static final Component RELOAD_SUCCESS = - translatable("box.autostore.reloaded", GRAY); + public static final Component RELOAD_SUCCESS = grayTranslatable("box.autostore.reloaded"); + public static final Component AUTO_STORE_ALL_MODE_NAME = aquaTranslatable("box.autostore.mode.all"); - public static final SingleArgument AUTO_STORE_MODE_NAME = - allMode -> translatable("box.autostore.mode." + (allMode ? "all" : "item")); + public static final Component AUTO_STORE_ITEM_MODE_NAME = aquaTranslatable("box.autostore.mode.item"); - public static final SingleArgument ENABLED_NAME = - bool -> bool ? - translatable("box.autostore.enabled", GREEN) : - translatable("box.autostore.disabled", RED); + public static final Component ENABLED_NAME = greenTranslatable("box.autostore.enabled"); + + public static final Component DISABLED_NAME = redTranslatable("box.autostore.disabled"); + + public static final SingleArgument ENABLED_OR_DISABLED = + enabled -> enabled ? ENABLED_NAME : DISABLED_NAME; public static final SingleArgument COMMAND_AUTOSTORE_TOGGLED = - enabled -> - translatable() - .key("box.autostore.command.autostore-toggled") - .args(ENABLED_NAME.apply(enabled)) - .color(GRAY) - .build(); + enabled -> grayTranslatable("box.autostore.command.autostore-toggled", ENABLED_OR_DISABLED.apply(enabled)); public static final SingleArgument COMMAND_MODE_CHANGED = - allMode -> - translatable() - .key("box.autostore.command.mode-changed") - .args(AUTO_STORE_MODE_NAME.apply(allMode).color(AQUA)) - .color(GRAY) - .build(); + allMode -> grayTranslatable( + "box.autostore.command.mode-changed", + allMode ? AUTO_STORE_ALL_MODE_NAME : AUTO_STORE_ITEM_MODE_NAME + ); public static final SingleArgument COMMAND_PER_ITEM_ALL_TOGGLED = - enabled -> - translatable() - .key("box.autostore.command.item.all-toggled") - .args(ENABLED_NAME.apply(enabled)) - .color(GRAY) - .build(); + enabled -> grayTranslatable("box.autostore.command.item.all-toggled", ENABLED_OR_DISABLED.apply(enabled)); public static final DoubleArgument COMMAND_PER_ITEM_ITEM_TOGGLED = - (item, enabled) -> - translatable() - .key("box.autostore.command.item.item-toggled") - .args( - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - ENABLED_NAME.apply(enabled) - ) - .color(GRAY) - .build(); + (item, enabled) -> grayTranslatable( + "box.autostore.command.item.item-toggled", + aquaItemName(item), ENABLED_OR_DISABLED.apply(enabled) + ); public static final SingleArgument COMMAND_MODE_NOT_FOUND = - mode -> - translatable() - .key("box.autostore.command.mode-not-found") - .args(text(mode, AQUA)) - .color(RED) - .build(); + mode -> redTranslatable("box.autostore.command.mode-not-found", aquaText(mode)); public static final SingleArgument COMMAND_NOT_BOOLEAN = - invalid -> - translatable() - .key("box.autostore.command.not-boolean") - .args(text(invalid, AQUA)) - .color(RED) - .build(); - - public static final Component COMMAND_HELP_1 = - translatable("box.autostore.command.help.toggle.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.autostore.command.help.toggle.description", GRAY)); - - public static final Component COMMAND_HELP_2 = - translatable("box.autostore.command.help.all.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.autostore.command.help.all.description", GRAY)); - - public static final Component COMMAND_HELP_3 = - translatable("box.autostore.command.help.item.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.autostore.command.help.item.description", GRAY)); + invalid -> redTranslatable("box.autostore.command.not-boolean", aquaText(invalid)); + + public static final Component COMMAND_HELP_1 = commandHelp("box.autostore.command.help.toggle", false); + + public static final Component COMMAND_HELP_2 = commandHelp("box.autostore.command.help.all", false); + + public static final Component COMMAND_HELP_3 = commandHelp("box.autostore.command.help.item", false); } diff --git a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java index dd23ceb8d1..d5c407be51 100644 --- a/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java +++ b/features/bemode/src/main/java/net/okocraft/box/feature/bemode/lang/Displays.java @@ -1,11 +1,10 @@ package net.okocraft.box.feature.bemode.lang; import net.kyori.adventure.text.Component; +import net.okocraft.box.api.message.Components; import net.okocraft.box.api.message.argument.SingleArgument; -import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GOLD; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GRAY; @@ -22,7 +21,7 @@ public final class Displays { transactionUnit -> translatable() .key("box.bemode.storage-deposit-mode.click-to-deposit") - .args(text(transactionUnit, AQUA)) + .args(Components.aquaText(transactionUnit)) .style(NO_DECORATION_GRAY) .build(); @@ -30,7 +29,7 @@ public final class Displays { transactionUnit -> translatable() .key("box.bemode.storage-withdraw-mode.click-to-withdraw") - .args(text(transactionUnit, AQUA)) + .args(Components.aquaText(transactionUnit)) .style(NO_DECORATION_GRAY) .build(); @@ -38,7 +37,7 @@ public final class Displays { stock -> translatable() .key("box.bemode.current-stock") - .args(text(stock, AQUA)) + .args(Components.aquaText(stock)) .style(NO_DECORATION_GRAY) .build(); diff --git a/features/category/src/main/java/net/okocraft/box/feature/category/CategoryFeature.java b/features/category/src/main/java/net/okocraft/box/feature/category/CategoryFeature.java index 8fda9d481b..359a807ae7 100644 --- a/features/category/src/main/java/net/okocraft/box/feature/category/CategoryFeature.java +++ b/features/category/src/main/java/net/okocraft/box/feature/category/CategoryFeature.java @@ -1,12 +1,11 @@ package net.okocraft.box.feature.category; import com.github.siroshun09.configapi.yaml.YamlConfiguration; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.okocraft.box.api.BoxProvider; import net.okocraft.box.api.feature.AbstractBoxFeature; import net.okocraft.box.api.feature.Disableable; import net.okocraft.box.api.feature.Reloadable; +import net.okocraft.box.api.message.Components; import net.okocraft.box.feature.category.internal.CategoryLoader; import net.okocraft.box.feature.category.internal.CustomItemListener; import net.okocraft.box.feature.category.internal.DefaultCategoryFile; @@ -53,6 +52,6 @@ public void disable() { public void reload(@NotNull CommandSender sender) { disable(); enable(); - sender.sendMessage(Component.translatable("box.category.reloaded", NamedTextColor.GRAY)); + sender.sendMessage(Components.grayTranslatable("box.category.reloaded")); } } diff --git a/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxAdminMessage.java b/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxAdminMessage.java index 9222d22dfe..60c9e429bf 100644 --- a/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxAdminMessage.java +++ b/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxAdminMessage.java @@ -17,369 +17,214 @@ import static net.kyori.adventure.text.Component.newline; import static net.kyori.adventure.text.Component.space; import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GREEN; -import static net.kyori.adventure.text.format.NamedTextColor.RED; -import static net.kyori.adventure.text.format.NamedTextColor.WHITE; +import static net.okocraft.box.api.message.Components.aquaItemName; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.aquaTranslatable; +import static net.okocraft.box.api.message.Components.commandHelp; +import static net.okocraft.box.api.message.Components.grayText; +import static net.okocraft.box.api.message.Components.grayTranslatable; +import static net.okocraft.box.api.message.Components.greenTranslatable; +import static net.okocraft.box.api.message.Components.redTranslatable; +import static net.okocraft.box.api.message.Components.whiteText; public final class BoxAdminMessage { public static final SingleArgument VERSION_INFO = version -> - translatable() - .key("box.command.boxadmin.version.info") - .args(text(version, AQUA)) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.version.info", + aquaText(version) + ); - public static final Component VERSION_HELP = - translatable("box.command.boxadmin.version.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.version.help.description", GRAY)); + public static final Component VERSION_HELP = commandHelp("box.command.boxadmin.version"); public static final QuadArgument GIVE_SUCCESS_SENDER = (targetName, item, increments, currentAmount) -> - translatable() - .key("box.command.boxadmin.give.success.sender") - .args( - text(targetName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(increments, AQUA), text(currentAmount, AQUA) - ) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.give.success.sender", + aquaText(targetName), aquaItemName(item), + aquaText(increments), aquaText(currentAmount) + ); public static final QuadArgument GIVE_SUCCESS_TARGET = (senderName, item, increments, currentAmount) -> - translatable() - .key("box.command.boxadmin.give.success.target") - .args( - text(senderName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(increments, AQUA), text(currentAmount, AQUA) - ) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.give.success.target", + aquaText(senderName), aquaItemName(item), + aquaText(increments), aquaText(currentAmount) + ); - public static final Component GIVE_HELP = - translatable("box.command.boxadmin.give.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.give.help.description", GRAY)); + public static final Component GIVE_HELP = commandHelp("box.command.boxadmin.give"); public static final TripleArgument SET_SUCCESS_SENDER = (targetName, item, currentAmount) -> - translatable() - .key("box.command.boxadmin.set.success.sender") - .args( - text(targetName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(currentAmount, AQUA) - ) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.set.success.sender", + aquaText(targetName), aquaItemName(item), aquaText(currentAmount) + ); public static final TripleArgument SET_SUCCESS_TARGET = (senderName, item, currentAmount) -> - translatable() - .key("box.command.boxadmin.set.success.target") - .args( - text(senderName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(currentAmount, AQUA) - ) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.set.success.target", + aquaText(senderName), aquaItemName(item), aquaText(currentAmount) + ); - public static final Component SET_HELP = - translatable("box.command.boxadmin.set.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.set.help.description", GRAY)); + public static final Component SET_HELP = commandHelp("box.command.boxadmin.set"); public static final QuadArgument TAKE_SUCCESS_SENDER = (targetName, item, increments, currentAmount) -> - translatable() - .key("box.command.boxadmin.take.success.sender") - .args( - text(targetName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(increments, AQUA), text(currentAmount, AQUA) - ) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.take.success.sender", + aquaText(targetName), aquaItemName(item), + aquaText(increments), aquaText(currentAmount) + ); public static final QuadArgument TAKE_SUCCESS_TARGET = (senderName, item, increments, currentAmount) -> - translatable() - .key("box.command.boxadmin.take.success.target") - .args( - text(senderName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(increments, AQUA), text(currentAmount, AQUA) - ) - .color(GRAY) - .build(); + grayTranslatable( + "box.command.boxadmin.take.success.target", + aquaText(senderName), aquaItemName(item), + aquaText(increments), aquaText(currentAmount) + ); - public static final Component TAKE_HELP = - translatable("box.command.boxadmin.take.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.take.help.description", GRAY)); + public static final Component TAKE_HELP = commandHelp("box.command.boxadmin.take"); - public static final Component REGISTER_IS_AIR = translatable("box.command.boxadmin.register.is-air", RED); + public static final Component REGISTER_IS_AIR = redTranslatable("box.command.boxadmin.register.is-air"); public static final SingleArgument REGISTER_ALREADY_REGISTERED = - item -> - translatable() - .key("box.command.boxadmin.register.already-registered") - .args(item.displayName().color(AQUA).hoverEvent(item)) - .color(RED) - .build(); + item -> redTranslatable("box.command.boxadmin.register.already-registered", aquaItemName(item)); public static final SingleArgument REGISTER_SUCCESS = - item -> - translatable() - .key("box.command.boxadmin.register.success") - .args( - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(item.getPlainName(), AQUA) - .clickEvent(ClickEvent.copyToClipboard(item.getPlainName())) - ) - .color(GRAY) - .build(); + item -> grayTranslatable( + "box.command.boxadmin.register.success", + aquaItemName(item), + aquaText(item.getPlainName()).clickEvent(ClickEvent.copyToClipboard(item.getPlainName())) + ); - public static final Component REGISTER_TIP_RENAME = translatable("box.command.boxadmin.register.tip-rename", GRAY); + public static final Component REGISTER_TIP_RENAME = grayTranslatable("box.command.boxadmin.register.tip-rename"); public static final SingleArgument REGISTER_FAILURE = - throwable -> - translatable() - .key("box.command.boxadmin.register.failure") - .args(text(throwable.getMessage(), WHITE)) - .color(RED) - .build(); + throwable -> redTranslatable("box.command.boxadmin.register.failure", whiteText(throwable.getMessage())); - public static final Component REGISTER_HELP = - translatable("box.command.boxadmin.register.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.register.help.description", GRAY)); + public static final Component REGISTER_HELP = commandHelp("box.command.boxadmin.register"); - public static final Component RELOAD_START = - translatable("box.command.boxadmin.reload.start", GRAY); + public static final Component RELOAD_START = grayTranslatable("box.command.boxadmin.reload.start"); - public static final Component RELOAD_FINISH = - translatable("box.command.boxadmin.reload.finish", GRAY); + public static final Component RELOAD_FINISH = grayTranslatable("box.command.boxadmin.reload.finish"); - public static final Component RELOAD_HELP = - translatable("box.command.boxadmin.reload.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.reload.help.description", GRAY)); + public static final Component RELOAD_HELP = commandHelp("box.command.boxadmin.reload"); public static final SingleArgument RENAME_IS_NOT_CUSTOM_ITEM = - item -> - translatable() - .key("box.command.boxadmin.rename.is-not-custom-item") - .args(text(item.getPlainName(), AQUA).hoverEvent(item.getOriginal())) - .color(RED) - .build(); + item -> redTranslatable("box.command.boxadmin.rename.is-not-custom-item", aquaItemName(item)); public static final SingleArgument RENAME_ALREADY_USED_NAME = - name -> - translatable() - .key("box.command.boxadmin.rename.already-used-name") - .args(text(name, AQUA)) - .color(RED) - .build(); + name -> redTranslatable("box.command.boxadmin.rename.already-used-name", aquaText(name)); public static final SingleArgument RENAME_SUCCESS = - item -> - translatable() - .key("box.command.boxadmin.rename.success") - .args(text(item.getPlainName(), AQUA).hoverEvent(item.getOriginal())) - .color(GRAY) - .build(); + item -> grayTranslatable("box.command.boxadmin.rename.success", aquaItemName(item)); public static final SingleArgument RENAME_FAILURE = - throwable -> - translatable() - .key("box.command.boxadmin.rename.failure") - .args(text(throwable.getMessage(), WHITE)) - .color(RED) - .build(); + throwable -> redTranslatable("box.command.boxadmin.rename.failure", whiteText(throwable.getMessage())); - public static final Component RENAME_HELP = - translatable("box.command.boxadmin.rename.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.rename.help.description", GRAY)); + public static final Component RENAME_HELP = commandHelp("box.command.boxadmin.rename"); - public static final Component INFINITY_MODE_ENABLE = translatable("box.command.boxadmin.infinity.enabled"); + public static final Component INFINITY_MODE_ENABLE = greenTranslatable("box.command.boxadmin.infinity.enabled"); - public static final Component INFINITY_MODE_DISABLED = translatable("box.command.boxadmin.infinity.disabled"); + public static final Component INFINITY_MODE_DISABLED = redTranslatable("box.command.boxadmin.infinity.disabled"); public static final SingleArgument INFINITY_MODE_TOGGLE = - enabled -> - translatable() - .key("box.command.boxadmin.infinity.toggle") - .args(enabled ? INFINITY_MODE_ENABLE.color(GREEN) : INFINITY_MODE_DISABLED.color(RED)) - .color(GRAY) - .build(); + enabled -> grayTranslatable( + "box.command.boxadmin.infinity.toggle", + enabled ? INFINITY_MODE_ENABLE : INFINITY_MODE_DISABLED + ); public static final DoubleArgument INFINITY_MODE_TOGGLE_SENDER = - (target, enabled) -> - translatable() - .key("box.command.boxadmin.infinity.toggle-sender") - .args( - text(target.getName(), AQUA), - enabled ? INFINITY_MODE_ENABLE.color(GREEN) : INFINITY_MODE_DISABLED.color(RED) - ) - .color(GRAY) - .build(); + (target, enabled) -> grayTranslatable( + "box.command.boxadmin.infinity.toggle-sender", + aquaText(target.getName()), + enabled ? INFINITY_MODE_ENABLE : INFINITY_MODE_DISABLED + ); public static final DoubleArgument INFINITY_MODE_TOGGLE_TARGET = - (sender, enabled) -> - translatable() - .key("box.command.boxadmin.infinity.toggle-target") - .args( - text(sender.getName(), AQUA), - enabled ? INFINITY_MODE_ENABLE.color(GREEN) : INFINITY_MODE_DISABLED.color(RED) - ) - .color(GRAY) - .build(); + (sender, enabled) -> grayTranslatable( + "box.command.boxadmin.infinity.toggle-target", + aquaText(sender.getName()), + enabled ? INFINITY_MODE_ENABLE : INFINITY_MODE_DISABLED + ); - public static final Component INFINITY_MODE_TIP = translatable("box.command.boxadmin.infinity.tip", GRAY); + public static final Component INFINITY_MODE_TIP = grayTranslatable("box.command.boxadmin.infinity.tip"); - public static final Component INFINITY_HELP = - translatable("box.command.boxadmin.infinity.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.infinity.help.description", GRAY)); + public static final Component INFINITY_HELP = commandHelp("box.command.boxadmin.infinity"); public static final SingleArgument RESET_SUCCESS_SENDER = - target -> translatable() - .key("box.command.boxadmin.reset.success.sender") - .args(text(target.getName(), AQUA)) - .color(GRAY) - .build(); + target -> grayTranslatable("box.command.boxadmin.reset.success.sender", aquaText(target.getName())); public static final SingleArgument RESET_SUCCESS_TARGET = - sender -> translatable() - .key("box.command.boxadmin.reset.success.target") - .args(text(sender.getName(), AQUA)) - .color(GRAY) - .build(); + sender -> grayTranslatable("box.command.boxadmin.reset.success.target", aquaText(sender.getName())); - public static final Component RESET_CANCEL = - translatable("box.command.boxadmin.reset.cancel", GRAY); + public static final Component RESET_CANCEL = grayTranslatable("box.command.boxadmin.reset.cancel"); public static final SingleArgument RESET_CONFIRMATION = - target -> text() - .append( - translatable() - .key("box.command.boxadmin.reset.confirmation.info") - .args(text(target.getName(), AQUA)) - .color(GRAY) - .build() - ).append(newline()) - .append(translatable("box.command.boxadmin.reset.confirmation.warning", GRAY)) - .append(newline()) - .append( - translatable() - .key("box.command.boxadmin.reset.confirmation.confirm-command") - .args(text("/boxadmin reset confirm", AQUA)) - .color(GRAY) - .build() - ).append(newline()) - .append( - translatable() - .key("box.command.boxadmin.reset.confirmation.cancel-command") - .args(text("/boxadmin reset cancel", AQUA)) - .color(GRAY) - .build() - ) - .build(); + target -> + text().append(grayTranslatable( + "box.command.boxadmin.reset.confirmation.info", aquaText(target.getName()) + )).append(newline()) + .append(grayTranslatable("box.command.boxadmin.reset.confirmation.warning")) + .append(newline()) + .append(confirmationCommand("confirm")) + .append(newline()) + .append(confirmationCommand("cancel")) + .build(); + + private static Component confirmationCommand(String arg) { + return grayTranslatable( + "box.command.boxadmin.reset.confirmation." + arg + "-command", + aquaText("/boxadmin reset " + arg) + ); + } - public static final Component RESET_HELP = - translatable("box.command.boxadmin.reset.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.reset.help.description", GRAY)); + public static final Component RESET_HELP = commandHelp("box.command.boxadmin.reset"); - public static final Component STOCK_HELP = - translatable("box.command.boxadmin.stock.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.stock.help.description", GRAY)); + public static final Component STOCK_HELP = commandHelp("box.command.boxadmin.stock"); - public static final Component STOCK_INFO_HELP = - translatable("box.command.boxadmin.stock.info.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.stock.info.help.description", GRAY)); + public static final Component STOCK_INFO_HELP = commandHelp("box.command.boxadmin.stock.info"); public static final TripleArgument STOCK_INFO_AMOUNT = - (targetName, item, amount) -> - translatable() - .key("box.command.boxadmin.stock.info.amount") - .args( - text(targetName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(amount, AQUA) - ) - .color(GRAY) - .build(); + (targetName, item, amount) -> grayTranslatable( + "box.command.boxadmin.stock.info.amount", + aquaText(targetName), aquaItemName(item), aquaText(amount) + ); public static final Component STOCK_LIST_HELP = - text().append(translatable("box.command.boxadmin.stock.list.help.command-line", AQUA)) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.boxadmin.stock.list.help.description", GRAY)) + text().append(commandHelp("box.command.boxadmin.stock.list")) .append(newline()).append(space()) - .append( - translatable() - .key("box.command.boxadmin.stock.list.help.argument.sorter.format") - .args( - text("-s", AQUA), text("--sorter", AQUA), - translatable("box.command.boxadmin.stock.list.help.argument.sorter.value", AQUA) - ) - .color(GRAY) - ).append(newline()).append(space()) - .append( - translatable() - .key("box.command.boxadmin.stock.list.help.argument.page.format") - .args( - text("-p", AQUA), text("--page", AQUA), - translatable("box.command.boxadmin.stock.list.help.argument.page.value", AQUA) - ) - .color(GRAY) - ).append(newline()).append(space()) - .append( - translatable() - .key("box.command.boxadmin.stock.list.help.argument.filter.format") - .args( - text("-f", AQUA), text("--filter", AQUA), - translatable("box.command.boxadmin.stock.list.help.argument.page.value", AQUA) - ) - .color(GRAY) - ).build(); + .append(stockListArgumentHelp("sorter", "s")) + .append(newline()).append(space()) + .append(stockListArgumentHelp("page", "p")) + .append(newline()).append(space()) + .append(stockListArgumentHelp("filter", "f")) + .build(); + + private static Component stockListArgumentHelp(String arg, String shortArg) { + var keyPrefix = "box.command.boxadmin.stock.list.help.argument." + arg; + return grayTranslatable( + keyPrefix + ".format", + aquaText("-" + shortArg), aquaText("--" + arg), aquaTranslatable(keyPrefix + ".value") + ); + } public static final TripleArgument STOCK_LIST_HEADER = - (target, page, maxPage) -> - translatable() - .key("box.command.boxadmin.stock.list.header") - .args( - text(target.getName(), AQUA), - text(page, AQUA), - text(maxPage, AQUA) - ) - .color(GRAY) - .build(); + (target, page, maxPage) -> grayTranslatable( + "box.command.boxadmin.stock.list.header", + aquaText(target.getName()), aquaText(page), aquaText(maxPage) + ); public static final DoubleArgument STOCK_LIST_ITEM_AMOUNT = - (num, stockData) -> - translatable() - .key("box.command.boxadmin.stock.list.amount") - .args( - text(num, GRAY), - stockData.item().getDisplayName().color(AQUA).hoverEvent(stockData.item().getOriginal()), - text(stockData.amount(), AQUA) - ) - .color(GRAY) - .build(); + (num, stockData) -> grayTranslatable( + "box.command.boxadmin.stock.list.amount", + grayText(num), aquaItemName(stockData.item()), aquaText(stockData.amount()) + ); private BoxAdminMessage() { throw new UnsupportedOperationException(); diff --git a/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxMessage.java b/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxMessage.java index e6fbf77b19..49cf7c5433 100644 --- a/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxMessage.java +++ b/features/command/src/main/java/net/okocraft/box/feature/command/message/BoxMessage.java @@ -11,177 +11,103 @@ import static net.kyori.adventure.text.Component.newline; import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.okocraft.box.api.message.Components.aquaItemName; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.commandHelp; +import static net.okocraft.box.api.message.Components.grayTranslatable; +import static net.okocraft.box.api.message.Components.redTranslatable; public final class BoxMessage { public static final TripleArgument DEPOSIT_SUCCESS = - (item, amount, current) -> - translatable() - .key("box.command.box.deposit.success") - .args( - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(amount, AQUA), - text(current, AQUA) - ) - .color(GRAY) - .build(); + (item, amount, current) -> grayTranslatable( + "box.command.box.deposit.success", + aquaItemName(item), aquaText(amount), aquaText(current) + ); public static final SingleArgument DEPOSIT_ALL_SUCCESS = - amount -> translatable() - .key("box.command.box.deposit.all-success") - .args(text(amount, AQUA)) - .color(GRAY) - .build(); + amount -> grayTranslatable("box.command.box.deposit.all-success", aquaText(amount)); - public static final Component DEPOSIT_IS_AIR = - translatable("box.command.box.deposit.is-air", RED); + public static final Component DEPOSIT_IS_AIR = redTranslatable("box.command.box.deposit.is-air"); public static final Component DEPOSIT_ITEM_NOT_REGISTERED = - translatable("box.command.box.deposit.item-not-registered", RED); + redTranslatable("box.command.box.deposit.item-not-registered"); - public static final Component DEPOSIT_NOT_DEPOSITED = - translatable("box.command.box.deposit.not-deposited", RED); + public static final Component DEPOSIT_NOT_DEPOSITED = redTranslatable("box.command.box.deposit.not-deposited"); - public static final Component DEPOSIT_NOT_FOUND = - translatable("box.command.box.deposit.not-found", RED); + public static final Component DEPOSIT_NOT_FOUND = redTranslatable("box.command.box.deposit.not-found"); - public static final Component DEPOSIT_HELP_1 = - translatable("box.command.box.deposit.help.main-hand.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.deposit.help.main-hand.description", GRAY)); + public static final Component DEPOSIT_HELP_1 = commandHelp("box.command.box.deposit.help.main-hand", false); - public static final Component DEPOSIT_HELP_2 = - translatable("box.command.box.deposit.help.all.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.deposit.help.all.description", GRAY)); + public static final Component DEPOSIT_HELP_2 = commandHelp("box.command.box.deposit.help.all", false); - public static final Component DEPOSIT_HELP_3 = - translatable("box.command.box.deposit.help.item.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.deposit.help.item.description", GRAY)); + public static final Component DEPOSIT_HELP_3 = commandHelp("box.command.box.deposit.help.item", false); public static final QuadArgument GIVE_SUCCESS_SENDER = - (targetName, item, amount, current) -> - translatable() - .key("box.command.box.give.success.sender") - .args( - text(targetName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(amount, AQUA), - text(current, AQUA) - ) - .color(GRAY) - .build(); + (targetName, item, amount, current) -> grayTranslatable( + "box.command.box.give.success.sender", + aquaText(targetName), aquaItemName(item), aquaText(amount), aquaText(current) + ); public static final QuadArgument GIVE_SUCCESS_TARGET = - (senderName, item, amount, current) -> - translatable() - .key("box.command.box.give.success.target") - .args( - text(senderName, AQUA), - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(amount, AQUA), - text(current, AQUA) - ) - .color(GRAY) - .build(); + (senderName, item, amount, current) -> grayTranslatable( + "box.command.box.give.success.target", + aquaText(senderName), aquaItemName(item), aquaText(amount), aquaText(current) + ); public static final SingleArgument GIVE_NO_STOCK = - item -> - translatable() - .key("box.command.box.give.no-stock") - .args(item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal())) - .color(RED) - .build(); + item -> redTranslatable("box.command.box.give.no-stock", aquaItemName(item)); - public static final Component GIVE_SELF = translatable("box.command.box.give.self", RED); + public static final Component GIVE_SELF = redTranslatable("box.command.box.give.self"); public static final DoubleArgument GIVE_TARGET_NO_PERMISSION = - (target, permission) -> - translatable() - .key("box.command.box.give.target-no-permission") - .args(text(target.getName(), AQUA), text(permission, AQUA)) - .color(RED) - .build(); + (target, permission) -> redTranslatable( + "box.command.box.give.target-no-permission", + aquaText(target.getName()), aquaText(permission) + ); public static final DoubleArgument GIVE_TARGET_IS_IN_DISABLED_WORLD = (target, world) -> - translatable() - .key("box.command.box.give.target-is-in-disabled-world") - .args(text(target.getName(), AQUA), text(world.getName(), AQUA)) - .color(RED) - .build(); + redTranslatable( + "box.command.box.give.target-is-in-disabled-world", + aquaText(target.getName()), aquaText(world.getName()) + ); - public static final Component GIVE_HELP = - translatable("box.command.box.give.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.give.help.description", GRAY)); + public static final Component GIVE_HELP = commandHelp("box.command.box.give"); public static final TripleArgument WITHDRAW_SUCCESS = - (item, amount, current) -> - translatable() - .key("box.command.box.withdraw.success") - .args( - item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()), - text(amount, AQUA), - text(current, AQUA) - ) - .color(GRAY) - .build(); + (item, amount, current) -> grayTranslatable( + "box.command.box.withdraw.success", + aquaItemName(item), aquaText(amount), aquaText(current) + ); public static final TripleArgument WITHDRAW_PARTIAL_SUCCESS = (item, amount, current) -> - translatable("box.command.box.withdraw.stop", RED) + text().append(redTranslatable("box.command.box.withdraw.stop")) .append(newline()) - .append(WITHDRAW_SUCCESS.apply(item, amount, current)); + .append(WITHDRAW_SUCCESS.apply(item, amount, current)) + .build(); public static final SingleArgument WITHDRAW_NO_STOCK = - item -> - translatable() - .key("box.command.box.withdraw.no-stock") - .args(item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal())) - .color(RED) - .build(); + item -> redTranslatable("box.command.box.withdraw.no-stock", aquaItemName(item)); public static final Component WITHDRAW_INVENTORY_IS_FULL = - translatable("box.command.box.withdraw.inventory-is-full", RED); + redTranslatable("box.command.box.withdraw.inventory-is-full"); - public static final Component WITHDRAW_HELP = - translatable("box.command.box.withdraw.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.withdraw.help.description", GRAY)); + public static final Component WITHDRAW_HELP = commandHelp("box.command.box.withdraw"); - public static final Component ITEM_INFO_IS_AIR = - translatable("box.command.box.iteminfo.is-air", RED); + public static final Component ITEM_INFO_IS_AIR = redTranslatable("box.command.box.iteminfo.is-air"); public static final Component ITEM_INFO_NOT_REGISTERED = - translatable("box.command.box.iteminfo.item-not-registered", RED); + redTranslatable("box.command.box.iteminfo.item-not-registered"); public static final SingleArgument ITEM_INFO_NAME = - item -> - translatable() - .key("box.command.box.iteminfo.name") - .args(text(item.getPlainName()).color(AQUA).hoverEvent(item.getOriginal())) - .color(GRAY) - .build(); + item -> grayTranslatable("box.command.box.iteminfo.name", aquaItemName(item)); public static final SingleArgument ITEM_INFO_STOCK = - stock -> - translatable() - .key("box.command.box.iteminfo.stock") - .args(text(stock, AQUA)) - .color(GRAY) - .build(); + stock -> grayTranslatable("box.command.box.iteminfo.stock", aquaText(stock)); - public static final Component ITEM_INFO_HELP = - translatable("box.command.box.iteminfo.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.command.box.iteminfo.help.description", GRAY)); + public static final Component ITEM_INFO_HELP = commandHelp("box.command.box.iteminfo"); private BoxMessage() { throw new UnsupportedOperationException(); diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java index bed497885f..5fe3427a57 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java @@ -2,13 +2,12 @@ import com.github.siroshun09.configapi.api.util.ResourceUtils; import com.github.siroshun09.configapi.yaml.YamlConfiguration; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.okocraft.box.api.BoxProvider; import net.okocraft.box.api.feature.AbstractBoxFeature; import net.okocraft.box.api.feature.BoxFeature; import net.okocraft.box.api.feature.Disableable; import net.okocraft.box.api.feature.Reloadable; +import net.okocraft.box.api.message.Components; import net.okocraft.box.feature.craft.command.CraftCommand; import net.okocraft.box.feature.craft.loader.RecipeLoader; import net.okocraft.box.feature.craft.mode.CraftMode; @@ -67,7 +66,7 @@ public void reload(@NotNull CommandSender sender) { enable(); try { - sender.sendMessage(Component.translatable("box.craft.command.recipe-reloaded", NamedTextColor.GRAY)); + sender.sendMessage(Components.grayTranslatable("box.craft.command.recipe-reloaded")); } catch (Exception ignored) { // I don't know why it loops infinitely and throws an exception when the message send to the console. // It's probably a bug of Paper or Adventure. diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/lang/Displays.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/lang/Displays.java index 8eadbdd29c..2fcd555bae 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/lang/Displays.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/lang/Displays.java @@ -6,11 +6,13 @@ import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; import static net.kyori.adventure.text.format.NamedTextColor.BLACK; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.okocraft.box.api.message.Components.aquaItemName; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.aquaTranslatable; +import static net.okocraft.box.api.message.Components.blackTranslatable; +import static net.okocraft.box.api.message.Components.commandHelp; +import static net.okocraft.box.api.message.Components.redTranslatable; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_AQUA; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GOLD; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GRAY; @@ -19,20 +21,10 @@ public final class Displays { public static final SingleArgument CRAFT_MENU_TITLE = - result -> - translatable() - .key("box.craft.gui.menus.craft") - .args(translatable(result.getOriginal(), BLACK)) - .color(BLACK) - .build(); + result -> blackTranslatable("box.craft.gui.menus.craft", result.getDisplayName().color(BLACK)); public static final SingleArgument RECIPE_SELECTOR_TITLE = - result -> - translatable() - .key("box.craft.gui.menus.recipe-selector") - .args(translatable(result.getOriginal(), BLACK)) - .color(BLACK) - .build(); + result -> blackTranslatable("box.craft.gui.menus.recipe-selector", result.getDisplayName().color(BLACK)); public static final SingleArgument CRAFT_BUTTON_DISPLAY_NAME = times -> @@ -55,7 +47,7 @@ public final class Displays { stock -> translatable() .key("box.craft.gui.buttons.current-stock") - .args(text(stock, AQUA)) + .args(aquaText(stock)) .style(NO_DECORATION_GRAY) .build(); @@ -63,10 +55,10 @@ public final class Displays { translatable("box.craft.gui.buttons.destination.display-name", NO_DECORATION_GOLD); public static final Component DISTRIBUTION_BUTTON_INVENTORY = - translatable("box.craft.gui.buttons.destination.inventory", AQUA); + aquaTranslatable("box.craft.gui.buttons.destination.inventory"); public static final Component DISTRIBUTION_BUTTON_BOX = - translatable("box.craft.gui.buttons.destination.box", AQUA); + aquaTranslatable("box.craft.gui.buttons.destination.box"); public static final SingleArgument DISTRIBUTION_CURRENT = current -> @@ -97,7 +89,7 @@ public final class Displays { currentAmount -> translatable() .key("box.craft.gui.buttons.change-times.current") - .args(text(currentAmount, AQUA)) + .args(aquaText(currentAmount)) .style(NO_DECORATION_GRAY) .build(); @@ -111,7 +103,7 @@ public final class Displays { unit -> translatable() .key("box.craft.gui.buttons.change-times.increase.lore") - .args(text(unit, AQUA)) + .args(aquaText(unit)) .style(NO_DECORATION_GRAY) .build(); @@ -125,7 +117,7 @@ public final class Displays { unit -> translatable() .key("box.craft.gui.buttons.change-times.decrease.lore") - .args(text(unit, AQUA)) + .args(aquaText(unit)) .style(NO_DECORATION_GRAY) .build(); @@ -133,7 +125,7 @@ public final class Displays { unit -> translatable() .key("box.craft.gui.buttons.change-times.set-to-unit") - .args(text(unit, AQUA)) + .args(aquaText(unit)) .style(NO_DECORATION_GRAY) .build(); @@ -152,17 +144,9 @@ public final class Displays { translatable("box.craft.gui.buttons.ingredient-change-mode.each", NO_DECORATION_GOLD); public static final SingleArgument COMMAND_RECIPE_NOT_FOUND = - item -> - translatable() - .key("box.craft.command.recipe-not-found") - .args(item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal())) - .color(RED) - .build(); + item -> redTranslatable("box.craft.command.recipe-not-found", aquaItemName(item)); - public static final Component COMMAND_HELP = - translatable("box.craft.command.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.craft.command.help.description", GRAY)); + public static final Component COMMAND_HELP = commandHelp("box.craft.command"); private Displays() { throw new UnsupportedOperationException(); diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java index 1b872b3864..92414e3af0 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/GuiFeature.java @@ -1,12 +1,11 @@ package net.okocraft.box.feature.gui; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; import net.okocraft.box.api.BoxProvider; import net.okocraft.box.api.feature.AbstractBoxFeature; import net.okocraft.box.api.feature.BoxFeature; import net.okocraft.box.api.feature.Disableable; import net.okocraft.box.api.feature.Reloadable; +import net.okocraft.box.api.message.Components; import net.okocraft.box.feature.category.CategoryFeature; import net.okocraft.box.feature.gui.internal.command.MenuOpenCommand; import net.okocraft.box.feature.gui.internal.holder.BoxInventoryHolder; @@ -68,7 +67,7 @@ public void reload(@NotNull CommandSender sender) { enable(); try { - sender.sendMessage(Component.translatable("box.gui.reloaded", NamedTextColor.GRAY)); + sender.sendMessage(Components.grayTranslatable("box.gui.reloaded")); } catch (Exception ignored) { // I don't know why it loops infinitely and throws an exception when the message send to the console. // It's probably a bug of Paper or Adventure. diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java index d94a9ac611..f3d1ef0a43 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/command/MenuOpenCommand.java @@ -8,6 +8,7 @@ import net.okocraft.box.api.util.TabCompleter; import net.okocraft.box.api.util.UserStockHolderOperator; import net.okocraft.box.feature.gui.api.event.MenuOpenEvent; +import net.okocraft.box.api.message.Components; import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import net.okocraft.box.feature.gui.api.session.PlayerSession; import net.okocraft.box.feature.gui.api.util.MenuOpener; @@ -20,21 +21,11 @@ import java.util.List; import java.util.Set; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.RED; - public class MenuOpenCommand extends AbstractCommand { private static final String OTHER_PLAYERS_GUI_PERMISSION = "box.admin.command.gui.other"; - private static final Component CANNOT_OPEN_MENU = translatable("box.gui.cannot-open-menu", RED); - private static final Component COMMAND_HELP = - translatable("box.gui.command-help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.gui.command-help.description", GRAY)); + private static final Component CANNOT_OPEN_MENU = Components.redTranslatable("box.gui.cannot-open-menu"); + private static final Component COMMAND_HELP =Components.commandHelp("box.gui.command-help", false); public MenuOpenCommand() { super("gui", "box.command.gui", Set.of("g", "menu", "m")); diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/lang/Displays.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/lang/Displays.java index 40a85d55dd..29376609e8 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/lang/Displays.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/lang/Displays.java @@ -1,14 +1,14 @@ package net.okocraft.box.feature.gui.internal.lang; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; +import net.okocraft.box.api.message.Components; import net.okocraft.box.api.message.argument.SingleArgument; import net.okocraft.box.feature.category.model.Category; -import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; import static net.kyori.adventure.text.format.NamedTextColor.BLACK; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.redTranslatable; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GOLD; import static net.okocraft.box.feature.gui.api.lang.Styles.NO_DECORATION_GRAY; @@ -57,7 +57,7 @@ public final class Displays { currentAmount -> translatable() .key("box.gui.buttons.change-transaction-amount.current") - .args(text(currentAmount, AQUA)) + .args(aquaText(currentAmount)) .style(NO_DECORATION_GRAY) .build(); @@ -71,7 +71,7 @@ public final class Displays { unit -> translatable() .key("box.gui.buttons.change-transaction-amount.increase.lore") - .args(text(unit, AQUA)) + .args(aquaText(unit)) .style(NO_DECORATION_GRAY) .build(); @@ -85,7 +85,7 @@ public final class Displays { unit -> translatable() .key("box.gui.buttons.change-transaction-amount.decrease.lore") - .args(text(unit, AQUA)) + .args(aquaText(unit)) .style(NO_DECORATION_GRAY) .build(); @@ -93,7 +93,7 @@ public final class Displays { unit -> translatable() .key("box.gui.buttons.change-transaction-amount.set-to-unit") - .args(text(unit, AQUA)) + .args(aquaText(unit)) .style(NO_DECORATION_GRAY) .build(); @@ -115,7 +115,7 @@ public final class Displays { transactionUnit -> translatable() .key("box.gui.modes.storage-mode.left-click-to-deposit") - .args(text(transactionUnit, AQUA)) + .args(aquaText(transactionUnit)) .style(NO_DECORATION_GRAY) .build(); @@ -123,7 +123,7 @@ public final class Displays { transactionUnit -> translatable() .key("box.gui.modes.storage-mode.right-click-to-withdraw") - .args(text(transactionUnit, AQUA)) + .args(aquaText(transactionUnit)) .style(NO_DECORATION_GRAY) .build(); @@ -131,7 +131,7 @@ public final class Displays { stock -> translatable() .key("box.gui.modes.storage-mode.current-stock") - .args(text(stock, AQUA)) + .args(aquaText(stock)) .style(NO_DECORATION_GRAY) .build(); @@ -145,10 +145,5 @@ public final class Displays { translatable("box.gui.modes.storage-mode.deposit-all.lore-2", NO_DECORATION_GRAY); public static final SingleArgument ERROR_WHILE_CLICK_PROCESSING = - throwable -> - Component.translatable() - .key("box.gui.error-occurred") - .args(Component.text(throwable.getMessage(), NamedTextColor.WHITE)) - .color(NamedTextColor.RED) - .build(); + throwable -> redTranslatable("box.gui.error-occurred", Components.whiteText(throwable.getMessage())); } diff --git a/features/notifier/src/main/java/net/okocraft/box/feature/notifier/factory/NotificationFactory.java b/features/notifier/src/main/java/net/okocraft/box/feature/notifier/factory/NotificationFactory.java index f9216c897c..a6925661e0 100644 --- a/features/notifier/src/main/java/net/okocraft/box/feature/notifier/factory/NotificationFactory.java +++ b/features/notifier/src/main/java/net/okocraft/box/feature/notifier/factory/NotificationFactory.java @@ -7,10 +7,10 @@ import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.RED; -import static net.kyori.adventure.text.format.NamedTextColor.WHITE; +import static net.okocraft.box.api.message.Components.aquaText; +import static net.okocraft.box.api.message.Components.redText; +import static net.okocraft.box.api.message.Components.whiteText; public class NotificationFactory { @@ -60,12 +60,11 @@ private NotificationFactory(@NotNull BoxItem item) { translatable() .key(item.getOriginal()) .append(COMMON_PARTS_1) - .append(text(current, WHITE)); + .append(whiteText(current)); if (diff != 0) { - var minus = diff < 0; notification.append(COMMON_PARTS_2) - .append(text((minus ? "-" : "+") + Math.abs(diff), minus ? RED : AQUA)) + .append(0 <= diff ? aquaText("+" + diff) : redText(diff)) .append(COMMON_PARTS_3); } diff --git a/features/stick/src/main/java/net/okocraft/box/feature/stick/command/CustomStickCommand.java b/features/stick/src/main/java/net/okocraft/box/feature/stick/command/CustomStickCommand.java index b29d108ee9..8fdf612f6a 100644 --- a/features/stick/src/main/java/net/okocraft/box/feature/stick/command/CustomStickCommand.java +++ b/features/stick/src/main/java/net/okocraft/box/feature/stick/command/CustomStickCommand.java @@ -10,37 +10,16 @@ import org.bukkit.persistence.PersistentDataType; import org.jetbrains.annotations.NotNull; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.okocraft.box.api.message.Components.commandHelp; +import static net.okocraft.box.api.message.Components.grayTranslatable; +import static net.okocraft.box.api.message.Components.redTranslatable; public class CustomStickCommand extends AbstractCommand { - private static final Component CUSTOM_STICK_HELP = - translatable("box.stick.command.customstick.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.stick.command.customstick.help.description", GRAY)); - - private static final Component CUSTOM_STICK_SUCCESS = - translatable() - .key("box.stick.command.customstick.success") - .color(GRAY) - .build(); - - private static final Component CUSTOM_STICK_ALREADY = - translatable() - .key("box.stick.command.customstick.already") - .color(RED) - .build(); - - private static final Component CUSTOM_STICK_IS_AIR = - translatable() - .key("box.stick.command.customstick.is-air") - .color(RED) - .build(); + private static final Component CUSTOM_STICK_HELP = commandHelp("box.stick.command.customstick"); + private static final Component CUSTOM_STICK_SUCCESS = grayTranslatable("box.stick.command.customstick.success"); + private static final Component CUSTOM_STICK_ALREADY = redTranslatable("box.stick.command.customstick.already"); + private static final Component CUSTOM_STICK_IS_AIR = redTranslatable("box.stick.command.customstick.is-air"); private final NamespacedKey key; diff --git a/features/stick/src/main/java/net/okocraft/box/feature/stick/command/StickCommand.java b/features/stick/src/main/java/net/okocraft/box/feature/stick/command/StickCommand.java index 162c14428d..9083672a5b 100644 --- a/features/stick/src/main/java/net/okocraft/box/feature/stick/command/StickCommand.java +++ b/features/stick/src/main/java/net/okocraft/box/feature/stick/command/StickCommand.java @@ -11,28 +11,18 @@ import java.util.Set; -import static net.kyori.adventure.text.Component.text; -import static net.kyori.adventure.text.Component.translatable; -import static net.kyori.adventure.text.format.NamedTextColor.AQUA; -import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.GRAY; -import static net.kyori.adventure.text.format.NamedTextColor.RED; +import static net.okocraft.box.api.message.Components.commandHelp; +import static net.okocraft.box.api.message.Components.redTranslatable; public class StickCommand extends AbstractCommand { - private static final Component ALREADY_HAVE = - translatable("box.stick.command.already-have", RED); + private static final Component ALREADY_HAVE = redTranslatable("box.stick.command.already-have"); - private static final Component COULD_NOT_GIVE_STICK = - translatable("box.stick.command.could-not-give-stick", RED); + private static final Component COULD_NOT_GIVE_STICK = redTranslatable("box.stick.command.could-not-give-stick"); - private static final Component GIVE_SUCCESS = - translatable("box.stick.command.success", GRAY); + private static final Component GIVE_SUCCESS = redTranslatable("box.stick.command.success"); - private static final Component HELP = - translatable("box.stick.command.help.command-line", AQUA) - .append(text(" - ", DARK_GRAY)) - .append(translatable("box.stick.command.help.description", GRAY)); + private static final Component HELP = commandHelp("box.stick.command"); private final BoxStickItem boxStickItem; From 401b6bbe7b00ed6415715a15813656b6a2429087 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 09:59:24 +0900 Subject: [PATCH 29/53] docs(api): add javadocs for Components --- .../okocraft/box/api/message/Components.java | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/api/src/main/java/net/okocraft/box/api/message/Components.java b/api/src/main/java/net/okocraft/box/api/message/Components.java index 5d2c11dcc9..2037ad37f5 100644 --- a/api/src/main/java/net/okocraft/box/api/message/Components.java +++ b/api/src/main/java/net/okocraft/box/api/message/Components.java @@ -16,108 +16,259 @@ import static net.kyori.adventure.text.format.NamedTextColor.RED; import static net.kyori.adventure.text.format.NamedTextColor.WHITE; +/** + * A class to help reduce codes that create {@link Component}. + */ public final class Components { + /** + * Creates a gray {@link Component} from a string. + * + * @param text the text to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component grayText(@NotNull String text) { return text(text, GRAY); } + /** + * Creates an aqua {@link Component} from a string. + * + * @param text the text to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component aquaText(@NotNull String text) { return text(text, AQUA); } + /** + * Creates a white {@link Component} from a string. + * + * @param text the text to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component whiteText(@NotNull String text) { return text(text, WHITE); } + /** + * Creates a gray {@link Component} from an integer. + * + * @param value the integer to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component grayText(int value) { return text(value, GRAY); } + /** + * Creates an aqua {@link Component} from an integer. + * + * @param value the integer to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component aquaText(int value) { return text(value, AQUA); } + /** + * Creates a red {@link Component} from an integer. + * + * @param value the integer to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component redText(int value) { return text(value, RED); } + /** + * Creates a white {@link Component} from an integer. + * + * @param value the integer to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component whiteText(int value) { return text(value, WHITE); } + /** + * Creates a gray {@link Component} from the key of the message. + * + * @param key the key of the message + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component grayTranslatable(@NotNull String key) { return translatable(key, GRAY); } + /** + * Creates an aqua {@link Component} from the key of the message. + * + * @param key the key of the message + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component aquaTranslatable(@NotNull String key) { return translatable(key, AQUA); } + /** + * Creates a red {@link Component} from the key of the message. + * + * @param key the key of the message + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component redTranslatable(@NotNull String key) { return translatable(key, RED); } + /** + * Creates a green {@link Component} from the key of the message. + * + * @param key the key of the message + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component greenTranslatable(@NotNull String key) { return translatable(key, GREEN); } + /** + * Creates a black {@link Component} from the key of the message. + * + * @param key the key of the message + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component blackTranslatable(@NotNull String key) { return translatable(key, BLACK); } + /** + * Creates a gray {@link Component} from the key of the message and arguments. + * + * @param key the key of the message + * @param args the arguments + * @return the created {@link Component} + */ @Contract(value = "_, _ -> new", pure = true) public static @NotNull Component grayTranslatable(@NotNull String key, @NotNull Component... args) { return translatable().key(key).args(args).color(GRAY).build(); } + /** + * Creates an aqua {@link Component} from the key of the message and arguments. + * + * @param key the key of the message + * @param args the arguments + * @return the created {@link Component} + */ @Contract(value = "_, _ -> new", pure = true) public static @NotNull Component aquaTranslatable(@NotNull String key, @NotNull Component... args) { return translatable().key(key).args(args).color(AQUA).build(); } + /** + * Creates a red {@link Component} from the key of the message and arguments. + * + * @param key the key of the message + * @param args the arguments + * @return the created {@link Component} + */ @Contract(value = "_, _ -> new", pure = true) public static @NotNull Component redTranslatable(@NotNull String key, @NotNull Component... args) { return translatable().key(key).args(args).color(RED).build(); } + /** + * Creates a green {@link Component} from the key of the message and arguments. + * + * @param key the key of the message + * @param args the arguments + * @return the created {@link Component} + */ @Contract(value = "_, _ -> new", pure = true) public static @NotNull Component greenTranslatable(@NotNull String key, @NotNull Component... args) { return translatable().key(key).args(args).color(GREEN).build(); } + /** + * Creates a black {@link Component} from the key of the message and arguments. + * + * @param key the key of the message + * @param args the arguments + * @return the created {@link Component} + */ @Contract(value = "_, _ -> new", pure = true) public static @NotNull Component blackTranslatable(@NotNull String key, @NotNull Component... args) { return translatable().key(key).args(args).color(BLACK).build(); } + /** + * Creates an aqua {@link Component} from the {@link BoxItem}. + *

+ * This method will set the item's display name to aqua color + * and set the item's hover event. + * + * @param item the item to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component aquaItemName(@NotNull BoxItem item) { return item.getDisplayName().color(AQUA).hoverEvent(item.getOriginal()); } + /** + * Creates an aqua {@link Component} from the {@link ItemStack}. + *

+ * This method displays the item's display name in aqua + * and sets the item's hover event to the component. + * + * @param item the item to create {@link Component} + * @return the created {@link Component} + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component aquaItemName(@NotNull ItemStack item) { return item.displayName().color(AQUA).hoverEvent(item); } + /** + * Creates a command help. + * + * @param keyPrefix the key prefix of the messages + * @return the created {@link Component} + * @see #commandHelp(String, boolean) + */ @Contract(value = "_ -> new", pure = true) public static @NotNull Component commandHelp(@NotNull String keyPrefix) { return commandHelp(keyPrefix, true); } + /** + * Creates a command help. + *

+ * This method creates a help message for the command + * by adding {@code .command-line} and {@code .description} to the prefix of the given key. + *

+ * The keys of the referenced messages are {@code keyPrefix.command-line} + * and {@code keyPrefix.description}. + *

+ * If {@code appendHelp} is {@code true}, the keys of the messages are + * {@code keyPrefix.help.command-line} and {@code keyPrefix.help.description}. + * + * @param keyPrefix the key prefix of the messages + * @param appendHelp whether to append {@code .help} to the key prefix + * @return the created {@link Component} + */ @Contract(value = "_, _ -> new", pure = true) public static @NotNull Component commandHelp(@NotNull String keyPrefix, boolean appendHelp) { keyPrefix = appendHelp ? keyPrefix + ".help" : keyPrefix; From a80a31151631c37f03b7a989e65a8c39526c9644 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Fri, 21 Jan 2022 10:00:04 +0900 Subject: [PATCH 30/53] change(api): hide the constructor --- .../main/java/net/okocraft/box/api/message/Components.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/src/main/java/net/okocraft/box/api/message/Components.java b/api/src/main/java/net/okocraft/box/api/message/Components.java index 2037ad37f5..efb8251367 100644 --- a/api/src/main/java/net/okocraft/box/api/message/Components.java +++ b/api/src/main/java/net/okocraft/box/api/message/Components.java @@ -278,4 +278,8 @@ public final class Components { .append(grayTranslatable(keyPrefix + ".description")) .build(); } + + private Components() { + throw new UnsupportedOperationException(); + } } From 19ca3882b4452b73273bd7281aef5a7a63f64876 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Sun, 30 Jan 2022 08:41:43 +0900 Subject: [PATCH 31/53] fix(craft): add slot number to equals and hashCode --- .../okocraft/box/feature/craft/model/IngredientHolder.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java index bf60c717ff..553d9ed4e4 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java @@ -58,6 +58,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; IngredientHolder that = (IngredientHolder) o; + if (slot != that.slot) { + return false; + } + if (patterns.size() != that.patterns.size()) { return false; } @@ -73,7 +77,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return patterns.hashCode(); + return Objects.hash(slot, patterns); } public static class SelectableIngredients { From dce7164eca529a814966bdf9c160183dbf6e3101 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Sun, 30 Jan 2022 08:42:35 +0900 Subject: [PATCH 32/53] improve(craft): use Collections#unmodifiableList --- .../net/okocraft/box/feature/craft/model/IngredientHolder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java index 553d9ed4e4..28cb9e2a52 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java @@ -7,6 +7,7 @@ import org.jetbrains.annotations.Unmodifiable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -37,7 +38,7 @@ private IngredientHolder(int slot, @NotNull List patterns) { boxItem.ifPresent(value -> tempPattern.add(new BoxIngredientItem(value, item.getAmount()))); } - this.patterns = List.copyOf(tempPattern); + this.patterns = Collections.unmodifiableList(tempPattern); } public int getSlot() { From e295ba2e41ef225d76f68a2630915826ffb812f6 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Sun, 30 Jan 2022 08:50:10 +0900 Subject: [PATCH 33/53] improve(craft): reduce objects that will be generated while enabling --- .../box/feature/craft/CraftFeature.java | 8 ++++ .../feature/craft/model/IngredientHolder.java | 10 ++-- .../box/feature/craft/model/ModelCache.java | 47 +++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 features/craft/src/main/java/net/okocraft/box/feature/craft/model/ModelCache.java diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java index 5fe3427a57..55e59d0a37 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/CraftFeature.java @@ -11,6 +11,7 @@ import net.okocraft.box.feature.craft.command.CraftCommand; import net.okocraft.box.feature.craft.loader.RecipeLoader; import net.okocraft.box.feature.craft.mode.CraftMode; +import net.okocraft.box.feature.craft.model.ModelCache; import net.okocraft.box.feature.gui.GuiFeature; import net.okocraft.box.feature.gui.api.mode.ClickModeRegistry; import org.bukkit.command.CommandSender; @@ -43,8 +44,15 @@ public void enable() { BoxProvider.get().getLogger().log(Level.SEVERE, "Could not load recipes.yml", e); } + // Reduce objects that will be generated + // BoxIngredientItem 5030 -> 325 + // IngredientHolder 3506 -> 1417 + ModelCache.createCache(); + var recipeMap = RecipeLoader.load(recipeConfig); + ModelCache.clearCache(); + RecipeRegistry.setRecipeMap(recipeMap); BoxProvider.get().getLogger().info(recipeMap.size() + " recipes are imported!"); diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java index 28cb9e2a52..cc6ad671fe 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/IngredientHolder.java @@ -14,28 +14,28 @@ public class IngredientHolder { public static @NotNull IngredientHolder fromMaterialChoice(int slot, @NotNull RecipeChoice.MaterialChoice choice) { - return new IngredientHolder(slot, choice.getChoices().stream().map(ItemStack::new).toList()); + return ModelCache.getIngredientHolder(slot, choice.getChoices().stream().map(ItemStack::new).toList()); } public static @NotNull IngredientHolder fromExactChoice(int slot, @NotNull RecipeChoice.ExactChoice choice) { - return new IngredientHolder(slot, choice.getChoices()); + return ModelCache.getIngredientHolder(slot, choice.getChoices()); } public static @NotNull IngredientHolder fromSingleItem(int slot, @NotNull ItemStack itemStack) { - return new IngredientHolder(slot, List.of(itemStack)); + return ModelCache.getIngredientHolder(slot, List.of(itemStack)); } private final int slot; private final List patterns; - private IngredientHolder(int slot, @NotNull List patterns) { + IngredientHolder(int slot, @NotNull List patterns) { this.slot = slot; var tempPattern = new ArrayList(); for (var item : patterns) { var boxItem = BoxProvider.get().getItemManager().getBoxItem(item); - boxItem.ifPresent(value -> tempPattern.add(new BoxIngredientItem(value, item.getAmount()))); + boxItem.ifPresent(value -> tempPattern.add(ModelCache.getIngredientItem(value, item.getAmount()))); } this.patterns = Collections.unmodifiableList(tempPattern); diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/model/ModelCache.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/ModelCache.java new file mode 100644 index 0000000000..837d9be957 --- /dev/null +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/model/ModelCache.java @@ -0,0 +1,47 @@ +package net.okocraft.box.feature.craft.model; + +import net.okocraft.box.api.model.item.BoxItem; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +public final class ModelCache { + + private static Map GENERATED_INGREDIENT_ITEMS = null; + private static Map INGREDIENT_HOLDER_CACHE = null; + + public static void createCache() { + GENERATED_INGREDIENT_ITEMS = new HashMap<>(100); + INGREDIENT_HOLDER_CACHE = new HashMap<>(300); + } + + public static void clearCache() { + GENERATED_INGREDIENT_ITEMS = null; + INGREDIENT_HOLDER_CACHE = null; + } + + static @NotNull BoxIngredientItem getIngredientItem(@NotNull BoxItem item, int amount) { + return GENERATED_INGREDIENT_ITEMS != null && amount == 1 ? + GENERATED_INGREDIENT_ITEMS.computeIfAbsent(item, ModelCache::createIngredientItem) : + new BoxIngredientItem(item, amount); + } + + static @NotNull IngredientHolder getIngredientHolder(int slot, @NotNull List patterns) { + var holder = new IngredientHolder(slot, patterns); + return INGREDIENT_HOLDER_CACHE != null ? + INGREDIENT_HOLDER_CACHE.computeIfAbsent(holder, Function.identity()) : + holder; + } + + private static @NotNull BoxIngredientItem createIngredientItem(@NotNull BoxItem item) { + return new BoxIngredientItem(item, 1); + } + + private ModelCache() { + throw new UnsupportedOperationException(); + } +} From 2c1838c5ada2df92c94a19c96d4c8029a1db4d8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Feb 2022 13:13:40 +0000 Subject: [PATCH 34/53] build(deps): bump io.freefair.aggregate-javadoc from 6.3.0 to 6.4.0 Bumps io.freefair.aggregate-javadoc from 6.3.0 to 6.4.0. --- updated-dependencies: - dependency-name: io.freefair.aggregate-javadoc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2b714833ae..decde8d886 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("io.freefair.aggregate-javadoc") version "6.3.0" + id("io.freefair.aggregate-javadoc") version "6.4.0" } tasks { From 59eac08367ed94f45d9394ccf0d0d9e6448206df Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Wed, 23 Mar 2022 19:32:05 +0900 Subject: [PATCH 35/53] build: update gradle to 7.4.1 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e5897b5..00e33edef6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 758c3fe78436ce5f2c699b3cf9243715b4a132cf Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Wed, 23 Mar 2022 19:36:23 +0900 Subject: [PATCH 36/53] ci: update actions dependencies --- .github/workflows/deployment.yml | 4 ++-- .github/workflows/gradle.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index a03463b6d3..5139fe37f5 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -10,9 +10,9 @@ jobs: runs-on: ubuntu-latest if: "! contains(github.event.head_commit.message, '[DEPLOY-SKIP]')" steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v3.0.0 - name: Set up JDK 16 - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3.0.0 with: distribution: 'temurin' java-version: '16' diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f0e9aac1bc..ec61aa9555 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -5,9 +5,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v3.0.0 - name: Set up JDK 16 - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v3.0.0 with: distribution: 'temurin' java-version: '16' @@ -32,7 +32,7 @@ jobs: mv features/gui/build staging/features/gui mv features/notifier/build staging/features/notifier mv features/stick/build staging/features/stick - - uses: actions/upload-artifact@v2.3.1 + - uses: actions/upload-artifact@v3.0.0 with: name: Package path: staging From c72c201c46d5fd80af44610140e91d9207fc6c2d Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Wed, 23 Mar 2022 19:41:55 +0900 Subject: [PATCH 37/53] ci: use gradle actions --- .github/workflows/deployment.yml | 17 ++++++++++++----- .github/workflows/gradle.yml | 16 ++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 5139fe37f5..6faeb1cc3d 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -17,12 +17,19 @@ jobs: distribution: 'temurin' java-version: '16' cache: 'gradle' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1.0.4 + - run: chmod +x ./gradlew - name: Deploy to staging directory - run: | - chmod +x ./gradlew - ./gradlew clean - ./gradlew publish -P box.publish=true - ./gradlew aggregateJavadoc + uses: gradle/gradle-build-action@v2.1.4 + with: + arguments: | + clean + publish -P box.publish=true + - name: Generate Javadocs + uses: gradle/gradle-build-action@v2.1.4 + with: + arguments: aggregateJavadoc - name: Move Javadoc pages to staging directory (release) if: ${{ github.ref == 'refs/heads/v4/master' }} run: | diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ec61aa9555..2722831231 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -12,12 +12,16 @@ jobs: distribution: 'temurin' java-version: '16' cache: 'gradle' - - name: Build - run: | - chmod +x ./gradlew - ./gradlew clean - ./gradlew build - ./gradlew shadowJar + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1.0.4 + - run: chmod +x ./gradlew + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.1.4 + with: + arguments: | + clean + build + shadowJar - name: Move the artifact run: | mkdir staging From 1b67668301cd08ddcdf921a7444f6cd01fa1b2a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Feb 2022 11:31:13 +0000 Subject: [PATCH 38/53] build(deps): bump io.freefair.aggregate-javadoc from 6.4.0 to 6.4.1 Bumps io.freefair.aggregate-javadoc from 6.4.0 to 6.4.1. --- updated-dependencies: - dependency-name: io.freefair.aggregate-javadoc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index decde8d886..9251f688f6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("io.freefair.aggregate-javadoc") version "6.4.0" + id("io.freefair.aggregate-javadoc") version "6.4.1" } tasks { From e4a4cdd8c8f92ab5e69d1331251308c39570982c Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Wed, 23 Mar 2022 20:15:36 +0900 Subject: [PATCH 39/53] refactor: improve XmasChecker --- .../gui/internal/util/XmasChecker.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/util/XmasChecker.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/util/XmasChecker.java index a6eb5abda1..9ffc59e90b 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/util/XmasChecker.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/util/XmasChecker.java @@ -1,10 +1,9 @@ package net.okocraft.box.feature.gui.internal.util; -import java.time.Instant; -import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.Month; +import java.time.ZoneId; import java.time.temporal.ChronoUnit; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; @@ -23,20 +22,19 @@ private static void checkXmas() { return; } - var today = LocalDate.now(); + var today = LocalDateTime.now(); IS_XMAS.set( today.getMonth() == Month.DECEMBER && (today.getDayOfMonth() == 24 || today.getDayOfMonth() == 25) ); - if (NEXT_XMAS_CHECK_TIME.get() == 0) { - NEXT_XMAS_CHECK_TIME.set( - Instant.now().plus(1, ChronoUnit.HOURS) - .truncatedTo(ChronoUnit.HOURS).toEpochMilli() - ); - } else { - NEXT_XMAS_CHECK_TIME.addAndGet(TimeUnit.HOURS.toMillis(1)); - } + NEXT_XMAS_CHECK_TIME.set( + today.truncatedTo(ChronoUnit.DAYS) + .plusDays(1) + .atZone(ZoneId.systemDefault()) + .toInstant() + .toEpochMilli() + ); } } From 251db59b0dab18389a98a7b1a56e25fd9c6bbc86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 11:20:09 +0000 Subject: [PATCH 40/53] build(deps): bump actions/setup-java from 3.0.0 to 3.1.0 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3.0.0...v3.1.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 2 +- .github/workflows/gradle.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 6faeb1cc3d..9bbf786bc1 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3.0.0 - name: Set up JDK 16 - uses: actions/setup-java@v3.0.0 + uses: actions/setup-java@v3.1.0 with: distribution: 'temurin' java-version: '16' diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 2722831231..0663a54a8e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v3.0.0 - name: Set up JDK 16 - uses: actions/setup-java@v3.0.0 + uses: actions/setup-java@v3.1.0 with: distribution: 'temurin' java-version: '16' From 0b6856632cf13f93442d741d14dadba5ddd46ce4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 11:25:16 +0000 Subject: [PATCH 41/53] build(deps): bump gradle/gradle-build-action from 2.1.4 to 2.1.5 Bumps [gradle/gradle-build-action](https://github.com/gradle/gradle-build-action) from 2.1.4 to 2.1.5. - [Release notes](https://github.com/gradle/gradle-build-action/releases) - [Commits](https://github.com/gradle/gradle-build-action/compare/v2.1.4...v2.1.5) --- updated-dependencies: - dependency-name: gradle/gradle-build-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 4 ++-- .github/workflows/gradle.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 9bbf786bc1..fc40deb37f 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -21,13 +21,13 @@ jobs: uses: gradle/wrapper-validation-action@v1.0.4 - run: chmod +x ./gradlew - name: Deploy to staging directory - uses: gradle/gradle-build-action@v2.1.4 + uses: gradle/gradle-build-action@v2.1.5 with: arguments: | clean publish -P box.publish=true - name: Generate Javadocs - uses: gradle/gradle-build-action@v2.1.4 + uses: gradle/gradle-build-action@v2.1.5 with: arguments: aggregateJavadoc - name: Move Javadoc pages to staging directory (release) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 0663a54a8e..ed6aebda3a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -16,7 +16,7 @@ jobs: uses: gradle/wrapper-validation-action@v1.0.4 - run: chmod +x ./gradlew - name: Build with Gradle - uses: gradle/gradle-build-action@v2.1.4 + uses: gradle/gradle-build-action@v2.1.5 with: arguments: | clean From 6ee4761853e538dfb1d7e4bea040b5fb611752a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 11:23:40 +0000 Subject: [PATCH 42/53] build(deps): bump io.freefair.aggregate-javadoc from 6.4.1 to 6.4.2 Bumps io.freefair.aggregate-javadoc from 6.4.1 to 6.4.2. --- updated-dependencies: - dependency-name: io.freefair.aggregate-javadoc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9251f688f6..77d65a40bf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("io.freefair.aggregate-javadoc") version "6.4.1" + id("io.freefair.aggregate-javadoc") version "6.4.2" } tasks { From acd903633fa528e4ce37c60116db30bd7080ab9d Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Sun, 10 Apr 2022 12:01:53 +0900 Subject: [PATCH 43/53] fix(gui): copy mode list on initializing --- .../okocraft/box/feature/gui/api/mode/ClickModeRegistry.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java index 800684fb31..3a3c56d763 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java @@ -5,7 +5,6 @@ import org.jetbrains.annotations.Unmodifiable; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public final class ClickModeRegistry { @@ -13,7 +12,7 @@ public final class ClickModeRegistry { private static final StorageMode STORAGE_MODE = new StorageMode(); private static final List REGISTERED_BOX_ITEM_CLICK_MODE = new ArrayList<>(List.of(STORAGE_MODE)); - private static List COPIED_REGISTERED_BOX_ITEM_CLICK_MODE = Collections.emptyList(); + private static List COPIED_REGISTERED_BOX_ITEM_CLICK_MODE = List.copyOf(REGISTERED_BOX_ITEM_CLICK_MODE); public static @NotNull StorageMode getStorageMode() { return STORAGE_MODE; From 624780ce4c548b0bdac3f03c2f80819094fef16c Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Sun, 10 Apr 2022 12:05:15 +0900 Subject: [PATCH 44/53] chore(gui): add COPIED_REGISTERED_BOX_ITEM_CLICK_MODE comment --- .../okocraft/box/feature/gui/api/mode/ClickModeRegistry.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java index 3a3c56d763..3e98845c60 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/mode/ClickModeRegistry.java @@ -12,6 +12,8 @@ public final class ClickModeRegistry { private static final StorageMode STORAGE_MODE = new StorageMode(); private static final List REGISTERED_BOX_ITEM_CLICK_MODE = new ArrayList<>(List.of(STORAGE_MODE)); + // Because ClickModeRegistry#getModes is called frequently, + // keep a copied list to reduce calls to List#copyOf and Collections#unmodifiableList. private static List COPIED_REGISTERED_BOX_ITEM_CLICK_MODE = List.copyOf(REGISTERED_BOX_ITEM_CLICK_MODE); public static @NotNull StorageMode getStorageMode() { From fa4e5c5929631ef737bf20077c18e5224db3dda4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Apr 2022 11:19:24 +0000 Subject: [PATCH 45/53] build(deps): bump actions/checkout from 3.0.0 to 3.0.1 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.0.0...v3.0.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 2 +- .github/workflows/gradle.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index fc40deb37f..10e45e9273 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: "! contains(github.event.head_commit.message, '[DEPLOY-SKIP]')" steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.0.1 - name: Set up JDK 16 uses: actions/setup-java@v3.1.0 with: diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ed6aebda3a..ee619a7c0e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -5,7 +5,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.0.1 - name: Set up JDK 16 uses: actions/setup-java@v3.1.0 with: From 55de5907e018d467e8f3067f15461ab30ca12300 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Apr 2022 13:52:52 +0000 Subject: [PATCH 46/53] build(deps): bump actions/setup-java from 3.1.0 to 3.1.1 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3.1.0...v3.1.1) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 2 +- .github/workflows/gradle.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 10e45e9273..d3e491d966 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3.0.1 - name: Set up JDK 16 - uses: actions/setup-java@v3.1.0 + uses: actions/setup-java@v3.1.1 with: distribution: 'temurin' java-version: '16' diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ee619a7c0e..f33493f150 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v3.0.1 - name: Set up JDK 16 - uses: actions/setup-java@v3.1.0 + uses: actions/setup-java@v3.1.1 with: distribution: 'temurin' java-version: '16' From 111b51b9cbcd87a468791a44d223652a129e8b40 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Thu, 28 Apr 2022 03:41:53 +0900 Subject: [PATCH 47/53] build: update gradle to 7.4.2 --- gradle/wrapper/gradle-wrapper.jar | Bin 59536 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 10 +++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae8848c63b8b4dea2cb829da983f2fa..41d9927a4d4fb3f96a785543079b8df6723c946b 100644 GIT binary patch delta 8958 zcmY+KWl$VIlZIh&f(Hri?gR<$?iyT!TL`X;1^2~W7YVSq1qtqM!JWlDxLm%}UESUM zndj}Uny%^UnjhVhFb!8V3s(a#fIy>`VW15{5nuy;_V&a5O#0S&!a4dSkUMz_VHu3S zGA@p9Q$T|Sj}tYGWdjH;Mpp8m&yu&YURcrt{K;R|kM~(*{v%QwrBJIUF+K1kX5ZmF zty3i{d`y0;DgE+de>vN@yYqFPe1Ud{!&G*Q?iUc^V=|H%4~2|N zW+DM)W!`b&V2mQ0Y4u_)uB=P@-2`v|Wm{>CxER1P^ z>c}ZPZ)xxdOCDu59{X^~2id7+6l6x)U}C4Em?H~F`uOxS1?}xMxTV|5@}PlN%Cg$( zwY6c}r60=z5ZA1L zTMe;84rLtYvcm?M(H~ZqU;6F7Evo{P7!LGcdwO|qf1w+)MsnvK5^c@Uzj<{ zUoej1>95tuSvDJ|5K6k%&UF*uE6kBn47QJw^yE&#G;u^Z9oYWrK(+oL97hBsUMc_^ z;-lmxebwlB`Er_kXp2$`&o+rPJAN<`WX3ws2K{q@qUp}XTfV{t%KrsZ5vM!Q#4{V& zq>iO$MCiLq#%wXj%`W$_%FRg_WR*quv65TdHhdpV&jlq<=K^K`&!Kl5mA6p4n~p3u zWE{20^hYpn1M}}VmSHBXl1*-)2MP=0_k)EPr#>EoZukiXFDz?Di1I>2@Z^P$pvaF+ zN+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(%%`WswrDyzX*rn}i}}TB4^y#@mAwPzoC)`?rYv zHgx|trUN#mu*VzUV~8TnJM2Qh*ZM5B{x&y>5An`(M7=Z*Q>TdiH@j*2=moNuOtvpz z+G`@~-`%~+AgPKgke@XiRPgndh@bp*-HRsh;HTtz@-y_uhb%7ylVOTqG0#u?Vn5c5 zEp*XRo|8hcgG^$#{$O9CJ&NE;TrfRpSnLmes&MO{m=N%zc`}gb!eQ7odl$oy1%PI} z#AIxx%oRVy&{O~9xnK4$EY>(eQj}!HKIV$Fz*H=-=Kn)N0D6u`(;iO|VraI4fu_W` z;b5{7;Lyx4za}DU#+U7}=H0dAS#YJJ&g2!P@Htu-AL&w=-)*%P9h2{wR|@?Ff9~)b z^+e_3Hetq7W%ls{!?<6&Y$Z;NNB41pvrv)|MET6AZXFXJeFqbFW5@i5WGzl?bP+~? z*&_puH;wKv2)9T_d+P`bLvJFqX#j&xa*-;0nGBbQf0DC>o~=J_Wmtf*2SZQr?{i~X z9-IbRH8{iy?<0v9Ir1?$66+igy|yDQ5J~A9sFX@Pe<*kCY8+MwH?I z`P}zfQ6l^AO8ehZ=l^ZR;R%uu4;BK*=?W9t|0{+-at(MQZ(CtG=EJFNaFMlKCMXu30(gJUqj5+ z`GM|!keqcj;FKTa_qq;{*dHRXAq157hlB@kL#8%yAm2AgfU|*rDKX@FLlp=HL8ddv zAWLCHe@DcDeB2}fl7#=0+#<05c3=VqM*O3bkr@9X4nO|)q0hU;Gye{L8ZN*NH8Id@mP-u;Fmb8YuorjLrW&ndip8CN%_qp982r w1WEnz9^$&s1hkp_3#lPJQ~!HI7WYYjA7>z!`?f%npAh2%rB@vD|Lau$2O)#1n*aa+ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 00e33edef6..aa991fceae 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 76ccb9c36c..1b6c787337 100644 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright ? 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions $var, ${var}, ${var:-default}, ${var+SET}, -# ${var#prefix}, ${var%suffix}, and $( cmd ); -# * compound commands having a testable exit status, especially case; -# * various built-in commands including command, set, and ulimit. +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # From 5f7818acc63c1d9b00e51d83d18f20a936737724 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 11:24:31 +0000 Subject: [PATCH 48/53] build(deps): bump actions/setup-java from 3.1.1 to 3.2.0 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.1.1 to 3.2.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3.1.1...v3.2.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 2 +- .github/workflows/gradle.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index d3e491d966..6b360da288 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3.0.1 - name: Set up JDK 16 - uses: actions/setup-java@v3.1.1 + uses: actions/setup-java@v3.2.0 with: distribution: 'temurin' java-version: '16' diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f33493f150..ac81e3dd1d 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v3.0.1 - name: Set up JDK 16 - uses: actions/setup-java@v3.1.1 + uses: actions/setup-java@v3.2.0 with: distribution: 'temurin' java-version: '16' From b5cb61df43337d02d4a1411c03626151f35df9ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:24:25 +0000 Subject: [PATCH 49/53] build(deps): bump actions/checkout from 3.0.1 to 3.0.2 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.0.1...v3.0.2) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 2 +- .github/workflows/gradle.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 6b360da288..13cce9951c 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: "! contains(github.event.head_commit.message, '[DEPLOY-SKIP]')" steps: - - uses: actions/checkout@v3.0.1 + - uses: actions/checkout@v3.0.2 - name: Set up JDK 16 uses: actions/setup-java@v3.2.0 with: diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ac81e3dd1d..607ed1577b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -5,7 +5,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.0.1 + - uses: actions/checkout@v3.0.2 - name: Set up JDK 16 uses: actions/setup-java@v3.2.0 with: From 78174e2843b757fe2016db331b91611b1032e434 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 11:24:41 +0000 Subject: [PATCH 50/53] build(deps): bump io.freefair.aggregate-javadoc from 6.4.2 to 6.4.3 Bumps [io.freefair.aggregate-javadoc](https://github.com/freefair/gradle-plugins) from 6.4.2 to 6.4.3. - [Release notes](https://github.com/freefair/gradle-plugins/releases) - [Commits](https://github.com/freefair/gradle-plugins/compare/6.4.2...6.4.3) --- updated-dependencies: - dependency-name: io.freefair.aggregate-javadoc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 77d65a40bf..a77aae1eca 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("io.freefair.aggregate-javadoc") version "6.4.2" + id("io.freefair.aggregate-javadoc") version "6.4.3" } tasks { From d81342a12311b4a530d4364831ba4b8598127184 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 May 2022 11:23:43 +0000 Subject: [PATCH 51/53] build(deps): bump actions/upload-artifact from 3.0.0 to 3.1.0 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3.0.0...v3.1.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 607ed1577b..eae8f37fbc 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -36,7 +36,7 @@ jobs: mv features/gui/build staging/features/gui mv features/notifier/build staging/features/notifier mv features/stick/build staging/features/stick - - uses: actions/upload-artifact@v3.0.0 + - uses: actions/upload-artifact@v3.1.0 with: name: Package path: staging From af7dc9627ad81a94cb94b770cf9bf5adbe7b9bd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 May 2022 11:18:49 +0000 Subject: [PATCH 52/53] build(deps): bump actions/setup-java from 3.2.0 to 3.3.0 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v3.2.0...v3.3.0) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 2 +- .github/workflows/gradle.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 13cce9951c..41c06947d9 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3.0.2 - name: Set up JDK 16 - uses: actions/setup-java@v3.2.0 + uses: actions/setup-java@v3.3.0 with: distribution: 'temurin' java-version: '16' diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index eae8f37fbc..06891560e3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v3.0.2 - name: Set up JDK 16 - uses: actions/setup-java@v3.2.0 + uses: actions/setup-java@v3.3.0 with: distribution: 'temurin' java-version: '16' From 167a18790aafcff73c3d1561f94476844efba218 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 11:22:39 +0000 Subject: [PATCH 53/53] build(deps): bump gradle/gradle-build-action from 2.1.5 to 2.1.7 Bumps [gradle/gradle-build-action](https://github.com/gradle/gradle-build-action) from 2.1.5 to 2.1.7. - [Release notes](https://github.com/gradle/gradle-build-action/releases) - [Commits](https://github.com/gradle/gradle-build-action/compare/v2.1.5...v2.1.7) --- updated-dependencies: - dependency-name: gradle/gradle-build-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/deployment.yml | 4 ++-- .github/workflows/gradle.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 41c06947d9..bdd3ca531e 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -21,13 +21,13 @@ jobs: uses: gradle/wrapper-validation-action@v1.0.4 - run: chmod +x ./gradlew - name: Deploy to staging directory - uses: gradle/gradle-build-action@v2.1.5 + uses: gradle/gradle-build-action@v2.1.7 with: arguments: | clean publish -P box.publish=true - name: Generate Javadocs - uses: gradle/gradle-build-action@v2.1.5 + uses: gradle/gradle-build-action@v2.1.7 with: arguments: aggregateJavadoc - name: Move Javadoc pages to staging directory (release) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 06891560e3..5aa0c3fd5e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -16,7 +16,7 @@ jobs: uses: gradle/wrapper-validation-action@v1.0.4 - run: chmod +x ./gradlew - name: Build with Gradle - uses: gradle/gradle-build-action@v2.1.5 + uses: gradle/gradle-build-action@v2.1.7 with: arguments: | clean