Setting MapView to ItemStack 1.14

Discussion in 'Plugin Development' started by The_Spaceman, May 4, 2019.

  1. Offline

    The_Spaceman

    In Bukkit 1.13 you use:
    Code:java
    1. short mapID = mapView.getId();
    2. is.setDurability(mapID);


    in Bukkit 1.14 the ID is now a Integer, and the setDurability wont accept an Integer...

    Is there a new way to set the mapView to an ItemStack?

    Thanks
     
  2. @The_Spaceman
    Try getting the ID first as an int, and then cast it back as a short. This will mean that for 1.13 and lower, the short will be converted to an int and then back to a short, while in 1.14, the int will be first taken as an int, and then converted to a short.
     
  3. Offline

    The_Spaceman

    Thank you.

    When checking other plugins I came across another change, how do I get the inventory title, the getTitle does not exist anymore...
     
  4. Offline

    KarimAKL

    @The_Spaceman Haven't tried 1.14 yet but does 'getName' exist?
     
  5. Offline

    The_Spaceman

    nope, nothing starting with 'get' returns a String
     
  6. Offline

    KarimAKL

    @The_Spaceman Just checked and it seems you have to do 'event.getView().getTitle()', event being an instance of 'InventoryEvent' and 'getView()' returning an 'InventoryView'.
    I can't seem to find a way to get the name without an event.
     
    The_Spaceman likes this.
  7. Offline

    The_Spaceman

    for now it works, but still I think its stupid you can't get the title of an inventory object...
    but you can get it fro the InventoryView
     
  8. Offline

    KarimAKL

    @The_Spaceman That's because the inventory and the inventory view is two different things, the inventory is the collection of slots with items (or 'null' for no item) and the view is the link between the player and the inventory.
    At least from what i understood.
    Note: This is my attempt at a quick explanation.
     
  9. Offline

    The_Spaceman

    it works for now (for private use only), but when the inventory is for example a horse you will get an error that the title does not have a title... and there is no way to check if the view has a title...

    there clearly has to be another way that works no matter what. And I think that e.getCursor() and e.getItem() returns null (in stead of Material.AIR, like in previous versions) when clicking on an empty slot/outside of the inventory...
     
  10. Offline

    KarimAKL

    Pretty sure an ItemStack has always returned null if you click an empty slot in a inventory. (or at least for a long time)
     

Share This Page