1
0
mirror of https://e.coding.net/circlecloud/AuthMe.git synced 2025-11-24 21:26:20 +00:00

修复控制台清除密码记录失效的问题...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092
2015-11-01 01:53:20 +08:00
parent ded732c8b0
commit e0016ed4cb
3 changed files with 23 additions and 35 deletions

View File

@@ -68,8 +68,12 @@ public class AuthMe extends JavaPlugin {
private static AuthMe authme; private static AuthMe authme;
private static Server server; private static Server server;
public boolean antibotMod = false;
public static AuthMe getInstance() {
return authme;
}
public boolean antibotMod = false;
public NewAPI api; public NewAPI api;
public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>(); public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>(); public ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
@@ -81,6 +85,7 @@ public class AuthMe extends JavaPlugin {
public Location essentialsSpawn; public Location essentialsSpawn;
public AuthMeInventoryPacketAdapter inventoryProtector; public AuthMeInventoryPacketAdapter inventoryProtector;
public Management management; public Management management;
public OtherAccounts otherAccounts; public OtherAccounts otherAccounts;
public Permission permission; public Permission permission;
@@ -89,17 +94,13 @@ public class AuthMe extends JavaPlugin {
// TODO: Create Manager for fields below // TODO: Create Manager for fields below
public ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>(); public ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
private Logger authmeLogger; private Logger authmeLogger;
private Messages m; private Messages m;
private JsonCache playerBackup; private JsonCache playerBackup;
private Settings settings; private Settings settings;
public static AuthMe getInstance() {
return authme;
}
public boolean authmePermissible(final CommandSender sender, final String perm) { public boolean authmePermissible(final CommandSender sender, final String perm) {
if (sender.hasPermission(perm)) { if (sender.hasPermission(perm)) {
return true; return true;
@@ -311,11 +312,14 @@ public class AuthMe extends JavaPlugin {
} }
// Load settings and custom configurations // Load settings and custom configurations
// TODO: new configuration style (more files)
try { try {
settings = new Settings(this); settings = new Settings(this);
Settings.reloadcfg(); Settings.reloadcfg();
Settings.loadVariables(); Settings.loadVariables();
// Setup messages
m = Messages.getInstance();
// Setup otherAccounts file
otherAccounts = OtherAccounts.getInstance();
} catch (final Exception e) { } catch (final Exception e) {
ConsoleLogger.writeStackTrace(e); ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("无法载入配置文件... 某些配置是错误的, 为了安全考虑 服务器即将关闭!"); ConsoleLogger.showError("无法载入配置文件... 某些配置是错误的, 为了安全考虑 服务器即将关闭!");
@@ -327,12 +331,6 @@ public class AuthMe extends JavaPlugin {
return; return;
} }
// Setup otherAccounts file
otherAccounts = OtherAccounts.getInstance();
// Setup messages
m = Messages.getInstance();
// Set Console Filter // Set Console Filter
if (Settings.removePassword) { if (Settings.removePassword) {
final ConsoleFilter filter = new ConsoleFilter(); final ConsoleFilter filter = new ConsoleFilter();
@@ -343,7 +341,8 @@ public class AuthMe extends JavaPlugin {
// Set Log4J Filter // Set Log4J Filter
try { try {
Class.forName("org.apache.logging.log4j.core.Filter"); Class.forName("org.apache.logging.log4j.core.Filter");
setLog4JFilter(); final org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger();
coreLogger.addFilter(new Log4JFilter());
} catch (ClassNotFoundException | NoClassDefFoundError e) { } catch (ClassNotFoundException | NoClassDefFoundError e) {
ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled"); ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
} }
@@ -361,6 +360,7 @@ public class AuthMe extends JavaPlugin {
} }
// Download GeoIp.dat file // Download GeoIp.dat file
ConsoleLogger.info("[LICENSE] IP数据来自 CityCraft 的 Yum 源 原始数据来自 http://www.maxmind.com");
Utils.checkGeoIP(); Utils.checkGeoIP();
// Find Permissions // Find Permissions
@@ -710,16 +710,4 @@ public class AuthMe extends JavaPlugin {
} }
}, 1, 1200 * Settings.delayRecall); }, 1, 1200 * Settings.delayRecall);
} }
// Set the console filter to remove the passwords
private void setLog4JFilter() {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
final org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger();
coreLogger.addFilter(new Log4JFilter());
}
});
}
} }

View File

@@ -8,6 +8,7 @@ import java.util.logging.LogRecord;
* @author Xephi59 * @author Xephi59
*/ */
public class ConsoleFilter implements Filter { public class ConsoleFilter implements Filter {
String[] filterkey = new String[] { "/login ", "/l ", "/reg ", "/register ", "/changepassword ", "/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp " };
public ConsoleFilter() { public ConsoleFilter() {
} }
@@ -19,20 +20,20 @@ public class ConsoleFilter implements Filter {
return true; return true;
} }
final String logM = record.getMessage().toLowerCase(); final String logM = record.getMessage().toLowerCase();
System.out.println("AuthMe LogRecord : " + logM);
if (!logM.contains("issued server command:")) { if (!logM.contains("issued server command:")) {
return true; return true;
} }
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") for (final String key : filterkey) {
&& !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") if (logM.contains(key)) {
&& !logM.contains("/register ")) { final String playername = record.getMessage().split(" ")[0];
return true; record.setMessage(playername + " 执行了一个 AuthMe 命令!");
break;
}
} }
final String playername = record.getMessage().split(" ")[0];
record.setMessage(playername + " 执行了一个 AuthMe 命令!");
return false;
} catch (final NullPointerException npe) { } catch (final NullPointerException npe) {
return true;
} }
return true;
} }
} }

View File

@@ -89,7 +89,6 @@ public class Utils {
if (lookupService != null) { if (lookupService != null) {
return true; return true;
} }
ConsoleLogger.info("[LICENSE] IP数据来自 CityCraft 的 Yum 源 原始数据来自 http://www.maxmind.com");
final File file = new File(Settings.APLUGIN_FOLDER, "GeoIP.dat"); final File file = new File(Settings.APLUGIN_FOLDER, "GeoIP.dat");
try { try {
if (file.exists()) { if (file.exists()) {