Sign GUI and Bukkit Inventories?

Discussion in 'Plugin Development' started by gabrielmaennl555, May 9, 2018.

Thread Status:
Not open for further replies.
  1. Hey everyone!
    So my first question is whenever we create an inventory, so let’s say we create an iventory for a player when they type a certain command. (bukkit.createInventory etc) What happens to those inventories once the players close them? Do they just delete? Or do they just keep creating mor which causes lag?

    Another question is how would I open a SIGN creation GUI? I am trying to make a plugin that allows a player to edit a sign in this form, thanks!
     
  2. Offline

    MightyOne

    Java itself has a garbage collector. if an object has no existing reference anymore it should be deleted pretty quickly. you also would not create any lag but rather use a lot of ram. thats a totally different thing
     
    Last edited: May 10, 2018
  3. Alright thanks! In that case how do you think I should go about fixing that?
     
  4. Offline

    MightyOne

    Well you can't do anything wrong. Just don't create 10000 inventories per second and everything will be handled fine.
     
  5. Offline

    DanielTheDev

    this will answer your last question. I wrote a simple class that edits sign, but it doesn't support coloured signs.

    I hope to have helped you sufficiently and if there any questions, I will help you :)

    Instructions: Shift click on any sign to edit.

    Code:

    Code:
        @EventHandler
        public void click_sign(PlayerInteractEvent e) {
            CraftBlock block = (CraftBlock) e.getClickedBlock();
            if(e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getPlayer().isSneaking() && block.getState() instanceof CraftSign) {
                CraftSign sign = (CraftSign) block.getState();
                openSignGui(e.getPlayer(), e.getClickedBlock());
            }
        }
     
        public void openSignGui(Player player, Block block) {
            EntityPlayer ep = ((CraftPlayer)player).getHandle();
            BlockPosition position = new BlockPosition(block.getX(), block.getY(), block.getZ());
            if((block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) && block.getState() instanceof CraftSign) {
                ((CraftSign) block.getState()).getTileEntity().isEditable = true;
                PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(position);
                ep.playerConnection.sendPacket(packet);
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page