How do I code into my plugin give an essentials kit?

Discussion in 'Plugin Development' started by Jawfy, Feb 11, 2015.

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

    Jawfy

    Hello, I was wondering if anyone would be kind enough to show me the code I would use to give a player a essentials kit when joining :)
     
  2. Offline

    yewtree8

    I'm presuming you mean as creating it from scratch.

    Code:
    @EventHandler
    public void onJoin(PlayerJoinEvent event){
        Player player = event.getPlayer();
       
        if(!(player.hasPlayedBefore())){
            player.getInventory().addItem(new ItemStack(Material.WHATEVERYOUWANT, <Quanity>);
            player.updateInventory();
        }
    
    
    }
     
  3. @Jawfy OnJoin execute the command "/kit " + kit + e.getPlayer().getName()
     
  4. Offline

    Signatured

    Doesn't essentials do this already when a player first joins?
     
  5. @Signatured First but not all the times after that.
     
  6. Offline

    Signatured

    I guess. Like @bwfcwalshy said, just have console execute the command whenever a player joins.
     
  7. Offline

    TheOatBaron

    Forgot a space

    "/kit " + <kit> + " " + e.getPlayer().getName()
     
  8. Offline

    MordorKing78

  9. Offline

    JustThiemoo

    As said above here, use player join event, make dispatch command to give kit ;)
     
  10. Offline

    MCJoshua345

    Code:
    @EventHandler
    public void onPJoin(PlayerJoinEvent e){
       
          Player p = e.getPlayer();
          String pname = p.getName();
              p.performCommand("/kit <kit> " + pname);
    }
     
  11. @AllOfYou
    performCommand already contains the /
    With your code the command would look like this: //kit <kit> player
    Should look like this: "kit <kit> " + p.getName()
     
  12. Code:
     Bukkit.dispatchCommand(Bukkit.getConsoleSender, "kit <Kit>" + p.getName()); 
    ^^ How to excecute console commands.
     
    Last edited: Mar 19, 2015
  13. Sorry xD. I did that without opening my IDE and tried todo it without the finishing syntax. Lol ty.
     
Thread Status:
Not open for further replies.

Share This Page