From e294ef8312ab0ed99ec747c2c052e6d0e4728200 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Thu, 13 Aug 2020 14:34:03 -0500 Subject: [PATCH] Reimplement vanish command - SuperVanish has a wack permission system, and it didn't work in some rare circumstances. Added back TFMs vanish with the SuperVanish API - Fixed the permission nodes so admins can see other admins, like how it was in TFM --- .../totalfreedommod/bridge/VanishBridge.java | 3 +- .../command/Command_permissions.java | 1 - .../command/Command_vanish.java | 44 +++++++++++++++++++ .../permissions/PermissionConfig.java | 5 --- .../permissions/PermissionManager.java | 2 - src/main/resources/permissions.yml | 2 +- src/main/resources/plugin.yml | 2 +- 7 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_vanish.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java index fd380598..097309b6 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/VanishBridge.java @@ -35,6 +35,7 @@ public class VanishBridge extends FreedomService } 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" + "**"); } @@ -53,7 +54,7 @@ public class VanishBridge extends FreedomService Player player = event.getPlayer(); if (event.isSilent()) { - plugin.al.messageAllAdmins(ChatColor.GOLD + player.getName() + " silently vanished."); + plugin.al.messageAllAdmins(ChatColor.GOLD + player.getName() + " vanished and is now only visible to admins."); } else { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java index d328cc6b..ecfa2477 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_permissions.java @@ -12,7 +12,6 @@ import org.bukkit.permissions.PermissionAttachmentInfo; @CommandParameters(description = "Check your permissions", usage = "/ [prefix | reload]") public class Command_permissions extends FreedomCommand { - @Override public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { 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 diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java index e1a004da..77ea542b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionConfig.java @@ -15,7 +15,6 @@ import org.bukkit.configuration.file.YamlConfiguration; public class PermissionConfig extends FreedomService { - public static final String PERMISSIONS_FILENAME = "permissions.yml"; // private final EnumMap entries; @@ -60,13 +59,11 @@ public class PermissionConfig extends FreedomService @Override public void onStart() { - } @Override public void onStop() { - } public void load() @@ -167,7 +164,6 @@ public class PermissionConfig extends FreedomService public static class PermissionDefaults { - private YamlConfiguration defaults = null; private PermissionDefaults(InputStream defaultConfig) @@ -190,5 +186,4 @@ public class PermissionConfig extends FreedomService return defaults.get(path); } } - } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java index 5ebc094d..06f2bb90 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/permissions/PermissionManager.java @@ -17,7 +17,6 @@ import org.bukkit.permissions.PermissionAttachmentInfo; public class PermissionManager extends FreedomService { - public Map> permissions = Maps.newHashMap(); public Map attachments = Maps.newHashMap(); @@ -35,7 +34,6 @@ public class PermissionManager extends FreedomService public void loadPermissionNodes() { - FLog.info("Loading permission nodes..."); permissions.clear(); diff --git a/src/main/resources/permissions.yml b/src/main/resources/permissions.yml index b1fa4aa5..bbfe3d96 100644 --- a/src/main/resources/permissions.yml +++ b/src/main/resources/permissions.yml @@ -211,7 +211,7 @@ super_admins: - "essentials.tphere" - "essentials.tpo" - "essentials.tpohere" - - "sv.use" + - "sv.see" - "sv.toggleitems" # Telnet Admin permission nodes diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1465512f..56e8e6eb 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,6 +2,6 @@ name: TotalFreedomMod main: me.totalfreedom.totalfreedommod.TotalFreedomMod version: ${project.version} description: Plugin for the Total Freedom server. -loadbefore: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit, WorldGuard, WorldGuardExtraFlags, TFGuilds] +loadbefore: [BukkitTelnet, Essentials, LibsDisguises, WorldEdit, WorldGuard, WorldGuardExtraFlags, TFGuilds, SuperVanish, PremiumVanish] authors: [Madgeek1450, Prozza] api-version: 1.16 \ No newline at end of file