diff --git a/build.gradle.kts b/build.gradle.kts index 5aeda679..183052f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ dependencies { // metrics and sentry implementation("org.bstats:bstats-bukkit:3.0.2") - implementation("io.sentry:sentry:6.31.0") + implementation("io.sentry:sentry:6.32.0") // database implementation("com.zaxxer:HikariCP:5.0.1") diff --git a/src/main/java/com/eternalcode/parcellockers/ParcelLockers.java b/src/main/java/com/eternalcode/parcellockers/ParcelLockers.java index 0e7c2722..e8fd99b8 100644 --- a/src/main/java/com/eternalcode/parcellockers/ParcelLockers.java +++ b/src/main/java/com/eternalcode/parcellockers/ParcelLockers.java @@ -61,8 +61,8 @@ public void onEnable() { this.audiences = BukkitAudiences.create(this); MiniMessage miniMessage = MiniMessage.builder() - .postProcessor(new LegacyColorProcessor()) - .build(); + .postProcessor(new LegacyColorProcessor()) + .build(); NotificationAnnouncer announcer = new NotificationAnnouncer(this.audiences, miniMessage); ConfigurationManager configManager = new ConfigurationManager(this.getDataFolder()); @@ -84,28 +84,28 @@ public void onEnable() { HikariDataSource dataSource = DataSourceFactory.buildHikariDataSource(config, this.getDataFolder()); - LockerRepositoryImpl parcelLockerRepositoryImpl = new LockerRepositoryImpl(dataSource); - parcelLockerRepositoryImpl.updatePositionCache(); - + LockerRepositoryImpl lockerRepositoryImpl = new LockerRepositoryImpl(dataSource); + lockerRepositoryImpl.updatePositionCache(); + ParcelRepositoryImpl parcelRepository = new ParcelRepositoryImpl(dataSource); ParcelManager parcelManager = new ParcelManager(config, announcer, parcelRepository); - LockerManager lockerManager = new LockerManager(parcelLockerRepositoryImpl); + LockerManager lockerManager = new LockerManager(lockerRepositoryImpl); + + MainGUI mainGUI = new MainGUI(this, server, miniMessage, config, parcelRepository, lockerRepositoryImpl); + ParcelListGUI parcelListGUI = new ParcelListGUI(this, server, miniMessage, config, parcelRepository, lockerRepositoryImpl, mainGUI); - MainGUI mainGUI = new MainGUI(this, server, miniMessage, config, parcelRepository, parcelLockerRepositoryImpl); - ParcelListGUI parcelListGUI = new ParcelListGUI(this, server, miniMessage, config, parcelRepository, parcelLockerRepositoryImpl, mainGUI); - this.liteCommands = LiteBukkitAdventurePlatformFactory.builder(server, "parcellockers", false, this.audiences, true) - .argument(Parcel.class, new ParcelArgument(parcelRepository)) - .argument(Player.class, new PlayerArgument(server, config)) - .contextualBind(Player.class, new BukkitOnlyPlayerContextual<>(config.messages.onlyForPlayers)) - .commandInstance( - new ParcelCommand(server, parcelLockerRepositoryImpl, announcer, config, mainGUI, parcelListGUI, parcelManager), - new ParcelLockersCommand(configManager, config, announcer, miniMessage) - ) - .invalidUsageHandler(new InvalidUsage(announcer, config)) - .permissionHandler(new PermissionMessage(announcer, config)) - .register(); + .argument(Parcel.class, new ParcelArgument(parcelRepository)) + .argument(Player.class, new PlayerArgument(server, config)) + .contextualBind(Player.class, new BukkitOnlyPlayerContextual<>(config.messages.onlyForPlayers)) + .commandInstance( + new ParcelCommand(server, lockerRepositoryImpl, announcer, config, mainGUI, parcelListGUI, parcelManager), + new ParcelLockersCommand(configManager, config, announcer, miniMessage) + ) + .invalidUsageHandler(new InvalidUsage(announcer, config)) + .permissionHandler(new PermissionMessage(announcer, config)) + .register(); if (!this.setupEconomy()) { this.getLogger().severe("Disabling due to no Vault dependency found!"); @@ -114,9 +114,9 @@ public void onEnable() { } Stream.of( - new LockerInteractionController(parcelLockerRepositoryImpl, miniMessage, config), - new LockerPlaceController(config, miniMessage, this, parcelLockerRepositoryImpl, announcer), - new LockerBreakController(parcelLockerRepositoryImpl, announcer, config.messages) + new LockerInteractionController(lockerRepositoryImpl, miniMessage, config), + new LockerPlaceController(config, miniMessage, this, lockerRepositoryImpl, announcer), + new LockerBreakController(lockerRepositoryImpl, announcer, config.messages) ).forEach(controller -> server.getPluginManager().registerEvents(controller, this)); new Metrics(this, 17677); @@ -161,12 +161,12 @@ private boolean setupEconomy() { if (this.getServer().getPluginManager().getPlugin("Vault") == null) { return false; } - + RegisteredServiceProvider rsp = this.getServer().getServicesManager().getRegistration(Economy.class); if (rsp == null) { return false; } - + this.economy = rsp.getProvider(); return true; } diff --git a/src/main/java/com/eternalcode/parcellockers/ParcelLockersCommand.java b/src/main/java/com/eternalcode/parcellockers/ParcelLockersCommand.java index c3ce6620..8e492966 100644 --- a/src/main/java/com/eternalcode/parcellockers/ParcelLockersCommand.java +++ b/src/main/java/com/eternalcode/parcellockers/ParcelLockersCommand.java @@ -27,7 +27,7 @@ public ParcelLockersCommand(ConfigurationManager configManager, PluginConfigurat this.announcer = announcer; this.miniMessage = miniMessage; } - + @Async @Execute(route = "reload", aliases = {"rl"}) void reload(CommandSender sender) { diff --git a/src/main/java/com/eternalcode/parcellockers/command/argument/PlayerArgument.java b/src/main/java/com/eternalcode/parcellockers/command/argument/PlayerArgument.java index 822792aa..1087a036 100644 --- a/src/main/java/com/eternalcode/parcellockers/command/argument/PlayerArgument.java +++ b/src/main/java/com/eternalcode/parcellockers/command/argument/PlayerArgument.java @@ -36,8 +36,8 @@ public PlayerArgument(Server server, PluginConfiguration config) { @Override public List suggest(LiteInvocation invocation) { return this.server.getOnlinePlayers().stream() - .map(HumanEntity::getName) - .map(Suggestion::of) - .toList(); + .map(HumanEntity::getName) + .map(Suggestion::of) + .toList(); } } diff --git a/src/main/java/com/eternalcode/parcellockers/command/handler/InvalidUsage.java b/src/main/java/com/eternalcode/parcellockers/command/handler/InvalidUsage.java index de293ede..7ffbc404 100644 --- a/src/main/java/com/eternalcode/parcellockers/command/handler/InvalidUsage.java +++ b/src/main/java/com/eternalcode/parcellockers/command/handler/InvalidUsage.java @@ -31,7 +31,7 @@ public void handle(CommandSender sender, LiteInvocation invocation, Schematic sc for (String scheme : schematics) { Formatter formatter = new Formatter() - .register("{USAGE}", scheme); + .register("{USAGE}", scheme); this.announcer.sendMessage(sender, formatter.format(this.config.messages.invalidUsage)); } diff --git a/src/main/java/com/eternalcode/parcellockers/command/handler/PermissionMessage.java b/src/main/java/com/eternalcode/parcellockers/command/handler/PermissionMessage.java index 33614928..5bfd5df8 100644 --- a/src/main/java/com/eternalcode/parcellockers/command/handler/PermissionMessage.java +++ b/src/main/java/com/eternalcode/parcellockers/command/handler/PermissionMessage.java @@ -22,11 +22,11 @@ public PermissionMessage(NotificationAnnouncer announcer, PluginConfiguration co @Override public void handle(CommandSender commandSender, LiteInvocation invocation, RequiredPermissions requiredPermissions) { String value = Joiner.on(", ") - .join(requiredPermissions.getPermissions()) - .toString(); + .join(requiredPermissions.getPermissions()) + .toString(); Formatter formatter = new Formatter() - .register("{PERMISSION}", value); + .register("{PERMISSION}", value); this.announcer.sendMessage(commandSender, formatter.format(this.config.messages.noPermission)); } diff --git a/src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java b/src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java index 3d4782ac..05c604bc 100644 --- a/src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java +++ b/src/main/java/com/eternalcode/parcellockers/configuration/ConfigurationManager.java @@ -11,10 +11,10 @@ public class ConfigurationManager { private static final Cdn CDN = CdnFactory - .createYamlLike() - .getSettings() - .withComposer(PositionComposer.class, new PositionComposer()) - .build(); + .createYamlLike() + .getSettings() + .withComposer(PositionComposer.class, new PositionComposer()) + .build(); private final Set configs = new HashSet<>(); private final File dataFolder; @@ -25,10 +25,10 @@ public ConfigurationManager(File dataFolder) { public T load(T config) { CDN.load(config.resource(this.dataFolder), config) - .orThrow(RuntimeException::new); + .orThrow(RuntimeException::new); CDN.render(config, config.resource(this.dataFolder)) - .orThrow(RuntimeException::new); + .orThrow(RuntimeException::new); this.configs.add(config); diff --git a/src/main/java/com/eternalcode/parcellockers/configuration/implementation/ConfigItem.java b/src/main/java/com/eternalcode/parcellockers/configuration/implementation/ConfigItem.java index d760264c..14dcac0c 100644 --- a/src/main/java/com/eternalcode/parcellockers/configuration/implementation/ConfigItem.java +++ b/src/main/java/com/eternalcode/parcellockers/configuration/implementation/ConfigItem.java @@ -33,7 +33,8 @@ public GuiItem toGuiItem(MiniMessage miniMessage, GuiAction } public GuiItem toGuiItem(MiniMessage miniMessage) { - return this.toGuiItem(miniMessage, event -> {}); + return this.toGuiItem(miniMessage, event -> { + }); } public ConfigItem setType(Material type) { diff --git a/src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java b/src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java index 89a304c6..df7b4465 100644 --- a/src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java +++ b/src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfiguration.java @@ -27,11 +27,11 @@ public class PluginConfiguration implements ReloadableConfig { public static class Settings { @Description({" ", - "# Should we enable Sentry integration?", - "# Sentry is a service that collects errors and other information about the plugin.", - "# It is used to improve the plugin and fix bugs.", - "# It is also strongly recommended to enable this option.", - "# You can learn more about Sentry here: https://sentry.io/"}) + "# Should we enable Sentry integration?", + "# Sentry is a service that collects errors and other information about the plugin.", + "# It is used to improve the plugin and fix bugs.", + "# It is also strongly recommended to enable this option.", + "# You can learn more about Sentry here: https://sentry.io/"}) public boolean enableSentry = true; @Description({" ", "# Whether the player after entering the server should receive information about the new version of the plugin?"}) @@ -60,9 +60,9 @@ public static class Settings { @Description({" ", "# The parcel locker item."}) public ConfigItem parcelLockerItem = new ConfigItem() - .setName("&3Parcel locker") - .setType(Material.CHEST) - .setLore(List.of("&bPlace to create a parcel locker.")); + .setName("&3Parcel locker") + .setType(Material.CHEST) + .setLore(List.of("&bPlace to create a parcel locker.")); @Description({" ", "# Small parcel cost."}) public double smallParcelCost = 5.0; @@ -76,6 +76,7 @@ public static class Settings { @Contextual public static class Messages { + public String onlyForPlayers = "&7» &cThis command is only available to players!"; public String noPermission = "&7» &cYou don't have permission to perform this command! &c(&7{PERMISSION}&c)"; public String cantFindPlayer = "&7» &cThe specified player could not be found!"; @@ -126,101 +127,101 @@ public static class GuiSettings { @Description({" ", "# The item of the small parcel size button"}) public ConfigItem smallParcelSizeItem = new ConfigItem() - .setName("&aSmall") - .setLore(List.of("&bClick to select the small parcel size.")) - .setType(Material.LIME_STAINED_GLASS); + .setName("&aSmall") + .setLore(List.of("&bClick to select the small parcel size.")) + .setType(Material.LIME_STAINED_GLASS); @Description({" ", "# The item of the medium parcel size button"}) public ConfigItem mediumParcelSizeItem = new ConfigItem() - .setName("&eMedium") - .setLore(List.of("&bClick to select the medium parcel size.")) - .setType(Material.YELLOW_STAINED_GLASS); + .setName("&eMedium") + .setLore(List.of("&bClick to select the medium parcel size.")) + .setType(Material.YELLOW_STAINED_GLASS); @Description({" ", "# The item of the large parcel size button"}) public ConfigItem largeParcelSizeItem = new ConfigItem() - .setName("&cLarge") - .setLore(List.of("&bClick to select the large parcel size.")) - .setType(Material.RED_STAINED_GLASS); + .setName("&cLarge") + .setLore(List.of("&bClick to select the large parcel size.")) + .setType(Material.RED_STAINED_GLASS); @Description({" ", "# The item of the priority button"}) public ConfigItem priorityItem = new ConfigItem() - .setName("&aPriority") - .setLore(List.of("&bClick to select the priority.")) - .setType(Material.REDSTONE); + .setName("&aPriority") + .setLore(List.of("&bClick to select the priority.")) + .setType(Material.REDSTONE); @Description({" ", "# The close button item"}) public ConfigItem closeItem = new ConfigItem() - .setName("&cClose") - .setLore(List.of("&cClick to close the GUI.")) - .setType(Material.BARRIER); + .setName("&cClose") + .setLore(List.of("&cClick to close the GUI.")) + .setType(Material.BARRIER); @Description({" ", "# The item of the main GUI"}) public ConfigItem mainGuiBackgroundItem = new ConfigItem() - .setName("") - .setLore(Collections.emptyList()) - .setType(Material.GRAY_STAINED_GLASS_PANE); + .setName("") + .setLore(Collections.emptyList()) + .setType(Material.GRAY_STAINED_GLASS_PANE); @Description({" ", "# The item of the corner GUI item.", "# Purely for decoration purposes."}) public ConfigItem cornerItem = new ConfigItem() - .setName("") - .setLore(Collections.emptyList()) - .setType(Material.BLUE_STAINED_GLASS_PANE); + .setName("") + .setLore(Collections.emptyList()) + .setType(Material.BLUE_STAINED_GLASS_PANE); @Description({" ", "# The item of the parcel list button"}) public ConfigItem myParcelsItem = new ConfigItem() - .setName("&3My parcels") - .setLore(List.of("&bClick to open your parcels.")) - .setType(Material.ENDER_CHEST); + .setName("&3My parcels") + .setLore(List.of("&bClick to open your parcels.")) + .setType(Material.ENDER_CHEST); @Description({" ", "# The item of the sent parcels button"}) public ConfigItem sentParcelsItem = new ConfigItem() - .setName("&6Sent parcels") - .setLore(List.of("&eClick to show parcels, which you sent.", "&eYou can also cancel them here, if you want to.")) - .setType(Material.FILLED_MAP) - .setGlow(true); + .setName("&6Sent parcels") + .setLore(List.of("&eClick to show parcels, which you sent.", "&eYou can also cancel them here, if you want to.")) + .setType(Material.FILLED_MAP) + .setGlow(true); @Description({" ", "# The parcel archive item button."}) public ConfigItem parcelArchiveItem = new ConfigItem() - .setName("&5Parcel archive") - .setLore(List.of("&eClick to show all parcels, which you sent or received in the past.")) - .setType(Material.WRITTEN_BOOK); + .setName("&5Parcel archive") + .setLore(List.of("&eClick to show all parcels, which you sent or received in the past.")) + .setType(Material.WRITTEN_BOOK); @Description({" ", "# The item of the parcel locker collect button"}) public ConfigItem parcelLockerCollectItem = new ConfigItem() - .setName("&aCollect parcels") - .setLore(List.of("&aClick to collect your parcels.")) - .setType(Material.HOPPER) - .setGlow(true); + .setName("&aCollect parcels") + .setLore(List.of("&aClick to collect your parcels.")) + .setType(Material.HOPPER) + .setGlow(true); @Description({" ", "# The item of the parcel locker send button"}) public ConfigItem parcelLockerSendItem = new ConfigItem() - .setName("&bSend parcels") - .setLore(List.of("&bClick to send parcels.")) - .setType(Material.SCULK_SHRIEKER) - .setGlow(true); + .setName("&bSend parcels") + .setLore(List.of("&bClick to send parcels.")) + .setType(Material.SCULK_SHRIEKER) + .setGlow(true); @Description({" ", "# The item of the parcel locker status button"}) public ConfigItem parcelLockerStatusItem = new ConfigItem() - .setName("&3Parcel locker status") - .setLore(List.of("&bClick to show the status of your parcel locker.")) - .setType(Material.END_PORTAL_FRAME) - .setGlow(true); + .setName("&3Parcel locker status") + .setLore(List.of("&bClick to show the status of your parcel locker.")) + .setType(Material.END_PORTAL_FRAME) + .setGlow(true); @Description({" ", "# The item of the parcel"}) public ConfigItem parcelItem = new ConfigItem() - .setName("&6{NAME}") - .setLore(List.of( - "&6UUID: &e{UUID}", - "&Sender: &e{SENDER}", - "&6Receiver: &e{RECEIVER}", - "&6Size: &e{SIZE}", - "&6Position: &6X: &e{POSITION_X}, &6Y: &e{POSITION_Y}, &6Z: &e{POSITION_Z}", - "&6Priority: &e{PRIORITY}", - "&6Description: &e{DESCRIPTION}", - "&6Recipients: &e{RECIPIENTS}" - ) + .setName("&6{NAME}") + .setLore(List.of( + "&6UUID: &e{UUID}", + "&Sender: &e{SENDER}", + "&6Receiver: &e{RECEIVER}", + "&6Size: &e{SIZE}", + "&6Position: &6X: &e{POSITION_X}, &6Y: &e{POSITION_Y}, &6Z: &e{POSITION_Z}", + "&6Priority: &e{PRIORITY}", + "&6Description: &e{DESCRIPTION}", + "&6Recipients: &e{RECIPIENTS}" ) - .setType(Material.CHEST_MINECART); + ) + .setType(Material.CHEST_MINECART); @Description({" ", "# The item of the parcel item storage button"}) public ConfigItem parcelStorageItem = new ConfigItem() @@ -230,27 +231,27 @@ public static class GuiSettings { @Description({" ", "# The item of the previous page button"}) public ConfigItem previousPageItem = new ConfigItem() - .setName("&bPrevious page") - .setLore(List.of("&bClick to go to the previous page.")) - .setType(Material.ARROW); + .setName("&bPrevious page") + .setLore(List.of("&bClick to go to the previous page.")) + .setType(Material.ARROW); @Description({" ", "# The item of the next page button"}) public ConfigItem nextPageItem = new ConfigItem() - .setName("&bNext page") - .setLore(List.of("&bClick to go to the next page.")) - .setType(Material.ARROW); + .setName("&bNext page") + .setLore(List.of("&bClick to go to the next page.")) + .setType(Material.ARROW); @Description({" ", "# The item of the confirm items button"}) public ConfigItem confirmItemsItem = new ConfigItem() - .setName("&aConfirm items") - .setLore(List.of("&aClick to confirm the items.")) - .setType(Material.LIME_WOOL); + .setName("&aConfirm items") + .setLore(List.of("&aClick to confirm the items.")) + .setType(Material.LIME_WOOL); @Description({" ", "# The item of the cancel items button"}) public ConfigItem cancelItemsItem = new ConfigItem() - .setName("&cCancel items") - .setLore(List.of("&cClick to cancel the items.")) - .setType(Material.RED_WOOL); + .setName("&cCancel items") + .setLore(List.of("&cClick to cancel the items.")) + .setType(Material.RED_WOOL); @Description({" ", "# The name of the parcel small content GUI"}) public String parcelSmallContentGuiTitle = "&aSmall parcel content"; diff --git a/src/main/java/com/eternalcode/parcellockers/deliverycode/DeliveryCode.java b/src/main/java/com/eternalcode/parcellockers/deliverycode/DeliveryCode.java new file mode 100644 index 00000000..1a48abb9 --- /dev/null +++ b/src/main/java/com/eternalcode/parcellockers/deliverycode/DeliveryCode.java @@ -0,0 +1,7 @@ +package com.eternalcode.parcellockers.deliverycode; + +import java.util.UUID; + +public record DeliveryCode(UUID parcelUUID, String code) { + +} diff --git a/src/main/java/com/eternalcode/parcellockers/deliverycode/repository/DeliveryCodeRepository.java b/src/main/java/com/eternalcode/parcellockers/deliverycode/repository/DeliveryCodeRepository.java new file mode 100644 index 00000000..100351db --- /dev/null +++ b/src/main/java/com/eternalcode/parcellockers/deliverycode/repository/DeliveryCodeRepository.java @@ -0,0 +1,19 @@ +package com.eternalcode.parcellockers.deliverycode.repository; + +import com.eternalcode.parcellockers.deliverycode.DeliveryCode; + +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public interface DeliveryCodeRepository { + + CompletableFuture save(DeliveryCode deliveryCode); + + CompletableFuture> findByUUID(UUID parcelUUID); + + CompletableFuture remove(DeliveryCode deliveryCode); + + CompletableFuture remove(UUID parcelUUID); + +} diff --git a/src/main/java/com/eternalcode/parcellockers/deliverycode/repository/DeliveryCodeRepositoryImpl.java b/src/main/java/com/eternalcode/parcellockers/deliverycode/repository/DeliveryCodeRepositoryImpl.java new file mode 100644 index 00000000..130a5fdb --- /dev/null +++ b/src/main/java/com/eternalcode/parcellockers/deliverycode/repository/DeliveryCodeRepositoryImpl.java @@ -0,0 +1,80 @@ +package com.eternalcode.parcellockers.deliverycode.repository; + +import com.eternalcode.parcellockers.database.AbstractDatabaseService; +import com.eternalcode.parcellockers.deliverycode.DeliveryCode; + +import javax.sql.DataSource; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +public class DeliveryCodeRepositoryImpl extends AbstractDatabaseService implements DeliveryCodeRepository { + + private final Map cache = new HashMap<>(); + + protected DeliveryCodeRepositoryImpl(DataSource dataSource) { + super(dataSource); + + this.initTable(); + } + + private void initTable() { + this.executeSync("CREATE TABLE IF NOT EXISTS `delivery_codes`(" + + "`parcelUUID` VARCHAR(36) NOT NULL, " + + "`code` VARCHAR(6) NOT NULL, " + + "PRIMARY KEY (parcelUUID) " + + ");", PreparedStatement::execute); + } + + @Override + public CompletableFuture save(DeliveryCode deliveryCode) { + return this.execute("INSERT INTO `delivery_codes` (`parcelUUID`, `code`) VALUES (?, ?);", preparedStatement -> { + preparedStatement.setString(1, deliveryCode.parcelUUID().toString()); + preparedStatement.setString(2, deliveryCode.code()); + preparedStatement.execute(); + this.cache.put(deliveryCode.parcelUUID(), deliveryCode); + }); + } + + @Override + public CompletableFuture> findByUUID(UUID parcelUUID) { + return this.supplyExecute("SELECT * FROM `delivery_codes` WHERE `parcelUUID` = ?;", statement -> { + statement.setString(1, parcelUUID.toString()); + ResultSet rs = statement.executeQuery(); + + if (!rs.next()) { + return Optional.empty(); + } + + DeliveryCode deliveryCode = new DeliveryCode(UUID.fromString(rs.getString("parcelUUID")), rs.getString("code")); + + this.cache.putIfAbsent(parcelUUID, deliveryCode); + + return Optional.of(deliveryCode); + }); + } + + @Override + public CompletableFuture remove(DeliveryCode deliveryCode) { + return this.remove(deliveryCode.parcelUUID()); + } + + @Override + public CompletableFuture remove(UUID parcelUUID) { + return this.supplyExecute("DELETE FROM `delivery_codes` WHERE `parcelUUID` = ?;", statement -> { + statement.setString(1, parcelUUID.toString()); + statement.execute(); + this.cache.remove(parcelUUID); + return null; + }); + } + + public Optional find(UUID parcelUUID) { + return Optional.ofNullable(this.cache.get(parcelUUID)) + .or(() -> this.findByUUID(parcelUUID).join()); + } +} diff --git a/src/main/java/com/eternalcode/parcellockers/event/EventCaller.java b/src/main/java/com/eternalcode/parcellockers/event/EventCaller.java new file mode 100644 index 00000000..69eaee15 --- /dev/null +++ b/src/main/java/com/eternalcode/parcellockers/event/EventCaller.java @@ -0,0 +1,20 @@ +package com.eternalcode.parcellockers.event; + +import org.bukkit.Server; +import org.bukkit.event.Event; + +public class EventCaller { + + private final Server server; + + public EventCaller(Server server) { + this.server = server; + } + + public T callEvent(T event) { + this.server.getPluginManager().callEvent(event); + + return event; + } + +} diff --git a/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerBreakController.java b/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerBreakController.java index 0751c3a2..b607da2c 100644 --- a/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerBreakController.java +++ b/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerBreakController.java @@ -49,16 +49,16 @@ public void onBlockBreak(BlockBreakEvent event) { UUID toRemove = this.parcelLockerRepositoryImpl.positionCache().get(position); this.parcelLockerRepositoryImpl.remove(toRemove); - + this.announcer.sendMessage(player, this.messages.parcelLockerSuccessfullyDeleted); - + Formatter formatter = new Formatter() .register("{X}", position.x()) .register("{Y}", position.y()) .register("{Z}", position.z()) .register("{WORLD}", position.world()) .register("{PLAYER}", player.getName()); - + this.announcer.broadcast(formatter.format(this.messages.broadcastParcelLockerRemoved)); } @@ -69,7 +69,7 @@ public void onBlockBurn(BlockBurnEvent event) { Block block = event.getBlock(); Location location = block.getLocation(); Position position = PositionAdapter.convert(location); - + if (this.parcelLockerRepositoryImpl.isInCache(position)) { event.setCancelled(true); } @@ -80,7 +80,7 @@ public void onBlockExplode(BlockExplodeEvent event) { Block block = event.getBlock(); Location location = block.getLocation(); Position position = PositionAdapter.convert(location); - + if (this.parcelLockerRepositoryImpl.isInCache(position)) { event.setCancelled(true); } @@ -100,7 +100,7 @@ public void onBlockIgnite(BlockIgniteEvent event) { Block block = event.getBlock(); Location location = block.getLocation(); Position position = PositionAdapter.convert(location); - + if (this.parcelLockerRepositoryImpl.isInCache(position)) { event.setCancelled(true); } @@ -111,7 +111,7 @@ public void onBlockDamage(BlockDamageEvent event) { Block block = event.getBlock(); Location location = block.getLocation(); Position position = PositionAdapter.convert(location); - + if (this.parcelLockerRepositoryImpl.isInCache(position)) { event.setCancelled(true); } diff --git a/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerInteractionController.java b/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerInteractionController.java index f6e61461..e598b222 100644 --- a/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerInteractionController.java +++ b/src/main/java/com/eternalcode/parcellockers/locker/controller/LockerInteractionController.java @@ -31,15 +31,15 @@ public LockerInteractionController(LockerRepositoryImpl parcelLockerRepositoryIm public void onInventoryOpen(PlayerInteractEvent event) { Player player = event.getPlayer(); Position blockPos = PositionAdapter.convert(player.getTargetBlock(Set.of(Material.AIR), 4).getLocation()); - + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { return; - } - - if (event.getClickedBlock().getType() != Material.CHEST) { - return; - } - + } + + if (event.getClickedBlock().getType() != Material.CHEST) { + return; + } + if (this.parcelLockerRepositoryImpl.isInCache(blockPos)) { event.setCancelled(true); new LockerMainGUI(this.miniMessage, this.config).show(player); diff --git a/src/main/java/com/eternalcode/parcellockers/locker/gui/LockerMainGUI.java b/src/main/java/com/eternalcode/parcellockers/locker/gui/LockerMainGUI.java index 1e1b8759..a26684c4 100644 --- a/src/main/java/com/eternalcode/parcellockers/locker/gui/LockerMainGUI.java +++ b/src/main/java/com/eternalcode/parcellockers/locker/gui/LockerMainGUI.java @@ -24,7 +24,7 @@ public LockerMainGUI(MiniMessage miniMessage, PluginConfiguration config) { @Override public void show(Player player) { Component guiTitle = this.miniMessage.deserialize(this.config.guiSettings.mainGuiTitle); - + Gui gui = Gui.gui() .title(RESET_ITEM.append(guiTitle)) .rows(6) diff --git a/src/main/java/com/eternalcode/parcellockers/locker/repository/LockerRepositoryImpl.java b/src/main/java/com/eternalcode/parcellockers/locker/repository/LockerRepositoryImpl.java index 06375f99..6b281773 100644 --- a/src/main/java/com/eternalcode/parcellockers/locker/repository/LockerRepositoryImpl.java +++ b/src/main/java/com/eternalcode/parcellockers/locker/repository/LockerRepositoryImpl.java @@ -35,11 +35,11 @@ public LockerRepositoryImpl(DataSource dataSource) { private void initTable() { this.executeSync("CREATE TABLE IF NOT EXISTS `lockers`(" + - "uuid VARCHAR(36) NOT NULL, " + - "description VARCHAR(64) NOT NULL, " + - "position VARCHAR(255) NOT NULL, " + - "PRIMARY KEY (uuid)" + - ");", PreparedStatement::execute); + "uuid VARCHAR(36) NOT NULL, " + + "description VARCHAR(64) NOT NULL, " + + "position VARCHAR(255) NOT NULL, " + + "PRIMARY KEY (uuid)" + + ");", PreparedStatement::execute); } @Override @@ -47,10 +47,10 @@ public CompletableFuture save(Locker locker) { return CompletableFuture.runAsync(() -> { try (Connection connection = this.dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement( - "INSERT INTO `lockers`(`uuid`, " + - "`description`, " + - "`position`" + - ") VALUES(?, ?, ?);" + "INSERT INTO `lockers`(`uuid`, " + + "`description`, " + + "`position`" + + ") VALUES(?, ?, ?);" ) ) { statement.setString(1, locker.uuid().toString()); @@ -89,7 +89,7 @@ public CompletableFuture remove(UUID uuid) { return this.execute("DELETE FROM `lockers` WHERE `uuid` = ?;", statement -> { statement.setString(1, uuid.toString()); statement.execute(); - + this.removeFromCache(uuid); }); } @@ -104,7 +104,7 @@ public CompletableFuture findPage(Page page) { return this.supplyExecute("SELECT * FROM `lockers` LIMIT ? OFFSET ?;", statement -> { statement.setInt(1, page.getLimit() + 1); statement.setInt(2, page.getOffset()); - + List lockers = this.extractParcelLockers(statement); boolean hasNext = lockers.size() > page.getLimit(); @@ -130,7 +130,7 @@ private List extractParcelLockers(PreparedStatement statement) throws SQ } list.forEach(this::addToCache); - + return list; } @@ -188,7 +188,7 @@ private CompletableFuture> findBy(String column, String value) rs.getString("description"), Position.parse(rs.getString("position")) ); - + this.addToCache(locker); return Optional.of(locker); } diff --git a/src/main/java/com/eternalcode/parcellockers/notification/NotificationAnnouncer.java b/src/main/java/com/eternalcode/parcellockers/notification/NotificationAnnouncer.java index c8b1a879..98831e23 100644 --- a/src/main/java/com/eternalcode/parcellockers/notification/NotificationAnnouncer.java +++ b/src/main/java/com/eternalcode/parcellockers/notification/NotificationAnnouncer.java @@ -14,10 +14,10 @@ public class NotificationAnnouncer { private final static Map> NOTIFICATION_HANDLERS = Map.of( - NotificationType.CHAT, Audience::sendMessage, - NotificationType.ACTION_BAR, Audience::sendActionBar, - NotificationType.TITLE, (audience, component) -> audience.showTitle(Title.title(component, Component.empty())), - NotificationType.SUBTITLE, (audience, component) -> audience.showTitle(Title.title(Component.empty(), component)) + NotificationType.CHAT, Audience::sendMessage, + NotificationType.ACTION_BAR, Audience::sendActionBar, + NotificationType.TITLE, (audience, component) -> audience.showTitle(Title.title(component, Component.empty())), + NotificationType.SUBTITLE, (audience, component) -> audience.showTitle(Title.title(Component.empty(), component)) ); private final AudienceProvider audienceProvider; @@ -50,7 +50,7 @@ public void sendMessage(CommandSender commandSender, String text) { public void broadcast(String text) { Audience audience = this.audienceProvider.all(); Component message = this.miniMessage.deserialize(text); - + audience.sendMessage(message); } diff --git a/src/main/java/com/eternalcode/parcellockers/parcel/Parcel.java b/src/main/java/com/eternalcode/parcellockers/parcel/Parcel.java index aa825e6e..67beaa6f 100644 --- a/src/main/java/com/eternalcode/parcellockers/parcel/Parcel.java +++ b/src/main/java/com/eternalcode/parcellockers/parcel/Parcel.java @@ -4,7 +4,8 @@ import java.util.UUID; -public record Parcel(UUID uuid, UUID sender, String name, String description, boolean priority, Set recipients, UUID receiver, ParcelSize size, UUID entryLocker, UUID destinationLocker) { +public record Parcel(UUID uuid, UUID sender, String name, String description, boolean priority, Set recipients, + UUID receiver, ParcelSize size, UUID entryLocker, UUID destinationLocker) { public static Builder builder() { return new Builder(); diff --git a/src/main/java/com/eternalcode/parcellockers/parcel/command/argument/ParcelArgument.java b/src/main/java/com/eternalcode/parcellockers/parcel/command/argument/ParcelArgument.java index b8c28bab..0de84ee9 100644 --- a/src/main/java/com/eternalcode/parcellockers/parcel/command/argument/ParcelArgument.java +++ b/src/main/java/com/eternalcode/parcellockers/parcel/command/argument/ParcelArgument.java @@ -23,7 +23,7 @@ public ParcelArgument(ParcelRepositoryImpl cache) { @Override public Result parse(LiteInvocation invocation, String argument) { Parcel parcel = this.databaseService.findParcel(UUID.fromString(argument)).orElse(null); - + if (parcel == null) { return Result.error(); } @@ -33,8 +33,8 @@ public ParcelArgument(ParcelRepositoryImpl cache) { @Override public List suggest(LiteInvocation invocation) { return this.databaseService.cache().values().stream() - .map(Parcel::name) - .map(Suggestion::of) - .toList(); + .map(Parcel::name) + .map(Suggestion::of) + .toList(); } } diff --git a/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelItemStorageGUI.java b/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelItemStorageGUI.java index 29bf51b1..ae28b92f 100644 --- a/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelItemStorageGUI.java +++ b/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelItemStorageGUI.java @@ -24,7 +24,7 @@ public ParcelItemStorageGUI(PluginConfiguration config, MiniMessage miniMessage) void show(Player player, ParcelSize size) { PluginConfiguration.GuiSettings guiSettings = this.config.guiSettings; - + GuiItem backgroundItem = guiSettings.mainGuiBackgroundItem.toGuiItem(this.miniMessage); GuiItem confirmItem = guiSettings.confirmItemsItem.toGuiItem(this.miniMessage, event -> { this.confirmed = true; @@ -59,23 +59,23 @@ void show(Player player, ParcelSize size) { this.gui.setItem(this.gui.getRows(), 2, cancelItem); this.gui.setCloseGuiAction(event -> { if (this.confirmed) { - return; + return; } - + if (this.gui.getInventory().getContents() == null) { return; } - + for (ItemStack item : this.gui.getInventory().getContents()) { if (item == null) { continue; } - + player.getInventory().addItem(item); this.gui.removeItem(item); } }); - + this.gui.open(player); } } diff --git a/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelListGUI.java b/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelListGUI.java index 45a59c78..557e501c 100644 --- a/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelListGUI.java +++ b/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelListGUI.java @@ -58,7 +58,7 @@ private void show(Player player, Page page) { .disableAllInteractions() .rows(6) .create(); - + GuiItem parcelItem = this.config.guiSettings.parcelItem.toGuiItem(this.miniMessage); GuiItem backgroundItem = this.config.guiSettings.mainGuiBackgroundItem.toGuiItem(this.miniMessage); GuiItem cornerItem = this.config.guiSettings.cornerItem.toGuiItem(this.miniMessage); @@ -81,19 +81,19 @@ private void show(Player player, Page page) { for (Parcel parcel : result.parcels()) { if (!player.hasPermission("parcellockers.admin.debug.seeOthersParcels")) { - continue; + continue; } - + if (!parcel.sender().equals(player.getUniqueId())) { continue; } - + if (!parcel.recipients().contains(player.getUniqueId())) { continue; } ItemMeta parcelItemMeta = parcelItem.getItemStack().getItemMeta(); - + List newLore = this.replaceParcelPlaceholders(parcel, parcelItemMeta.getLore()); parcelItemMeta.setLore(newLore); diff --git a/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelSendingGUI.java b/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelSendingGUI.java index d31fdc18..066f0aed 100644 --- a/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelSendingGUI.java +++ b/src/main/java/com/eternalcode/parcellockers/parcel/gui/ParcelSendingGUI.java @@ -82,7 +82,7 @@ public void show(Player player) { private void updateSmallButton(Gui gui, ConfigItem smallButton, ConfigItem mediumButton, ConfigItem largeButton) { this.size = ParcelSize.SMALL; - + gui.updateItem(20, smallButton.setGlow(true).toGuiItem(this.miniMessage)); gui.updateItem(22, mediumButton.setGlow(false).toGuiItem(this.miniMessage, e -> this.updateMediumButton(gui, smallButton, mediumButton, largeButton))); gui.updateItem(24, largeButton.setGlow(false).toGuiItem(this.miniMessage, e -> this.updateLargeButton(gui, smallButton, mediumButton, largeButton))); @@ -90,7 +90,7 @@ private void updateSmallButton(Gui gui, ConfigItem smallButton, ConfigItem mediu private void updateMediumButton(Gui gui, ConfigItem smallButton, ConfigItem mediumButton, ConfigItem largeButton) { this.size = ParcelSize.MEDIUM; - + gui.updateItem(20, smallButton.setGlow(false).toGuiItem(this.miniMessage, e -> this.updateSmallButton(gui, smallButton, mediumButton, largeButton))); gui.updateItem(22, mediumButton.setGlow(true).toGuiItem(this.miniMessage)); gui.updateItem(24, largeButton.setGlow(false).toGuiItem(this.miniMessage, e -> this.updateLargeButton(gui, smallButton, mediumButton, largeButton))); @@ -98,7 +98,7 @@ private void updateMediumButton(Gui gui, ConfigItem smallButton, ConfigItem medi private void updateLargeButton(Gui gui, ConfigItem smallButton, ConfigItem mediumButton, ConfigItem largeButton) { this.size = ParcelSize.LARGE; - + gui.updateItem(20, smallButton.setGlow(false).toGuiItem(this.miniMessage, e -> this.updateSmallButton(gui, smallButton, mediumButton, largeButton))); gui.updateItem(22, mediumButton.setGlow(false).toGuiItem(this.miniMessage, e -> this.updateMediumButton(gui, smallButton, mediumButton, largeButton))); gui.updateItem(24, largeButton.setGlow(true).toGuiItem(this.miniMessage)); diff --git a/src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryImpl.java b/src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryImpl.java index 3664e0cf..38ff4637 100644 --- a/src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryImpl.java +++ b/src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryImpl.java @@ -34,18 +34,18 @@ public ParcelRepositoryImpl(DataSource dataSource) { private void initTable() { try (Connection connection = this.dataSource.getConnection(); PreparedStatement statement = connection.prepareStatement( - "CREATE TABLE IF NOT EXISTS `parcels`(" + - "`uuid` VARCHAR(36) NOT NULL, " + - "`name` VARCHAR(24) NOT NULL, " + - "`description` VARCHAR(64), " + - "`priority` BOOLEAN NOT NULL, " + - "`receiver` VARCHAR(36) NOT NULL, " + - "`size` VARCHAR(10) NOT NULL, " + - "`entryLocker` VARCHAR(36) NOT NULL, " + - "`destinationLocker` VARCHAR(36) NOT NULL, " + - "`sender` VARCHAR(36) NOT NULL, " + - "PRIMARY KEY (uuid) " + - ");" + "CREATE TABLE IF NOT EXISTS `parcels`(" + + "`uuid` VARCHAR(36) NOT NULL, " + + "`name` VARCHAR(24) NOT NULL, " + + "`description` VARCHAR(64), " + + "`priority` BOOLEAN NOT NULL, " + + "`receiver` VARCHAR(36) NOT NULL, " + + "`size` VARCHAR(10) NOT NULL, " + + "`entryLocker` VARCHAR(36) NOT NULL, " + + "`destinationLocker` VARCHAR(36) NOT NULL, " + + "`sender` VARCHAR(36) NOT NULL, " + + "PRIMARY KEY (uuid) " + + ");" ) ) { statement.execute(); @@ -76,7 +76,7 @@ public CompletableFuture save(Parcel parcel) { statement.setString(8, parcel.destinationLocker().toString()); statement.setString(9, parcel.sender().toString()); statement.execute(); - + this.addParcelToCache(parcel); }); } @@ -103,7 +103,7 @@ public CompletableFuture update(Parcel newParcel) { statement.setString(8, newParcel.sender().toString()); statement.setString(9, newParcel.uuid().toString()); statement.execute(); - + this.addParcelToCache(newParcel); }); } @@ -115,9 +115,9 @@ public CompletableFuture> findByUUID(UUID uuid) { ResultSet rs = statement.executeQuery(); if (rs.next()) { Parcel parcel = this.createParcel(rs); - + this.addParcelToCache(parcel); - + return Optional.of(parcel); } return Optional.empty(); @@ -129,11 +129,11 @@ public CompletableFuture> findBySender(UUID sender) { return this.supplyExecute("SELECT * FROM `parcels` WHERE `sender` = ?", statement -> { statement.setString(1, sender.toString()); ResultSet rs = statement.executeQuery(); - + List parcels = new ArrayList<>(); while (rs.next()) { Parcel parcel = this.createParcel(rs); - + this.addParcelToCache(parcel); parcels.add(parcel); } @@ -146,7 +146,7 @@ public CompletableFuture> findByReceiver(UUID receiver) { return this.supplyExecute("SELECT * FROM `parcels` WHERE `receiver` = ?", statement -> { statement.setString(1, receiver.toString()); ResultSet rs = statement.executeQuery(); - + List parcels = new ArrayList<>(); while (rs.next()) { Parcel parcel = this.createParcel(rs); @@ -168,7 +168,7 @@ public CompletableFuture remove(UUID uuid) { return this.supplyExecute("DELETE FROM `parcels` WHERE `uuid` = ?", statement -> { statement.setString(1, uuid.toString()); statement.execute(); - + this.removeParcelFromCache(uuid); return null; }); @@ -180,7 +180,7 @@ public CompletableFuture findPage(Page page) { statement.setInt(1, page.getLimit() + 1); statement.setInt(2, page.getOffset()); ResultSet rs = statement.executeQuery(); - + List parcels = new ArrayList<>(); while (rs.next()) { Parcel parcel = this.createParcel(rs); @@ -198,16 +198,16 @@ public CompletableFuture findPage(Page page) { private Parcel createParcel(ResultSet rs) throws SQLException { return new Parcel( - UUID.fromString(rs.getString("uuid")), - UUID.fromString(rs.getString("sender")), - rs.getString("name"), - rs.getString("description"), - rs.getBoolean("priority"), - new HashSet<>(), - UUID.fromString(rs.getString("receiver")), - ParcelSize.valueOf(rs.getString("size")), - UUID.fromString(rs.getString("entryLocker")), - UUID.fromString(rs.getString("destinationLocker")) + UUID.fromString(rs.getString("uuid")), + UUID.fromString(rs.getString("sender")), + rs.getString("name"), + rs.getString("description"), + rs.getBoolean("priority"), + new HashSet<>(), + UUID.fromString(rs.getString("receiver")), + ParcelSize.valueOf(rs.getString("size")), + UUID.fromString(rs.getString("entryLocker")), + UUID.fromString(rs.getString("destinationLocker")) ); } diff --git a/src/main/java/com/eternalcode/parcellockers/shared/PositionAdapter.java b/src/main/java/com/eternalcode/parcellockers/shared/PositionAdapter.java index b3e393b5..b9c7c92e 100644 --- a/src/main/java/com/eternalcode/parcellockers/shared/PositionAdapter.java +++ b/src/main/java/com/eternalcode/parcellockers/shared/PositionAdapter.java @@ -6,7 +6,8 @@ public final class PositionAdapter { - private PositionAdapter() {} + private PositionAdapter() { + } public static Position convert(Location location) { if (location.getWorld() == null) { diff --git a/src/main/java/com/eternalcode/parcellockers/updater/UpdaterService.java b/src/main/java/com/eternalcode/parcellockers/updater/UpdaterService.java index 2654bd00..e724d6e6 100644 --- a/src/main/java/com/eternalcode/parcellockers/updater/UpdaterService.java +++ b/src/main/java/com/eternalcode/parcellockers/updater/UpdaterService.java @@ -10,6 +10,7 @@ import java.util.concurrent.CompletableFuture; public class UpdaterService { + private static final GitRepository GIT_REPOSITORY = GitRepository.of("EternalCodeTeam", "ParcelLockers"); private final GitCheck gitCheck = new GitCheck(); private final Lazy gitCheckResult; diff --git a/src/main/java/com/eternalcode/parcellockers/util/AdventureUtil.java b/src/main/java/com/eternalcode/parcellockers/util/AdventureUtil.java index 3a79f534..0775ceb7 100644 --- a/src/main/java/com/eternalcode/parcellockers/util/AdventureUtil.java +++ b/src/main/java/com/eternalcode/parcellockers/util/AdventureUtil.java @@ -6,8 +6,8 @@ public final class AdventureUtil { public static final Component RESET_ITEM = Component.text() - .decoration(TextDecoration.ITALIC, false) - .build(); + .decoration(TextDecoration.ITALIC, false) + .build(); private AdventureUtil() { throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); diff --git a/src/main/java/com/eternalcode/parcellockers/util/DurationUtil.java b/src/main/java/com/eternalcode/parcellockers/util/DurationUtil.java index c373db4f..c2c3b36a 100644 --- a/src/main/java/com/eternalcode/parcellockers/util/DurationUtil.java +++ b/src/main/java/com/eternalcode/parcellockers/util/DurationUtil.java @@ -18,8 +18,8 @@ public static String format(Duration duration, boolean removeMillis) { } return duration.toString() - .substring(2) - .replaceAll("(\\d[HMS])(?!$)", "$1 ") - .toLowerCase(); + .substring(2) + .replaceAll("(\\d[HMS])(?!$)", "$1 ") + .toLowerCase(); } } diff --git a/src/main/java/com/eternalcode/parcellockers/util/ItemUtil.java b/src/main/java/com/eternalcode/parcellockers/util/ItemUtil.java index 3b3bb877..10df35c4 100644 --- a/src/main/java/com/eternalcode/parcellockers/util/ItemUtil.java +++ b/src/main/java/com/eternalcode/parcellockers/util/ItemUtil.java @@ -17,7 +17,7 @@ public static boolean compareMeta(ItemStack first, ItemStack second) { if (firstMeta == null) { return false; } - + ItemMeta secondMeta = second.getItemMeta(); if (secondMeta == null) { return false; @@ -26,7 +26,7 @@ public static boolean compareMeta(ItemStack first, ItemStack second) { if (first.getType() != second.getType()) { return false; } - + return firstMeta.getLore().containsAll(secondMeta.getLore()) && firstMeta.getDisplayName().equals(secondMeta.getDisplayName()); } diff --git a/src/main/java/com/eternalcode/parcellockers/util/legacy/Legacy.java b/src/main/java/com/eternalcode/parcellockers/util/legacy/Legacy.java index b2d42f19..7ed719f8 100644 --- a/src/main/java/com/eternalcode/parcellockers/util/legacy/Legacy.java +++ b/src/main/java/com/eternalcode/parcellockers/util/legacy/Legacy.java @@ -6,10 +6,10 @@ public class Legacy { private static final LegacyComponentSerializer AMPERSAND_SERIALIZER = LegacyComponentSerializer.builder() - .character('&') - .hexColors() - .useUnusualXRepeatedCharacterHexFormat() - .build(); + .character('&') + .hexColors() + .useUnusualXRepeatedCharacterHexFormat() + .build(); public static Component component(String text) { return AMPERSAND_SERIALIZER.deserialize(text); diff --git a/src/main/java/com/eternalcode/parcellockers/util/legacy/LegacyColorProcessor.java b/src/main/java/com/eternalcode/parcellockers/util/legacy/LegacyColorProcessor.java index 6a00b1c2..f86aa087 100644 --- a/src/main/java/com/eternalcode/parcellockers/util/legacy/LegacyColorProcessor.java +++ b/src/main/java/com/eternalcode/parcellockers/util/legacy/LegacyColorProcessor.java @@ -10,6 +10,6 @@ public class LegacyColorProcessor implements UnaryOperator { @Override public Component apply(Component component) { return component.replaceText(builder -> builder.match(Pattern.compile(".*")) - .replacement((matchResult, builder1) -> Legacy.component(matchResult.group()))); + .replacement((matchResult, builder1) -> Legacy.component(matchResult.group()))); } }