Oheers / EvenMoreFish

An advanced fishing plugin based on MoreFish, created 2 years after its last update.
MIT License
91 stars 55 forks source link

Fish with ItemsAdder id in raw-material does not return an item #195

Closed katiebosch closed 6 months ago

katiebosch commented 1 year ago

There is a check in the checkRawMaterial method that attempts to get the material from the Bukkit API based on the material name. This check will always return false because the ItemsAdder item value is not a vanilla value. This is preventing me from getting a fish if it has a raw-material with an ItemsAdder item populated.

katiebosch commented 1 year ago

I rewrote the method in the project's style, but I do not have write access. Here's the code, hopefully all you need to do is copy and paste:

    private ItemStack checkRawMaterial() {
        String materialID = this.configurationFile.getString(configLocation + ".item.raw-material");

        Material material;
        if (materialID == null) {
            return null;
        }

        rawMaterial = true;

        ItemStack stack;
        if ((stack = getItemsAdderStack(materialID)) != null) {
            return stack;
        }

        if ((material = Material.getMaterial(materialID.toUpperCase())) == null) {
            EvenMoreFish.logger.severe(() -> String.format("%s has an incorrect assigned material: %s",
                                                           configLocation,
                                                           materialID));
            material = Material.COD;
        }
        return new ItemStack(material);
    }
katiebosch commented 1 year ago

Just a note, I compiled and tested the above on my server and it did not fix the issue. I'll see if I have time tomorrow to set something up locally so I can debug ☝️

sarhatabaot commented 1 year ago

I rewrote the method in the project's style, but I do not have write access. Here's the code, hopefully all you need to do is copy and paste:

    private ItemStack checkRawMaterial() {
        String materialID = this.configurationFile.getString(configLocation + ".item.raw-material");

        Material material;
        if (materialID == null) {
            return null;
        }

        rawMaterial = true;

        ItemStack stack;
        if ((stack = getItemsAdderStack(materialID)) != null) {
            return stack;
        }

        if ((material = Material.getMaterial(materialID.toUpperCase())) == null) {
            EvenMoreFish.logger.severe(() -> String.format("%s has an incorrect assigned material: %s",
                                                           configLocation,
                                                           materialID));
            material = Material.COD;
        }
        return new ItemStack(material);
    }

Please create a fork and submit a pr :)

Oheers commented 1 year ago

Apologies I've only just seen this - as sarhatabaot said the best way is to create a pull request, then you get credit on GitHub for your work too, if you need help just reply and I'm more than happy to assist 👍

katiebosch commented 1 year ago

Sorry I had made a fork but forgot to open the PR :) I tested this in a local server and it works. https://github.com/Oheers/EvenMoreFish/pull/198

Oheers commented 1 year ago

Cheers for that, I've just merged your PR now.

sarhatabaot commented 6 months ago

Closed via #198