Merge branch 'Xephi-master'

This commit is contained in:
Gabriele C 2015-10-20 22:05:44 +02:00
commit 8df8e8069a
5 changed files with 30 additions and 20 deletions

View File

@ -108,8 +108,8 @@ public class DataManager {
continue;
}
try {
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
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) {
@ -129,12 +129,12 @@ public class DataManager {
public void purgeEssentials(List<String> cleared) {
int i = 0;
for (String name : cleared) {
try {
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");
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
if (playerFile.exists()) {
playerFile.delete();
i++;
@ -145,7 +145,7 @@ public class DataManager {
}
public synchronized void purgePermissions(List<String> cleared,
Permission permission) {
Permission permission) {
int i = 0;
for (String name : cleared) {
try {
@ -165,6 +165,7 @@ public class DataManager {
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())
@ -182,4 +183,13 @@ public class DataManager {
executor.shutdown();
}
}
public Player getOnlinePlayerLower(String name) {
name = name.toLowerCase();
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.getName().equalsIgnoreCase(name))
return player;
}
return null;
}
}

View File

@ -95,14 +95,14 @@ public class SendMailSSL {
ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail);
}
}
Transport transport = session.getTransport("smtp");
message.setContent(multipart);
try {
transport.connect(smtp, acc, password);
} catch (Exception e) {
ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recorvery email to " + mail);
ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recovery email to " + mail);
if (file != null)
file.delete();
return;

View File

@ -209,6 +209,7 @@ public class AuthMePlayerListener implements Listener {
// Shedule login task so works after the prelogin
// (Fix found by Koolaid5000)
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Player player = event.getPlayer();
@ -225,28 +226,27 @@ public class AuthMePlayerListener implements Listener {
});
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
final String name = event.getName().toLowerCase();
final Player player = Bukkit.getServer().getPlayer(name);
final Player player = plugin.dataManager.getOnlinePlayerLower(name);
if (player == null)
return;
// Check if forceSingleSession is set to true, so kick player that has
// joined with same nick of online player
if (Settings.isForceSingleSessionEnabled && plugin.dataManager.isOnline(player, name)) {
event.setKickMessage(m.send("same_nick")[0]);
if (Settings.isForceSingleSessionEnabled) {
event.setKickMessage(m.getString("same_nick"));
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
if (LimboCache.getInstance().hasLimboPlayer(name))
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
if (limbo != null && PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo != null && PlayerCache.getInstance().isAuthenticated(name)) {
Utils.addNormal(player, limbo.getGroup());
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
LimboCache.getInstance().deleteLimboPlayer(name);
}
}
});
@ -268,8 +268,7 @@ public class AuthMePlayerListener implements Listener {
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED)
return;
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable
&& !plugin.authmePermissible(player, "authme.bypassantibot")) {
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) {
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
event.setKickMessage(m.send("country_banned")[0]);
@ -277,8 +276,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
}
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable
&& !plugin.authmePermissible(player, "authme.bypassantibot")) {
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) {
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || !Settings.countries.contains(code))) {
event.setKickMessage(m.send("country_banned")[0]);

View File

@ -280,7 +280,7 @@ public final class Settings extends YamlConfiguration {
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
forceRegisterCommandsAsConsole = configFile.getStringList("settings.forceRegisterCommandsAsConsole");
customAttributes = configFile.getBoolean("Hooks.customAttributes");
generateImage = configFile.getBoolean("Email.generateImage", true);
generateImage = configFile.getBoolean("Email.generateImage", false);
isMySQLWebsite = configFile.getBoolean("DataSource.mySQLWebsite", false);
// Load the welcome message
@ -476,7 +476,7 @@ public final class Settings extends YamlConfiguration {
changes = true;
}
if (!contains("Email.generateImage")) {
set("Email.generateImage", true);
set("Email.generateImage", false);
changes = true;
}
if (!contains("DataSource.mySQLRealName")) {

View File

@ -352,6 +352,8 @@ Email:
- 10minutemail.com
# WhiteList only these domains for emails
emailWhitelisted: []
# Do we need to send new password draw in an image ?
generateImage: false
Hooks:
# Do we need to hook with multiverse for spawn checking?
multiverse: true