mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-29 04:57:37 +00:00
Added "isTelnetAdmin" to SA list.
This commit is contained in:
parent
81995f38a1
commit
2d655e4009
@ -1,5 +1,5 @@
|
||||
#Fri, 27 Sep 2013 08:45:15 -0400
|
||||
#Fri, 27 Sep 2013 10:59:36 -0400
|
||||
|
||||
program.VERSION=3.2
|
||||
program.BUILDNUM=613
|
||||
program.BUILDDATE=09/27/2013 08\:45 AM
|
||||
program.BUILDNUM=615
|
||||
program.BUILDDATE=09/27/2013 10\:59 AM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Fri Sep 27 08:45:15 EDT 2013
|
||||
build.number=614
|
||||
#Fri Sep 27 10:59:36 EDT 2013
|
||||
build.number=616
|
||||
|
@ -1,6 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -13,6 +15,17 @@ public class TFM_CustomListener implements Listener
|
||||
String ip = event.getIp();
|
||||
String name = event.getName();
|
||||
boolean canBypassPassword = event.canBypassPassword();
|
||||
|
||||
TFM_Log.info("Caught TelnetPreLoginEvent: name: " + name + " - ip: " + ip + " - canBypassPassword: " + canBypassPassword);
|
||||
|
||||
if (ip != null && !ip.isEmpty())
|
||||
{
|
||||
TFM_Superadmin admin = TFM_SuperadminList.getAdminEntryByIP(ip, true);
|
||||
if (admin != null && (admin.isTelnetAdmin() || admin.isSeniorAdmin()))
|
||||
{
|
||||
event.setBypassPassword(true);
|
||||
event.setName(admin.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,18 +10,20 @@ public class TFM_Superadmin
|
||||
private final String name;
|
||||
private final String loginMessage;
|
||||
private final boolean isSeniorAdmin;
|
||||
private final boolean isTelnetAdmin;
|
||||
private final List<String> consoleAliases;
|
||||
private List<String> ips;
|
||||
private final List<String> ips;
|
||||
private Date lastLogin;
|
||||
private boolean isActivated;
|
||||
|
||||
public TFM_Superadmin(String name, List<String> ips, Date lastLogin, String loginMessage, boolean isSeniorAdmin, List<String> consoleAliases, boolean isActivated)
|
||||
public TFM_Superadmin(String name, List<String> ips, Date lastLogin, String loginMessage, boolean isSeniorAdmin, boolean isTelnetAdmin, List<String> consoleAliases, boolean isActivated)
|
||||
{
|
||||
this.name = name.toLowerCase();
|
||||
this.ips = ips;
|
||||
this.lastLogin = lastLogin;
|
||||
this.loginMessage = loginMessage;
|
||||
this.isSeniorAdmin = isSeniorAdmin;
|
||||
this.isTelnetAdmin = isTelnetAdmin;
|
||||
this.consoleAliases = consoleAliases;
|
||||
this.isActivated = isActivated;
|
||||
}
|
||||
@ -33,6 +35,7 @@ public class TFM_Superadmin
|
||||
this.lastLogin = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L))));
|
||||
this.loginMessage = section.getString("custom_login_message", "");
|
||||
this.isSeniorAdmin = section.getBoolean("is_senior_admin", false);
|
||||
this.isTelnetAdmin = section.getBoolean("is_telnet_admin", false);
|
||||
this.consoleAliases = section.getStringList("console_aliases");
|
||||
this.isActivated = section.getBoolean("is_activated", true);
|
||||
}
|
||||
@ -49,6 +52,7 @@ public class TFM_Superadmin
|
||||
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);
|
||||
}
|
||||
@ -85,16 +89,16 @@ public class TFM_Superadmin
|
||||
return isSeniorAdmin;
|
||||
}
|
||||
|
||||
public boolean isTelnetAdmin()
|
||||
{
|
||||
return isTelnetAdmin;
|
||||
}
|
||||
|
||||
public List<String> getConsoleAliases()
|
||||
{
|
||||
return consoleAliases;
|
||||
}
|
||||
|
||||
public void setIps(List<String> ips)
|
||||
{
|
||||
this.ips = ips;
|
||||
}
|
||||
|
||||
public void setLastLogin(Date lastLogin)
|
||||
{
|
||||
this.lastLogin = lastLogin;
|
||||
|
@ -179,15 +179,33 @@ public class TFM_SuperadminList
|
||||
}
|
||||
|
||||
public static TFM_Superadmin getAdminEntryByIP(String ip)
|
||||
{
|
||||
return getAdminEntryByIP(ip, false);
|
||||
}
|
||||
|
||||
public static TFM_Superadmin getAdminEntryByIP(String needleIP, boolean fuzzy)
|
||||
{
|
||||
Iterator<Entry<String, TFM_Superadmin>> it = superadminList.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Entry<String, TFM_Superadmin> pair = it.next();
|
||||
TFM_Superadmin superadmin = pair.getValue();
|
||||
if (superadmin.getIps().contains(ip))
|
||||
if (fuzzy)
|
||||
{
|
||||
return superadmin;
|
||||
for (String haystackIP : superadmin.getIps())
|
||||
{
|
||||
if (TFM_Util.fuzzyIpMatch(needleIP, haystackIP, 3))
|
||||
{
|
||||
return superadmin;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (superadmin.getIps().contains(needleIP))
|
||||
{
|
||||
return superadmin;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -300,7 +318,6 @@ public class TFM_SuperadminList
|
||||
{
|
||||
List<String> ips = entry.getIps();
|
||||
ips.add(ip);
|
||||
entry.setIps(ips);
|
||||
saveSuperadminList();
|
||||
}
|
||||
}
|
||||
@ -349,12 +366,7 @@ public class TFM_SuperadminList
|
||||
}
|
||||
else
|
||||
{
|
||||
Date lastLogin = new Date();
|
||||
String loginMessage = "";
|
||||
boolean isSeniorAdmin = false;
|
||||
List<String> consoleAliases = new ArrayList<String>();
|
||||
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(username, ips, lastLogin, loginMessage, isSeniorAdmin, consoleAliases, true);
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(username, ips, new Date(), "", false, false, new ArrayList<String>(), true);
|
||||
superadminList.put(username.toLowerCase(), superadmin);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user