From 1d1774f4f2e8b2363159d1e0b63210bdb94d7bc2 Mon Sep 17 00:00:00 2001 From: zrdzn Date: Sun, 15 Sep 2024 15:14:17 +0200 Subject: [PATCH] Simplify configs --- .../lovelydrop/LovelyDropCommand.java | 8 +- .../lovelydrop/LovelyDropPlugin.java | 8 +- .../minecraft/lovelydrop/PluginConfig.java | 50 +------ .../lovelydrop/drop/DropCommand.java | 4 +- .../minecraft/lovelydrop/drop/DropConfig.java | 80 ++--------- .../lovelydrop/drop/DropListener.java | 24 ++-- .../minecraft/lovelydrop/menu/MenuConfig.java | 130 ++---------------- .../minecraft/lovelydrop/menu/MenuFacade.java | 6 +- .../lovelydrop/menu/MenuFactory.java | 50 +++---- .../lovelydrop/menu/MenuItemConfig.java | 50 +------ .../lovelydrop/message/MessageConfig.java | 109 ++------------- .../serdes/ColoredTextTransformer.java | 5 +- .../serdes/ComplexItemStackSerializer.java | 7 +- .../serdes/FloatFormatTransformer.java | 5 +- .../lovelydrop/storage/StorageConfig.java | 100 ++------------ .../lovelydrop/storage/StorageFactory.java | 20 +-- .../zrdzn/minecraft/spigot/SpigotAdapter.java | 2 + .../minecraft/spigot/V1_12SpigotAdapter.java | 5 + .../minecraft/spigot/V1_13SpigotAdapter.java | 5 + .../minecraft/spigot/V1_8SpigotAdapter.java | 5 + 20 files changed, 138 insertions(+), 535 deletions(-) diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropCommand.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropCommand.java index 71c4c46..32b77da 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropCommand.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropCommand.java @@ -22,23 +22,23 @@ public LovelyDropCommand(PluginConfig config, MessageFacade messageFacade) { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (!sender.hasPermission("lovelydrop.reload")) { - this.messageFacade.sendMessageAsync(sender, this.config.getMessages().getNoPermissions()); + this.messageFacade.sendMessageAsync(sender, this.config.messages.noPermissions); return true; } if (args.length == 0) { - this.messageFacade.sendMessageAsync(sender, this.config.getMessages().getNotEnoughArguments()); + this.messageFacade.sendMessageAsync(sender, this.config.messages.notEnoughArguments); return true; } if (!args[0].equalsIgnoreCase("reload")) { - this.messageFacade.sendMessageAsync(sender, this.config.getMessages().getNotValidArgument()); + this.messageFacade.sendMessageAsync(sender, this.config.messages.notValidArgument); return true; } this.config.load(); - this.messageFacade.sendMessageAsync(sender, this.config.getMessages().getPluginReloaded()); + this.messageFacade.sendMessageAsync(sender, this.config.messages.pluginReloaded); return true; } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropPlugin.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropPlugin.java index 12a8c01..60a0272 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropPlugin.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/LovelyDropPlugin.java @@ -86,12 +86,13 @@ public void start() { } SpigotAdapter spigotAdapter = this.prepareSpigotAdapter(); + this.logger.info("Using server engine adapter for version v" + spigotAdapter.getVersion()); MessageFacade messageFacade = new MessageFacade(this); Storage storage; try { - storage = new StorageFactory(config.getStorage(), this.getDataFolder()).createStorage(); + storage = new StorageFactory(config.storage, this.getDataFolder()).createStorage(); } catch (StorageException exception) { this.logger.error("Could not create the storage.", exception); this.shutdown(); @@ -106,7 +107,7 @@ public void start() { UserSettingTask userSettingTask = new UserSettingTask(userSettingFacade); BukkitScheduler scheduler = this.getServer().getScheduler(); - this.userSettingBukkitTask = scheduler.runTaskTimerAsynchronously(this, userSettingTask, 20L, config.getUserSettingsSaveInterval() * 20L); + this.userSettingBukkitTask = scheduler.runTaskTimerAsynchronously(this, userSettingTask, 20L, config.userSettingsSaveInterval * 20L); this.registerListeners(config, spigotAdapter, messageFacade, userSettingFacade); @@ -131,7 +132,7 @@ public void registerListeners(PluginConfig config, SpigotAdapter spigotAdapter, PluginManager pluginManager = this.getServer().getPluginManager(); Map defaultDropsToInventory = new HashMap<>(); - config.getDrops().keySet().forEach(key -> defaultDropsToInventory.put(key, true)); + config.drops.keySet().forEach(key -> defaultDropsToInventory.put(key, true)); this.userSettingListener = new UserSettingListener(this, userSettingFacade, defaultDropsToInventory); pluginManager.registerEvents(this.userSettingListener, this); @@ -163,7 +164,6 @@ public SpigotAdapter prepareSpigotAdapter() { try { namespaced = Class.forName("org.bukkit.NamespacedKey"); } catch (ClassNotFoundException exception) { - this.logger.info("Class 'NamespacedKey' not found on 1.12.2+. Using 1.8 spigot adapter."); return new V1_8SpigotAdapter(); } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/PluginConfig.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/PluginConfig.java index 0283ba5..72d1b2c 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/PluginConfig.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/PluginConfig.java @@ -22,15 +22,15 @@ public class PluginConfig extends OkaeriConfig { @Comment("How often should all users settings be saved to the database (in seconds)?") @Comment("By default it is 180 seconds (3 minutes).") - private long userSettingsSaveInterval = 180L; + public long userSettingsSaveInterval = 180L; @Comment("") @Comment("Whole configuration for the drop menu.") - private MenuConfig menu = new MenuConfig(); + public MenuConfig menu = new MenuConfig(); @Comment("") @Comment("All drops that will be available on the server.") - private Map drops = new HashMap() {{ + public Map drops = new HashMap() {{ this.put( "diamondSword", new DropConfig( @@ -195,51 +195,11 @@ public class PluginConfig extends OkaeriConfig { }}; @Comment("") - private StorageConfig storage = new StorageConfig(); + public StorageConfig storage = new StorageConfig(); @Comment("") @Comment("All messages that can be sent by plugin to players.") @Comment("If you want to disable specific messages just set them to '' (empty).") - private MessageConfig messages = new MessageConfig(); - - public long getUserSettingsSaveInterval() { - return this.userSettingsSaveInterval; - } - - public void setUserSettingsSaveInterval(long userSettingsSaveInterval) { - this.userSettingsSaveInterval = userSettingsSaveInterval; - } - - public MenuConfig getMenu() { - return this.menu; - } - - public void setMenu(MenuConfig menu) { - this.menu = menu; - } - - public Map getDrops() { - return this.drops; - } - - public void setDrops(Map drops) { - this.drops = drops; - } - - public StorageConfig getStorage() { - return this.storage; - } - - public void setStorage(StorageConfig storage) { - this.storage = storage; - } - - public MessageConfig getMessages() { - return this.messages; - } - - public void setMessages(MessageConfig messages) { - this.messages = messages; - } + public MessageConfig messages = new MessageConfig(); } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropCommand.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropCommand.java index 0e424cb..fd1c8a2 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropCommand.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropCommand.java @@ -28,14 +28,14 @@ public DropCommand(PluginConfig config, MessageFacade messageFacade, MenuFacade public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { // Check if sender is console. if (!(sender instanceof Player)) { - this.messageFacade.sendMessageAsync(sender, this.config.getMessages().getExecutedAsConsole()); + this.messageFacade.sendMessageAsync(sender, this.config.messages.executedAsConsole); return true; } Player player = (Player) sender; if (!player.hasPermission("lovelydrop.menu.open")) { - this.messageFacade.sendMessageAsync(sender, this.config.getMessages().getNoPermissions()); + this.messageFacade.sendMessageAsync(sender, this.config.messages.noPermissions); return true; } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropConfig.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropConfig.java index 3106ba3..db545d5 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropConfig.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropConfig.java @@ -16,15 +16,15 @@ public class DropConfig extends OkaeriConfig { public static class FortuneConfig extends OkaeriConfig { @Comment("Percentage chance of dropping the item.") - private FloatFormat chance; + public FloatFormat chance; @Comment("") @Comment("Range of the amount of items that can be dropped.") - private IntRange amount; + public IntRange amount; @Comment("") @Comment("Amount of experience given to the player when they have a successful drop.") - private int experience; + public int experience; public FortuneConfig(float chance, IntRange amount, int experience) { this(new FloatFormat(chance), amount, experience); @@ -36,30 +36,6 @@ public FortuneConfig(FloatFormat chance, IntRange amount, int experience) { this.experience = experience; } - public FloatFormat getChance() { - return this.chance; - } - - public void setChance(FloatFormat chance) { - this.chance = chance; - } - - public IntRange getAmount() { - return this.amount; - } - - public void setAmount(IntRange amount) { - this.amount = amount; - } - - public int getExperience() { - return this.experience; - } - - public void setExperience(int experience) { - this.experience = experience; - } - } @Comment("Item representation of the drop.") @@ -71,26 +47,26 @@ public void setExperience(int experience) { @Comment("For example:") @Comment("1.8 - damage_all | 1.8 - durability | 1.8 - loot_bonus_mobs") @Comment("1.18 - sharpness | 1.18 - unbreaking | 1.18 - loot") - private ComplexItemStack item; + public ComplexItemStack item; @Comment("") @Comment("Item representation of the block from which 'item' should be dropped.") @Comment("If you want to use legacy materials, set a durability to some number, e.g. material: stone with durability: 5 for andesite.") @Comment("Check https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html for list of materials.") - private ItemStack source; + public ItemStack source; @Comment("") @Comment("Height range within which the item can be dropped.") - private IntRange height; + public IntRange height; @Comment("") @Comment("All properties will be applied to the drop, depending on the current pickaxe fortune level.") @Comment("It must contain at least one section.") - private Map fortune; + public Map fortune; @Comment("") @Comment("List of biomes in which the drop will not be dropped.") - private Set disabledBioms; + public Set disabledBioms; public DropConfig(ComplexItemStack item, ItemStack source, IntRange height, Map fortune) { this(item, source, height, fortune, new HashSet<>()); @@ -104,44 +80,4 @@ public DropConfig(ComplexItemStack item, ItemStack source, IntRange height, Map< this.disabledBioms = disabledBioms; } - public ComplexItemStack getItem() { - return this.item; - } - - public void setItem(ComplexItemStack item) { - this.item = item; - } - - public ItemStack getSource() { - return this.source.clone(); - } - - public void setSource(ItemStack source) { - this.source = source; - } - - public IntRange getHeight() { - return this.height; - } - - public void setHeight(IntRange height) { - this.height = height; - } - - public Map getFortune() { - return this.fortune; - } - - public void setFortune(Map fortune) { - this.fortune = fortune; - } - - public Set getDisabledBioms() { - return this.disabledBioms; - } - - public void setDisabledBioms(Set disabledBioms) { - this.disabledBioms = disabledBioms; - } - } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java index 82bdbb0..14c0ed7 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/drop/DropListener.java @@ -60,18 +60,18 @@ public void onSourceBreak(BlockBreakEvent event) { Optional userSettingMaybe = this.userSettingFacade.findUserSettingByPlayerIdFromCache(player.getUniqueId()); if (!userSettingMaybe.isPresent()) { this.logger.error("User settings not found for {}.", player.getName()); - this.messageFacade.sendMessageAsync(player, this.config.getMessages().getNeedToJoinAgain()); + this.messageFacade.sendMessageAsync(player, this.config.messages.needToJoinAgain); return; } UserSetting userSetting = userSettingMaybe.get(); // Get all drops from the source. - Set> drops = this.config.getDrops().entrySet().stream() + Set> drops = this.config.drops.entrySet().stream() .filter(drop -> !userSetting.hasDisabledDrop(drop.getKey())) - .filter(drop -> !drop.getValue().getDisabledBioms().contains(block.getBiome())) - .filter(drop -> drop.getValue().getSource().getType() == block.getType()) - .filter(drop -> drop.getValue().getSource().getDurability() == block.getData()) + .filter(drop -> !drop.getValue().disabledBioms.contains(block.getBiome())) + .filter(drop -> drop.getValue().source.getType() == block.getType()) + .filter(drop -> drop.getValue().source.getDurability() == block.getData()) .collect(Collectors.toSet()); if (drops.isEmpty()) { return; @@ -87,21 +87,21 @@ public void onSourceBreak(BlockBreakEvent event) { drops.forEach(keyAndDrop -> { DropConfig drop = keyAndDrop.getValue(); - IntRange heightRange = drop.getHeight(); + IntRange heightRange = drop.height; if (blockHeight < heightRange.getMin() || blockHeight > heightRange.getMax()) { return; } - FortuneConfig fortune = drop.getFortune().getOrDefault(fortuneLevel, drop.getFortune().get(0)); + FortuneConfig fortune = drop.fortune.getOrDefault(fortuneLevel, drop.fortune.get(0)); if (fortune == null) { return; } - if (fortune.getChance().getValue() <= Math.random() * 100.0F) { + if (fortune.chance.getValue() <= Math.random() * 100.0F) { return; } - ItemStack dropItem = drop.getItem().getItemStack(); + ItemStack dropItem = drop.item.getItemStack(); // If pickaxe has silk touch and drop is cobblestone, change drop to stone. if (dropItem.getType() == Material.COBBLESTONE && pickaxe.containsEnchantment(Enchantment.SILK_TOUCH)) { @@ -109,14 +109,14 @@ public void onSourceBreak(BlockBreakEvent event) { } // Give experience to player. - player.giveExp(fortune.getExperience()); + player.giveExp(fortune.experience); // Randomize amount from range and set it for item. - int amount = fortune.getAmount().getRandom(); + int amount = fortune.amount.getRandom(); dropItem.setAmount(amount); String[] placeholders = { "{DROP}", keyAndDrop.getKey(), "{AMOUNT}", String.valueOf(amount) }; - this.messageFacade.sendMessage(player, this.config.getMessages().getDropSuccessful(), placeholders); + this.messageFacade.sendMessage(player, this.config.messages.dropSuccessful, placeholders); World world = player.getWorld(); diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuConfig.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuConfig.java index 75066eb..23745de 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuConfig.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuConfig.java @@ -20,7 +20,7 @@ public class MenuConfig extends OkaeriConfig { public static class FillerConfig extends OkaeriConfig { @Comment("Whether empty slots should be filled with specified item or not.") - private boolean enabled = false; + public boolean enabled = false; @Comment("") @Comment("Item representation of the drop.") @@ -32,83 +32,51 @@ public static class FillerConfig extends OkaeriConfig { @Comment("For example:") @Comment("1.8 - damage_all | 1.8 - durability | 1.8 - loot_bonus_mobs") @Comment("1.18 - sharpness | 1.18 - unbreaking | 1.18 - loot") - private ItemStack item = new ItemStack(Material.GLASS); - - public boolean isEnabled() { - return this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public ItemStack getItem() { - return this.item; - } - - public void setItem(ItemStack item) { - this.item = item; - } + public ItemStack item = new ItemStack(Material.GLASS); } public static class SwitchConfig extends OkaeriConfig { @Comment("Used when the switch is enabled.") - private ColoredText enabled = new ColoredText("&eon"); + public ColoredText enabled = new ColoredText("&eon"); @Comment("") @Comment("Used when the switch is disabled.") - private ColoredText disabled = new ColoredText("&coff"); - - public ColoredText getEnabled() { - return this.enabled; - } - - public void setEnabled(ColoredText enabled) { - this.enabled = enabled; - } - - public ColoredText getDisabled() { - return this.disabled; - } - - public void setDisabled(ColoredText disabled) { - this.disabled = disabled; - } + public ColoredText disabled = new ColoredText("&coff"); } @Comment("Title of the drop menu.") - private ColoredText title = new ColoredText("&2&lDrop Menu"); + public ColoredText title = new ColoredText("&2&lDrop Menu"); @Comment("") @Comment("Rows amount of the drop menu.") - private int rows = 4; + public int rows = 4; @Comment("") @Comment("Item that is filled in empty slots.") - private FillerConfig filler = new FillerConfig(); + public FillerConfig filler = new FillerConfig(); @Comment("") @Comment("Text placeholder which stands for {SWITCH} that could be used in items section.") - private SwitchConfig dropSwitch = new SwitchConfig(); + public SwitchConfig dropSwitch = new SwitchConfig(); @Comment("") @Comment("Text placeholder which stands for {SWITCH_INVENTORY} that could be used in items section.") - private SwitchConfig inventoryDropSwitch = new SwitchConfig(); + public SwitchConfig inventoryDropSwitch = new SwitchConfig(); @Comment("") @Comment("Text placeholder which stands for {AMOUNT-{LEVEL}} that could be used in items section.") - private IntRangeFormatConfig amountFormat = new IntRangeFormatConfig("&e{AMOUNT}", "&e{AMOUNT-MIN}&8-&e{AMOUNT-MAX}"); + public IntRangeFormatConfig amountFormat = new IntRangeFormatConfig("&e{AMOUNT}", "&e{AMOUNT-MIN}&8-&e{AMOUNT-MAX}"); @Comment("") @Comment("Text placeholder which stands for {HEIGHT} that could be used in items section.") - private IntRangeFormatConfig heightFormat = new IntRangeFormatConfig("&e{HEIGHT}", "&e{HEIGHT-MIN}&8-&e{HEIGHT-MAX}"); + public IntRangeFormatConfig heightFormat = new IntRangeFormatConfig("&e{HEIGHT}", "&e{HEIGHT-MIN}&8-&e{HEIGHT-MAX}"); @Comment("") @Comment("If drop to inventory should be enabled by default or not.") - private boolean defaultDropToInventory = true; + public boolean defaultDropToInventory = true; @Comment("") @Comment("All items that will appear in the menu.") @@ -119,7 +87,7 @@ public void setDisabled(ColoredText disabled) { @Comment("{SWITCH} - a text that will be shown depending on the drop switch status") @Comment("{SWITCH_INVENTORY} - a text that will be shown depending on the inventory drop switch status") @Comment("{HEIGHT} - a text that will be shown depending on the customized height range") - private Map items = new HashMap() {{ + public Map items = new HashMap() {{ this.put( "close", new MenuItemConfig( @@ -242,76 +210,4 @@ public void setDisabled(ColoredText disabled) { ); }}; - public ColoredText getTitle() { - return this.title; - } - - public void setTitle(ColoredText title) { - this.title = title; - } - - public int getRows() { - return this.rows; - } - - public void setRows(int rows) { - this.rows = rows; - } - - public FillerConfig getFiller() { - return this.filler; - } - - public void setFiller(FillerConfig filler) { - this.filler = filler; - } - - public SwitchConfig getDropSwitch() { - return this.dropSwitch; - } - - public void setDropSwitch(SwitchConfig dropSwitch) { - this.dropSwitch = dropSwitch; - } - - public SwitchConfig getInventoryDropSwitch() { - return this.inventoryDropSwitch; - } - - public void setInventoryDropSwitch(SwitchConfig inventoryDropSwitch) { - this.inventoryDropSwitch = inventoryDropSwitch; - } - - public IntRangeFormatConfig getAmountFormat() { - return this.amountFormat; - } - - public void setAmountFormat(IntRangeFormatConfig amountFormat) { - this.amountFormat = amountFormat; - } - - public IntRangeFormatConfig getHeightFormat() { - return this.heightFormat; - } - - public void setHeightFormat(IntRangeFormatConfig heightFormat) { - this.heightFormat = heightFormat; - } - - public boolean isDefaultDropToInventory() { - return this.defaultDropToInventory; - } - - public void setDefaultDropToInventory(boolean defaultDropToInventory) { - this.defaultDropToInventory = defaultDropToInventory; - } - - public Map getItems() { - return this.items; - } - - public void setItems(Map items) { - this.items = items; - } - } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFacade.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFacade.java index 5ac1166..4c1339d 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFacade.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFacade.java @@ -36,14 +36,14 @@ public MenuFacade(PluginConfig config, MenuFactory menuFactory, MessageFacade me * @param player a player to open the menu for */ public void open(Player player) { - MessageConfig messageConfig = this.config.getMessages(); - MenuConfig menuConfig = this.config.getMenu(); + MessageConfig messageConfig = this.config.messages; + MenuConfig menuConfig = this.config.menu; // Get user settings from the cache. Optional userSettingMaybe = this.userSettingFacade.findUserSettingByPlayerIdFromCache(player.getUniqueId()); if (!userSettingMaybe.isPresent()) { this.logger.error("User settings not found for {}.", player.getName()); - this.messageFacade.sendMessageAsync(player, messageConfig.getNeedToJoinAgain()); + this.messageFacade.sendMessageAsync(player, messageConfig.needToJoinAgain); return; } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFactory.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFactory.java index 469b6e0..f14b55b 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFactory.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuFactory.java @@ -30,25 +30,25 @@ public MenuFactory(PluginConfig config, MessageFacade messageFacade) { } public Gui createDropMenu(Player player, UserSetting userSetting) { - MenuConfig menuConfig = this.config.getMenu(); + MenuConfig menuConfig = this.config.menu; - Gui menu = new Gui(menuConfig.getRows(), menuConfig.getTitle().getText(), InteractionModifier.VALUES); + Gui menu = new Gui(menuConfig.rows, menuConfig.title.getText(), InteractionModifier.VALUES); // Forbid the player from getting the item from the inventory. menu.setDefaultClickAction(event -> event.setCancelled(true)); - menuConfig.getItems().forEach((menuSlotItemKey, menuSlotItem) -> { - MenuItemConfig.SlotConfig slot = menuSlotItem.getSlot(); - int row = slot.getRow(); - int column = slot.getColumn(); + menuConfig.items.forEach((menuSlotItemKey, menuSlotItem) -> { + MenuItemConfig.SlotConfig slot = menuSlotItem.slot; + int row = slot.row; + int column = slot.column; - Map actions = menuSlotItem.getClickAction(); + Map actions = menuSlotItem.clickAction; - DropConfig drop = this.config.getDrops().get(menuSlotItemKey); + DropConfig drop = this.config.drops.get(menuSlotItemKey); // Set item that does not have drop item assigned to it. if (drop == null) { - menu.setItem(row, column, ItemBuilder.from(menuSlotItem.getItem()) + menu.setItem(row, column, ItemBuilder.from(menuSlotItem.item) .asGuiItem(event -> { ClickType click = event.getClick(); @@ -60,12 +60,12 @@ public Gui createDropMenu(Player player, UserSetting userSetting) { return; } - IntRangeFormatConfig heightFormat = menuConfig.getHeightFormat(); - IntRange heightRange = drop.getHeight(); + IntRangeFormatConfig heightFormat = menuConfig.heightFormat; + IntRange heightRange = drop.height; String minimumHeight = String.valueOf(heightRange.getMin()); String maximumHeight = String.valueOf(heightRange.getMax()); - ItemStack menuItemStack = menuSlotItem.getItem(); + ItemStack menuItemStack = menuSlotItem.item; List lore = menuItemStack.getItemMeta().getLore().stream() .map(line -> { String formattedHeight; @@ -81,12 +81,12 @@ public Gui createDropMenu(Player player, UserSetting userSetting) { }) .collect(Collectors.toList()); - Map fortunes = drop.getFortune(); + Map fortunes = drop.fortune; for (int level = 0; level < fortunes.size(); level++) { DropConfig.FortuneConfig fortune = fortunes.get(level); - IntRangeFormatConfig amountFormat = menuConfig.getAmountFormat(); - IntRange amountRange = fortune.getAmount(); + IntRangeFormatConfig amountFormat = menuConfig.amountFormat; + IntRange amountRange = fortune.amount; String minimumAmount = String.valueOf(amountRange.getMin()); String maximumAmount = String.valueOf(amountRange.getMax()); @@ -94,7 +94,7 @@ public Gui createDropMenu(Player player, UserSetting userSetting) { // Format lore with the chance and experience. String line = StringUtils.replaceEach(lore.get(lineNumber), new String[]{ String.format("{CHANCE-%d}", level), String.format("{EXPERIENCE-%d}", level) }, - new String[]{ fortune.getChance().getFormattedValue(), String.valueOf(fortune.getExperience()) }); + new String[]{ fortune.chance.getFormattedValue(), String.valueOf(fortune.experience) }); // Format lore with the fixed amount. String placeholder = String.format("{AMOUNT-%d}", level); @@ -112,8 +112,8 @@ public Gui createDropMenu(Player player, UserSetting userSetting) { } } - MenuConfig.SwitchConfig dropSwitch = menuConfig.getDropSwitch(); - MenuConfig.SwitchConfig inventorySwitch = menuConfig.getInventoryDropSwitch(); + MenuConfig.SwitchConfig dropSwitch = menuConfig.dropSwitch; + MenuConfig.SwitchConfig inventorySwitch = menuConfig.inventoryDropSwitch; ItemBuilder menuItemBuilder = ItemBuilder.from(menuItemStack) .setLore(this.formatLore(lore, userSetting, menuSlotItemKey, dropSwitch, inventorySwitch)); @@ -139,9 +139,9 @@ public Gui createDropMenu(Player player, UserSetting userSetting) { }); // Fill the rest inventory with the specified item if enabled. - MenuConfig.FillerConfig filler = menuConfig.getFiller(); - if (filler.isEnabled()) { - menu.getFiller().fill(ItemBuilder.from(filler.getItem()).asGuiItem()); + MenuConfig.FillerConfig filler = menuConfig.filler; + if (filler.enabled) { + menu.getFiller().fill(ItemBuilder.from(filler.item).asGuiItem()); } return menu; @@ -157,10 +157,10 @@ private void handleClickAction(Player player, UserSetting userSetting, Gui menu, userSetting.addDisabledDrop(menuSlotItemKey); } - this.messageFacade.sendMessage(player, this.config.getMessages().getDropSwitched(), "{DROP}", menuSlotItemKey); + this.messageFacade.sendMessage(player, this.config.messages.dropSwitched, "{DROP}", menuSlotItemKey); } else if (action == MenuAction.SWITCH_DROP_TO_INVENTORY) { userSetting.setDropToInventory(menuSlotItemKey, !userSetting.hasDropToInventory(menuSlotItemKey)); - this.messageFacade.sendMessage(player, this.config.getMessages().getDropSwitchedInventory(), "{DROP}", menuSlotItemKey); + this.messageFacade.sendMessage(player, this.config.messages.dropSwitchedInventory, "{DROP}", menuSlotItemKey); } } @@ -169,8 +169,8 @@ private List formatLore(List lore, UserSetting userSetting, Stri return lore.stream() .map(line -> { String[] replacements = { - userSetting.hasDisabledDrop(menuSlotItemKey) ? dropSwitch.getDisabled().getText() : dropSwitch.getEnabled().getText(), - userSetting.hasDropToInventory(menuSlotItemKey) ? inventorySwitch.getEnabled().getText() : inventorySwitch.getDisabled().getText() + userSetting.hasDisabledDrop(menuSlotItemKey) ? dropSwitch.disabled.getText() : dropSwitch.enabled.getText(), + userSetting.hasDropToInventory(menuSlotItemKey) ? inventorySwitch.enabled.getText() : inventorySwitch.disabled.getText() }; return StringUtils.replaceEach(line, new String[]{ "{SWITCH}", "{SWITCH_INVENTORY}" }, replacements); diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuItemConfig.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuItemConfig.java index 7a8f5cf..7fc6b9d 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuItemConfig.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/menu/MenuItemConfig.java @@ -11,33 +11,17 @@ public class MenuItemConfig extends OkaeriConfig { public static class SlotConfig extends OkaeriConfig { @Comment("Row of the menu item.") - private int row; + public int row; @Comment("") @Comment("Column of the menu item.") - private int column; + public int column; public SlotConfig(int row, int column) { this.row = row; this.column = column; } - public int getRow() { - return this.row; - } - - public void setRow(int row) { - this.row = row; - } - - public int getColumn() { - return this.column; - } - - public void setColumn(int column) { - this.column = column; - } - } @Comment("Item representation of the drop.") @@ -49,7 +33,7 @@ public void setColumn(int column) { @Comment("For example:") @Comment("1.8 - damage_all | 1.8 - durability | 1.8 - loot_bonus_mobs") @Comment("1.18 - sharpness | 1.18 - unbreaking | 1.18 - loot") - private ItemStack item; + public ItemStack item; @Comment("") @Comment("What should happen when the player clicks the item.") @@ -60,11 +44,11 @@ public void setColumn(int column) { @Comment("SWITCH_DROP_TO_INVENTORY - switches the drop to inventory (id of the menu item must be equal to drop item id).") @Comment(" ") @Comment("Section contains key and value fields where the key is the specified field in the https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/ClickType.html.") - private Map clickAction; + public Map clickAction; @Comment("") @Comment("Item position in the menu.") - private SlotConfig slot; + public SlotConfig slot; public MenuItemConfig(ItemStack item, Map clickAction, SlotConfig slot) { this.item = item; @@ -72,28 +56,4 @@ public MenuItemConfig(ItemStack item, Map clickAction, Sl this.slot = slot; } - public ItemStack getItem() { - return this.item.clone(); - } - - public void setItem(ItemStack item) { - this.item = item; - } - - public Map getClickAction() { - return this.clickAction; - } - - public void setClickAction(Map clickAction) { - this.clickAction = clickAction; - } - - public SlotConfig getSlot() { - return this.slot; - } - - public void setSlot(SlotConfig slot) { - this.slot = slot; - } - } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/message/MessageConfig.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/message/MessageConfig.java index e90085a..4df46d8 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/message/MessageConfig.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/message/MessageConfig.java @@ -5,104 +5,15 @@ public class MessageConfig extends OkaeriConfig { - private ColoredText executedAsConsole = new ColoredText("&cYou cannot execute this command as console."); - - private ColoredText noPermissions = new ColoredText("&cYou do not have enough permissions to perform that action."); - - private ColoredText menuOpenError = new ColoredText("&cSomething went wrong while opening the drop menu."); - - private ColoredText pluginReloaded = new ColoredText("&aPlugin has been reloaded."); - - private ColoredText notEnoughArguments = new ColoredText("&cYou need to provide arguments."); - - private ColoredText notValidArgument = new ColoredText("&cYou have provided wrong argument. &eUse /lovelydrop reload."); - - private ColoredText dropSwitched = new ColoredText("&aYou have switched the {DROP} drop."); - - private ColoredText dropSwitchedInventory = new ColoredText("&aYou have switched the {DROP} drop to inventory."); - - private ColoredText dropSuccessful = new ColoredText("&aYou have dropped {AMOUNT}x {DROP}!"); - - private ColoredText needToJoinAgain = new ColoredText("&cSomething went wrong while loading your settings, please try joining again."); - - public ColoredText getExecutedAsConsole() { - return this.executedAsConsole; - } - - public void setExecutedAsConsole(ColoredText executedAsConsole) { - this.executedAsConsole = executedAsConsole; - } - - public ColoredText getNoPermissions() { - return this.noPermissions; - } - - public void setNoPermissions(ColoredText noPermissions) { - this.noPermissions = noPermissions; - } - - public ColoredText getMenuOpenError() { - return this.menuOpenError; - } - - public void setMenuOpenError(ColoredText menuOpenError) { - this.menuOpenError = menuOpenError; - } - - public ColoredText getPluginReloaded() { - return this.pluginReloaded; - } - - public void setPluginReloaded(ColoredText pluginReloaded) { - this.pluginReloaded = pluginReloaded; - } - - public ColoredText getNotEnoughArguments() { - return this.notEnoughArguments; - } - - public void setNotEnoughArguments(ColoredText notEnoughArguments) { - this.notEnoughArguments = notEnoughArguments; - } - - public ColoredText getNotValidArgument() { - return this.notValidArgument; - } - - public void setNotValidArgument(ColoredText notValidArgument) { - this.notValidArgument = notValidArgument; - } - - public ColoredText getDropSwitched() { - return this.dropSwitched; - } - - public void setDropSwitched(ColoredText dropSwitched) { - this.dropSwitched = dropSwitched; - } - - public ColoredText getDropSwitchedInventory() { - return this.dropSwitchedInventory; - } - - public void setDropSwitchedInventory(ColoredText dropSwitchedInventory) { - this.dropSwitchedInventory = dropSwitchedInventory; - } - - public ColoredText getDropSuccessful() { - return this.dropSuccessful; - } - - public void setDropSuccessful(ColoredText dropSuccessful) { - this.dropSuccessful = dropSuccessful; - } - - public ColoredText getNeedToJoinAgain() { - return this.needToJoinAgain; - } - - public void setNeedToJoinAgain(ColoredText needToJoinAgain) { - this.needToJoinAgain = needToJoinAgain; - } + public ColoredText executedAsConsole = new ColoredText("&cYou cannot execute this command as console."); + public ColoredText noPermissions = new ColoredText("&cYou do not have enough permissions to perform that action."); + public ColoredText menuOpenError = new ColoredText("&cSomething went wrong while opening the drop menu."); + public ColoredText pluginReloaded = new ColoredText("&aPlugin has been reloaded."); + public ColoredText notEnoughArguments = new ColoredText("&cYou need to provide arguments."); + public ColoredText notValidArgument = new ColoredText("&cYou have provided wrong argument. &eUse /lovelydrop reload."); + public ColoredText dropSwitched = new ColoredText("&aYou have switched the {DROP} drop."); + public ColoredText dropSwitchedInventory = new ColoredText("&aYou have switched the {DROP} drop to inventory."); + public ColoredText dropSuccessful = new ColoredText("&aYou have dropped {AMOUNT}x {DROP}!"); + public ColoredText needToJoinAgain = new ColoredText("&cSomething went wrong while loading your settings, please try joining again."); } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ColoredTextTransformer.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ColoredTextTransformer.java index 2bcbba5..3608606 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ColoredTextTransformer.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ColoredTextTransformer.java @@ -4,6 +4,7 @@ import eu.okaeri.configs.serdes.BidirectionalTransformer; import eu.okaeri.configs.serdes.SerdesContext; import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; /** * Text transformer where left is the raw text with unparsed color codes and right is the colored text. @@ -16,12 +17,12 @@ public GenericsPair getPair() { } @Override - public ColoredText leftToRight(String text, SerdesContext serdesContext) { + public ColoredText leftToRight(@NotNull String text, @NotNull SerdesContext serdesContext) { return new ColoredText(ChatColor.translateAlternateColorCodes('&', text)); } @Override - public String rightToLeft(ColoredText text, SerdesContext serdesContext) { + public String rightToLeft(ColoredText text, @NotNull SerdesContext serdesContext) { return text.getText().replace(ChatColor.COLOR_CHAR, '&'); } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ComplexItemStackSerializer.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ComplexItemStackSerializer.java index 4db47ac..5d313c9 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ComplexItemStackSerializer.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/ComplexItemStackSerializer.java @@ -7,6 +7,7 @@ import eu.okaeri.configs.serdes.SerializationData; import io.github.zrdzn.minecraft.lovelydrop.shared.ItemFactory; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Complex itemstack serializer which serializes/deserializes it from/to configuration file. @@ -14,12 +15,12 @@ public class ComplexItemStackSerializer implements ObjectSerializer> { @Override - public boolean supports(Class> type) { + public boolean supports(@NotNull Class> type) { return ComplexItemStack.class.isAssignableFrom(type); } @Override - public void serialize(ComplexItemStack complexItemStack, SerializationData data, GenericsDeclaration generics) { + public void serialize(ComplexItemStack complexItemStack, SerializationData data, @NotNull GenericsDeclaration generics) { data.add("stack", complexItemStack.getItemStack(), ItemStack.class); if (complexItemStack.getNbtData() != null) { Map nbtData = (Map) complexItemStack.getNbtData(); @@ -28,7 +29,7 @@ public void serialize(ComplexItemStack complexItemStack, SerializationData da } @Override - public ComplexItemStack deserialize(DeserializationData data, GenericsDeclaration generics) { + public ComplexItemStack deserialize(DeserializationData data, @NotNull GenericsDeclaration generics) { ItemStack itemStack = data.get("stack", ItemStack.class); Map nbtData = data.getAsMap("nbt", String.class, Object.class); diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/FloatFormatTransformer.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/FloatFormatTransformer.java index a0c3c29..97aba6d 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/FloatFormatTransformer.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/serdes/FloatFormatTransformer.java @@ -3,6 +3,7 @@ import eu.okaeri.configs.schema.GenericsPair; import eu.okaeri.configs.serdes.BidirectionalTransformer; import eu.okaeri.configs.serdes.SerdesContext; +import org.jetbrains.annotations.NotNull; /** * Float transformer which removes trailing zeroes and holds it along with the original value. @@ -15,14 +16,14 @@ public GenericsPair getPair() { } @Override - public FloatFormat leftToRight(Float data, SerdesContext serdesContext) { + public FloatFormat leftToRight(@NotNull Float data, @NotNull SerdesContext serdesContext) { String formattedValue = String.valueOf(data); formattedValue = formattedValue.contains(".") ? formattedValue.replaceAll("0*$","").replaceAll("\\.$","") : formattedValue; return new FloatFormat(data, formattedValue); } @Override - public Float rightToLeft(FloatFormat data, SerdesContext serdesContext) { + public Float rightToLeft(FloatFormat data, @NotNull SerdesContext serdesContext) { return data.getValue(); } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageConfig.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageConfig.java index e1ee727..8a2ea65 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageConfig.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageConfig.java @@ -6,122 +6,42 @@ public class StorageConfig extends OkaeriConfig { @Comment("A type of the data source that should be used. Available: SQLITE, POSTGRESQL, IN_MEMORY") - private StorageType type = StorageType.SQLITE; + public StorageType type = StorageType.SQLITE; @Comment("") @Comment("A file name if SQLite is used.") - private String sqliteFile = "lovelydrop.db"; + public String sqliteFile = "lovelydrop.db"; @Comment("") @Comment("Database host address.") - private String host = "localhost"; + public String host = "localhost"; @Comment("") @Comment("Database port.") - private int port = 5432; + public int port = 5432; @Comment("") @Comment("Database name.") - private String database = "lovelydrop"; + public String database = "lovelydrop"; @Comment("") @Comment("Database user name.") - private String user = "minecraft_user"; + public String user = "minecraft_user"; @Comment("") @Comment("Database password.") - private String password = "tomatoes"; + public String password = "tomatoes"; @Comment("") @Comment("Should SSL be enabled for database?") - private boolean enableSsl = false; + public boolean enableSsl = false; @Comment("") @Comment("Database maximum pool size.") - private int maximumPoolSize = 10; + public int maximumPoolSize = 10; @Comment("") @Comment("Database connection timeout.") - private int connectionTimeout = 5000; - - public StorageType getType() { - return this.type; - } - - public void setType(StorageType type) { - this.type = type; - } - - public String getSqliteFile() { - return this.sqliteFile; - } - - public void setSqliteFile(String sqliteFile) { - this.sqliteFile = sqliteFile; - } - - public String getHost() { - return this.host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return this.port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getDatabase() { - return this.database; - } - - public void setDatabase(String database) { - this.database = database; - } - - public String getUser() { - return this.user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getPassword() { - return this.password; - } - - public void setPassword(String password) { - this.password = password; - } - - public boolean isEnableSsl() { - return this.enableSsl; - } - - public void setEnableSsl(boolean enableSsl) { - this.enableSsl = enableSsl; - } - - public int getMaximumPoolSize() { - return this.maximumPoolSize; - } - - public void setMaximumPoolSize(int maximumPoolSize) { - this.maximumPoolSize = maximumPoolSize; - } - - public int getConnectionTimeout() { - return this.connectionTimeout; - } - - public void setConnectionTimeout(int connectionTimeout) { - this.connectionTimeout = connectionTimeout; - } + public int connectionTimeout = 5000; } diff --git a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageFactory.java b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageFactory.java index 4d99761..aa54462 100644 --- a/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageFactory.java +++ b/plugin/src/main/java/io/github/zrdzn/minecraft/lovelydrop/storage/StorageFactory.java @@ -38,8 +38,8 @@ public Storage createStorage() { StorageType storageType; HikariConfig hikariConfig = new HikariConfig(); - hikariConfig.setUsername(this.config.getUser()); - hikariConfig.setPassword(this.config.getPassword()); + hikariConfig.setUsername(this.config.user); + hikariConfig.setPassword(this.config.password); hikariConfig.addDataSourceProperty("cachePrepStmts", true); hikariConfig.addDataSourceProperty("prepStmtCacheSize", 250); hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", 2048); @@ -47,16 +47,16 @@ public Storage createStorage() { hikariConfig.addDataSourceProperty("cacheResultSetMetadata", true); hikariConfig.addDataSourceProperty("tcpKeepAlive", true); hikariConfig.setLeakDetectionThreshold(60000L); - hikariConfig.setMaximumPoolSize(this.config.getMaximumPoolSize()); - hikariConfig.setConnectionTimeout(this.config.getConnectionTimeout()); + hikariConfig.setMaximumPoolSize(this.config.maximumPoolSize); + hikariConfig.setConnectionTimeout(this.config.connectionTimeout); hikariConfig.setMinimumIdle(0); hikariConfig.setIdleTimeout(30000L); - String host = this.config.getHost(); - int port = this.config.getPort(); - String database = this.config.getDatabase(); + String host = this.config.host; + int port = this.config.port; + String database = this.config.database; - switch (this.config.getType()) { + switch (this.config.type) { case SQLITE: try { Class.forName("org.sqlite.JDBC"); @@ -64,7 +64,7 @@ public Storage createStorage() { throw new StorageException("SQLite driver not found.", exception); } - File sqliteFile = new File(this.dataFolder, this.config.getSqliteFile()); + File sqliteFile = new File(this.dataFolder, this.config.sqliteFile); if (!sqliteFile.exists()) { try { Files.createParentDirs(sqliteFile); @@ -96,7 +96,7 @@ public Storage createStorage() { break; case POSTGRESQL: - boolean enableSsl = this.config.isEnableSsl(); + boolean enableSsl = this.config.enableSsl; if (!enableSsl) { this.logger.warn("Storage connection is configured without SSL enabled."); } diff --git a/spigot/src/main/java/io/github/zrdzn/minecraft/spigot/SpigotAdapter.java b/spigot/src/main/java/io/github/zrdzn/minecraft/spigot/SpigotAdapter.java index bd7c114..69a820d 100644 --- a/spigot/src/main/java/io/github/zrdzn/minecraft/spigot/SpigotAdapter.java +++ b/spigot/src/main/java/io/github/zrdzn/minecraft/spigot/SpigotAdapter.java @@ -2,6 +2,8 @@ public interface SpigotAdapter { + String getVersion(); + BlockBreakHelper getBlockBreakHelper(); } diff --git a/v1_12/src/main/java/io/github/zrdzn/minecraft/spigot/V1_12SpigotAdapter.java b/v1_12/src/main/java/io/github/zrdzn/minecraft/spigot/V1_12SpigotAdapter.java index 122ac48..ebb8e2c 100644 --- a/v1_12/src/main/java/io/github/zrdzn/minecraft/spigot/V1_12SpigotAdapter.java +++ b/v1_12/src/main/java/io/github/zrdzn/minecraft/spigot/V1_12SpigotAdapter.java @@ -2,6 +2,11 @@ public class V1_12SpigotAdapter implements SpigotAdapter { + @Override + public String getVersion() { + return "1.12"; + } + @Override public BlockBreakHelper getBlockBreakHelper() { return new V1_12BlockBreakHelper(); diff --git a/v1_13/src/main/java/io/github/zrdzn/minecraft/spigot/V1_13SpigotAdapter.java b/v1_13/src/main/java/io/github/zrdzn/minecraft/spigot/V1_13SpigotAdapter.java index 0f7dcd4..df94233 100644 --- a/v1_13/src/main/java/io/github/zrdzn/minecraft/spigot/V1_13SpigotAdapter.java +++ b/v1_13/src/main/java/io/github/zrdzn/minecraft/spigot/V1_13SpigotAdapter.java @@ -2,6 +2,11 @@ public class V1_13SpigotAdapter implements SpigotAdapter { + @Override + public String getVersion() { + return "1.13"; + } + @Override public BlockBreakHelper getBlockBreakHelper() { return new V1_12BlockBreakHelper(); diff --git a/v1_8/src/main/java/io/github/zrdzn/minecraft/spigot/V1_8SpigotAdapter.java b/v1_8/src/main/java/io/github/zrdzn/minecraft/spigot/V1_8SpigotAdapter.java index d8072f8..d647c65 100644 --- a/v1_8/src/main/java/io/github/zrdzn/minecraft/spigot/V1_8SpigotAdapter.java +++ b/v1_8/src/main/java/io/github/zrdzn/minecraft/spigot/V1_8SpigotAdapter.java @@ -2,6 +2,11 @@ public class V1_8SpigotAdapter implements SpigotAdapter { + @Override + public String getVersion() { + return "1.8"; + } + @Override public BlockBreakHelper getBlockBreakHelper() { return new V1_8BlockBreakHelper();