From dffd9f8c3c5990ded4ff3517e15c192c42505e14 Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Sat, 3 Aug 2019 19:50:31 -0700 Subject: [PATCH] couldnt give it a better name --- .../totalfreedommod/TotalFreedomMod.java | 2 - .../totalfreedommod/admin/AdminList.java | 9 ++- .../command/Command_saconfig.java | 6 ++ .../command/Command_verifynoadmin.java | 78 +++++++++++++++++++ .../totalfreedommod/rank/RankManager.java | 10 +++ .../totalfreedommod/rank/Title.java | 1 + 6 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 4dc3c983..b8fc765d 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -112,7 +112,6 @@ public class TotalFreedomMod extends AeroPlugin public Monitors mo; public MovementValidator mv; public EntityWiper ew; - public FrontDoor fd; public ServerPing sp; public CurseListener cul; public ItemFun it; @@ -229,7 +228,6 @@ public class TotalFreedomMod extends AeroPlugin mv = services.registerService(MovementValidator.class); ew = services.registerService(EntityWiper.class); - fd = services.registerService(FrontDoor.class); sp = services.registerService(ServerPing.class); pv = services.registerService(PlayerVerification.class); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java index e4e3c343..b1ca3003 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java @@ -36,6 +36,8 @@ public class AdminList extends FreedomService private final Set activeAdmins = Sets.newHashSet(); private final Map nameTable = Maps.newHashMap(); private final Map ipTable = Maps.newHashMap(); + public final List verifiedNoAdmins = new ArrayList<>(); + public final Map> verifiedNoAdminIps = Maps.newHashMap(); // private final YamlConfig config; @@ -255,7 +257,12 @@ public class AdminList extends FreedomService public boolean isAdminImpostor(Player player) { - return getEntryByName(player.getName()) != null && !isAdmin(player); + return getEntryByName(player.getName()) != null && !isAdmin(player) && !isVerifiedAdmin(player); + } + + public boolean isVerifiedAdmin(Player player) + { + return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(Ips.getIp(player)); } public boolean isIdentityMatched(Player player) 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 6774b42c..76eca6bb 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -285,6 +285,12 @@ public class Command_saconfig extends FreedomCommand } } + if (plugin.al.isVerifiedAdmin(player)) + { + plugin.al.verifiedNoAdmins.remove(player.getName()); + plugin.al.verifiedNoAdminIps.remove(player.getName()); + } + plugin.al.save(); plugin.al.updateTables(); if (player != null) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java new file mode 100644 index 00000000..1348e4b2 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_verifynoadmin.java @@ -0,0 +1,78 @@ +package me.totalfreedom.totalfreedommod.command; + +import java.util.ArrayList; +import java.util.List; +import me.totalfreedom.totalfreedommod.player.FPlayer; +import me.totalfreedom.totalfreedommod.rank.Rank; +import me.totalfreedom.totalfreedommod.util.FUtil; +import net.pravian.aero.util.Ips; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH) +@CommandParameters(description = "Warns a player.", usage = "/ ", aliases = "vna") +public class Command_verifynoadmin extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length < 1) + { + return false; + } + + Player player = getPlayer(args[0]); + + if (player == null) + { + msg(PLAYER_NOT_FOUND); + return true; + } + + if (plugin.al.isAdminImpostor(player)) + { + if (!plugin.al.verifiedNoAdmins.contains(player.getName())) + { + plugin.al.verifiedNoAdmins.add(player.getName()); + } + String ip = Ips.getIp(player); + if (!plugin.al.verifiedNoAdminIps.containsKey(player.getName())) + { + List ips = new ArrayList<>(); + ips.add(ip); + plugin.al.verifiedNoAdminIps.put(player.getName(), ips); + } + else + { + List ips = plugin.al.verifiedNoAdminIps.get(player.getName()); + if (!ips.contains(ip)) + { + ips.add(ip); + plugin.al.verifiedNoAdmins.remove(player.getName()); + plugin.al.verifiedNoAdminIps.put(player.getName(), ips); + + } + } + plugin.rm.updateDisplay(player); + FUtil.adminAction(sender.getName(), "Verified " + player.getName() + ", but didn't give them admin permissions", true); + player.setOp(true); + player.sendMessage(YOU_ARE_OP); + final FPlayer fPlayer = plugin.pl.getPlayer(player); + if (fPlayer.getFreezeData().isFrozen()) + { + fPlayer.getFreezeData().setFrozen(false); + player.sendMessage(ChatColor.GRAY + "You have been unfrozen."); + } + msg("Verified " + player.getName() + " but didn't give them admin permissions", ChatColor.GREEN); + } + else + { + msg(player.getName() + " is not an admin imposter.", ChatColor.RED); + } + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java index a0520a7c..d40a64f3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java @@ -67,6 +67,11 @@ public class RankManager extends FreedomService return Title.EXECUTIVE; } + if (plugin.al.isVerifiedAdmin(player)) + { + return Title.VERIFIED_ADMIN; + } + // Master builders show up if they are not admins if (plugin.mbl.isMasterBuilder(player) && !plugin.al.isAdmin(player)) { @@ -170,6 +175,11 @@ public class RankManager extends FreedomService } } + if (plugin.al.isVerifiedAdmin(player)) + { + FUtil.bcastMsg("Warning: " + player.getName() + " is an admin, but does not have any admin permissions.", ChatColor.RED); + } + // Handle impostors boolean isImpostor = plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player); if (isImpostor) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java b/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java index 6b32bc77..978d5bf3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java @@ -7,6 +7,7 @@ public enum Title implements Displayable { MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB"), + VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA"), EXECUTIVE("an", "Executive", ChatColor.RED, "Exec"), DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev"), OWNER("the", "Owner", ChatColor.DARK_RED, "Owner");