diff --git a/src/main/java/xyz/oribuin/fishing/api/gui/GuiItem.java b/src/main/java/xyz/oribuin/fishing/api/gui/GuiItem.java index b2aebeb..151ab76 100644 --- a/src/main/java/xyz/oribuin/fishing/api/gui/GuiItem.java +++ b/src/main/java/xyz/oribuin/fishing/api/gui/GuiItem.java @@ -4,6 +4,7 @@ import dev.rosewood.rosegarden.utils.StringPlaceholders; import dev.triumphteam.gui.components.GuiAction; import dev.triumphteam.gui.guis.BaseGui; +import org.bukkit.Material; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -18,7 +19,7 @@ public class GuiItem implements Configurable { protected boolean enabled = true; protected String name = "item"; protected List slot = List.of(0); - protected ItemConstruct item = ItemConstruct.EMPTY; + protected ItemConstruct item = ItemConstruct.of(Material.STONE).tooltip(false); public GuiItem() { } diff --git a/src/main/java/xyz/oribuin/fishing/fish/Tier.java b/src/main/java/xyz/oribuin/fishing/fish/Tier.java index a6c2d3d..e8bc6d5 100644 --- a/src/main/java/xyz/oribuin/fishing/fish/Tier.java +++ b/src/main/java/xyz/oribuin/fishing/fish/Tier.java @@ -3,6 +3,7 @@ import dev.rosewood.rosegarden.config.CommentedConfigurationSection; import dev.rosewood.rosegarden.config.CommentedFileConfiguration; import dev.rosewood.rosegarden.utils.StringPlaceholders; +import org.bukkit.Material; import org.jetbrains.annotations.NotNull; import org.w3c.dom.stylesheets.LinkStyle; import xyz.oribuin.fishing.FishingPlugin; @@ -43,33 +44,12 @@ public Tier(String name) { Objects.requireNonNull(name, "Quality name cannot be null."); this.name = name; - this.baseDisplay = ItemConstruct.EMPTY; + this.baseDisplay = ItemConstruct.of(Material.COD); this.tierFile = FishUtils.createFile(FishingPlugin.get(), "tiers", name + ".yml"); this.config = CommentedFileConfiguration.loadConfiguration(this.tierFile); this.fish = new HashMap<>(); } - /** - * Create a new quality name for a fish, Does not create a new file for the quality - * - * @param name The name of the quality - * @param tierFile The file where the relational data is stored - */ - public Tier(String name, File tierFile) { - Objects.requireNonNull(name, "Quality name cannot be null."); - - this.name = name; - this.money = 0.0; - this.chance = 0.0; - this.entropy = 0; - this.fishExp = 0; - this.naturalExp = 0.0f; - this.baseDisplay = ItemConstruct.EMPTY; - this.tierFile = tierFile; - this.config = CommentedFileConfiguration.loadConfiguration(this.tierFile); - this.fish = new HashMap<>(); - } - /** * Load the settings from the configuration file * I would recommend always super calling this method to save any settings that could be implemented @@ -81,7 +61,7 @@ public void loadSettings(@NotNull CommentedConfigurationSection config) { this.money = config.getDouble("money", 0.0); this.chance = config.getDouble("chance", 0.0); this.entropy = config.getInt("entropy", 0); - this.baseDisplay = ItemConstruct.EMPTY; + this.baseDisplay = ItemConstruct.of(Material.STONE); this.baseDisplay.loadSettings(this.pullSection(config, "display-item")); this.fishExp = config.getInt("fish-exp", 0); @@ -191,7 +171,7 @@ public ItemConstruct baseDisplay() { } public void baseDisplay(ItemConstruct baseDisplay) { - this.baseDisplay = baseDisplay != null ? baseDisplay : ItemConstruct.EMPTY; + this.baseDisplay = baseDisplay != null ? baseDisplay : ItemConstruct.of(Material.COD); } public int fishExp() { diff --git a/src/main/java/xyz/oribuin/fishing/listener/FishListener.java b/src/main/java/xyz/oribuin/fishing/listener/FishListener.java index f9d77a3..daf023c 100644 --- a/src/main/java/xyz/oribuin/fishing/listener/FishListener.java +++ b/src/main/java/xyz/oribuin/fishing/listener/FishListener.java @@ -60,14 +60,16 @@ public void onFish(PlayerFishEvent event) { event.getPlayer().sendMessage("You caught a " + fish.displayName() + "!"); // TODO: Replace with locale message // locale.sendMessage(event.getPlayer(), "fish-caught", StringPlaceholders.of("fish", fish.displayName())); + ItemStack resultItem = fish.createItemStack(); + // Give the fish to the player PlayerInventory inv = event.getPlayer().getInventory(); if (inv.firstEmpty() == -1) { - event.getPlayer().getWorld().dropItem(event.getPlayer().getLocation(), fish.createItemStack()); + event.getPlayer().getWorld().dropItem(event.getPlayer().getLocation(), resultItem); continue; } - inv.addItem(fish.createItemStack()); + inv.addItem(resultItem); } Fisher fisher = this.plugin.getManager(DataManager.class).get(event.getPlayer().getUniqueId()); diff --git a/src/main/java/xyz/oribuin/fishing/util/ItemConstruct.java b/src/main/java/xyz/oribuin/fishing/util/ItemConstruct.java index 0b16bd6..c3ea9e8 100644 --- a/src/main/java/xyz/oribuin/fishing/util/ItemConstruct.java +++ b/src/main/java/xyz/oribuin/fishing/util/ItemConstruct.java @@ -27,8 +27,6 @@ @SuppressWarnings({ "unused", "FieldMayBeFinal" }) public class ItemConstruct implements Configurable { - public static ItemConstruct EMPTY = ItemConstruct.of(Material.STONE); // Empty itemstack - private Material type; private Integer amount; private String name;