[Bleeding] Switched to UUIDs in TFM_AdminList

Various other changes
This commit is contained in:
unknown 2014-04-09 22:33:03 +02:00
parent ec8a528564
commit a54c113a86
42 changed files with 317 additions and 326 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Apr 09 20:26:09 CEST 2014
build.number=712
#Wed Apr 09 22:31:37 CEST 2014
build.number=713

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -31,7 +31,7 @@ public class Command_adminmode extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
player.kickPlayer("Server is now closed to non-superadmins.");
}

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.World;
@ -217,7 +217,7 @@ public class Command_adminworld extends TFM_Command
private void assertCommandPerms(CommandSender sender, Player sender_p) throws PermissionDeniedException
{
if (!(sender instanceof Player) || sender_p == null || !TFM_SuperadminList.isSuperAdmin(sender))
if (!(sender instanceof Player) || sender_p == null || !TFM_AdminList.isSuperAdmin(sender))
{
throw new PermissionDeniedException(TotalFreedomMod.MSG_NO_PERMS);
}

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
@ -47,7 +47,7 @@ public class Command_blockcmd extends TFM_Command
return true;
}
if (TFM_SuperadminList.isSuperAdmin(player))
if (TFM_AdminList.isSuperAdmin(player))
{
playerMsg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
return true;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart;
@ -36,7 +36,7 @@ public class Command_cartsit extends TFM_Command
return true;
}
}
else if (targetPlayer != sender_p && !TFM_SuperadminList.isSuperAdmin(sender))
else if (targetPlayer != sender_p && !TFM_AdminList.isSuperAdmin(sender))
{
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
return true;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.GameMode;
@ -33,7 +33,7 @@ public class Command_creative extends TFM_Command
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -48,7 +48,7 @@ public class Command_creative extends TFM_Command
return true;
}
if (!(senderIsConsole || TFM_SuperadminList.isSuperAdmin(sender)))
if (!(senderIsConsole || TFM_AdminList.isSuperAdmin(sender)))
{
playerMsg("Only superadmins can change other user's gamemode.");
return true;

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -39,10 +39,10 @@ public class Command_doom extends TFM_Command
final String IP = player.getAddress().getAddress().getHostAddress().trim();
// remove from superadmin
if (TFM_SuperadminList.isSuperAdmin(player))
if (TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list.", true);
TFM_SuperadminList.removeSuperadmin(player);
TFM_AdminList.removeSuperadmin(player);
}
// remove from whitelist

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
@ -44,7 +44,7 @@ public class Command_fr extends TFM_Command
playerMsg("Players are now frozen.");
for (Player player : Bukkit.getOnlinePlayers())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.playerMsg(player, "You have been frozen due to rule breaker(s), you will be unfrozen very soon.", ChatColor.RED);
}

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerList.PlayerEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
@ -29,7 +29,7 @@ public class Command_glist extends TFM_Command
if (args[0].equalsIgnoreCase("purge"))
{
//Purge does not clear the banlist! This is not for clearing bans! This is for clearing the yaml file that stores the player/IP database!
if (TFM_SuperadminList.isSeniorAdmin(sender))
if (TFM_AdminList.isSeniorAdmin(sender))
{
TFM_PlayerList.getInstance().purgeAll();
}

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -25,7 +25,7 @@ public class Command_halt extends TFM_Command
int counter = 0;
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
TFM_PlayerData.getPlayerData(player).setHalted(true);
counter++;

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
@ -38,7 +38,7 @@ public class Command_invis extends TFM_Command
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(player.getName());
if (smite && !TFM_SuperadminList.isSuperAdmin(player))
if (smite && !TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.adminAction(sender.getName(), "Smiting all invisible players", true);
player.setHealth(0.0);

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -18,7 +18,7 @@ public class Command_kicknoob extends TFM_Command
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
player.kickPlayer(ChatColor.RED + "Disconnected by admin.");
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.apache.commons.lang.StringUtils;
@ -55,7 +55,7 @@ public class Command_list extends TFM_Command
final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers())
{
final boolean userSuperadmin = TFM_SuperadminList.isSuperAdmin(player);
final boolean userSuperadmin = TFM_AdminList.isSuperAdmin(player);
if (listFilter == Command_list.ListFilter.ADMINS && !userSuperadmin)
{

View File

@ -113,7 +113,7 @@ public class Command_logs extends TFM_Command
{
for (String ip : superadmin.getIps())
{
updateLogsRegistration(null, superadmin.getName(), ip, Command_logs.LogsRegistrationMode.DELETE);
updateLogsRegistration(null, superadmin.getLastLoginName(), ip, Command_logs.LogsRegistrationMode.DELETE);
}
}

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
@ -26,7 +26,7 @@ public class Command_onlinemode extends TFM_Command
{
boolean online_mode;
if (sender instanceof Player && !TFM_SuperadminList.isSeniorAdmin(sender, true))
if (sender instanceof Player && !TFM_AdminList.isSeniorAdmin(sender, true))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@ -38,7 +38,7 @@ public class Command_op extends TFM_Command
// if the player is not online
if (player == null)
{
if (TFM_SuperadminList.isSuperAdmin(sender) || senderIsConsole)
if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole)
{
player = server.getOfflinePlayer(args[0]);
}

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
@ -38,7 +38,7 @@ public class Command_potion extends TFM_Command
}
else if (args[0].equalsIgnoreCase("clearall"))
{
if (!(TFM_SuperadminList.isSuperAdmin(sender) || senderIsConsole))
if (!(TFM_AdminList.isSuperAdmin(sender) || senderIsConsole))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -71,7 +71,7 @@ public class Command_potion extends TFM_Command
if (!target.equals(sender_p))
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg("Only superadmins can clear potion effects from other players.");
return true;
@ -116,7 +116,7 @@ public class Command_potion extends TFM_Command
if (!target.equals(sender_p))
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
sender.sendMessage("Only superadmins can apply potion effects to other players.");
return true;

View File

@ -2,11 +2,12 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -23,11 +24,11 @@ public class Command_saconfig extends TFM_Command
{
if (args[0].equals("list"))
{
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminUUIDs(), ", "), ChatColor.GOLD);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminUUIDs(), ", "), ChatColor.GOLD);
}
else
{
if (!TFM_SuperadminList.isSeniorAdmin(sender, true))
if (!TFM_AdminList.isSeniorAdmin(sender, true))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -36,8 +37,8 @@ public class Command_saconfig extends TFM_Command
if (args[0].equals("clean"))
{
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list", true);
TFM_SuperadminList.cleanSuperadminList(true);
playerMsg("Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminUUIDs(), ", "), ChatColor.YELLOW);
TFM_AdminList.cleanSuperadminList(true);
playerMsg("Superadmins: " + StringUtils.join(TFM_AdminList.getSuperadminUUIDs(), ", "), ChatColor.YELLOW);
}
else
{
@ -53,19 +54,19 @@ public class Command_saconfig extends TFM_Command
{
if (args[0].equalsIgnoreCase("info"))
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
TFM_Admin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
TFM_Admin superadmin = TFM_AdminList.getAdminEntry(args[1].toLowerCase());
if (superadmin == null)
{
try
{
superadmin = TFM_SuperadminList.getAdminEntry(getPlayer(args[1]).getName().toLowerCase());
superadmin = TFM_AdminList.getAdminEntry(getPlayer(args[1]).getName().toLowerCase());
}
catch (PlayerNotFoundException ex)
{
@ -93,7 +94,7 @@ public class Command_saconfig extends TFM_Command
if (args[0].equalsIgnoreCase("add"))
{
Player player = null;
String admin_name = null;
String playername = null;
try
{
@ -101,10 +102,10 @@ public class Command_saconfig extends TFM_Command
}
catch (PlayerNotFoundException ex)
{
TFM_Admin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
TFM_Admin superadmin = TFM_AdminList.getAdminEntry(args[1].toLowerCase());
if (superadmin != null)
{
admin_name = superadmin.getName();
playername = superadmin.getLastLoginName();
}
else
{
@ -116,17 +117,17 @@ public class Command_saconfig extends TFM_Command
if (player != null)
{
TFM_Util.adminAction(sender.getName(), "Adding " + player.getName() + " to the superadmin list.", true);
TFM_SuperadminList.addSuperadmin(player);
TFM_AdminList.addSuperadmin(player);
}
else if (admin_name != null)
else if (playername != null)
{
TFM_Util.adminAction(sender.getName(), "Adding " + admin_name + " to the superadmin list.", true);
TFM_SuperadminList.addSuperadmin(admin_name);
TFM_Util.adminAction(sender.getName(), "Adding " + playername + " to the superadmin list.", true);
TFM_AdminList.addSuperadmin(player);
}
}
else if (TFM_Util.isRemoveCommand(args[0]))
{
if (!TFM_SuperadminList.isSeniorAdmin(sender))
if (!TFM_AdminList.isSeniorAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -142,14 +143,14 @@ public class Command_saconfig extends TFM_Command
{
}
if (!TFM_SuperadminList.getSuperadminUUIDs().contains(targetName.toLowerCase()))
if (!TFM_AdminList.getSuperadminUUIDs().contains(targetName.toLowerCase()))
{
playerMsg("Superadmin not found: " + targetName);
return true;
}
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
TFM_SuperadminList.removeSuperadmin(targetName);
TFM_AdminList.removeSuperadmin(Bukkit.getOfflinePlayer(targetName));
// Twitterbot
if (TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
@ -68,7 +68,7 @@ public class Command_stfu extends TFM_Command
int counter = 0;
for (Player player : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setMuted(true);
@ -118,7 +118,7 @@ public class Command_stfu extends TFM_Command
}
else
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.adminAction(sender.getName(), "Muting " + player.getName(), true);
playerdata.setMuted(true);

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
@ -35,7 +35,7 @@ public class Command_survival extends TFM_Command
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isSuperAdmin(sender) || senderIsConsole)
if (!TFM_AdminList.isSuperAdmin(sender) || senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -50,7 +50,7 @@ public class Command_survival extends TFM_Command
return true;
}
if (senderIsConsole || TFM_SuperadminList.isSuperAdmin(sender))
if (senderIsConsole || TFM_AdminList.isSuperAdmin(sender))
{
try
{

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
@ -27,7 +27,7 @@ public class Command_tag extends TFM_Command
{
if ("clearall".equals(args[0]))
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;
@ -69,7 +69,7 @@ public class Command_tag extends TFM_Command
return true;
}
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
for (String word : FORBIDDEN_WORDS)
{
@ -98,7 +98,7 @@ public class Command_tag extends TFM_Command
{
if ("clear".equals(args[0]))
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
playerMsg(TotalFreedomMod.MSG_NO_PERMS);
return true;

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@ -21,7 +21,7 @@ public class Command_tfbanlist extends TFM_Command
{
if (args[0].equalsIgnoreCase("purge"))
{
if (senderIsConsole || TFM_SuperadminList.isSuperAdmin(sender))
if (senderIsConsole || TFM_AdminList.isSuperAdmin(sender))
{
try
{

View File

@ -5,7 +5,7 @@ import java.util.Collections;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -22,7 +22,7 @@ public class Command_tfipbanlist extends TFM_Command
{
if (args[0].equalsIgnoreCase("purge"))
{
if (senderIsConsole || TFM_SuperadminList.isSuperAdmin(sender))
if (senderIsConsole || TFM_AdminList.isSuperAdmin(sender))
{
try
{

View File

@ -1,7 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.OfflinePlayer;
@ -56,7 +56,7 @@ public class Command_whitelist extends TFM_Command
}
// all commands past this line are superadmin-only
if (!(senderIsConsole || TFM_SuperadminList.isSuperAdmin(sender)))
if (!(senderIsConsole || TFM_AdminList.isSuperAdmin(sender)))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;

View File

@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -57,7 +57,7 @@ public class Command_whohas extends TFM_Command
if (player.getInventory().contains(material))
{
players.add(player.getName());
if (smite & !TFM_SuperadminList.isSuperAdmin(player))
if (smite & !TFM_AdminList.isSuperAdmin(player))
{
Command_smite.smite(player);
}

View File

@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
@ -62,11 +62,11 @@ public abstract class TFM_Command
CommandPermissions permissions = commandClass.getAnnotation(CommandPermissions.class);
if (permissions != null)
{
boolean is_super = TFM_SuperadminList.isSuperAdmin(this.commandSender);
boolean is_super = TFM_AdminList.isSuperAdmin(this.commandSender);
boolean is_senior = false;
if (is_super)
{
is_senior = TFM_SuperadminList.isSeniorAdmin(this.commandSender);
is_senior = TFM_AdminList.isSeniorAdmin(this.commandSender);
}
AdminLevel level = permissions.level();

View File

@ -1,6 +1,6 @@
package me.StevenLawson.TotalFreedomMod.HTTPD;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -26,9 +26,9 @@ public class Module_list extends TFM_HTTPD_Module
for (Player player : onlinePlayers)
{
String prefix = "";
if (TFM_SuperadminList.isSuperAdmin(player))
if (TFM_AdminList.isSuperAdmin(player))
{
if (TFM_SuperadminList.isSeniorAdmin(player))
if (TFM_AdminList.isSeniorAdmin(player))
{
prefix = "[SrA]";
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.HTTPD;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import java.util.UUID;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
@ -34,14 +35,14 @@ public class Module_players extends TFM_HTTPD_Module
}
// Super admins (non-telnet and non-senior)
for (String superadmin : TFM_SuperadminList.getSuperadminUUIDs())
for (UUID superadmin : TFM_AdminList.getSuperadminUUIDs())
{
if (TFM_SuperadminList.getSenioradminUUIDs().contains(superadmin))
if (TFM_AdminList.getSenioradminUUIDs().contains(superadmin))
{
continue;
}
if (TFM_SuperadminList.getTelnetadminUUIDs().contains(superadmin))
if (TFM_AdminList.getTelnetadminUUIDs().contains(superadmin))
{
continue;
}
@ -50,9 +51,9 @@ public class Module_players extends TFM_HTTPD_Module
}
// Telnet admins (non-senior)
for (String telnetadmin : TFM_SuperadminList.getTelnetadminUUIDs())
for (UUID telnetadmin : TFM_AdminList.getTelnetadminUUIDs())
{
if (TFM_SuperadminList.getSenioradminUUIDs().contains(telnetadmin))
if (TFM_AdminList.getSenioradminUUIDs().contains(telnetadmin))
{
continue;
}
@ -60,7 +61,7 @@ public class Module_players extends TFM_HTTPD_Module
}
// Senior admins
for (String senioradmin : TFM_SuperadminList.getSenioradminUUIDs())
for (UUID senioradmin : TFM_AdminList.getSenioradminUUIDs())
{
senioradmins.add(getName(senioradmin));
}
@ -79,16 +80,8 @@ public class Module_players extends TFM_HTTPD_Module
return response;
}
private String getName(String caseInsensitiveName)
private String getName(UUID uuid)
{
final OfflinePlayer player = Bukkit.getOfflinePlayer(caseInsensitiveName);
if (player == null)
{
return caseInsensitiveName;
}
else
{
return player.getName();
}
return TFM_AdminList.getAdminEntry(uuid).getLastLoginName();
}
}

View File

@ -13,7 +13,7 @@ import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Method;
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Response;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import net.minecraft.util.org.apache.commons.io.FileUtils;
import net.minecraft.util.org.apache.commons.lang3.StringEscapeUtils;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
@ -223,7 +223,7 @@ public class Module_schematic extends TFM_HTTPD_Module
private boolean isAuthorized(String remoteAddress)
{
TFM_Admin entry = TFM_SuperadminList.getAdminEntryByIP(remoteAddress);
TFM_Admin entry = TFM_AdminList.getAdminEntryByIP(remoteAddress);
return entry != null && entry.isActivated();
}

View File

@ -91,7 +91,7 @@ public class TFM_BlockListener implements Listener
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
if (TFM_ProtectedArea.isInProtectedArea(blockLocation))
{
@ -161,7 +161,7 @@ public class TFM_BlockListener implements Listener
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
if (TFM_ProtectedArea.isInProtectedArea(blockLocation))
{
@ -249,7 +249,7 @@ public class TFM_BlockListener implements Listener
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRollbackBlockBreak(BlockBreakEvent event)
{
if (!TFM_SuperadminList.isSuperAdmin(event.getPlayer()))
if (!TFM_AdminList.isSuperAdmin(event.getPlayer()))
{
TFM_RollbackManager.blockBreak(event);
}
@ -258,7 +258,7 @@ public class TFM_BlockListener implements Listener
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRollbackBlockPlace(BlockPlaceEvent event)
{
if (!TFM_SuperadminList.isSuperAdmin(event.getPlayer()))
if (!TFM_AdminList.isSuperAdmin(event.getPlayer()))
{
TFM_RollbackManager.blockPlace(event);
}

View File

@ -97,7 +97,7 @@ public class TFM_PlayerListener implements Listener
{
case STICK:
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
break;
}
@ -167,7 +167,7 @@ public class TFM_PlayerListener implements Listener
break;
}
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
if (!TFM_AdminList.isSeniorAdmin(player, true))
{
break;
}
@ -203,7 +203,7 @@ public class TFM_PlayerListener implements Listener
break;
}
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
if (!TFM_AdminList.isSeniorAdmin(player, true))
{
break;
}
@ -331,7 +331,7 @@ public class TFM_PlayerListener implements Listener
boolean freeze = false;
if (TotalFreedomMod.allPlayersFrozen)
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
freeze = true;
}
@ -490,7 +490,7 @@ public class TFM_PlayerListener implements Listener
// Check for muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
player.sendMessage(ChatColor.RED + "You are muted, STFU!");
event.setCancelled(true);
@ -583,7 +583,7 @@ public class TFM_PlayerListener implements Listener
// Block commands if player is muted
if (playerdata.isMuted())
{
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
for (String commandName : BLOCKED_MUTED_CMDS)
{
@ -615,11 +615,11 @@ public class TFM_PlayerListener implements Listener
event.setCancelled(true);
}
if (!TFM_SuperadminList.isSuperAdmin(player))
if (!TFM_AdminList.isSuperAdmin(player))
{
for (Player pl : Bukkit.getOnlinePlayers())
{
if (TFM_SuperadminList.isSuperAdmin(pl) && TFM_PlayerData.getPlayerData(pl).cmdspyEnabled())
if (TFM_AdminList.isSuperAdmin(pl) && TFM_PlayerData.getPlayerData(pl).cmdspyEnabled())
{
TFM_Util.playerMsg(pl, player.getName() + ": " + command);
}
@ -709,9 +709,9 @@ public class TFM_PlayerListener implements Listener
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
playerdata.setSuperadminIdVerified(null);
final boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player);
final boolean impostor = TFM_AdminList.isAdminImpostor(player);
if (impostor || TFM_SuperadminList.isSuperAdmin(player))
if (impostor || TFM_AdminList.isSuperAdmin(player))
{
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
@ -724,11 +724,11 @@ public class TFM_PlayerListener implements Listener
}
else
{
if (TFM_SuperadminList.verifyIdentity(player.getName(), TFM_Util.getIp(player)))
if (TFM_AdminList.verifyIdentity(player.getName(), TFM_Util.getIp(player)))
{
playerdata.setSuperadminIdVerified(Boolean.TRUE);
TFM_SuperadminList.updateLastLogin(player);
TFM_AdminList.updateLastLogin(player);
}
else
{

View File

@ -4,7 +4,7 @@ import me.StevenLawson.BukkitTelnet.api.TelnetCommandEvent;
import me.StevenLawson.BukkitTelnet.api.TelnetPreLoginEvent;
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler;
@ -23,7 +23,7 @@ public class TFM_TelnetListener implements Listener
return;
}
final TFM_Admin admin = TFM_SuperadminList.getAdminEntryByIP(ip, true);
final TFM_Admin admin = TFM_AdminList.getAdminEntryByIP(ip, true);
if (admin == null || !(admin.isTelnetAdmin() || admin.isSeniorAdmin()))
{
@ -31,9 +31,9 @@ public class TFM_TelnetListener implements Listener
}
event.setBypassPassword(true);
event.setName(admin.getName());
event.setName(admin.getLastLoginName());
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin.getName());
final OfflinePlayer player = Bukkit.getOfflinePlayer(admin.getLastLoginName());
if (player == null)
{
return;

View File

@ -3,12 +3,14 @@ package me.StevenLawson.TotalFreedomMod;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.bukkit.configuration.ConfigurationSection;
public class TFM_Admin
{
private final String name;
private final UUID uuid;
private String lastLoginName;
private final String loginMessage;
private final boolean isSeniorAdmin;
private final boolean isTelnetAdmin;
@ -17,9 +19,10 @@ public class TFM_Admin
private Date lastLogin;
private boolean isActivated;
public TFM_Admin(String name, List<String> ips, Date lastLogin, String loginMessage, boolean isSeniorAdmin, boolean isTelnetAdmin, List<String> consoleAliases, boolean isActivated)
public TFM_Admin(UUID uuid, String lastLoginName, List<String> ips, Date lastLogin, String loginMessage, boolean isSeniorAdmin, boolean isTelnetAdmin, List<String> consoleAliases, boolean isActivated)
{
this.name = name.toLowerCase();
this.uuid = uuid;
this.lastLoginName = lastLoginName;
this.ips = ips;
this.lastLogin = lastLogin;
this.loginMessage = loginMessage;
@ -29,9 +32,10 @@ public class TFM_Admin
this.isActivated = isActivated;
}
public TFM_Admin(String name, ConfigurationSection section)
public TFM_Admin(UUID uuid, ConfigurationSection section)
{
this.name = name.toLowerCase();
this.uuid = uuid;
this.lastLoginName = section.getString("last_login_name");
this.ips = section.getStringList("ips");
this.lastLogin = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L))));
this.loginMessage = section.getString("custom_login_message", "");
@ -44,30 +48,34 @@ public class TFM_Admin
@Override
public String toString()
{
StringBuilder output = new StringBuilder();
final StringBuilder output = new StringBuilder();
try
{
output.append("Name: ").append(this.name).append("\n");
output.append("- IPs: ").append(StringUtils.join(this.ips, ", ")).append("\n");
output.append("- Last Login: ").append(TFM_Util.dateToString(this.lastLogin)).append("\n");
output.append("- Custom Login Message: ").append(this.loginMessage).append("\n");
output.append("- Is Senior Admin: ").append(this.isSeniorAdmin).append("\n");
output.append("- Is Telnet Admin: ").append(this.isTelnetAdmin).append("\n");
output.append("- Console Aliases: ").append(StringUtils.join(this.consoleAliases, ", ")).append("\n");
output.append("- Is Activated: ").append(this.isActivated);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
output.append("UUID: ").append(uuid.toString()).append("\n");
output.append("- Last Login Name: ").append(lastLoginName).append("\n");
output.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n");
output.append("- Last Login: ").append(TFM_Util.dateToString(lastLogin)).append("\n");
output.append("- Custom Login Message: ").append(loginMessage).append("\n");
output.append("- Is Senior Admin: ").append(isSeniorAdmin).append("\n");
output.append("- Is Telnet Admin: ").append(isTelnetAdmin).append("\n");
output.append("- Console Aliases: ").append(StringUtils.join(consoleAliases, ", ")).append("\n");
output.append("- Is Activated: ").append(isActivated);
return output.toString();
}
public String getName()
public UUID getUniqueId()
{
return name;
return uuid;
}
public void setLastLoginName(String lastLoginName)
{
this.lastLoginName = lastLoginName;
}
public String getLastLoginName()
{
return lastLoginName;
}
public List<String> getIps()
@ -75,6 +83,14 @@ public class TFM_Admin
return Collections.unmodifiableList(ips);
}
public void addIp(String ip)
{
if (!ips.contains(ip))
{
ips.add(ip);
}
}
public Date getLastLogin()
{
return lastLogin;
@ -97,7 +113,7 @@ public class TFM_Admin
public List<String> getConsoleAliases()
{
return consoleAliases;
return Collections.unmodifiableList(consoleAliases);
}
public void setLastLogin(Date lastLogin)

View File

@ -16,6 +16,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import me.StevenLawson.TotalFreedomMod.Commands.Command_logs;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
@ -23,9 +24,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.util.FileUtil;
public class TFM_SuperadminList
public class TFM_AdminList
{
private static final Map<UUID, TFM_Admin> superadminList;
private static final Map<UUID, TFM_Admin> adminList;
private static final Set<UUID> superadminUUIDs;
private static final Set<UUID> telnetadminUUIDs;
private static final Set<UUID> senioradminUUIDs;
@ -35,7 +36,7 @@ public class TFM_SuperadminList
static
{
superadminList = new HashMap<UUID, TFM_Admin>();
adminList = new HashMap<UUID, TFM_Admin>();
superadminUUIDs = new HashSet<UUID>();
telnetadminUUIDs = new HashSet<UUID>();
senioradminUUIDs = new HashSet<UUID>();
@ -43,7 +44,7 @@ public class TFM_SuperadminList
superadminIps = new HashSet<String>();
}
private TFM_SuperadminList()
private TFM_AdminList()
{
throw new AssertionError();
}
@ -82,7 +83,7 @@ public class TFM_SuperadminList
{
try
{
superadminList.clear();
adminList.clear();
TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE);
@ -114,7 +115,7 @@ public class TFM_SuperadminList
final UUID uuid = UUID.fromString(uuidString);
final TFM_Admin superadmin = new TFM_Admin(uuid, section.getConfigurationSection(uuidString));
superadminList.put(uuid, superadmin);
adminList.put(uuid, superadmin);
}
updateIndexLists();
@ -140,7 +141,7 @@ public class TFM_SuperadminList
senioradminAliases.clear();
superadminIps.clear();
final Iterator<Entry<UUID, TFM_Admin>> it = superadminList.entrySet().iterator();
final Iterator<Entry<UUID, TFM_Admin>> it = adminList.entrySet().iterator();
while (it.hasNext())
{
final Entry<UUID, TFM_Admin> pair = it.next();
@ -187,7 +188,7 @@ public class TFM_SuperadminList
config.set("clean_threshold_hours", cleanThreshold);
Iterator<Entry<UUID, TFM_Admin>> it = superadminList.entrySet().iterator();
Iterator<Entry<UUID, TFM_Admin>> it = adminList.entrySet().iterator();
while (it.hasNext())
{
Entry<UUID, TFM_Admin> pair = it.next();
@ -219,35 +220,28 @@ public class TFM_SuperadminList
if (Bukkit.getOnlineMode())
{
if (superadminList.containsKey(uuid))
if (adminList.containsKey(uuid))
{
return superadminList.get(uuid);
return adminList.get(uuid);
}
}
try
{
final String ip = player.getAddress().getAddress().getHostAddress().trim();
if (ip != null && !ip.isEmpty())
{
return getAdminEntryByIP(ip);
}
}
catch (Exception ex)
{
return null;
}
return null;
return getAdminEntryByIP(TFM_Util.getIp(player));
}
public static TFM_Admin getAdminEntry(UUID uuid)
{
return adminList.get(uuid);
}
@Deprecated
public static TFM_Admin getAdminEntry(String name)
{
for (UUID uuid : superadminList.keySet())
for (UUID uuid : adminList.keySet())
{
if (superadminList.get(uuid).getLastLoginName().equalsIgnoreCase(name))
if (adminList.get(uuid).getLastLoginName().equalsIgnoreCase(name))
{
return superadminList.get(uuid);
return adminList.get(uuid);
}
}
return null;
@ -260,16 +254,17 @@ public class TFM_SuperadminList
public static TFM_Admin getAdminEntryByIP(String needleIp, boolean fuzzy)
{
Iterator<Entry<UUID, TFM_Admin>> it = superadminList.entrySet().iterator();
Iterator<Entry<UUID, TFM_Admin>> it = adminList.entrySet().iterator();
while (it.hasNext())
{
Entry<UUID, TFM_Admin> pair = it.next();
TFM_Admin superadmin = pair.getValue();
final Entry<UUID, TFM_Admin> pair = it.next();
final TFM_Admin superadmin = pair.getValue();
if (fuzzy)
{
for (String haystackIP : superadmin.getIps())
for (String haystackIp : superadmin.getIps())
{
if (TFM_Util.fuzzyIpMatch(needleIp, haystackIP, 3))
if (TFM_Util.fuzzyIpMatch(needleIp, haystackIp, 3))
{
return superadmin;
}
@ -288,10 +283,11 @@ public class TFM_SuperadminList
public static void updateLastLogin(Player player)
{
TFM_Admin admin_entry = getAdminEntry(player);
if (admin_entry != null)
final TFM_Admin admin = getAdminEntry(player);
if (admin != null)
{
admin_entry.setLastLogin(new Date());
admin.setLastLogin(new Date());
admin.setLastLoginName(player.getName());
saveSuperadminList();
}
}
@ -341,63 +337,55 @@ public class TFM_SuperadminList
}
}
try
if (superadminIps.contains(TFM_Util.getIp((Player) sender)))
{
final String ip = TFM_Util.getIp((Player) sender);
if (ip != null && !ip.isEmpty())
{
if (superadminIps.contains(ip))
{
return true;
}
}
}
catch (RuntimeException ex)
{
return false;
return true;
}
return false;
}
@Deprecated
public static boolean checkPartialSuperadminIP(String ip, String name)
{
ip = ip.trim();
if (superadminIps.contains(ip))
{
return true;
}
try
{
ip = ip.trim();
if (superadminIps.contains(ip))
String matchIp = null;
for (String testIp : superadminIps)
{
return true;
}
else
{
String matchIp = null;
for (String testIp : getSuperadminIps())
if (TFM_Util.fuzzyIpMatch(ip, testIp, 3))
{
if (TFM_Util.fuzzyIpMatch(ip, testIp, 3))
{
matchIp = testIp;
break;
}
matchIp = testIp;
break;
}
}
if (matchIp != null)
if (matchIp != null)
{
final TFM_Admin entry = getAdminEntryByIP(matchIp);
if (entry == null)
{
TFM_Admin entry = getAdminEntryByIP(matchIp);
if (entry != null)
{
if (entry.getName().equalsIgnoreCase(name))
{
List<String> ips = entry.getIps();
ips.add(ip);
saveSuperadminList();
}
}
return true;
}
if (entry.getLastLoginName().equalsIgnoreCase(name))
{
if (!entry.getIps().contains(ip))
{
entry.addIp(ip);
}
saveSuperadminList();
}
return true;
}
}
catch (Exception ex)
@ -408,16 +396,9 @@ public class TFM_SuperadminList
return false;
}
public static boolean isSuperadminImpostor(CommandSender user)
public static boolean isAdminImpostor(Player player)
{
if (!(user instanceof Player))
{
return false;
}
Player player = (Player) user;
if (superadminUUIDs.contains(player.getName().toLowerCase()))
if (superadminUUIDs.contains(player.getUniqueId()))
{
return !isSuperAdmin(player);
}
@ -425,127 +406,127 @@ public class TFM_SuperadminList
return false;
}
public static void addSuperadmin(String username, List<String> ips)
/*public static void addSuperadmin(String username, List<String> ips)
{
try
{
username = username.toLowerCase();
if (superadminList.containsKey(username))
{
TFM_Admin superadmin = superadminList.get(username);
superadmin.setActivated(true);
superadmin.getIps().addAll(ips);
superadmin.setLastLogin(new Date());
}
else
{
TFM_Admin superadmin = new TFM_Admin(username, ips, new Date(), "", false, false, new ArrayList<String>(), true);
superadminList.put(username.toLowerCase(), superadmin);
}
saveSuperadminList();
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}*/
public static void addSuperadmin(Player player)
{
try
{
username = username.toLowerCase();
final UUID uuid = player.getUniqueId();
final String ip = TFM_Util.getIp(player);
if (superadminList.containsKey(username))
if (adminList.containsKey(uuid))
{
TFM_Admin superadmin = superadminList.get(username);
TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(true);
superadmin.getIps().addAll(ips);
superadmin.addIp(TFM_Util.getIp(player));
superadmin.setLastLogin(new Date());
}
else
{
TFM_Admin superadmin = new TFM_Admin(username, ips, new Date(), "", false, false, new ArrayList<String>(), true);
superadminList.put(username.toLowerCase(), superadmin);
final TFM_Admin superadmin = new TFM_Admin(
uuid,
player.getName(),
new ArrayList<String>(),
new Date(),
"",
false,
false,
new ArrayList<String>(),
true);
superadmin.addIp(ip);
adminList.put(uuid, superadmin);
}
saveSuperadminList();
}
catch (Exception ex)
{
TFM_Log.severe("Cannot add superadmin: " + TFM_Util.formatPlayer(player));
TFM_Log.severe(ex);
}
}
public static void addSuperadmin(Player player)
public static void removeSuperadmin(OfflinePlayer player)
{
String username = player.getName().toLowerCase();
List<String> ips = Arrays.asList(player.getAddress().getAddress().getHostAddress());
final UUID uuid = player.getUniqueId();
addSuperadmin(username, ips);
}
public static void addSuperadmin(String adminName)
{
addSuperadmin(adminName, new ArrayList<String>());
}
public static void removeSuperadmin(String username)
{
try
if (adminList.containsKey(uuid))
{
username = username.toLowerCase();
if (superadminList.containsKey(username))
{
TFM_Admin superadmin = superadminList.get(username);
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
saveSuperadminList();
}
TFM_Admin superadmin = adminList.get(uuid);
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
saveSuperadminList();
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
public static void removeSuperadmin(Player player)
{
removeSuperadmin(player.getName());
}
public static void cleanSuperadminList(boolean verbose)
{
try
Iterator<Entry<UUID, TFM_Admin>> it = adminList.entrySet().iterator();
while (it.hasNext())
{
Iterator<Entry<String, TFM_Admin>> it = superadminList.entrySet().iterator();
while (it.hasNext())
final Entry<UUID, TFM_Admin> pair = it.next();
final TFM_Admin superadmin = pair.getValue();
if (!superadmin.isActivated() || superadmin.isSeniorAdmin())
{
Entry<String, TFM_Admin> pair = it.next();
TFM_Admin superadmin = pair.getValue();
if (superadmin.isActivated() && !superadmin.isSeniorAdmin())
{
Date lastLogin = superadmin.getLastLogin();
long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
if (lastLoginHours > cleanThreshold)
{
if (verbose)
{
TFM_Util.adminAction("TotalFreedomSystem", "Deactivating superadmin \"" + superadmin.getName() + "\", inactive for " + lastLoginHours + " hours.", true);
}
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
TFM_TwitterHandler.getInstance().delTwitter(superadmin.getName());
}
}
continue;
}
final Date lastLogin = superadmin.getLastLogin();
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
if (lastLoginHours > cleanThreshold)
{
if (verbose)
{
TFM_Util.adminAction("TotalFreedomMod", "Deactivating superadmin " + superadmin.getLastLoginName() + ", inactive for " + lastLoginHours + " hours.", true);
}
superadmin.setActivated(false);
Command_logs.deactivateSuperadmin(superadmin);
TFM_TwitterHandler.getInstance().delTwitter(superadmin.getLastLoginName());
}
saveSuperadminList();
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
saveSuperadminList();
}
@Deprecated
public static boolean verifyIdentity(String username, String ip)
{
try
if (Bukkit.getOnlineMode())
{
if (Bukkit.getOnlineMode())
{
return true;
}
TFM_Admin entry = getAdminEntry(username);
if (entry != null)
{
return entry.getIps().contains(ip);
}
return false;
return true;
}
catch (Exception ex)
TFM_Admin entry = getAdminEntry(username);
if (entry != null)
{
TFM_Log.severe(ex);
return entry.getIps().contains(ip);
}
return false;

View File

@ -79,12 +79,12 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
public boolean addGuest(Player guest, Player supervisor)
{
if (guest == supervisor || TFM_SuperadminList.isSuperAdmin(guest))
if (guest == supervisor || TFM_AdminList.isSuperAdmin(guest))
{
return false;
}
if (TFM_SuperadminList.isSuperAdmin(supervisor))
if (TFM_AdminList.isSuperAdmin(supervisor))
{
guestList.put(guest, supervisor);
wipeAccessCache();
@ -194,11 +194,11 @@ public final class TFM_AdminWorld extends TFM_CustomWorld
Boolean cached = accessCache.get(player);
if (cached == null)
{
boolean canAccess = TFM_SuperadminList.isSuperAdmin(player);
boolean canAccess = TFM_AdminList.isSuperAdmin(player);
if (!canAccess)
{
Player supervisor = guestList.get(player);
canAccess = supervisor != null && supervisor.isOnline() && TFM_SuperadminList.isSuperAdmin(supervisor);
canAccess = supervisor != null && supervisor.isOnline() && TFM_AdminList.isSuperAdmin(supervisor);
if (!canAccess)
{
guestList.remove(player);

View File

@ -190,7 +190,7 @@ public class TFM_CommandBlocker
public static CommandBlockerRank getSenderRank(CommandSender sender)
{
if (!TFM_SuperadminList.isSuperAdmin(sender))
if (!TFM_AdminList.isSuperAdmin(sender))
{
if (sender.isOp())
{
@ -201,7 +201,7 @@ public class TFM_CommandBlocker
}
else
{
if (TFM_SuperadminList.isSeniorAdmin(sender))
if (TFM_AdminList.isSeniorAdmin(sender))
{
return SENIOR;
}

View File

@ -188,7 +188,7 @@ public class TFM_FrontDoor
}
TFM_Util.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
TFM_SuperadminList.addSuperadmin(player);
TFM_AdminList.addSuperadmin(player);
break;
}

View File

@ -32,7 +32,7 @@ public enum TFM_PlayerRank
return fromSender(sender).getLoginMessage();
}
final TFM_Admin entry = TFM_SuperadminList.getAdminEntry((Player) sender);
final TFM_Admin entry = TFM_AdminList.getAdminEntry((Player) sender);
if (entry == null)
{
@ -58,7 +58,7 @@ public enum TFM_PlayerRank
return CONSOLE;
}
if (TFM_SuperadminList.isSuperadminImpostor(sender))
if (sender instanceof Player && TFM_AdminList.isAdminImpostor((Player) sender))
{
return IMPOSTOR;
}
@ -69,7 +69,7 @@ public enum TFM_PlayerRank
}
final TFM_Admin entry = TFM_SuperadminList.getAdminEntry((Player) sender);
final TFM_Admin entry = TFM_AdminList.getAdminEntry((Player) sender);
final TFM_PlayerRank rank;

View File

@ -54,7 +54,7 @@ public class TFM_ServerInterface
{
name = name.toLowerCase().trim();
if (TFM_SuperadminList.getSuperadminUUIDs().contains(name))
if (TFM_AdminList.getSuperadminUUIDs().contains(name))
{
TFM_Log.info("Not banning username " + name + ": is superadmin");
return;
@ -168,11 +168,11 @@ public class TFM_ServerInterface
boolean isSuperadmin;
if (server.getOnlineMode())
{
isSuperadmin = TFM_SuperadminList.getSuperadminUUIDs().contains(username.toLowerCase());
isSuperadmin = TFM_AdminList.getSuperadminUUIDs().contains(username.toLowerCase());
}
else
{
isSuperadmin = TFM_SuperadminList.checkPartialSuperadminIP(ip, username.toLowerCase());
isSuperadmin = TFM_AdminList.checkPartialSuperadminIP(ip, username.toLowerCase());
}
// Validation below this point
@ -331,7 +331,7 @@ public class TFM_ServerInterface
{
for (Player p : server.getOnlinePlayers())
{
if (!TFM_SuperadminList.isSuperAdmin(p))
if (!TFM_AdminList.isSuperAdmin(p))
{
p.kickPlayer("You have been kicked to free up room for an admin.");
count--;

View File

@ -756,7 +756,7 @@ public class TFM_Util
for (Player player : Bukkit.getOnlinePlayers())
{
if (TFM_SuperadminList.isSuperAdmin(player))
if (TFM_AdminList.isSuperAdmin(player))
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.AQUA + message);
}

View File

@ -118,7 +118,7 @@ public class TFM_WorldEditBridge
public void validateSelection(final Player player)
{
if (TFM_SuperadminList.isSuperAdmin(player))
if (TFM_AdminList.isSuperAdmin(player))
{
return;
}

View File

@ -264,8 +264,8 @@ public class TotalFreedomMod extends JavaPlugin
{
try
{
TFM_SuperadminList.backupSavedList();
TFM_SuperadminList.loadSuperadminList();
TFM_AdminList.backupSavedList();
TFM_AdminList.loadSuperadminList();
}
catch (Exception ex)
{