mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Implemented new superadmin autoadd.
This commit is contained in:
parent
1f359da0d1
commit
d35baebef9
@ -26,12 +26,12 @@ dist.jar=${dist.dir}/TotalFreedomMod.jar
|
|||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar
|
file.reference.MobDisguise.jar=../MobDisguise/dist/MobDisguise.jar
|
||||||
includes=**
|
includes=**
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${file.reference.MobDisguise.jar}:\
|
${libs.Bukkit.classpath}:\
|
||||||
${libs.Bukkit.classpath}
|
${file.reference.MobDisguise.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=-Xlint:unchecked
|
javac.compilerargs=-Xlint:unchecked
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -271,7 +271,7 @@ public class TFM_Util
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean match_found = false;
|
String match_ip = null;
|
||||||
for (String test_ip : tfm.superadmin_ips)
|
for (String test_ip : tfm.superadmin_ips)
|
||||||
{
|
{
|
||||||
String[] test_octets = test_ip.split("\\.");
|
String[] test_octets = test_ip.split("\\.");
|
||||||
@ -279,32 +279,46 @@ public class TFM_Util
|
|||||||
{
|
{
|
||||||
if (user_octets[0].equals(test_octets[0]) && user_octets[1].equals(test_octets[1]) && user_octets[2].equals(test_octets[2]))
|
if (user_octets[0].equals(test_octets[0]) && user_octets[1].equals(test_octets[1]) && user_octets[2].equals(test_octets[2]))
|
||||||
{
|
{
|
||||||
log.info("New IP '" + user_ip + "' matches old IP '" + test_ip + "' via partial match, adding it to superadmin list.");
|
match_ip = test_ip;
|
||||||
match_found = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match_found)
|
if (match_ip != null)
|
||||||
{
|
{
|
||||||
tfm.superadmin_ips.add(user_ip);
|
tfm.superadmin_ips.add(user_ip);
|
||||||
|
|
||||||
log.severe("TODO: Implement add to superadmin list.");
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||||
|
|
||||||
// try
|
fileloop:
|
||||||
// {
|
for (String user : config.getKeys(false))
|
||||||
// FileConfiguration sa_config = YamlConfiguration.loadConfiguration(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
{
|
||||||
// sa_config.set("superadmin_ips", tfm.superadmin_ips);
|
List<String> user_ips = config.getStringList(user);
|
||||||
// sa_config.save(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
for (String ip : user_ips)
|
||||||
// }
|
{
|
||||||
// catch (IOException ex)
|
ip = ip.toLowerCase().trim();
|
||||||
// {
|
if (ip.equals(match_ip))
|
||||||
// Logger.getLogger(TFM_Util.class.getName()).log(Level.SEVERE, null, ex);
|
{
|
||||||
// }
|
log.info("New IP '" + user_ip + "' matches old IP '" + match_ip + "' via partial match, adding it to superadmin list.");
|
||||||
|
user_ips.add(user_ip);
|
||||||
|
config.set(user, user_ips);
|
||||||
|
break fileloop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
config.save(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return match_found;
|
return match_ip != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,41 +169,6 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public List<String> superadmins = new ArrayList<String>();
|
public List<String> superadmins = new ArrayList<String>();
|
||||||
public List<String> superadmin_ips = new ArrayList<String>();
|
public List<String> superadmin_ips = new ArrayList<String>();
|
||||||
|
|
||||||
// public void loadSuperadminConfig()
|
|
||||||
// {
|
|
||||||
// TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, this, getFile());
|
|
||||||
// FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), SUPERADMIN_FILE));
|
|
||||||
//
|
|
||||||
// superadmins = new ArrayList<String>();
|
|
||||||
// List<String> superadmins_temp = config.getStringList("superadmins");
|
|
||||||
// if (superadmins_temp == null || superadmins_temp.isEmpty())
|
|
||||||
// {
|
|
||||||
// superadmins.add("Madgeek1450");
|
|
||||||
// superadmins.add("markbyron");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// for (String admin_name : superadmins_temp)
|
|
||||||
// {
|
|
||||||
// superadmins.add(admin_name.toLowerCase().trim());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// superadmin_ips = new ArrayList<String>();
|
|
||||||
// List<String> superadmin_ips_temp = config.getStringList("superadmin_ips");
|
|
||||||
// if (superadmin_ips_temp == null || superadmin_ips_temp.isEmpty())
|
|
||||||
// {
|
|
||||||
// superadmin_ips.add("127.0.0.1");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// for (String admin_ip : superadmin_ips_temp)
|
|
||||||
// {
|
|
||||||
// superadmin_ips.add(admin_ip.toLowerCase().trim());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void loadSuperadminConfig()
|
public void loadSuperadminConfig()
|
||||||
{
|
{
|
||||||
TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, this, getFile());
|
TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, this, getFile());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: TotalFreedomMod
|
name: TotalFreedomMod
|
||||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||||
version: 2.1
|
version: 2.2
|
||||||
description: Plugin for the Total Freedom server.
|
description: Plugin for the Total Freedom server.
|
||||||
author: StevenLawson / Madgeek1450
|
author: StevenLawson / Madgeek1450
|
||||||
commands:
|
commands:
|
||||||
|
Loading…
Reference in New Issue
Block a user