mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-31 22:07:38 +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.VERSION=3.2
|
||||||
program.BUILDNUM=613
|
program.BUILDNUM=615
|
||||||
program.BUILDDATE=09/27/2013 08\:45 AM
|
program.BUILDDATE=09/27/2013 10\:59 AM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Fri Sep 27 08:45:15 EDT 2013
|
#Fri Sep 27 10:59:36 EDT 2013
|
||||||
build.number=614
|
build.number=616
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -13,6 +15,17 @@ public class TFM_CustomListener implements Listener
|
|||||||
String ip = event.getIp();
|
String ip = event.getIp();
|
||||||
String name = event.getName();
|
String name = event.getName();
|
||||||
boolean canBypassPassword = event.canBypassPassword();
|
boolean canBypassPassword = event.canBypassPassword();
|
||||||
|
|
||||||
TFM_Log.info("Caught TelnetPreLoginEvent: name: " + name + " - ip: " + ip + " - canBypassPassword: " + 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 name;
|
||||||
private final String loginMessage;
|
private final String loginMessage;
|
||||||
private final boolean isSeniorAdmin;
|
private final boolean isSeniorAdmin;
|
||||||
|
private final boolean isTelnetAdmin;
|
||||||
private final List<String> consoleAliases;
|
private final List<String> consoleAliases;
|
||||||
private List<String> ips;
|
private final List<String> ips;
|
||||||
private Date lastLogin;
|
private Date lastLogin;
|
||||||
private boolean isActivated;
|
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.name = name.toLowerCase();
|
||||||
this.ips = ips;
|
this.ips = ips;
|
||||||
this.lastLogin = lastLogin;
|
this.lastLogin = lastLogin;
|
||||||
this.loginMessage = loginMessage;
|
this.loginMessage = loginMessage;
|
||||||
this.isSeniorAdmin = isSeniorAdmin;
|
this.isSeniorAdmin = isSeniorAdmin;
|
||||||
|
this.isTelnetAdmin = isTelnetAdmin;
|
||||||
this.consoleAliases = consoleAliases;
|
this.consoleAliases = consoleAliases;
|
||||||
this.isActivated = isActivated;
|
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.lastLogin = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L))));
|
||||||
this.loginMessage = section.getString("custom_login_message", "");
|
this.loginMessage = section.getString("custom_login_message", "");
|
||||||
this.isSeniorAdmin = section.getBoolean("is_senior_admin", false);
|
this.isSeniorAdmin = section.getBoolean("is_senior_admin", false);
|
||||||
|
this.isTelnetAdmin = section.getBoolean("is_telnet_admin", false);
|
||||||
this.consoleAliases = section.getStringList("console_aliases");
|
this.consoleAliases = section.getStringList("console_aliases");
|
||||||
this.isActivated = section.getBoolean("is_activated", true);
|
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("- Last Login: ").append(TFM_Util.dateToString(this.lastLogin)).append("\n");
|
||||||
output.append("- Custom Login Message: ").append(this.loginMessage).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 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("- Console Aliases: ").append(StringUtils.join(this.consoleAliases, ", ")).append("\n");
|
||||||
output.append("- Is Activated: ").append(this.isActivated);
|
output.append("- Is Activated: ").append(this.isActivated);
|
||||||
}
|
}
|
||||||
@ -85,16 +89,16 @@ public class TFM_Superadmin
|
|||||||
return isSeniorAdmin;
|
return isSeniorAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTelnetAdmin()
|
||||||
|
{
|
||||||
|
return isTelnetAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getConsoleAliases()
|
public List<String> getConsoleAliases()
|
||||||
{
|
{
|
||||||
return consoleAliases;
|
return consoleAliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIps(List<String> ips)
|
|
||||||
{
|
|
||||||
this.ips = ips;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastLogin(Date lastLogin)
|
public void setLastLogin(Date lastLogin)
|
||||||
{
|
{
|
||||||
this.lastLogin = lastLogin;
|
this.lastLogin = lastLogin;
|
||||||
|
@ -179,15 +179,33 @@ public class TFM_SuperadminList
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static TFM_Superadmin getAdminEntryByIP(String ip)
|
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();
|
Iterator<Entry<String, TFM_Superadmin>> it = superadminList.entrySet().iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
Entry<String, TFM_Superadmin> pair = it.next();
|
Entry<String, TFM_Superadmin> pair = it.next();
|
||||||
TFM_Superadmin superadmin = pair.getValue();
|
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;
|
return null;
|
||||||
@ -300,7 +318,6 @@ public class TFM_SuperadminList
|
|||||||
{
|
{
|
||||||
List<String> ips = entry.getIps();
|
List<String> ips = entry.getIps();
|
||||||
ips.add(ip);
|
ips.add(ip);
|
||||||
entry.setIps(ips);
|
|
||||||
saveSuperadminList();
|
saveSuperadminList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,12 +366,7 @@ public class TFM_SuperadminList
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Date lastLogin = new Date();
|
TFM_Superadmin superadmin = new TFM_Superadmin(username, ips, new Date(), "", false, false, new ArrayList<String>(), true);
|
||||||
String loginMessage = "";
|
|
||||||
boolean isSeniorAdmin = false;
|
|
||||||
List<String> consoleAliases = new ArrayList<String>();
|
|
||||||
|
|
||||||
TFM_Superadmin superadmin = new TFM_Superadmin(username, ips, lastLogin, loginMessage, isSeniorAdmin, consoleAliases, true);
|
|
||||||
superadminList.put(username.toLowerCase(), superadmin);
|
superadminList.put(username.toLowerCase(), superadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user