From 5af45a21542826757286a718b8c419fb0e340885 Mon Sep 17 00:00:00 2001 From: Business Goose Date: Tue, 3 May 2022 09:44:36 +0100 Subject: [PATCH] Do the disabling in the admin class, so it works with commands like doom & also disable potion spy --- .../totalfreedommod/admin/Admin.java | 30 +++++++++++++++++++ .../command/Command_saconfig.java | 17 ----------- .../totalfreedommod/player/FPlayer.java | 8 +++++ .../totalfreedommod/rank/RankManager.java | 7 ++++- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java index 79f699bb..e90b3c5f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java @@ -6,11 +6,13 @@ import java.util.*; import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode; import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.player.FPlayer; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; +import org.bukkit.Server; import org.bukkit.entity.Player; public class Admin @@ -157,6 +159,34 @@ public class Admin { plugin.btb.killTelnetSessions(getName()); } + + // Ensure admins don't have admin functionality when removed (FS-222) + AdminList.vanished.remove(getName()); + + if (plugin.esb != null) + { + plugin.esb.setVanished(getName(), false); + } + + setCommandSpy(false); + setPotionSpy(false); + + Server server = Bukkit.getServer(); + Player player = server.getPlayer(getName()); + + if (player != null) + { + // Update chats + FPlayer freedomPlayer = plugin.pl.getPlayer(player); + freedomPlayer.removeAdminFunctionality(); + + // Disable vanish + for (Player player1 : server.getOnlinePlayers()) + { + player1.showPlayer(plugin, player); + } + } + } plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java index e9a70c45..78979d4e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -6,7 +6,6 @@ import java.util.Collections; import java.util.Date; 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.discord.Discord; import me.totalfreedom.totalfreedommod.player.FPlayer; @@ -242,7 +241,6 @@ public class Command_saconfig extends FreedomCommand Player player = getPlayer(args[1]); - FPlayer freedomPlayer = player != null ? plugin.pl.getPlayer(player) : null; Admin admin = player != null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]); String adminName = admin.getName(); @@ -258,24 +256,9 @@ public class Command_saconfig extends FreedomCommand plugin.al.save(admin); plugin.al.updateTables(); - AdminList.vanished.remove(adminName); - plugin.esb.setVanished(adminName, false); - if (player != null) { - // Update tab name plugin.rm.updateDisplay(player); - - // Ensure admins don't have admin functionality when removed (FS-222) - freedomPlayer.setAdminChat(false); - freedomPlayer.setCommandSpy(false); - freedomPlayer.setFuckoffRadius(0); - - // Disable vanish - for (Player player1 : server.getOnlinePlayers()) - { - player1.showPlayer(plugin, player); - } } if (plugin.dc.enabled && ConfigEntry.DISCORD_ROLE_SYNC.getBoolean()) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java index 603cd4af..002b16f9 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java @@ -112,6 +112,14 @@ public class FPlayer this.player = player; } + // Ensure admins don't have admin functionality when removed (FS-222) + public void removeAdminFunctionality() + { + this.setCommandSpy(false); + this.setAdminChat(false); + this.setFuckoffRadius(0); + } + public boolean isOrbiting() { return isOrbiting; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java index 9af8fe94..e1d07e1e 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java @@ -9,7 +9,6 @@ import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; -import org.bukkit.GameMode; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -185,6 +184,12 @@ public class RankManager extends FreedomService if (isAdmin) { plugin.al.updateLastLogin(player); + } else + { + // Ensure admins don't have admin functionality when removed (FS-222) + FPlayer freedomPlayer = plugin.pl.getPlayer(player); + + freedomPlayer.removeAdminFunctionality(); } // Broadcast login message