77 lines
2.0 KiB
Java
77 lines
2.0 KiB
Java
package eu.univento.core.commands;
|
|
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.AutoCommand;
|
|
import eu.univento.core.api.languages.Messages;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.core.api.player.Perms.Ranks;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 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());
|
|
Messages msgs = new Messages(p);
|
|
if(p.isAllowed(Ranks.Moderator)) {
|
|
if(players.contains(p)) {
|
|
for(Player players : Bukkit.getOnlinePlayers()) {
|
|
players.showPlayer(p);
|
|
}
|
|
players.remove(p);
|
|
p.sendMessage(msgs.PREFIX() + msgs.Core_VANISH_OFF());
|
|
}else {
|
|
for(Player players : Bukkit.getOnlinePlayers()) {
|
|
players.hidePlayer(p);
|
|
}
|
|
players.add(p);
|
|
p.sendMessage(msgs.PREFIX() + msgs.Core_VANISH_ON());
|
|
}
|
|
}else {
|
|
p.sendMessage(msgs.NO_PERMS());
|
|
}
|
|
}else {
|
|
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
|
return null;
|
|
}
|
|
|
|
|
|
} |