Merge pull request #11 from Xephi/master

Up
This commit is contained in:
Gabriele C. 2015-07-10 14:03:43 +02:00
commit 032361b733
39 changed files with 457 additions and 391 deletions

45
pom.xml
View File

@ -119,16 +119,10 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository> </repository>
<!-- Mcstats.org Metrics Repo --> <!-- Essentials Repo -->
<repository> <repository>
<id>Plugin Metrics</id> <id>ess-repo</id>
<url>http://repo.mcstats.org/content/repositories/releases</url> <url>http://repo.ess3.net/content/groups/public</url>
</repository>
<!-- Vault Repo -->
<repository>
<id>vault-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository> </repository>
<!-- Citizens 2.X Repo --> <!-- Citizens 2.X Repo -->
@ -137,24 +131,12 @@
<url>http://repo.citizensnpcs.co</url> <url>http://repo.citizensnpcs.co</url>
</repository> </repository>
<!-- Essentials Repo -->
<repository>
<id>ess-repo</id>
<url>http://repo.ess3.net/content/groups/essentials</url>
</repository>
<!-- CombatTagPlus Repo --> <!-- CombatTagPlus Repo -->
<repository> <repository>
<id>minelink-thirdparty</id> <id>minelink-thirdparty</id>
<url>http://repo.minelink.net/content/repositories/public</url> <url>http://repo.minelink.net/content/repositories/public</url>
</repository> </repository>
<!-- XAuth Repo -->
<repository>
<id>luricos-releases</id>
<url>http://repo.luricos.de/content/repositories/bukkit-plugins</url>
</repository>
<!-- Attribute Repo --> <!-- Attribute Repo -->
<repository> <repository>
<id>comphenix-snapshots</id> <id>comphenix-snapshots</id>
@ -167,6 +149,24 @@
<url>http://repo.onarandombox.com/content/repositories/multiverse</url> <url>http://repo.onarandombox.com/content/repositories/multiverse</url>
</repository> </repository>
<!-- Vault Repo -->
<repository>
<id>vault-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository>
<!-- Mcstats.org Metrics Repo -->
<repository>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/releases</url>
</repository>
<!-- XAuth Repo -->
<repository>
<id>luricos-releases</id>
<url>http://repo.luricos.de/content/repositories/bukkit-plugins</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -248,6 +248,7 @@
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.5</version> <version>1.5</version>
<scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
@ -300,7 +301,7 @@
<dependency> <dependency>
<groupId>net.ess3</groupId> <groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId> <artifactId>Essentials</artifactId>
<version>2.13-SNAPSHOT</version> <version>2.14-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>

View File

