2017-11-11 17:12:30 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
2017-11-11 17:12:30 +00:00
|
|
|
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command>", aliases = "v")
|
|
|
|
public class Command_vanish extends FreedomCommand
|
|
|
|
{
|
2018-01-01 03:43:10 +00:00
|
|
|
public static ArrayList<Player> VANISHED = new ArrayList<Player>();
|
2017-11-11 17:12:30 +00:00
|
|
|
|
|
|
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole) {
|
2018-01-01 03:43:10 +00:00
|
|
|
Displayable display = plugin.rm.getDisplay(playerSender);
|
2017-11-11 17:12:30 +00:00
|
|
|
String loginMsg = display.getColoredLoginMessage();
|
2018-01-01 03:43:10 +00:00
|
|
|
String displayName = display.getColor() + playerSender.getName();
|
|
|
|
Admin admin = plugin.al.getAdmin(playerSender);
|
|
|
|
if (VANISHED.contains(playerSender))
|
|
|
|
{
|
|
|
|
msg(ChatColor.GOLD + "You have been unvanished.");
|
|
|
|
if (admin.hasLoginMessage())
|
|
|
|
{
|
2017-11-11 17:12:30 +00:00
|
|
|
loginMsg = FUtil.colorize(admin.getLoginMessage());
|
|
|
|
}
|
|
|
|
FUtil.bcastMsg(ChatColor.AQUA + playerSender.getName() + " is " + loginMsg);
|
|
|
|
FUtil.bcastMsg(playerSender.getName() + " joined the game", ChatColor.YELLOW);
|
2018-01-01 03:43:10 +00:00
|
|
|
plugin.pl.getPlayer(playerSender).setTag(display.getColoredTag());
|
2017-11-11 17:12:30 +00:00
|
|
|
FLog.info(playerSender.getName() + " is no longer vanished.");
|
2018-01-01 03:43:10 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
2017-11-11 17:12:30 +00:00
|
|
|
player.showPlayer(playerSender);
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
plugin.esb.setVanished(playerSender.getName(), false);
|
2017-11-11 17:12:30 +00:00
|
|
|
playerSender.removePotionEffect(PotionEffectType.INVISIBILITY);
|
|
|
|
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
2018-01-01 03:43:10 +00:00
|
|
|
VANISHED.remove(playerSender);
|
2017-11-11 17:12:30 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
msg("You have been vanished.", ChatColor.GOLD);
|
2017-11-11 17:12:30 +00:00
|
|
|
FUtil.bcastMsg(playerSender.getName() + " left the game", ChatColor.YELLOW);
|
|
|
|
FLog.info(playerSender.getName() + " is now vanished.");
|
2018-01-01 03:43:10 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
2017-11-11 17:12:30 +00:00
|
|
|
player.hidePlayer(playerSender);
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
plugin.esb.setVanished(playerSender.getName(), true);
|
2017-11-11 17:12:30 +00:00
|
|
|
playerSender.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 1000000, true, false));
|
2018-01-01 03:43:10 +00:00
|
|
|
VANISHED.add(playerSender);
|
2017-11-11 17:12:30 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|