Solved Best way to create an Inventory

Discussion in 'Plugin Development' started by AntonioC94, Apr 17, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    AntonioC94

    Hi there!
    So.. Im doing a plugin (1.15.2) and I need first to create an Inventory.
    The problem that I have is I have an error and Im not really sure about where is the documentation that I need to look.

    I have the error "Type mismatch: cannot convert from org.bukkit.inventory.Inventory to racesRPG.Inventory"
    when I create the inventory.

    This code works in 1.14 but not in 1.15, so ¿maybe is the version?

    Code:java
    1.  
    2. public class Inventory {
    3.  
    4. public void nuevoInventario(Player player) {
    5.  
    6. Inventory i = Bukkit.getServer().createInventory(null, 9, ChatColor.DARK_RED + "Test");
    7.  
    8. }
    9.  
    10. }
     
  2. Offline

    caderapee

    @AntonioC94

    Yes, dun't name ur class Inventory, or be care when u import
     
  3. Offline

    KarimAKL

    @AntonioC94 The class is called "Inventory", so unless you specify the package "org.bukkit.inventory.Inventory", it'll use your own "Inventory" class.

    Solution: Change your class name, or specify the package.
     
  4. Offline

    AntonioC94

    Thanks for answer! Yeah , the problem was so stupid .
    Just change the name of the class and be care with imports!
    Solved!
     
Thread Status:
Not open for further replies.

Share This Page