mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-27 20:27:37 +00:00
Made superadmin entries permanent, can only be removed manually.
/saconfig del will only deactivate the entry, not remove it. Renamed SuperAwesomeAdmin to Senior Admin.
This commit is contained in:
parent
59e6588779
commit
6e266fcff2
@ -14,7 +14,7 @@ public class Command_doom extends TFM_Command
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!(senderIsConsole && TFM_SuperadminList.isSuperAwesomeAdmin(sender)))
|
||||
if (!(senderIsConsole && TFM_SuperadminList.isSeniorAdmin(sender)))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
|
@ -24,7 +24,7 @@ public class Command_fuckoff extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isSuperAwesomeAdmin(sender_p))
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(sender_p))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
|
@ -16,7 +16,7 @@ public class Command_lockup extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!(senderIsConsole && TFM_SuperadminList.isSuperAwesomeAdmin(sender)))
|
||||
if (!(senderIsConsole && TFM_SuperadminList.isSeniorAdmin(sender)))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
|
@ -13,7 +13,7 @@ public class Command_wipeflatlands extends TFM_Command
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!(senderIsConsole && TFM_SuperadminList.isSuperAwesomeAdmin(sender)))
|
||||
if (!(senderIsConsole && TFM_SuperadminList.isSeniorAdmin(sender)))
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
return true;
|
||||
|
@ -265,7 +265,7 @@ public class TFM_BlockListener implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isSuperAwesomeAdmin(player))
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(player))
|
||||
{
|
||||
TFM_Util.playerMsg(player, "You do not have permission to set Command Block commands.");
|
||||
event.setCancelled(true);
|
||||
|
@ -9,19 +9,21 @@ public class TFM_Superadmin
|
||||
{
|
||||
private final String name;
|
||||
private final String custom_login_message;
|
||||
private final boolean is_super_awesome_admin;
|
||||
private final boolean is_senior_admin;
|
||||
private final List<String> console_aliases;
|
||||
private List<String> ips;
|
||||
private Date last_login;
|
||||
private boolean is_activated;
|
||||
|
||||
public TFM_Superadmin(String name, List<String> ips, Date last_login, String custom_login_message, boolean is_super_awesome_admin, List<String> console_aliases)
|
||||
public TFM_Superadmin(String name, List<String> ips, Date last_login, String custom_login_message, boolean is_senior_admin, List<String> console_aliases, boolean is_activated)
|
||||
{
|
||||
this.name = name.toLowerCase();
|
||||
this.ips = ips;
|
||||
this.last_login = last_login;
|
||||
this.custom_login_message = custom_login_message;
|
||||
this.is_super_awesome_admin = is_super_awesome_admin;
|
||||
this.is_senior_admin = is_senior_admin;
|
||||
this.console_aliases = console_aliases;
|
||||
this.is_activated = is_activated;
|
||||
}
|
||||
|
||||
public TFM_Superadmin(String name, ConfigurationSection section)
|
||||
@ -30,8 +32,9 @@ public class TFM_Superadmin
|
||||
this.ips = section.getStringList("ips");
|
||||
this.last_login = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L))));
|
||||
this.custom_login_message = section.getString("custom_login_message", "");
|
||||
this.is_super_awesome_admin = section.getBoolean("is_super_awesome_admin", false);
|
||||
this.is_senior_admin = section.getBoolean("is_senior_admin", false);
|
||||
this.console_aliases = section.getStringList("console_aliases");
|
||||
this.is_activated = section.getBoolean("is_activated", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,8 +48,9 @@ public class TFM_Superadmin
|
||||
output.append("- IPs: ").append(StringUtils.join(this.ips, ", ")).append("\n");
|
||||
output.append("- Last Login: ").append(TFM_Util.dateToString(this.last_login)).append("\n");
|
||||
output.append("- Custom Login Message: ").append(this.custom_login_message).append("\n");
|
||||
output.append("- Is Super Awesome Admin: ").append(this.is_super_awesome_admin).append("\n");
|
||||
output.append("- Console Aliases: ").append(StringUtils.join(this.console_aliases, ", "));
|
||||
output.append("- Is Senior Admin: ").append(this.is_senior_admin).append("\n");
|
||||
output.append("- Console Aliases: ").append(StringUtils.join(this.console_aliases, ", ")).append("\n");
|
||||
output.append("- Is Activated: ").append(this.is_activated);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -76,9 +80,9 @@ public class TFM_Superadmin
|
||||
return custom_login_message;
|
||||
}
|
||||
|
||||
public boolean isSuperAwesomeAdmin()
|
||||
public boolean isSeniorAdmin()
|
||||
{
|
||||
return is_super_awesome_admin;
|
||||
return is_senior_admin;
|
||||
}
|
||||
|
||||
public List<String> getConsoleAliases()
|
||||
@ -95,4 +99,14 @@ public class TFM_Superadmin
|
||||
{
|
||||
this.last_login = last_login;
|
||||
}
|
||||
|
||||
public boolean isActivated()
|
||||
{
|
||||
return is_activated;
|
||||
}
|
||||
|
||||
public void setActivated(boolean is_activated)
|
||||
{
|
||||
this.is_activated = is_activated;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class TFM_SuperadminList
|
||||
private static Map<String, TFM_Superadmin> superadminList = new HashMap<String, TFM_Superadmin>();
|
||||
private static List<String> superadminNames = new ArrayList<String>();
|
||||
private static List<String> superadminIPs = new ArrayList<String>();
|
||||
private static List<String> superAwesomeAdminsConsole = new ArrayList<String>();
|
||||
private static List<String> seniorAdminNames = new ArrayList<String>();
|
||||
|
||||
private TFM_SuperadminList()
|
||||
{
|
||||
@ -43,8 +43,6 @@ public class TFM_SuperadminList
|
||||
{
|
||||
try
|
||||
{
|
||||
// convertV1List();
|
||||
|
||||
superadminList.clear();
|
||||
|
||||
TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE, TotalFreedomMod.plugin_file);
|
||||
@ -93,50 +91,28 @@ public class TFM_SuperadminList
|
||||
String admin_name = pair.getKey().toLowerCase();
|
||||
TFM_Superadmin superadmin = pair.getValue();
|
||||
|
||||
superadminNames.add(admin_name);
|
||||
|
||||
for (String ip : superadmin.getIps())
|
||||
if (superadmin.isActivated())
|
||||
{
|
||||
superadminIPs.add(ip);
|
||||
}
|
||||
superadminNames.add(admin_name);
|
||||
|
||||
if (superadmin.isSuperAwesomeAdmin())
|
||||
{
|
||||
superAwesomeAdminsConsole.add(admin_name);
|
||||
|
||||
for (String console_alias : superadmin.getConsoleAliases())
|
||||
for (String ip : superadmin.getIps())
|
||||
{
|
||||
superAwesomeAdminsConsole.add(console_alias.toLowerCase());
|
||||
superadminIPs.add(ip);
|
||||
}
|
||||
|
||||
if (superadmin.isSeniorAdmin())
|
||||
{
|
||||
seniorAdminNames.add(admin_name);
|
||||
|
||||
for (String console_alias : superadmin.getConsoleAliases())
|
||||
{
|
||||
seniorAdminNames.add(console_alias.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public static void convertV1List()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// superadminList.clear();
|
||||
//
|
||||
// TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE, TotalFreedomMod.plugin_file);
|
||||
// FileConfiguration config = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||
//
|
||||
// if (!config.isConfigurationSection("superadmins"))
|
||||
// {
|
||||
// for (String admin_name : config.getKeys(false))
|
||||
// {
|
||||
// TFM_Superadmin superadmin = new TFM_Superadmin(admin_name, config.getStringList(admin_name), new Date(), "", false, new ArrayList<String>());
|
||||
// superadminList.put(admin_name.toLowerCase(), superadmin);
|
||||
// }
|
||||
//
|
||||
// saveSuperadminList();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// TFM_Log.severe(ex);
|
||||
// }
|
||||
// }
|
||||
public static void saveSuperadminList()
|
||||
{
|
||||
try
|
||||
@ -156,8 +132,9 @@ public class TFM_SuperadminList
|
||||
config.set("superadmins." + admin_name + ".ips", superadmin.getIps());
|
||||
config.set("superadmins." + admin_name + ".last_login", TFM_Util.dateToString(superadmin.getLastLogin()));
|
||||
config.set("superadmins." + admin_name + ".custom_login_message", superadmin.getCustomLoginMessage());
|
||||
config.set("superadmins." + admin_name + ".is_super_awesome_admin", superadmin.isSuperAwesomeAdmin());
|
||||
config.set("superadmins." + admin_name + ".is_senior_admin", superadmin.isSeniorAdmin());
|
||||
config.set("superadmins." + admin_name + ".console_aliases", superadmin.getConsoleAliases());
|
||||
config.set("superadmins." + admin_name + ".is_activated", superadmin.isActivated());
|
||||
}
|
||||
|
||||
config.save(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||
@ -212,19 +189,19 @@ public class TFM_SuperadminList
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSuperAwesomeAdmin(CommandSender user)
|
||||
public static boolean isSeniorAdmin(CommandSender user)
|
||||
{
|
||||
String user_name = user.getName().toLowerCase();
|
||||
|
||||
if (!(user instanceof Player))
|
||||
{
|
||||
return superAwesomeAdminsConsole.contains(user_name);
|
||||
return seniorAdminNames.contains(user_name);
|
||||
}
|
||||
|
||||
TFM_Superadmin admin_entry = getAdminEntry((Player) user);
|
||||
if (admin_entry != null)
|
||||
{
|
||||
return admin_entry.isSuperAwesomeAdmin();
|
||||
return admin_entry.isSeniorAdmin();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -339,13 +316,23 @@ public class TFM_SuperadminList
|
||||
|
||||
public static void addSuperadmin(String admin_name, List<String> ips)
|
||||
{
|
||||
Date last_login = new Date();
|
||||
String custom_login_message = "";
|
||||
boolean is_super_awesome_admin = false;
|
||||
List<String> console_aliases = new ArrayList<String>();
|
||||
admin_name = admin_name.toLowerCase();
|
||||
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(admin_name, ips, last_login, custom_login_message, is_super_awesome_admin, console_aliases);
|
||||
superadminList.put(admin_name.toLowerCase(), superadmin);
|
||||
if (superadminList.containsKey(admin_name))
|
||||
{
|
||||
TFM_Superadmin superadmin = superadminList.get(admin_name);
|
||||
superadmin.setActivated(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Date last_login = new Date();
|
||||
String custom_login_message = "";
|
||||
boolean is_senior_admin = false;
|
||||
List<String> console_aliases = new ArrayList<String>();
|
||||
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(admin_name, ips, last_login, custom_login_message, is_senior_admin, console_aliases, true);
|
||||
superadminList.put(admin_name.toLowerCase(), superadmin);
|
||||
}
|
||||
|
||||
saveSuperadminList();
|
||||
}
|
||||
@ -369,10 +356,10 @@ public class TFM_SuperadminList
|
||||
|
||||
if (superadminList.containsKey(admin_name))
|
||||
{
|
||||
superadminList.remove(admin_name);
|
||||
TFM_Superadmin superadmin = superadminList.get(admin_name);
|
||||
superadmin.setActivated(false);
|
||||
saveSuperadminList();
|
||||
}
|
||||
|
||||
saveSuperadminList();
|
||||
}
|
||||
|
||||
public static void removeSuperadmin(Player p)
|
||||
|
@ -547,7 +547,7 @@ public class TFM_Util
|
||||
//JeromSar
|
||||
public static String getRank(CommandSender sender)
|
||||
{
|
||||
if (TFM_Util.isSuperadminImpostor(sender))
|
||||
if (TFM_SuperadminList.isSuperadminImpostor(sender))
|
||||
{
|
||||
return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "impostor" + ChatColor.RESET + ChatColor.AQUA + "!";
|
||||
}
|
||||
@ -556,17 +556,27 @@ public class TFM_Util
|
||||
|
||||
if (admin_entry != null)
|
||||
{
|
||||
String custom_login_message = admin_entry.getCustomLoginMessage();
|
||||
|
||||
if (custom_login_message != null)
|
||||
if (admin_entry.isActivated())
|
||||
{
|
||||
if (!custom_login_message.isEmpty())
|
||||
String custom_login_message = admin_entry.getCustomLoginMessage();
|
||||
|
||||
if (custom_login_message != null)
|
||||
{
|
||||
return ChatColor.translateAlternateColorCodes('&', custom_login_message);
|
||||
if (!custom_login_message.isEmpty())
|
||||
{
|
||||
return ChatColor.translateAlternateColorCodes('&', custom_login_message);
|
||||
}
|
||||
}
|
||||
|
||||
if (admin_entry.isSeniorAdmin())
|
||||
{
|
||||
return "a " + ChatColor.GOLD + "senior admin" + ChatColor.AQUA + ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "an " + ChatColor.RED + "admin" + ChatColor.AQUA + ".";
|
||||
}
|
||||
}
|
||||
|
||||
return "an " + ChatColor.RED + "admin" + ChatColor.AQUA + ".";
|
||||
}
|
||||
|
||||
if (sender.isOp())
|
||||
|
@ -5,7 +5,7 @@ superadmins:
|
||||
- 213.211.159.63
|
||||
last_login: Fri, 9 Nov 2012 03:09:14 -0500
|
||||
custom_login_message: a &5developer&b!
|
||||
is_super_awesome_admin: true
|
||||
is_senior_admin: true
|
||||
console_aliases:
|
||||
- darth
|
||||
madgeek1450:
|
||||
@ -14,7 +14,7 @@ superadmins:
|
||||
- 8.8.8.8
|
||||
last_login: Sun, 11 Nov 2012 01:09:14 -0500
|
||||
custom_login_message: the &5chief-developer&b and &6master-ass-kicker&b.
|
||||
is_super_awesome_admin: true
|
||||
is_senior_admin: true
|
||||
console_aliases:
|
||||
- madgeek
|
||||
markbyron:
|
||||
@ -23,5 +23,5 @@ superadmins:
|
||||
- 8.8.4.4
|
||||
last_login: Sat, 10 Nov 2012 02:09:14 -0500
|
||||
custom_login_message: the &downer&b.
|
||||
is_super_awesome_admin: true
|
||||
is_senior_admin: true
|
||||
console_aliases: []
|
||||
|
Loading…
Reference in New Issue
Block a user