Solved ArrayList Error?

Discussion in 'Plugin Development' started by king_of_all96543, Apr 1, 2014.

Thread Status:
Not open for further replies.
  1. Hello, I am having an issue i am trying to add a player to an ArrayList phantom.add(player.getName); but the add is having an error under it and wants me to change it it addAll, then wants me to change it back to add please help here is code!

    Code:java
    1. package me.toxic.ability;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.block.Action;
    12. import org.bukkit.event.player.PlayerInteractEvent;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class Main extends JavaPlugin implements Listener{
    16.  
    17. ArrayList<Player> phantom = new ArrayList<Player>();
    18.  
    19. public void onEnable(){
    20.  
    21. }
    22.  
    23. public void onDisable(){
    24.  
    25. }
    26.  
    27. @EventHandler
    28. public void onInteract(PlayerInteractEvent e){
    29. final Player player = e.getPlayer();
    30. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
    31. if(player.getItemInHand().equals(Material.FEATHER)){
    32. player.setFlying(true);
    33. phantom.add<---//here is here//(player.getName());
    34. player.getInventory().remove(Material.FEATHER);
    35. player.sendMessage(ChatColor.GOLD + "You have become airborne for 5 seconds!");
    36. Bukkit.getScheduler().runTaskLater(this, new Runnable()
    37. {
    38. public void run() {
    39. player.setFlying(false);
    40. }
    41. }
    42. , 100L);
    43. Bukkit.getScheduler().runTaskLaterAsynchronously(this, new Runnable()
    44. {
    45. public void run() {
    46. phantom.remove(player.getName());
    47. player.sendMessage(ChatColor.GREEN + "You are no longer on cooldown");
    48.  
    49. }
    50. }
    51. , 400L);
    52. }
    53. }
    54. }
    55.  
    56. }
    57.  
     
  2. Offline

    Cirno

    Change from to ArrayList<String> in every instance of ArrayList<Player
     
  3. Cirno wow THANK YOU, i have no idea why i didnt put string thanks for answering my question SOLVED
     
Thread Status:
Not open for further replies.

Share This Page