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

Signed-off-by: j502647092 <jtb1@163.com>
master
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 Server server;
public boolean antibotMod = false;
public static AuthMe getInstance() {
return authme;
}
public boolean antibotMod = false;
public NewAPI api;
public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
@ -81,6 +85,7 @@ public class AuthMe extends JavaPlugin {
public Location essentialsSpawn;
public AuthMeInventoryPacketAdapter inventoryProtector;
public Management management;
public OtherAccounts otherAccounts;
public Permission permission;
@ -89,17 +94,13 @@ public class AuthMe extends JavaPlugin {
// TODO: Create Manager for fields below
public ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
private Logger authmeLogger;
private Messages m;
private JsonCache playerBackup;
private Settings settings;
public static AuthMe getInstance() {
return authme;
}
public boolean authmePermissible(final CommandSender sender, final String perm) {
if (sender.hasPermission(perm)) {
return true;
@ -311,11 +312,14 @@ public class AuthMe extends JavaPlugin {
}
// Load settings and custom configurations
// TODO: new configuration style (more files)
try {
settings = new Settings(this);
Settings.reloadcfg();
Settings.loadVariables();
// Setup messages
m = Messages.getInstance();
// Setup otherAccounts file
otherAccounts = OtherAccounts.getInstance();
} catch (final Exception e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("无法载入配置文件... 某些配置是错误的, 为了安全考虑 服务器即将关闭!");
@ -327,12 +331,6 @@ public class AuthMe extends JavaPlugin {
return;
}
// Setup otherAccounts file
otherAccounts = OtherAccounts.getInstance();
// Setup messages
m = Messages.getInstance();
// Set Console Filter
if (Settings.removePassword) {
final ConsoleFilter filter = new ConsoleFilter();
@ -343,7 +341,8 @@ public class AuthMe extends JavaPlugin {
// Set Log4J Filter
try {
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) {
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
ConsoleLogger.info("[LICENSE] IP数据来自 CityCraft 的 Yum 源 原始数据来自 http://www.maxmind.com");
Utils.checkGeoIP();
// Find Permissions
@ -710,16 +710,4 @@ public class AuthMe extends JavaPlugin {
}
}, 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
*/
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() {
}
@ -19,20 +20,20 @@ public class ConsoleFilter implements Filter {
return true;
}
final String logM = record.getMessage().toLowerCase();
System.out.println("AuthMe LogRecord : " + logM);
if (!logM.contains("issued server command:")) {
return true;
}
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ")
&& !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ")
&& !logM.contains("/register ")) {
return true;
for (final String key : filterkey) {
if (logM.contains(key)) {
final String playername = record.getMessage().split(" ")[0];
record.setMessage(playername + " 执行了一个 AuthMe 命令!");
break;
}
}
final String playername = record.getMessage().split(" ")[0];
record.setMessage(playername + " 执行了一个 AuthMe 命令!");
return false;
} catch (final NullPointerException npe) {
return true;
}
return true;
}
}

View File

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