Solved KitPvP - 1 Kit Per Life

Discussion in 'Plugin Development' started by Etched, Jan 14, 2014.

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

    Etched

    Recently I have been developing a KitPvP plugin. There is a main class and all the other classes are for the kit(eg. stomper.class). I have all the code working, but I want to make it so there is only one kit per life, but am struggling as there are multiple classes. I have tried using constructors, but I think I'm doing something wrong. Help would be much appreciated. I can't find an answer to this anywhere :p .
    -Thanks,
    Etched
     
  2. You could listen to PlayerDeathEvent and PlayerRespawnEvent
     
  3. Offline

    Etched

    I know, but I am not sure how to make it one global hashset, so every class can access it.
     
  4. Offline

    NetherResident

    Etched Make the hashset static, then add a player to it once they have claimed a kit. Then remove them from the hashset when they respawn.
     
  5. Offline

    Vorqe

    this is for my viper kit but here

    Code:
    public static ArrayList<String> stomper= new ArrayList<String>();
    then in the onCommand use this
    Code:
    Player player = (Player)sender;
                if (stomper.contains(player.getName())) {
     
                    player.sendMessage(ChatColor.RED
                            + "You can only pick one kit each life!");
                } else {
                   stomper.add(player.getName());
    then the rest of your code....
     
  6. Offline

    HyrulesLegend

    What I do is create the ArrayList in my Main class, then I call this method in every class:

    Code:java
    1. public Main plugin;
    2. public ClassName(Main plugin) {
    3. this.plugin = plugin;
    4. }


    Then I can just do:
    Code:java
    1. plugin.arrayname.WhateverYouWantToDoHere
     
  7. Offline

    Etched

    So do I make this in the main, or each class individually

    Thank you so much :D. I got a few errors to start with, but that was when I forgot to make the Main plugin public, or forgot plugin. at the start of the hashmap. Once again thank you for the help, it's greatly appreciated.

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

    Vorqe

    Do it where ever you have put the code for the kit , just to keep everything simple
     
Thread Status:
Not open for further replies.

Share This Page