From 10d7a4ed98b03c4c1fa6f375d6114db14244716e Mon Sep 17 00:00:00 2001 From: Paldiu Date: Tue, 17 May 2022 13:34:25 -0500 Subject: [PATCH] Minor Functionality Changes - Modified SpecialRabbitsFoot - Improved functionality of some code interactions --- .../io/github/simplex/luck/FeelingLucky.java | 6 ++++ .../simplex/luck/listener/PlayerListener.java | 28 +++---------------- .../luck/listener/VillagerInventory.java | 6 ++-- .../simplex/luck/util/SpecialFootItem.java | 2 +- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/main/java/io/github/simplex/luck/FeelingLucky.java b/src/main/java/io/github/simplex/luck/FeelingLucky.java index 5e950d4..afea16e 100644 --- a/src/main/java/io/github/simplex/luck/FeelingLucky.java +++ b/src/main/java/io/github/simplex/luck/FeelingLucky.java @@ -5,6 +5,7 @@ import io.github.simplex.luck.player.PlayerConfig; import io.github.simplex.luck.player.PlayerHandler; import io.github.simplex.luck.util.LuckCMD; import io.github.simplex.luck.util.SneakyWorker; +import io.github.simplex.luck.util.SpecialFootItem; import io.github.simplex.metrics.Metrics; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; @@ -19,6 +20,7 @@ import java.util.UUID; public final class FeelingLucky extends JavaPlugin { private final Map configMap = new HashMap<>(); private final File playerDirectory = new File(getDataFolder(), "players"); + private final SpecialFootItem specialFootItem = new SpecialFootItem(); private PlayerHandler handler; private Config config; @@ -97,4 +99,8 @@ public final class FeelingLucky extends JavaPlugin { public Config getConfig() { return config; } + + public SpecialFootItem getFoot() { + return specialFootItem; + } } diff --git a/src/main/java/io/github/simplex/luck/listener/PlayerListener.java b/src/main/java/io/github/simplex/luck/listener/PlayerListener.java index fd9b4e1..0a6a751 100644 --- a/src/main/java/io/github/simplex/luck/listener/PlayerListener.java +++ b/src/main/java/io/github/simplex/luck/listener/PlayerListener.java @@ -31,7 +31,7 @@ public final class PlayerListener extends AbstractListener { public void rabbitFoot(PlayerInteractEvent event) { Action action = event.getAction(); ItemStack foot = new ItemStack(Material.RABBIT_FOOT); - SpecialFootItem special = new SpecialFootItem(); + SpecialFootItem special = plugin.getFoot(); Player player = event.getPlayer(); Luck luck = getHandler().getLuckContainer(player); @@ -41,10 +41,10 @@ public final class PlayerListener extends AbstractListener { return; } - if (action.isRightClick() && player.getInventory().getItemInMainHand().isSimilar(foot)) { + if (action.isRightClick() && player.getInventory().getItemInMainHand().getType().equals(foot.getType())) { if (foot.getItemMeta().equals(special.meta()) || foot.equals(special.get())) { - luck.setMultiplier(luck.multiplier() + 1); - player.sendMessage(MiniComponent.info("Your luck multiplier has increased by 1!")); + luck.setMultiplier(luck.multiplier() + 0.1); + player.sendMessage(MiniComponent.info("Your luck multiplier has increased by 0.1!")); } double rng = Luck.RNG().nextDouble(2.0, 5.0); player.getInventory().remove(player.getInventory().getItemInMainHand()); @@ -78,24 +78,4 @@ public final class PlayerListener extends AbstractListener { } } } - - @Override - public boolean equals(Object obj) { - if (obj == this) return true; - if (obj == null || obj.getClass() != this.getClass()) return false; - var that = (PlayerListener) obj; - return Objects.equals(this.plugin, that.plugin); - } - - @Override - public int hashCode() { - return Objects.hash(plugin); - } - - @Override - public String toString() { - return "PlayerListener[" + - "plugin=" + plugin + ']'; - } - } diff --git a/src/main/java/io/github/simplex/luck/listener/VillagerInventory.java b/src/main/java/io/github/simplex/luck/listener/VillagerInventory.java index b2dc5ae..eb3a12d 100644 --- a/src/main/java/io/github/simplex/luck/listener/VillagerInventory.java +++ b/src/main/java/io/github/simplex/luck/listener/VillagerInventory.java @@ -15,12 +15,14 @@ import java.util.Arrays; import java.util.List; public class VillagerInventory extends AbstractListener { - private final SpecialFootItem foot = new SpecialFootItem(); - private final MerchantRecipe recipe = new MerchantRecipe(foot.get(), 0, 2, true); + private final MerchantRecipe recipe; public VillagerInventory(FeelingLucky plugin) { super(plugin); + SpecialFootItem foot = plugin.getFoot(); + this.recipe = new MerchantRecipe(foot.get(), 0, 2, true); + recipe.setIngredients(Arrays.asList( ItemBuilder.of(Material.EMERALD).build(), ItemBuilder.of(Material.RABBIT_HIDE).build() diff --git a/src/main/java/io/github/simplex/luck/util/SpecialFootItem.java b/src/main/java/io/github/simplex/luck/util/SpecialFootItem.java index 4f220bf..45e5791 100644 --- a/src/main/java/io/github/simplex/luck/util/SpecialFootItem.java +++ b/src/main/java/io/github/simplex/luck/util/SpecialFootItem.java @@ -12,7 +12,7 @@ public class SpecialFootItem { stack = ItemBuilder.of(Material.RABBIT_FOOT) .setName("Enhanced Rabbit Foot") .setAmount(1).setLore("A strange energy radiates from within.", - "This item will increase your luck multiplier by one.") + "This item will increase your luck multiplier by 0.1.") .build(); }