From e77d92407c0f1815faaa7b888e8b1bc6c195702b Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Sat, 15 Aug 2020 17:41:26 -0500 Subject: [PATCH] Revert "forgot to pull" This reverts commit e4c9ea656ee799c3820bf6feb5861dcfba1d64bb. --- .idea/misc.xml | 2 +- pom.xml | 13 +++ .../totalfreedommod/TotalFreedomMod.java | 5 +- .../totalfreedommod/VanishHandler.java | 83 ------------------- .../totalfreedommod/admin/AdminList.java | 6 +- .../totalfreedommod/bridge/VanishBridge.java | 64 ++++++++++++++ .../totalfreedommod/command/Command_list.java | 8 +- .../command/Command_vanish.java | 44 ++++++++++ 8 files changed, 132 insertions(+), 93 deletions(-) delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 982bac40..602a0ddb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -7,5 +7,5 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index da9c2b15..032257c0 100644 --- a/pom.xml +++ b/pom.xml @@ -140,6 +140,13 @@ compile + + com.github.MyzelYam + SuperVanish + 6.1.8 + provided + + org.spigotmc spigot @@ -202,6 +209,12 @@ provided + + me.rayzr522 + jsonmessage + 1.0.0 + + com.github.vexsoftware votifier diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 4760a4a3..6625e77a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -22,6 +22,7 @@ import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge; import me.totalfreedom.totalfreedommod.bridge.FAWEBridge; import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge; import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge; +import me.totalfreedom.totalfreedommod.bridge.VanishBridge; import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge; import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge; import me.totalfreedom.totalfreedommod.caging.Cager; @@ -136,7 +137,7 @@ public class TotalFreedomMod extends JavaPlugin public SignBlocker snp; public EntityWiper ew; public Sitter st; - public VanishHandler vh; + public VanishBridge vb; public AMP amp; //public HubWorldRestrictions hwr; @@ -235,7 +236,7 @@ public class TotalFreedomMod extends JavaPlugin snp = new SignBlocker(); ew = new EntityWiper(); st = new Sitter(); - vh = new VanishHandler(); + vb = new VanishBridge(); amp = new AMP(); // Single admin utils diff --git a/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java b/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java deleted file mode 100644 index 7d1e586d..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/VanishHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -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."); - } - } -} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java index 8d2f5b54..2b4d6c61 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.admin; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import de.myzelyam.api.vanish.VanishAPI; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -31,7 +32,6 @@ public class AdminList extends FreedomService private final Map ipTable = Maps.newHashMap(); public final List verifiedNoAdmins = new ArrayList<>(); public final Map> verifiedNoAdminIps = Maps.newHashMap(); - public static List vanished = new ArrayList<>(); @Override public void onStart() @@ -363,8 +363,8 @@ public class AdminList extends FreedomService updateTables(); } - public boolean isVanished(String player) + public boolean isVanished(Player player) { - return vanished.contains(player); + return VanishAPI.isInvisible(player); } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java new file mode 100644 index 00000000..097309b6 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java @@ -0,0 +1,64 @@ +package me.totalfreedom.totalfreedommod.bridge; + +import de.myzelyam.api.vanish.PlayerHideEvent; +import de.myzelyam.api.vanish.PlayerShowEvent; +import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.player.PlayerData; +import me.totalfreedom.totalfreedommod.rank.Displayable; +import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class VanishBridge extends FreedomService +{ + @Override + public void onStart() + { + } + + @Override + public void onStop() + { + } + + @EventHandler + public void onPlayerUnvanish(PlayerShowEvent event) + { + Player player = event.getPlayer(); + Displayable display = plugin.rm.getDisplay(player); + String tag = display.getColoredTag(); + + if (event.isSilent()) + { + plugin.al.messageAllAdmins(ChatColor.GOLD + player.getName() + " silently unvanished."); + } + else + { + plugin.al.messageAllAdmins(ChatColor.GOLD + player.getName() + " unvanished and is now visible to all players."); + FUtil.bcastMsg(plugin.rm.craftLoginMessage(event.getPlayer(), null)); + plugin.dc.messageChatChannel("**" + player.getName() + " joined the server" + "**"); + } + + PlayerData playerData = plugin.pl.getData(player); + if (playerData.getTag() != null) + { + tag = FUtil.colorize(playerData.getTag()); + } + playerData.setTag(tag); + } + + @EventHandler + public void onPlayerVanish(PlayerHideEvent event) + { + Player player = event.getPlayer(); + if (event.isSilent()) + { + plugin.al.messageAllAdmins(ChatColor.GOLD + player.getName() + " vanished and is now only visible to admins."); + } + else + { + plugin.dc.messageChatChannel("**" + player.getName() + " left the server" + "**"); + } + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java index d2ee0af0..a3ab50d4 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java @@ -1,9 +1,9 @@ package me.totalfreedom.totalfreedommod.command; +import de.myzelyam.api.vanish.VanishAPI; import java.util.ArrayList; import java.util.List; import me.totalfreedom.totalfreedommod.admin.Admin; -import me.totalfreedom.totalfreedommod.admin.AdminList; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.rank.Displayable; import me.totalfreedom.totalfreedommod.rank.Rank; @@ -96,7 +96,7 @@ public class Command_list extends FreedomCommand } else { - onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - AdminList.vanished.size()) + onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().size() - VanishAPI.getInvisiblePlayers().size()) .append(ChatColor.BLUE) .append(" out of a maximum ") .append(ChatColor.RED) @@ -109,11 +109,11 @@ public class Command_list extends FreedomCommand { continue; } - if (listFilter == ListFilter.ADMINS && plugin.al.isVanished(p.getName())) + if (listFilter == ListFilter.ADMINS && plugin.al.isVanished(p)) { continue; } - if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.isVanished(p.getName())) + if (listFilter == ListFilter.VANISHED_ADMINS && !plugin.al.isVanished(p)) { continue; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java new file mode 100644 index 00000000..4a20ae47 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java @@ -0,0 +1,44 @@ +package me.totalfreedom.totalfreedommod.command; + +import de.myzelyam.api.vanish.VanishAPI; +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Hide yourself from other players", usage = "/ [-s]", aliases = "v,ev,evanish") +public class Command_vanish extends FreedomCommand +{ + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length == 0) + { + if (!VanishAPI.isInvisible(playerSender)) + { + VanishAPI.hidePlayer(playerSender); + } + else + { + VanishAPI.showPlayer(playerSender); + } + } + else if (args[0].equalsIgnoreCase("-s") || args[0].equalsIgnoreCase("-v")) + { + if (!VanishAPI.isInvisible(playerSender)) + { + VanishAPI.getPlugin().getVisibilityChanger().hidePlayer(playerSender, null, true); + } + else + { + VanishAPI.getPlugin().getVisibilityChanger().showPlayer(playerSender, null, true); + } + } + else + { + return false; + } + return true; + } +} \ No newline at end of file