ok so i coded this plugin earlier in the morning and it uses a array list and i cant remove the player from the array list here is the code: Code:java package me.DMDO1599.Listener; import java.util.ArrayList; import me.DMDO1599.main; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandExecutor;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.player.AsyncPlayerChatEvent; public class Mute implements Listener, CommandExecutor{ public ArrayList<String> mute = new ArrayList<String>(); private main plugin; public Mute(main instance){ this.plugin =instance; this.plugin.getServer().getPluginManager().registerEvents(this, this.plugin); } @EventHandler public void onChat(AsyncPlayerChatEvent e){ Player p = e.getPlayer(); if(mute.contains(p.getName())){ e.setCancelled(true); p.sendMessage(ChatColor.DARK_RED + "You are still muted!"); } } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player p = (Player) sender; if(commandLabel.equalsIgnoreCase("mute")){ if(args.length == 0){ p.sendMessage(ChatColor.RED + "Incorrect usage /mute <username>"); return true; } if(args.length == 1){ Player online = Bukkit.getPlayer(args[0]); if(online == null || !online.isOnline()){ p.sendMessage(ChatColor.RED + "Player: " + args[0] + " is not online"); }else{ mute.add(online.getName()); p.sendMessage(ChatColor.GREEN + "You have succesfully muted: " + online.getName()); online.sendMessage(ChatColor.RED + "You have been muted by: " + p.getName()); } } } if(commandLabel.equalsIgnoreCase("unmute")){ if(args.length == 0){ p.sendMessage(ChatColor.RED + "Incorrect usage /unmute <username>"); return true; } if(args.length == 1){ Player online = Bukkit.getPlayer(args[0]); if(online == null || !online.isOnline()){ p.sendMessage(ChatColor.RED + "Player: " + args[0] + " is not online"); }else{ mute.remove(online.getName()); mute.remove(online.getName()); mute.remove(online.getName()); p.sendMessage(ChatColor.GREEN + "You have succesfully unmuted: " + online.getName()); online.sendMessage(ChatColor.GREEN + "You have been unmuted by: " + p.getName()); } } } return false; }}
DMDO1599 First of all, use Collections.synchronizedList(new ArrayList<String>()); for your mute list. Chat us handled in an asynchronous thread. What happens you try the unmute command?
when i do the unmute it sends the message but it doesnt removes you from the array list i need to fix this fast plz :S