Q:

ArrayList is not working as expected

(I'm still pretty new to coding)
I'm trying to make a Minecraft plugin that has a command so that a player freezes when the command is typed, but my ArrayList is acting very weirdly.
When I type the command (/freeze) the plugin sends a message to me saying that the target has been frozen. When I check the list with a piece of code that says it in chat (code below) it says it is empty. But when I do the command again, the function unFreeze, that requires the ArrayList has the name, still, works. But if I move and freeze myself that way, the name is added to the list and it works, even the code that checks the list and says it in chat says it is there, but even if I walk and the playername gets added to the list, the text that says that I'm frozen or unfrozen doesn't seem to get affected, it just toggles between the two, and the command doesn't do anything else.
Code for checking the list:
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (label.equalsIgnoreCase("seefrozenlist")){
        for (String s : freezeListener.frozen){
            sender.sendMessage(s);
        }
    }
    return true;
}

Code for adding the player:
if (freezeListener.frozen.contains(player.getName())){ //normally freezeListener.getFrozen.contains(...)
    freezeListener.unFreeze(player.getName());
    sender.sendMessage(ChatColor.translateAlternateColorCodes('&',player.getDisplayName() + "&e is no longer &b&lFROZEN"));
    player.sendMessage(ChatColor.translateAlternateColorCodes('&',"&eYou are no longer &b&lFROZEN"));
    return true;
}
else {
    //freezeListener.freeze(player.getName());
    freezeListener.freeze(player.getName());
    sender.sendMessage(ChatColor.translateAlternateColorCodes('&',player.getDisplayName() + "&e is now &b&lFROZEN"));
    player.sendMessage(ChatColor.translateAlternateColorCodes('&',"&eYou are now &b&lFROZEN"));
    return true;
}

Class that has the ArrayList:
public class FreezeListener implements Listener {
// was private, is public for testing
public ArrayList<String> frozen = new ArrayList<>();

public ArrayList<String> getFrozen(){
    return frozen;
}

public void freeze(String name){
    //if (!(frozen.contains(name))){
        frozen.add(name.trim());
        Bukkit.getServer().getPlayer(name).sendMessage("\"" + name + "\" Freeze");
    //}
}

public void unFreeze(String name){
    if (frozen.contains(name)){
        frozen.remove(name);
        Bukkit.getServer().getPlayer(name).sendMessage("\"" + name + "\" Unfreeze");
    }
}

@EventHandler
public void onPlayerMove(PlayerMoveEvent event){
    if (getFrozen().contains(event.getPlayer().getName().trim())){
        event.getPlayer().sendMessage("2");
        Location to = event.getFrom();
        to.setPitch(event.getTo().getPitch());
        to.setYaw(event.getTo().getYaw());
        event.setTo(to);
    }
    //For testing
    else {
        freeze(event.getPlayer().getName());
    }
}

A:

Your problem is that you have few different instances of FreezeListener. The one which is used for adding/removing player is not the same that is read in chat with onCommand. You should create new FreezeListener once and use it everywhere. You should do something like that probably in main class:
FreezeListener freezeListener = new FreezeListener();
FreezeCommand freezeCommand = new FreezeCommand( freezeListener); //<- This listener...

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (label.equalsIgnoreCase("seefrozenlist")){
        for (String s : freezeListener.frozen){ // <-...and this one are now the same listener and will share the list of frozen players
            sender.sendMessage(s);
        }
    }
    return true;
}

I can try to be more accurate if you show your main class.

