I am making a bukkit plugin and it has an option to toggle. This is the code I used to make the toggle. In game, the only response is OFF, when it should toggle between ON and OFF. Please help!
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
ArrayList<String> players = new ArrayList<String>();
if (cmd.getName().equalsIgnoreCase("togglegift") && sender instanceof Player){
Player Tplayer = (Player) sender;
if(players.contains(Tplayer.getName())) {
Tplayer.sendMessage(ChatColor.GOLD + "[BapGift] " + ChatColor.LIGHT_PURPLE + "Gifts Toggled" + ChatColor.GREEN + " ON");
players.remove(Tplayer.getName());
} else {
players.add(Tplayer.getName());
Tplayer.sendMessage(ChatColor.GOLD + "[BapGift] " + ChatColor.LIGHT_PURPLE + "Gifts Toggled" + ChatColor.RED + " OFF");
}
}
Aucun commentaire:
Enregistrer un commentaire