kit per life probem!

Discussion in 'Plugin Development' started by mihalaras11, Jun 25, 2015.

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

    mihalaras11

    hey there i am working on a kit plugin and i have a problem i want my player to get a kit per life in the begining of my main class i have created an array list caled kits
    Code:
    ArrayList<String> kits = new ArrayList<String>();
    on each kit i check if the player is the list if yes i send them a message
    Code:
    if(kits.contains(player.getName())){
                player.sendMessage("§cYou can only use one kit per life");
                return false;
            }
    and in the end of the kit i add them to the list
    Code:
    kits.add(player.getName());
    now in the botton of the main class i have created an event onplayer death to remove the player from the list so they can get again a kit again
    Code:
    @EventHandler
    
    public void onPlayerDeath(PlayerDeathEvent e){
        Player player = (Player)e.getEntity();
    if(kits.contains(player.getName())){
    kits.remove(player.getName());
    }

    when i test it when i use a kit i cant get another but when i die it doesnt remove me from the list...

    also is it possible to remove a certain item from my player inventory

    for examble i want when he uses /reffil to remove all his bowls and soups and then give him new soups

    thanks
     
  2. Offline

    CraftBang

    Did you register the listener class?

    Yes you can remove items from players inventory.
    Loop through the inventory, check if the item is a bowl and replace it with a Bowl with soup
     
    mihalaras11 likes this.
  3. Offline

    mihalaras11

    and what is the replace command?
    the first worked fine :p
     
  4. @mihalaras11 First off, use UUID not their name.
    Did you register the event?
    Just loop through the inventory, if the item is a bowl set it to soup.
     
    mihalaras11 likes this.
  5. Offline

    mihalaras11

    thanks guys! i did it with the easy way i said when he types reffil remove all the bowls and soups and and add new soups but thanks!
     
  6. Offline

    mkezar

    Please mark your forum post as Solved if you have figured it out. Becuase I came over here to help but you already figured it out.
     
  7. Ignoring the fact this is solved:

    Make 'kits' a List, not an ArrayList.

    List<String> kits = new ArrayList<String>();
     
  8. Offline

    mihalaras11

    well i have another question is it possible to make a new item stack based on item id? i mean istead of using
    ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP, 5); can i replace the mushroum soup with 282 which is its id because i want to make config and let players edit the kits and i dont want to make them write MUSHTOOM_SOUP but 282 which is easier
     
  9. Offline

    CraftBang

  10. Offline

    mihalaras11

    and how do i select ammount i tried 282, 5 but didn't work
     
Thread Status:
Not open for further replies.

Share This Page