[HELP] Stop drop certain item

Discussion in 'Plugin Development' started by Swakiny, Sep 1, 2012.

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

    Swakiny

    [​IMG]


    I have error, in verify item id, because if i remove "itemid == 276" not drop any item, but i need not drop certain item id
     
  2. Offline

    Developher

    Try
    Code:
    if(e.getType == Material.<?> && player.hasPermission("")) {
    e.setCancelled(true);
    } 
    
     
  3. Offline

    Swakiny


    Developher

    what is "e" ?

    any ppl help me plz =/

    plz

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

    Developher

    Sorry, e == event, so with your situation it would be

    Swakiny

    Code:
    if(event.getType == Material.<?> && player.hasPermission("")) {
    e.setCancelled(true);
    }
    
    e == what you specify in the method I.E
    Code:
    public void methodName(PlayerDropItemEvent <name(event)>) {
    }
    
    You need to specify 'player' in player.hasPermission, so reference it as
    Code:
    Player player = event.getPlayer();
    
     
    Swakiny likes this.
  5. Offline

    Swakiny

    Sure, but not working, the plugin don't compare if droped item id is 276(Diamond_Sword),

    event.getType == Material.DIAMOND_SWORD

    =/
     
  6. Offline

    Deleted user

    Code:
    @EventHandler
    public void onPlayerDropItem(PlayerDropItemEvent event) {
    Player p = event.getPlayer();
     
    if (event.getItemDrop().getItemStack().getType() == Material.DIAMOND_SWORD) {
    event.setCancelled(true);
    p.sendMessage( "You can't do this.");
    }
    }
    }
    
     
    Swakiny likes this.
  7. Offline

    Swakiny

    THANK U, <3 -q

    Ok working, but with permissions, not work

    Eballer48

    @EventHandler
    public void onPlayerDropItem(PlayerDropItemEvent event) {
    Player p = event.getPlayer();
    Material item2 = event.getItemDrop().getItemStack().getType();

    if (item2 == Material.DIAMOND_SWORD && item2 == Material.DIAMOND_BOOTS && item2 == Material.DIAMOND_CHESTPLATE && item2 == Material.DIAMOND_HELMET && item2 == Material.DIAMOND_LEGGINGS && item2 == Material.EXP_BOTTLE) {
    if(!p.hasPermission("vipswakiny.drop")){
    event.setCancelled(true);
    p.sendMessage(ChatColor.DARK_RED + "[VIP]" + ChatColor.GOLD + "Tipo de item proibido.");
    }
    }
    }
    }

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  8. Offline

    Deleted user

    Okay so
    Code:
    &&
    
    Literally means AND so your basically saying the player has to drop all those items at once! :p Now this:

    Code:
    ||
    
    Hold shit and click the \ button it's to the left of your ] means 'or' in java speak so this:

    Code:
    @EventHandler
    public void onPlayerDropItem2(PlayerDropItemEvent event) {
    Player p = event.getPlayer();
    Material item2 = event.getItemDrop().getItemStack().getType();
     
    if (item2 == Material.DIAMOND_SWORD || item2 == Material.DIAMOND_BOOTS || item2 == Material.DIAMOND_CHESTPLATE || item2 == Material.DIAMOND_HELMET || item2 == Material.DIAMOND_LEGGINGS || item2 == Material.EXP_BOTTLE) {
    if (!p.hasPermission("vipswakiny.drop")) {
    event.setCancelled(true);
    p.sendMessage(ChatColor.DARK_RED + "[VIP]" + ChatColor.GOLD + "Tipo de item proibido.");
    }
    }
    }
    
    Note: Pleased you understand how to use '!'

    Also next time type
    Code:
    [code]
    
    before your code and
    [/code] after it!
     
    Swakiny likes this.
  9. Offline

    Swakiny

    Thank u again <3
     
Thread Status:
Not open for further replies.

Share This Page