Coming back to spigot, difficulties with Materials

Discussion in 'Spigot Plugin Development' started by EmbryoGod, Nov 3, 2019.

  1. So I recently came back to spigot development after stopping sometime around like 1.10-1.11 ish. There's a little plugin I typically do to try and learn about any new changes in the API, and the differences are so substantial that I don't even know where to begin to look and would appreciate some help.

    Basically what I'm doing is building a little dummy farming plugin, something that requires you to use a hoe to break a block. What I used to do was just check for Material.CROPS and go on my merry way, but that doesn't work anymore. Even when I attempt to use Material.LEGACY_CROPS, the server will complain that I need to specify 1.13 as my API instead of 1.14.

    That was an easy enough solution, just use BlockData instead and parse it out to get the age and material (minecraft:wheat, etc. etc.). But now it comes time to trying to generate drops from what I've done. I can't make an ItemStack with ItemStack(Material mat, int amount) anymore, because no matter which material I use, legacy or not, the server won't load up the plugin.

    To provide an example:

    org.bukkit.plugin.AuthorNagException: No legacy enum constant for WHEAT_SEEDS. Did you forget to define api-version: 1.13 in your plugin.yml?

    I get the same error if I switch it to Material.LEGACY_SEEDS. I don't mind the old way of doing things being changed, but I don't even know where to begin to try and set up drops at this point. I can't make an ItemStack using Material anymore. Should I try to create BlockData for the seed item? Would that even work because it's technically an item not even a block?

    Any advice would be appreciated, thanks.
     
  2. It's telling you what is the problem, add this to your plugin.yml
    Code (YAML):
    api-version: 1.13
     
    • Agree Agree x 1
  3. I want this code to work without any potential issues with calls being removed in later updates. I understand I could just use the older API, but wouldn't that potentially cause conflicts in the future if those Enum constants were removed?
     
  4. If you don't plan on supporting < 1.13 then don't use the legacy enums.
     
  5. That's precisely why I was trying to figure out how to set up the ItemStack without having to directly use the Material enums. Under the deprecated list from Spigot's documentation, it says to use BlockData instead of Material and MaterialData. I want to use the 1.14 specific API without using any deprecated Classes, Enums, or Methods
     
  6. If you put api-version: 1.13 (or 1.14) in your plugin.yml, and do new ItemStack(Material.WHEAT_SEEDS, 7), it should work. BlockData is used in modifying blocks, not items.