revamp vanish

This commit is contained in:
speedxx 2020-07-22 17:40:58 -04:00
parent fc05003354
commit 7593fbda9e
19 changed files with 183 additions and 60 deletions

View File

@ -31,7 +31,7 @@ public class LoginProcess extends FreedomService
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
//
@Getter
@Setter
private static boolean lockdownEnabled = false;
@ -226,14 +226,6 @@ public class LoginProcess extends FreedomService
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
}
for (Player p : plugin.al.vanished)
{
if (!plugin.al.isAdmin(player))
{
player.hidePlayer(plugin, p);
}
}
if (!plugin.al.isAdmin(player))
{
String tag = playerData.getTag();
@ -241,6 +233,7 @@ public class LoginProcess extends FreedomService
{
fPlayer.setTag(FUtil.colorize(tag));
}
int noteCount = playerData.getNotes().size();
if (noteCount != 0)
{
@ -274,7 +267,6 @@ public class LoginProcess extends FreedomService
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
}
}
}.runTaskLater(plugin, 20L * 1L);
}.runTaskLater(plugin, 20L);
}
}

View File

@ -135,6 +135,7 @@ public class TotalFreedomMod extends JavaPlugin
public SignBlocker snp;
public EntityWiper ew;
public Sitter st;
public VanishHandler vh;
//public HubWorldRestrictions hwr;
//
@ -243,6 +244,7 @@ public class TotalFreedomMod extends JavaPlugin
snp = new SignBlocker();
ew = new EntityWiper();
st = new Sitter();
vh = new VanishHandler();
// Single admin utils
cs = new CommandSpy();

View File

@ -0,0 +1,83 @@
package me.totalfreedom.totalfreedommod;
import me.totalfreedom.totalfreedommod.util.FLog;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class VanishHandler extends FreedomService
{
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
for (Player p : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
{
player.hidePlayer(plugin, p);
}
}
for (Player p : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
{
p.hidePlayer(plugin, player);
}
}
if (plugin.al.isVanished(player.getName()))
{
plugin.esb.setVanished(player.getName(), true);
FLog.info(player.getName() + " joined while still vanished.");
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
event.setJoinMessage(null);
new BukkitRunnable()
{
@Override
public void run()
{
if (!plugin.al.isVanished(player.getName()))
{
this.cancel();
}
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
}
}.runTaskTimer(plugin, 0L, 4L);
}
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
Player player = event.getPlayer();
if (plugin.al.isVanished(player.getName()))
{
event.setQuitMessage(null);
FLog.info(player.getName() + " left while still vanished.");
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
}
}
}

View File

@ -31,7 +31,7 @@ public class AdminList extends FreedomService
private final Map<String, Admin> ipTable = Maps.newHashMap();
public final List<String> verifiedNoAdmins = new ArrayList<>();
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
public static ArrayList<Player> vanished = new ArrayList<>();
public static List<String> vanished = new ArrayList<>();
@Override
public void onStart()
@ -362,4 +362,9 @@ public class AdminList extends FreedomService
updateTables();
}
public boolean isVanished(String player)
{
return vanished.contains(player);
}
}

View File