@ -12,8 +12,6 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -80,7 +78,6 @@ public class AuthMe extends JavaPlugin {
public DataSource database = null; public DataSource database = null;
private Settings settings; private Settings settings;
private Messages m; private Messages m;
public PlayersLogs pllog;
public OtherAccounts otherAccounts; public OtherAccounts otherAccounts;
public static Server server; public static Server server;
public static Logger authmeLogger = Logger.getLogger("AuthMe"); public static Logger authmeLogger = Logger.getLogger("AuthMe");
@ -97,9 +94,9 @@ public class AuthMe extends JavaPlugin {
public Essentials ess; public Essentials ess;
public API api; public API api;
public Management management; public Management management;
public HashMap<String, Integer> captcha = new HashMap<String, Integer>(); public ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<String, Integer>();
public HashMap<String, String> cap = new HashMap<String, String>(); public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<String, String>();
public HashMap<String, String> realIp = new HashMap<String, String>(); public ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<String, String>();
public MultiverseCore multiverse = null; public MultiverseCore multiverse = null;
public Location essentialsSpawn; public Location essentialsSpawn;
public LookupService ls = null; public LookupService ls = null;
@ -151,8 +148,6 @@ public class AuthMe extends JavaPlugin {
m = Messages.getInstance(); m = Messages.getInstance();
pllog = PlayersLogs.getInstance();
otherAccounts = OtherAccounts.getInstance(); otherAccounts = OtherAccounts.getInstance();
server = getServer(); server = getServer();
@ -208,13 +203,13 @@ public class AuthMe extends JavaPlugin {
setupDatabase(); setupDatabase();
dataManager = new DataManager(this, database); dataManager = new DataManager(this);
// Setup API // Setup API
api = new API(this, database); api = new API(this);
// Setup Management // Setup Management
management = new Management(database, this); management = new Management(this);
PluginManager pm = getServer().getPluginManager(); PluginManager pm = getServer().getPluginManager();
if (Settings.bungee) { if (Settings.bungee) {
@ -222,33 +217,34 @@ public class AuthMe extends JavaPlugin {
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this)); Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
} }
pm.registerEvents(new AuthMePlayerListener(this, database), this); pm.registerEvents(new AuthMePlayerListener(this), this);
pm.registerEvents(new AuthMeBlockListener(database, this), this); pm.registerEvents(new AuthMeBlockListener(this), this);
pm.registerEvents(new AuthMeEntityListener(database, this), this); pm.registerEvents(new AuthMeEntityListener(this), this);
pm.registerEvents(new AuthMeServerListener(this), this); pm.registerEvents(new AuthMeServerListener(this), this);
if (ChestShop != 0) { if (ChestShop != 0) {
pm.registerEvents(new AuthMeChestShopListener(database, this), this); pm.registerEvents(new AuthMeChestShopListener(this), this);
ConsoleLogger.info("Successfully hook with ChestShop!"); ConsoleLogger.info("Successfully hook with ChestShop!");
} }
this.getCommand("authme").setExecutor(new AdminCommand(this, database)); this.getCommand("authme").setExecutor(new AdminCommand(this));
this.getCommand("register").setExecutor(new RegisterCommand(this)); this.getCommand("register").setExecutor(new RegisterCommand(this));
this.getCommand("login").setExecutor(new LoginCommand(this)); this.getCommand("login").setExecutor(new LoginCommand(this));
this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(database, this)); this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
this.getCommand("logout").setExecutor(new LogoutCommand(this, database)); this.getCommand("logout").setExecutor(new LogoutCommand(this));
this.getCommand("unregister").setExecutor(new UnregisterCommand(this, database)); this.getCommand("unregister").setExecutor(new UnregisterCommand(this));
this.getCommand("passpartu").setExecutor(new PasspartuCommand(this)); this.getCommand("passpartu").setExecutor(new PasspartuCommand(this));
this.getCommand("email").setExecutor(new EmailCommand(this, database)); this.getCommand("email").setExecutor(new EmailCommand(this));
this.getCommand("captcha").setExecutor(new CaptchaCommand(this)); this.getCommand("captcha").setExecutor(new CaptchaCommand(this));
this.getCommand("converter").setExecutor(new ConverterCommand(this, database)); this.getCommand("converter").setExecutor(new ConverterCommand(this));
if (!Settings.isForceSingleSessionEnabled) { if (!Settings.isForceSingleSessionEnabled) {
ConsoleLogger.showError("BECAREFUL !!! By disabling ForceSingleSession, your server protection is set to LOW"); ConsoleLogger.showError("BECAREFUL !!! By disabling ForceSingleSession, your server protection is set to LOW");
} }
PlayersLogs.getInstance();
if (Settings.reloadSupport) if (Settings.reloadSupport)
try { try {
onReload();
int playersOnline = 0; int playersOnline = 0;
try { try {
if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class) if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class)
@ -261,7 +257,7 @@ public class AuthMe extends JavaPlugin {
database.purgeLogged(); database.purgeLogged();
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
} }
} } else PlayersLogs.getInstance().loadPlayers();
} catch (Exception ex) { } catch (Exception ex) {
} }
@ -432,27 +428,6 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " disabled"); ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " disabled");
} }
private void onReload() {
try {
if (Bukkit.getServer().getOnlinePlayers() != null) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
if (database.isLogged(player.getName().toLowerCase())) {
String name = player.getName().toLowerCase();
PlayerAuth pAuth = database.getAuth(name);
if (pAuth == null)
break;
PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(), pAuth.getIp(), new Date().getTime(), pAuth.getEmail());
database.updateSession(auth);
PlayerCache.getInstance().addPlayer(auth);
}
}
}
return;
} catch (Exception ex) {
return;
}
}
public static AuthMe getInstance() { public static AuthMe getInstance() {
return authme; return authme;
} }
@ -460,7 +435,7 @@ public class AuthMe extends JavaPlugin {
public void savePlayer(Player player) public void savePlayer(Player player)
throws IllegalStateException, NullPointerException { throws IllegalStateException, NullPointerException {
try { try {
if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) { if ((citizens.isNPC(player)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
@ -566,8 +541,8 @@ public class AuthMe extends JavaPlugin {
Location spawnLoc = world.getSpawnLocation(); Location spawnLoc = world.getSpawnLocation();
for (int i = spawnPriority.length - 1; i >= 0; i--) { for (int i = spawnPriority.length - 1; i >= 0; i--) {
String s = spawnPriority[i]; String s = spawnPriority[i];
if (s.equalsIgnoreCase("default") && getDefaultSpawn(world) != null) if (s.equalsIgnoreCase("default") && getDefaultSpawn() != null)
spawnLoc = getDefaultSpawn(world); spawnLoc = getDefaultSpawn();
if (s.equalsIgnoreCase("multiverse") && getMultiverseSpawn(world) != null) if (s.equalsIgnoreCase("multiverse") && getMultiverseSpawn(world) != null)
spawnLoc = getMultiverseSpawn(world); spawnLoc = getMultiverseSpawn(world);
if (s.equalsIgnoreCase("essentials") && getEssentialsSpawn() != null) if (s.equalsIgnoreCase("essentials") && getEssentialsSpawn() != null)
@ -580,8 +555,8 @@ public class AuthMe extends JavaPlugin {
return spawnLoc; return spawnLoc;
} }
private Location getDefaultSpawn(World world) { private Location getDefaultSpawn() {
return world.getSpawnLocation(); return this.getServer().getWorld(Settings.defaultWorld).getSpawnLocation();
} }
private Location getMultiverseSpawn(World world) { private Location getMultiverseSpawn(World world) {
@ -607,7 +582,7 @@ public class AuthMe extends JavaPlugin {
return Spawn.getInstance().getFirstSpawn(); return Spawn.getInstance().getFirstSpawn();
if (Spawn.getInstance().getSpawn() != null) if (Spawn.getInstance().getSpawn() != null)
return Spawn.getInstance().getSpawn(); return Spawn.getInstance().getSpawn();
return null; return this.getServer().getWorld(Settings.defaultWorld).getSpawnLocation();
} }
public void downloadGeoIp() { public void downloadGeoIp() {

View File

@ -8,23 +8,19 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import net.milkbowl.vault.permission.Permission;
public class DataManager { public class DataManager {
public AuthMe plugin; public AuthMe plugin;
public DataSource database;
public DataManager(AuthMe plugin, DataSource database) { public DataManager(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.database = database;
} }
public void run() { public void run() {

View File

@ -0,0 +1,33 @@
package fr.xephi.authme;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
public class ImageGenerator {
private String pass;
private AuthMe plugin;
public ImageGenerator(AuthMe plugin, String pass) {
this.pass = pass;
this.plugin = plugin;
}
public BufferedImage generateImage() {
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D graphics = image.createGraphics();
graphics.setColor(Color.BLACK);
graphics.fillRect(0, 0, 200, 40);
GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
graphics.setPaint(gradientPaint);
Font font = new Font("Comic Sans MS", Font.BOLD, 30);
graphics.setFont(font);
graphics.drawString(pass, 5, 30);
graphics.dispose();
image.flush();
return image;
}
}

View File

@ -1,9 +1,14 @@
package fr.xephi.authme; package fr.xephi.authme;
import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.imageio.ImageIO;
import javax.mail.BodyPart; import javax.mail.BodyPart;
import javax.mail.Message; import javax.mail.Message;
import javax.mail.Multipart; import javax.mail.Multipart;
@ -46,9 +51,8 @@ public class SendMailSSL {
final String subject = Settings.getMailSubject; final String subject = Settings.getMailSubject;
final String smtp = Settings.getmailSMTP; final String smtp = Settings.getmailSMTP;
final String password = Settings.getmailPassword; final String password = Settings.getmailPassword;
final String mailText = Settings.getMailText; final String mailText = Settings.getMailText.replace("<playername>", auth.getNickname()).replace("<servername>", plugin.getServer().getServerName()).replace("<generatedpass>", newPass);
final String mail = auth.getEmail(); final String mail = auth.getEmail();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
@ -74,10 +78,26 @@ public class SendMailSSL {
messageBodyPart.setText(mailText); messageBodyPart.setText(mailText);
Multipart multipart = new MimeMultipart(); Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart); multipart.addBodyPart(messageBodyPart);
// Generate an image ?
File file = null;
if (Settings.generateImage) {
ImageGenerator gen = new ImageGenerator(plugin, newPass);
file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg");
ImageIO.write(gen.generateImage(), "jpg", file);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(file);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(auth.getNickname() + "_new_pass.jpg");
multipart.addBodyPart(messageBodyPart);
}
message.setContent(multipart); message.setContent(multipart);
Transport transport = session.getTransport("smtp"); Transport transport = session.getTransport("smtp");
transport.connect(smtp, acc, password); transport.connect(smtp, acc, password);
transport.sendMessage(message, message.getAllRecipients()); transport.sendMessage(message, message.getAllRecipients());
if (file != null)
file.delete();
} catch (Exception e) { } catch (Exception e) {
System.out.println("Some error occured while trying to send a mail to " + mail); System.out.println("Some error occured while trying to send a mail to " + mail);

View File

@ -13,7 +13,6 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils; import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.plugin.manager.CombatTagComunicator;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
@ -23,16 +22,13 @@ public class API {
public static final String newline = System.getProperty("line.separator"); public static final String newline = System.getProperty("line.separator");
public static API singleton; public static API singleton;
public AuthMe plugin; public AuthMe plugin;
public DataSource database;
public API(AuthMe plugin, DataSource database) { public API(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.database = database;
} }
public API(Server serv) { public API(Server serv) {
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe"); this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
this.database = this.plugin.database;
} }
/** /**
@ -50,7 +46,7 @@ public class API {
return null; return null;
} }
AuthMe authme = (AuthMe) p; AuthMe authme = (AuthMe) p;
singleton = (new API(authme, authme.database)); singleton = (new API(authme));
return singleton; return singleton;
} }
@ -67,25 +63,13 @@ public class API {
return PlayerCache.getInstance().isAuthenticated(player.getName()); return PlayerCache.getInstance().isAuthenticated(player.getName());
} }
/**
*
* @param player
* @return true if player is a npc
*/
@Deprecated
public boolean isaNPC(Player player) {
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
return true;
return CombatTagComunicator.isNPC(player);
}
/** /**
* *
* @param player * @param player
* @return true if player is a npc * @return true if player is a npc
*/ */
public boolean isNPC(Player player) { public boolean isNPC(Player player) {
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return true; return true;
return CombatTagComunicator.isNPC(player); return CombatTagComunicator.isNPC(player);
} }
@ -131,7 +115,7 @@ public class API {
*/ */
public boolean isRegistered(String playerName) { public boolean isRegistered(String playerName) {
String player = playerName.toLowerCase(); String player = playerName.toLowerCase();
return database.isAuthAvailable(player); return plugin.database.isAuthAvailable(player);
} }
/** /**
@ -143,7 +127,7 @@ public class API {
if (!isRegistered(playerName)) if (!isRegistered(playerName))
return false; return false;
String player = playerName.toLowerCase(); String player = playerName.toLowerCase();
PlayerAuth auth = database.getAuth(player); PlayerAuth auth = plugin.database.getAuth(player);
try { try {
return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName); return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
@ -166,7 +150,7 @@ public class API {
return false; return false;
} }
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com"); PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com");
if (!database.saveAuth(auth)) { if (!plugin.database.saveAuth(auth)) {
return false; return false;
} }
return true; return true;

View File

@ -43,4 +43,8 @@ public class PlayerCache {
return cache.size(); return cache.size();
} }
public ConcurrentHashMap<String, PlayerAuth> getCache() {
return this.cache;
}
} }

View File

@ -39,7 +39,7 @@ public class LimboCache {
boolean flying = false; boolean flying = false;
if (playerData.doesCacheExist(player)) { if (playerData.doesCacheExist(player)) {
StoreInventoryEvent event = new StoreInventoryEvent(player, playerData); final StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) { if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
inv = event.getInventory(); inv = event.getInventory();
@ -90,6 +90,9 @@ public class LimboCache {
player.sendMessage("Your inventory has been cleaned!"); player.sendMessage("Your inventory has been cleaned!");
} }
} }
if (gameMode == GameMode.CREATIVE) {
flying = false;
}
gameMode = GameMode.SURVIVAL; gameMode = GameMode.SURVIVAL;
} }
if (player.isDead()) { if (player.isDead()) {

View File

@ -33,7 +33,6 @@ import fr.xephi.authme.Utils.groupType;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
@ -46,10 +45,8 @@ public class AdminCommand implements CommandExecutor {
public AuthMe plugin; public AuthMe plugin;
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
public DataSource database;
public AdminCommand(AuthMe plugin, DataSource database) { public AdminCommand(AuthMe plugin) {
this.database = database;
this.plugin = plugin; this.plugin = plugin;
} }
@ -107,7 +104,7 @@ public class AdminCommand implements CommandExecutor {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -(Integer.parseInt(args[1]))); calendar.add(Calendar.DATE, -(Integer.parseInt(args[1])));
long until = calendar.getTimeInMillis(); long until = calendar.getTimeInMillis();
List<String> purged = database.autoPurgeDatabase(until); List<String> purged = plugin.database.autoPurgeDatabase(until);
sender.sendMessage("Deleted " + purged.size() + " user accounts"); sender.sendMessage("Deleted " + purged.size() + " user accounts");
if (Settings.purgeEssentialsFile && plugin.ess != null) if (Settings.purgeEssentialsFile && plugin.ess != null)
plugin.dataManager.purgeEssentials(purged); plugin.dataManager.purgeEssentials(purged);
@ -161,8 +158,8 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
try { try {
if (database.getAuth(args[1].toLowerCase()) != null) { if (plugin.database.getAuth(args[1].toLowerCase()) != null) {
PlayerAuth player = database.getAuth(args[1].toLowerCase()); PlayerAuth player = plugin.database.getAuth(args[1].toLowerCase());
long lastLogin = player.getLastLogin(); long lastLogin = player.getLastLogin();
Date d = new Date(lastLogin); Date d = new Date(lastLogin);
final long diff = System.currentTimeMillis() - lastLogin; final long diff = System.currentTimeMillis() - lastLogin;
@ -195,13 +192,13 @@ public class AdminCommand implements CommandExecutor {
PlayerAuth pAuth = null; PlayerAuth pAuth = null;
String message = "[AuthMe] "; String message = "[AuthMe] ";
try { try {
pAuth = database.getAuth(arguments[1].toLowerCase()); pAuth = plugin.database.getAuth(arguments[1].toLowerCase());
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
fSender.sendMessage("[AuthMe] This player is unknown"); fSender.sendMessage("[AuthMe] This player is unknown");
return; return;
} }
if (pAuth != null) { if (pAuth != null) {
List<String> accountList = database.getAllAuthsByName(pAuth); List<String> accountList = plugin.database.getAllAuthsByName(pAuth);
if (accountList.isEmpty() || accountList == null) { if (accountList.isEmpty() || accountList == null) {
fSender.sendMessage("[AuthMe] This player is unknown"); fSender.sendMessage("[AuthMe] This player is unknown");
return; return;
@ -238,7 +235,7 @@ public class AdminCommand implements CommandExecutor {
public void run() { public void run() {
String message = "[AuthMe] "; String message = "[AuthMe] ";
if (arguments[1] != null) { if (arguments[1] != null) {
List<String> accountList = database.getAllAuthsByIp(arguments[1]); List<String> accountList = plugin.database.getAllAuthsByIp(arguments[1]);
if (accountList.isEmpty() || accountList == null) { if (accountList.isEmpty() || accountList == null) {
fSender.sendMessage("[AuthMe] Please put a valid IP"); fSender.sendMessage("[AuthMe] Please put a valid IP");
return; return;
@ -275,7 +272,7 @@ public class AdminCommand implements CommandExecutor {
} }
try { try {
String name = args[1].toLowerCase(); String name = args[1].toLowerCase();
if (database.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(sender, "user_regged"); m.send(sender, "user_regged");
return true; return true;
} }
@ -284,7 +281,7 @@ public class AdminCommand implements CommandExecutor {
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
auth.setSalt(PasswordSecurity.userSalt.get(name)); auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt(""); else auth.setSalt("");
if (!database.saveAuth(auth)) { if (!plugin.database.saveAuth(auth)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -301,7 +298,7 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
String playername = args[1].toLowerCase(); String playername = args[1].toLowerCase();
PlayerAuth getAuth = database.getAuth(playername); PlayerAuth getAuth = plugin.database.getAuth(playername);
if (getAuth == null) { if (getAuth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
@ -314,13 +311,13 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
String playername = args[1].toLowerCase(); String playername = args[1].toLowerCase();
PlayerAuth getAuth = database.getAuth(playername); PlayerAuth getAuth = plugin.database.getAuth(playername);
if (getAuth == null) { if (getAuth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
} }
getAuth.setEmail(args[2]); getAuth.setEmail(args[2]);
if (!database.updateEmail(getAuth)) { if (!plugin.database.updateEmail(getAuth)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -358,7 +355,7 @@ public class AdminCommand implements CommandExecutor {
for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) { for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) {
bannedPlayers.add(off.getName().toLowerCase()); bannedPlayers.add(off.getName().toLowerCase());
} }
database.purgeBanned(bannedPlayers); plugin.database.purgeBanned(bannedPlayers);
if (Settings.purgeEssentialsFile && plugin.ess != null) if (Settings.purgeEssentialsFile && plugin.ess != null)
plugin.dataManager.purgeEssentials(bannedPlayers); plugin.dataManager.purgeEssentials(bannedPlayers);
if (Settings.purgePlayerDat) if (Settings.purgePlayerDat)
@ -406,8 +403,8 @@ public class AdminCommand implements CommandExecutor {
PlayerAuth auth = null; PlayerAuth auth = null;
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
auth = PlayerCache.getInstance().getAuth(name); auth = PlayerCache.getInstance().getAuth(name);
} else if (database.isAuthAvailable(name)) { } else if (plugin.database.isAuthAvailable(name)) {
auth = database.getAuth(name); auth = plugin.database.getAuth(name);
} }
if (auth == null) { if (auth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
@ -416,9 +413,9 @@ public class AdminCommand implements CommandExecutor {
auth.setHash(hash); auth.setHash(hash);
if (PasswordSecurity.userSalt.containsKey(name)) { if (PasswordSecurity.userSalt.containsKey(name)) {
auth.setSalt(PasswordSecurity.userSalt.get(name)); auth.setSalt(PasswordSecurity.userSalt.get(name));
database.updateSalt(auth); plugin.database.updateSalt(auth);
} }
if (!database.updatePassword(auth)) { if (!plugin.database.updatePassword(auth)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -435,11 +432,11 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} }
String name = args[1].toLowerCase(); String name = args[1].toLowerCase();
if (!database.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
m.send(sender, "user_unknown"); m.send(sender, "user_unknown");
return true; return true;
} }
if (!database.removeAuth(name)) { if (!plugin.database.removeAuth(name)) {
m.send(sender, "error"); m.send(sender, "error");
return true; return true;
} }
@ -484,7 +481,7 @@ public class AdminCommand implements CommandExecutor {
} }
try { try {
String name = args[1].toLowerCase(); String name = args[1].toLowerCase();
PlayerAuth auth = database.getAuth(name); PlayerAuth auth = plugin.database.getAuth(name);
if (auth == null) { if (auth == null) {
sender.sendMessage("The player " + name + " is not registered "); sender.sendMessage("The player " + name + " is not registered ");
return true; return true;
@ -493,7 +490,7 @@ public class AdminCommand implements CommandExecutor {
auth.setQuitLocY(0); auth.setQuitLocY(0);
auth.setQuitLocZ(0); auth.setQuitLocZ(0);
auth.setWorld("world"); auth.setWorld("world");
database.updateQuitLoc(auth); plugin.database.updateQuitLoc(auth);
sender.sendMessage(name + " 's last pos location is now reset"); sender.sendMessage(name + " 's last pos location is now reset");
} catch (Exception e) { } catch (Exception e) {
ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: "); ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: ");
@ -539,7 +536,7 @@ public class AdminCommand implements CommandExecutor {
sender.sendMessage("Usage : /authme resetPosition <playerName>"); sender.sendMessage("Usage : /authme resetPosition <playerName>");
return true; return true;
} }
PlayerAuth auth = database.getAuth(args[1]); PlayerAuth auth = plugin.database.getAuth(args[1]);
if (auth == null) { if (auth == null) {
m.send(sender, "unknown_user"); m.send(sender, "unknown_user");
return true; return true;
@ -548,7 +545,7 @@ public class AdminCommand implements CommandExecutor {
auth.setQuitLocY(0D); auth.setQuitLocY(0D);
auth.setQuitLocZ(0D); auth.setQuitLocZ(0D);
auth.setWorld("world"); auth.setWorld("world");
database.updateQuitLoc(auth); plugin.database.updateQuitLoc(auth);
sender.sendMessage("[AuthMe] Successfully reset position for " + auth.getNickname()); sender.sendMessage("[AuthMe] Successfully reset position for " + auth.getNickname());
return true; return true;
} else if (args[0].equalsIgnoreCase("forcelogin")) { } else if (args[0].equalsIgnoreCase("forcelogin")) {

View File

@ -11,7 +11,6 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
@ -19,11 +18,9 @@ import fr.xephi.authme.settings.Settings;
public class ChangePasswordCommand implements CommandExecutor { public class ChangePasswordCommand implements CommandExecutor {
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
private DataSource database;
public AuthMe plugin; public AuthMe plugin;
public ChangePasswordCommand(DataSource database, AuthMe plugin) { public ChangePasswordCommand(AuthMe plugin) {
this.database = database;
this.plugin = plugin; this.plugin = plugin;
} }
@ -79,11 +76,11 @@ public class ChangePasswordCommand implements CommandExecutor {
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
auth.setSalt(PasswordSecurity.userSalt.get(name)); auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt(""); else auth.setSalt("");
if (!database.updatePassword(auth)) { if (!plugin.database.updatePassword(auth)) {
m.send(player, "error"); m.send(player, "error");
return true; return true;
} }
database.updateSalt(auth); plugin.database.updateSalt(auth);
PlayerCache.getInstance().updatePlayer(auth); PlayerCache.getInstance().updatePlayer(auth);
m.send(player, "pwd_changed"); m.send(player, "pwd_changed");
ConsoleLogger.info(player.getName() + " changed his password"); ConsoleLogger.info(player.getName() + " changed his password");

View File

@ -16,18 +16,15 @@ import fr.xephi.authme.converter.RoyalAuthConverter;
import fr.xephi.authme.converter.SqlToFlat; import fr.xephi.authme.converter.SqlToFlat;
import fr.xephi.authme.converter.vAuthConverter; import fr.xephi.authme.converter.vAuthConverter;
import fr.xephi.authme.converter.xAuthConverter; import fr.xephi.authme.converter.xAuthConverter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
public class ConverterCommand implements CommandExecutor { public class ConverterCommand implements CommandExecutor {
private AuthMe plugin; private AuthMe plugin;
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
private DataSource database;
public ConverterCommand(AuthMe plugin, DataSource database) { public ConverterCommand(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.database = database;
} }
@Override @Override
@ -61,22 +58,22 @@ public class ConverterCommand implements CommandExecutor {
converter = new FlatToSqlite(sender); converter = new FlatToSqlite(sender);
break; break;
case xauth: case xauth:
converter = new xAuthConverter(plugin, database, sender); converter = new xAuthConverter(plugin, sender);
break; break;
case crazylogin: case crazylogin:
converter = new CrazyLoginConverter(plugin, database, sender); converter = new CrazyLoginConverter(plugin, sender);
break; break;
case rakamak: case rakamak:
converter = new RakamakConverter(plugin, database, sender); converter = new RakamakConverter(plugin, sender);
break; break;
case royalauth: case royalauth:
converter = new RoyalAuthConverter(plugin); converter = new RoyalAuthConverter(plugin);
break; break;
case vauth: case vauth:
converter = new vAuthConverter(plugin, database, sender); converter = new vAuthConverter(plugin, sender);
break; break;
case sqltoflat: case sqltoflat:
converter = new SqlToFlat(plugin, database, sender); converter = new SqlToFlat(plugin, sender);
break; break;
default: default:
break; break;

View File

@ -11,7 +11,6 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.RandomString; import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
@ -24,12 +23,10 @@ import fr.xephi.authme.settings.Settings;
public class EmailCommand implements CommandExecutor { public class EmailCommand implements CommandExecutor {
public AuthMe plugin; public AuthMe plugin;
private DataSource data;
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
public EmailCommand(AuthMe plugin, DataSource data) { public EmailCommand(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.data = data;
} }
@Override @Override
@ -60,7 +57,7 @@ public class EmailCommand implements CommandExecutor {
return true; return true;
} }
if (Settings.getmaxRegPerEmail > 0) { if (Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) { if (!plugin.authmePermissible(sender, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
m.send(player, "max_reg"); m.send(player, "max_reg");
return true; return true;
} }
@ -76,7 +73,7 @@ public class EmailCommand implements CommandExecutor {
return true; return true;
} }
auth.setEmail(args[1]); auth.setEmail(args[1]);
if (!data.updateEmail(auth)) { if (!plugin.database.updateEmail(auth)) {
m.send(player, "error"); m.send(player, "error");
return true; return true;
} }
@ -86,7 +83,7 @@ public class EmailCommand implements CommandExecutor {
} else if (PlayerCache.getInstance().isAuthenticated(name)) { } else if (PlayerCache.getInstance().isAuthenticated(name)) {
m.send(player, "email_confirm"); m.send(player, "email_confirm");
} else { } else {
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
m.send(player, "reg_email_msg"); m.send(player, "reg_email_msg");
@ -98,7 +95,7 @@ public class EmailCommand implements CommandExecutor {
return true; return true;
} }
if (Settings.getmaxRegPerEmail > 0) { if (Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) { if (!plugin.authmePermissible(sender, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) {
m.send(player, "max_reg"); m.send(player, "max_reg");
return true; return true;
} }
@ -118,7 +115,7 @@ public class EmailCommand implements CommandExecutor {
return true; return true;
} }
auth.setEmail(args[2]); auth.setEmail(args[2]);
if (!data.updateEmail(auth)) { if (!plugin.database.updateEmail(auth)) {
m.send(player, "error"); m.send(player, "error");
return true; return true;
} }
@ -128,7 +125,7 @@ public class EmailCommand implements CommandExecutor {
} else if (PlayerCache.getInstance().isAuthenticated(name)) { } else if (PlayerCache.getInstance().isAuthenticated(name)) {
m.send(player, "email_confirm"); m.send(player, "email_confirm");
} else { } else {
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
m.send(player, "reg_email_msg"); m.send(player, "reg_email_msg");
@ -144,7 +141,7 @@ public class EmailCommand implements CommandExecutor {
m.send(player, "error"); m.send(player, "error");
return true; return true;
} }
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
m.send(player, "logged_in"); m.send(player, "logged_in");
return true; return true;
@ -156,8 +153,8 @@ public class EmailCommand implements CommandExecutor {
PlayerAuth auth = null; PlayerAuth auth = null;
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
auth = PlayerCache.getInstance().getAuth(name); auth = PlayerCache.getInstance().getAuth(name);
} else if (data.isAuthAvailable(name)) { } else if (plugin.database.isAuthAvailable(name)) {
auth = data.getAuth(name); auth = plugin.database.getAuth(name);
} else { } else {
m.send(player, "unknown_user"); m.send(player, "unknown_user");
return true; return true;
@ -172,7 +169,7 @@ public class EmailCommand implements CommandExecutor {
return true; return true;
} }
auth.setHash(hashnew); auth.setHash(hashnew);
data.updatePassword(auth); plugin.database.updatePassword(auth);
plugin.mail.main(auth, thePass); plugin.mail.main(auth, thePass);
m.send(player, "email_send"); m.send(player, "email_send");
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {

View File

@ -6,23 +6,15 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
public class LogoutCommand implements CommandExecutor { public class LogoutCommand implements CommandExecutor {
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
private AuthMe plugin; private AuthMe plugin;
private DataSource database;
private Utils utils = Utils.getInstance();
private FileCache playerBackup;
public LogoutCommand(AuthMe plugin, DataSource database) { public LogoutCommand(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.database = database;
this.playerBackup = new FileCache(plugin);
} }
@Override @Override

View File

@ -20,7 +20,6 @@ import fr.xephi.authme.Utils.groupType;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.FileCache; import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
@ -32,12 +31,10 @@ public class UnregisterCommand implements CommandExecutor {
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
public AuthMe plugin; public AuthMe plugin;
private DataSource database;
private FileCache playerCache; private FileCache playerCache;
public UnregisterCommand(AuthMe plugin, DataSource database) { public UnregisterCommand(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.database = database;
this.playerCache = new FileCache(plugin); this.playerCache = new FileCache(plugin);
} }
@ -67,7 +64,7 @@ public class UnregisterCommand implements CommandExecutor {
} }
try { try {
if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) { if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
if (!database.removeAuth(name)) { if (!plugin.database.removeAuth(name)) {
player.sendMessage("error"); player.sendMessage("error");
return true; return true;
} }

View File

@ -5,6 +5,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
@ -23,10 +24,9 @@ public class CrazyLoginConverter implements Converter {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
public CrazyLoginConverter(AuthMe instance, DataSource database, public CrazyLoginConverter(AuthMe instance, CommandSender sender) {
CommandSender sender) {
this.instance = instance; this.instance = instance;
this.database = database; this.database = instance.database;
this.sender = sender; this.sender = sender;
} }

View File

@ -29,10 +29,9 @@ public class RakamakConverter implements Converter {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
public RakamakConverter(AuthMe instance, DataSource database, public RakamakConverter(AuthMe instance, CommandSender sender) {
CommandSender sender) {
this.instance = instance; this.instance = instance;
this.database = database; this.database = instance.database;
this.sender = sender; this.sender = sender;
} }

View File

@ -17,9 +17,9 @@ public class SqlToFlat implements Converter {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
public SqlToFlat(AuthMe plugin, DataSource database, CommandSender sender) { public SqlToFlat(AuthMe plugin, CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = database; this.database = plugin.database;
this.sender = sender; this.sender = sender;
} }

View File

@ -12,17 +12,16 @@ public class vAuthConverter implements Converter {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
public vAuthConverter(AuthMe plugin, DataSource database, public vAuthConverter(AuthMe plugin, CommandSender sender) {
CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = database; this.database = plugin.database;
this.sender = sender; this.sender = sender;
} }
@Override @Override
public void run() { public void run() {
try { try {
new vAuthFileReader(plugin, database, sender).convert(); new vAuthFileReader(plugin, sender).convert();
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage(e.getMessage()); sender.sendMessage(e.getMessage());
ConsoleLogger.showError(e.getMessage()); ConsoleLogger.showError(e.getMessage());

View File

@ -19,10 +19,9 @@ public class vAuthFileReader {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
public vAuthFileReader(AuthMe plugin, DataSource database, public vAuthFileReader(AuthMe plugin, CommandSender sender) {
CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = database; this.database = plugin.database;
this.sender = sender; this.sender = sender;
} }

View File

@ -3,18 +3,14 @@ package fr.xephi.authme.converter;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.datasource.DataSource;
public class xAuthConverter implements Converter { public class xAuthConverter implements Converter {
public AuthMe plugin; public AuthMe plugin;
public DataSource database;
public CommandSender sender; public CommandSender sender;
public xAuthConverter(AuthMe plugin, DataSource database, public xAuthConverter(AuthMe plugin, CommandSender sender) {
CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = database;
this.sender = sender; this.sender = sender;
} }
@ -22,7 +18,7 @@ public class xAuthConverter implements Converter {
public void run() { public void run() {
try { try {
Class.forName("de.luricos.bukkit.xAuth.xAuth"); Class.forName("de.luricos.bukkit.xAuth.xAuth");
xAuthToFlat converter = new xAuthToFlat(plugin, database, sender); xAuthToFlat converter = new xAuthToFlat(plugin, sender);
converter.convert(); converter.convert();
} catch (ClassNotFoundException ce) { } catch (ClassNotFoundException ce) {
sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!"); sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!");

View File

@ -23,10 +23,9 @@ public class xAuthToFlat {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
public xAuthToFlat(AuthMe instance, DataSource database, public xAuthToFlat(AuthMe instance, CommandSender sender) {
CommandSender sender) {
this.instance = instance; this.instance = instance;
this.database = database; this.database = instance.database;
this.sender = sender; this.sender = sender;
} }

View File

@ -13,6 +13,7 @@ import java.util.List;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.settings.PlayersLogs; import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
@ -648,17 +649,17 @@ public class FlatFile implements DataSource {
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
return PlayersLogs.getInstance().players.contains(user.toLowerCase()); return PlayerCache.getInstance().isAuthenticated(user);
} }
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
PlayersLogs.getInstance().addPlayer(user.toLowerCase()); PlayersLogs.getInstance().savePlayerLogs();
} }
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
PlayersLogs.getInstance().removePlayer(user.toLowerCase()); PlayersLogs.getInstance().savePlayerLogs();
} }
@Override @Override

View File

@ -12,6 +12,7 @@ import java.util.List;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException; import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
import fr.xephi.authme.settings.PlayersLogs; import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
@ -74,8 +75,8 @@ public class SQLite implements DataSource {
} }
} }
private synchronized void connect() throws ClassNotFoundException, private synchronized void connect()
SQLException { throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded"); ConsoleLogger.info("SQLite driver loaded");
this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db"); this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
@ -508,17 +509,17 @@ public class SQLite implements DataSource {
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
return PlayersLogs.getInstance().players.contains(user.toLowerCase()); return PlayerCache.getInstance().isAuthenticated(user);
} }
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
PlayersLogs.getInstance().addPlayer(user.toLowerCase()); PlayersLogs.getInstance().savePlayerLogs();
} }
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
PlayersLogs.getInstance().removePlayer(user.toLowerCase()); PlayersLogs.getInstance().savePlayerLogs();
} }
@Override @Override

View File

@ -0,0 +1,40 @@
package fr.xephi.authme.events;
import org.bukkit.Location;
import org.bukkit.entity.Player;
/**
*
* Called if a player is teleported to the authme first spawn
*
* @author Xephi59
*/
public class FirstSpawnTeleportEvent extends CustomEvent {
private Player player;
private Location to;
private Location from;
public FirstSpawnTeleportEvent(Player player, Location from, Location to) {
this.player = player;
this.from = from;
this.to = to;
}
public Player getPlayer() {
return player;
}
public void setTo(Location to) {
this.to = to;
}
public Location getTo() {
return to;
}
public Location getFrom() {
return from;
}
}

View File

@ -9,16 +9,14 @@ import org.bukkit.event.block.BlockPlaceEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils; import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
public class AuthMeBlockListener implements Listener { public class AuthMeBlockListener implements Listener {
private DataSource data;
public AuthMe instance; public AuthMe instance;
public AuthMeBlockListener(DataSource data, AuthMe instance) { public AuthMeBlockListener(AuthMe instance) {
this.data = data;
this.instance = instance; this.instance = instance;
} }
@ -39,7 +37,7 @@ public class AuthMeBlockListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -64,7 +62,7 @@ public class AuthMeBlockListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }

View File

@ -11,16 +11,13 @@ import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils; import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
public class AuthMeChestShopListener implements Listener { public class AuthMeChestShopListener implements Listener {
public DataSource database;
public AuthMe plugin; public AuthMe plugin;
public AuthMeChestShopListener(DataSource database, AuthMe plugin) { public AuthMeChestShopListener(AuthMe plugin) {
this.database = database;
this.plugin = plugin; this.plugin = plugin;
} }
@ -41,7 +38,7 @@ public class AuthMeChestShopListener implements Listener {
return; return;
} }
if (!database.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }

View File

@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
@ -15,21 +15,18 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils; import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.plugin.manager.CombatTagComunicator;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
public class AuthMeEntityListener implements Listener { public class AuthMeEntityListener implements Listener {
private DataSource data;
public AuthMe instance; public AuthMe instance;
public AuthMeEntityListener(DataSource data, AuthMe instance) { public AuthMeEntityListener(AuthMe instance) {
this.data = data;
this.instance = instance; this.instance = instance;
} }
@EventHandler (priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -44,7 +41,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (instance.citizens.isNPC(entity, instance)) if (instance.citizens.isNPC(entity))
return; return;
Player player = (Player) entity; Player player = (Player) entity;
@ -57,7 +54,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -67,7 +64,7 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler (priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityTarget(EntityTargetEvent event) { public void onEntityTarget(EntityTargetEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -79,7 +76,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (instance.citizens.isNPC(entity, instance)) if (instance.citizens.isNPC(entity))
return; return;
Player player = (Player) entity; Player player = (Player) entity;
@ -89,7 +86,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -97,36 +94,36 @@ public class AuthMeEntityListener implements Listener {
event.setTarget(null); event.setTarget(null);
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onDmg(EntityDamageByEntityEvent event) { public void onDmg(EntityDamageByEntityEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
Entity entity = event.getDamager(); Entity entity = event.getDamager();
if (entity == null || !(entity instanceof Player)) { if (entity == null || !(entity instanceof Player)) {
return; return;
} }
Player player = (Player) entity; Player player = (Player) entity;
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
} }
event.setCancelled(true);
}
@EventHandler (priority = EventPriority.LOWEST) event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -137,7 +134,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (instance.citizens.isNPC(entity, instance)) if (instance.citizens.isNPC(entity))
return; return;
Player player = (Player) entity; Player player = (Player) entity;
@ -147,7 +144,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -168,7 +165,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (instance.citizens.isNPC(entity, instance)) if (instance.citizens.isNPC(entity))
return; return;
Player player = (Player) entity; Player player = (Player) entity;
@ -178,7 +175,7 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -205,14 +202,14 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (instance.citizens.isNPC(player, instance)) if (instance.citizens.isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(player.getName())) { if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -237,14 +234,14 @@ public class AuthMeEntityListener implements Listener {
return; return;
} }
if (instance.citizens.isNPC(player, instance)) if (instance.citizens.isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(player.getName())) { if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!instance.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }

View File

@ -43,25 +43,21 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.plugin.manager.CombatTagComunicator;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
public class AuthMePlayerListener implements Listener { public class AuthMePlayerListener implements Listener {
public static GameMode gm = GameMode.SURVIVAL;
public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<String, GameMode>(); public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<String, GameMode>();
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<String, String>(); public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<String, String>();
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
public AuthMe plugin; public AuthMe plugin;
private DataSource data;
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<String, Boolean>(); public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<String, Boolean>();
private List<String> antibot = new ArrayList<String>(); private List<String> antibot = new ArrayList<String>();
public AuthMePlayerListener(AuthMe plugin, DataSource data) { public AuthMePlayerListener(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.data = data;
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
@ -78,7 +74,7 @@ public class AuthMePlayerListener implements Listener {
if (PlayerCache.getInstance().isAuthenticated(name)) if (PlayerCache.getInstance().isAuthenticated(name))
return; return;
if (!data.isAuthAvailable(name)) if (!plugin.database.isAuthAvailable(name))
if (!Settings.isForcedRegistrationEnabled) if (!Settings.isForcedRegistrationEnabled)
return; return;
@ -114,7 +110,7 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0]; String cmd = event.getMessage().split(" ")[0];
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -151,7 +147,7 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0]; String cmd = event.getMessage().split(" ")[0];
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -188,7 +184,7 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0]; String cmd = event.getMessage().split(" ")[0];
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -225,7 +221,7 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0]; String cmd = event.getMessage().split(" ")[0];
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -263,7 +259,7 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0]; String cmd = event.getMessage().split(" ")[0];
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -300,7 +296,7 @@ public class AuthMePlayerListener implements Listener {
String cmd = event.getMessage().split(" ")[0]; String cmd = event.getMessage().split(" ")[0];
if (data.isAuthAvailable(name)) { if (plugin.database.isAuthAvailable(name)) {
m.send(player, "login_msg"); m.send(player, "login_msg");
} else { } else {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -328,7 +324,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return; return;
} }
@ -337,7 +333,7 @@ public class AuthMePlayerListener implements Listener {
} }
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
if (!data.isAuthAvailable(name)) if (!plugin.database.isAuthAvailable(name))
return; return;
} }
@ -405,9 +401,9 @@ public class AuthMePlayerListener implements Listener {
if (player == null) if (player == null)
return; return;
final String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
boolean isAuthAvailable = data.isAuthAvailable(name); boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return; return;
} }
@ -429,7 +425,7 @@ public class AuthMePlayerListener implements Listener {
} }
if (Settings.isKickNonRegisteredEnabled) { if (Settings.isKickNonRegisteredEnabled) {
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
event.setKickMessage(m.send("reg_only")[0]); event.setKickMessage(m.send("reg_only")[0]);
event.setResult(PlayerLoginEvent.Result.KICK_OTHER); event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
return; return;
@ -580,7 +576,7 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performQuit(player, false); plugin.management.performQuit(player, false);
if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection) if (plugin.database.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
event.setQuitMessage(null); event.setQuitMessage(null);
} }
@ -616,14 +612,14 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -644,14 +640,14 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -673,14 +669,14 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -702,14 +698,14 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -727,7 +723,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return; return;
} }
@ -735,7 +731,7 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -755,14 +751,14 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) { if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -786,7 +782,7 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -807,7 +803,7 @@ public class AuthMePlayerListener implements Listener {
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
return; return;
} }
if (!data.isAuthAvailable(name)) { if (!plugin.database.isAuthAvailable(name)) {
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
@ -827,21 +823,21 @@ public class AuthMePlayerListener implements Listener {
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
return; return;
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(name)) if (PlayerCache.getInstance().isAuthenticated(name))
return; return;
if (!data.isAuthAvailable(name)) if (!plugin.database.isAuthAvailable(name))
if (!Settings.isForcedRegistrationEnabled) if (!Settings.isForcedRegistrationEnabled)
return; return;
Location spawn = plugin.getSpawnLocation(player); Location spawn = plugin.getSpawnLocation(player);
if (Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) { if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName()); final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName());
try { try {
data.updateQuitLoc(auth); plugin.database.updateQuitLoc(auth);
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
} }
} }
@ -855,8 +851,6 @@ public class AuthMePlayerListener implements Listener {
return; return;
if (event.getPlayer() == null || event == null) if (event.getPlayer() == null || event == null)
return; return;
if (!Settings.isForceSurvivalModeEnabled)
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -868,18 +862,19 @@ public class AuthMePlayerListener implements Listener {
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
return; return;
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) if (plugin.getCitizensCommunicator().isNPC(player))
return; return;
if (PlayerCache.getInstance().isAuthenticated(name)) if (PlayerCache.getInstance().isAuthenticated(name))
return; return;
if (!data.isAuthAvailable(name)) if (!plugin.database.isAuthAvailable(name))
if (!Settings.isForcedRegistrationEnabled) if (!Settings.isForcedRegistrationEnabled)
return; return;
if (causeByAuthMe.containsKey(name) && causeByAuthMe.get(name)) if (causeByAuthMe.containsKey(name) && causeByAuthMe.get(name))
return; return;
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -13,7 +13,7 @@ public class CitizensCommunicator {
this.instance = instance; this.instance = instance;
} }
public boolean isNPC(final Entity player, AuthMe instance) { public boolean isNPC(final Entity player) {
if (!this.instance.isCitizensActive) if (!this.instance.isCitizensActive)
return false; return false;
try { try {

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.process.join.AsyncronousJoin; import fr.xephi.authme.process.join.AsyncronousJoin;
import fr.xephi.authme.process.login.AsyncronousLogin; import fr.xephi.authme.process.login.AsyncronousLogin;
import fr.xephi.authme.process.logout.AsyncronousLogout; import fr.xephi.authme.process.logout.AsyncronousLogout;
@ -22,13 +21,11 @@ import fr.xephi.authme.settings.Settings;
*/ */
public class Management { public class Management {
public DataSource database;
public AuthMe plugin; public AuthMe plugin;
public static RandomString rdm = new RandomString(Settings.captchaLength); public static RandomString rdm = new RandomString(Settings.captchaLength);
public PluginManager pm; public PluginManager pm;
public Management(DataSource database, AuthMe plugin) { public Management(AuthMe plugin) {
this.database = database;
this.plugin = plugin; this.plugin = plugin;
this.pm = plugin.getServer().getPluginManager(); this.pm = plugin.getServer().getPluginManager();
} }
@ -39,7 +36,7 @@ public class Management {
@Override @Override
public void run() { public void run() {
new AsyncronousLogin(player, password, forceLogin, plugin, database).process(); new AsyncronousLogin(player, password, forceLogin, plugin, plugin.database).process();
} }
}); });
} }
@ -50,7 +47,7 @@ public class Management {
@Override @Override
public void run() { public void run() {
new AsyncronousRegister(player, password, email, plugin, database).process(); new AsyncronousRegister(player, password, email, plugin, plugin.database).process();
} }
}); });
} }
@ -60,7 +57,7 @@ public class Management {
@Override @Override
public void run() { public void run() {
new AsyncronousLogout(player, plugin, database).process(); new AsyncronousLogout(player, plugin, plugin.database).process();
} }
}); });
} }
@ -70,7 +67,7 @@ public class Management {
@Override @Override
public void run() { public void run() {
new AsyncronousQuit(player, plugin, database, isKick).process(); new AsyncronousQuit(player, plugin, plugin.database, isKick).process();
} }
}); });
@ -81,7 +78,7 @@ public class Management {
@Override @Override
public void run() { public void run() {
new AsyncronousJoin(player, plugin, database).process(); new AsyncronousJoin(player, plugin, plugin.database).process();
} }
}); });

View File

@ -22,12 +22,14 @@ import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.ProtectInventoryEvent; import fr.xephi.authme.events.ProtectInventoryEvent;
import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.plugin.manager.CombatTagComunicator; import fr.xephi.authme.plugin.manager.CombatTagComunicator;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask; import fr.xephi.authme.task.TimeoutTask;
@ -53,7 +55,7 @@ public class AsyncronousJoin {
AuthMePlayerListener.gameMode.put(name, player.getGameMode()); AuthMePlayerListener.gameMode.put(name, player.getGameMode());
BukkitScheduler sched = plugin.getServer().getScheduler(); BukkitScheduler sched = plugin.getServer().getScheduler();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return; return;
} }
@ -149,7 +151,7 @@ public class AsyncronousJoin {
return; return;
} }
if (!Settings.noTeleport) if (!Settings.noTeleport)
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { if (!needFirstspawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
@ -216,7 +218,7 @@ public class AsyncronousJoin {
public void run() { public void run() {
if (player.isOp()) if (player.isOp())
player.setOp(false); player.setOp(false);
if (!Settings.isMovementAllowed) { if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(true); player.setAllowFlight(true);
player.setFlying(true); player.setFlying(true);
} }
@ -249,6 +251,31 @@ public class AsyncronousJoin {
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
} }
private boolean needFirstspawn() {
if (database.isAuthAvailable(player.getName().toLowerCase()) && player.hasPlayedBefore())
return false;
else {
if (Spawn.getInstance().getFirstSpawn() == null || Spawn.getInstance().getFirstSpawn().getWorld() == null)
return false;
final Location loc = Spawn.getInstance().getFirstSpawn();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), loc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
if (player != null && player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo());
}
}
}
});
return true;
}
}
private void placePlayerSafely(final Player player, private void placePlayerSafely(final Player player,
final Location spawnLoc) { final Location spawnLoc) {
Location loc = null; Location loc = null;
@ -258,14 +285,16 @@ public class AsyncronousJoin {
return; return;
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
return; return;
if (!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore())
return;
Block b = player.getLocation().getBlock(); Block b = player.getLocation().getBlock();
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) { if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn"); m.send(player, "unsafe_spawn");
if (spawnLoc.getWorld() != null) if (spawnLoc.getWorld() != null)
loc = spawnLoc; loc = spawnLoc;
} else { } else {
Block c = player.getLocation().add(0D, 1D, 0D).getBlock(); Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) { if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn"); m.send(player, "unsafe_spawn");
if (spawnLoc.getWorld() != null) if (spawnLoc.getWorld() != null)
loc = spawnLoc; loc = spawnLoc;

View File

@ -10,7 +10,6 @@ import org.bukkit.potion.PotionEffectType;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils; import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.groupType; import fr.xephi.authme.Utils.groupType;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.backup.FileCache; import fr.xephi.authme.cache.backup.FileCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
@ -53,8 +52,13 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
protected void restoreOpState() { protected void restoreOpState() {
player.setOp(limbo.getOperator()); player.setOp(limbo.getOperator());
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) { if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(limbo.isFlying()); if (limbo.getGameMode() != GameMode.CREATIVE) {
player.setFlying(limbo.isFlying()); player.setAllowFlight(limbo.isFlying());
player.setFlying(limbo.isFlying());
} else {
player.setAllowFlight(false);
player.setFlying(false);
}
} }
} }
@ -120,8 +124,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
* ProtectInventoryEvent after Teleporting Also it's the current * ProtectInventoryEvent after Teleporting Also it's the current
* world inventory ! * world inventory !
*/ */
player.setGameMode(limbo.getGameMode());
if (!Settings.forceOnlyAfterLogin) { if (!Settings.forceOnlyAfterLogin) {
player.setGameMode(limbo.getGameMode());
// Inventory - Make it after restore GameMode , cause we need to // Inventory - Make it after restore GameMode , cause we need to
// restore the // restore the
// right inventory in the right gamemode // right inventory in the right gamemode
@ -146,7 +150,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
} else { } else {
teleportBackFromSpawn(); teleportBackFromSpawn();
} }
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) { } else
if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
teleportToSpawn(); teleportToSpawn();
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) { } else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
packQuitLocation(); packQuitLocation();

