diff --git a/src/main/java/xyz/oribuin/fishing/fish/Fish.java b/src/main/java/xyz/oribuin/fishing/fish/Fish.java index b5ffff8..82d5592 100644 --- a/src/main/java/xyz/oribuin/fishing/fish/Fish.java +++ b/src/main/java/xyz/oribuin/fishing/fish/Fish.java @@ -60,20 +60,11 @@ public Fish(String name, String tier) { */ @Override public void loadSettings(@NotNull CommentedConfigurationSection config) { - String name = config.getString(this.name + "name"); - String tier = config.getString(this.name + "tier"); - - // Make sure the name is not null - if (this.name == null || this.tier == null) { - FishingPlugin.get().getLogger().warning("'name' is null for fish"); - return; - } - - // Load additional values from the config Fish fish = new Fish(name, tier); + System.out.println("Loading fish: " + name); // Catch Conditions - this.displayName = config.getString("display-name", name); + this.displayName = config.getString("display-name", StringUtils.capitalize(this.name)); this.description = config.getStringList("description"); this.modelData = config.getInt("model-data", -1); diff --git a/src/main/java/xyz/oribuin/fishing/listener/FishListener.java b/src/main/java/xyz/oribuin/fishing/listener/FishListener.java index 15b061d..3392425 100644 --- a/src/main/java/xyz/oribuin/fishing/listener/FishListener.java +++ b/src/main/java/xyz/oribuin/fishing/listener/FishListener.java @@ -9,8 +9,10 @@ import xyz.oribuin.fishing.FishingPlugin; import xyz.oribuin.fishing.fish.Fish; import xyz.oribuin.fishing.fish.Tier; +import xyz.oribuin.fishing.manager.DataManager; import xyz.oribuin.fishing.manager.FishManager; import xyz.oribuin.fishing.manager.LocaleManager; +import xyz.oribuin.fishing.storage.Fisher; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -43,29 +45,41 @@ public void onFish(PlayerFishEvent event) { // Add the fish into the player inventory double baseExpGained = event.getExpToDrop(); - AtomicReference newExp = new AtomicReference<>(0.0); - caught.forEach(fish -> { - if (fish == null) return; // shouldn't happen but just in case + double naturalExp = 0.0; + double newFishExp = 0.0; + int newEntropy = 0; + + for (Fish fish : caught) { + if (fish == null) continue; Tier tier = fish.tier(); - if (tier == null) return; // shouldn't happen but just in case + if (fish.tier() == null) continue; + + naturalExp += baseExpGained * tier.naturalExp(); + newFishExp += tier.fishExp(); + newEntropy += tier.entropy(); // Tell the player they caught a fish locale.sendMessage(event.getPlayer(), "fish-caught", StringPlaceholders.of("fish", fish.displayName())); - // gIve the fish to the player + // Give the fish to the player PlayerInventory inv = event.getPlayer().getInventory(); if (inv.firstEmpty() == -1) { event.getPlayer().getWorld().dropItem(event.getPlayer().getLocation(), fish.createItemStack()); - return; + continue; } inv.addItem(fish.createItemStack()); - newExp.set(newExp.get() + (baseExpGained * tier.naturalExp())); - }); + } // Apply more exp to the player - event.setExpToDrop(newExp.get().intValue()); + event.setExpToDrop((int) naturalExp); + + // TODO: Give the player entropy + // TODO: Give the player statistics + +// Fisher fisher = this.plugin.getManager(DataManager.class).get + } } diff --git a/src/main/java/xyz/oribuin/fishing/manager/FishManager.java b/src/main/java/xyz/oribuin/fishing/manager/FishManager.java index 42ae396..4ddcafe 100644 --- a/src/main/java/xyz/oribuin/fishing/manager/FishManager.java +++ b/src/main/java/xyz/oribuin/fishing/manager/FishManager.java @@ -98,7 +98,6 @@ public List tryCatch(Player player, ItemStack rod, FishHook hook) { List result = new ArrayList<>(); Map augments = AugmentManager.getAugments(rod); - // TODO: Check for augments on the fishing rod InitialFishCatchEvent event = new InitialFishCatchEvent(player, rod, hook); event.callEvent();