[Manager needed] Quickbar Extension

Discussion in 'Archived: Plugin Requests' started by bergerkiller, Nov 3, 2012.

  1. Offline

    bergerkiller

    I wanted to test some stuff out so I wrote a small plugin. All it consists of is a Listener class with some logic. What the plugin does is, when you scroll using the mouse wheel and go to the far end of the quick bar, it will translate all the rows in the inventory one down. This allows extending the inventory quickbar from 9 to 36 items. This is mainly useful in creative where you otherwise have to switch between window panes all the time.

    Code:
    Code:
    package com.bergerkiller.bukkit.qe;
     
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerItemHeldEvent;
    import org.bukkit.inventory.ItemStack;
     
    public class QEListener implements Listener {
     
        @EventHandler(priority = EventPriority.LOWEST)
        public void onHeldItemChange(PlayerItemHeldEvent event) {
            boolean next = false;
            boolean previous = false;
            if (event.getPreviousSlot() == 0 && event.getNewSlot() == 8) {
                previous = true;
            } else if (event.getPreviousSlot() == 8 && event.getNewSlot() == 0) {
                next = true;
            }
            if (next || previous) {
                ItemStack[] items = event.getPlayer().getInventory().getContents();
                ItemStack[] newItems = new ItemStack[items.length];
                final int rowCount = 4;
                final int rowMask = 0x3;
                for (int row = 0; row < rowCount; row++) {
                    int newrow = row;
                    if (previous) {
                        newrow = (row - 1) & rowMask;
                    } else if (next) {
                        newrow = (row + 1) & rowMask;
                    }
                    for (int i = 0; i < 9; i++) {
                        newItems[newrow * 9 + i] = items[row * 9 + i];
                    }
                }
                event.getPlayer().getInventory().setContents(newItems);
            }
        }
    }
    
    I don't have time to manage this let alone manage another dev-bukkit page for it, so any takers willing to continue it/use it? No idea how useful people will find this though. :)

    Note: There is no need to put me down as an author, this would be your own plugin
     
    Hester likes this.
  2. Offline

    jacklin213

    Wrong section XD, but does this already have a plugin page ? or does one need to be made.
    Im willing to take this on , do u mind if its open sourced?
     
  3. Offline

    Njol

    The fact that he posted this here makes it open source ;) (though not neccessarily public domain)
     
  4. Offline

    jacklin213

    yeh but just wanted to know if he was alright with a open source on github
     
  5. Offline

    bergerkiller

    jacklin213
    I am all-right with anything. The point is, I can't publish it, and I noticed that none like it was found on dev-bukkit either. It's a plugin request as in: Someone make this into a proper plugin.
     
  6. Offline

    jacklin213

    oh sure ill do that for ya, ofc i need your permission first
     
  7. Offline

    bergerkiller

    jacklin213
    You have all permission to use the code I posted and make it into a plugin. You don't have to put my name on it, consider it your own. (no, seriously, writing that code took me < 2 minutes, it's yours...)
     
  8. Offline

    jacklin213

    TY ill look for a good use of it , another thing has this code been tested at all?
     
  9. Offline

    bergerkiller

    jacklin213
    Yes, I included it in another plugin for testing (registered the listener)
     
  10. Offline

    jacklin213

    Exams are over ill look for a use of it this weekend xD
     
  11. Offline

    jacklin213

  12. Offline

    bergerkiller

  13. Offline

    jacklin213

    Man thank your for the code, made me open my eyes to a new world XD.
    If I wanted to make a scroll icon for the quick bar I would need spout wouldn't I ?
     
  14. Offline

    bergerkiller

    jacklin213
    Well you can handle the WindowClickEvent in Bukkit to handle the clicking of an item. Then you could use certain item types for the icons. But yeah, if you want to add a new widget or want to use arrow keys, you will need to use Spout for that. Spout plugin has keyboard events you can use for this.
     
  15. Offline

    jacklin213

    Wait so even if i wanted to add arrow key movement i would need spout??
     
  16. Offline

    bergerkiller

    jacklin213
    Yes, because I don't think the minecraft client sends messages of keyboard input to the server. (Unless this was added in some version, of course)
     
  17. Offline

    jacklin213

    i think you can do it using an action of a event which requires keypress. ill look into it
     

Share This Page