@ -36,7 +36,7 @@ public class Command_deop extends FreedomCommand
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
{
if (player.isOp() && !AdminList.vanished.contains(player))
if (player.isOp() && !AdminList.vanished.contains(player.getName()))
{
matchedPlayerNames.add(player.getName());
player.setOp(false);

View File

@ -16,6 +16,7 @@ import org.bukkit.potion.PotionEffectType;
@CommandParameters(description = "Shows (optionally clears) invisible players", usage = "/<command> [clear]")
public class Command_invis extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -42,7 +43,7 @@ public class Command_invis extends FreedomCommand
for (Player player : server.getOnlinePlayers())
{
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.vanished.contains(player))
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY) && !plugin.al.isVanished(player.getName()))
{
players.add(player.getName());
if (clear && !plugin.al.isAdmin(player))

View File

@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Lists the real names of all online players.", usage = "/<command> [-a | -i | -f | -v]", aliases = "who,lsit")
public class Command_list extends FreedomCommand
{
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
if (args.length > 1)
@ -108,11 +109,11 @@ public class Command_list extends FreedomCommand
{
continue;
}
if (listFilter == ListFilter.ADMINS && AdminList.vanished.contains(p))
if (listFilter == ListFilter.ADMINS && AdminList.vanished.contains(p.getName()))
{
continue;
}
if (listFilter == ListFilter.VANISHED_ADMINS && !AdminList.vanished.contains(p))
if (listFilter == ListFilter.VANISHED_ADMINS && !AdminList.vanished.contains(p.getName()))
{
continue;
}
@ -124,7 +125,7 @@ public class Command_list extends FreedomCommand
{
continue;
}
if (listFilter == ListFilter.PLAYERS && AdminList.vanished.contains(p))
if (listFilter == ListFilter.PLAYERS && AdminList.vanished.contains(p.getName()))
{
continue;
}

View File

@ -41,11 +41,11 @@ public class Command_nickfilter extends FreedomCommand
player = getPlayerByDisplayName(displayName);
if (player == null || plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (player == null || plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{
player = getPlayerByDisplayNameAlt(displayName);
if (player == null || !plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (player == null || !plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{
sender.sendMessage(ChatColor.GRAY + "Can't find player by nickname: " + displayName);
return true;

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "OP a player", usage = "/<command> <partialname>")
public class Command_op extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -36,7 +37,7 @@ public class Command_op extends FreedomCommand
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName)
|| player.getName().contains(targetName) || player.getDisplayName().contains(targetName))
{
if (!player.isOp() && !AdminList.vanished.contains(player))
if (!player.isOp() && !AdminList.vanished.contains(player.getName()))
{
matchedPlayerNames.add(player.getName());
player.setOp(true);

View File

@ -106,7 +106,7 @@ public class Command_potion extends FreedomCommand
{
target = getPlayer(args[4]);
if (target == null || plugin.al.vanished.contains(target) && !plugin.al.isAdmin(sender))
if (target == null || plugin.al.isVanished(target.getName()) && !plugin.al.isAdmin(sender))
{
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
@ -244,5 +244,4 @@ public class Command_potion extends FreedomCommand
}
return types;
}
}

View File

@ -48,7 +48,7 @@ public class Command_tag extends FreedomCommand
for (final Player player : server.getOnlinePlayers())
{
if (plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{
continue;
}

View File

@ -1,16 +1,18 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.rank.Displayable;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@ -23,7 +25,6 @@ public class Command_vanish extends FreedomCommand
Displayable display = plugin.rm.getDisplay(playerSender);
String displayName = display.getColor() + playerSender.getName();
String tag = display.getColoredTag();
Admin admin = plugin.al.getAdmin(playerSender);
boolean silent = false;
if (args.length > 0)
{
@ -32,22 +33,30 @@ public class Command_vanish extends FreedomCommand
silent = true;
}
}
if (plugin.al.vanished.contains(playerSender))
if (plugin.al.isVanished(playerSender.getName()))
{
msg(ChatColor.GOLD + "You have been unvanished.");
if (!silent)
if (silent)
{
msg(ChatColor.GOLD + "Silently unvanished.");
}
else
{
msg("You have unvanished.", ChatColor.GOLD);
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
FUtil.bcastMsg(playerSender.getName() + " joined the game.", ChatColor.YELLOW);
plugin.dc.messageChatChannel("**" + playerSender.getName() + " joined the server" + "**");
}
PlayerData playerData = plugin.pl.getData(playerSender);
if (playerData.getTag() != null)
{
tag = FUtil.colorize(playerData.getTag());
}
plugin.pl.getData(playerSender).setTag(tag);
FLog.info(playerSender.getName() + " is no longer vanished.");
for (Player player : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(player))
@ -61,16 +70,33 @@ public class Command_vanish extends FreedomCommand
}
plugin.esb.setVanished(playerSender.getName(), false);
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
plugin.al.vanished.remove(playerSender);
plugin.al.vanished.remove(playerSender.getName());
}
else
{
msg("You have been vanished.", ChatColor.GOLD);
if (!silent)
new BukkitRunnable()
{
@Override
public void run()
{
if (plugin.al.isVanished(playerSender.getName()))
{
playerSender.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
}
}
}.runTaskTimer(plugin, 0L, 4L);
if (silent)
{
msg("Silently vanished.", ChatColor.GOLD);
}
else
{
msg ("You have vanished.", ChatColor.GOLD);
FUtil.bcastMsg(playerSender.getName() + " left the game.", ChatColor.YELLOW);
plugin.dc.messageChatChannel("**" + playerSender.getName() + " left the server" + "**");
}
FLog.info(playerSender.getName() + " is now vanished.");
for (Player player : server.getOnlinePlayers())
{
@ -85,8 +111,9 @@ public class Command_vanish extends FreedomCommand
}
}
}
plugin.esb.setVanished(playerSender.getName(), true);
plugin.al.vanished.add(playerSender);
plugin.al.vanished.add(playerSender.getName());
}
return true;
}

View File

@ -40,7 +40,7 @@ public class Command_whohas extends FreedomCommand
for (final Player player : server.getOnlinePlayers())
{
if (!plugin.al.isAdmin(sender) && plugin.al.vanished.contains(player))
if (!plugin.al.isAdmin(sender) && plugin.al.isVanished(player.getName()))
{
continue;
}

View File

@ -303,10 +303,13 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
protected Player getPlayer(String name, Boolean nullVanished)
{
Player player = Bukkit.getPlayer(name);
if (nullVanished && plugin.al.vanished.contains(player) && !plugin.al.isAdmin(sender))
if (player != null)
{
if (nullVanished && plugin.al.isVanished(player.getName()) && !plugin.al.isAdmin(sender))
{
return null;
}
}
return player;
}

View File

@ -49,6 +49,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class Discord extends FreedomService
{
public static HashMap<String, PlayerData> LINK_CODES = new HashMap<>();
public static HashMap<String, PlayerData> VERIFICATION_CODES = new HashMap<>();
public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR;
@ -252,15 +253,21 @@ public class Discord extends FreedomService
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
if (!plugin.al.isVanished(event.getPlayer().getName()))
{
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " joined the server" + "**");
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLeave(PlayerQuitEvent event)
{
if (!plugin.al.isVanished(event.getPlayer().getName()))
{
messageChatChannel("**" + deformat(event.getPlayer().getName()) + " left the server" + "**");
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event)

View File

@ -40,7 +40,7 @@ public class Module_list extends HTTPDModule
for (Player player : Bukkit.getOnlinePlayers())
{
if (plugin.al.vanished.contains(player))
if (plugin.al.isVanished(player.getName()))
{
continue;
}
@ -128,7 +128,7 @@ public class Module_list extends HTTPDModule
for (Player player : onlinePlayers)
{
if (plugin.al.vanished.contains(player))
if (plugin.al.isVanished(player.getName()))
{
continue;
}

View File

@ -36,7 +36,7 @@ public class Module_players extends HTTPDModule
// All online players
for (Player player : Bukkit.getOnlinePlayers())
{
if (!plugin.al.vanished.contains(player))
if (!plugin.al.isVanished(player.getName()))
{
players.add(player.getName());
if (plugin.al.isAdmin(player) && !plugin.al.isAdminImpostor(player))

View File

@ -249,9 +249,12 @@ public class RankManager extends FreedomService
// Broadcast login message
if (isAdmin || FUtil.isDeveloper(player.getName()) || plugin.pl.getData(player).isMasterBuilder() || plugin.pl.getData(player).isDonator())
{
if (!plugin.al.isVanished(player.getName()))
{
FUtil.bcastMsg(craftLoginMessage(player, null));
}
}
// Set display
updateDisplay(player);

View File

@ -52,10 +52,9 @@ public class FUtil
{
private static final Random RANDOM = new Random();
//
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "supernt", "Telesphoreo", "CoolJWB");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "supernt");
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
@ -146,7 +145,7 @@ public class FUtil
List<String> names = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers())
{
if (!TotalFreedomMod.plugin().al.vanished.contains(player))
if (!TotalFreedomMod.plugin().al.isVanished(player.getName()))
{
names.add(player.getName());
}