mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-16 23:35:02 +02:00
commit
cf5c76f353
@ -3,6 +3,7 @@ package fr.xephi.authme.cache.backup;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
@ -51,7 +52,7 @@ public class FileCache {
|
||||
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "playerdatas.cache");
|
||||
|
||||
if (!file.getParentFile().exists())
|
||||
file.getParentFile().mkdir();
|
||||
file.getParentFile().mkdirs();
|
||||
if (file.exists()) {
|
||||
return;
|
||||
}
|
||||
@ -68,7 +69,7 @@ public class FileCache {
|
||||
|
||||
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory");
|
||||
|
||||
file.mkdir();
|
||||
file.mkdirs();
|
||||
ItemStack[] inv = playerData.getInventory();
|
||||
for (int i = 0; i < inv.length; i++) {
|
||||
ItemStack item = inv[i];
|
||||
@ -108,14 +109,20 @@ public class FileCache {
|
||||
if (Settings.customAttributes) {
|
||||
try {
|
||||
Attributes attributes = new Attributes(item);
|
||||
if (attributes != null)
|
||||
while (attributes.values().iterator().hasNext()) {
|
||||
Attribute a = attributes.values().iterator().next();
|
||||
if (attributes != null) {
|
||||
Iterator<Attribute> iter = attributes.values().iterator();
|
||||
Attribute a = null;
|
||||
while (iter.hasNext()) {
|
||||
Attribute b = iter.next();
|
||||
if (a != null && a == b)
|
||||
break;
|
||||
a = b;
|
||||
if (a != null) {
|
||||
if (a.getName() != null && a.getAttributeType() != null && a.getOperation() != null && a.getUUID() != null)
|
||||
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Error e) {
|
||||
}
|
||||
@ -128,8 +135,8 @@ public class FileCache {
|
||||
|
||||
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours");
|
||||
if (!file.getParentFile().exists())
|
||||
file.getParentFile().mkdir();
|
||||
file.mkdir();
|
||||
file.getParentFile().mkdirs();
|
||||
file.mkdirs();
|
||||
|
||||
ItemStack[] armors = playerData.getArmour();
|
||||
for (int i = 0; i < armors.length; i++) {
|
||||
@ -393,8 +400,7 @@ public class FileCache {
|
||||
line = line.substring(8);
|
||||
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
||||
}
|
||||
if (Settings.customAttributes)
|
||||
{
|
||||
if (Settings.customAttributes) {
|
||||
if (line.startsWith("attribute=")) {
|
||||
if (attributes == null)
|
||||
attributes = new Attributes(item);
|
||||
@ -468,8 +474,7 @@ public class FileCache {
|
||||
line = line.substring(8);
|
||||
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
||||
}
|
||||
if (Settings.customAttributes)
|
||||
{
|
||||
if (Settings.customAttributes) {
|
||||
if (line.startsWith("attribute=")) {
|
||||
if (attributes == null)
|
||||
attributes = new Attributes(item);
|
||||
|
@ -53,6 +53,11 @@ public class ChangePasswordCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String lowpass = args[1].toLowerCase();
|
||||
if ((lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null")) || !lowpass.matches(Settings.getPassRegex)) {
|
||||
m.send(player, "password_error");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, args[1], name);
|
||||
|
||||
|
@ -29,6 +29,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -353,6 +354,12 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.isAuthAvailable(name)) {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
@ -400,7 +407,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.countriesBlacklist.isEmpty()) {
|
||||
if (Settings.enablePasspartu && !Settings.countriesBlacklist.isEmpty()) {
|
||||
String code = plugin.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
||||
event.setKickMessage(m.send("country_banned")[0]);
|
||||
@ -566,6 +573,58 @@ public class AuthMePlayerListener implements Listener {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if (event.getPlayer() == null)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName();
|
||||
String regex = Settings.getNickRegex;
|
||||
if (Settings.enableProtection && !Settings.countriesBlacklist.isEmpty()) {
|
||||
String code = plugin.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
||||
event.setKickMessage(m.send("country_banned")[0]);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Settings.enableProtection && !Settings.countries.isEmpty()) {
|
||||
String code = plugin.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (((code == null) || (!Settings.countries.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
||||
event.setKickMessage(m.send("country_banned")[0]);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (!player.getName().matches(regex) || name.equals("Player")) {
|
||||
try {
|
||||
event.setKickMessage(m.send("regex")[0].replace("REG_EX", regex));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
} catch (Exception exc) {
|
||||
event.setKickMessage("allowed char : " + regex);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (PatternSyntaxException pse) {
|
||||
if (regex == null || regex.isEmpty()) {
|
||||
event.setKickMessage("Your nickname do not match");
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
event.setKickMessage(m.send("regex")[0].replace("REG_EX", regex));
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
} catch (Exception exc) {
|
||||
event.setKickMessage("allowed char : " + regex);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (event.getPlayer() == null) {
|
||||
@ -829,7 +888,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
}
|
||||
if (limbo.getTimeoutTaskId() != null)
|
||||
limbo.getTimeoutTaskId().cancel();
|
||||
if (limbo.getMessageTaskId() != null)
|
||||
limbo.getMessageTaskId().cancel();
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (playerBackup.doesCacheExist(player)) {
|
||||
@ -916,7 +977,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
}
|
||||
if (limbo.getTimeoutTaskId() != null)
|
||||
limbo.getTimeoutTaskId().cancel();
|
||||
if (limbo.getMessageTaskId() != null)
|
||||
limbo.getMessageTaskId().cancel();
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (this.playerBackup.doesCacheExist(player)) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.process;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@ -34,11 +35,21 @@ public class Management extends Thread {
|
||||
|
||||
public void performLogin(final Player player, final String password,
|
||||
final boolean forceLogin) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousLogin(player, password, forceLogin, plugin, database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void performRegister(final Player player, final String password,
|
||||
final String email) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousRegister(player, password, email, plugin, database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,9 @@ public class AsyncronousLogin {
|
||||
// processed in other order.
|
||||
ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(player, plugin, database);
|
||||
if (syncronousPlayerLogin.getLimbo() != null) {
|
||||
if (syncronousPlayerLogin.getLimbo().getTimeoutTaskId() != null)
|
||||
syncronousPlayerLogin.getLimbo().getTimeoutTaskId().cancel();
|
||||
if (syncronousPlayerLogin.getLimbo().getMessageTaskId() != null)
|
||||
syncronousPlayerLogin.getLimbo().getMessageTaskId().cancel();
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncronousPlayerLogin);
|
||||
|
Loading…
Reference in New Issue
Block a user