Solved Making items stick to Hotbar Help!

Discussion in 'Plugin Development' started by TECGaming360, Apr 26, 2014.

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

    TECGaming360

    I am trying to get my plugin to stick the item to the hotbar so a person cant move its spot, i already have it so players cant drop a the specified item? Any ideas?????
    Code:java
    1. @EventHandler
    2. public void onDropItem(PlayerDropItemEvent e) {
    3. Player player = e.getPlayer();
    4. if (e.getItemDrop().getItemStack().getType() == Material.COMPASS) {
    5. e.setCancelled(true);
    6. player.sendMessage(ChatColor.YELLOW + "[" + ChatColor.AQUA + "KeepthatItem" + ChatColor.YELLOW + "]" + ChatColor.RED + "You can not Drop this Item!");
    7. }
    8. }


    How should i add it, I'm kind of new to java codding need all the assistants possible :) thanks!
     
  2. Offline

    killerman747

    Code:
    @EventHandler
    public void PlayerInvClick(InventoryClickEvent event){
        Player player = event.getPlayer();
        if(event.getInventory().equals(player.getInventory())){
            event.seCancelled(true);
     
  3. Offline

    TECGaming360

    The method getPlayer() is undefined for the type InventoryClickEvent
     
  4. Offline

    killerman747

    TECGaming360
    Sorry my bad...
    Code:java
    1. Player player = (Player) event.getWhoClicked();
     
  5. Offline

    TECGaming360

    There got, thank you sooo much! :)
     
Thread Status:
Not open for further replies.

Share This Page