SaberLLC / Saber-Factions

The Ultimate Factions Plugin
GNU General Public License v3.0
120 stars 98 forks source link

Fix Crop Boost Upgrade #246

Closed Dakotaa closed 1 year ago

Dakotaa commented 1 year ago

This fixes the crop boost upgrade by making it more like one would expect based on the description. It now grows crops by an extra stage, rather than just setting them to fully grown instantly, and works for all ageable crops (wheat, beetroots, carrots, potatoes, netherwart, and cocoa)

Dakotaa commented 1 year ago

I don't exactly follow, do you mean make an Enum of all crop types (e.g. enum crops {WHEAT, BEETROOT, CARROTS, POTATOES, NETHER_WART, COCOA, SUGAR_CANE, CACTUS}, make an EnumSet from that, and then make the list of materials from that EnumSet? Or make two EnumSets (one for the ageable crops and one for sugarcane/cactus) from the Enum?

Dakotaa commented 1 year ago

Or something like this?

        if (cropMaterials == null) {
            EnumSet<XMaterial> ageableCrops = EnumSet.of(XMaterial.WHEAT, XMaterial.BEETROOTS, XMaterial.CARROTS, XMaterial.POTATOES, XMaterial.NETHER_WART, XMaterial.COCOA);
            for (XMaterial m : ageableCrops) {
                cropMaterials.add(m.parseMaterial());
            }
        }
Atilt commented 1 year ago

I don't exactly follow, do you mean make an Enum of all crop types (e.g. enum crops {WHEAT, BEETROOT, CARROTS, POTATOES, NETHER_WART, COCOA, SUGAR_CANE, CACTUS}, make an EnumSet from that, and then make the list of materials from that EnumSet? Or make two EnumSets (one for the ageable crops and one for sugarcane/cactus) from the Enum?

I meant using java.util.EnumSet in a similar way to:

private static final Set<Material> VALID_CROPS = EnumSet.of(
        XMaterial.WHEAT.parseMaterial(),
        XMaterial.BEETROOT.parseMaterial()
        ...
);