View File

@ -51,8 +51,10 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
if (Settings.applyBlindEffect) if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
player.setOp(false); player.setOp(false);
player.setAllowFlight(true); if (!Settings.isMovementAllowed) {
player.setFlying(true); player.setAllowFlight(true);
player.setFlying(true);
}
// Player is now logout... Time to fire event ! // Player is now logout... Time to fire event !
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {

View File

@ -45,7 +45,7 @@ public class AsyncronousQuit {
public void process() { public void process() {
final Player player = p; final Player player = p;
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return; return;
} }

View File

@ -12,6 +12,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
public class AsyncronousRegister { public class AsyncronousRegister {
@ -64,9 +65,7 @@ public class AsyncronousRegister {
else if (database.isAuthAvailable(name)) { else if (database.isAuthAvailable(name)) {
m.send(player, "user_regged"); m.send(player, "user_regged");
if (plugin.pllog.getStringList("players").contains(name)) { PlayersLogs.getInstance().savePlayerLogs();
plugin.pllog.getStringList("players").remove(name);
}
allowRegister = false; allowRegister = false;
} }

View File

@ -17,6 +17,7 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.LoginEvent; import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RegisterTeleportEvent; import fr.xephi.authme.events.RegisterTeleportEvent;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask; import fr.xephi.authme.task.TimeoutTask;
@ -71,7 +72,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval)); BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
try { try {
plugin.pllog.removePlayer(name); PlayersLogs.getInstance().save();
if (player.isInsideVehicle()) if (player.isInsideVehicle())
player.getVehicle().eject(); player.getVehicle().eject();
} catch (NullPointerException npe) { } catch (NullPointerException npe) {

View File

@ -2,8 +2,14 @@ package fr.xephi.authme.settings;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
/** /**
* *
* @author Xephi59 * @author Xephi59
@ -11,19 +17,27 @@ import java.util.List;
public class PlayersLogs extends CustomConfiguration { public class PlayersLogs extends CustomConfiguration {
private static PlayersLogs pllog = null; private static PlayersLogs pllog = null;
public List<String> players;
public PlayersLogs() { public PlayersLogs() {
super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "players.yml")); super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "players.yml"));
pllog = this; pllog = this;
load(); load();
save(); save();
players = this.getStringList("players");
} }
public void clear() { public void loadPlayers() {
set("players", new ArrayList<String>()); DataSource database = AuthMe.getInstance().database;
save(); List<String> list = this.getStringList("players");
if (list == null || list.isEmpty())
return;
for (String s : list) {
PlayerAuth auth = database.getAuth(s);
if (auth == null)
continue;
auth.setLastLogin(new Date().getTime());
database.updateSession(auth);
PlayerCache.getInstance().addPlayer(auth);
}
} }
public static PlayersLogs getInstance() { public static PlayersLogs getInstance() {
@ -33,21 +47,18 @@ public class PlayersLogs extends CustomConfiguration {
return pllog; return pllog;
} }
public void addPlayer(String user) { public void savePlayerLogs() {
players = this.getStringList("players"); List<String> players = new ArrayList<String>();
if (!players.contains(user.toLowerCase())) { for (String s : PlayerCache.getInstance().getCache().keySet()) {
players.add(user.toLowerCase()); players.add(s);
set("players", players);
save();
} }
this.set("players", players);
this.save();
} }
public void removePlayer(String user) { public void clear() {
players = this.getStringList("players"); this.set("players", new ArrayList<String>());
if (players.contains(user.toLowerCase())) { this.save();
players.remove(user.toLowerCase());
set("players", players);
save();
}
} }
} }

View File

@ -70,7 +70,7 @@ public final class Settings extends YamlConfiguration {
purgePermissions, enableProtection, enableAntiBot, recallEmail, purgePermissions, enableProtection, enableAntiBot, recallEmail,
useWelcomeMessage, broadcastWelcomeMessage, forceRegKick, useWelcomeMessage, broadcastWelcomeMessage, forceRegKick,
forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport, forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport,
applyBlindEffect, customAttributes; applyBlindEffect, customAttributes, generateImage;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
@ -269,6 +269,7 @@ public final class Settings extends YamlConfiguration {
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>()); forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>()); forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
customAttributes = configFile.getBoolean("Hooks.customAttributes"); customAttributes = configFile.getBoolean("Hooks.customAttributes");
generateImage = configFile.getBoolean("Email.generateImage", true);
// Load the welcome message // Load the welcome message
getWelcomeMessage(plugin); getWelcomeMessage(plugin);
@ -435,6 +436,7 @@ public final class Settings extends YamlConfiguration {
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>()); forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>()); forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
customAttributes = configFile.getBoolean("Hooks.customAttributes"); customAttributes = configFile.getBoolean("Hooks.customAttributes");
generateImage = configFile.getBoolean("Email.generateImage", true);
// Reload the welcome message // Reload the welcome message
getWelcomeMessage(AuthMe.getInstance()); getWelcomeMessage(AuthMe.getInstance());
@ -587,6 +589,10 @@ public final class Settings extends YamlConfiguration {
} }
if (contains("Hooks.notifications")) if (contains("Hooks.notifications"))
set("Hooks.notifications", null); set("Hooks.notifications", null);
if (!contains("Email.generateImage")) {
set("Email.generateImage", true);
changes = true;
}
if (changes) { if (changes) {
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me"); plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");

View File

@ -1,57 +1,59 @@
unknown_user: '使用者名稱不在資料庫內' unknown_user: "&b【AuthMe】&6沒有在資料庫內找到該玩家。"
unsafe_spawn: '退出的位置是不安全的,你被傳送到重生點' unsafe_spawn: '&b【AuthMe】&6你登出的地點不安全已傳送你到安全的地點。'
not_logged_in: '&c您還未登入!' not_logged_in: '&b【AuthMe】&6你還沒有登入!'
reg_voluntarily: '您可以在本伺服器創一個屬於您的密碼 ,指令:"/register <密碼> 確認密碼"' reg_voluntarily: '&b【AuthMe】&6使用 &c"/register <密碼> <確認密碼>" &6來註冊你的暱稱'
usage_log: '&c正確用法為:使用"/login <密碼>"來登入' usage_log: '&b【AuthMe】&6用法: &c"/login <密碼>"'
wrong_pwd: '&c密碼錯誤!' wrong_pwd: '&b【AuthMe】&6密碼錯誤!'
unregistered: '&a此密碼尚未被註冊!' unregistered: '&b【AuthMe】&6你還沒有註冊!'
reg_disabled: '&c註冊被禁用' reg_disabled: '&b【AuthMe】&6已關閉註冊功能'
password_error_nick: '&fYou can''t use your name as password' password_error_nick: '&fYou can''t use your name as password'
password_error_unsafe: '&fYou can''t use unsafe passwords' password_error_unsafe: '&fYou can''t use unsafe passwords'
valid_session: '&c"會議"登入' valid_session: '&b【AuthMe】&6憑證登入'
login: '&a登入成功!' login: '&b【AuthMe】&6密碼正確你已成功登入!'
vb_nonActiv: '你的帳號沒有被繳活,請查看你的電子信箱!' vb_nonActiv: '&b【AuthMe】&6你的帳號還沒有經過驗證! 檢查看看你的電子信箱 (Email) 吧!'
user_regged: '&c此密碼已被註冊請重新註冊您的新密碼!' user_regged: '&b【AuthMe】&6這個帳號已經被註冊過了!'
usage_reg: '&c正確用法為:使用"/register <密碼> <確認密碼>"來註冊你的密碼' usage_reg: '&b【AuthMe】&6用法: &c"/register <密碼> <確認密碼>"'
max_reg: '你的密碼註冊數量已滿,無法繼續註冊!' max_reg: '&b【AuthMe】&6你註冊的帳號數量已達到最大。'
no_perm: '&c你沒有權限!' no_perm: '&b【AuthMe】&6你沒有使用該指令的權限。'
error: '發生未知錯誤,請通知管理員!' error: '&b【AuthMe】&6發生錯誤請聯繫管理員'
login_msg: '&c請使用"/login <密碼>"來登入' login_msg: '&b【AuthMe】&6請使用 &c"/login <密碼>" &6來登入。'
reg_msg: '&c初次登入請使用"/register <密碼> <確認密碼>"來註冊!' reg_msg: '&b【AuthMe】&6請使用 "&c/register <密碼> <確認密碼>" 來註冊。'
usage_unreg: '&c正確用法為:使用"/unregister <密碼>"來取消現有密碼' reg_email_msg: '&b【AuthMe】&6請使用 &c"/register <email> <重複Email>" 來註冊'
pwd_changed: '&c密碼變更成功!' usage_unreg: '&b【AuthMe】&6用法: &c"/unregister <密碼>"'
user_unknown: '&c此用戶名並未被註冊!' pwd_changed: '&b【AuthMe】&6密碼變更成功!'
password_error: <密碼>與<錯認密碼>不相同! user_unknown: '&b【AuthMe】&6這個帳號還沒有註冊過'
invalid_session: 'Session Dataes doesnt corrispond Plaese wait the end of session' password_error: '&b【AuthMe】&6兩次輸入的密碼不一致!'
reg_only: 'Registered players only! Please visit http://example.com to register' invalid_session: '&b【AuthMe】&6憑證日期不相符!'
logged_in: '&c您已經登入了!' reg_only: '&b【AuthMe】&6請訪問 http://example.com 進行註冊'
logout: '&a登出成功!' logged_in: '&b【AuthMe】&6你已經登入了!'
same_nick: '與別人的密碼重複!' logout: '&b【AuthMe】&6你已成功登出'
registered: '&a註冊成功!' same_nick: '&b【AuthMe】&6有同樣帳號的玩家在線上!'
pass_len: '您的密碼未到達最小長度(4),或超過最大長度(20)' registered: '&b【AuthMe】&6你已成功註冊'
reload: '伺服器已重新配置數據庫' pass_len: '&b【AuthMe】&6你的密碼 超過最大字數 / 小於最小字數'
timeout: '登入超時了!' reload: '&b【AuthMe】&6已重新讀取設定檔及資料庫'
usage_changepassword: '正確用法為:使用"/changepassword <舊密碼> <新密碼>"來更換密碼' timeout: '&b【AuthMe】&6超過登入時間請再試一次'
name_len: '&cYour nickname is too Short or too long' usage_changepassword: '&b【AuthMe】&6用法: &c"/changepassword <舊密碼> <新密碼>"'
regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX' name_len: '&b【AuthMe】&6你的暱稱 太長 / 太短 了!'
add_email: '&cPlease add your email with : /email add yourEmail confirmEmail' regex: '&b【AuthMe】&6暱稱裡包含不能使用的字符'
bad_database_email: '[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin' add_email: '&b【AuthMe】&6請使用 &c"/email add <你的Email> <再次輸入你的Email>" &6來增加Email'
recovery_email: '&cForgot your password? Please use /email recovery <yourEmail>' bad_database_email: '&b【AuthMe】&6這個 &c"/email" &6指令只適用於有使用MySQL和SQLite的時候請聯繫管理員'
usage_captcha: '&cYou need to type a captcha, please type: /captcha <theCaptcha>' recovery_email: '&b【AuthMe】&6忘記密碼了嗎? 使用 &c"/email recovery <你的Email>"'
wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA' usage_captcha: '&b【AuthMe】&6請用 &c"/captcha <theCaptcha>" &6來輸入你的驗證碼'
valid_captcha: '&cYour captcha is valid !' wrong_captcha: '&b【AuthMe】&6錯誤的驗證碼'
kick_forvip: '&cA VIP Player join the full server!' valid_captcha: '&b【AuthMe】&6驗證碼無效!'
kick_fullserver: '&cThe server is actually full, Sorry!' kick_forvip: '&&b【AuthMe】&6VIP玩家只能在伺服器滿人時登入伺服器!'
usage_email_add: '&fUsage: /email add <email> <confirmeEmail> ' kick_fullserver: '&b【AuthMe】&6伺服器已經滿了請等等再試一次'
usage_email_change: '&fUsage: /email change oldEmail> <newEmail> ' usage_email_add: '&b【AuthMe】&6用法: &c"/email add <你的Email> <重複輸入你的Email>"'
usage_email_recovery: '&fUsage: /email recovery <Email>' usage_email_change: '&b【AuthMe】&6用法: &c"/email change <現在的Email> <要替換的Email>"'
new_email_invalid: '[AuthMe] New email invalid!' usage_email_recovery: '&b【AuthMe】&6用法: &c"/email recovery <你的Email>"'
old_email_invalid: '[AuthMe] Old email invalid!' new_email_invalid: '&b【AuthMe】&6新的Email無效!'
email_invalid: '[AuthMe] Invalid Email' old_email_invalid: '&b【AuthMe】&6舊的Email無效!'
email_added: '[AuthMe] Email Added !' email_invalid: '&b【AuthMe】&6無效的Email!'
email_confirm: '[AuthMe] Confirm your Email !' email_added: '&b【AuthMe】&6已添加Email!'
email_changed: '[AuthMe] Email Change !' email_confirm: '&b【AuthMe】&6驗證你的Email!'
email_send: '[AuthMe] Recovery Email Send !' email_changed: '&b【AuthMe】&6Email已變更!'
country_banned: 'Your country is banned from this server' email_send: '&b【AuthMe】&6已經送出要求至你的Email!'
antibot_auto_enabled: '[AuthMe] AntiBotMod automatically enabled due to massive connections!' email_exists: '&b【AuthMe】&6這個帳戶已經有設定電子郵件了'
antibot_auto_disabled: '[AuthMe] AntiBotMod automatically disabled after %m Minutes, hope invasion stopped' country_banned: '你所在的地區無法進入此伺服器'
antibot_auto_enabled: '&b【AuthMe】&6AntiBotMod已自動啟用!'
antibot_auto_disabled: '&b【AuthMe】&6AntiBotMod將會於 &c%m &6分鐘後自動關閉'