Bukkit error or just us?

Discussion in 'Plugin Development' started by kreashenz, Oct 12, 2013.

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

    kreashenz

    stuntguy3000
    Well, ^ and I were working on a plugin and it involves creating a custom inventory and stuff, but one thing got us. When we right click the BOTTOM row of piston heads, we get kicked for "Internal Server Error". I've gotten the stacktrace, which has nothing to do with our plugin, but instead with Bukkit (stacktrace). I don't know how to fix this but if it does involve our code, this is really all we're doing to the piston heads.
    Code:java
    1. ItemStack close = new ItemStack(Material.PISTON_MOVING_PIECE, 1);
    2.  
    3. ItemMeta im = close.getItemMeta();
    4. im.setDisplayName(plugin.colourize("Close"));
    5. close.setItemMeta(im);
    6. for(int i = 0; i <= 8; i++)
    7. shop.setItem(i, close);
    8.  
    9. for(int i = 45; i <= 53; i++)
    10. shop.setItem(i, close);

    If you don't REALLY understand what I mean by the bottom row of piston heads:
    [​IMG]
    Hopefully if anyone knows that the hell is going on, please comment..
     
  2. Offline

    geNAZt

    Well how do you create the Custom Inventory and its View ?
     
  3. Offline

    Syd

    kreashenz
    The stuff above and do you handle Inventory Clicks in some ways? (If yes: how)
     
  4. kreashenz its an error on your side. It tells you that the inventory is 45 slots big, and you try to get the 51th in the inventory. But for the rest I don't know what is wrong with it
     
  5. Offline

    geNAZt

    Datdenkikniet if this would be so, he wouldnt be able to set the 45th+ slot. It would crash by sending the packets to the client or the client would crash.

    But he can create a valid Inventory Container with such much slots. He can send it, he can view it in the Client. But if the Client sends data back which does not fit in a normal Container. The Minecraft Server kicks you because you have send an "invalid" Slot.

    I think this is a minecraft Bug. I think it should be supported to make more inventories if you need some :D
     
  6. Offline

    kreashenz

    geNAZt Syd Datdenkikniet
    I have this code to open the inventory
    Code:java
    1. public void openShop(Block b, Type t, Player p) {
    2. if (t == Type.Buy) {
    3. ItemStack close = new ItemStack(Material.PISTON_MOVING_PIECE, 1);
    4.  
    5. ItemMeta im = close.getItemMeta();
    6. im.setDisplayName(plugin.colourize("Close"));
    7. close.setItemMeta(im);
    8. // ItemStack adding stuff
    9. // setting item names, lores.
    10. Inventory shop = Bukkit.createInventory(p, 54, plugin.colourize("&6Shop &7- &6Buy"));
    11. for(int i = 0; i <= 8; i++)
    12. shop.setItem(i, close);
    13.  
    14. for(int i = 45; i <= 53; i++) shop.setItem(i, close);
    15. shop.setItem(9, close);
    16. shop.setItem(17, close);
    17. shop.setItem(18, close);
    18. shop.setItem(26, close);
    19. shop.setItem(27, close);
    20. shop.setItem(35, close);
    21. shop.setItem(36, close);
    22. shop.setItem(44, close);
    23. p.openInventory(shop);


    And this code while I'm clicking through the inventory (InventoryClickEvent)
    Code:java
    1. @EventHandler
    2. public void shopClickInv(InventoryClickEvent event) {
    3. if(event.getWhoClicked() instanceof Player){
    4. Player p = (Player) event.getWhoClicked();
    5. ItemStack item = event.getInventory().getItem(event.getSlot());
    6. int s = event.getSlot();
    7. if (event.getInventory().getName().contains("Buy")) {
    8. event.setCancelled(true);
    9. p.closeInventory();
    10. }
    11. }
    12. }
     
  7. Offline

    geNAZt

    Well i think this is a Minecraft bug
     
  8. Offline

    Syd

    kreashenz
    It doesn't looks like that there is anything in your code, that could cause this error.
    I've looked in the CB/NMS Code, but I didn't find the error either.

    I would agree with geNAZt, that it's more likely a MC/CB error, but I might be wrong.
     
  9. Offline

    deathknife

    @kreashenz
    I have tried what you are doing and it doesn't crash on me.

    Event:
    Code:java
    1. @EventHandler
    2. public void shopClickInv(InventoryClickEvent event) {
    3. if(event.getWhoClicked() instanceof Player){
    4. Player p = (Player) event.getWhoClicked();
    5. ItemStack item = event.getInventory().getItem(event.getSlot());
    6. int s = event.getSlot();
    7. if (event.getInventory().getName().contains("Buy")) {
    8. event.setCancelled(true);
    9. p.closeInventory();
    10. }
    11. }
    12. }


    Inventory:

    Code:java
    1. public void openShop(Player p) {
    2. ItemStack close = new ItemStack(Material.PISTON_MOVING_PIECE, 1);
    3.  
    4. ItemMeta im = close.getItemMeta();
    5. im.setDisplayName("Close");
    6. close.setItemMeta(im);
    7. // ItemStack adding stuff
    8. // setting item names, lores.
    9. Inventory shop = Bukkit.createInventory(p, 54, "&6Shop &7- &6Buy");
    10. for(int i = 0; i <= 8; i++)
    11. shop.setItem(i, close);
    12.  
    13. for(int i = 45; i <= 53; i++) shop.setItem(i, close);
    14. shop.setItem(9, close);
    15. shop.setItem(17, close);
    16. shop.setItem(18, close);
    17. shop.setItem(26, close);
    18. shop.setItem(27, close);
    19. shop.setItem(35, close);
    20. shop.setItem(36, close);
    21. shop.setItem(44, close);
    22. p.openInventory(shop);
    23. }

    It seems to work fine here. Closes the inventory and doesn't crash the client.

    Would you be able to provide ' plugin.colourize' please?
     
  10. Offline

    caelum19

    An inventory shop? I like the idea. mind if I use it for a zombie-survival-like plugin? :3

    It looks like a bukkit/mc bug to me... I'll look into it a lil' further because I'm strangely interested By the way, you may want to disclude your IP address from the log.
     
  11. Offline

    Janmm14

    kreashenz
    try to update to latest craftbukkit, test it, and if it fails, try the version before and so on. so its easy to see which code additions made the error if there is one in latest craftbukkit
     
    caelum19 likes this.
  12. Offline

    stuntguy3000

    I will do that,


    Would you be able to provide ' plugin.colourize' please?
    That just is a method that uses ChatColor.translate.. and returns the colourized string. I will test locally.

    I am not sure it was highlighted, but this only happens when right clicking the items on the bottom row. This happens with every item (including air).

    Just updated to newest build (dev), still bugged. Same error. eek

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  13. Offline

    deathknife

    Ahh, I get the same error when right clicking. Seems like Bukkit error.
     
  14. Offline

    stuntguy3000

    I am going to file a bukkit report. I think something has broken internally.
     
  15. Offline

    deathknife

    After doing some tests, the line:
    p.closeInventory();
    causes that.
    You can do
    Code:
    if(s < 45 || event.isLeftClick())
                  p.closeInventory();
    But this won't close the inventory if the client right clicks the button row, but will avoid erroring.

    Also, it only seems to happen with inventories that have 54 or more slots.
     
  16. Offline

    stuntguy3000

  17. Did you try to use getView().close() instead of closeInventory(). I'm not sure but a have something in mind, that it is a bad idea to force close an inventory when there is currently an event handled on it.
     
Thread Status:
Not open for further replies.

Share This Page