mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-22 18:25:27 +01:00
Update 3.3.4
//Changes 3.3.4:// * Add an isLogged column in mySQL * Add a maxLoginPerIp * Add a maxJoinPerIp * Add a way to force kick after register * Add a way to force login after register * Update session correctly * Fix Change Email command * Fix some perm problems * Fix some problems with email sending * Remove some dead code * Add a way to control spawn priority, by default , in order, it is : authme,essentials,multiverse,default
This commit is contained in:
parent
4e7e9e6cb4
commit
b659d8968e
2
pom.xml
2
pom.xml
@ -24,7 +24,7 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<version>3.3.3</version>
|
||||
<version>3.3.4</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -55,7 +55,6 @@ import fr.xephi.authme.datasource.FileDataSource;
|
||||
import fr.xephi.authme.datasource.MySQLDataSource;
|
||||
import fr.xephi.authme.datasource.SqliteDataSource;
|
||||
import fr.xephi.authme.listener.AuthMeBlockListener;
|
||||
import fr.xephi.authme.listener.AuthMeBungeeCordListener;
|
||||
import fr.xephi.authme.listener.AuthMeChestShopListener;
|
||||
import fr.xephi.authme.listener.AuthMeEntityListener;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
@ -74,7 +73,6 @@ import fr.xephi.authme.threads.FlatFileThread;
|
||||
import fr.xephi.authme.threads.MySQLThread;
|
||||
import fr.xephi.authme.threads.SQLiteThread;
|
||||
|
||||
|
||||
public class AuthMe extends JavaPlugin {
|
||||
|
||||
public DataSource database = null;
|
||||
@ -85,7 +83,6 @@ public class AuthMe extends JavaPlugin {
|
||||
public static Logger authmeLogger = Logger.getLogger("AuthMe");
|
||||
public static AuthMe authme;
|
||||
public Permission permission;
|
||||
private static AuthMe instance;
|
||||
private Utils utils = Utils.getInstance();
|
||||
private JavaPlugin plugin;
|
||||
private FileCache playerBackup = new FileCache();
|
||||
@ -115,16 +112,15 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
authme = instance;
|
||||
authme = this;
|
||||
|
||||
authmeLogger.setParent(this.getLogger());
|
||||
|
||||
citizens = new CitizensCommunicator(this);
|
||||
|
||||
settings = new Settings(this);
|
||||
settings.loadConfigOptions();
|
||||
|
||||
citizens = new CitizensCommunicator(this);
|
||||
|
||||
if (Settings.enableAntiBot) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@Override
|
||||
@ -275,13 +271,6 @@ public class AuthMe extends JavaPlugin {
|
||||
if (Settings.bungee) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
|
||||
try {
|
||||
if (Class.forName("net.md_5.bungee.api.event.ChatEvent") != null) {
|
||||
pm.registerEvents(new AuthMeBungeeCordListener(database, this), this);
|
||||
ConsoleLogger.info("Successfully hook with BungeeCord!");
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
}
|
||||
if (pm.isPluginEnabled("Spout")) {
|
||||
pm.registerEvents(new AuthMeSpoutListener(database), this);
|
||||
@ -312,14 +301,10 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
if (Settings.reloadSupport)
|
||||
try {
|
||||
if (!new File(getDataFolder() + File.separator + "players.yml").exists()) {
|
||||
pllog = new PlayersLogs();
|
||||
}
|
||||
onReload();
|
||||
if (server.getOnlinePlayers().length < 1) {
|
||||
try {
|
||||
PlayersLogs.players.clear();
|
||||
pllog.save();
|
||||
database.purgeLogged();
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
@ -486,7 +471,6 @@ public class AuthMe extends JavaPlugin {
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
this.savePlayer(player);
|
||||
}
|
||||
pllog.save();
|
||||
|
||||
if (database != null) {
|
||||
database.close();
|
||||
@ -506,9 +490,9 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
private void onReload() {
|
||||
try {
|
||||
if (Bukkit.getServer().getOnlinePlayers() != null && !PlayersLogs.players.isEmpty()) {
|
||||
if (Bukkit.getServer().getOnlinePlayers() != null) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
if (database.isLogged(player.getName().toLowerCase())) {
|
||||
String name = player.getName().toLowerCase();
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if(pAuth == null)
|
||||
@ -526,7 +510,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static AuthMe getInstance() {
|
||||
return instance;
|
||||
return authme;
|
||||
}
|
||||
|
||||
public void savePlayer(Player player) throws IllegalStateException, NullPointerException {
|
||||
@ -561,6 +545,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
player.saveData();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
@ -636,23 +621,8 @@ public class AuthMe extends JavaPlugin {
|
||||
purgeLimitedCreative(cleared);
|
||||
if (Settings.purgeAntiXray)
|
||||
purgeAntiXray(cleared);
|
||||
//if (Settings.purgePermissions && permission != null)
|
||||
//purgePerms(cleared);
|
||||
}
|
||||
|
||||
/* private void purgePerms(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
if (player == null) continue;
|
||||
String playerName = player.getName();
|
||||
for (String group : permission.getPlayerGroups((String) null, playerName)) {
|
||||
permission.playerRemoveGroup((String) null, playerName, group);
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " players permissions");
|
||||
} */
|
||||
|
||||
public void purgeAntiXray(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
@ -720,28 +690,59 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||
}
|
||||
|
||||
public Location getSpawnLocation(String name, World world) {
|
||||
public Location getSpawnLocation(Player player, World world) {
|
||||
String[] spawnPriority = Settings.spawnPriority.split(",");
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
int i = 3;
|
||||
for (i = 3 ; i >= 0 ; i--) {
|
||||
String s = spawnPriority[i];
|
||||
if (s.equalsIgnoreCase("default") && getDefaultSpawn(world) != null)
|
||||
spawnLoc = getDefaultSpawn(world);
|
||||
if (s.equalsIgnoreCase("multiverse") && getMultiverseSpawn(world) != null)
|
||||
spawnLoc = getMultiverseSpawn(world);
|
||||
if (s.equalsIgnoreCase("essentials") && getEssentialsSpawn() != null)
|
||||
spawnLoc = getEssentialsSpawn();
|
||||
if (s.equalsIgnoreCase("authme") && getAuthMeSpawn(player) != null)
|
||||
spawnLoc = getAuthMeSpawn(player);
|
||||
}
|
||||
if (spawnLoc == null)
|
||||
spawnLoc = world.getSpawnLocation();
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
private Location getDefaultSpawn(World world) {
|
||||
return world.getSpawnLocation();
|
||||
}
|
||||
|
||||
private Location getMultiverseSpawn(World world) {
|
||||
if (multiverse != null && Settings.multiverse) {
|
||||
try {
|
||||
spawnLoc = multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
return multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (essentialsSpawn != null) {
|
||||
spawnLoc = essentialsSpawn;
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location getEssentialsSpawn() {
|
||||
if (essentialsSpawn != null) {
|
||||
return essentialsSpawn;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location getAuthMeSpawn(Player player) {
|
||||
if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && Spawn.getInstance().getFirstSpawn() != null)
|
||||
return Spawn.getInstance().getFirstSpawn();
|
||||
if (Spawn.getInstance().getSpawn() != null)
|
||||
spawnLoc = Spawn.getInstance().getSpawn();
|
||||
if (!database.isAuthAvailable(name) && Spawn.getInstance().getFirstSpawn() != null)
|
||||
spawnLoc = Spawn.getInstance().getFirstSpawn();
|
||||
return spawnLoc;
|
||||
return Spawn.getInstance().getSpawn();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void downloadGeoIp() {
|
||||
ConsoleLogger.info(" This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
|
||||
ConsoleLogger.info("LICENSE : This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
|
||||
File file = new File(getDataFolder(), "GeoIP.dat");
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@ -829,4 +830,29 @@ public class AuthMe extends JavaPlugin {
|
||||
} catch (Exception e) {}
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getIP(Player player, String name) {
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
if (realIp.containsKey(name))
|
||||
ip = realIp.get(name);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
public boolean isLoggedIp(String ip) {
|
||||
for (Player player : this.getServer().getOnlinePlayers()) {
|
||||
if(ip.equalsIgnoreCase(getIP(player, player.getName())) && database.isLogged(player.getName().toLowerCase()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasJoinedIp(String ip) {
|
||||
for (Player player : this.getServer().getOnlinePlayers()) {
|
||||
if(ip.equalsIgnoreCase(getIP(player, player.getName())))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ import fr.xephi.authme.settings.Settings;
|
||||
*/
|
||||
public class SendMailSSL {
|
||||
|
||||
public AuthMe instance;
|
||||
public AuthMe plugin;
|
||||
|
||||
public SendMailSSL(AuthMe instance) {
|
||||
this.instance = instance;
|
||||
public SendMailSSL(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public void main(final PlayerAuth auth, final String newPass) {
|
||||
|
||||
public void main(final PlayerAuth auth, final String newPass) {
|
||||
String sendername;
|
||||
|
||||
if (Settings.getmailSenderName.isEmpty() || Settings.getmailSenderName == null) {
|
||||
@ -65,11 +65,11 @@ public class SendMailSSL {
|
||||
message.setSubject(Settings.getMailSubject);
|
||||
message.setSentDate(new Date());
|
||||
String text = Settings.getMailText;
|
||||
text = text.replaceAll("<playername>", auth.getNickname());
|
||||
text = text.replaceAll("<servername>", instance.getServer().getServerName());
|
||||
text = text.replaceAll("<generatedpass>", newPass);
|
||||
text = text.replace("<playername>", auth.getNickname());
|
||||
text = text.replace("<servername>", plugin.getServer().getServerName());
|
||||
text = text.replace("<generatedpass>", newPass);
|
||||
message.setContent(text, "text/html");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(instance, new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
@ -97,6 +97,12 @@ public class PlayerAuth {
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
if (ip == null || ip.isEmpty())
|
||||
ip = "127.0.0.1";
|
||||
|
@ -89,7 +89,7 @@ public class LimboCache {
|
||||
gameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
if(player.isDead()) {
|
||||
loc = plugin.getSpawnLocation(player.getName().toLowerCase(), player.getWorld());
|
||||
loc = plugin.getSpawnLocation(player, player.getWorld());
|
||||
}
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
|
||||
}
|
||||
|
@ -179,11 +179,11 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("[AuthMe] The player : " + player.getNickname() + " is unlogged since " + msg);
|
||||
sender.sendMessage("[AuthMe] LastPlayer IP : " + lastIP);
|
||||
} else {
|
||||
sender.sendMessage("This player does not exist");
|
||||
m._(sender, "unknown_user");
|
||||
return true;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
sender.sendMessage("This player does not exist");
|
||||
m._(sender, "unknown_user");
|
||||
return true;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("accounts")) {
|
||||
@ -344,7 +344,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
String playername = args[1].toLowerCase();
|
||||
PlayerAuth getAuth = database.getAuth(playername);
|
||||
if (getAuth == null) {
|
||||
sender.sendMessage("This player does not exist");
|
||||
m._(sender, "unknown_user");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage("[AuthMe] " + args[1] + " email : " + getAuth.getEmail());
|
||||
@ -357,7 +357,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
String playername = args[1].toLowerCase();
|
||||
PlayerAuth getAuth = database.getAuth(playername);
|
||||
if (getAuth == null) {
|
||||
sender.sendMessage("This player does not exist");
|
||||
m._(sender, "unknown_user");
|
||||
return true;
|
||||
}
|
||||
getAuth.setEmail(args[2]);
|
||||
@ -506,7 +506,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
if (target != null) {
|
||||
if (target.isOnline()) {
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawn = plugin.getSpawnLocation(name, target.getWorld());
|
||||
Location spawn = plugin.getSpawnLocation(target, target.getWorld());
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
|
@ -92,9 +92,13 @@ public class EmailCommand implements CommandExecutor {
|
||||
m._(player, "reg_email_msg");
|
||||
}
|
||||
}
|
||||
} else if(args[0].equalsIgnoreCase("change") && args.length == 3 ) {
|
||||
} else if(args[0].equalsIgnoreCase("change")) {
|
||||
if (args.length != 3) {
|
||||
m._(player, "usage_email_change");
|
||||
return true;
|
||||
}
|
||||
if(Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
|
||||
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) {
|
||||
m._(player, "max_reg");
|
||||
return true;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
@ -30,7 +29,6 @@ import fr.xephi.authme.task.TimeoutTask;
|
||||
public class LogoutCommand implements CommandExecutor {
|
||||
|
||||
private Messages m = Messages.getInstance();
|
||||
private PlayersLogs pllog = PlayersLogs.getInstance();
|
||||
private AuthMe plugin;
|
||||
private DataSource database;
|
||||
private Utils utils = Utils.getInstance();
|
||||
@ -61,7 +59,6 @@ public class LogoutCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
auth.setIp("198.18.0.1");
|
||||
database.updateSession(auth);
|
||||
auth.setQuitLocX(player.getLocation().getX());
|
||||
auth.setQuitLocY(player.getLocation().getY());
|
||||
@ -70,9 +67,10 @@ public class LogoutCommand implements CommandExecutor {
|
||||
database.updateQuitLoc(auth);
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawnLoc = plugin.getSpawnLocation(name, player.getWorld());
|
||||
Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld());
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
@ -104,10 +102,6 @@ public class LogoutCommand implements CommandExecutor {
|
||||
int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
try {
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
pllog.save();
|
||||
}
|
||||
if (player.isInsideVehicle())
|
||||
player.getVehicle().eject();
|
||||
} catch (NullPointerException npe) {
|
||||
|
@ -23,7 +23,6 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
@ -32,7 +31,6 @@ import fr.xephi.authme.task.TimeoutTask;
|
||||
public class UnregisterCommand implements CommandExecutor {
|
||||
|
||||
private Messages m = Messages.getInstance();
|
||||
private PlayersLogs pllog = PlayersLogs.getInstance();
|
||||
public AuthMe plugin;
|
||||
private DataSource database;
|
||||
private FileCache playerCache = new FileCache();
|
||||
@ -73,7 +71,7 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
}
|
||||
if(Settings.isForcedRegistrationEnabled) {
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
|
||||
Location spawn = plugin.getSpawnLocation(player, player.getWorld());
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
@ -110,17 +108,13 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
if(playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
pllog.save();
|
||||
}
|
||||
m._(player, "unregistered");
|
||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
|
||||
}
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
|
||||
Location spawn = plugin.getSpawnLocation(player, player.getWorld());
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
|
@ -191,4 +191,28 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return source.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return source.isLogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
source.setLogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
source.setUnlogged(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
source.purgeLogged();
|
||||
}
|
||||
}
|
||||
|
@ -48,4 +48,14 @@ public interface DataSource {
|
||||
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
DataSourceType getType();
|
||||
|
||||
boolean isLogged(String user);
|
||||
|
||||
void setLogged(String user);
|
||||
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.util.List;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
@ -629,4 +630,29 @@ public class FileDataSource implements DataSource {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayersLogs.getInstance().players.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().addPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().removePlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public class MySQLDataSource implements DataSource {
|
||||
private String lastlocWorld;
|
||||
private String columnEmail;
|
||||
private String columnID;
|
||||
private String columnLogged;
|
||||
private List<String> columnOthers;
|
||||
private MiniConnectionPoolManager conPool;
|
||||
|
||||
@ -62,6 +63,7 @@ public class MySQLDataSource implements DataSource {
|
||||
this.columnEmail = Settings.getMySQLColumnEmail;
|
||||
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
|
||||
connect();
|
||||
setup();
|
||||
@ -91,13 +93,14 @@ public class MySQLDataSource implements DataSource {
|
||||
+ columnID + " INTEGER AUTO_INCREMENT,"
|
||||
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
|
||||
+ columnPassword + " VARCHAR(255) NOT NULL,"
|
||||
+ columnIp + " VARCHAR(40) NOT NULL,"
|
||||
+ columnLastLogin + " BIGINT,"
|
||||
+ columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
|
||||
+ columnLastLogin + " BIGINT DEFAULT '0',"
|
||||
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0',"
|
||||
+ lastlocY + " DOUBLE NOT NULL DEFAULT '0.0',"
|
||||
+ lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0',"
|
||||
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
|
||||
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
|
||||
+ columnLogged + " SMALLINT NOT NULL DEFAULT '0',"
|
||||
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
if (!rs.next()) {
|
||||
@ -108,13 +111,13 @@ public class MySQLDataSource implements DataSource {
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
+ columnIp + " VARCHAR(40) NOT NULL;");
|
||||
+ columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
+ columnLastLogin + " BIGINT;");
|
||||
+ columnLastLogin + " BIGINT DEFAULT '0';");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
||||
@ -130,7 +133,12 @@ public class MySQLDataSource implements DataSource {
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocZ +";");
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocWorld +";");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail +";");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
||||
@ -806,4 +814,105 @@ public class MySQLDataSource implements DataSource {
|
||||
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.MYSQL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
|
||||
+ columnName + "=?;");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next())
|
||||
return (rs.getInt(columnLogged) == 1);
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
@ -509,4 +510,28 @@ public class SqliteDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayersLogs.getInstance().players.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().addPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().removePlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class AuthMeBungeeCordListener implements Listener {
|
||||
private DataSource data;
|
||||
private AuthMe plugin;
|
||||
|
||||
public AuthMeBungeeCordListener(DataSource data, AuthMe plugin) {
|
||||
this.data = data;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onBungeeChatEvent(ChatEvent event) {
|
||||
if (!Settings.bungee) return;
|
||||
if (event.isCancelled()) return;
|
||||
if (!event.isCommand()) return;
|
||||
Player player = null;
|
||||
try {
|
||||
for (String p : plugin.realIp.keySet()) {
|
||||
Player pl = Bukkit.getPlayer(p);
|
||||
if (pl != null) {
|
||||
if (plugin.realIp.get(p).equalsIgnoreCase(event.getSender().getAddress().getAddress().getHostAddress()))
|
||||
player = pl;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
if (player == null) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getAddress().getAddress().equals(event.getSender().getAddress().getAddress())) {
|
||||
player = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.isAuthAvailable(name)) {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
event.setMessage("/unreacheablecommand");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -56,7 +56,6 @@ import fr.xephi.authme.events.SessionEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
@ -366,7 +365,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
|
||||
int radius = Settings.getMovementRadius;
|
||||
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
|
||||
Location spawn = plugin.getSpawnLocation(player, player.getWorld());
|
||||
|
||||
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
|
||||
event.getPlayer().teleport(spawn);
|
||||
@ -543,7 +542,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
final String name = player.getName().toLowerCase();
|
||||
Location spawnLoc = plugin.getSpawnLocation(name, world);
|
||||
Location spawnLoc = plugin.getSpawnLocation(player, world);
|
||||
gm = player.getGameMode();
|
||||
gameMode.put(name, gm);
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
@ -573,6 +572,12 @@ public class AuthMePlayerListener implements Listener {
|
||||
plugin.getServer().banIP(ip);
|
||||
return;
|
||||
}
|
||||
if(Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
|
||||
if (plugin.hasJoinedIp(ip)) {
|
||||
player.kickPlayer("A player with the same IP is already in game!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (data.isAuthAvailable(name)) {
|
||||
if (Settings.isSessionsEnabled) {
|
||||
PlayerAuth auth = data.getAuth(name);
|
||||
@ -586,6 +591,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
} else {
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
data.setLogged(name);
|
||||
}
|
||||
m._(player, "valid_session");
|
||||
// Restore Permission Group
|
||||
@ -606,6 +612,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
//Player change his IP between 2 relog-in
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
data.setUnlogged(name);
|
||||
} else {
|
||||
GameMode gM = gameMode.get(name);
|
||||
this.causeByAuthMe = true;
|
||||
@ -617,6 +624,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
} else {
|
||||
//Session is ended correctly
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
data.setUnlogged(name);
|
||||
}
|
||||
}
|
||||
// isent in session or session was ended correctly
|
||||
@ -742,6 +750,12 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
if (plugin.realIp.containsKey(name))
|
||||
ip = plugin.realIp.get(name);
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
|
||||
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(name,loc.getX(),loc.getY(),loc.getZ(),loc.getWorld().getName());
|
||||
@ -749,6 +763,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
data.updateQuitLoc(auth);
|
||||
} catch (NullPointerException npe) { }
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
|
||||
data.updateSession(auth);
|
||||
}
|
||||
|
||||
if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
|
||||
@ -777,9 +793,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
data.setUnlogged(name);
|
||||
try {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
PlayersLogs.getInstance().save();
|
||||
player.getVehicle().eject();
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
@ -810,13 +825,22 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
|
||||
(Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)) {
|
||||
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
if (plugin.realIp.containsKey(name))
|
||||
ip = plugin.realIp.get(name);
|
||||
}
|
||||
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead())) {
|
||||
if ((Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)){
|
||||
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(),loc.getWorld().getName());
|
||||
try {
|
||||
data.updateQuitLoc(auth);
|
||||
} catch (NullPointerException npe) { }
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
|
||||
data.updateSession(auth);
|
||||
}
|
||||
|
||||
if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
|
||||
event.setLeaveMessage(null);
|
||||
@ -859,14 +883,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
this.playerBackup.removeCache(name);
|
||||
}
|
||||
}
|
||||
try {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
PlayersLogs.getInstance().save();
|
||||
data.setUnlogged(name);
|
||||
if (gameMode.containsKey(name)) gameMode.remove(name);
|
||||
try {
|
||||
player.getVehicle().eject();
|
||||
player.saveData();
|
||||
} catch (NullPointerException ex) {}
|
||||
player.saveData();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -1099,7 +1122,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (!Settings.isForcedRegistrationEnabled)
|
||||
return;
|
||||
|
||||
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
|
||||
Location spawn = plugin.getSpawnLocation(player, player.getWorld());
|
||||
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(name,spawn.getX(),spawn.getY(),spawn.getZ(),spawn.getWorld().getName());
|
||||
try {
|
||||
|
@ -61,7 +61,7 @@ public class AsyncronousLogin {
|
||||
}
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
for (String s : m._("need_captcha")) {
|
||||
for (String s : m._("usage_captcha")) {
|
||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
|
||||
}
|
||||
return true;
|
||||
@ -99,6 +99,12 @@ public class AsyncronousLogin {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
||||
if (plugin.isLoggedIp(getIP())) {
|
||||
m._(player, "logged_in");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if (pAuth == null) {
|
||||
m._(player, "user_unknown");
|
||||
@ -131,8 +137,6 @@ public class AsyncronousLogin {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
|
||||
database.updateSession(auth);
|
||||
|
||||
plugin.pllog.addPlayer(player);
|
||||
|
||||
if (Settings.useCaptcha) {
|
||||
if (plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
@ -156,6 +160,7 @@ public class AsyncronousLogin {
|
||||
|
||||
// makes player isLoggedin via API
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
database.setLogged(name);
|
||||
|
||||
// As the scheduling executes the Task most likely after the current task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be processed in other order.
|
||||
|
@ -68,7 +68,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
}
|
||||
}
|
||||
protected void teleportToSpawn() {
|
||||
Location spawnL = plugin.getSpawnLocation(name, player.getWorld());
|
||||
Location spawnL = plugin.getSpawnLocation(player, player.getWorld());
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
|
@ -148,7 +148,10 @@ public class AsyncronousRegister {
|
||||
m._(player, "error");
|
||||
return;
|
||||
}
|
||||
if (!Settings.forceRegLogin) {
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
database.setLogged(name);
|
||||
}
|
||||
ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
||||
return;
|
||||
|
@ -49,7 +49,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
|
||||
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
World world = player.getWorld();
|
||||
Location loca = plugin.getSpawnLocation(name, world);
|
||||
Location loca = plugin.getSpawnLocation(player, world);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
|
@ -7,16 +7,20 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.events.LoginEvent;
|
||||
import fr.xephi.authme.events.RegisterTeleportEvent;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
|
||||
@ -37,6 +41,39 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
protected void forceLogin(Player player) {
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld());
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
try {
|
||||
plugin.pllog.removePlayer(name);
|
||||
if (player.isInsideVehicle())
|
||||
player.getVehicle().eject();
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@ -44,7 +81,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
World world = player.getWorld();
|
||||
Location loca = plugin.getSpawnLocation(name, world);
|
||||
Location loca = plugin.getSpawnLocation(player, world);
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
@ -73,11 +110,29 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
|
||||
}
|
||||
|
||||
// Kick Player after Registration is enabled, kick the player
|
||||
if (Settings.forceRegKick) {
|
||||
player.kickPlayer(m._("registered")[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Request Login after Registation
|
||||
if (Settings.forceRegLogin) {
|
||||
forceLogin(player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Register is finish and player is logged, display welcome message
|
||||
if(Settings.useWelcomeMessage)
|
||||
if(Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(s);
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
@ -87,11 +142,6 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
forceCommands(player);
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,16 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -58,8 +64,24 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
public boolean loadRessource(File file) {
|
||||
boolean out = true;
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
InputStream fis = getClass().getResourceAsStream("/" + file.getName());
|
||||
FileOutputStream fos = null;
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(fis, Charset.forName("UTF-8").newDecoder()));
|
||||
String str;
|
||||
Writer writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(file), Charset.forName("UTF-8").newEncoder()));
|
||||
while ((str = reader.readLine()) != null) {
|
||||
writer.append(str).append("\r\n");
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
reader.close();
|
||||
fis.close();
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
|
||||
out = false;
|
||||
}
|
||||
/*FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(file);
|
||||
byte[] buf = new byte[1024];
|
||||
@ -81,6 +103,7 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
@ -1,25 +1,28 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class PlayersLogs extends CustomConfiguration {
|
||||
private static PlayersLogs pllog = null;
|
||||
public static List<String> players;
|
||||
public List<String> players;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PlayersLogs() {
|
||||
super(new File("./plugins/AuthMe/players.yml"));
|
||||
pllog = this;
|
||||
load();
|
||||
save();
|
||||
players = (List<String>) this.getList("players");
|
||||
players = this.getStringList("players");
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
set("players", new ArrayList<String>());
|
||||
save();
|
||||
}
|
||||
|
||||
public static PlayersLogs getInstance() {
|
||||
@ -29,11 +32,20 @@ public class PlayersLogs extends CustomConfiguration {
|
||||
return pllog;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
List<String> players = this.getStringList("players");
|
||||
if (!players.contains(player.getName())) {
|
||||
players.add(player.getName());
|
||||
this.set("players", players);
|
||||
public void addPlayer(String user) {
|
||||
players = this.getStringList("players");
|
||||
if (!players.contains(user.toLowerCase())) {
|
||||
players.add(user.toLowerCase());
|
||||
set("players", players);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(String user) {
|
||||
players = this.getStringList("players");
|
||||
if (players.contains(user.toLowerCase())) {
|
||||
players.remove(user.toLowerCase());
|
||||
set("players", players);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public final class Settings extends YamlConfiguration {
|
||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
|
||||
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||
broadcastWelcomeMessage;
|
||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin;
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||
@ -68,12 +68,12 @@ public final class Settings extends YamlConfiguration {
|
||||
getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
|
||||
rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
|
||||
getMailSubject, getMailText, getMySQLlastlocWorld, defaultWorld,
|
||||
getPhpbbPrefix, getWordPressPrefix;
|
||||
getPhpbbPrefix, getWordPressPrefix, getMySQLColumnLogged, spawnPriority;
|
||||
|
||||
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
|
||||
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
|
||||
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
|
||||
bCryptLog2Rounds, getPhpbbGroup, antiBotSensibility, antiBotDuration, delayRecall;
|
||||
bCryptLog2Rounds, getPhpbbGroup, antiBotSensibility, antiBotDuration, delayRecall, getMaxLoginPerIp, getMaxJoinPerIp;
|
||||
|
||||
protected static YamlConfiguration configFile;
|
||||
|
||||
@ -235,6 +235,12 @@ public void loadConfigOptions() {
|
||||
unsafePasswords = (List<String>) configFile.getList("settings.security.unsafePasswords", new ArrayList<String>());
|
||||
countriesBlacklist = (List<String>) configFile.getList("Protection.countriesBlacklist", new ArrayList<String>());
|
||||
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
|
||||
forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
|
||||
forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
|
||||
getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged","isLogged");
|
||||
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
|
||||
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
||||
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
||||
|
||||
// Load the welcome message
|
||||
getWelcomeMessage(plugin);
|
||||
@ -386,6 +392,12 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
unsafePasswords = (List<String>) configFile.getList("settings.security.unsafePasswords", new ArrayList<String>());
|
||||
countriesBlacklist = (List<String>) configFile.getList("Protection.countriesBlacklist", new ArrayList<String>());
|
||||
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
|
||||
forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
|
||||
forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
|
||||
getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged","isLogged");
|
||||
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
|
||||
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
||||
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
||||
|
||||
// Reload the welcome message
|
||||
getWelcomeMessage(AuthMe.getInstance());
|
||||
@ -525,6 +537,18 @@ public void mergeConfig() {
|
||||
}
|
||||
if(!contains("settings.broadcastWelcomeMessage"))
|
||||
set("settings.broadcastWelcomeMessage", false);
|
||||
if(!contains("settings.registration.forceKickAfterRegister"))
|
||||
set("settings.registration.forceKickAfterRegister", false);
|
||||
if(!contains("settings.registration.forceLoginAfterRegister"))
|
||||
set("settings.registration.forceLoginAfterRegister", false);
|
||||
if(!contains("DataSource.mySQLColumnLogged"))
|
||||
set("DataSource.mySQLColumnLogged", "isLogged");
|
||||
if(!contains("settings.restrictions.spawnPriority"))
|
||||
set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
|
||||
if(!contains("settings.restrictions.maxLoginPerIp"))
|
||||
set("settings.restrictions.maxLoginPerIp", 0);
|
||||
if(!contains("settings.restrictions.maxJoinPerIp"))
|
||||
set("settings.restrictions.maxJoinPerIp", 0);
|
||||
|
||||
plugin.getLogger().warning("Merge new Config Options if needed..");
|
||||
plugin.getLogger().warning("Please check your config.yml file!");
|
||||
@ -728,6 +752,7 @@ public void mergeConfig() {
|
||||
while((line = br.readLine()) != null) {
|
||||
welcomeMsg.add(line);
|
||||
}
|
||||
br.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
|
@ -15,6 +15,7 @@ import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
@ -642,4 +643,28 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayersLogs.getInstance().players.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().addPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().removePlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
@ -41,6 +40,7 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
private String lastlocWorld;
|
||||
private String columnEmail;
|
||||
private String columnID;
|
||||
private String columnLogged;
|
||||
private List<String> columnOthers;
|
||||
private MiniConnectionPoolManager conPool;
|
||||
|
||||
@ -64,6 +64,7 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
this.columnEmail = Settings.getMySQLColumnEmail;
|
||||
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
this.columnLogged = Settings.getMySQLColumnLogged;
|
||||
try {
|
||||
this.connect();
|
||||
this.setup();
|
||||
@ -121,13 +122,14 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
+ columnID + " INTEGER AUTO_INCREMENT,"
|
||||
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
|
||||
+ columnPassword + " VARCHAR(255) NOT NULL,"
|
||||
+ columnIp + " VARCHAR(40) NOT NULL,"
|
||||
+ columnLastLogin + " BIGINT,"
|
||||
+ columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
|
||||
+ columnLastLogin + " BIGINT DEFAULT '0',"
|
||||
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0',"
|
||||
+ lastlocY + " DOUBLE NOT NULL DEFAULT '0.0',"
|
||||
+ lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0',"
|
||||
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
|
||||
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
|
||||
+ columnLogged + " SMALLINT NOT NULL DEFAULT '0',"
|
||||
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
if (!rs.next()) {
|
||||
@ -160,7 +162,12 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocZ +";");
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocWorld +";");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail +";");
|
||||
}
|
||||
rs.close();
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
|
||||
@ -836,4 +843,105 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.MYSQL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
|
||||
+ columnName + "=?;");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next())
|
||||
return (rs.getInt(columnLogged) == 1);
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, 1);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setString(2, user);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
|
||||
pst.setInt(1, 0);
|
||||
pst.setInt(2, 1);
|
||||
pst.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (TimeoutException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.settings.PlayersLogs;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
@ -521,4 +522,28 @@ public class SQLiteThread extends Thread implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayersLogs.getInstance().players.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PlayersLogs.getInstance().addPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PlayersLogs.getInstance().removePlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeLogged() {
|
||||
PlayersLogs.getInstance().clear();
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ DataSource:
|
||||
mySQLColumnPassword: password
|
||||
# Password about Database Connection Infos
|
||||
mySQLPassword: '12345'
|
||||
# Do we need to cache all things ? Not Recommanded with multiThreading enable
|
||||
# Do we need to cache all query?
|
||||
caching: true
|
||||
# Column for SaveQuitLocation - X
|
||||
mySQLlastlocX: x
|
||||
@ -35,6 +35,8 @@ DataSource:
|
||||
mySQLColumnEmail: email
|
||||
# Column of IDs to sort data
|
||||
mySQLColumnId: id
|
||||
# Column for Saving if a player is logged in or not
|
||||
mySQLColumnLogged: isLogged
|
||||
GroupOptions:
|
||||
# if you want to set up a particulary Permission Group for
|
||||
# users that arent registered yet. Pay attention this option
|
||||
@ -154,6 +156,12 @@ settings:
|
||||
- world_the_end
|
||||
# Ban ip when the ip is not the ip registered in database
|
||||
banUnsafedIP: false
|
||||
# Spawn Priority, Values : authme, essentials, multiverse, default
|
||||
spawnPriority: authme,essentials,multiverse,default
|
||||
# Maximum Login authorized by IP
|
||||
maxLoginPerIp: 0
|
||||
# Maximum Join authorized by IP
|
||||
maxJoinPerIp: 0
|
||||
GameMode:
|
||||
# ForceSurvivalMode to player when join ?
|
||||
ForceSurvivalMode: false
|
||||
@ -199,10 +207,10 @@ settings:
|
||||
# AuthMe will update the password to the new passwordHash !
|
||||
supportOldPasswordHash: false
|
||||
# Cancel unsafe passwords for being used, put them on lowercase!
|
||||
unsafePasswords: []
|
||||
#unsafePasswords:
|
||||
#- '123456'
|
||||
#- 'password'
|
||||
unsafePasswords: []
|
||||
registration:
|
||||
# enable registration on the server?
|
||||
enabled: true
|
||||
@ -218,6 +226,11 @@ settings:
|
||||
# when it's true, registration require that kind of command:
|
||||
# /register <email> <confirmEmail>
|
||||
doubleEmailCheck: false
|
||||
# Do we force kicking player after a successful registration ?
|
||||
# Do not use with login feature below
|
||||
forceKickAfterRegister: false
|
||||
# Does AuthMe need to enforce a /login after a successful registration ?
|
||||
forceLoginAfterRegister: false
|
||||
unrestrictions:
|
||||
# below you can list all your account name, that
|
||||
# AuthMe will ignore for registration or login, configure it
|
||||
|
@ -1,4 +1,4 @@
|
||||
unknown_user: '&fKäyttäjä ei ole tietokannassa!'
|
||||
unknown_user: '&fKäyttäjä ei ole tietokannassa!'
|
||||
unsafe_spawn: '&fHengenvaarallinen poistumispaikka! Siirsimme sinut spawnille!'
|
||||
not_logged_in: '&cEt ole kirjautunut sisään!'
|
||||
reg_voluntarily: '&fNyt voit rekisteröidä pelaajasi palvelimellemme: "/register salasana salasana"'
|
||||
|
@ -1,36 +1,36 @@
|
||||
reg_only: Csak regisztrált játékosoknak! Jelentkezni a yndicraft@freemail.hu e-mail címen lehet
|
||||
usage_unreg: '&cHasználat: /unregister jelszó'
|
||||
registered: '&aSikeres regisztráció. Üdvözöllek!'
|
||||
user_regged: '&cJátékosnév már regisztrálva'
|
||||
login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
|
||||
reg_only: Csak regisztrált játékosoknak! Jelentkezni a yndicraft@freemail.hu e-mail címen lehet
|
||||
usage_unreg: '&cHasználat: /unregister jelszó'
|
||||
registered: '&aSikeres regisztráció. Üdvözöllek!'
|
||||
user_regged: '&cJátékosnév már regisztrálva'
|
||||
login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
|
||||
not_logged_in: '&cNem vagy bejelentkezve!'
|
||||
logout: '&cSikeresen kijelentkeztél'
|
||||
usage_log: '&cBejelentkezés: /login jelszó'
|
||||
logout: '&cSikeresen kijelentkeztél'
|
||||
usage_log: '&cBejelentkezés: /login jelszó'
|
||||
unknown_user: User is not in database
|
||||
reg_voluntarily: Regisztrálhatod beceneved a szerveren a következö parancsal "/register jelszó jelszó"
|
||||
reg_disabled: '&cRegisztráció letiltva'
|
||||
no_perm: '&cNincs engedélyed'
|
||||
usage_reg: '&cHasználat: /register jelszó jelszóújra'
|
||||
unregistered: '&cRegisztráció sikeresen törölve!'
|
||||
same_nick: Ezen a játékosnéven már játszanak
|
||||
reg_voluntarily: Regisztrálhatod beceneved a szerveren a következö parancsal "/register jelszó jelszó"
|
||||
reg_disabled: '&cRegisztráció letiltva'
|
||||
no_perm: '&cNincs engedélyed'
|
||||
usage_reg: '&cHasználat: /register jelszó jelszóújra'
|
||||
unregistered: '&cRegisztráció sikeresen törölve!'
|
||||
same_nick: Ezen a játékosnéven már játszanak
|
||||
valid_session: '&cSession login'
|
||||
pwd_changed: '&cJelszó cserélve!'
|
||||
reload: Beálítások és adatbázis újratöltve!
|
||||
timeout: Bejelentkezési idötúllépés
|
||||
error: Hiba lépett fel; Lépj kapcsolatba a tulajjal'
|
||||
logged_in: '&cMár be vagy jelentkezve!'
|
||||
login: '&aSikeresen Beléptél! Üdvözöllek!!!'
|
||||
wrong_pwd: '&4Hibás jelszó'
|
||||
user_unknown: '&cJátékosnév nem regisztrált'
|
||||
reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
|
||||
pwd_changed: '&cJelszó cserélve!'
|
||||
reload: Beálítások és adatbázis újratöltve!
|
||||
timeout: Bejelentkezési idötúllépés
|
||||
error: Hiba lépett fel; Lépj kapcsolatba a tulajjal'
|
||||
logged_in: '&cMár be vagy jelentkezve!'
|
||||
login: '&aSikeresen Beléptél! Üdvözöllek!!!'
|
||||
wrong_pwd: '&4Hibás jelszó'
|
||||
user_unknown: '&cJátékosnév nem regisztrált'
|
||||
reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
|
||||
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
|
||||
unsafe_spawn: A kilépési helyzeted nem biztonságos, teleportálás a kezdö Spawnra.
|
||||
max_reg: Csak egy karakterrel Registrálhatsz!!!
|
||||
password_error: A jelszó nem illik össze
|
||||
unsafe_spawn: A kilépési helyzeted nem biztonságos, teleportálás a kezdö Spawnra.
|
||||
max_reg: Csak egy karakterrel Registrálhatsz!!!
|
||||
password_error: A jelszó nem illik össze
|
||||
unvalid_session: Session Dataes doesnt corrispond Plaese wait the end of session
|
||||
pass_len: A jelszavad nem éri el a minimális hosszat
|
||||
pass_len: A jelszavad nem éri el a minimális hosszat
|
||||
vb_nonActiv: Your Account isent Activated yet check your Emails!
|
||||
usage_changepassword: 'használat: /changepassword régiJelszó újJelszó'
|
||||
usage_changepassword: 'használat: /changepassword régiJelszó újJelszó'
|
||||
name_len: '&cYour nickname is too Short or too long'
|
||||
regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
|
||||
add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
|
||||
|
@ -1,4 +1,4 @@
|
||||
unknown_user: 사용자는 데이터베이스에 없습니다
|
||||
unknown_user: 사용자는 데이터베이스에 없습니다
|
||||
unsafe_spawn: 당신이 나갔던 위치는 안전하지 않았습니다, 당신을 윌드 스폰으로 텔레포트시킵니다
|
||||
not_logged_in: '&c로그인하지 않았습니다!'
|
||||
reg_voluntarily: 당신이 서버에 게정을 등록하고 싶다면 "/register 비밀번호 비밀번호재입력"을 치세요
|
||||
|
@ -3,7 +3,7 @@ author: Xephi59
|
||||
website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
|
||||
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
|
||||
main: fr.xephi.authme.AuthMe
|
||||
version: 3.3.3
|
||||
version: 3.3.4
|
||||
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
|
||||
commands:
|
||||
register:
|
||||
|
Loading…
Reference in New Issue
Block a user