From a92c6953365a4588683fe969564fdacd9a2929c0 Mon Sep 17 00:00:00 2001 From: Siroshun09 Date: Mon, 27 May 2024 19:40:31 +0900 Subject: [PATCH] style(*): add `this` qualifier for methods --- .../net/okocraft/box/api/event/BoxEvent.java | 2 +- .../player/PlayerStockHolderChangeEvent.java | 4 +-- .../box/api/model/stock/StockHolder.java | 4 +-- .../api/model/stock/StockHolderWrapper.java | 24 ++++++------- .../box/api/transaction/DepositImpl.java | 4 +-- .../box/api/transaction/WithdrawalImpl.java | 4 +-- .../net/okocraft/box/api/util/Version.java | 2 +- .../net/okocraft/box/plugin/BoxPlugin.java | 2 +- .../java/net/okocraft/box/core/BoxCore.java | 4 +-- .../box/core/command/BaseCommand.java | 12 +++---- .../core/model/manager/item/BoxItemMap.java | 26 +++++++------- .../model/manager/item/BukkitBoxItemMap.java | 12 +++---- .../box/core/model/stock/StockHolderImpl.java | 4 +-- .../box/core/player/BoxPlayerMapImpl.java | 4 +-- .../autostore/AutoStoreSettingContainer.java | 4 +-- .../autostore/command/AutoStoreCommand.java | 4 +-- .../command/AutoStoreItemCommand.java | 6 ++-- .../gui/buttons/BulkEditingButton.java | 2 +- .../autostore/gui/buttons/DirectButton.java | 2 +- .../autostore/gui/buttons/ModeButton.java | 2 +- .../autostore/gui/buttons/ToggleButton.java | 2 +- .../autostore/listener/ItemListener.java | 12 +++---- .../autostore/setting/AutoStoreSetting.java | 2 +- .../bemode/mode/StorageDepositMode.java | 2 +- .../bemode/mode/StorageWithdrawMode.java | 2 +- .../feature/command/box/DepositCommand.java | 12 +++---- .../box/feature/command/box/GiveCommand.java | 4 +-- .../boxadmin/stock/StockModifyCommands.java | 2 +- .../box/feature/craft/CraftFeature.java | 4 +-- .../box/feature/craft/gui/CurrentRecipe.java | 2 +- .../box/feature/craft/loader/Processor.java | 14 ++++---- .../feature/gui/api/event/MenuClickEvent.java | 22 ++++++------ .../feature/gui/api/event/MenuOpenEvent.java | 14 ++++---- .../menu/paginate/AbstractPaginatedMenu.java | 6 ++-- .../box/feature/gui/api/session/Amount.java | 2 +- .../gui/api/session/PlayerSession.java | 2 +- .../gui/internal/command/MenuOpenCommand.java | 6 ++-- .../internal/holder/BoxInventoryHolder.java | 6 ++-- .../internal/listener/InventoryListener.java | 2 +- .../gui/internal/mode/StorageMode.java | 4 +-- .../feature/stick/listener/StickListener.java | 36 +++++++++---------- .../database/mysql/MySQLDatabase.java | 6 ++-- .../database/sqlite/SQLiteDatabase.java | 2 +- .../table/AbstractCustomDataTable.java | 14 ++++---- .../database/table/AbstractTable.java | 2 +- .../database/table/CustomDataTable.java | 4 +-- .../database/table/ItemTable.java | 28 +++++++-------- .../database/table/LegacyCustomDataTable.java | 2 +- .../database/table/MetaTable.java | 18 +++++----- .../database/table/StockTable.java | 6 ++-- .../database/table/UserTable.java | 12 +++---- .../implementation/AbstractDataMigrator.java | 2 +- .../implementation/yaml/YamlUserStorage.java | 6 ++-- .../memory/user/MemoryUserStorage.java | 2 +- 54 files changed, 195 insertions(+), 195 deletions(-) diff --git a/api/src/main/java/net/okocraft/box/api/event/BoxEvent.java b/api/src/main/java/net/okocraft/box/api/event/BoxEvent.java index 30c34f1aa4..d3ffea5a5f 100644 --- a/api/src/main/java/net/okocraft/box/api/event/BoxEvent.java +++ b/api/src/main/java/net/okocraft/box/api/event/BoxEvent.java @@ -19,7 +19,7 @@ public BoxEvent() { * @return the debug log */ public @NotNull String toDebugLog() { - return toString(); + return this.toString(); } } diff --git a/api/src/main/java/net/okocraft/box/api/event/player/PlayerStockHolderChangeEvent.java b/api/src/main/java/net/okocraft/box/api/event/player/PlayerStockHolderChangeEvent.java index 4a76424e04..b1217cf99f 100644 --- a/api/src/main/java/net/okocraft/box/api/event/player/PlayerStockHolderChangeEvent.java +++ b/api/src/main/java/net/okocraft/box/api/event/player/PlayerStockHolderChangeEvent.java @@ -37,8 +37,8 @@ public PlayerStockHolderChangeEvent(@NotNull BoxPlayer boxPlayer, @Override public @NotNull String toDebugLog() { return "PlayerStockHolderChangeEvent{" + - "uuid=" + getBoxPlayer().getUUID() + - ", name=" + getBoxPlayer().getName() + + "uuid=" + this.getBoxPlayer().getUUID() + + ", name=" + this.getBoxPlayer().getName() + ", previousStockholderUuid=" + this.previous.getUUID() + ", previousStockHolderName=" + this.previous.getName() + ", previousStockHolderClass=" + this.previous.getClass().getSimpleName() + diff --git a/api/src/main/java/net/okocraft/box/api/model/stock/StockHolder.java b/api/src/main/java/net/okocraft/box/api/model/stock/StockHolder.java index 2cccbc73a5..f3cc4d62cd 100644 --- a/api/src/main/java/net/okocraft/box/api/model/stock/StockHolder.java +++ b/api/src/main/java/net/okocraft/box/api/model/stock/StockHolder.java @@ -42,7 +42,7 @@ public interface StockHolder { * @throws NullPointerException if {@code item} is {@code null} */ default int getAmount(@NotNull BoxItem item) { - return getAmount(item.getInternalId()); + return this.getAmount(item.getInternalId()); } /** @@ -152,7 +152,7 @@ default boolean decreaseIfPossible(@NotNull Map decrementMap, map.put(entry.getKey(), entry.getValue().intValue()); } - return decreaseIfPossible(map, cause); + return this.decreaseIfPossible(map, cause); } /** diff --git a/api/src/main/java/net/okocraft/box/api/model/stock/StockHolderWrapper.java b/api/src/main/java/net/okocraft/box/api/model/stock/StockHolderWrapper.java index d8ca3b286c..161c000eb8 100644 --- a/api/src/main/java/net/okocraft/box/api/model/stock/StockHolderWrapper.java +++ b/api/src/main/java/net/okocraft/box/api/model/stock/StockHolderWrapper.java @@ -25,61 +25,61 @@ public interface StockHolderWrapper extends StockHolder { @Override default @NotNull String getName() { - return delegate().getName(); + return this.delegate().getName(); } @Override default @NotNull UUID getUUID() { - return delegate().getUUID(); + return this.delegate().getUUID(); } @Override default int getAmount(int itemId) { - return delegate().getAmount(itemId); + return this.delegate().getAmount(itemId); } @Override default void setAmount(@NotNull BoxItem item, @Range(from = 0, to = Integer.MAX_VALUE) int amount, StockEvent.@NotNull Cause cause) { - delegate().setAmount(item, amount, cause); + this.delegate().setAmount(item, amount, cause); } @Override default int increase(@NotNull BoxItem item, @Range(from = 0, to = Integer.MAX_VALUE) int increment, StockEvent.@NotNull Cause cause) { - return delegate().increase(item, increment, cause); + return this.delegate().increase(item, increment, cause); } @Override default int decrease(@NotNull BoxItem item, @Range(from = 0, to = Integer.MAX_VALUE) int decrement, StockEvent.@NotNull Cause cause) { - return delegate().decrease(item, decrement, cause); + return this.delegate().decrease(item, decrement, cause); } @Override default int decreaseToZero(@NotNull BoxItem item, @Range(from = 0, to = Integer.MAX_VALUE) int limit, StockEvent.@NotNull Cause cause) { - return delegate().decreaseToZero(item, limit, cause); + return this.delegate().decreaseToZero(item, limit, cause); } @Override default int decreaseIfPossible(@NotNull BoxItem item, @Range(from = 0, to = Integer.MAX_VALUE) int decrement, StockEvent.@NotNull Cause cause) { - return delegate().decreaseIfPossible(item, decrement, cause); + return this.delegate().decreaseIfPossible(item, decrement, cause); } @Override default boolean decreaseIfPossible(@NotNull Object2IntMap decrementMap, StockEvent.@NotNull Cause cause) { - return delegate().decreaseIfPossible(decrementMap, cause); + return this.delegate().decreaseIfPossible(decrementMap, cause); } @Override default @NotNull @Unmodifiable Collection getStockedItems() { - return delegate().getStockedItems(); + return this.delegate().getStockedItems(); } @Override default @NotNull @Unmodifiable Collection toStockDataCollection() { - return delegate().toStockDataCollection(); + return this.delegate().toStockDataCollection(); } @Override default @NotNull @Unmodifiable Collection reset() { - return delegate().reset(); + return this.delegate().reset(); } } diff --git a/api/src/main/java/net/okocraft/box/api/transaction/DepositImpl.java b/api/src/main/java/net/okocraft/box/api/transaction/DepositImpl.java index 96991e9101..0d56e8a797 100644 --- a/api/src/main/java/net/okocraft/box/api/transaction/DepositImpl.java +++ b/api/src/main/java/net/okocraft/box/api/transaction/DepositImpl.java @@ -22,12 +22,12 @@ record DepositImpl(@NotNull StockHolder stockHolder, @NotNull BoxItem boxItem, @Override public @NotNull @Unmodifiable List fromInventory(@NotNull Inventory inventory, @NotNull StockEvent.Cause cause) { - return fromInventory(inventory, null, cause); + return this.fromInventory(inventory, null, cause); } @Override public @NotNull @Unmodifiable List fromTopInventory(@NotNull InventoryView view, @NotNull StockEvent.Cause cause) { - return fromInventory(view.getTopInventory(), view, cause); + return this.fromInventory(view.getTopInventory(), view, cause); } private @NotNull List fromInventory(@NotNull Inventory inventory, @Nullable InventoryView view, @NotNull StockEvent.Cause cause) { diff --git a/api/src/main/java/net/okocraft/box/api/transaction/WithdrawalImpl.java b/api/src/main/java/net/okocraft/box/api/transaction/WithdrawalImpl.java index 68deb972c2..eefdad31d9 100644 --- a/api/src/main/java/net/okocraft/box/api/transaction/WithdrawalImpl.java +++ b/api/src/main/java/net/okocraft/box/api/transaction/WithdrawalImpl.java @@ -19,12 +19,12 @@ record WithdrawalImpl(@NotNull StockHolder stockHolder, @NotNull BoxItem boxItem @Override public @NotNull TransactionResult toInventory(@NotNull Inventory inventory, @NotNull StockEvent.Cause cause) { - return toInventory(inventory, null, cause); + return this.toInventory(inventory, null, cause); } @Override public @NotNull TransactionResult toTopInventory(@NotNull InventoryView view, @NotNull StockEvent.Cause cause) { - return toInventory(view.getTopInventory(), view, cause); + return this.toInventory(view.getTopInventory(), view, cause); } private @NotNull TransactionResult toInventory(@NotNull Inventory inventory, @Nullable InventoryView view, @NotNull StockEvent.Cause cause) { diff --git a/api/src/main/java/net/okocraft/box/api/util/Version.java b/api/src/main/java/net/okocraft/box/api/util/Version.java index 7de3676a57..3cf4ceea02 100644 --- a/api/src/main/java/net/okocraft/box/api/util/Version.java +++ b/api/src/main/java/net/okocraft/box/api/util/Version.java @@ -70,7 +70,7 @@ default boolean isAfterOrSame(@NotNull V other) { * @return {@code true} if this {@link Version} is contained between the specified {@link Version}s, otherwise {@code false} */ default boolean isBetween(@NotNull V startInclusive, @NotNull V endInclusive) { - return isAfterOrSame(startInclusive) && isBeforeOrSame(endInclusive); + return this.isAfterOrSame(startInclusive) && this.isBeforeOrSame(endInclusive); } } diff --git a/bundle/src/main/java/net/okocraft/box/plugin/BoxPlugin.java b/bundle/src/main/java/net/okocraft/box/plugin/BoxPlugin.java index d06c062747..03fd3799b6 100644 --- a/bundle/src/main/java/net/okocraft/box/plugin/BoxPlugin.java +++ b/bundle/src/main/java/net/okocraft/box/plugin/BoxPlugin.java @@ -110,7 +110,7 @@ public void onEnable() { } try { - runMigratorIfNeeded(); + this.runMigratorIfNeeded(); } catch (Exception e) { BoxLogger.logger().error("An exception occurred while migrating data.", e); this.status = Status.EXCEPTION_OCCURRED; diff --git a/core/src/main/java/net/okocraft/box/core/BoxCore.java b/core/src/main/java/net/okocraft/box/core/BoxCore.java index ab4e4d5555..b2b49d42ae 100644 --- a/core/src/main/java/net/okocraft/box/core/BoxCore.java +++ b/core/src/main/java/net/okocraft/box/core/BoxCore.java @@ -310,12 +310,12 @@ public void disableAllFeatures() { @Override public boolean canUseBox(@NotNull Player player) { - return !isDisabledWorld(player.getWorld()) || player.hasPermission("box.admin.ignore-disabled-world"); + return !this.isDisabledWorld(player.getWorld()) || player.hasPermission("box.admin.ignore-disabled-world"); } @Override public boolean isDisabledWorld(@NotNull World world) { - return isDisabledWorld(world.getName()); + return this.isDisabledWorld(world.getName()); } @Override diff --git a/core/src/main/java/net/okocraft/box/core/command/BaseCommand.java b/core/src/main/java/net/okocraft/box/core/command/BaseCommand.java index d98030a8af..9b86a76e59 100644 --- a/core/src/main/java/net/okocraft/box/core/command/BaseCommand.java +++ b/core/src/main/java/net/okocraft/box/core/command/BaseCommand.java @@ -39,7 +39,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { var source = this.messageProvider.findSource(sender); - if (!sender.hasPermission(getPermissionNode())) { + if (!sender.hasPermission(this.getPermissionNode())) { ErrorMessages.NO_PERMISSION.apply(this.getPermissionNode()).source(source).send(sender); return; } @@ -49,7 +49,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { this.scheduler.runAsyncTask(() -> this.commandOfNoArgument.onCommand(sender, args)); } else { ErrorMessages.NOT_ENOUGH_ARGUMENT.source(source).send(sender); - sendHelp(sender, source); + this.sendHelp(sender, source); } return; } @@ -60,7 +60,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { if (!args[0].equalsIgnoreCase("help")) { ErrorMessages.SUB_COMMAND_NOT_FOUND.source(source).send(sender); } - sendHelp(sender, source); + this.sendHelp(sender, source); return; } @@ -84,7 +84,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { Objects.requireNonNull(sender); Objects.requireNonNull(args); - if (args.length == 0 || !sender.hasPermission(getPermissionNode())) { + if (args.length == 0 || !sender.hasPermission(this.getPermissionNode())) { return Collections.emptyList(); } @@ -139,13 +139,13 @@ public void onAsyncTabComplete(@NotNull AsyncTabCompleteEvent event) { var label = buffer.substring(0, firstSpace).toLowerCase(Locale.ROOT); - if (!getName().equals(label) && !getAliases().contains(label)) { + if (!this.getName().equals(label) && !this.getAliases().contains(label)) { return; } String[] args = buffer.substring(firstSpace + 1).split(" ", -1); - event.setCompletions(onTabComplete(event.getSender(), args)); + event.setCompletions(this.onTabComplete(event.getSender(), args)); event.setHandled(true); } diff --git a/core/src/main/java/net/okocraft/box/core/model/manager/item/BoxItemMap.java b/core/src/main/java/net/okocraft/box/core/model/manager/item/BoxItemMap.java index 2dae52a82a..b769e2e7f0 100644 --- a/core/src/main/java/net/okocraft/box/core/model/manager/item/BoxItemMap.java +++ b/core/src/main/java/net/okocraft/box/core/model/manager/item/BoxItemMap.java @@ -50,7 +50,7 @@ boolean isRegistered(@NotNull String itemName) { Objects.requireNonNull(itemName); { long readAttempt = this.lock.tryOptimisticRead(); - boolean result = checkItemNameAtUnsynchronized(itemName); + boolean result = this.checkItemNameAtUnsynchronized(itemName); if (this.lock.validate(readAttempt)) { return result; @@ -60,7 +60,7 @@ boolean isRegistered(@NotNull String itemName) { this.lock.readLock(); try { - return checkItemNameAtUnsynchronized(itemName); + return this.checkItemNameAtUnsynchronized(itemName); } finally { this.lock.tryUnlockRead(); } @@ -70,7 +70,7 @@ boolean isRegistered(@NotNull String itemName) { Objects.requireNonNull(itemName); { long readAttempt = this.lock.tryOptimisticRead(); - var boxItem = getByItemNameAtUnsynchronized(itemName); + var boxItem = this.getByItemNameAtUnsynchronized(itemName); if (this.lock.validate(readAttempt)) { return boxItem; @@ -80,7 +80,7 @@ boolean isRegistered(@NotNull String itemName) { this.lock.readLock(); try { - return getByItemNameAtUnsynchronized(itemName); + return this.getByItemNameAtUnsynchronized(itemName); } finally { this.lock.tryUnlockRead(); } @@ -93,7 +93,7 @@ boolean isRegistered(@NotNull String itemName) { { long readAttempt = this.lock.tryOptimisticRead(); - var boxItem = getByIdAtUnsynchronized(id); + var boxItem = this.getByIdAtUnsynchronized(id); if (this.lock.validate(readAttempt)) { return boxItem; @@ -103,7 +103,7 @@ boolean isRegistered(@NotNull String itemName) { this.lock.readLock(); try { - return getByIdAtUnsynchronized(id); + return this.getByIdAtUnsynchronized(id); } finally { this.lock.tryUnlockRead(); } @@ -112,7 +112,7 @@ boolean isRegistered(@NotNull String itemName) { @NotNull IntImmutableList getItemIdList() { { long readAttempt = this.lock.tryOptimisticRead(); - var list = getItemIdListAtUnsynchronized(); + var list = this.getItemIdListAtUnsynchronized(); if (this.lock.validate(readAttempt)) { return list; @@ -122,7 +122,7 @@ boolean isRegistered(@NotNull String itemName) { this.lock.readLock(); try { - return getItemIdListAtUnsynchronized(); + return this.getItemIdListAtUnsynchronized(); } finally { this.lock.tryUnlockRead(); } @@ -131,7 +131,7 @@ boolean isRegistered(@NotNull String itemName) { @NotNull ObjectImmutableList getItemNameList() { { long readAttempt = this.lock.tryOptimisticRead(); - var list = getItemNameListAtUnsynchronized(); + var list = this.getItemNameListAtUnsynchronized(); if (this.lock.validate(readAttempt)) { return list; @@ -141,7 +141,7 @@ boolean isRegistered(@NotNull String itemName) { this.lock.readLock(); try { - return getItemNameListAtUnsynchronized(); + return this.getItemNameListAtUnsynchronized(); } finally { this.lock.tryUnlockRead(); } @@ -150,7 +150,7 @@ boolean isRegistered(@NotNull String itemName) { @NotNull ObjectImmutableList getItemList() { { long readAttempt = this.lock.tryOptimisticRead(); - var list = getBoxItemListAtUnsynchronized(); + var list = this.getBoxItemListAtUnsynchronized(); if (this.lock.validate(readAttempt)) { return list; @@ -160,7 +160,7 @@ boolean isRegistered(@NotNull String itemName) { this.lock.readLock(); try { - return getBoxItemListAtUnsynchronized(); + return this.getBoxItemListAtUnsynchronized(); } finally { this.lock.tryUnlockRead(); } @@ -201,7 +201,7 @@ void rebuildCache() { } private @Nullable BoxItem getByItemNameAtUnsynchronized(@NotNull String itemName) { - return getByIdAtUnsynchronized(this.itemNameToId.getInt(itemName)); + return this.getByIdAtUnsynchronized(this.itemNameToId.getInt(itemName)); } private @NotNull IntImmutableList getItemIdListAtUnsynchronized() { diff --git a/core/src/main/java/net/okocraft/box/core/model/manager/item/BukkitBoxItemMap.java b/core/src/main/java/net/okocraft/box/core/model/manager/item/BukkitBoxItemMap.java index 6ac5eb9f47..8f27f404da 100644 --- a/core/src/main/java/net/okocraft/box/core/model/manager/item/BukkitBoxItemMap.java +++ b/core/src/main/java/net/okocraft/box/core/model/manager/item/BukkitBoxItemMap.java @@ -40,7 +40,7 @@ boolean isRegistered(@NotNull ItemStack itemStack) { { long readAttempt = this.lock.tryOptimisticRead(); - boolean result = checkItemAtUnsynchronized(itemStack); + boolean result = this.checkItemAtUnsynchronized(itemStack); if (this.lock.validate(readAttempt)) { return result; @@ -50,7 +50,7 @@ boolean isRegistered(@NotNull ItemStack itemStack) { this.lock.readLock(); try { - return checkItemAtUnsynchronized(itemStack); + return this.checkItemAtUnsynchronized(itemStack); } finally { this.lock.tryUnlockRead(); } @@ -60,14 +60,14 @@ boolean isRegistered(@NotNull ItemStack itemStack) { Objects.requireNonNull(item); if (!item.hasItemMeta()) { - return getByItemName(item.getType().name()); + return this.getByItemName(item.getType().name()); } var one = item.asOne(); { long readAttempt = this.lock.tryOptimisticRead(); - var boxItem = getByItemStackAtUnsynchronized(one); + var boxItem = this.getByItemStackAtUnsynchronized(one); if (this.lock.validate(readAttempt)) { return boxItem; @@ -77,7 +77,7 @@ boolean isRegistered(@NotNull ItemStack itemStack) { this.lock.readLock(); try { - return getByItemStackAtUnsynchronized(one); + return this.getByItemStackAtUnsynchronized(one); } finally { this.lock.tryUnlockRead(); } @@ -100,6 +100,6 @@ void removeItemAtUnsynchronized(@NotNull BoxItem item) { } private @Nullable BoxItem getByItemStackAtUnsynchronized(@NotNull ItemStack item) { - return getByIdAtUnsynchronized(this.itemToId.getInt(item)); + return this.getByIdAtUnsynchronized(this.itemToId.getInt(item)); } } diff --git a/core/src/main/java/net/okocraft/box/core/model/stock/StockHolderImpl.java b/core/src/main/java/net/okocraft/box/core/model/stock/StockHolderImpl.java index 14b12324de..27f563d8e8 100644 --- a/core/src/main/java/net/okocraft/box/core/model/stock/StockHolderImpl.java +++ b/core/src/main/java/net/okocraft/box/core/model/stock/StockHolderImpl.java @@ -313,8 +313,8 @@ public boolean decreaseIfPossible(@NotNull Object2IntMap decrementMap, @Override public String toString() { var builder = - new StringBuilder(getClass().getSimpleName()) - .append("{name=").append(getName()) + new StringBuilder(this.getClass().getSimpleName()) + .append("{name=").append(this.getName()) .append(", uuid=").append(this.uuid) .append(", stockMap={"); this.writeStockMap(builder); diff --git a/core/src/main/java/net/okocraft/box/core/player/BoxPlayerMapImpl.java b/core/src/main/java/net/okocraft/box/core/player/BoxPlayerMapImpl.java index 6bceee3315..2b8a9aee62 100644 --- a/core/src/main/java/net/okocraft/box/core/player/BoxPlayerMapImpl.java +++ b/core/src/main/java/net/okocraft/box/core/player/BoxPlayerMapImpl.java @@ -77,7 +77,7 @@ public void scheduleLoadingData(@NotNull Player player) { private void load(@NotNull Player player) { try { - loadBoxPlayer(player); + this.loadBoxPlayer(player); } catch (Exception e) { this.playerMap.remove(player); BoxLogger.logger().error("Could not load a player ({})", player.getName(), e); @@ -118,7 +118,7 @@ private void unload(@NotNull BoxPlayerImpl boxPlayer) { public void loadAll() { Bukkit.getOnlinePlayers().forEach(player -> { this.playerMap.put(player, NOT_LOADED_YET); - load(player); + this.load(player); }); } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/AutoStoreSettingContainer.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/AutoStoreSettingContainer.java index 8ceca73644..5714581d3c 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/AutoStoreSettingContainer.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/AutoStoreSettingContainer.java @@ -52,8 +52,8 @@ public void save(@NotNull AutoStoreSetting setting) throws Exception { void registerBoxPlayerListener(@NotNull MiniMessageBase loadErrorMessage) { BoxAPI.api().getEventManager().subscribeAll(List.of( - new ListenerBase<>(PlayerLoadEvent.class, PLAYER_LISTENER_KEY, event -> load(event.getBoxPlayer().getPlayer(), loadErrorMessage), Priority.NORMAL), - new ListenerBase<>(PlayerUnloadEvent.class, PLAYER_LISTENER_KEY, event -> unload(event.getBoxPlayer().getPlayer()), Priority.NORMAL) + new ListenerBase<>(PlayerLoadEvent.class, PLAYER_LISTENER_KEY, event -> this.load(event.getBoxPlayer().getPlayer(), loadErrorMessage), Priority.NORMAL), + new ListenerBase<>(PlayerUnloadEvent.class, PLAYER_LISTENER_KEY, event -> this.unload(event.getBoxPlayer().getPlayer()), Priority.NORMAL) )); } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreCommand.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreCommand.java index eea51cf7cb..a977d15d10 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreCommand.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreCommand.java @@ -82,7 +82,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { } } - var subCommand = matchSubCommand(args[1]); + var subCommand = this.matchSubCommand(args[1]); if (subCommand.isPresent()) { subCommand.get().runCommand(sender, args, msgSrc, setting); @@ -107,7 +107,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { .collect(Collectors.toList()); } - return matchSubCommand(args[1]) + return this.matchSubCommand(args[1]) .map(cmd -> cmd.runTabComplete(sender, args)) .orElse(Collections.emptyList()); } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreItemCommand.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreItemCommand.java index 5b7552b2ba..846764c6b4 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreItemCommand.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/command/AutoStoreItemCommand.java @@ -55,7 +55,7 @@ void runCommand(@NotNull CommandSender sender, @NotNull String[] args, @NotNull var optionalBoxItem = itemManager.getBoxItem(args[2]); if (optionalBoxItem.isEmpty()) { - if (args.length < 4 || !isAll(args[2])) { + if (args.length < 4 || !this.isAll(args[2])) { ErrorMessages.ITEM_NOT_FOUND.apply(args[2]).source(msgSrc).send(sender); return; } @@ -67,7 +67,7 @@ void runCommand(@NotNull CommandSender sender, @NotNull String[] args, @NotNull } AutoStoreCommandUtil.changeAutoStore(setting, sender, msgSrc, true, false); - changeToPerItemMode(setting, sender, msgSrc); + this.changeToPerItemMode(setting, sender, msgSrc); perItemModeSetting.clearAndEnableItems(result ? itemManager.getItemIdList() : IntSet.of()); (result ? this.allEnabled : this.allDisabled).source(msgSrc).send(sender); @@ -95,7 +95,7 @@ void runCommand(@NotNull CommandSender sender, @NotNull String[] args, @NotNull } AutoStoreCommandUtil.changeAutoStore(setting, sender, msgSrc, true, false); - changeToPerItemMode(setting, sender, msgSrc); + this.changeToPerItemMode(setting, sender, msgSrc); (result ? this.itemEnabled : this.itemDisabled).apply(boxItem).source(msgSrc).send(sender); AutoStoreCommandUtil.callEvent(setting); diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/BulkEditingButton.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/BulkEditingButton.java index 78643309ab..564c0df05a 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/BulkEditingButton.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/BulkEditingButton.java @@ -98,7 +98,7 @@ public BulkEditingButton(@NotNull DefaultMessageCollector collector) { } sound.play(session.getViewer()); - callAutoStoreSettingChangeEvent(setting); + this.callAutoStoreSettingChangeEvent(setting); return result; } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/DirectButton.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/DirectButton.java index ab2f675c3f..1b42dfeec3 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/DirectButton.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/DirectButton.java @@ -60,7 +60,7 @@ public DirectButton(@NotNull DefaultMessageCollector collector) { } SoundBase.CLICK.play(session.getViewer()); - callAutoStoreSettingChangeEvent(setting); + this.callAutoStoreSettingChangeEvent(setting); return result; } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ModeButton.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ModeButton.java index ffb1df30fc..07462df64d 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ModeButton.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ModeButton.java @@ -59,7 +59,7 @@ public ModeButton(@NotNull DefaultMessageCollector collector) { } SoundBase.CLICK.play(session.getViewer()); - callAutoStoreSettingChangeEvent(setting); + this.callAutoStoreSettingChangeEvent(setting); return result; } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ToggleButton.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ToggleButton.java index 89c8e70cbb..01f89180c6 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ToggleButton.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/gui/buttons/ToggleButton.java @@ -52,7 +52,7 @@ public ToggleButton(@NotNull DefaultMessageCollector collector) { setting.setEnabled(!setting.isEnabled()); SoundBase.CLICK.play(session.getViewer()); - callAutoStoreSettingChangeEvent(setting); + this.callAutoStoreSettingChangeEvent(setting); return ClickResult.UPDATE_BUTTON; } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/listener/ItemListener.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/listener/ItemListener.java index d8a6e66c9f..a635ee97d9 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/listener/ItemListener.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/listener/ItemListener.java @@ -36,7 +36,7 @@ public void onPickup(@NotNull EntityPickupItemEvent event) { return; } - if (processEvent(player, event.getItem().getLocation(), event.getItem().getItemStack(), false)) { + if (this.processEvent(player, event.getItem().getLocation(), event.getItem().getItemStack(), false)) { event.setCancelled(true); event.getItem().remove(); } @@ -45,7 +45,7 @@ public void onPickup(@NotNull EntityPickupItemEvent event) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockDropItem(@NotNull BlockDropItemEvent event) { var location = event.getBlock().getLocation(); - event.getItems().removeIf(item -> processEvent(event.getPlayer(), location, item.getItemStack(), true)); + event.getItems().removeIf(item -> this.processEvent(event.getPlayer(), location, item.getItemStack(), true)); } /** @@ -58,7 +58,7 @@ public void onEntityDeath(@NotNull EntityDeathEvent event) { var killed = event.getEntity(); if (killed instanceof Mob && !(killed instanceof Boss) && killed.getKiller() != null) { var location = killed.getLocation(); - event.getDrops().removeIf(item -> processEvent(killed.getKiller(), location, item, true)); + event.getDrops().removeIf(item -> this.processEvent(killed.getKiller(), location, item, true)); } } @@ -70,7 +70,7 @@ public void onEntityDeath(@NotNull EntityDeathEvent event) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onHarvestBlock(@NotNull PlayerHarvestBlockEvent event) { var location = event.getHarvestedBlock().getLocation(); - event.getItemsHarvested().removeIf(item -> processEvent(event.getPlayer(), location, item, true)); + event.getItemsHarvested().removeIf(item -> this.processEvent(event.getPlayer(), location, item, true)); } /** @@ -81,12 +81,12 @@ public void onHarvestBlock(@NotNull PlayerHarvestBlockEvent event) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onShearBlock(@NotNull PlayerShearBlockEvent event) { var location = event.getBlock().getLocation(); - event.getDrops().removeIf(item -> processEvent(event.getPlayer(), location, item, true)); + event.getDrops().removeIf(item -> this.processEvent(event.getPlayer(), location, item, true)); } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onArrowPickup(@NotNull PlayerPickupArrowEvent event) { - if (processEvent(event.getPlayer(), event.getArrow().getLocation(), event.getArrow().getItemStack(), false)) { + if (this.processEvent(event.getPlayer(), event.getArrow().getLocation(), event.getArrow().getItemStack(), false)) { event.setCancelled(true); event.getArrow().remove(); } diff --git a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/setting/AutoStoreSetting.java b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/setting/AutoStoreSetting.java index 86c2bdf2f7..cb4411ee5e 100644 --- a/features/autostore/src/main/java/net/okocraft/box/feature/autostore/setting/AutoStoreSetting.java +++ b/features/autostore/src/main/java/net/okocraft/box/feature/autostore/setting/AutoStoreSetting.java @@ -120,7 +120,7 @@ public boolean shouldAutoStore(@NotNull BoxItem item) { @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (o == null || this.getClass() != o.getClass()) return false; AutoStoreSetting that = (AutoStoreSetting) o; return this.uuid.equals(that.uuid); } 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 10681f3c45..4bc076de0a 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 @@ -75,7 +75,7 @@ public void onSelect(@NotNull PlayerSession session) { @Override public @NotNull ClickResult onClick(@NotNull PlayerSession session, @NotNull BoxItem item, @NotNull ClickType clickType) { - return processDeposit(session, item); + return this.processDeposit(session, item); } @Override 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 3ebdafb2ab..2e92d63fce 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 @@ -65,7 +65,7 @@ public void onSelect(@NotNull PlayerSession session) { @Override public @NotNull ClickResult onClick(@NotNull PlayerSession session, @NotNull BoxItem item, @NotNull ClickType clickType) { - return processWithdraw(session, item); + return this.processWithdraw(session, item); } @Override diff --git a/features/command/src/main/java/net/okocraft/box/feature/command/box/DepositCommand.java b/features/command/src/main/java/net/okocraft/box/feature/command/box/DepositCommand.java index 5ea8ab5721..7274f3f08b 100644 --- a/features/command/src/main/java/net/okocraft/box/feature/command/box/DepositCommand.java +++ b/features/command/src/main/java/net/okocraft/box/feature/command/box/DepositCommand.java @@ -70,7 +70,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { } if (args.length == 1) { - depositItemInMainHand(player, Integer.MAX_VALUE, msgSrc); + this.depositItemInMainHand(player, Integer.MAX_VALUE, msgSrc); return; } @@ -80,22 +80,22 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { var arg = args[1]; if (arg.equalsIgnoreCase("all")) { - depositAll(player, msgSrc); + this.depositAll(player, msgSrc); return; } try { - depositItemInMainHand(player, Math.max(Integer.parseInt(arg), 1), msgSrc); + this.depositItemInMainHand(player, Math.max(Integer.parseInt(arg), 1), msgSrc); return; } catch (NumberFormatException ignored) { } itemManager.getBoxItem(arg).ifPresentOrElse( - boxItem -> depositItem(player, msgSrc, boxItem, Integer.MAX_VALUE), + boxItem -> this.depositItem(player, msgSrc, boxItem, Integer.MAX_VALUE), () -> { if (!arg.isEmpty() && arg.length() < 4 && (arg.charAt(0) == 'a' || arg.charAt(0) == 'A')) { - depositAll(player, msgSrc); + this.depositAll(player, msgSrc); } else { ErrorMessages.ITEM_NOT_FOUND.apply(arg).source(msgSrc).send(sender); } @@ -122,7 +122,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { return; } - depositItem(player, msgSrc, boxItem.get(), amount); + this.depositItem(player, msgSrc, boxItem.get(), amount); } } diff --git a/features/command/src/main/java/net/okocraft/box/feature/command/box/GiveCommand.java b/features/command/src/main/java/net/okocraft/box/feature/command/box/GiveCommand.java index 21985de7fb..388985861e 100644 --- a/features/command/src/main/java/net/okocraft/box/feature/command/box/GiveCommand.java +++ b/features/command/src/main/java/net/okocraft/box/feature/command/box/GiveCommand.java @@ -83,7 +83,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { return; } - if (!target.hasPermission(getPermissionNode())) { + if (!target.hasPermission(this.getPermissionNode())) { this.targetNoPermission.apply(target.getName(), this.getPermissionNode()).source(msgSrc).send(sender); return; } @@ -159,7 +159,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { } if (args.length == 2) { - return TabCompleter.players(args[1], getPermissionNode()); + return TabCompleter.players(args[1], this.getPermissionNode()); } if (args.length == 3) { diff --git a/features/command/src/main/java/net/okocraft/box/feature/command/boxadmin/stock/StockModifyCommands.java b/features/command/src/main/java/net/okocraft/box/feature/command/boxadmin/stock/StockModifyCommands.java index 0a399fa8c4..cf7d9be7d9 100644 --- a/features/command/src/main/java/net/okocraft/box/feature/command/boxadmin/stock/StockModifyCommands.java +++ b/features/command/src/main/java/net/okocraft/box/feature/command/boxadmin/stock/StockModifyCommands.java @@ -88,7 +88,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { } var stockHolder = BoxAPI.api().getStockManager().getPersonalStockHolder(target); - int current = modifyStock(sender, stockHolder, item.get(), amount); + int current = this.modifyStock(sender, stockHolder, item.get(), amount); this.successSender.apply(target.getName().orElseGet(target.getUUID()::toString), item.get(), amount, current).source(msgSrc).send(sender); 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 666d2a2246..15614e0e8f 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 @@ -62,8 +62,8 @@ public void disable(@NotNull FeatureContext.Disabling context) { @Override public void reload(@NotNull FeatureContext.Reloading context) throws IOException { - disable(context.asDisabling()); - enable(context.asEnabling()); + this.disable(context.asDisabling()); + this.enable(context.asEnabling()); this.reloaded.source(BoxAPI.api().getMessageProvider().findSource(context.commandSender())).send(context.commandSender()); } diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/gui/CurrentRecipe.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/gui/CurrentRecipe.java index 963a5785a7..c49521cf68 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/gui/CurrentRecipe.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/gui/CurrentRecipe.java @@ -54,7 +54,7 @@ public void nextRecipe(int pos, boolean sameIngredient) { } } - updateSelectedRecipe(); + this.updateSelectedRecipe(); } public @Nullable SelectableIngredients getIngredients(int pos) { diff --git a/features/craft/src/main/java/net/okocraft/box/feature/craft/loader/Processor.java b/features/craft/src/main/java/net/okocraft/box/feature/craft/loader/Processor.java index c6e97191f6..139a43d20b 100644 --- a/features/craft/src/main/java/net/okocraft/box/feature/craft/loader/Processor.java +++ b/features/craft/src/main/java/net/okocraft/box/feature/craft/loader/Processor.java @@ -53,12 +53,12 @@ void processRecipe(@NotNull Recipe recipe) { } if (recipe instanceof ShapedRecipe shapedRecipe) { - processShapedRecipe(shapedRecipe, result.get()); + this.processShapedRecipe(shapedRecipe, result.get()); return; } if (recipe instanceof ShapelessRecipe shapelessRecipe) { - processShapelessRecipe(shapelessRecipe, result.get()); + this.processShapelessRecipe(shapelessRecipe, result.get()); } } @@ -109,7 +109,7 @@ void processCustomRecipes() { } if (process) { - processCustomRecipe(ingredients, resultItem.get(), Math.max(1, customRecipe.amount())); + this.processCustomRecipe(ingredients, resultItem.get(), Math.max(1, customRecipe.amount())); } } } @@ -126,7 +126,7 @@ private void processShapedRecipe(@NotNull ShapedRecipe recipe, @NotNull BoxItem var ingredients = new ArrayList(); for (var entry : recipe.getChoiceMap().entrySet()) { - var slot = getPosition(entry.getKey(), recipe.getShape()); + var slot = this.getPosition(entry.getKey(), recipe.getShape()); var choice = entry.getValue(); if (choice instanceof RecipeChoice.MaterialChoice materialChoice) { @@ -144,7 +144,7 @@ private void processShapedRecipe(@NotNull ShapedRecipe recipe, @NotNull BoxItem } } - addRecipe(ingredients, result, recipe.getResult().getAmount()); + this.addRecipe(ingredients, result, recipe.getResult().getAmount()); } private void processShapelessRecipe(@NotNull ShapelessRecipe recipe, @NotNull BoxItem result) { @@ -173,7 +173,7 @@ private void processShapelessRecipe(@NotNull ShapelessRecipe recipe, @NotNull Bo slot++; } - addRecipe(ingredients, result, recipe.getResult().getAmount()); + this.addRecipe(ingredients, result, recipe.getResult().getAmount()); } private void processCustomRecipe(@Nullable BoxItem @NotNull [] ingredients, @NotNull BoxItem result, int amount) { @@ -186,7 +186,7 @@ private void processCustomRecipe(@Nullable BoxItem @NotNull [] ingredients, @Not } } - addRecipe(ingredientHolders, result, amount); + this.addRecipe(ingredientHolders, result, amount); } @Contract(pure = true) 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 index bad1b4d389..deaf5c1577 100644 --- 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 @@ -43,23 +43,23 @@ public void setCancelled(boolean cancel) { @Override public @NotNull String toDebugLog() { return "MenuClickEvent{" + - "viewerUuid=" + getViewer().getUniqueId() + - ", viewerName=" + getViewer().getName() + - ", menuClass=" + getMenu().getClass().getSimpleName() + - ", buttonClass=" + getClickedButton().getClass().getSimpleName() + - ", clickType=" + getClickType() + - ", cancelled=" + isCancelled() + + "viewerUuid=" + this.getViewer().getUniqueId() + + ", viewerName=" + this.getViewer().getName() + + ", menuClass=" + this.getMenu().getClass().getSimpleName() + + ", buttonClass=" + this.getClickedButton().getClass().getSimpleName() + + ", clickType=" + this.getClickType() + + ", cancelled=" + this.isCancelled() + '}'; } @Override public String toString() { return "MenuClickEvent{" + - "viewer=" + getViewer() + - ", menu=" + getMenu() + - ", clickedButton=" + getClickedButton() + - ", clickType=" + getClickType() + - ", cancelled=" + isCancelled() + + "viewer=" + this.getViewer() + + ", menu=" + this.getMenu() + + ", clickedButton=" + this.getClickedButton() + + ", clickType=" + this.getClickType() + + ", cancelled=" + this.isCancelled() + '}'; } } 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 index 50411ce3d2..f9fa08cf04 100644 --- 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 @@ -26,19 +26,19 @@ public void setCancelled(boolean cancel) { @Override public @NotNull String toDebugLog() { return "MenuOpenEvent{" + - "viewerUuid=" + getViewer().getUniqueId() + - ", viewerName=" + getViewer().getName() + - ", menuClass=" + getMenu().getClass().getSimpleName() + - ", cancelled=" + isCancelled() + + "viewerUuid=" + this.getViewer().getUniqueId() + + ", viewerName=" + this.getViewer().getName() + + ", menuClass=" + this.getMenu().getClass().getSimpleName() + + ", cancelled=" + this.isCancelled() + '}'; } @Override public String toString() { return "MenuOpenEvent{" + - "viewer=" + getViewer() + - ", menu=" + getMenu() + - ", cancelled=" + isCancelled() + + "viewer=" + this.getViewer() + + ", menu=" + this.getMenu() + + ", cancelled=" + this.isCancelled() + '}'; } } diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/paginate/AbstractPaginatedMenu.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/paginate/AbstractPaginatedMenu.java index 5a8bb12426..040f177a02 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/paginate/AbstractPaginatedMenu.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/menu/paginate/AbstractPaginatedMenu.java @@ -32,7 +32,7 @@ protected AbstractPaginatedMenu(int rows, @NotNull List list, @NotNull TypedK this.rows = rows; this.list = list; this.currentPageKey = currentPageKey; - this.iconsPerPage = (getRows() - 1) * 9; + this.iconsPerPage = (this.getRows() - 1) * 9; this.maxPage = (list.size() + this.iconsPerPage - 1) / this.iconsPerPage; } @@ -71,7 +71,7 @@ public void setCurrentPage(@NotNull PlayerSession session, int page) { int end = start + this.iconsPerPage; for (int i = start, limit = this.list.size(), slot = 0; i < limit && i < end; i++, slot++) { - buttons.add(createButton(this.list.get(i), slot)); + buttons.add(this.createButton(this.list.get(i), slot)); } if (currentPage < this.maxPage) { @@ -82,7 +82,7 @@ public void setCurrentPage(@NotNull PlayerSession session, int page) { buttons.add(new PageSwitchButton(this.rows, currentPage - 1, false, this.currentPageKey)); } - addAdditionalButtons(session, buttons); + this.addAdditionalButtons(session, buttons); return buttons; } diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/Amount.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/Amount.java index 7fb61028fc..1ef008717b 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/Amount.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/api/session/Amount.java @@ -61,7 +61,7 @@ public int getAmount() { public @NotNull Unit next() { var values = values(); - var index = ordinal() + 1; + var index = this.ordinal() + 1; if (index == values.length) { index = 0; 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 bcbde5b232..394db5e38e 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 @@ -62,7 +62,7 @@ private PlayerSession(@NotNull Player viewer, @NotNull BoxUser sourceUser, @NotN var data = this.getData(key); if (data == null) { - throw new IllegalStateException(key + " does not exist in this session (" + getViewer().getName() + ")"); + throw new IllegalStateException(key + " does not exist in this session (" + this.getViewer().getName() + ")"); } return data; 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 16f5013631..c4a9512d8a 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 @@ -63,12 +63,12 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { } if (args.length < 2) { - openMenu(PlayerSession.newSession(player), new CategorySelectorMenu()); + this.openMenu(PlayerSession.newSession(player), new CategorySelectorMenu()); return; } if (!args[1].startsWith("-")) { - legacyBehavior(player, args); + this.legacyBehavior(player, args); return; } @@ -127,7 +127,7 @@ public void onCommand(@NotNull CommandSender sender, @NotNull String[] args) { paginatedMenu.setCurrentPage(session, Math.min(page, paginatedMenu.getMaxPage())); } - openMenu(session, menu); + this.openMenu(session, menu); } @Override diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/holder/BoxInventoryHolder.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/holder/BoxInventoryHolder.java index 5f058bd362..819d0c5cec 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/holder/BoxInventoryHolder.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/holder/BoxInventoryHolder.java @@ -101,7 +101,7 @@ public void finishClickProcess() { public void processClick(int slot, @NotNull ClickType clickType) { try { - processClick0(slot, clickType); + this.processClick0(slot, clickType); } catch (Throwable e) { var viewer = this.session.getViewer(); ERROR.apply(e).source(this.session.getMessageSource()).send(viewer); @@ -132,9 +132,9 @@ private void processClick0(int slot, @NotNull ClickType clickType) { var result = button.onClick(this.session, clickType); if (result instanceof ClickResult.WaitingTask waitingTask) { - waitingTask.onCompleted(r -> processClickResult(button, r)); + waitingTask.onCompleted(r -> this.processClickResult(button, r)); } else { - processClickResult(button, result); + this.processClickResult(button, result); } } diff --git a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/listener/InventoryListener.java b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/listener/InventoryListener.java index 6f02cb6ebe..d8a14532d0 100644 --- a/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/listener/InventoryListener.java +++ b/features/gui/src/main/java/net/okocraft/box/feature/gui/internal/listener/InventoryListener.java @@ -101,7 +101,7 @@ private void openCategoryMenu(@NotNull BoxInventoryHolder holder, @NotNull BoxIt return; } - var category = findCategory(boxItem).orElse(null); + var category = this.findCategory(boxItem).orElse(null); if (category == null) { return; 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 fa70ca3359..73c12cfc49 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 @@ -77,9 +77,9 @@ public void onSelect(@NotNull PlayerSession session) { @Override public @NotNull ClickResult onClick(@NotNull PlayerSession session, @NotNull BoxItem item, @NotNull ClickType clickType) { if (clickType.isLeftClick()) { - return processDeposit(session, item); + return this.processDeposit(session, item); } else if (clickType.isRightClick()) { - return processWithdraw(session, item); + return this.processWithdraw(session, item); } return ClickResult.NO_UPDATE_NEEDED; diff --git a/features/stick/src/main/java/net/okocraft/box/feature/stick/listener/StickListener.java b/features/stick/src/main/java/net/okocraft/box/feature/stick/listener/StickListener.java index 534b898537..088757aa3a 100644 --- a/features/stick/src/main/java/net/okocraft/box/feature/stick/listener/StickListener.java +++ b/features/stick/src/main/java/net/okocraft/box/feature/stick/listener/StickListener.java @@ -55,7 +55,7 @@ public StickListener(@NotNull BoxStickItem boxStickItem) { public void onInteract(@NotNull PlayerInteractEvent event) { var player = event.getPlayer(); - if (event.getAction() == Action.PHYSICAL || !canUseBox(player)) { + if (event.getAction() == Action.PHYSICAL || !this.canUseBox(player)) { return; } @@ -88,7 +88,7 @@ private void clickBlock(@NotNull PlayerInteractEvent event) { } var player = event.getPlayer(); - var boxPlayer = getBoxPlayerOrNull(player); + var boxPlayer = this.getBoxPlayerOrNull(player); var block = event.getClickedBlock(); if (boxPlayer == null || !player.isSneaking() || block == null) { @@ -101,7 +101,7 @@ private void clickBlock(@NotNull PlayerInteractEvent event) { boolean isStickInOffhand = this.boxStickItem.check(offHand); if (isStickInOffhand && block.getState() instanceof Container container) { - clickContainer(event, boxPlayer, container, block.getLocation().clone()); + this.clickContainer(event, boxPlayer, container, block.getLocation().clone()); return; } @@ -220,7 +220,7 @@ public void onBlockPlace(@NotNull BlockPlaceEvent event) { } var player = event.getPlayer(); - var boxPlayer = checkPlayerAndGetBoxPlayer(player, "box.stick.block"); + var boxPlayer = this.checkPlayerAndGetBoxPlayer(player, "box.stick.block"); if (boxPlayer == null) { return; @@ -228,8 +228,8 @@ public void onBlockPlace(@NotNull BlockPlaceEvent event) { var mainHandItem = player.getInventory().getItemInMainHand(); - if (!isIllegalStack(mainHandItem) && event.getItemInHand().equals(mainHandItem) && - tryConsumingStock(boxPlayer, mainHandItem, new StickCauses.BlockPlace(boxPlayer, block.getLocation().clone()))) { + if (!this.isIllegalStack(mainHandItem) && event.getItemInHand().equals(mainHandItem) && + this.tryConsumingStock(boxPlayer, mainHandItem, new StickCauses.BlockPlace(boxPlayer, block.getLocation().clone()))) { player.getInventory().setItemInMainHand(mainHandItem.clone()); } } @@ -237,7 +237,7 @@ public void onBlockPlace(@NotNull BlockPlaceEvent event) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemConsume(@NotNull PlayerItemConsumeEvent event) { var player = event.getPlayer(); - var boxPlayer = checkPlayerAndGetBoxPlayer(player, "box.stick.food"); + var boxPlayer = this.checkPlayerAndGetBoxPlayer(player, "box.stick.food"); if (boxPlayer == null) { return; @@ -246,7 +246,7 @@ public void onItemConsume(@NotNull PlayerItemConsumeEvent event) { var mainHandItem = player.getInventory().getItemInMainHand(); var cause = new StickCauses.ItemConsume(boxPlayer); - if (isIllegalStack(mainHandItem) || !event.getItem().equals(mainHandItem) || !tryConsumingStock(boxPlayer, mainHandItem, cause)) { + if (this.isIllegalStack(mainHandItem) || !event.getItem().equals(mainHandItem) || !this.tryConsumingStock(boxPlayer, mainHandItem, cause)) { return; } @@ -273,10 +273,10 @@ public void onItemConsume(@NotNull PlayerItemConsumeEvent event) { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onItemBreak(@NotNull PlayerItemBreakEvent event) { var player = event.getPlayer(); - var boxPlayer = checkPlayerAndGetBoxPlayer(player, "box.stick.tool"); + var boxPlayer = this.checkPlayerAndGetBoxPlayer(player, "box.stick.tool"); var original = event.getBrokenItem(); - if (boxPlayer == null || isIllegalStack(original)) { + if (boxPlayer == null || this.isIllegalStack(original)) { return; } @@ -284,7 +284,7 @@ public void onItemBreak(@NotNull PlayerItemBreakEvent event) { copied.editMeta(Damageable.class, meta -> meta.setDamage(0)); - if (tryConsumingStock(boxPlayer, copied, new StickCauses.ItemBreak(boxPlayer))) { + if (this.tryConsumingStock(boxPlayer, copied, new StickCauses.ItemBreak(boxPlayer))) { original.setAmount(2); } } @@ -307,7 +307,7 @@ public void onProjectileLaunch(@NotNull ProjectileLaunchEvent event) { default -> null; }; - var boxPlayer = permissionNodeSuffix != null ? checkPlayerAndGetBoxPlayer(player, "box.stick." + permissionNodeSuffix) : null; + var boxPlayer = permissionNodeSuffix != null ? this.checkPlayerAndGetBoxPlayer(player, "box.stick." + permissionNodeSuffix) : null; if (boxPlayer == null) { return; @@ -315,7 +315,7 @@ public void onProjectileLaunch(@NotNull ProjectileLaunchEvent event) { var mainHandItem = player.getInventory().getItemInMainHand(); - if (!isIllegalStack(mainHandItem) && tryConsumingStock(boxPlayer, mainHandItem, new StickCauses.ProjectileLaunch(boxPlayer, entityType))) { + if (!this.isIllegalStack(mainHandItem) && this.tryConsumingStock(boxPlayer, mainHandItem, new StickCauses.ProjectileLaunch(boxPlayer, entityType))) { mainHandItem.setAmount(mainHandItem.getAmount() + 1); player.updateInventory(); } @@ -330,7 +330,7 @@ public void onShoot(@NotNull EntityShootBowEvent event) { return; } - var boxPlayer = checkPlayerAndGetBoxPlayer(player, "box.stick.arrow"); + var boxPlayer = this.checkPlayerAndGetBoxPlayer(player, "box.stick.arrow"); if (boxPlayer == null) { return; @@ -338,7 +338,7 @@ public void onShoot(@NotNull EntityShootBowEvent event) { var arrowItem = event.getConsumable(); - if (arrowItem != null && !isIllegalStack(arrowItem) && tryConsumingStock(boxPlayer, arrowItem, new StickCauses.ShootBow(boxPlayer))) { + if (arrowItem != null && !this.isIllegalStack(arrowItem) && this.tryConsumingStock(boxPlayer, arrowItem, new StickCauses.ShootBow(boxPlayer))) { player.getInventory().addItem(arrowItem.asOne()); } } @@ -354,9 +354,9 @@ private boolean tryConsumingStock(@NotNull BoxPlayer boxPlayer, @NotNull ItemSta } private @Nullable BoxPlayer checkPlayerAndGetBoxPlayer(@NotNull Player player, @NotNull String permissionNode) { - if (isSurvivalOrAdventure(player) && canUseBox(player) && - player.hasPermission(permissionNode) && hasBoxStickInOffHand(player)) { - return getBoxPlayerOrNull(player); + if (this.isSurvivalOrAdventure(player) && this.canUseBox(player) && + player.hasPermission(permissionNode) && this.hasBoxStickInOffHand(player)) { + return this.getBoxPlayerOrNull(player); } else { return null; } diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/mysql/MySQLDatabase.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/mysql/MySQLDatabase.java index 9afaa020d1..0126f78787 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/mysql/MySQLDatabase.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/mysql/MySQLDatabase.java @@ -49,7 +49,7 @@ public void prepare() throws Exception { config.setMaxLifetime(60000); config.setMaximumPoolSize(50); - configureDataSourceProperties(config.getDataSourceProperties()); + this.configureDataSourceProperties(config.getDataSourceProperties()); this.hikariDataSource = new HikariDataSource(config); } @@ -71,7 +71,7 @@ public void shutdown() { result.add(Storage.Property.of("database-name", this.mySQLSetting.databaseName())); result.add(Storage.Property.of("table-prefix", this.mySQLSetting.tablePrefix())); - var ping = ping(); + var ping = this.ping(); if (0 < ping) { result.add(Storage.Property.of("ping", ping + "ms")); } @@ -119,7 +119,7 @@ private long ping() { long start = System.currentTimeMillis(); - try (var connection = getConnection(); var statement = connection.createStatement()) { + try (var connection = this.getConnection(); var statement = connection.createStatement()) { statement.execute("SELECT 1"); } catch (Exception ignored) { return -1; diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/sqlite/SQLiteDatabase.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/sqlite/SQLiteDatabase.java index 121e9c9b25..95cc508444 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/sqlite/SQLiteDatabase.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/database/sqlite/SQLiteDatabase.java @@ -41,7 +41,7 @@ public class SQLiteDatabase implements Database { @Override public void prepare() throws Exception { if (!Files.exists(this.databasePath)) { - createDatabaseFile(); + this.createDatabaseFile(); } this.connection = new NonCloseableConnection(this.createConnection()); diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractCustomDataTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractCustomDataTable.java index d310dd51c1..b484b22c7d 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractCustomDataTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractCustomDataTable.java @@ -21,7 +21,7 @@ public AbstractCustomDataTable(@NotNull Database database, @NotNull TableSchema @Override public @NotNull MapNode loadData(@NotNull Key key) throws Exception { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `data` FROM `%table%` WHERE `key`=? LIMIT 1")) { + var statement = this.prepareStatement(connection, "SELECT `data` FROM `%table%` WHERE `key`=? LIMIT 1")) { statement.setString(1, key.asString()); try (var resultSet = statement.executeQuery()) { @@ -38,13 +38,13 @@ public AbstractCustomDataTable(@NotNull Database database, @NotNull TableSchema public void saveData(@NotNull Key key, @NotNull MapNode mapNode) throws Exception { if (mapNode.value().isEmpty()) { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "DELETE FROM `%table%` WHERE `key`=?")) { + var statement = this.prepareStatement(connection, "DELETE FROM `%table%` WHERE `key`=?")) { statement.setString(1, key.asString()); statement.execute(); } } else { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, this.insertOrUpdateDataStatement())) { + var statement = this.prepareStatement(connection, this.insertOrUpdateDataStatement())) { statement.setString(1, key.asString()); this.writeBytesToStatement(statement, 2, this.toBytes(mapNode)); statement.execute(); @@ -56,12 +56,12 @@ public void saveData(@NotNull Key key, @NotNull MapNode mapNode) throws Exceptio @Override public void visitData(@NotNull String namespace, @NotNull BiConsumer consumer) throws Exception { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `key`, `data` FROM `%table%` WHERE `key` LIKE ?")) { + var statement = this.prepareStatement(connection, "SELECT `key`, `data` FROM `%table%` WHERE `key` LIKE ?")) { statement.setString(1, namespace + ":%"); try (var resultSet = statement.executeQuery()) { while (resultSet.next()) { - consumer.accept(Key.key(resultSet.getString("key")), readDataFromResultSet(resultSet)); + consumer.accept(Key.key(resultSet.getString("key")), this.readDataFromResultSet(resultSet)); } } } @@ -71,10 +71,10 @@ public void visitData(@NotNull String namespace, @NotNull BiConsumer consumer) throws Exception { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `key`, `data` FROM `%table%`")) { + var statement = this.prepareStatement(connection, "SELECT `key`, `data` FROM `%table%`")) { try (var resultSet = statement.executeQuery()) { while (resultSet.next()) { - consumer.accept(Key.key(resultSet.getString("key")), readDataFromResultSet(resultSet)); + consumer.accept(Key.key(resultSet.getString("key")), this.readDataFromResultSet(resultSet)); } } } diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractTable.java index a34aa71285..0c69346a1c 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/AbstractTable.java @@ -37,7 +37,7 @@ protected void createTableAndIndex() throws SQLException { } protected @NotNull PreparedStatement prepareStatement(@NotNull Connection connection, @NotNull String sql) throws SQLException { - var tableNameReplaced = replaceTableName(sql); + var tableNameReplaced = this.replaceTableName(sql); return connection.prepareStatement(tableNameReplaced); } diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/CustomDataTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/CustomDataTable.java index 64dedba1f5..34b9847747 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/CustomDataTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/CustomDataTable.java @@ -25,7 +25,7 @@ public CustomDataTable(@NotNull Database database, @NotNull MetaTable metaTable) @Override public void init() throws Exception { - createTableAndIndex(); + this.createTableAndIndex(); if (!this.metaTable.isCurrentCustomDataFormat() && this.legacyTableExists()) { this.legacyCustomDataTable = new LegacyCustomDataTable(this.database, false); @@ -93,7 +93,7 @@ public void visitAllData(@NotNull BiConsumer consumer) throws Exce } protected @NotNull MapNode readDataFromResultSet(@NotNull ResultSet resultSet) throws Exception { - try (var in = new ByteArrayInputStream(readBytesFromResultSet(resultSet, "data"))) { + try (var in = new ByteArrayInputStream(this.readBytesFromResultSet(resultSet, "data"))) { return BinaryFormat.DEFAULT.load(in) instanceof MapNode mapNode ? mapNode : MapNode.create(); } } diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/ItemTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/ItemTable.java index d79c4a6eee..c04e208eae 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/ItemTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/ItemTable.java @@ -56,7 +56,7 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { var result = new ArrayList(1000); // The number of default items is currently around 1400, so this should only need to be expanded once. try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `id`, `name`, `item_data` FROM `%table%` WHERE `is_default_item`=TRUE")) { + var statement = this.prepareStatement(connection, "SELECT `id`, `name`, `item_data` FROM `%table%` WHERE `is_default_item`=TRUE")) { try (var rs = statement.executeQuery()) { while (rs.next()) { result.add(function.apply(this.toItemData(rs))); @@ -72,13 +72,13 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { var result = new ArrayList(newItems.size() + updatedItemMap.size()); try (var connection = this.database.getConnection()) { - try (var statement = prepareStatement(connection, "UPDATE `%table%` SET `name`=?, `item_data`=? WHERE `id`=?")) { + try (var statement = this.prepareStatement(connection, "UPDATE `%table%` SET `name`=?, `item_data`=? WHERE `id`=?")) { for (var entry : updatedItemMap.int2ObjectEntrySet()) { int internalId = entry.getIntKey(); var item = entry.getValue(); statement.setString(1, item.plainName()); - writeBytesToStatement(statement, 2, item.itemStack().serializeAsBytes()); + this.writeBytesToStatement(statement, 2, item.itemStack().serializeAsBytes()); statement.setInt(3, internalId); statement.addBatch(); @@ -90,7 +90,7 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { int maxId; - try (var statement = prepareStatement(connection, "SELECT MAX(`id`) FROM `%table%`"); + try (var statement = this.prepareStatement(connection, "SELECT MAX(`id`) FROM `%table%`"); var resultSet = statement.executeQuery()) { if (resultSet.next()) { maxId = resultSet.getInt(1); @@ -99,10 +99,10 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { } } - try (var statement = prepareStatement(connection, "INSERT INTO `%table%` (`name`, `item_data`, `is_default_item`) VALUES(?,?,?)")) { + try (var statement = this.prepareStatement(connection, "INSERT INTO `%table%` (`name`, `item_data`, `is_default_item`) VALUES(?,?,?)")) { for (var item : newItems) { statement.setString(1, item.plainName()); - writeBytesToStatement(statement, 2, item.itemStack().serializeAsBytes()); + this.writeBytesToStatement(statement, 2, item.itemStack().serializeAsBytes()); statement.setBoolean(3, true); statement.addBatch(); @@ -112,7 +112,7 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { var nameToItemMap = newItems.stream().collect(Collectors.toMap(DefaultItem::plainName, Function.identity())); - try (var statement = prepareStatement(connection, "SELECT `id`, `name` FROM `%table%` WHERE `id` > ?")) { + try (var statement = this.prepareStatement(connection, "SELECT `id`, `name` FROM `%table%` WHERE `id` > ?")) { statement.setInt(1, maxId); try(var resultSet = statement.executeQuery()) { while (resultSet.next()) { @@ -133,7 +133,7 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { var result = new ArrayList(); try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `id`, `name`, `item_data` FROM `%table%` WHERE `is_default_item`=FALSE")) { + var statement = this.prepareStatement(connection, "SELECT `id`, `name`, `item_data` FROM `%table%` WHERE `is_default_item`=FALSE")) { try (var rs = statement.executeQuery()) { while (rs.next()) { result.add(function.apply(this.toItemData(rs))); @@ -147,11 +147,11 @@ public void saveItemVersion(@NotNull ItemVersion itemVersion) throws Exception { @Override public void updateCustomItems(@NotNull Collection items) throws Exception { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "UPDATE `%table%` SET `name`=?, `item_data`=? WHERE `id`=?")) { + var statement = this.prepareStatement(connection, "UPDATE `%table%` SET `name`=?, `item_data`=? WHERE `id`=?")) { for (var item : items) { statement.setString(1, item.getPlainName()); - writeBytesToStatement(statement, 2, item.getOriginal().serializeAsBytes()); + this.writeBytesToStatement(statement, 2, item.getOriginal().serializeAsBytes()); statement.setInt(3, item.getInternalId()); statement.addBatch(); @@ -167,9 +167,9 @@ public void updateCustomItems(@NotNull Collection items) throws E var itemBytes = item.serializeAsBytes(); var name = itemName != null ? itemName : ItemNameGenerator.itemStack(item.getType(), itemBytes); - try (var statement = prepareStatement(connection, "INSERT INTO `%table%` (`name`, `item_data`, `is_default_item`) VALUES(?,?,?)")) { + try (var statement = this.prepareStatement(connection, "INSERT INTO `%table%` (`name`, `item_data`, `is_default_item`) VALUES(?,?,?)")) { statement.setString(1, name); - writeBytesToStatement(statement, 2, itemBytes); + this.writeBytesToStatement(statement, 2, itemBytes); statement.setBoolean(3, false); statement.executeUpdate(); @@ -188,7 +188,7 @@ public void updateCustomItems(@NotNull Collection items) throws E @Override public @NotNull BoxCustomItem renameCustomItem(@NotNull BoxCustomItem item, @NotNull String newName) throws Exception { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "UPDATE `%table%` SET `name`=? WHERE `id`=?")) { + var statement = this.prepareStatement(connection, "UPDATE `%table%` SET `name`=? WHERE `id`=?")) { statement.setString(1, newName); statement.setInt(2, item.getInternalId()); @@ -203,7 +203,7 @@ public void updateCustomItems(@NotNull Collection items) throws E private @NotNull ItemData toItemData(@NotNull ResultSet resultSet) throws SQLException { int id = resultSet.getInt("id"); var name = resultSet.getString("name"); - var itemData = readBytesFromResultSet(resultSet, "item_data"); + var itemData = this.readBytesFromResultSet(resultSet, "item_data"); return new ItemData(id, name, itemData); } diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/LegacyCustomDataTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/LegacyCustomDataTable.java index ea5a6b1c12..42ea1499c7 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/LegacyCustomDataTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/LegacyCustomDataTable.java @@ -36,7 +36,7 @@ public void init() throws Exception { } protected @NotNull MapNode readDataFromResultSet(@NotNull ResultSet resultSet) throws Exception { - try (var in = new ByteArrayInputStream(readBytesFromResultSet(resultSet, "data")); + try (var in = new ByteArrayInputStream(this.readBytesFromResultSet(resultSet, "data")); var reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { return YamlFormat.DEFAULT.load(reader); } diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/MetaTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/MetaTable.java index 48cc954648..a9e652a47c 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/MetaTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/MetaTable.java @@ -26,11 +26,11 @@ public MetaTable(@NotNull Database database) { } public void init() throws Exception { - createTableAndIndex(); + this.createTableAndIndex(); } public @Nullable MCDataVersion getItemDataVersion() throws SQLException { - var version = getVersion(ITEM_DATA_VERSION_KEY); + var version = this.getVersion(ITEM_DATA_VERSION_KEY); if (version != null) { this.hasItemDataVersion = true; @@ -41,11 +41,11 @@ public void init() throws Exception { } public void saveItemDataVersion(int dataVersion) throws SQLException { - saveVersion(ITEM_DATA_VERSION_KEY, dataVersion, this.hasItemDataVersion); + this.saveVersion(ITEM_DATA_VERSION_KEY, dataVersion, this.hasItemDataVersion); } public int getDefaultItemProviderVersion() throws SQLException { - var version = getVersion(DEFAULT_ITEM_VERSION_KEY); + var version = this.getVersion(DEFAULT_ITEM_VERSION_KEY); if (version != null) { this.hasDefaultItemVersion = true; @@ -55,12 +55,12 @@ public int getDefaultItemProviderVersion() throws SQLException { } public void saveDefaultItemVersion(int version) throws SQLException { - saveVersion(DEFAULT_ITEM_VERSION_KEY, version, this.hasDefaultItemVersion); + this.saveVersion(DEFAULT_ITEM_VERSION_KEY, version, this.hasDefaultItemVersion); } private @Nullable Integer getVersion(@NotNull String key) throws SQLException { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `value` FROM `%table%` WHERE `key`=? LIMIT 1")) { + var statement = this.prepareStatement(connection, "SELECT `value` FROM `%table%` WHERE `key`=? LIMIT 1")) { statement.setString(1, key); try (var resultSet = statement.executeQuery()) { @@ -79,7 +79,7 @@ private void saveVersion(@NotNull String key, int version, boolean exists) throw "INSERT INTO `%table%` (`key`, `value`) VALUES(?,?)"; try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, sql)) { + var statement = this.prepareStatement(connection, sql)) { if (exists) { statement.setInt(1, version); statement.setString(2, key); @@ -94,7 +94,7 @@ private void saveVersion(@NotNull String key, int version, boolean exists) throw public boolean isCurrentCustomDataFormat() throws SQLException { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT `value` FROM `%table%` WHERE `key`=? LIMIT 1")) { + var statement = this.prepareStatement(connection, "SELECT `value` FROM `%table%` WHERE `key`=? LIMIT 1")) { statement.setString(1, CUSTOM_DATA_FORMAT_KEY); try (var resultSet = statement.executeQuery()) { @@ -109,7 +109,7 @@ public boolean isCurrentCustomDataFormat() throws SQLException { public void saveCurrentCustomDataFormat() throws SQLException { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, this.upsertCurrentCustomDataFormatStatement())) { + var statement = this.prepareStatement(connection, this.upsertCurrentCustomDataFormatStatement())) { statement.setString(1, CUSTOM_DATA_FORMAT_KEY); statement.setString(2, CUSTOM_DATA_FORMAT_KEY); statement.execute(); diff --git a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/StockTable.java b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/StockTable.java index be8cd34735..df9e17f431 100644 --- a/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/StockTable.java +++ b/storage/database/src/main/java/net/okocraft/box/storage/implementation/database/table/StockTable.java @@ -76,7 +76,7 @@ public void savePartialStockData(@NotNull UUID uuid, @NotNull Collection(); try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, "SELECT * FROM `%table%`")) { + var statement = this.prepareStatement(connection, "SELECT * FROM `%table%`")) { try (var resultSet = statement.executeQuery()) { while (resultSet.next()) { var uuid = UUIDParser.parseOrWarn(resultSet.getString("uuid")); @@ -94,7 +94,7 @@ public void saveBoxUser(@NotNull UUID uuid, @Nullable String name) throws Except @Override public void saveBoxUsers(@NotNull Collection users) throws Exception { try (var connection = this.database.getConnection(); - var statement = prepareStatement(connection, insertOrUpdateUsernameStatement())) { + var statement = this.prepareStatement(connection, this.insertOrUpdateUsernameStatement())) { for (var user : users) { statement.setString(1, user.getUUID().toString()); statement.setString(2, user.getName().orElse("")); diff --git a/storage/migrator/src/main/java/net/okocraft/box/storage/migrator/implementation/AbstractDataMigrator.java b/storage/migrator/src/main/java/net/okocraft/box/storage/migrator/implementation/AbstractDataMigrator.java index ddc1872add..53659e2edf 100644 --- a/storage/migrator/src/main/java/net/okocraft/box/storage/migrator/implementation/AbstractDataMigrator.java +++ b/storage/migrator/src/main/java/net/okocraft/box/storage/migrator/implementation/AbstractDataMigrator.java @@ -8,7 +8,7 @@ abstract class AbstractDataMigrator implements DataMigrator { @Override public @NotNull R migrate(@NotNull Storage source, @NotNull Storage target, boolean debug) throws Exception { - BoxLogger.logger().info("Starting {}...", getClass().getSimpleName()); + BoxLogger.logger().info("Starting {}...", this.getClass().getSimpleName()); return this.migrateData(this.getDataStorage(source), this.getDataStorage(target), debug); } diff --git a/storage/yaml/src/main/java/net/okocraft/box/storage/implementation/yaml/YamlUserStorage.java b/storage/yaml/src/main/java/net/okocraft/box/storage/implementation/yaml/YamlUserStorage.java index cd565a1bbb..d7e5f99282 100644 --- a/storage/yaml/src/main/java/net/okocraft/box/storage/implementation/yaml/YamlUserStorage.java +++ b/storage/yaml/src/main/java/net/okocraft/box/storage/implementation/yaml/YamlUserStorage.java @@ -67,7 +67,7 @@ public void saveBoxUser(@NotNull UUID uuid, @Nullable String name) throws Except this.userMap.putUUIDAndUsername(uuid, name != null ? name : ""); synchronized (this) { - saveUserMap(); + this.saveUserMap(); } } @@ -89,7 +89,7 @@ public void saveBoxUsers(@NotNull Collection users) throws Exception { } synchronized (this) { - saveUserMap(); + this.saveUserMap(); } } @@ -251,7 +251,7 @@ private NameKey(@NotNull String name) { @Override public boolean equals(Object object) { if (this == object) return true; - if (object == null || getClass() != object.getClass()) return false; + if (object == null || this.getClass() != object.getClass()) return false; NameKey other = (NameKey) object; return this.lowercase.equals(other.lowercase); } diff --git a/test-shared-classes/src/main/java/net/okocraft/box/test/shared/storage/memory/user/MemoryUserStorage.java b/test-shared-classes/src/main/java/net/okocraft/box/test/shared/storage/memory/user/MemoryUserStorage.java index 87a671124e..2fbe56468d 100644 --- a/test-shared-classes/src/main/java/net/okocraft/box/test/shared/storage/memory/user/MemoryUserStorage.java +++ b/test-shared-classes/src/main/java/net/okocraft/box/test/shared/storage/memory/user/MemoryUserStorage.java @@ -70,7 +70,7 @@ public void saveBoxUsers(@NotNull Collection users) { this.throwExceptionIfEnabled(); for (var user : users) { - saveBoxUser(user.getUUID(), user.getName().orElse(null)); + this.saveBoxUser(user.getUUID(), user.getName().orElse(null)); } }