Solved Need help with per kit use

Discussion in 'Plugin Development' started by InspectorFacepalm, May 4, 2013.

Thread Status:
Not open for further replies.
  1. So i'm trying to make it if you use a class you can't use that class again until you die
    Here's what I have, and it doesn't work, no errors in console or anything. Anyone know how what to do?
    Code:
    java.util.List<String> usedkit = new ArrayList<String>();
     
      @EventHandler
      public void onPlayerDeath1(PlayerDeathEvent e) {
        Player player = e.getEntity().getPlayer();
        this.usedkit.remove(player.getName());
     
    this.usedkit.contains(p.getName());
     if(!usedkit.contains(p.getName())) {
     
  2. Offline

    Paper

    Uh what? The last 2 lines of your code make no sense.
     
  3. It's in the kit, i mean like this, This is my kit plugin, just something I made up really quick
    You put the this.usedkit.contains(p.getName()); which will get the name
    and when you do if(!usedkit.contains(p.getName())) {
    sender.sendMessage(ChatColor.RED + "You have already used a kit!);
    Code:
     
    public void onEnable() {
    System.out.println("PvP has been Enabled!");
    }
    public void onDisable() {
    System.out.println("PvP has been Enabled!");
    }
     
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(cmd.getName().equalsIgnoreCase("pvp")) {
    Player player = (Player) sender;
    ItemStack sword = new ItemStack(Material.DIAMOND_AXE, 1);
    player.setItemInHand(sword);
     
    return true;
    }
    return false;
    }
    }
    
    Paper
    Do you know what i'm talking about?

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

    Compressions

    facepalm Explain the code to yourself out loud and use logic to determine what will happen with each check.
     
  5. Offline

    Paper

    But, this.usedKit.contains(p.getName()); is a boolean. So you can only put that in a statement block, not on its own?
     
  6. Offline

    MP5K

    InspectorFacepalm

    you could use this code: (untested)

    PHP:
     private List<StringusedKits = new ArrayList<String>();

    @
    EventHandler
    public void onPlayerDeath1(PlayerDeathEvent e) {
    Player player e.getEntity().getPlayer();
    if(
    this.usedKits.contains(player.getName())){
    this.usedKits.remove(player.getName());
    }
    }

    @
    Override
    public boolean onCommand(CommandSender senderCommand cmdString labelString[] args) {
    if(
    cmd.getName().equalsIgnoreCase("pvp")) {
    Player player = (Playersender;
    if(
    usedKits.contains(player.getName())){
    player.sendMessage("You have allready used that Kit!");
    return 
    true;
    }
    ItemStack sword = new ItemStack(Material.DIAMOND_AXE1);
    player.setItemInHand(sword);
    this.usedKits.add(player.getName());
    return 
    true;
    }
    return 
    false;
    }
    [OFF TOPIC]
    Awesome nickname Paper :3
     
    InspectorFacepalm likes this.
  7. MP5K
    Thanks I'll try it out tomorrow because I don't have my server files where I'm at.

    Edit: Omy, I love you mp5k!
     
Thread Status:
Not open for further replies.

Share This Page