Core/src/de/joethei/core/commands/Vanish.java

77 lines
1.9 KiB
Java

package de.joethei.core.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
/**
* vanish players
* @author joethei
* @version 1.0
*/
public class Vanish extends AutoCommand<Core>{
/**
* contains vanished players
*/
private static ArrayList<CustomPlayer> players = new ArrayList<CustomPlayer>();
/**
* @return vanished players
*/
public static ArrayList<CustomPlayer> getPlayers() {
return players;
}
/**
* @param plugin main class
* @param command command to execute
* @param description describes the command
* @param aliases aliases of command
*/
public Vanish(Core plugin, String command, String description, String[] aliases) {
super(plugin, command, description, aliases);
}
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if(sender instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
if(p.isAllowed(Ranks.Moderator)) {
if(players.contains(p)) {
for(Player players : Bukkit.getOnlinePlayers()) {
players.showPlayer(p);
}
players.remove(p);
p.sendMessage("§cDu bist nun wieder sichtbar");
}else {
for(Player players : Bukkit.getOnlinePlayers()) {
players.hidePlayer(p);
}
players.add(p);
p.sendMessage("Du bist nun unsichtbar");
}
}else {
p.sendMessage(Messages.NO_PERMS);
}
}else {
sender.sendMessage(Messages.NOT_A_PLAYER);
}
return false;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
return null;
}
}