Discussion in 'Spigot Plugin Development' started by Pyronucleic, Feb 20, 2020.

  1. I have an XML file being parsed using the SAX method.

    One of the values parsed for is a material, and for testing sake I set it to golden sword. This is the specific chunk of code parsing my information:
    Code (Text):

    public void endElement(String uri, String localName, String qName) throws SAXException {
        if (bSharp) {
            stat.setSharpness((byte) Integer.parseInt(data.toString()));
            bSharp = false;
        } else if (bWeight) {
            stat.setWeight((byte) Integer.parseInt(data.toString()));
            bWeight = false;
        }else if (bAero) {
            stat.setAerodynamics((byte) Integer.parseInt(data.toString()));
            bAero = false;
        }else if (bLore) {
            bLore = false;
        }else if (bRarity) {
            bRarity = false;
        }else if (bMaterial) {

            //TODO: For some reason it thinks GOLDEN_SWORD is LEGACY_GOLDEN_SWORD, find why it's changing that.
            bMaterial = false;
    Code (Text):

    [00:05:33 INFO]: 1
    [00:05:33 INFO]: 1
    [00:05:33 INFO]: 1
    [00:05:33 INFO]: A stick
    [00:05:33 INFO]: COMMON
    [00:05:33 INFO]: STICK
    [00:05:33 INFO]: STICK
    [00:05:33 INFO]: 5
    [00:05:33 INFO]: 10
    [00:05:33 INFO]: 3
    [00:05:33 INFO]: A pretty nice looking sword.
    [00:05:33 INFO]: RARE
    [00:05:33 INFO]: GOLDEN_SWORD
    [00:05:33 ERROR]: Error occurred while enabling GravityCraftCore v0.02 (Is it up to date?)
    java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.LEGACY_GOLDEN_SWORD
        at java.lang.Enum.valueOf(Unknown Source) ~[?:1.8.0_211]
        at org.bukkit.Material.valueOf( ~[spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.util.CraftLegacy.valueOf( ~[spigot.jar:git-Spigot-800b93f-8160e29]
        at io.pyronucleic.gravitycore.xml.ItemXMLHandler.endElement( ~[?:?]
        at Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at$ Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at$JAXPSAXParser.parse(Unknown Source) ~[?:1.8.0_211]
        at Source) ~[?:1.8.0_211]
        at javax.xml.parsers.SAXParser.parse(Unknown Source) ~[?:1.8.0_211]
        at io.pyronucleic.gravitycore.xml.ItemXMLParser.parseXMLItems( ~[?:?]
        at io.pyronucleic.gravitycore.main.Main.onEnable( ~[?:?]
        at ~[spigot.jar:git-Spigot-800b93f-8160e29]
        at [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin( [spigot.jar:git-Spigot-800b93f-8160e29]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins( [spigot.jar:git-Spigot-800b93f-8160e29]
        at net.minecraft.server.v1_15_R1.MinecraftServer.a( [spigot.jar:git-Spigot-800b93f-8160e29]
        at net.minecraft.server.v1_15_R1.DedicatedServer.init( [spigot.jar:git-Spigot-800b93f-8160e29]
        at [spigot.jar:git-Spigot-800b93f-8160e29]
        at Source) [?:1.8.0_211]
    It also repeats that specific task twice, which I'll need to figure out. But for now there is a potential issue with parsing that must be solved.

    I shows the previous parsed object to show that for materials without legacy duplicates do not have this issue.

    SOLVED: Some looking around found out that I'm supposed to include the API version in plugin.yml. Hadnt coded in spigot for some time and didn't check whats new
    #1 Pyronucleic, Feb 20, 2020
    Last edited: Feb 20, 2020