for some reason i get an error on:
boolean vanished = vanishCommand.vanished.contains(player);
could someone help me please
boolean vanished = vanishCommand.vanished.contains(player);
could someone help me please
vanishCommand is the instance for my VanishCommand classOh I would help but I don't know what vanishCommand(probably command instance) is, vanished(probably array list), or even what the error IS!
tried that and it still spams them errors when i joinTry changing it to if (vanishCommand.vanished.contains(player){
}
And then run your code had a simmilair issue a while back
public ArrayList<Player> vanished = new ArrayList<Player>();The arraylist is equal to null, make sure you initialised it properly.
public ArrayList<Player> vanished = new ArrayList<>();
public ArrayList<Player> vanished = new ArrayList<Player>();
boolean vanished;
if (vanished.contains(player)) {
vanished = true;
} else {
vanished = false;
}
I just wanted to point a few things out with your post.ArrayList should be:
However this will also work, but not necceasary with the newer versions.:Code:public ArrayList<Player> vanished = new ArrayList<>();
Booleans must be a true or false value, you have set it to none.Code:public ArrayList<Player> vanished = new ArrayList<Player>();
Note: Would get in the practice of using UUIDS instead. Also im not sure but wrong section?Code:boolean vanished; if (vanished.contains(player)) { vanished = true; } else { vanished = false; }
scoreboard class:I just wanted to point a few things out with your post.
As for the user I recommend using a set for performance.
- Doesn't matter if you use a UUID or Player as long as you remove the player
- vanish.contains() this method IS a boolean so you can do boolean vanished = this.vanished.contains(player)
- Use List<Player> vanished = new ArrayList<>();
Annd as for when using a UUID or Player doesnt matter, it does NOT affect performance which is what some people thing. You store object references in collections not an instance of the object. Reason being is because Player classes have a runtime of O(1)
done that and it still wont work[DOUBLEPOST=1501265576][/DOUBLEPOST]Put vanish.getInstance in ur splayer constructor and change arraylist to this:
Code:List<Player> vanished = new ArrayList<>();
wait, wheres the splayer constructor?Put vanish.getInstance in ur splayer constructor and change arraylist to this:
Code:List<Player> vanished = new ArrayList<>();
for (Player o : Bukkit.getServer().getOnlinePlayers()) {
if(vanished.contains(p)) {
Go learn java & spigotalso if possible could you help out with getting koths to show (subsides koth) and possibly an sotw timer?
