mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-07 04:38:03 +02:00
Prevent some NPE on (auto)purge
This commit is contained in:
parent
35a4e6508c
commit
7ba37d75c9
@ -43,15 +43,17 @@ public class DataManager extends Thread {
|
|||||||
public void purgeAntiXray(List<String> cleared) {
|
public void purgeAntiXray(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
try {
|
||||||
if (player == null)
|
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||||
continue;
|
if (player == null)
|
||||||
String playerName = player.getName();
|
continue;
|
||||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
String playerName = player.getName();
|
||||||
if (playerFile.exists()) {
|
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||||
playerFile.delete();
|
if (playerFile.exists()) {
|
||||||
i++;
|
playerFile.delete();
|
||||||
}
|
i++;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||||
}
|
}
|
||||||
@ -59,25 +61,27 @@ public class DataManager extends Thread {
|
|||||||
public void purgeLimitedCreative(List<String> cleared) {
|
public void purgeLimitedCreative(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
try {
|
||||||
if (player == null)
|
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||||
continue;
|
if (player == null)
|
||||||
String playerName = player.getName();
|
continue;
|
||||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
String playerName = player.getName();
|
||||||
if (playerFile.exists()) {
|
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||||
playerFile.delete();
|
if (playerFile.exists()) {
|
||||||
i++;
|
playerFile.delete();
|
||||||
}
|
i++;
|
||||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
}
|
||||||
if (playerFile.exists()) {
|
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||||
playerFile.delete();
|
if (playerFile.exists()) {
|
||||||
i++;
|
playerFile.delete();
|
||||||
}
|
i++;
|
||||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
}
|
||||||
if (playerFile.exists()) {
|
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||||
playerFile.delete();
|
if (playerFile.exists()) {
|
||||||
i++;
|
playerFile.delete();
|
||||||
}
|
i++;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||||
}
|
}
|
||||||
@ -85,15 +89,17 @@ public class DataManager extends Thread {
|
|||||||
public void purgeDat(List<String> cleared) {
|
public void purgeDat(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
try {
|
||||||
if (player == null)
|
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||||
continue;
|
if (player == null)
|
||||||
String playerName = player.getName();
|
continue;
|
||||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + playerName + ".dat");
|
String playerName = player.getName();
|
||||||
if (playerFile.exists()) {
|
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + playerName + ".dat");
|
||||||
playerFile.delete();
|
if (playerFile.exists()) {
|
||||||
i++;
|
playerFile.delete();
|
||||||
}
|
i++;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||||
}
|
}
|
||||||
@ -101,11 +107,13 @@ public class DataManager extends Thread {
|
|||||||
public void purgeEssentials(List<String> cleared) {
|
public void purgeEssentials(List<String> cleared) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (String name : cleared) {
|
for (String name : cleared) {
|
||||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
try {
|
||||||
if (playerFile.exists()) {
|
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||||
playerFile.delete();
|
if (playerFile.exists()) {
|
||||||
i++;
|
playerFile.delete();
|
||||||
}
|
i++;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||||
}
|
}
|
||||||
|
@ -45,14 +45,12 @@ public class SendMailSSL {
|
|||||||
props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
|
props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
|
||||||
|
|
||||||
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
|
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
|
||||||
|
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
return new PasswordAuthentication(Settings.getmailAccount, Settings.getmailPassword);
|
return new PasswordAuthentication(Settings.getmailAccount, Settings.getmailPassword);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final Message message = new MimeMessage(session);
|
final Message message = new MimeMessage(session);
|
||||||
try {
|
try {
|
||||||
message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
|
message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
|
||||||
@ -68,7 +66,6 @@ public class SendMailSSL {
|
|||||||
text = text.replace("<generatedpass>", newPass);
|
text = text.replace("<generatedpass>", newPass);
|
||||||
message.setContent(text, "text/html");
|
message.setContent(text, "text/html");
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -84,5 +81,4 @@ public class SendMailSSL {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user