2017-11-11 17:12:30 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
2018-07-31 07:01:29 +00:00
|
|
|
import java.util.ArrayList;
|
2017-11-11 17:12:30 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
2018-07-31 07:01:29 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2017-11-11 17:12:30 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2018-07-31 07:01:29 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2017-11-11 17:12:30 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2018-07-31 07:01:29 +00:00
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
2019-07-31 16:21:21 +00:00
|
|
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
2017-11-11 17:12:30 +00:00
|
|
|
|
2018-01-01 03:43:10 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
2018-06-29 17:49:06 +00:00
|
|
|
@CommandParameters(description = "Vanish/unvanish yourself.", usage = "/<command> [-s[ilent]]", aliases = "v")
|
2017-11-11 17:12:30 +00:00
|
|
|
public class Command_vanish extends FreedomCommand
|
|
|
|
{
|
2018-06-29 19:36:42 +00:00
|
|
|
public static ArrayList<Player> VANISHED = new ArrayList<>();
|
2018-06-29 17:49:06 +00:00
|
|
|
|
2018-07-31 06:41:56 +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();
|
2018-03-28 10:37:40 +00:00
|
|
|
String tag = display.getColoredTag();
|
2018-01-01 03:43:10 +00:00
|
|
|
Admin admin = plugin.al.getAdmin(playerSender);
|
2018-06-29 17:49:06 +00:00
|
|
|
boolean silent = false;
|
|
|
|
if (args.length > 0)
|
|
|
|
{
|
|
|
|
if (args[0].equalsIgnoreCase("-s") || args[0].equalsIgnoreCase("-silent"))
|
|
|
|
{
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
if (VANISHED.contains(playerSender))
|
|
|
|
{
|
|
|
|
msg(ChatColor.GOLD + "You have been unvanished.");
|
|
|
|
if (admin.hasLoginMessage())
|
|
|
|
{
|
2019-08-13 12:55:01 +00:00
|
|
|
loginMsg = FUtil.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName());
|
2017-11-11 17:12:30 +00:00
|
|
|
}
|
2018-06-29 17:49:06 +00:00
|
|
|
if (!silent)
|
|
|
|
{
|
2019-08-14 20:53:35 +00:00
|
|
|
FUtil.bcastMsg(ChatColor.AQUA + sender.getName() + " is " + loginMsg);
|
2019-12-25 01:11:07 +00:00
|
|
|
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
|
2019-12-27 16:26:38 +00:00
|
|
|
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
|
2018-06-29 17:49:06 +00:00
|
|
|
}
|
2018-03-28 10:37:40 +00:00
|
|
|
if (admin.getTag() != null)
|
|
|
|
{
|
|
|
|
tag = FUtil.colorize(admin.getTag());
|
|
|
|
}
|
2019-09-10 05:44:27 +00:00
|
|
|
plugin.pl.getPlayer(playerSender).setTag(tag);
|
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())
|
|
|
|
{
|
2019-08-01 05:59:26 +00:00
|
|
|
if (plugin.al.isAdmin(player))
|
2019-08-01 20:45:51 +00:00
|
|
|
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has unvanished and is now visible to everyone." );
|
2018-07-31 05:58:50 +00:00
|
|
|
player.showPlayer(plugin, playerSender);
|
2017-11-11 17:12:30 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
plugin.esb.setVanished(playerSender.getName(), false);
|
2017-11-11 17:12:30 +00:00
|
|
|
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);
|
2018-06-29 17:49:06 +00:00
|
|
|
if (!silent)
|
|
|
|
{
|
2019-12-25 01:11:07 +00:00
|
|
|
FUtil.bcastMsg(playerSender.getName() + " left the game.", ChatColor.YELLOW);
|
2019-12-27 16:26:38 +00:00
|
|
|
plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**");
|
2018-06-29 17:49:06 +00:00
|
|
|
}
|
2017-11-11 17:12:30 +00:00
|
|
|
FLog.info(playerSender.getName() + " is now vanished.");
|
2018-01-01 03:43:10 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
2018-07-31 05:58:50 +00:00
|
|
|
{
|
2019-07-31 16:21:21 +00:00
|
|
|
if (plugin.al.isAdmin(player))
|
2019-08-01 20:45:51 +00:00
|
|
|
playerMsg(player, ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins." );
|
2019-07-31 16:21:21 +00:00
|
|
|
if (!plugin.al.isAdmin(player))
|
|
|
|
player.hidePlayer(plugin, playerSender);
|
2018-07-31 05:58:50 +00:00
|
|
|
}
|
2017-11-11 17:12:30 +00:00
|
|
|
}
|
2018-01-01 03:43:10 +00:00
|
|
|
plugin.esb.setVanished(playerSender.getName(), true);
|
|
|
|
VANISHED.add(playerSender);
|
2017-11-11 17:12:30 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|