Solved Getting material from id

Discussion in 'Plugin Development' started by johnnyD, Jun 28, 2020.

  1. Offline

    johnnyD

    So I have looked online and also tried many different ways to get around my problem but none seem to work.
    Im trying to get a material from an id. Many posts online state Material.getMaterial should take an int value, but I guess thats on an outdated version since Material.getMaterial takes a string value now which is very unhelpful.

    Example:
    https://gyazo.com/9b78fe24e1ee0377552d7ba65efa076d
     
  2. Offline

    timtower Moderator Moderator

  3. Offline

    johnnyD

    I understand that its gross, but I dont see any other way. What I have now... Example : https://gyazo.com/bf0b2d03938519c8702677670a2b1c67

    Which basically takes the string value of line 1 on a sign, and checks if its a valid material, this only works with some materials. OAK_PLANKS for example comes through as null, so I thought using ID's would be more precise.

    @timtower
     
  4. Offline

    timtower Moderator Moderator

    @johnnyD What version are you building on?
    And if above 1.13: did you specify the API version?
    Have you tried printing the Material#name()

    Because those ID's are not even in the game anymore with the latest versions (as far as I know at least)
     
  5. Offline

    johnnyD

    So weird how all of a sudden it recognizes OAK_PLANKS even without any changes... Maybe a restarted server had something to do with it?
    @timtower
     
  6. Offline

    timtower Moderator Moderator

    @johnnyD Server doesn't magically updates a plugin, restart is required to load the new code again.
     
  7. Offline

    johnnyD

    @timtower I am aware... A reload does the job usually though
     
  8. Offline

    timtower Moderator Moderator

    There are some weird things with unloading there
     
  9. Offline

    johnnyD

    ??
     
  10. Offline

    timtower Moderator Moderator

    Server can't or won't fully unload everything, so it could have been using the old jar.
     

Share This Page