Hey guy, so I am making a class to check if a player is in an array list, then execute a public void run. However I can't do it as I don't know what to set player as. I would usaully set player as " Player player = event.getPlayer();" however I don't know what event to use. Any help would be great!
Maurdekye I was wondering what event I should use, as I am making a class PURELY for checking if a player is in a array list then executing a event.
Niknea OMG, it depends when you want to check... Event is an event, it is called when it's happening/happened.
newboyhun Well I want it to check if they are in a array list, then if they a public void run would execute, which is what I said on my main post. xTigerRebornx Mind showing me an example? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Niknea No, you asked for AN EVENT to use. But we don't have any information about when do you want to check..... Nonsense
xTigerRebornx So I want to check if a player is on a array list. and if they are the code will run. Pretty much what will happen is after 10 seconds they will be removed ( so it is like a cooldown ).
Ohhhh, I think I might be having a similar problem. I'm pretty sure the ArrayList.contains() method doesn't work for this case, though, so you have to loop through the list and compare player names; Code:java public boolean checkPlayerInArrayList(ArrayList<Player> chweckIn, Player checkFor) {for (Player p : checkIn) {if (p.getName().equals(checkFor.getName())) return true;}return false;} As far as I know, this is the most reliable way to compare players.
Maurdekye Also what would I register it as? A listener or a command? Also would I then need to add @EventHandler?
I have no idea what you mean until you describe what you want in full. All you asked for was a way of checking if a player was within an arraylist. When and where do you want to check for this player? How often, and for what purpose?