mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 15:17:56 +01:00
Some minor automatic fixes and changes
This commit is contained in:
parent
1cdf49f7e1
commit
f15eaae67f
@ -878,8 +878,8 @@ public class AuthMe extends JavaPlugin {
|
||||
ip = realIp.get(name);
|
||||
}
|
||||
if (Settings.checkVeryGames)
|
||||
if (getVeryGamesIP(player) != null)
|
||||
ip = getVeryGamesIP(player);
|
||||
if (getVeryGamesIp(player) != null)
|
||||
ip = getVeryGamesIp(player);
|
||||
return ip;
|
||||
}
|
||||
|
||||
@ -908,11 +908,12 @@ public class AuthMe extends JavaPlugin {
|
||||
/**
|
||||
* Gets a player's real IP through VeryGames method.
|
||||
*
|
||||
* @param player the player to process
|
||||
* @return the real IP of the player
|
||||
* @param player The player to process.
|
||||
*
|
||||
* @return The real IP of the player.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getVeryGamesIP(Player player) {
|
||||
public String getVeryGamesIp(Player player) {
|
||||
String realIP = player.getAddress().getAddress().getHostAddress();
|
||||
String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
|
||||
sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress()).replace("%PORT%", "" + player.getAddress().getPort());
|
||||
|
@ -30,8 +30,8 @@ public class ConsoleFilter implements Filter {
|
||||
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;
|
||||
String playername = record.getMessage().split(" ")[0];
|
||||
record.setMessage(playername + " issued an AuthMe command!");
|
||||
String playerName = record.getMessage().split(" ")[0];
|
||||
record.setMessage(playerName + " issued an AuthMe command!");
|
||||
return true;
|
||||
} catch (NullPointerException npe) {
|
||||
return true;
|
||||
|
@ -1,261 +1,269 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DataManager {
|
||||
|
||||
public AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for DataManager.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public DataManager(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOfflinePlayer.
|
||||
*
|
||||
* @param name String
|
||||
* @return OfflinePlayer
|
||||
*/
|
||||
public synchronized OfflinePlayer getOfflinePlayer(final String name) {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
|
||||
|
||||
public synchronized OfflinePlayer call() throws Exception {
|
||||
OfflinePlayer result = null;
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
result = op;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return (null);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeAntiXray.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeAntiXray(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeLimitedCreative.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeLimitedCreative(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeDat.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeDat(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception ignore) {
|
||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeEssentials.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void purgeEssentials(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||
}
|
||||
|
||||
// TODO: What is this method for? Is it correct?
|
||||
|
||||
/**
|
||||
* @param cleared Cleared players.
|
||||
*/
|
||||
public synchronized void purgePermissions(List<String> cleared) {
|
||||
// Get the permissions manager, and make sure it's valid
|
||||
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
||||
if (permsMan == null)
|
||||
ConsoleLogger.showError("Unable to access permissions manager instance!");
|
||||
assert permsMan != null;
|
||||
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase()));
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions");
|
||||
|
||||
/*int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
OfflinePlayer p = this.getOfflinePlayer(name);
|
||||
for (String group : permission.getPlayerGroups((Player) p)) {
|
||||
permission.playerRemoveGroup(null, p, group);
|
||||
}
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isOnline.
|
||||
*
|
||||
* @param player Player
|
||||
* @param name String
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isOnline(Player player, final String name) {
|
||||
if (player.isOnline())
|
||||
return true;
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
@Override
|
||||
public synchronized Boolean call() throws Exception {
|
||||
for (OfflinePlayer op : Utils.getOnlinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOnlinePlayerLower.
|
||||
*
|
||||
* @param name String
|
||||
* @return Player
|
||||
*/
|
||||
public Player getOnlinePlayerLower(String name) {
|
||||
name = name.toLowerCase();
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DataManager {
|
||||
|
||||
public AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for DataManager.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public DataManager(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOfflinePlayer.
|
||||
*
|
||||
* @param name String
|
||||
* @return OfflinePlayer
|
||||
*/
|
||||
public synchronized OfflinePlayer getOfflinePlayer(final String name) {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
|
||||
|
||||
public synchronized OfflinePlayer call() throws Exception {
|
||||
OfflinePlayer result = null;
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
result = op;
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return (null);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeAntiXray.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeAntiXray(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeLimitedCreative.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeLimitedCreative(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeDat.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeDat(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception ignore) {
|
||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeEssentials.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void purgeEssentials(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||
}
|
||||
|
||||
// TODO: What is this method for? Is it correct?
|
||||
|
||||
/**
|
||||
* @param cleared Cleared players.
|
||||
*/
|
||||
public synchronized void purgePermissions(List<String> cleared) {
|
||||
// Get the permissions manager, and make sure it's valid
|
||||
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
||||
if (permsMan == null)
|
||||
ConsoleLogger.showError("Unable to access permissions manager instance!");
|
||||
assert permsMan != null;
|
||||
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase()));
|
||||
i++;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions");
|
||||
|
||||
/*int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
OfflinePlayer p = this.getOfflinePlayer(name);
|
||||
for (String group : permission.getPlayerGroups((Player) p)) {
|
||||
permission.playerRemoveGroup(null, p, group);
|
||||
}
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isOnline.
|
||||
*
|
||||
* @param player Player
|
||||
* @param name String
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isOnline(Player player, final String name) {
|
||||
if (player.isOnline())
|
||||
return true;
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
@Override
|
||||
public synchronized Boolean call() throws Exception {
|
||||
for (OfflinePlayer op : Utils.getOnlinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOnlinePlayerLower.
|
||||
*
|
||||
* @param name String
|
||||
* @return Player
|
||||
*/
|
||||
public Player getOnlinePlayerLower(String name) {
|
||||
name = name.toLowerCase();
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class PerformBackup {
|
||||
*/
|
||||
private boolean checkWindows(String windowsPath) {
|
||||
String isWin = System.getProperty("os.name").toLowerCase();
|
||||
if (isWin.indexOf("win") >= 0) {
|
||||
if (isWin.contains("win")) {
|
||||
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -34,15 +34,15 @@ public class SendMailSSL {
|
||||
* @param newPass String
|
||||
*/
|
||||
public void main(final PlayerAuth auth, final String newPass) {
|
||||
String sendername;
|
||||
String senderName;
|
||||
|
||||
if (Settings.getmailSenderName == null || Settings.getmailSenderName.isEmpty()) {
|
||||
sendername = Settings.getmailAccount;
|
||||
senderName = Settings.getmailAccount;
|
||||
} else {
|
||||
sendername = Settings.getmailSenderName;
|
||||
senderName = Settings.getmailSenderName;
|
||||
}
|
||||
|
||||
final String sender = sendername;
|
||||
final String sender = senderName;
|
||||
final int port = Settings.getMailPort;
|
||||
final String acc = Settings.getmailAccount;
|
||||
final String subject = Settings.getMailSubject;
|
||||
@ -90,6 +90,7 @@ public class SendMailSSL {
|
||||
ConsoleLogger.showError("Fail to send a mail to " + mail);
|
||||
}
|
||||
if (file != null)
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.delete();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user