Minor Functionality Changes

- Modified SpecialRabbitsFoot
- Improved functionality of some code interactions
This commit is contained in:
Paldiu 2022-05-17 13:34:25 -05:00
parent 73e5be91eb
commit 10d7a4ed98
4 changed files with 15 additions and 27 deletions

View File

@ -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<UUID, PlayerConfig> 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;
}
}

View File

@ -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 + ']';
}
}

View File

@ -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()

View File

@ -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();
}