mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-22 16:48:21 +01:00
Update 2.7.14
* Add Slot Reservation system ( permission : authme.vip ) * Add ConsoleLogging in authme.log file ( disabled by default, check config ) * Save the main thread by different database access and saves * Perform login more quickly * CleanUp the code entirely * BungeeCord should be fixed :'( * Fix the Flat To MySQL converter * Teleport players correctly
This commit is contained in:
parent
468aaa18a3
commit
73c97a39e6
Binary file not shown.
2
pom.xml
2
pom.xml
@ -28,7 +28,7 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<version>2.7.13b2</version>
|
||||
<version>2.7.14</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
|
@ -97,28 +97,26 @@ public class AuthMe extends JavaPlugin {
|
||||
public HashMap<String, Integer> captcha = new HashMap<String, Integer>();
|
||||
public HashMap<String, String> cap = new HashMap<String, String>();
|
||||
public MultiverseCore mv = null;
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
authme = instance;
|
||||
|
||||
|
||||
citizens = new CitizensCommunicator(this);
|
||||
|
||||
settings = new Settings(this);
|
||||
settings.loadConfigOptions();
|
||||
|
||||
|
||||
setMessages(Messages.getInstance());
|
||||
pllog = PlayersLogs.getInstance();
|
||||
|
||||
|
||||
server = getServer();
|
||||
|
||||
|
||||
|
||||
//Set Console Filter
|
||||
if (Settings.removePassword)
|
||||
Bukkit.getLogger().setFilter(new ConsoleFilter());
|
||||
|
||||
|
||||
|
||||
//Load MailApi
|
||||
File mailFile = new File("lib", "mail.jar");
|
||||
if (mailFile.exists()) {
|
||||
@ -127,22 +125,22 @@ public class AuthMe extends JavaPlugin {
|
||||
} else {
|
||||
mail = null;
|
||||
}
|
||||
|
||||
|
||||
//Check Citizens Version
|
||||
citizensVersion();
|
||||
|
||||
|
||||
//Check Combat Tag Version
|
||||
combatTag();
|
||||
|
||||
|
||||
//Check Notifications
|
||||
checkNotifications();
|
||||
|
||||
|
||||
//Check Multiverse
|
||||
checkMultiverse();
|
||||
|
||||
|
||||
//Check ChestShop
|
||||
checkChestShop();
|
||||
|
||||
|
||||
/*
|
||||
* Back style on start if avaible
|
||||
*/
|
||||
@ -151,7 +149,7 @@ public class AuthMe extends JavaPlugin {
|
||||
if(Backup) ConsoleLogger.info("Backup Complete");
|
||||
else ConsoleLogger.showError("Error while making Backup");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Backend MYSQL - FILE - SQLITE
|
||||
*/
|
||||
@ -230,11 +228,11 @@ public class AuthMe extends JavaPlugin {
|
||||
if (Settings.isCachingEnabled) {
|
||||
database = new CacheDataSource(this, database);
|
||||
}
|
||||
|
||||
|
||||
api = new API(this, database);
|
||||
|
||||
|
||||
management = new Management(database, this);
|
||||
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
if (pm.isPluginEnabled("Spout")) {
|
||||
pm.registerEvents(new AuthMeSpoutListener(database), this);
|
||||
@ -247,8 +245,7 @@ public class AuthMe extends JavaPlugin {
|
||||
pm.registerEvents(new AuthMeChestShopListener(database, this), this);
|
||||
ConsoleLogger.info("Successfully hook with ChestShop!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Find Permissions
|
||||
if(Settings.isPermissionCheckEnabled) {
|
||||
RegisteredServiceProvider<Permission> permissionProvider =
|
||||
@ -257,10 +254,11 @@ public class AuthMe extends JavaPlugin {
|
||||
permission = permissionProvider.getProvider();
|
||||
else {
|
||||
ConsoleLogger.showError("Vault and Permissions plugins is needed for enable AuthMe Reloaded!");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
ConsoleLogger.showError("Server Shutdown for Security");
|
||||
this.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.getCommand("authme").setExecutor(new AdminCommand(this, database));
|
||||
this.getCommand("register").setExecutor(new RegisterCommand(database, this));
|
||||
this.getCommand("login").setExecutor(new LoginCommand(this));
|
||||
@ -270,11 +268,11 @@ public class AuthMe extends JavaPlugin {
|
||||
this.getCommand("passpartu").setExecutor(new PasspartuCommand(database, this));
|
||||
this.getCommand("email").setExecutor(new EmailCommand(this, database));
|
||||
this.getCommand("captcha").setExecutor(new CaptchaCommand(this));
|
||||
|
||||
|
||||
if(!Settings.isForceSingleSessionEnabled) {
|
||||
ConsoleLogger.showError("ATTENTION by disabling ForceSingleSession, your server protection is set to low");
|
||||
}
|
||||
|
||||
|
||||
if (Settings.reloadSupport)
|
||||
try {
|
||||
if (!new File(getDataFolder() + File.separator + "players.yml").exists()) {
|
||||
@ -289,13 +287,10 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
|
||||
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
|
||||
}
|
||||
|
||||
|
||||
private void checkChestShop() {
|
||||
if (!Settings.chestshop) {
|
||||
this.ChestShop = 0;
|
||||
@ -320,16 +315,12 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.showError("Please Update your ChestShop version!");
|
||||
}
|
||||
} catch (NumberFormatException nfee) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (NullPointerException npe) {}
|
||||
catch (NoClassDefFoundError ncdfe) {}
|
||||
catch (ClassCastException cce) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkMultiverse() {
|
||||
@ -362,7 +353,6 @@ public class AuthMe extends JavaPlugin {
|
||||
} else {
|
||||
this.notifications = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void combatTag() {
|
||||
@ -395,23 +385,17 @@ public class AuthMe extends JavaPlugin {
|
||||
this.savePlayer(player);
|
||||
}
|
||||
pllog.save();
|
||||
|
||||
|
||||
if (database != null) {
|
||||
database.close();
|
||||
}
|
||||
//utils = Utils.getInstance();
|
||||
|
||||
/*
|
||||
* Back style on start if avaible
|
||||
*/
|
||||
|
||||
if(Settings.isBackupActivated && Settings.isBackupOnStop) {
|
||||
Boolean Backup = new PerformBackup(this).DoBackup();
|
||||
if(Backup) ConsoleLogger.info("Backup Complete");
|
||||
else ConsoleLogger.showError("Error while making Backup");
|
||||
}
|
||||
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " disabled");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void onReload() {
|
||||
@ -421,7 +405,6 @@ public class AuthMe extends JavaPlugin {
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
String name = player.getName().toLowerCase();
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
// if Mysql is unavaible
|
||||
if(pAuth == null)
|
||||
break;
|
||||
PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(), pAuth.getIp(), new Date().getTime());
|
||||
@ -435,18 +418,17 @@ public class AuthMe extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static AuthMe getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
public void savePlayer(Player player) throws IllegalStateException, NullPointerException {
|
||||
try {
|
||||
if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) { }
|
||||
|
||||
try {
|
||||
String name = player.getName().toLowerCase();
|
||||
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
|
||||
@ -454,7 +436,6 @@ public class AuthMe extends JavaPlugin {
|
||||
PlayerAuth auth = new PlayerAuth(player.getName().toLowerCase(), (int)player.getLocation().getX(), (int)player.getLocation().getY(), (int)player.getLocation().getZ());
|
||||
this.database.updateQuitLoc(auth);
|
||||
}
|
||||
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
{
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@ -468,14 +449,12 @@ public class AuthMe extends JavaPlugin {
|
||||
player.teleport(limbo.getLoc());
|
||||
this.utils.addNormal(player, limbo.getGroup());
|
||||
player.setOp(limbo.getOperator());
|
||||
|
||||
this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (this.playerBackup.doesCacheExist(name)) {
|
||||
this.playerBackup.removeCache(name);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
player.saveData();
|
||||
} catch (Exception ex) {
|
||||
@ -497,7 +476,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public Messages getMessages() {
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
public Player generateKickPlayer(Player[] players) {
|
||||
Player player = null;
|
||||
int i;
|
||||
@ -509,7 +488,13 @@ public class AuthMe extends JavaPlugin {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (player == null) {
|
||||
for (Player p : this.getServer().getOnlinePlayers()) {
|
||||
if (p.hasPermission("authme.vip"))
|
||||
player = p;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,17 +16,65 @@
|
||||
|
||||
package uk.org.whoami.authme;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class ConsoleLogger {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
public static void info(String message) {
|
||||
log.info("[AuthMe] " + message);
|
||||
if (AuthMe.getInstance().isEnabled()) {
|
||||
log.info("[AuthMe] " + message);
|
||||
if (Settings.useLogging) {
|
||||
Calendar date = Calendar.getInstance();
|
||||
final String actually = "[" + DateFormat.getDateInstance().format(date.getTime()) + ", " + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND) + "] " + message;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AuthMe.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
writeLog(actually);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void showError(String message) {
|
||||
log.severe("[AuthMe] ERROR: " + message);
|
||||
if (AuthMe.getInstance().isEnabled()) {
|
||||
log.severe("[AuthMe] ERROR: " + message);
|
||||
if (Settings.useLogging) {
|
||||
Calendar date = Calendar.getInstance();
|
||||
final String actually = "[" + DateFormat.getDateInstance().format(date.getTime()) + ", " + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND) + "] ERROR : " + message;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AuthMe.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
writeLog(actually);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeLog(String string) {
|
||||
try {
|
||||
FileWriter fw = new FileWriter(AuthMe.getInstance().getDataFolder() + File.separator + "authme.log", true);
|
||||
BufferedWriter w = null;
|
||||
w = new BufferedWriter(fw);
|
||||
w.write(string);
|
||||
w.newLine();
|
||||
w.close();
|
||||
} catch (IOException e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -44,7 +45,7 @@ public class Management {
|
||||
private boolean passpartu = false;
|
||||
public static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
public PluginManager pm;
|
||||
|
||||
|
||||
public Management(DataSource database, AuthMe plugin) {
|
||||
this.database = database;
|
||||
this.plugin = plugin;
|
||||
@ -57,342 +58,423 @@ public class Management {
|
||||
this.plugin = plugin;
|
||||
this.pm = plugin.getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public String performLogin(Player player, String password) {
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
ip = BungeeCord.getInstance().getPlayer(player.getName()).getAddress().getAddress().getHostAddress();
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
ConsoleLogger.showError("Your BungeeCord version is outdated, you need a version with the latest API");
|
||||
}
|
||||
}
|
||||
World world = player.getWorld();
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
spawnLoc = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
spawnLoc = Spawn.getInstance().getLocation();
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return m._("logged_in");
|
||||
|
||||
}
|
||||
|
||||
if (!database.isAuthAvailable(player.getName().toLowerCase())) {
|
||||
return m._("user_unknown");
|
||||
}
|
||||
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
// if Mysql is unavaible
|
||||
if(pAuth == null)
|
||||
return m._("user_unknown");
|
||||
|
||||
//if columnGroup is set
|
||||
if(!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
return m._("vb_nonActiv");
|
||||
}
|
||||
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
|
||||
public void performLogin(final Player player, final String password) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
try {
|
||||
if(!passpartu) {
|
||||
if (Settings.useCaptcha) {
|
||||
if(!plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.put(name, 1);
|
||||
} else {
|
||||
int i = plugin.captcha.get(name) + 1;
|
||||
plugin.captcha.remove(name);
|
||||
plugin.captcha.put(name, i);
|
||||
}
|
||||
|
||||
if(plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
player.sendMessage(m._("need_captcha"));
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
return "Type : /captcha " + plugin.cap.get(name);
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
try {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.cap.remove(name);
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
}
|
||||
}
|
||||
if (PasswordSecurity.comparePasswordWithHash(password, hash, name)) {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, ip, new Date().getTime(), email);
|
||||
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
@Override
|
||||
public void run() {
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
for (ProxiedPlayer pp : BungeeCord.getInstance().getPlayers()) {
|
||||
if (pp.getName().toLowerCase() == name) {
|
||||
ip = pp.getAddress().getAddress().getHostAddress();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
World world = player.getWorld();
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (plugin.mv != null) {
|
||||
try {
|
||||
spawnLoc = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (ClassCastException cce) {
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
}
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
spawnLoc = Spawn.getInstance().getLocation();
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
player.sendMessage(m._("logged_in"));
|
||||
return;
|
||||
}
|
||||
if (!database.isAuthAvailable(player.getName().toLowerCase())) {
|
||||
player.sendMessage(m._("user_unknown"));
|
||||
return;
|
||||
}
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if(pAuth == null) {
|
||||
player.sendMessage(m._("user_unknown"));
|
||||
return;
|
||||
}
|
||||
if(!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
|
||||
player.sendMessage(m._("vb_nonActiv"));
|
||||
return;
|
||||
}
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
try {
|
||||
if(!passpartu) {
|
||||
if (Settings.useCaptcha) {
|
||||
if(!plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.put(name, 1);
|
||||
} else {
|
||||
int i = plugin.captcha.get(name) + 1;
|
||||
plugin.captcha.remove(name);
|
||||
plugin.captcha.put(name, i);
|
||||
}
|
||||
if(plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
player.sendMessage(m._("need_captcha"));
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
player.sendMessage("Type : /captcha " + plugin.cap.get(name));
|
||||
return;
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
try {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.cap.remove(name);
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PasswordSecurity.comparePasswordWithHash(password, hash, name)) {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, ip, new Date().getTime(), email);
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
final LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
PlayerAuth getAuth = database.getAuth(name);
|
||||
if (limbo != null) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setOp(limbo.getOperator());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
player.setOp(limbo.getOperator());
|
||||
|
||||
this.utils.addNormal(player, limbo.getGroup());
|
||||
|
||||
|
||||
if ((Settings.isTeleportToSpawnEnabled) && (!Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||
{
|
||||
if ((Settings.isSaveQuitLocationEnabled) && (this.database.getAuth(name).getQuitLocY() != 0))
|
||||
{
|
||||
this.utils.packCoords(this.database.getAuth(name).getQuitLocX(), this.database.getAuth(name).getQuitLocY(), this.database.getAuth(name).getQuitLocZ(), player);
|
||||
}
|
||||
else {
|
||||
utils.addNormal(player, limbo.getGroup());
|
||||
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
else if ((Settings.isSaveQuitLocationEnabled) && (this.database.getAuth(name).getQuitLocY() != 0))
|
||||
{
|
||||
this.utils.packCoords(this.database.getAuth(name).getQuitLocX(), this.database.getAuth(name).getQuitLocY(), this.database.getAuth(name).getQuitLocZ(), player);
|
||||
}
|
||||
else {
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, limbo.getInventory(), limbo.getArmour());
|
||||
}
|
||||
}
|
||||
if ((Settings.isTeleportToSpawnEnabled) && (!Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||
{
|
||||
if ((Settings.isSaveQuitLocationEnabled) && (getAuth.getQuitLocY() != 0))
|
||||
{
|
||||
utils.packCoords(getAuth.getQuitLocX(), getAuth.getQuitLocY(), getAuth.getQuitLocZ(), player);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
player.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (this.playerCache.doesCacheExist(name)) {
|
||||
this.playerCache.removeCache(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Little Work Around under Registration Group Switching for admins that
|
||||
* add Registration thru a web Scripts.
|
||||
*/
|
||||
if ( Settings.isPermissionCheckEnabled && AuthMe.permission.playerInGroup(player, Settings.unRegisteredGroup) && !Settings.unRegisteredGroup.isEmpty() ) {
|
||||
AuthMe.permission.playerRemoveGroup(player.getWorld(), player.getName(), Settings.unRegisteredGroup);
|
||||
AuthMe.permission.playerAddGroup(player.getWorld(), player.getName(), Settings.getRegisteredGroup);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!PlayersLogs.players.contains(player.getName()))
|
||||
PlayersLogs.players.add(player.getName());
|
||||
pllog.save();
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
if (Settings.useCaptcha) {
|
||||
if(plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
if(plugin.cap.containsKey(name)) {
|
||||
plugin.cap.containsKey(name);
|
||||
}
|
||||
}
|
||||
player.sendMessage(m._("login"));
|
||||
displayOtherAccounts(auth);
|
||||
if(!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
player.saveData();
|
||||
|
||||
} else {
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " used the wrong password");
|
||||
if (Settings.isKickOnWrongPasswordEnabled) {
|
||||
try {
|
||||
int gm = AuthMePlayerListener.gameMode.get(name);
|
||||
player.setGameMode(GameMode.getByValue(gm));
|
||||
} catch (NullPointerException npe) {}
|
||||
player.kickPlayer(m._("wrong_pwd"));
|
||||
} else {
|
||||
return (m._("wrong_pwd"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// need for bypass password check if passpartu command is enabled
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, ip, new Date().getTime(), email);
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if ((Settings.isSaveQuitLocationEnabled) && (getAuth.getQuitLocY() != 0))
|
||||
{
|
||||
utils.packCoords(getAuth.getQuitLocX(), getAuth.getQuitLocY(), getAuth.getQuitLocZ(), player);
|
||||
}
|
||||
else {
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.setOp(limbo.getOperator());
|
||||
|
||||
this.utils.addNormal(player, limbo.getGroup());
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
}
|
||||
});
|
||||
|
||||
if ((Settings.isTeleportToSpawnEnabled) && (!Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||
{
|
||||
if ((Settings.isSaveQuitLocationEnabled) && (this.database.getAuth(name).getQuitLocY() != 0)) {
|
||||
Location quitLoc = new Location(player.getWorld(), this.database.getAuth(name).getQuitLocX() + 0.5D, this.database.getAuth(name).getQuitLocY() + 0.5D, this.database.getAuth(name).getQuitLocZ() + 0.5D);
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, quitLoc);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, limbo.getInventory(), limbo.getArmour());
|
||||
}
|
||||
}
|
||||
|
||||
player.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Little Work Around under Registration Group Switching for admins that
|
||||
* add Registration thru a web Scripts.
|
||||
*/
|
||||
if ( Settings.isPermissionCheckEnabled && AuthMe.permission.playerInGroup(player, Settings.unRegisteredGroup) && !Settings.unRegisteredGroup.isEmpty() ) {
|
||||
AuthMe.permission.playerRemoveGroup(player.getWorld(), player.getName(), Settings.unRegisteredGroup);
|
||||
AuthMe.permission.playerAddGroup(player.getWorld(), player.getName(), Settings.getRegisteredGroup);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!PlayersLogs.players.contains(player.getName()))
|
||||
PlayersLogs.players.add(player.getName());
|
||||
pllog.save();
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
if (Settings.useCaptcha) {
|
||||
if(plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
if(plugin.cap.containsKey(name)) {
|
||||
plugin.cap.containsKey(name);
|
||||
}
|
||||
}
|
||||
player.sendMessage(m._("login"));
|
||||
displayOtherAccounts(auth);
|
||||
if(!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.saveData();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
if (!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " used the wrong password");
|
||||
if (Settings.isKickOnWrongPasswordEnabled) {
|
||||
try {
|
||||
final int gm = AuthMePlayerListener.gameMode.get(name);
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setGameMode(GameMode.getByValue(gm));
|
||||
}
|
||||
});
|
||||
} catch (NullPointerException npe) {}
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.kickPlayer(m._("wrong_pwd"));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
player.sendMessage(m._("wrong_pwd"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// need for bypass password check if passpartu command is enabled
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, ip, new Date().getTime(), email);
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
final LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
player.setOp(limbo.getOperator());
|
||||
}
|
||||
});
|
||||
|
||||
utils.addNormal(player, limbo.getGroup());
|
||||
|
||||
if ((Settings.isTeleportToSpawnEnabled) && (!Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||
{
|
||||
if ((Settings.isSaveQuitLocationEnabled) && (database.getAuth(name).getQuitLocY() != 0)) {
|
||||
Location quitLoc = new Location(player.getWorld(), database.getAuth(name).getQuitLocX() + 0.5D, database.getAuth(name).getQuitLocY() + 0.5D, database.getAuth(name).getQuitLocZ() + 0.5D);
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, quitLoc);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if ((Settings.isSaveQuitLocationEnabled) && (database.getAuth(name).getQuitLocY() != 0)) {
|
||||
Location quitLoc = new Location(player.getWorld(), database.getAuth(name).getQuitLocX() + 0.5D, database.getAuth(name).getQuitLocY() + 0.5D, database.getAuth(name).getQuitLocZ() + 0.5D);
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, quitLoc);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
final Location fLoc = tpEvent.getTo();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(fLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
}
|
||||
});
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, limbo.getInventory(), limbo.getArmour());
|
||||
}
|
||||
}
|
||||
|
||||
player.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Little Work Around under Registration Group Switching for admins that
|
||||
* add Registration thru a web Scripts.
|
||||
*/
|
||||
if ( Settings.isPermissionCheckEnabled && AuthMe.permission.playerInGroup(player, Settings.unRegisteredGroup) && !Settings.unRegisteredGroup.isEmpty() ) {
|
||||
AuthMe.permission.playerRemoveGroup(player.getWorld(), player.getName(), Settings.unRegisteredGroup);
|
||||
AuthMe.permission.playerAddGroup(player.getWorld(), player.getName(), Settings.getRegisteredGroup);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!PlayersLogs.players.contains(player.getName()))
|
||||
PlayersLogs.players.add(player.getName());
|
||||
pllog.save();
|
||||
} catch (NullPointerException ex) { }
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
if (Settings.useCaptcha) {
|
||||
if(plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
if(plugin.cap.containsKey(name)) {
|
||||
plugin.cap.containsKey(name);
|
||||
}
|
||||
}
|
||||
player.sendMessage(m._("login"));
|
||||
displayOtherAccounts(auth);
|
||||
if(!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.saveData();
|
||||
}
|
||||
});
|
||||
passpartu = false;
|
||||
}
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
player.sendMessage(m._("error"));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, true);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
else if ((Settings.isSaveQuitLocationEnabled) && (this.database.getAuth(name).getQuitLocY() != 0)) {
|
||||
Location quitLoc = new Location(player.getWorld(), this.database.getAuth(name).getQuitLocX() + 0.5D, this.database.getAuth(name).getQuitLocY() + 0.5D, this.database.getAuth(name).getQuitLocZ() + 0.5D);
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, quitLoc);
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
|
||||
pm.callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
}
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, limbo.getInventory(), limbo.getArmour());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
player.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
player.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
if (this.playerCache.doesCacheExist(name)) {
|
||||
this.playerCache.removeCache(name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Little Work Around under Registration Group Switching for admins that
|
||||
* add Registration thru a web Scripts.
|
||||
*/
|
||||
if ( Settings.isPermissionCheckEnabled && AuthMe.permission.playerInGroup(player, Settings.unRegisteredGroup) && !Settings.unRegisteredGroup.isEmpty() ) {
|
||||
AuthMe.permission.playerRemoveGroup(player.getWorld(), player.getName(), Settings.unRegisteredGroup);
|
||||
AuthMe.permission.playerAddGroup(player.getWorld(), player.getName(), Settings.getRegisteredGroup);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!PlayersLogs.players.contains(player.getName()))
|
||||
PlayersLogs.players.add(player.getName());
|
||||
pllog.save();
|
||||
} catch (NullPointerException ex) { }
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
if (Settings.useCaptcha) {
|
||||
if(plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.remove(name);
|
||||
}
|
||||
if(plugin.cap.containsKey(name)) {
|
||||
plugin.cap.containsKey(name);
|
||||
}
|
||||
}
|
||||
player.sendMessage(m._("login"));
|
||||
displayOtherAccounts(auth);
|
||||
if(!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info(player.getName() + " logged in!");
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
|
||||
}
|
||||
player.saveData();
|
||||
this.passpartu = false;
|
||||
}
|
||||
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return (m._("error"));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
private void displayOtherAccounts(PlayerAuth auth) {
|
||||
if (!Settings.displayOtherAccounts) {
|
||||
return;
|
||||
@ -417,7 +499,7 @@ public class Management {
|
||||
} else {
|
||||
message = message + ".";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
for (Player player : AuthMe.getInstance().getServer().getOnlinePlayers()) {
|
||||
if (player.hasPermission("authme.seeOtherAccounts")) {
|
||||
@ -426,6 +508,5 @@ public class Management {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package uk.org.whoami.authme;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -20,7 +19,7 @@ import uk.org.whoami.authme.settings.Settings;
|
||||
* @author stefano
|
||||
*/
|
||||
public class PerformBackup {
|
||||
|
||||
|
||||
private String dbName = Settings.getMySQLDatabase;
|
||||
private String dbUserName = Settings.getMySQLUsername;
|
||||
private String dbPassword = Settings.getMySQLPassword;
|
||||
@ -29,14 +28,13 @@ public class PerformBackup {
|
||||
String dateString = format.format( new Date() );
|
||||
private String path = AuthMe.getInstance().getDataFolder()+"/backups/backup"+dateString;
|
||||
private AuthMe instance;
|
||||
|
||||
|
||||
public PerformBackup(AuthMe instance) {
|
||||
this.setInstance(instance);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean DoBackup() {
|
||||
|
||||
|
||||
switch(Settings.getDataSource) {
|
||||
case FILE: return FileBackup("auths.db");
|
||||
|
||||
@ -45,24 +43,21 @@ public class PerformBackup {
|
||||
case SQLITE: return FileBackup(Settings.getMySQLDatabase+".db");
|
||||
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean MySqlBackup() {
|
||||
File dirBackup = new File(AuthMe.getInstance().getDataFolder()+"/backups");
|
||||
|
||||
|
||||
if(!dirBackup.exists())
|
||||
dirBackup.mkdir();
|
||||
if(checkWindows(Settings.backupWindowsPath)) {
|
||||
String executeCmd = Settings.backupWindowsPath+"\\bin\\mysqldump.exe -u " + dbUserName + " -p" + dbPassword + " " + dbName + " --tables " + tblname + " -r " + path+".sql";
|
||||
//ConsoleLogger.info(executeCmd);
|
||||
Process runtimeProcess;
|
||||
try {
|
||||
//System.out.println("path "+path+" cmd "+executeCmd);
|
||||
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
|
||||
int processComplete = runtimeProcess.waitFor();
|
||||
|
||||
if (processComplete == 0) {
|
||||
ConsoleLogger.info("Backup created successfully");
|
||||
return true;
|
||||
@ -76,10 +71,8 @@ public class PerformBackup {
|
||||
String executeCmd = "mysqldump -u " + dbUserName + " -p" + dbPassword + " " + dbName + " --tables " + tblname + " -r " + path+".sql";
|
||||
Process runtimeProcess;
|
||||
try {
|
||||
//System.out.println("path "+path+" cmd "+executeCmd);
|
||||
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
|
||||
int processComplete = runtimeProcess.waitFor();
|
||||
|
||||
if (processComplete == 0) {
|
||||
ConsoleLogger.info("Backup created successfully");
|
||||
return true;
|
||||
@ -92,35 +85,30 @@ public class PerformBackup {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean FileBackup(String backend) {
|
||||
File dirBackup = new File(AuthMe.getInstance().getDataFolder()+"/backups");
|
||||
|
||||
|
||||
if(!dirBackup.exists())
|
||||
dirBackup.mkdir();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
copy(new File("plugins/AuthMe/"+backend),new File(path+".db"));
|
||||
return true;
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if we are under Windows and correct location
|
||||
* of mysqldump.exe otherwise return error.
|
||||
*/
|
||||
private boolean checkWindows(String windowsPath) {
|
||||
String isWin = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
if(isWin.indexOf("win") >= 0) {
|
||||
//ConsoleLogger.info(windowsPath+"\\bin\\mysqldump.exe");
|
||||
if(new File(windowsPath+"\\bin\\mysqldump.exe").exists()) {
|
||||
return true;
|
||||
} else {
|
||||
@ -128,8 +116,6 @@ public class PerformBackup {
|
||||
return true;
|
||||
}
|
||||
} else return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -156,5 +142,5 @@ public void setInstance(AuthMe instance) {
|
||||
public AuthMe getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,24 +14,28 @@ import org.bukkit.Bukkit;
|
||||
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class SendMailSSL {
|
||||
|
||||
|
||||
public AuthMe instance;
|
||||
|
||||
|
||||
public SendMailSSL(AuthMe instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
public void main(final PlayerAuth auth, final String newPass) {
|
||||
|
||||
|
||||
String sendername;
|
||||
|
||||
|
||||
if (Settings.getmailSenderName.isEmpty() || Settings.getmailSenderName == null) {
|
||||
sendername = Settings.getmailAccount;
|
||||
} else {
|
||||
sendername = Settings.getmailSenderName;
|
||||
}
|
||||
|
||||
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", Settings.getmailSMTP);
|
||||
props.put("mail.smtp.socketFactory.port", String.valueOf(Settings.getMailPort));
|
||||
@ -39,7 +43,7 @@ public class SendMailSSL {
|
||||
"javax.net.ssl.SSLSocketFactory");
|
||||
props.put("mail.smtp.auth", "true");
|
||||
props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
|
||||
|
||||
|
||||
Session session = Session.getInstance(props,
|
||||
new javax.mail.Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
@ -48,7 +52,7 @@ public class SendMailSSL {
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
|
||||
final Message message = new MimeMessage(session);
|
||||
try {
|
||||
message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
|
||||
@ -63,9 +67,7 @@ public class SendMailSSL {
|
||||
text = text.replaceAll("<servername>", instance.getServer().getServerName());
|
||||
text = text.replaceAll("<generatedpass>", newPass);
|
||||
message.setText(text);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(instance, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@ -73,16 +75,13 @@ public class SendMailSSL {
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(!Settings.noConsoleSpam)
|
||||
ConsoleLogger.info("Email sent to : " + auth.getNickname());
|
||||
|
||||
} catch (MessagingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,23 +24,17 @@ import uk.org.whoami.authme.settings.Settings;
|
||||
* @author stefano
|
||||
*/
|
||||
public class Utils {
|
||||
//private Settings settings = Settings.getInstance();
|
||||
private String currentGroup;
|
||||
private static Utils singleton;
|
||||
private String unLoggedGroup = Settings.getUnloggedinGroup;
|
||||
BukkitTask id;
|
||||
/*
|
||||
public Utils(Player player) {
|
||||
this.player = player;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public void setGroup(Player player, groupType group) {
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
if(!Settings.isPermissionCheckEnabled)
|
||||
return;
|
||||
|
||||
|
||||
switch(group) {
|
||||
case UNREGISTERED: {
|
||||
currentGroup = AuthMe.permission.getPrimaryGroup(player);
|
||||
@ -57,95 +51,74 @@ public class Utils {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public String removeAll(Player player) {
|
||||
|
||||
if(!Utils.getInstance().useGroupSystem()){
|
||||
return null;
|
||||
}
|
||||
|
||||
if( !Settings.getJoinPermissions.isEmpty() ) {
|
||||
hasPermOnJoin(player);
|
||||
}
|
||||
|
||||
this.currentGroup = AuthMe.permission.getPrimaryGroup(player.getWorld(),player.getName().toString());
|
||||
//System.out.println("current grop" + currentGroup);
|
||||
if(AuthMe.permission.playerRemoveGroup(player.getWorld(),player.getName().toString(), currentGroup) && AuthMe.permission.playerAddGroup(player.getWorld(),player.getName().toString(),this.unLoggedGroup)) {
|
||||
|
||||
return currentGroup;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean addNormal(Player player, String group) {
|
||||
if(!Utils.getInstance().useGroupSystem()){
|
||||
return false;
|
||||
}
|
||||
// System.out.println("in add normal");
|
||||
/* if (AuthMe.permission.playerRemove(this.player, "-*"))
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
if(AuthMe.permission.playerRemoveGroup(player.getWorld(),player.getName().toString(),this.unLoggedGroup) && AuthMe.permission.playerAddGroup(player.getWorld(),player.getName().toString(),group)) {
|
||||
//System.out.println("vecchio "+this.unLoggedGroup+ "nuovo" + group);
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String hasPermOnJoin(Player player) {
|
||||
/* if(Settings.getJoinPermissions.isEmpty())
|
||||
return null; */
|
||||
Iterator<String> iter = Settings.getJoinPermissions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String permission = iter.next();
|
||||
// System.out.println("permissions? "+ permission);
|
||||
|
||||
if(AuthMe.permission.playerHas(player, permission)){
|
||||
// System.out.println("player has permissions " +permission);
|
||||
AuthMe.permission.playerAddTransient(player, permission);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Iterator<String> iter = Settings.getJoinPermissions.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String permission = iter.next();
|
||||
if(AuthMe.permission.playerHas(player, permission)){
|
||||
AuthMe.permission.playerAddTransient(player, permission);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isUnrestricted(Player player) {
|
||||
|
||||
|
||||
|
||||
if(Settings.getUnrestrictedName.isEmpty() || Settings.getUnrestrictedName == null)
|
||||
return false;
|
||||
|
||||
// System.out.println("name to escape "+player.getName());
|
||||
if(Settings.getUnrestrictedName.contains(player.getName())) {
|
||||
// System.out.println("name to escape correctly"+player.getName());
|
||||
|
||||
if(Settings.getUnrestrictedName.contains(player.getName()))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
public static Utils getInstance() {
|
||||
|
||||
singleton = new Utils();
|
||||
|
||||
return singleton;
|
||||
|
||||
singleton = new Utils();
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
private boolean useGroupSystem() {
|
||||
|
||||
|
||||
if(Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty()) {
|
||||
return true;
|
||||
} return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void packCoords(int x, int y, int z, final Player pl)
|
||||
{
|
||||
final World world = pl.getWorld();
|
||||
final int fY = y;
|
||||
final Location loc = new Location(world, x + 0.5D, y + 0.6D, z + 0.5D);
|
||||
final Location loc = new Location(world, x, y + 0.6D, z);
|
||||
|
||||
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(pl, loc);
|
||||
AuthMe.getInstance().getServer().getPluginManager().callEvent(tpEvent);
|
||||
@ -154,31 +127,25 @@ public class Utils {
|
||||
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
|
||||
pl.teleport(tpEvent.getTo());
|
||||
}
|
||||
|
||||
|
||||
id = Bukkit.getScheduler().runTaskTimer(AuthMe.authme, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
int current = (int)pl.getLocation().getY();
|
||||
World currentWorld = pl.getWorld();
|
||||
|
||||
if (current != fY && world.getName() == currentWorld.getName()) {
|
||||
pl.teleport(loc);
|
||||
}
|
||||
}
|
||||
|
||||
}, 1L, 20L);
|
||||
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(AuthMe.authme, new Runnable()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
id.cancel();
|
||||
|
||||
}
|
||||
|
||||
}, 60L);
|
||||
}
|
||||
|
||||
@ -205,34 +172,27 @@ public class Utils {
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read Toekn
|
||||
*/
|
||||
public boolean readToken(String inputToken) {
|
||||
File file = new File("plugins/AuthMe/passpartu.token");
|
||||
|
||||
|
||||
if (!file.exists())
|
||||
return false;
|
||||
|
||||
|
||||
if (inputToken.isEmpty() )
|
||||
return false;
|
||||
|
||||
Scanner reader = null;
|
||||
try {
|
||||
reader = new Scanner(file);
|
||||
|
||||
while (reader.hasNextLine()) {
|
||||
final String line = reader.nextLine();
|
||||
|
||||
if (line.contains(":")) {
|
||||
String[] tokenInfo = line.split(":");
|
||||
//System.err.println("Authme input token "+inputToken+" saved token "+tokenInfo[0]);
|
||||
//System.err.println("Authme time "+System.currentTimeMillis()/1000+"saved time "+Integer.parseInt(tokenInfo[1]));
|
||||
if(tokenInfo[0].equals(inputToken) && System.currentTimeMillis()/1000-30 <= Integer.parseInt(tokenInfo[1]) ) {
|
||||
file.delete();
|
||||
reader.close();
|
||||
@ -243,7 +203,6 @@ public class Utils {
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
@ -251,19 +210,18 @@ public class Utils {
|
||||
* Generate Random Token
|
||||
*/
|
||||
private String generateToken() {
|
||||
// obtain new random token
|
||||
// obtain new random token
|
||||
Random rnd = new Random ();
|
||||
char[] arr = new char[5];
|
||||
|
||||
for (int i=0; i<5; i++) {
|
||||
int n = rnd.nextInt (36);
|
||||
arr[i] = (char) (n < 10 ? '0'+n : 'a'+n-10);
|
||||
}
|
||||
|
||||
return new String(arr);
|
||||
}
|
||||
|
||||
public enum groupType {
|
||||
UNREGISTERED, REGISTERED, NOTLOGGEDIN, LOGGEDIN
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ import uk.org.whoami.authme.security.PasswordSecurity.HashAlgorithm;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class API {
|
||||
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
|
||||
|
||||
public API(AuthMe instance, DataSource database) {
|
||||
this.instance = instance;
|
||||
this.database = database;
|
||||
@ -42,7 +42,7 @@ public class API {
|
||||
public AuthMe getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -51,7 +51,7 @@ public class API {
|
||||
public static boolean isAuthenticated(Player player) {
|
||||
return PlayerCache.getInstance().isAuthenticated(player.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -60,7 +60,7 @@ public class API {
|
||||
public boolean isaNPC(Player player) {
|
||||
return instance.getCitizensCommunicator().isNPC(player, instance);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -69,43 +69,43 @@ public class API {
|
||||
public static boolean isUnrestricted(Player player) {
|
||||
return Utils.getInstance().isUnrestricted(player);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isChatAllowed() {
|
||||
return Settings.isChatAllowed;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isAllowRestrictedIp() {
|
||||
return Settings.isAllowRestrictedIp;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isBackupActivated() {
|
||||
return Settings.isBackupActivated;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isForceSpawnLocOnJoinEnabled() {
|
||||
return Settings.isForceSpawnLocOnJoinEnabled;
|
||||
}
|
||||
|
||||
|
||||
public static DataSourceType getDataSource() {
|
||||
return Settings.getDataSource;
|
||||
}
|
||||
|
||||
|
||||
public static int getMovementRadius() {
|
||||
return Settings.getMovementRadius;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getJoinPermissions() {
|
||||
return Settings.getJoinPermissions;
|
||||
}
|
||||
|
||||
|
||||
public static Boolean isPasspartuEnable() {
|
||||
return Settings.enablePasspartu;
|
||||
}
|
||||
|
||||
|
||||
public static String getcUnrestrictedName() {
|
||||
return Settings.getcUnrestrictedName;
|
||||
}
|
||||
|
||||
|
||||
public static Boolean getEnablePasswordVerifier() {
|
||||
return Settings.getEnablePasswordVerifier;
|
||||
}
|
||||
@ -113,11 +113,11 @@ public class API {
|
||||
public static int getMaxNickLength() {
|
||||
return Settings.getMaxNickLength;
|
||||
}
|
||||
|
||||
|
||||
public static int getMinNickLength() {
|
||||
return Settings.getMinNickLength;
|
||||
}
|
||||
|
||||
|
||||
public static Array getLastLocationColumns() {
|
||||
Array columns = null;
|
||||
Array.set(columns, 0, Settings.getMySQLlastlocX);
|
||||
@ -125,7 +125,7 @@ public class API {
|
||||
Array.set(columns, 2, Settings.getMySQLlastlocZ);
|
||||
return columns;
|
||||
}
|
||||
|
||||
|
||||
public static Location getLastLocation(Player player) {
|
||||
try {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName());
|
||||
@ -140,52 +140,47 @@ public class API {
|
||||
} catch (NullPointerException ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String getNickRegex() {
|
||||
return Settings.getNickRegex;
|
||||
}
|
||||
|
||||
|
||||
public static int getPasswordMinLen() {
|
||||
return Settings.getPasswordMinLen;
|
||||
}
|
||||
|
||||
|
||||
public static HashAlgorithm getPasswordHash() {
|
||||
return Settings.getPasswordHash;
|
||||
}
|
||||
|
||||
|
||||
public static int getRegistrationTimeout() {
|
||||
return Settings.getRegistrationTimeout;
|
||||
}
|
||||
|
||||
|
||||
public static int getSessionTimeout() {
|
||||
return Settings.getSessionTimeout;
|
||||
}
|
||||
|
||||
|
||||
public static String getUnloggedinGroup() {
|
||||
return Settings.getUnloggedinGroup;
|
||||
}
|
||||
|
||||
|
||||
public static void setPlayerInventory(Player player, ItemStack[] content, ItemStack[] armor) {
|
||||
try {
|
||||
player.getInventory().setContents(content);
|
||||
player.getInventory().setArmorContents(armor);
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void saveAuth(final PlayerAuth auth) {
|
||||
instance.getServer().getScheduler().runTask(instance, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package uk.org.whoami.authme.cache.auth;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
|
||||
public class PlayerAuth {
|
||||
|
||||
private String nickname;
|
||||
@ -33,14 +32,14 @@ public class PlayerAuth {
|
||||
private String vBhash = null;
|
||||
private int groupId;
|
||||
private String email = "your@email.com";
|
||||
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -48,14 +47,14 @@ public class PlayerAuth {
|
||||
this.lastLogin = lastLogin;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public PlayerAuth(String nickname, int x, int y, int z) {
|
||||
this.nickname = nickname;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, int x, int y, int z, String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -66,10 +65,7 @@ public class PlayerAuth {
|
||||
this.z = z;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
//
|
||||
// This constructor is needed for Vbulletin board Auth!
|
||||
//
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, int x, int y, int z, String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -82,8 +78,7 @@ public class PlayerAuth {
|
||||
this.groupId = groupId;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// IPB Constructor with groups
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -92,8 +87,7 @@ public class PlayerAuth {
|
||||
this.salt = salt;
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
// IPB Constructor without groups
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -101,7 +95,7 @@ public class PlayerAuth {
|
||||
this.lastLogin = lastLogin;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, int x, int y, int z, String email) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -114,7 +108,6 @@ public class PlayerAuth {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, int x, int y, int z) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
@ -126,7 +119,6 @@ public class PlayerAuth {
|
||||
this.email = "your@email.com";
|
||||
}
|
||||
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
@ -138,26 +130,21 @@ public class PlayerAuth {
|
||||
public String getHash() {
|
||||
if(!salt.isEmpty() && Settings.getPasswordHash == PasswordSecurity.HashAlgorithm.MD5VB) {
|
||||
vBhash = "$MD5vb$"+salt+"$"+hash;
|
||||
// Compose Vbullettin Hash System!
|
||||
return vBhash;
|
||||
}
|
||||
else {
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
//Get Salt
|
||||
|
||||
public String getSalt() {
|
||||
return this.salt;
|
||||
}
|
||||
|
||||
//
|
||||
// GroupId for unactivated User on Vbullettin Board
|
||||
//
|
||||
|
||||
public int getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
|
||||
public int getQuitLocX() {
|
||||
return x;
|
||||
}
|
||||
@ -194,11 +181,11 @@ public class PlayerAuth {
|
||||
public void setLastLogin(long lastLogin) {
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public void setSalt(String salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
@ -209,7 +196,6 @@ public class PlayerAuth {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth other = (PlayerAuth) obj;
|
||||
|
||||
return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname);
|
||||
}
|
||||
|
||||
@ -220,4 +206,5 @@ public class PlayerAuth {
|
||||
hashCode = 71 * hashCode + (this.ip != null ? this.ip.hashCode() : 0);
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,4 +54,5 @@ public class PlayerCache {
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,24 +12,22 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DataFileCache {
|
||||
|
||||
|
||||
private ItemStack[] inventory;
|
||||
private ItemStack[] armor;
|
||||
private String group;
|
||||
private boolean operator;
|
||||
private String group;
|
||||
private boolean operator;
|
||||
|
||||
public DataFileCache(ItemStack[] inventory, ItemStack[] armor){
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
|
||||
}
|
||||
|
||||
public DataFileCache(ItemStack[] inventory, ItemStack[] armor, String group, boolean operator){
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
this.group = group;
|
||||
this.operator = operator;
|
||||
}
|
||||
this.group = group;
|
||||
this.operator = operator;
|
||||
}
|
||||
public ItemStack[] getInventory(){
|
||||
return inventory;
|
||||
}
|
||||
@ -37,13 +35,13 @@ public class DataFileCache {
|
||||
public ItemStack[] getArmour(){
|
||||
return armor;
|
||||
}
|
||||
|
||||
|
||||
public String getGroup(){
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getOperator(){
|
||||
return operator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,11 +15,8 @@ import java.util.Scanner;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class FileCache {
|
||||
//private HashMap<Enchantment, Integer> ench;
|
||||
|
||||
|
||||
|
||||
public FileCache() {
|
||||
final File folder = new File("cache");
|
||||
if (!folder.exists()) {
|
||||
@ -40,17 +37,13 @@ public class FileCache {
|
||||
file.createNewFile();
|
||||
|
||||
writer = new FileWriter(file);
|
||||
|
||||
// put player group in cache
|
||||
// put if player is an op or not 1: is op 0: isnet op!
|
||||
// line format Group|OperatorStatus
|
||||
|
||||
if(operator)
|
||||
writer.write(group+";1\r\n");
|
||||
else writer.write(group+";0\r\n");
|
||||
|
||||
writer.flush();
|
||||
|
||||
|
||||
// line format Group|OperatorStatus
|
||||
if(operator)
|
||||
writer.write(group+";1\r\n");
|
||||
else writer.write(group+";0\r\n");
|
||||
writer.flush();
|
||||
|
||||
ItemStack[] invstack = playerData.getInventory();
|
||||
|
||||
for (int i = 0; i < invstack.length; i++) {
|
||||
@ -58,24 +51,15 @@ public class FileCache {
|
||||
int itemid = 0;
|
||||
int amount = 0;
|
||||
int durability = 0;
|
||||
String enchList = "";
|
||||
//ench = new HashMap<Enchantment, Integer>();
|
||||
|
||||
String enchList = "";
|
||||
if (invstack[i] != null) {
|
||||
itemid = invstack[i].getTypeId();
|
||||
amount = invstack[i].getAmount();
|
||||
durability = invstack[i].getDurability();
|
||||
|
||||
|
||||
for(Enchantment e : invstack[i].getEnchantments().keySet())
|
||||
{
|
||||
//System.out.println("enchant "+e.getName()+" bog "+invstack[i].getEnchantmentLevel(e));
|
||||
enchList = enchList.concat(e.getName()+":"+invstack[i].getEnchantmentLevel(e)+":");
|
||||
//System.out.println(enchList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(Enchantment e : invstack[i].getEnchantments().keySet()) {
|
||||
enchList = enchList.concat(e.getName()+":"+invstack[i].getEnchantmentLevel(e)+":");
|
||||
}
|
||||
}
|
||||
writer.write("i" + ":" + itemid + ":" + amount + ":"
|
||||
+ durability + ":"+ enchList + "\r\n");
|
||||
writer.flush();
|
||||
@ -87,27 +71,19 @@ public class FileCache {
|
||||
int itemid = 0;
|
||||
int amount = 0;
|
||||
int durability = 0;
|
||||
String enchList = "";
|
||||
|
||||
String enchList = "";
|
||||
if (armorstack[i] != null) {
|
||||
itemid = armorstack[i].getTypeId();
|
||||
amount = armorstack[i].getAmount();
|
||||
durability = armorstack[i].getDurability();
|
||||
|
||||
for(Enchantment e : armorstack[i].getEnchantments().keySet())
|
||||
{
|
||||
//System.out.println("enchant "+e.getName()+" bog "+armorstack[i].getEnchantmentLevel(e));
|
||||
enchList = enchList.concat(e.getName()+":"+armorstack[i].getEnchantmentLevel(e)+":");
|
||||
//System.out.println(enchList);
|
||||
|
||||
}
|
||||
for(Enchantment e : armorstack[i].getEnchantments().keySet()) {
|
||||
enchList = enchList.concat(e.getName()+":"+armorstack[i].getEnchantmentLevel(e)+":");
|
||||
}
|
||||
}
|
||||
|
||||
writer.write("w" + ":" + itemid + ":" + amount + ":"
|
||||
+ durability + ":"+ enchList + "\r\n");
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
writer.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -120,9 +96,8 @@ public class FileCache {
|
||||
|
||||
ItemStack[] stacki = new ItemStack[36];
|
||||
ItemStack[] stacka = new ItemStack[4];
|
||||
String group = null;
|
||||
boolean op = false;
|
||||
|
||||
String group = null;
|
||||
boolean op = false;
|
||||
if (!file.exists()) {
|
||||
return new DataFileCache(stacki, stacka);
|
||||
}
|
||||
@ -149,41 +124,31 @@ public class FileCache {
|
||||
}
|
||||
|
||||
final String[] in = line.split(":");
|
||||
|
||||
/*if (in.length != 4) {
|
||||
continue;
|
||||
} */
|
||||
|
||||
if (!in[0].equals("i") && !in[0].equals("w")) {
|
||||
continue;
|
||||
}
|
||||
// can enchant item? size ofstring in file - 4 all / 2 = number of enchant
|
||||
if (in[0].equals("i")) {
|
||||
|
||||
stacki[i] = new ItemStack(Integer.parseInt(in[1]),
|
||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||
// qui c'e' un problema serio!
|
||||
if(in.length > 4 && !in[4].isEmpty()) {
|
||||
for(int k=4;k<in.length-1;k++) {
|
||||
//System.out.println("enchant "+in[k]);
|
||||
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||
if(in.length > 4 && !in[4].isEmpty()) {
|
||||
for(int k=4;k<in.length-1;k++) {
|
||||
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
stacka[a] = new ItemStack(Integer.parseInt(in[1]),
|
||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||
if(in.length > 4 && !in[4].isEmpty()) {
|
||||
for(int k=4;k<in.length-1;k++) {
|
||||
//System.out.println("enchant "+in[k]);
|
||||
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
if(in.length > 4 && !in[4].isEmpty()) {
|
||||
for(int k=4;k<in.length-1;k++) {
|
||||
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
a++;
|
||||
}
|
||||
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -214,5 +179,4 @@ public class FileCache {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class LimboCache {
|
||||
private HashMap<String, LimboPlayer> cache;
|
||||
private FileCache playerData = new FileCache();
|
||||
public AuthMe plugin;
|
||||
|
||||
|
||||
private LimboCache(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.cache = new HashMap<String, LimboPlayer>();
|
||||
@ -49,7 +49,7 @@ public class LimboCache {
|
||||
ItemStack[] inv;
|
||||
boolean operator;
|
||||
String playerGroup = "";
|
||||
|
||||
|
||||
if (playerData.doesCacheExist(name)) {
|
||||
StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
@ -72,7 +72,6 @@ public class LimboCache {
|
||||
inv = null;
|
||||
arm = null;
|
||||
}
|
||||
|
||||
if(player.isOp() ) {
|
||||
operator = true;
|
||||
} else {
|
||||
@ -80,8 +79,6 @@ public class LimboCache {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Settings.isForceSurvivalModeEnabled) {
|
||||
if(Settings.isResetInventoryIfCreative && gameMode != 0 ) {
|
||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
||||
@ -100,7 +97,6 @@ public class LimboCache {
|
||||
loc = plugin.mv.getMVWorldManager().getMVWorld(player.getWorld().getName()).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {}
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
if(cache.containsKey(name) && playerGroup.isEmpty()) {
|
||||
@ -109,15 +105,13 @@ public class LimboCache {
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup));
|
||||
}
|
||||
|
||||
|
||||
public void addLimboPlayer(Player player, String group) {
|
||||
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
|
||||
}
|
||||
|
||||
|
||||
public void deleteLimboPlayer(String name) {
|
||||
cache.remove(name);
|
||||
}
|
||||
@ -129,8 +123,7 @@ public class LimboCache {
|
||||
public boolean hasLimboPlayer(String name) {
|
||||
return cache.containsKey(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static LimboCache getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new LimboCache(AuthMe.getInstance());
|
||||
@ -144,4 +137,5 @@ public class LimboCache {
|
||||
}
|
||||
this.addLimboPlayer(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class LimboPlayer {
|
||||
this.operator = operator;
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
|
||||
public LimboPlayer(String name, Location loc, int gameMode, boolean operator, String group) {
|
||||
this.name = name;
|
||||
this.loc = loc;
|
||||
@ -48,13 +48,12 @@ public class LimboPlayer {
|
||||
this.operator = operator;
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
|
||||
public LimboPlayer(String name, String group) {
|
||||
this.name = name;
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -74,11 +73,11 @@ public class LimboPlayer {
|
||||
public int getGameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
|
||||
public boolean getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
@ -21,12 +21,14 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -52,14 +54,12 @@ import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.settings.SpoutCfg;
|
||||
|
||||
public class AdminCommand implements CommandExecutor {
|
||||
|
||||
public AuthMe plugin;
|
||||
|
||||
public AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
private SpoutCfg s = SpoutCfg.getInstance();
|
||||
//private Settings settings = Settings.getInstance();
|
||||
public DataSource database;
|
||||
|
||||
|
||||
public AdminCommand(AuthMe plugin, DataSource database) {
|
||||
this.database = database;
|
||||
this.plugin = plugin;
|
||||
@ -77,13 +77,12 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("/authme lastlogin <playername> - Display Date about the Player's LastLogin");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if((sender instanceof ConsoleCommandSender) && args[0].equalsIgnoreCase("passpartuToken")) {
|
||||
if(args.length > 1) {
|
||||
System.out.println("[AuthMe] command usage: authme passpartuToken");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Utils.getInstance().obtainToken()) {
|
||||
System.out.println("[AuthMe] You have 30s for insert this token ingame with /passpartu [token]");
|
||||
} else {
|
||||
@ -91,40 +90,32 @@ public class AdminCommand implements CommandExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!sender.hasPermission("authme.admin." + args[0].toLowerCase())) {
|
||||
sender.sendMessage(m._("no_perm"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (args[0].equalsIgnoreCase("version")) {
|
||||
sender.sendMessage("AuthMe Version: "+AuthMe.getInstance().getDescription().getVersion());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (args[0].equalsIgnoreCase("purge")) {
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage("Usage: /authme purge <DAYS>");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
long days = Long.parseLong(args[1]) * 86400000;
|
||||
long until = new Date().getTime() - days;
|
||||
|
||||
sender.sendMessage("Deleted " + database.purgeDatabase(until) + " user accounts");
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("Usage: /authme purge <DAYS>");
|
||||
return true;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
database.reload();
|
||||
|
||||
//Trying to load config from JAR-Ressources, if config.yml doesn't exist...
|
||||
File newConfigFile = new File("plugins/AuthMe","config.yml");
|
||||
if (!newConfigFile.exists()) {
|
||||
InputStream fis = getClass().getResourceAsStream("/config.yml");
|
||||
@ -186,7 +177,6 @@ public class AdminCommand implements CommandExecutor {
|
||||
final CommandSender fSender = sender;
|
||||
final String[] arguments = args;
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerAuth pAuth = null;
|
||||
@ -223,16 +213,13 @@ public class AdminCommand implements CommandExecutor {
|
||||
fSender.sendMessage("[AuthMe] This player is unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
final CommandSender fSender = sender;
|
||||
final String[] arguments = args;
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String message = "[AuthMe] ";
|
||||
@ -262,9 +249,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
fSender.sendMessage("[AuthMe] Please put a valid IP");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@ -273,16 +258,13 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("Usage: /authme register playername password");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
String name = args[1].toLowerCase();
|
||||
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name);
|
||||
|
||||
if (database.isAuthAvailable(name)) {
|
||||
sender.sendMessage(m._("user_regged"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0);
|
||||
if (!database.saveAuth(auth)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
@ -304,7 +286,6 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("xauthimport")) {
|
||||
xAuthToFlat converter = new xAuthToFlat(plugin, database);
|
||||
if (converter.convert(sender)) {
|
||||
@ -312,7 +293,6 @@ public class AdminCommand implements CommandExecutor {
|
||||
} else {
|
||||
sender.sendMessage("[AuthMe] Error while trying to convert from xAuth database");
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("getemail")) {
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage("Usage: /authme getemail playername");
|
||||
@ -322,7 +302,6 @@ public class AdminCommand implements CommandExecutor {
|
||||
PlayerAuth getAuth = PlayerCache.getInstance().getAuth(playername);
|
||||
sender.sendMessage("[AuthMe] " + args[1] + " email : " + getAuth.getEmail());
|
||||
return true;
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("chgemail")) {
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage("Usage: /authme chgemail playername email");
|
||||
@ -337,7 +316,6 @@ public class AdminCommand implements CommandExecutor {
|
||||
}
|
||||
PlayerCache.getInstance().updatePlayer(getAuth);
|
||||
return true;
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("convertfromrakamak")) {
|
||||
try {
|
||||
RakamakConverter.RakamakConvert();
|
||||
@ -348,7 +326,6 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("setspawn")) {
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
@ -361,7 +338,18 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("purgebannedplayers")) {
|
||||
List<String> bannedPlayers = new ArrayList<String>();
|
||||
for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) {
|
||||
bannedPlayers.add(off.getName().toLowerCase());
|
||||
}
|
||||
final List<String> bP = bannedPlayers;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
database.purgeBanned(bP);
|
||||
}
|
||||
});
|
||||
} else if (args[0].equalsIgnoreCase("spawn")) {
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
@ -374,17 +362,14 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
|
||||
} else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage("Usage: /authme changepassword playername newpassword");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
String name = args[1].toLowerCase();
|
||||
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name);
|
||||
|
||||
PlayerAuth auth = null;
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
auth = PlayerCache.getInstance().getAuth(name);
|
||||
@ -395,12 +380,10 @@ public class AdminCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
auth.setHash(hash);
|
||||
|
||||
if (!database.updatePassword(auth)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("pwd_changed");
|
||||
ConsoleLogger.info(args[1] + "'s password changed");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
@ -412,17 +395,13 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("Usage: /authme unregister playername");
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = args[1].toLowerCase();
|
||||
|
||||
if (!database.removeAuth(name)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
sender.sendMessage("unregistered");
|
||||
|
||||
ConsoleLogger.info(args[1] + " unregistered");
|
||||
} else {
|
||||
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
|
||||
|
@ -12,33 +12,31 @@ import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class CaptchaCommand implements CommandExecutor {
|
||||
|
||||
|
||||
public AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
public static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
|
||||
|
||||
public CaptchaCommand(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmnd,
|
||||
String label, String[] args) {
|
||||
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(m._("usage_captcha"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
player.sendMessage(m._("logged_in"));
|
||||
return true;
|
||||
@ -48,12 +46,12 @@ public class CaptchaCommand implements CommandExecutor {
|
||||
player.sendMessage(m._("no_perm"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!Settings.useCaptcha) {
|
||||
player.sendMessage(m._("usage_log"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(!plugin.cap.containsKey(name)) {
|
||||
player.sendMessage(m._("usage_log"));
|
||||
return true;
|
||||
@ -70,12 +68,9 @@ public class CaptchaCommand implements CommandExecutor {
|
||||
plugin.cap.remove(name);
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
|
||||
player.sendMessage("Your captcha is correct");
|
||||
player.sendMessage(m._("login_msg"));
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ import uk.org.whoami.authme.settings.Settings;
|
||||
public class ChangePasswordCommand implements CommandExecutor {
|
||||
|
||||
private Messages m = Messages.getInstance();
|
||||
//private Settings settings = Settings.getInstance();
|
||||
private DataSource database;
|
||||
public AuthMe plugin;
|
||||
|
||||
@ -63,7 +62,7 @@ public class ChangePasswordCommand implements CommandExecutor {
|
||||
player.sendMessage(m._("not_logged_in"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (args.length != 2) {
|
||||
player.sendMessage(m._("usage_changepassword"));
|
||||
return true;
|
||||
|
@ -34,25 +34,25 @@ import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author darkwarriors
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class EmailCommand implements CommandExecutor {
|
||||
|
||||
public AuthMe plugin;
|
||||
private DataSource data;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
|
||||
public EmailCommand(AuthMe plugin, DataSource data) {
|
||||
this.plugin = plugin;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmnd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!sender.hasPermission("authme." + label.toLowerCase())) {
|
||||
sender.sendMessage(m._("no_perm"));
|
||||
return true;
|
||||
@ -61,13 +61,13 @@ public class EmailCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage("usage: /email add <Email> <confirmEmail> ");
|
||||
player.sendMessage("usage: /email change <old> <new> ");
|
||||
player.sendMessage("usage: /email recovery <Email>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage("usage: /email add <Email> <confirmEmail> ");
|
||||
player.sendMessage("usage: /email change <old> <new> ");
|
||||
player.sendMessage("usage: /email recovery <Email>");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("add")) {
|
||||
if (args.length != 3) {
|
||||
player.sendMessage("[AuthMe] /email add <Email> <confirmEmail>");
|
||||
@ -148,7 +148,6 @@ public class EmailCommand implements CommandExecutor {
|
||||
player.sendMessage(m._("logged_in"));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
||||
String thePass = rand.nextString();
|
||||
@ -171,19 +170,14 @@ public class EmailCommand implements CommandExecutor {
|
||||
player.sendMessage("[AuthMe] Invalid Email");
|
||||
return true;
|
||||
}
|
||||
|
||||
final String finalhashnew = hashnew;
|
||||
final PlayerAuth finalauth = auth;
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalauth.setHash(finalhashnew);
|
||||
data.updatePassword(finalauth);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
plugin.mail.main(auth, thePass);
|
||||
player.sendMessage("[AuthMe] Recovery Email Send !");
|
||||
@ -198,7 +192,6 @@ public class EmailCommand implements CommandExecutor {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.settings.Messages;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class LoginCommand implements CommandExecutor {
|
||||
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
|
||||
public LoginCommand(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@ -39,13 +38,9 @@ public class LoginCommand implements CommandExecutor {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!Settings.useCaptcha) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
final Player player = (Player) sender;
|
||||
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(m._("usage_log"));
|
||||
return true;
|
||||
@ -56,10 +51,7 @@ public class LoginCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String result = plugin.management.performLogin(player, args[0]);
|
||||
if (result != "") player.sendMessage(result);
|
||||
|
||||
plugin.management.performLogin(player, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,11 @@ public class LogoutCommand implements CommandExecutor {
|
||||
|
||||
private Messages m = Messages.getInstance();
|
||||
private PlayersLogs pllog = PlayersLogs.getInstance();
|
||||
//private Settings settings = Settings.getInstance();
|
||||
private AuthMe plugin;
|
||||
private DataSource database;
|
||||
private Utils utils = Utils.getInstance();
|
||||
private FileCache playerBackup = new FileCache();
|
||||
|
||||
|
||||
public LogoutCommand(AuthMe plugin, DataSource database) {
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
@ -78,13 +77,12 @@ public class LogoutCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
//clear session
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
auth.setIp("198.18.0.1");
|
||||
database.updateSession(auth);
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
|
||||
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
if(Settings.protectInventoryBeforeLogInEnabled) {
|
||||
@ -117,22 +115,19 @@ public class LogoutCommand implements CommandExecutor {
|
||||
}
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT.getTaskId());
|
||||
|
||||
try {
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
pllog.save();
|
||||
}
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
}
|
||||
|
||||
player.sendMessage(m._("logout"));
|
||||
ConsoleLogger.info(player.getDisplayName() + " logged out");
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged out!"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class PasspartuCommand implements CommandExecutor {
|
||||
private Utils utils = new Utils();
|
||||
private DataSource database;
|
||||
public AuthMe plugin;
|
||||
|
||||
|
||||
public PasspartuCommand(DataSource database, AuthMe plugin) {
|
||||
this.database = database;
|
||||
this.plugin = plugin;
|
||||
@ -31,20 +31,18 @@ public class PasspartuCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmnd, String label, String[] args) {
|
||||
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(sender.getName().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if ((sender instanceof Player) && args.length == 1) {
|
||||
if(utils.readToken(args[0])) {
|
||||
//bypass login!
|
||||
Management bypass = new Management(database,true, plugin);
|
||||
String result = bypass.performLogin((Player)sender, "dontneed");
|
||||
if (result != "") sender.sendMessage(result);
|
||||
bypass.performLogin((Player)sender, "dontneed");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("Time is expired or Token is Wrong!");
|
||||
return true;
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 darkwarriors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package uk.org.whoami.authme.commands;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author darkwarriors
|
||||
*/
|
||||
public class RecoveryCommand {
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ import java.util.Date;
|
||||
|
||||
import me.muizers.Notifications.Notification;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -75,21 +76,24 @@ public class RegisterCommand implements CommandExecutor {
|
||||
sender.sendMessage(m._("no_perm"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
final Player player = (Player) sender;
|
||||
final String name = player.getName().toLowerCase();
|
||||
String ipA = player.getAddress().getAddress().getHostAddress();
|
||||
|
||||
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
ipA = BungeeCord.getInstance().getPlayer(player.getName()).getAddress().getAddress().getHostAddress();
|
||||
for (ProxiedPlayer pp : BungeeCord.getInstance().getPlayers()) {
|
||||
if (pp.getName().toLowerCase() == name) {
|
||||
ipA = pp.getAddress().getAddress().getHostAddress();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
ConsoleLogger.showError("Your BungeeCord version is outdated, you need a version with the latest API");
|
||||
}
|
||||
}
|
||||
|
||||
final String ip = ipA;
|
||||
|
||||
final String ip = ipA;
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
player.sendMessage(m._("logged_in"));
|
||||
return true;
|
||||
@ -107,18 +111,14 @@ public class RegisterCommand implements CommandExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// Check if player exeded the max number of registration
|
||||
//
|
||||
|
||||
|
||||
if(Settings.getmaxRegPerIp > 0 ){
|
||||
|
||||
if(!sender.hasPermission("authme.allow2accounts") && database.getAllAuthsByIp(ipA).size() >= Settings.getmaxRegPerIp) {
|
||||
player.sendMessage(m._("max_reg"));
|
||||
if(!sender.hasPermission("authme.allow2accounts") && database.getAllAuthsByIp(ipA).size() >= Settings.getmaxRegPerIp) {
|
||||
player.sendMessage(m._("max_reg"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
||||
if(!args[0].contains("@")) {
|
||||
player.sendMessage(m._("usage_reg"));
|
||||
@ -143,10 +143,8 @@ public class RegisterCommand implements CommandExecutor {
|
||||
}
|
||||
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
||||
final String thePass = rand.nextString();
|
||||
|
||||
if (!thePass.isEmpty()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (PasswordSecurity.userSalt.containsKey(name)) {
|
||||
@ -173,10 +171,8 @@ public class RegisterCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
if(!Settings.getRegisteredGroup.isEmpty()){
|
||||
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
|
||||
}
|
||||
@ -202,16 +198,12 @@ public class RegisterCommand implements CommandExecutor {
|
||||
try {
|
||||
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
} catch (ClassCastException cce) {
|
||||
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
|
||||
}
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
loca = Spawn.getInstance().getLocation();
|
||||
|
||||
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if(!tpEvent.isCancelled()) {
|
||||
@ -231,20 +223,16 @@ public class RegisterCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2) ) {
|
||||
player.sendMessage(m._("usage_reg"));
|
||||
return true;
|
||||
}
|
||||
//System.out.println("pass legth "+args[0].length());
|
||||
//System.out.println("pass length permit"+Settings.passwordMaxLength);
|
||||
|
||||
if(args[0].length() < Settings.getPasswordMinLen || args[0].length() > Settings.passwordMaxLength) {
|
||||
player.sendMessage(m._("pass_len"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
String hash;
|
||||
if(Settings.getEnablePasswordVerifier) {
|
||||
@ -256,7 +244,6 @@ public class RegisterCommand implements CommandExecutor {
|
||||
}
|
||||
} else
|
||||
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
|
||||
|
||||
if (Settings.getMySQLColumnSalt.isEmpty())
|
||||
{
|
||||
auth = new PlayerAuth(name, hash, ip, new Date().getTime());
|
||||
@ -268,7 +255,6 @@ public class RegisterCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
|
||||
@ -297,13 +283,11 @@ public class RegisterCommand implements CommandExecutor {
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
|
||||
sender.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
|
||||
sender.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!Settings.getRegisteredGroup.isEmpty()){
|
||||
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
|
||||
}
|
||||
@ -317,7 +301,6 @@ public class RegisterCommand implements CommandExecutor {
|
||||
if(plugin.notifications != null) {
|
||||
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
|
||||
}
|
||||
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
sender.sendMessage(m._("error"));
|
||||
|
@ -49,11 +49,10 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
|
||||
private Messages m = Messages.getInstance();
|
||||
private PlayersLogs pllog = PlayersLogs.getInstance();
|
||||
//private Settings settings = Settings.getInstance();
|
||||
public AuthMe plugin;
|
||||
private DataSource database;
|
||||
private FileCache playerCache = new FileCache();
|
||||
|
||||
|
||||
public UnregisterCommand(AuthMe plugin, DataSource database) {
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
@ -94,8 +93,6 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
player.saveData();
|
||||
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
|
||||
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = sender.getServer().getScheduler();
|
||||
@ -121,8 +118,7 @@ public class UnregisterCommand implements CommandExecutor {
|
||||
// check if Player cache File Exist and delete it, preventing duplication of items
|
||||
if(playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
|
||||
}
|
||||
if (PlayersLogs.players.contains(player.getName())) {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
pllog.save();
|
||||
|
@ -12,15 +12,18 @@ import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.ConsoleLogger;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class FlatToSql {
|
||||
|
||||
|
||||
public AuthMe instance;
|
||||
|
||||
|
||||
public FlatToSql (AuthMe instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
public FlatToSql getInstance() {
|
||||
return this;
|
||||
}
|
||||
@ -34,10 +37,9 @@ public class FlatToSql {
|
||||
private static String lastlocY;
|
||||
private static String lastlocZ;
|
||||
private static String columnEmail;
|
||||
|
||||
private static File source;
|
||||
private static File output;
|
||||
|
||||
|
||||
public static void FlatToSqlConverter() throws IOException {
|
||||
tableName = Settings.getMySQLTablename;
|
||||
columnName = Settings.getMySQLColumnName;
|
||||
@ -76,9 +78,9 @@ public class FlatToSql {
|
||||
sql.newLine();
|
||||
String[] args = line.split(":");
|
||||
if (args.length == 4)
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, " + "your@email.com" + ");";
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, " + "'your@email.com'" + ");";
|
||||
else if (args.length == 7)
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", " + "your@email.com" + ");";
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", " + "'your@email.com'" + ");";
|
||||
else
|
||||
newline = "";
|
||||
if (newline != "")
|
||||
@ -87,8 +89,7 @@ public class FlatToSql {
|
||||
}
|
||||
sql.close();
|
||||
br.close();
|
||||
System.out.println("[AuthMe] The FlatFile has been converted to authme.sql file");
|
||||
|
||||
ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} catch (IOException ex) {
|
||||
|
@ -17,15 +17,18 @@ import uk.org.whoami.authme.security.PasswordSecurity;
|
||||
import uk.org.whoami.authme.security.PasswordSecurity.HashAlgorithm;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class RakamakConverter {
|
||||
|
||||
|
||||
public AuthMe instance;
|
||||
|
||||
|
||||
public RakamakConverter (AuthMe instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
public RakamakConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
@ -34,12 +37,11 @@ public class RakamakConverter {
|
||||
private static Boolean useIP;
|
||||
private static String fileName;
|
||||
private static String ipFileName;
|
||||
|
||||
private static File source;
|
||||
private static File output;
|
||||
private static File ipfiles;
|
||||
private static boolean alreadyExist = false;
|
||||
|
||||
|
||||
public static void RakamakConvert() throws IOException {
|
||||
hash = Settings.rakamakHash;
|
||||
useIP = Settings.rakamakUseIp;
|
||||
@ -47,8 +49,6 @@ public class RakamakConverter {
|
||||
ipFileName = Settings.rakamakUsersIp;
|
||||
HashMap<String, String> playerIP = new HashMap<String, String>();
|
||||
HashMap<String, String> playerPSW = new HashMap<String, String>();
|
||||
|
||||
|
||||
try {
|
||||
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
|
||||
ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
|
||||
@ -86,8 +86,6 @@ public class RakamakConverter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
users.close();
|
||||
outputDB = new BufferedWriter(new FileWriter(output));
|
||||
for (Entry<String, String> m : playerPSW.entrySet()) {
|
||||
@ -96,7 +94,6 @@ public class RakamakConverter {
|
||||
String psw = playerPSW.get(player);
|
||||
String ip = playerIP.get(player);
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0";
|
||||
|
||||
} else {
|
||||
String player = m.getKey();
|
||||
String psw = playerPSW.get(player);
|
||||
@ -108,14 +105,8 @@ public class RakamakConverter {
|
||||
System.out.println("Write line");
|
||||
outputDB.newLine();
|
||||
}
|
||||
|
||||
|
||||
outputDB.close();
|
||||
|
||||
System.out.println("[AuthMe] Rakamak database has been converted to auths.db");
|
||||
|
||||
|
||||
|
||||
ConsoleLogger.info("Rakamak database has been converted to auths.db");
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} catch (IOException ex) {
|
||||
|
@ -18,16 +18,20 @@ import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class xAuthToFlat {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
|
||||
|
||||
public xAuthToFlat(AuthMe instance, DataSource database) {
|
||||
this.instance = instance;
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
|
||||
public boolean convert(CommandSender sender) {
|
||||
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
|
||||
sender.sendMessage("[AuthMe] xAuth plugin not found");
|
||||
@ -41,7 +45,6 @@ public class xAuthToFlat {
|
||||
sender.sendMessage("[AuthMe] Error while import xAuthPlayers");
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage("[AuthMe] Starting import...");
|
||||
for (int id : players) {
|
||||
String pl = getIdPlayer(id);
|
||||
@ -54,13 +57,12 @@ public class xAuthToFlat {
|
||||
sender.sendMessage("[AuthMe] Import done!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String getIdPlayer(int id) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
|
||||
@ -69,7 +71,6 @@ public class xAuthToFlat {
|
||||
rs = ps.executeQuery();
|
||||
if (!rs.next())
|
||||
return null;
|
||||
|
||||
realPass = rs.getString("playername").toLowerCase();
|
||||
} catch (SQLException e) {
|
||||
xAuthLog.severe("Failed to retrieve name for account: " + id, e);
|
||||
@ -107,7 +108,6 @@ public class xAuthToFlat {
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
|
||||
@ -116,7 +116,6 @@ public class xAuthToFlat {
|
||||
rs = ps.executeQuery();
|
||||
if (!rs.next())
|
||||
return null;
|
||||
|
||||
realPass = rs.getString("password");
|
||||
} catch (SQLException e) {
|
||||
xAuthLog.severe("Failed to retrieve password hash for account: " + accountId, e);
|
||||
|
@ -35,7 +35,7 @@ public class CacheDataSource implements DataSource {
|
||||
this.plugin = plugin;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
return cache.containsKey(user) ? true : source.isAuthAvailable(user);
|
||||
@ -79,30 +79,26 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
//System.out.println("[debug name chace non work]"+auth.getNickname()+"[debug loc]"+auth.getQuitLocX());
|
||||
if (source.updateQuitLoc(auth)) {
|
||||
//System.out.println("[debug name chace]"+auth.getNickname()+"[debug loc]"+auth.getQuitLocX());
|
||||
cache.get(auth.getNickname()).setQuitLocX(auth.getQuitLocX());
|
||||
cache.get(auth.getNickname()).setQuitLocY(auth.getQuitLocY());
|
||||
cache.get(auth.getNickname()).setQuitLocZ(auth.getQuitLocZ());
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
return source.getIps(ip);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
int cleared = source.purgeDatabase(until);
|
||||
|
||||
if (cleared > 0) {
|
||||
for (PlayerAuth auth : cache.values()) {
|
||||
if(auth.getLastLogin() < until) {
|
||||
@ -151,7 +147,7 @@ public class CacheDataSource implements DataSource {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
if(source.updateSalt(auth)) {
|
||||
@ -170,9 +166,19 @@ public class CacheDataSource implements DataSource {
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
return source.getAllAuthsByIp(ip);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
return source.getAllAuthsByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
source.purgeBanned(banned);
|
||||
for (PlayerAuth auth : cache.values()) {
|
||||
if (banned.contains(auth.getNickname())) {
|
||||
cache.remove(auth.getNickname());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,23 +40,25 @@ public interface DataSource {
|
||||
int purgeDatabase(long until);
|
||||
|
||||
boolean removeAuth(String user);
|
||||
|
||||
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
||||
|
||||
|
||||
int getIps(String ip);
|
||||
|
||||
|
||||
List<String> getAllAuthsByName(PlayerAuth auth);
|
||||
|
||||
|
||||
List<String> getAllAuthsByIp(String ip);
|
||||
|
||||
|
||||
List<String> getAllAuthsByEmail(String email);
|
||||
|
||||
|
||||
boolean updateEmail(PlayerAuth auth);
|
||||
|
||||
|
||||
boolean updateSalt(PlayerAuth auth);
|
||||
|
||||
|
||||
void close();
|
||||
|
||||
void reload();
|
||||
|
||||
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class FileDataSource implements DataSource {
|
||||
|
||||
|
||||
/* file layout:
|
||||
*
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:COORDS
|
||||
@ -48,7 +47,7 @@ public class FileDataSource implements DataSource {
|
||||
source = new File(Settings.AUTH_FILE);
|
||||
source.createNewFile();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
BufferedReader br = null;
|
||||
@ -83,17 +82,14 @@ public class FileDataSource implements DataSource {
|
||||
if (isAuthAvailable(auth.getNickname())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
if( auth.getQuitLocY() == 0 ) {
|
||||
bw = new BufferedWriter(new FileWriter(source, true));
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + "\n");
|
||||
//System.out.println("[Debug save1] "+auth.getQuitLocY());
|
||||
} else {
|
||||
bw = new BufferedWriter(new FileWriter(source, true));
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + "\n");
|
||||
//System.out.println("[Debug save2] "+auth.getQuitLocY());
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + "\n");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
@ -114,9 +110,7 @@ public class FileDataSource implements DataSource {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerAuth newAuth = null;
|
||||
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
@ -152,9 +146,7 @@ public class FileDataSource implements DataSource {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerAuth newAuth = null;
|
||||
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
@ -187,13 +179,10 @@ public class FileDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerAuth newAuth = null;
|
||||
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
@ -201,7 +190,6 @@ public class FileDataSource implements DataSource {
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
//System.out.println("[Debug update] "+auth.getQuitLocX());
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
|
||||
break;
|
||||
}
|
||||
@ -224,7 +212,7 @@ public class FileDataSource implements DataSource {
|
||||
saveAuth(newAuth);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
BufferedReader br = null;
|
||||
@ -234,7 +222,6 @@ public class FileDataSource implements DataSource {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
//System.out.println(ip+" match? "+args[2]);
|
||||
if (args.length > 3 && args[2].equals(ip)) {
|
||||
countIp++;
|
||||
}
|
||||
@ -255,14 +242,13 @@ public class FileDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
int cleared = 0;
|
||||
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
String line;
|
||||
@ -276,7 +262,6 @@ public class FileDataSource implements DataSource {
|
||||
}
|
||||
cleared++;
|
||||
}
|
||||
|
||||
bw = new BufferedWriter(new FileWriter(source));
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
@ -309,7 +294,6 @@ public class FileDataSource implements DataSource {
|
||||
if (!isAuthAvailable(user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
@ -322,7 +306,6 @@ public class FileDataSource implements DataSource {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
bw = new BufferedWriter(new FileWriter(source));
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
@ -400,7 +383,7 @@ public class FileDataSource implements DataSource {
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
return false;
|
||||
@ -415,7 +398,6 @@ public class FileDataSource implements DataSource {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
//System.out.println(ip+" match? "+args[2]);
|
||||
if (args.length > 3 && args[2].equals(auth.getIp())) {
|
||||
countIp.add(args[0]);
|
||||
}
|
||||
@ -471,4 +453,49 @@ public class FileDataSource implements DataSource {
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
try {
|
||||
if (banned.contains(args[0])) {
|
||||
lines.add(line);
|
||||
}
|
||||
} catch (NullPointerException npe) {}
|
||||
catch (ArrayIndexOutOfBoundsException aioobe) {}
|
||||
}
|
||||
bw = new BufferedWriter(new FileWriter(source));
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ public class MySQLDataSource implements DataSource {
|
||||
this.port = Settings.getMySQLPort;
|
||||
this.username = Settings.getMySQLUsername;
|
||||
this.password = Settings.getMySQLPassword;
|
||||
|
||||
this.database = Settings.getMySQLDatabase;
|
||||
this.tableName = Settings.getMySQLTablename;
|
||||
this.columnName = Settings.getMySQLColumnName;
|
||||
@ -73,7 +72,7 @@ public class MySQLDataSource implements DataSource {
|
||||
this.columnEmail = Settings.getMySQLColumnEmail;
|
||||
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
|
||||
|
||||
connect();
|
||||
setup();
|
||||
}
|
||||
@ -87,7 +86,6 @@ public class MySQLDataSource implements DataSource {
|
||||
dataSource.setPort(Integer.parseInt(port));
|
||||
dataSource.setUser(username);
|
||||
dataSource.setPassword(password);
|
||||
|
||||
conPool = new MiniConnectionPoolManager(dataSource, 10);
|
||||
ConsoleLogger.info("Connection pool ready");
|
||||
}
|
||||
@ -110,7 +108,6 @@ public class MySQLDataSource implements DataSource {
|
||||
+ lastlocZ + " smallint(6) DEFAULT '0',"
|
||||
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
|
||||
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
@ -343,7 +340,7 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -368,11 +365,7 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Check how many registration by given ip has been done
|
||||
//
|
||||
|
||||
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
Connection con = null;
|
||||
@ -401,7 +394,7 @@ public class MySQLDataSource implements DataSource {
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -424,7 +417,7 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
if (columnSalt.isEmpty()) {
|
||||
@ -450,7 +443,7 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
try {
|
||||
@ -551,7 +544,7 @@ public class MySQLDataSource implements DataSource {
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
Connection con = null;
|
||||
@ -581,5 +574,23 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
for (String name : banned) {
|
||||
con = conPool.getValidConnection();
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
|
||||
pst.setString(1, name);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} finally {
|
||||
close(pst);
|
||||
close(con);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package uk.org.whoami.authme.datasource;
|
||||
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -43,12 +42,10 @@ public class SqliteDataSource implements DataSource {
|
||||
private Connection con;
|
||||
|
||||
public SqliteDataSource() throws ClassNotFoundException, SQLException {
|
||||
//Settings s = Settings.getInstance();
|
||||
this.host = Settings.getMySQLHost;
|
||||
this.port = Settings.getMySQLPort;
|
||||
this.username = Settings.getMySQLUsername;
|
||||
this.password = Settings.getMySQLPassword;
|
||||
|
||||
this.database = Settings.getMySQLDatabase;
|
||||
this.tableName = Settings.getMySQLTablename;
|
||||
this.columnName = Settings.getMySQLColumnName;
|
||||
@ -63,7 +60,7 @@ public class SqliteDataSource implements DataSource {
|
||||
this.nonActivatedGroup = Settings.getNonActivatedGroup;
|
||||
this.columnEmail = Settings.getMySQLColumnEmail;
|
||||
this.columnID = Settings.getMySQLColumnId;
|
||||
|
||||
|
||||
connect();
|
||||
setup();
|
||||
}
|
||||
@ -71,13 +68,11 @@ public class SqliteDataSource implements DataSource {
|
||||
private synchronized void connect() throws ClassNotFoundException, SQLException {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
ConsoleLogger.info("SQLite driver loaded");
|
||||
|
||||
this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/"+database+".db");
|
||||
|
||||
}
|
||||
|
||||
private synchronized void setup() throws SQLException {
|
||||
//Connection con = null;
|
||||
Statement st = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
@ -93,7 +88,6 @@ public class SqliteDataSource implements DataSource {
|
||||
+ lastlocZ + " smallint(6) DEFAULT '0',"
|
||||
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
|
||||
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
|
||||
|
||||
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
|
||||
if (!rs.next()) {
|
||||
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||
@ -126,7 +120,6 @@ public class SqliteDataSource implements DataSource {
|
||||
} finally {
|
||||
close(rs);
|
||||
close(st);
|
||||
//close(con);
|
||||
}
|
||||
ConsoleLogger.info("SQLite Setup finished");
|
||||
}
|
||||
@ -146,33 +139,26 @@ public class SqliteDataSource implements DataSource {
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
|
||||
+ columnName + "=?;");
|
||||
pst.setString(1, user);
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
if (rs.getString(columnIp).isEmpty() ) {
|
||||
//System.out.println("[Authme Debug] ColumnIp is empty");
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
|
||||
} else {
|
||||
if(!columnSalt.isEmpty()){
|
||||
//System.out.println("[Authme Debug] column Salt is" + rs.getString(columnSalt));
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
|
||||
} else {
|
||||
//System.out.println("[Authme Debug] column Salt is empty");
|
||||
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(columnEmail));
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -184,13 +170,11 @@ public class SqliteDataSource implements DataSource {
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
|
||||
@ -214,14 +198,12 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
|
||||
@ -233,14 +215,12 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
|
||||
@ -253,14 +233,12 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
|
||||
@ -272,16 +250,13 @@ public class SqliteDataSource implements DataSource {
|
||||
return 0;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
|
||||
pst.setString(1, user);
|
||||
pst.executeUpdate();
|
||||
@ -290,17 +265,14 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, "+ lastlocY +"=?, "+ lastlocZ +"=? WHERE " + columnName + "=?;");
|
||||
pst.setLong(1, auth.getQuitLocX());
|
||||
pst.setLong(2, auth.getQuitLocY());
|
||||
@ -312,23 +284,16 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// Check how many registration by given ip has been done
|
||||
//
|
||||
|
||||
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
ResultSet rs = null;
|
||||
int countIp=0;
|
||||
try {
|
||||
|
||||
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
|
||||
+ columnIp + "=?;");
|
||||
pst.setString(1, ip);
|
||||
@ -343,13 +308,11 @@ public class SqliteDataSource implements DataSource {
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + "=? WHERE " + columnName + "=?;");
|
||||
@ -361,17 +324,15 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
if(columnSalt.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
//Connection con = null;
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + "=? WHERE " + columnName + "=?;");
|
||||
@ -383,11 +344,10 @@ public class SqliteDataSource implements DataSource {
|
||||
return false;
|
||||
} finally {
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
try {
|
||||
@ -456,7 +416,6 @@ public class SqliteDataSource implements DataSource {
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,10 +444,9 @@ public class SqliteDataSource implements DataSource {
|
||||
} finally {
|
||||
close(rs);
|
||||
close(pst);
|
||||
//close(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
PreparedStatement pst = null;
|
||||
@ -516,5 +474,21 @@ public class SqliteDataSource implements DataSource {
|
||||
close(pst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
for (String name : banned) {
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
|
||||
pst.setString(1, name);
|
||||
pst.executeUpdate();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
} finally {
|
||||
close(pst);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,10 +15,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CardboardBox implements Serializable {
|
||||
private static final long serialVersionUID = 729890133797629668L;
|
||||
|
||||
private final int type, amount;
|
||||
private final short damage;
|
||||
|
||||
private final HashMap<CardboardEnchantment, Integer> enchants;
|
||||
|
||||
public CardboardBox(ItemStack item) {
|
||||
|
@ -22,4 +22,5 @@ public class CardboardEnchantment implements Serializable {
|
||||
public Enchantment unbox() {
|
||||
return Enchantment.getById(this.id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,16 @@ package uk.org.whoami.authme.events;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class AuthMeTeleportEvent extends CustomEvent {
|
||||
|
||||
|
||||
private Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
|
||||
|
||||
public AuthMeTeleportEvent(Player player, Location to) {
|
||||
this.player = player;
|
||||
this.from = player.getLocation();
|
||||
|
@ -4,31 +4,32 @@ import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class CustomEvent extends Event {
|
||||
|
||||
|
||||
|
||||
private boolean isCancelled;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static Server s;
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.isCancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
public static Server getServer() {
|
||||
return s;
|
||||
}
|
||||
|
@ -2,21 +2,24 @@ package uk.org.whoami.authme.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class LoginEvent extends UncancellableEvent {
|
||||
|
||||
|
||||
private Player player;
|
||||
private boolean isLogin;
|
||||
|
||||
|
||||
public LoginEvent(Player player, boolean isLogin) {
|
||||
this.player = player;
|
||||
this.isLogin = isLogin;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
@ -28,4 +31,5 @@ public class LoginEvent extends UncancellableEvent {
|
||||
public boolean isLogin() {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,20 +5,24 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.api.API;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class ProtectInventoryEvent extends CustomEvent {
|
||||
|
||||
|
||||
private ItemStack[] storedinventory;
|
||||
private ItemStack[] storedarmor;
|
||||
private ItemStack[] emptyInventory = null;
|
||||
private ItemStack[] emptyArmor = null;
|
||||
private Player player;
|
||||
|
||||
|
||||
public ProtectInventoryEvent(Player player, ItemStack[] storedinventory, ItemStack[] storedarmor) {
|
||||
this.player = player;
|
||||
this.storedinventory = storedinventory;
|
||||
this.storedarmor = storedarmor;
|
||||
}
|
||||
|
||||
|
||||
public ProtectInventoryEvent(Player player, ItemStack[] storedinventory, ItemStack[] storedarmor, int newInventory, int newArmor) {
|
||||
this.player = player;
|
||||
this.storedinventory = storedinventory;
|
||||
@ -31,11 +35,11 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
public ItemStack[] getStoredInventory() {
|
||||
return this.storedinventory;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack[] getStoredArmor() {
|
||||
return this.storedarmor;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
@ -55,4 +59,5 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
public ItemStack[] getEmptyArmor() {
|
||||
return this.emptyArmor;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,16 @@ package uk.org.whoami.authme.events;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class RegisterTeleportEvent extends CustomEvent {
|
||||
|
||||
private Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
|
||||
|
||||
public RegisterTeleportEvent(Player player, Location to) {
|
||||
this.player = player;
|
||||
this.from = player.getLocation();
|
||||
@ -26,4 +30,5 @@ public class RegisterTeleportEvent extends CustomEvent {
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,20 +5,25 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.api.API;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class ResetInventoryEvent extends CustomEvent {
|
||||
|
||||
|
||||
private Player player;
|
||||
|
||||
|
||||
public ResetInventoryEvent(Player player) {
|
||||
this.player = player;
|
||||
API.setPlayerInventory(player, new ItemStack[36], new ItemStack[4]);
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,16 @@ package uk.org.whoami.authme.events;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class RestoreInventoryEvent extends CustomEvent {
|
||||
|
||||
|
||||
private ItemStack[] inventory;
|
||||
private ItemStack[] armor;
|
||||
private Player player;
|
||||
|
||||
|
||||
public RestoreInventoryEvent(Player player, ItemStack[] inventory, ItemStack[] armor) {
|
||||
this.player = player;
|
||||
this.inventory = inventory;
|
||||
@ -18,24 +22,25 @@ public class RestoreInventoryEvent extends CustomEvent {
|
||||
public ItemStack[] getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
|
||||
public void setInventory(ItemStack[] inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack[] getArmor() {
|
||||
return this.armor;
|
||||
}
|
||||
|
||||
|
||||
public void setArmor(ItemStack[] armor) {
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,21 +2,24 @@ package uk.org.whoami.authme.events;
|
||||
|
||||
import uk.org.whoami.authme.cache.auth.PlayerAuth;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class SessionEvent extends CustomEvent {
|
||||
|
||||
|
||||
private PlayerAuth player;
|
||||
private boolean isLogin;
|
||||
|
||||
|
||||
public SessionEvent(PlayerAuth auth, boolean isLogin) {
|
||||
this.player = auth;
|
||||
this.isLogin = isLogin;
|
||||
}
|
||||
|
||||
|
||||
public PlayerAuth getPlayerAuth() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
public void setPlayer(PlayerAuth player) {
|
||||
this.player = player;
|
||||
}
|
||||
@ -24,4 +27,5 @@ public class SessionEvent extends CustomEvent {
|
||||
public boolean isLogin() {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,17 @@ package uk.org.whoami.authme.events;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class SpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
|
||||
private Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
private boolean isAuthenticated;
|
||||
|
||||
|
||||
public SpawnTeleportEvent(Player player, Location from, Location to, boolean isAuthenticated) {
|
||||
this.player = player;
|
||||
this.from = from;
|
||||
|
@ -5,19 +5,22 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import uk.org.whoami.authme.cache.backup.FileCache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class StoreInventoryEvent extends CustomEvent {
|
||||
|
||||
|
||||
private ItemStack[] inventory;
|
||||
private ItemStack[] armor;
|
||||
private Player player;
|
||||
|
||||
|
||||
public StoreInventoryEvent(Player player) {
|
||||
this.player = player;
|
||||
this.inventory = player.getInventory().getContents();
|
||||
this.armor = player.getInventory().getArmorContents();
|
||||
}
|
||||
|
||||
|
||||
public StoreInventoryEvent(Player player, FileCache fileCache) {
|
||||
this.player = player;
|
||||
this.inventory = fileCache.readCache(player.getName().toLowerCase()).getInventory();
|
||||
@ -27,24 +30,25 @@ public class StoreInventoryEvent extends CustomEvent {
|
||||
public ItemStack[] getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
|
||||
public void setInventory(ItemStack[] inventory) {
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack[] getArmor() {
|
||||
return this.armor;
|
||||
}
|
||||
|
||||
|
||||
public void setArmor(ItemStack[] armor) {
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,21 +4,23 @@ import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class UncancellableEvent extends Event {
|
||||
|
||||
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static Server s;
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static Server getServer() {
|
||||
return s;
|
||||
}
|
||||
|
@ -3,10 +3,14 @@ package uk.org.whoami.authme.filter;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class ConsoleFilter implements Filter {
|
||||
|
||||
public ConsoleFilter() {}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
String logM = record.getMessage().toLowerCase();
|
||||
@ -17,7 +21,5 @@ public class ConsoleFilter implements Filter {
|
||||
record.setMessage(playername + " issued an AuthMe command!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import org.getspout.spoutapi.gui.GenericButton;
|
||||
public class CustomButton extends GenericButton
|
||||
{
|
||||
public Clickable handleRef = null;
|
||||
|
||||
|
||||
public CustomButton(Clickable c) {
|
||||
handleRef = c;
|
||||
}
|
||||
@ -15,7 +15,7 @@ public class CustomButton extends GenericButton
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
handleRef.handleClick(event);
|
||||
}
|
||||
|
||||
|
||||
public CustomButton setMidPos(int x, int y)
|
||||
{
|
||||
this.setX(x)
|
||||
@ -24,4 +24,5 @@ public class CustomButton extends GenericButton
|
||||
.shiftYPos(-(height / 2));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
|
||||
public AuthMe plugin = AuthMe.getInstance();
|
||||
private SpoutCfg spoutCfg = SpoutCfg.getInstance();
|
||||
|
||||
private CustomButton exitBtn;
|
||||
private CustomButton loginBtn;
|
||||
private GenericTextField passBox;
|
||||
@ -35,17 +34,16 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
private GenericLabel textLbl;
|
||||
private GenericLabel errorLbl;
|
||||
|
||||
String exitTxt = spoutCfg.getString("LoginScreen.exit button"); //"Quit";
|
||||
String loginTxt = spoutCfg.getString("LoginScreen.login button"); //"Login";
|
||||
String exitMsg = spoutCfg.getString("LoginScreen.exit message"); //"Good Bye";
|
||||
String title = spoutCfg.getString("LoginScreen.title"); //"LOGIN"
|
||||
String exitTxt = spoutCfg.getString("LoginScreen.exit button");
|
||||
String loginTxt = spoutCfg.getString("LoginScreen.login button");
|
||||
String exitMsg = spoutCfg.getString("LoginScreen.exit message");
|
||||
String title = spoutCfg.getString("LoginScreen.title");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> textlines = (List<String>) spoutCfg.getList("LoginScreen.text");
|
||||
public SpoutPlayer splayer;
|
||||
|
||||
|
||||
public LoginScreen(SpoutPlayer player) {
|
||||
this.splayer = player;
|
||||
|
||||
createScreen();
|
||||
}
|
||||
|
||||
@ -53,7 +51,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
int objects = textlines.size() + 4;
|
||||
int part = !(textlines.size() <= 5) ? 195 / objects : 20;
|
||||
int h = 3*part/4, w = 8*part;
|
||||
|
||||
titleLbl = new GenericLabel();
|
||||
titleLbl
|
||||
.setText(title)
|
||||
@ -64,7 +61,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
.setX(maxWidth / 2 )
|
||||
.setY(25);
|
||||
this.attachWidget(plugin, titleLbl);
|
||||
|
||||
int ystart = 25 + h + part/2;
|
||||
for (int x=0; x<textlines.size();x++)
|
||||
{
|
||||
@ -78,7 +74,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
.setY(ystart + x*part);
|
||||
this.attachWidget(plugin, textLbl);
|
||||
}
|
||||
|
||||
passBox = new GenericTextField();
|
||||
passBox
|
||||
.setMaximumCharacters(18)
|
||||
@ -89,7 +84,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
passBox.setPasswordField(true);
|
||||
setXToMid(passBox);
|
||||
this.attachWidget(plugin, passBox);
|
||||
|
||||
errorLbl = new GenericLabel();
|
||||
errorLbl
|
||||
.setText("")
|
||||
@ -99,7 +93,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
.setX(passBox.getX() + passBox.getWidth() + 2)
|
||||
.setY(passBox.getY());
|
||||
this.attachWidget(plugin, errorLbl);
|
||||
|
||||
loginBtn = new CustomButton(this);
|
||||
loginBtn
|
||||
.setText(loginTxt)
|
||||
@ -108,7 +101,6 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
.setY(220-h-part);
|
||||
setXToMid(loginBtn);
|
||||
this.attachWidget(plugin, loginBtn);
|
||||
|
||||
exitBtn = new CustomButton(this);
|
||||
exitBtn
|
||||
.setText(exitTxt)
|
||||
@ -118,10 +110,8 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
setXToMid(exitBtn);
|
||||
this.attachWidget(plugin, exitBtn);
|
||||
this.setPriority(RenderPriority.Highest);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void handleClick(ButtonClickEvent event) {
|
||||
Button b = event.getButton();
|
||||
@ -129,25 +119,15 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
if (event.isCancelled() || event == null || event.getPlayer() == null) return;
|
||||
if (b.equals(loginBtn))
|
||||
{
|
||||
String result = plugin.management.performLogin(player, passBox.getText());
|
||||
if(result == "") {
|
||||
player.closeActiveWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
errorLbl.setText(result);
|
||||
passBox.setText("");
|
||||
}
|
||||
plugin.management.performLogin(player, passBox.getText());
|
||||
}else if(b.equals(exitBtn))
|
||||
{
|
||||
event.getPlayer().kickPlayer(exitMsg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void setXToMid(Widget w) {
|
||||
w.setX( (maxWidth - w.getWidth()) / 2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
package uk.org.whoami.authme.gui.screens;
|
||||
|
||||
/**
|
||||
* @Author Hoezef
|
||||
*/
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.GenericTextField;
|
||||
import org.getspout.spoutapi.gui.WidgetAnchor;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import uk.org.whoami.authme.gui.Clickable;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class RegisterScreen extends GenericPopup implements Clickable{
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private SpoutPlayer splayer;
|
||||
@SuppressWarnings("unused")
|
||||
private boolean forcedRegistrationEnabled;
|
||||
private String title;
|
||||
|
||||
GenericLabel titleLbl = null;
|
||||
GenericTextField messageTF = null;
|
||||
|
||||
public RegisterScreen(SpoutPlayer player, Settings settings) {
|
||||
this.splayer = player;
|
||||
this.forcedRegistrationEnabled = Settings.isForcedRegistrationEnabled;
|
||||
this.title = ""; // needs to be set...
|
||||
|
||||
createScreen();
|
||||
}
|
||||
|
||||
private void createScreen() {
|
||||
titleLbl = new GenericLabel();
|
||||
titleLbl.setText(title)
|
||||
.setAnchor(WidgetAnchor.TOP_CENTER);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void handleClick(ButtonClickEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -33,14 +33,13 @@ public class AuthMeBlockListener implements Listener {
|
||||
|
||||
private DataSource data;
|
||||
public AuthMe instance;
|
||||
//private Settings settings = Settings.getInstance();
|
||||
|
||||
public AuthMeBlockListener(DataSource data, AuthMe instance) {
|
||||
this.data = data;
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
@ -62,11 +61,10 @@ public class AuthMeBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
@ -74,7 +72,7 @@ public class AuthMeBlockListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
if(instance.getCitizensCommunicator().isNPC(player, instance) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
@ -88,8 +86,7 @@ public class AuthMeBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,29 +12,28 @@ import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.Utils;
|
||||
import uk.org.whoami.authme.cache.auth.PlayerCache;
|
||||
import uk.org.whoami.authme.datasource.DataSource;
|
||||
import uk.org.whoami.authme.plugin.manager.CombatTagComunicator;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class AuthMeChestShopListener implements Listener {
|
||||
|
||||
|
||||
public DataSource database;
|
||||
public AuthMe plugin;
|
||||
|
||||
|
||||
public AuthMeChestShopListener(DataSource database, AuthMe plugin) {
|
||||
this.database = database;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPreTransaction(PreTransactionEvent event) {
|
||||
if (event.isCancelled() || event.getClient() == null || event == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = event.getClient();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,7 +47,5 @@ public class AuthMeChestShopListener implements Listener {
|
||||
}
|
||||
}
|
||||
event.setCancelled(TransactionOutcome.OTHER);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,14 +38,13 @@ public class AuthMeEntityListener implements Listener{
|
||||
|
||||
private DataSource data;
|
||||
public AuthMe instance;
|
||||
//private Settings settings = Settings.getInstance();
|
||||
|
||||
public AuthMeEntityListener(DataSource data, AuthMe instance) {
|
||||
this.data = data;
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -55,14 +54,7 @@ public class AuthMeEntityListener implements Listener{
|
||||
if (!(entity instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
System.out.println("[ Entity Damage ] "+event.getEntity().toString());
|
||||
@Future implementation till CombatTag dont release any apis
|
||||
if(event.getEntity().toString().indexOf("PvPLogger") != -1 ) {
|
||||
System.out.println("la stringa contiene PvPLogger 2");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if(instance.getCitizensCommunicator().isNPC(entity, instance) || Utils.getInstance().isUnrestricted((Player)entity) || CombatTagComunicator.isNPC(entity)) {
|
||||
return;
|
||||
}
|
||||
@ -79,7 +71,6 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player.setFireTicks(0);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -171,11 +162,11 @@ public class AuthMeEntityListener implements Listener{
|
||||
if (event.isCancelled() || event == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -193,19 +184,18 @@ public class AuthMeEntityListener implements Listener{
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onLowestEntityInteract(EntityInteractEvent event) {
|
||||
if (event.isCancelled() || event == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -222,8 +212,6 @@ public class AuthMeEntityListener implements Listener{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -71,10 +72,8 @@ import uk.org.whoami.authme.settings.Spawn;
|
||||
import uk.org.whoami.authme.task.MessageTask;
|
||||
import uk.org.whoami.authme.task.TimeoutTask;
|
||||
|
||||
|
||||
public class AuthMePlayerListener implements Listener {
|
||||
|
||||
|
||||
public static int gm = 0;
|
||||
public static HashMap<String, Integer> gameMode = new HashMap<String, Integer>();
|
||||
private Utils utils = Utils.getInstance();
|
||||
@ -96,8 +95,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
@ -122,30 +120,28 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (cmd.equalsIgnoreCase("/login") || cmd.equalsIgnoreCase("/register") || cmd.equalsIgnoreCase("/passpartu") || cmd.equalsIgnoreCase("/l") || cmd.equalsIgnoreCase("/reg") || cmd.equalsIgnoreCase("/email") || cmd.equalsIgnoreCase("/captcha")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.allowCommands.contains(cmd)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setMessage("/notloggedin");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler( priority = EventPriority.NORMAL)
|
||||
public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
if(plugin.CitizensVersion != 0) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(plugin.CombatTag != 0) {
|
||||
if (CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
@ -159,7 +155,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
@ -167,7 +163,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
@ -178,7 +174,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -193,14 +188,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler( priority = EventPriority.HIGH)
|
||||
public void onPlayerHighChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
@ -223,7 +217,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
@ -231,7 +225,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
@ -242,7 +236,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -257,14 +250,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler( priority = EventPriority.MONITOR)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
@ -287,7 +279,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
@ -295,7 +287,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
@ -306,7 +298,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -321,14 +312,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler( priority = EventPriority.HIGHEST)
|
||||
public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
@ -351,7 +341,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
@ -359,7 +349,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
@ -370,7 +360,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -385,15 +374,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler( priority = EventPriority.LOWEST)
|
||||
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
@ -416,7 +403,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
@ -424,7 +411,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
@ -435,7 +422,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -456,8 +442,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
@ -480,7 +465,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String cmd = event.getMessage().split(" ")[0];
|
||||
|
||||
if (!Settings.isChatAllowed && !(Settings.allowCommands.contains(cmd))) {
|
||||
@ -488,7 +473,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!event.isAsynchronous()) {
|
||||
if (data.isAuthAvailable(name)) {
|
||||
player.sendMessage(m._("login_msg"));
|
||||
@ -499,7 +484,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.sendMessage(m._("reg_msg"));
|
||||
}
|
||||
} else {
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -520,7 +504,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (event.isCancelled() || event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
@ -536,7 +519,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Settings.isMovementAllowed) {
|
||||
event.setTo(event.getFrom());
|
||||
return;
|
||||
@ -545,7 +528,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Settings.getMovementRadius == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int radius = Settings.getMovementRadius;
|
||||
Location spawn = player.getWorld().getSpawnLocation();
|
||||
@ -559,62 +541,44 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
if (Spawn.getInstance().getLocation() != null)
|
||||
spawn = Spawn.getInstance().getLocation();
|
||||
|
||||
|
||||
if ((spawn.distance(player.getLocation()) > radius) ) {
|
||||
event.getPlayer().teleport(spawn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("same_nick"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!event.isAsynchronous()) {
|
||||
if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
if(!Settings.isSessionsEnabled) {
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if(!Settings.sessionExpireOnIpChange)
|
||||
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
if(!Settings.isSessionsEnabled) {
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if(!Settings.sessionExpireOnIpChange)
|
||||
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//Run that asynchronous
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
if(!Settings.isSessionsEnabled) {
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if(!Settings.sessionExpireOnIpChange)
|
||||
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//Check if forceSingleSession is set to true, so kick player that has joined with same nick of online player
|
||||
if(player.isOnline() && Settings.isForceSingleSessionEnabled ) {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
@ -625,9 +589,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int min = Settings.getMinNickLength;
|
||||
int max = Settings.getMaxNickLength;
|
||||
String regex = Settings.getNickRegex;
|
||||
@ -645,7 +608,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (Settings.isKickNonRegisteredEnabled) {
|
||||
if (!data.isAuthAvailable(name)) {
|
||||
event.disallow(Result.KICK_OTHER, m._("reg_only"));
|
||||
@ -658,6 +621,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.disallow(Result.KICK_FULL, m._("kick_fullserver"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getServer().getOnlinePlayers().length > plugin.getServer().getMaxPlayers()) {
|
||||
event.allow();
|
||||
return;
|
||||
@ -673,7 +637,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
@ -699,9 +662,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
try {
|
||||
ip = BungeeCord.getInstance().getPlayer(player.getName()).getAddress().getAddress().getHostAddress();
|
||||
for (ProxiedPlayer pp : BungeeCord.getInstance().getPlayers()) {
|
||||
if (pp.getName().toLowerCase() == name) {
|
||||
ip = pp.getAddress().getAddress().getHostAddress();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
ConsoleLogger.showError("Your BungeeCord version is outdated, you need a version with the latest API");
|
||||
}
|
||||
}
|
||||
if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
||||
@ -712,17 +679,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
plugin.getServer().banIP(ip);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (data.isAuthAvailable(name)) {
|
||||
|
||||
|
||||
if (Settings.isSessionsEnabled) {
|
||||
PlayerAuth auth = data.getAuth(name);
|
||||
long timeout = Settings.getSessionTimeout * 60000;
|
||||
long lastLogin = auth.getLastLogin();
|
||||
long cur = new Date().getTime();
|
||||
|
||||
|
||||
if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) {
|
||||
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) {
|
||||
plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
|
||||
@ -756,10 +719,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
// isent in session or session was ended correctly
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
|
||||
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
||||
playerBackup.createCache(name, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator());
|
||||
|
||||
} else {
|
||||
if(!Settings.unRegisteredGroup.isEmpty()){
|
||||
utils.setGroup(player, Utils.groupType.UNREGISTERED);
|
||||
@ -768,9 +729,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Settings.protectInventoryBeforeLogInEnabled) {
|
||||
try {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
@ -783,10 +741,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
if(player.isOp())
|
||||
player.setOp(false);
|
||||
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
@ -797,25 +753,19 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_msg");
|
||||
int time = Settings.getRegistrationTimeout * 20;
|
||||
int msgInterval = Settings.getWarnMessageInterval;
|
||||
if (time != 0) {
|
||||
|
||||
BukkitTask id = sched.runTaskLater(plugin, new TimeoutTask(plugin, name), time);
|
||||
if(!LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id.getTaskId());
|
||||
}
|
||||
|
||||
if(!LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT.getTaskId());
|
||||
|
||||
if (Settings.isForceSurvivalModeEnabled)
|
||||
sched.runTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
@ -823,32 +773,34 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
|
||||
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
|
||||
PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),(int)player.getLocation().getX(),(int)player.getLocation().getY(),(int)player.getLocation().getZ());
|
||||
try {
|
||||
data.updateQuitLoc(auth);
|
||||
} catch (NullPointerException npe) { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
|
||||
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(),(int)player.getLocation().getX(),(int)player.getLocation().getY(),(int)player.getLocation().getZ());
|
||||
try {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
data.updateQuitLoc(auth);
|
||||
}
|
||||
});
|
||||
} catch (NullPointerException npe) { }
|
||||
}
|
||||
}
|
||||
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
//System.out.println("e' nel quit");
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@ -870,18 +822,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
try {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
}
|
||||
try {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
PlayersLogs.getInstance().save();
|
||||
player.getVehicle().eject();
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
if (gameMode.containsKey(name)) gameMode.remove(name);
|
||||
player.saveData();
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
@ -908,8 +855,13 @@ public class AuthMePlayerListener implements Listener {
|
||||
String name = player.getName().toLowerCase();
|
||||
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
|
||||
(Settings.isSaveQuitLocationEnabled.booleanValue()) && data.isAuthAvailable(name)) {
|
||||
PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), (int)player.getLocation().getX(), (int)player.getLocation().getY(), (int)player.getLocation().getZ());
|
||||
this.data.updateQuitLoc(auth);
|
||||
final PlayerAuth auth = new PlayerAuth(event.getPlayer().getName().toLowerCase(), (int)player.getLocation().getX(), (int)player.getLocation().getY(), (int)player.getLocation().getZ());
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
data.updateQuitLoc(auth);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
@ -936,7 +888,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
}
|
||||
this.utils.addNormal(player, limbo.getGroup());
|
||||
player.setOp(limbo.getOperator());
|
||||
@ -952,6 +903,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
PlayersLogs.players.remove(player.getName());
|
||||
PlayersLogs.getInstance().save();
|
||||
if (gameMode.containsKey(name)) gameMode.remove(name);
|
||||
player.getVehicle().eject();
|
||||
player.saveData();
|
||||
} catch (NullPointerException ex) {}
|
||||
}
|
||||
@ -982,11 +934,11 @@ public class AuthMePlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null) return;
|
||||
if (event.getClickedBlock() == null) return;
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@ -1003,17 +955,14 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
final int sign = event.getClickedBlock().getTypeId();
|
||||
if (sign == Material.SIGN_POST.getId() || sign == Material.WALL_SIGN.getId()) {
|
||||
event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
|
||||
}
|
||||
} catch (NullPointerException npe) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -1063,8 +1012,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//System.out.println("player try to drop item");
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -1091,8 +1038,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (event.isCancelled() || event.getPlayer() == null || event == null) {
|
||||
return;
|
||||
@ -1114,8 +1061,5 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,19 +17,16 @@ import uk.org.whoami.authme.settings.SpoutCfg;
|
||||
public class AuthMeSpoutListener implements Listener {
|
||||
private DataSource data;
|
||||
|
||||
|
||||
public AuthMeSpoutListener(DataSource data) {
|
||||
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onSpoutCraftEnable(final SpoutCraftEnableEvent event)
|
||||
{
|
||||
if(SpoutCfg.getInstance().getBoolean("LoginScreen.enabled")) {
|
||||
if (data.isAuthAvailable(event.getPlayer().getName().toLowerCase()) && !PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase()) ) {
|
||||
event.getPlayer().getMainScreen().attachPopupScreen(new LoginScreen(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onSpoutCraftEnable(final SpoutCraftEnableEvent event) {
|
||||
if(SpoutCfg.getInstance().getBoolean("LoginScreen.enabled")) {
|
||||
if (data.isAuthAvailable(event.getPlayer().getName().toLowerCase()) && !PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase()) ) {
|
||||
event.getPlayer().getMainScreen().attachPopupScreen(new LoginScreen(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ import org.bukkit.entity.Entity;
|
||||
import uk.org.whoami.authme.AuthMe;
|
||||
|
||||
public class CitizensCommunicator {
|
||||
|
||||
|
||||
public AuthMe instance;
|
||||
|
||||
|
||||
public CitizensCommunicator(AuthMe instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
@ -16,8 +16,9 @@ import org.bukkit.entity.Player;
|
||||
* @author stefano
|
||||
*/
|
||||
public abstract class CombatTagComunicator {
|
||||
static CombatTagApi combatApi;
|
||||
|
||||
|
||||
static CombatTagApi combatApi;
|
||||
|
||||
public CombatTagComunicator() {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
|
||||
combatApi = new CombatTagApi((CombatTag)Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
|
||||
@ -30,16 +31,15 @@ public abstract class CombatTagComunicator {
|
||||
* @return true if player is in combat
|
||||
*/
|
||||
public abstract boolean isInCombat(String player);
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Checks to see if the player is in combat. The combat time can be configured by the server owner
|
||||
* If the player has died while in combat the player is no longer considered in combat and as such will return false
|
||||
* @param player
|
||||
* @return true if player is in combat
|
||||
*/
|
||||
public abstract boolean isInCombat(Player player);
|
||||
|
||||
/**
|
||||
public abstract boolean isInCombat(Player player);
|
||||
/**
|
||||
* Returns the time before the tag is over
|
||||
* -1 if the tag has expired
|
||||
* -2 if the player is not in combat
|
||||
@ -48,25 +48,25 @@ public abstract class CombatTagComunicator {
|
||||
*/
|
||||
public abstract long getRemainingTagTime(String player);
|
||||
|
||||
//(Implemented in 3.8)
|
||||
/**
|
||||
/**
|
||||
* Returns if the entity is an NPC
|
||||
* @param player
|
||||
* @return true if the player is an NPC
|
||||
*/
|
||||
public static boolean isNPC(Entity player) {
|
||||
try {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
|
||||
combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
|
||||
return combatApi.isNPC(player);
|
||||
}
|
||||
} catch (ClassCastException ex) {
|
||||
return false;
|
||||
} catch (NullPointerException npe) {
|
||||
return false;
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isNPC(Entity player) {
|
||||
try {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null){
|
||||
combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
|
||||
return combatApi.isNPC(player);
|
||||
}
|
||||
} catch (ClassCastException ex) {
|
||||
return false;
|
||||
} catch (NullPointerException npe) {
|
||||
return false;
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,19 +31,16 @@ import uk.org.whoami.authme.AuthMe;
|
||||
import uk.org.whoami.authme.settings.Settings;
|
||||
|
||||
public class PasswordSecurity {
|
||||
|
||||
|
||||
private static SecureRandom rnd = new SecureRandom();
|
||||
public static HashMap<String, String> userSalt = new HashMap<String, String>();
|
||||
|
||||
private static String getMD5(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
byte[] digest = md5.digest();
|
||||
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,
|
||||
digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
private static String getSHA1(String message) throws NoSuchAlgorithmException {
|
||||
@ -51,20 +48,15 @@ public class PasswordSecurity {
|
||||
sha1.reset();
|
||||
sha1.update(message.getBytes());
|
||||
byte[] digest = sha1.digest();
|
||||
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,
|
||||
digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
private static String getSHA256(String message) throws NoSuchAlgorithmException {
|
||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
||||
|
||||
sha256.reset();
|
||||
sha256.update(message.getBytes());
|
||||
byte[] digest = sha256.digest();
|
||||
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,
|
||||
digest));
|
||||
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
|
||||
}
|
||||
|
||||
public static String getWhirlpool(String message) {
|
||||
@ -79,35 +71,28 @@ public class PasswordSecurity {
|
||||
private static String getSaltedHash(String message, String salt) throws NoSuchAlgorithmException {
|
||||
return "$SHA$" + salt + "$" + getSHA256(getSHA256(message) + salt);
|
||||
}
|
||||
|
||||
//
|
||||
// VBULLETIN 3.X 4.X METHOD
|
||||
//
|
||||
|
||||
|
||||
private static String getSaltedMd5(String message, String salt) throws NoSuchAlgorithmException {
|
||||
return "$MD5vb$" + salt + "$" + getMD5(getMD5(message) + salt);
|
||||
}
|
||||
|
||||
|
||||
private static String getSaltedMyBB(String message, String salt) throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt)+ getMD5(message));
|
||||
}
|
||||
|
||||
|
||||
private static String getXAuth(String message, String salt) {
|
||||
String hash = getWhirlpool(salt + message).toLowerCase();
|
||||
int saltPos = (message.length() >= hash.length() ? hash.length() - 1 : message.length());
|
||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||
}
|
||||
|
||||
private static String getSaltedIPB3(String message, String salt) throws NoSuchAlgorithmException {
|
||||
|
||||
return getMD5(getMD5(salt) + getMD5(message));
|
||||
|
||||
private static String getSaltedIPB3(String message, String salt) throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt) + getMD5(message));
|
||||
}
|
||||
|
||||
private static String createSalt(int length) throws NoSuchAlgorithmException {
|
||||
byte[] msg = new byte[40];
|
||||
rnd.nextBytes(msg);
|
||||
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
sha1.reset();
|
||||
byte[] digest = sha1.digest(msg);
|
||||
@ -203,10 +188,9 @@ public class PasswordSecurity {
|
||||
}
|
||||
|
||||
public static boolean comparePasswordWithHash(String password, String hash, String playername) throws NoSuchAlgorithmException {
|
||||
//System.out.println("[Authme Debug] debug hashString"+hash);
|
||||
if(hash.contains("$H$")) {
|
||||
PhpBB checkHash = new PhpBB();
|
||||
return checkHash.phpbb_check_hash(password, hash);
|
||||
PhpBB checkHash = new PhpBB();
|
||||
return checkHash.phpbb_check_hash(password, hash);
|
||||
}
|
||||
if(!Settings.getMySQLColumnSalt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.IPB3) {
|
||||
String saltipb = AuthMe.getInstance().database.getAuth(playername).getSalt();
|
||||
@ -241,32 +225,23 @@ public class PasswordSecurity {
|
||||
if(hash.length() < 32 ) {
|
||||
return hash.equals(password);
|
||||
}
|
||||
|
||||
if (hash.length() == 32) {
|
||||
return hash.equals(getMD5(password));
|
||||
}
|
||||
|
||||
if (hash.length() == 40) {
|
||||
return hash.equals(getSHA1(password));
|
||||
}
|
||||
|
||||
if (hash.length() == 140) {
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
String salt = hash.substring(saltPos, saltPos + 12);
|
||||
return hash.equals(getXAuth(password, salt));
|
||||
}
|
||||
|
||||
if (hash.contains("$")) {
|
||||
//System.out.println("[Authme Debug] debug hashString"+hash);
|
||||
String[] line = hash.split("\\$");
|
||||
if (line.length > 3 && line[1].equals("SHA")) {
|
||||
return hash.equals(getSaltedHash(password, line[2]));
|
||||
} else {
|
||||
if(line[1].equals("MD5vb")) {
|
||||
//System.out.println("[Authme Debug] password hashed from Authme"+getSaltedMd5(password, line[2]));
|
||||
//System.out.println("[Authme Debug] salt from Authme"+line[2]);
|
||||
//System.out.println("[Authme Debug] equals? Authme: "+hash);
|
||||
//hash = "$MD5vb$" + salt + "$" + hash;
|
||||
return hash.equals(getSaltedMd5(password, line[2]));
|
||||
}
|
||||
}
|
||||
@ -280,11 +255,10 @@ public class PasswordSecurity {
|
||||
return phpBBhash;
|
||||
}
|
||||
|
||||
|
||||
private static String getPlainText(String password) {
|
||||
return password;
|
||||
}
|
||||
|
||||
|
||||
public static String getPhPFusion(String msg, String keyString) {
|
||||
String digest = null;
|
||||
String algo = "HmacSHA256";
|
||||
@ -292,9 +266,7 @@ public class PasswordSecurity {
|
||||
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
|
||||
Mac mac = Mac.getInstance(algo);
|
||||
mac.init(key);
|
||||
|
||||
byte[] bytes = mac.doFinal(msg.getBytes("ASCII"));
|
||||
|
||||
StringBuffer hash = new StringBuffer();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
String hex = Integer.toHexString(0xFF & bytes[i]);
|
||||
@ -315,4 +287,5 @@ public class PasswordSecurity {
|
||||
|
||||
MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, PLAINTEXT, MYBB, IPB3, PHPFUSION, SMF, XFSHA1, XFSHA256, SALTED2MD5, JOOMLA
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,43 +17,34 @@ public class PhpBB {
|
||||
private String itoa64 =
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
|
||||
public String phpbb_hash(String password) {
|
||||
String random_state = unique_id();
|
||||
String random = "";
|
||||
int count = 6;
|
||||
|
||||
if (random.length() < count) {
|
||||
random = "";
|
||||
|
||||
for (int i = 0; i < count; i += 16) {
|
||||
random_state = md5(unique_id() + random_state);
|
||||
random += pack(md5(random_state));
|
||||
}
|
||||
random = random.substring(0, count);
|
||||
}
|
||||
|
||||
String hash = _hash_crypt_private(
|
||||
password, _hash_gensalt_private(random, itoa64));
|
||||
if (hash.length() == 34)
|
||||
return hash;
|
||||
|
||||
return md5(password);
|
||||
}
|
||||
|
||||
// global $config;
|
||||
// private boolean dss_seeded = false;
|
||||
|
||||
private String unique_id() {
|
||||
return unique_id("c");
|
||||
}
|
||||
|
||||
|
||||
private String unique_id(String extra) {
|
||||
//TODO: Maybe check the salt?
|
||||
return "1234567890abcdef";
|
||||
}
|
||||
|
||||
|
||||
private String _hash_gensalt_private(String input, String itoa64) {
|
||||
return _hash_gensalt_private(input, itoa64, 6);
|
||||
}
|
||||
@ -64,13 +55,11 @@ private String _hash_gensalt_private(
|
||||
if (iteration_count_log2 < 4 || iteration_count_log2 > 31) {
|
||||
iteration_count_log2 = 8;
|
||||
}
|
||||
|
||||
String output = "$H$";
|
||||
output += itoa64.charAt(
|
||||
Math.min(iteration_count_log2 +
|
||||
((PHP_VERSION >= 5) ? 5 : 3), 30));
|
||||
output += _hash_encode64(input, 6);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -80,58 +69,41 @@ private String _hash_gensalt_private(
|
||||
private String _hash_encode64(String input, int count) {
|
||||
String output = "";
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
int value = input.charAt(i++);
|
||||
output += itoa64.charAt(value & 0x3f);
|
||||
|
||||
if (i < count)
|
||||
value |= input.charAt(i) << 8;
|
||||
|
||||
output += itoa64.charAt((value >> 6) & 0x3f);
|
||||
|
||||
if (i++ >= count)
|
||||
break;
|
||||
|
||||
if (i < count)
|
||||
value |= input.charAt(i) << 16;
|
||||
|
||||
output += itoa64.charAt((value >> 12) & 0x3f);
|
||||
|
||||
if (i++ >= count)
|
||||
break;
|
||||
|
||||
output += itoa64.charAt((value >> 18) & 0x3f);
|
||||
} while (i < count);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
String _hash_crypt_private(String password, String setting) {
|
||||
String output = "*";
|
||||
|
||||
// Check for correct hash
|
||||
String output = "*";
|
||||
if (!setting.substring(0, 3).equals("$H$"))
|
||||
return output;
|
||||
|
||||
int count_log2 = itoa64.indexOf(setting.charAt(3));
|
||||
if (count_log2 < 7 || count_log2 > 30)
|
||||
return output;
|
||||
|
||||
int count = 1 << count_log2;
|
||||
String salt = setting.substring(4, 12);
|
||||
if (salt.length() != 8)
|
||||
return output;
|
||||
|
||||
String m1 = md5(salt + password);
|
||||
String hash = pack(m1);
|
||||
do {
|
||||
hash = pack(md5(hash + password));
|
||||
} while (--count > 0);
|
||||
|
||||
output = setting.substring(0, 12);
|
||||
output += _hash_encode64(hash, 16);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -154,18 +126,16 @@ private String _hash_gensalt_private(
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int hexToInt(char ch) {
|
||||
if(ch >= '0' && ch <= '9')
|
||||
return ch - '0';
|
||||
|
||||
ch = Character.toUpperCase(ch);
|
||||
if(ch >= 'A' && ch <= 'F')
|
||||
return ch - 'A' + 0xA;
|
||||
|
||||
throw new IllegalArgumentException("Not a hex character: " + ch);
|
||||
}
|
||||
|
||||
|
||||
private static String bytes2hex(byte[] bytes) {
|
||||
StringBuffer r = new StringBuffer(32);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
@ -188,4 +158,3 @@ private String _hash_gensalt_private(
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,20 @@ package uk.org.whoami.authme.security;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class RandomString
|
||||
{
|
||||
|
||||
private static final char[] symbols = new char[36];
|
||||
private static final char[] chars = new char[36];
|
||||
|
||||
static {
|
||||
for (int idx = 0; idx < 10; ++idx)
|
||||
symbols[idx] = (char) ('0' + idx);
|
||||
chars[idx] = (char) ('0' + idx);
|
||||
for (int idx = 10; idx < 36; ++idx)
|
||||
symbols[idx] = (char) ('a' + idx - 10);
|
||||
chars[idx] = (char) ('a' + idx - 10);
|
||||
}
|
||||
|
||||
private final Random random = new Random();
|
||||
@ -28,7 +32,7 @@ public class RandomString
|
||||
public String nextString()
|
||||
{
|
||||
for (int idx = 0; idx < buf.length; ++idx)
|
||||
buf[idx] = symbols[random.nextInt(symbols.length)];
|
||||
buf[idx] = chars[random.nextInt(chars.length)];
|
||||
return new String(buf);
|
||||
}
|
||||
|
||||
|
@ -131,26 +131,6 @@ class Whirlpool {
|
||||
C[t][x] = (C[t - 1][x] >>> 8) | ((C[t - 1][x] << 56));
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (int t = 0; t < 8; t++) {
|
||||
System.out.println("static const u64 C" + t + "[256] = {");
|
||||
for (int i = 0; i < 64; i++) {
|
||||
System.out.print(" ");
|
||||
for (int j = 0; j < 4; j++) {
|
||||
String v = Long.toHexString(C[t][4*i + j]);
|
||||
while (v.length() < 16) {
|
||||
v = "0" + v;
|
||||
}
|
||||
System.out.print(" LL(0x" + v + "),");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println("};");
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println();
|
||||
//*/
|
||||
|
||||
/*
|
||||
* build the round constants:
|
||||
*/
|
||||
@ -167,18 +147,6 @@ class Whirlpool {
|
||||
(C[6][i + 6] & 0x000000000000ff00L) ^
|
||||
(C[7][i + 7] & 0x00000000000000ffL);
|
||||
}
|
||||
/*
|
||||
System.out.println("static const u64 rc[R + 1] = {");
|
||||
for (int r = 0; r <= R; r++) {
|
||||
String v = Long.toHexString(rc[r]);
|
||||
while (v.length() < 16) {
|
||||
v = "0" + v;
|
||||
}
|
||||
System.out.println(" LL(0x" + v + "),");
|
||||
}
|
||||
System.out.println("};");
|
||||
System.out.println();
|
||||
//*/
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,10 +173,10 @@ class Whirlpool {
|
||||
* The hashing state.
|
||||
*/
|
||||
protected long[] hash = new long[8];
|
||||
protected long[] K = new long[8]; // the round key
|
||||
protected long[] K = new long[8];
|
||||
protected long[] L = new long[8];
|
||||
protected long[] block = new long[8]; // mu(buffer)
|
||||
protected long[] state = new long[8]; // the cipher state
|
||||
protected long[] block = new long[8];
|
||||
protected long[] state = new long[8];
|
||||
|
||||
public Whirlpool() {
|
||||
}
|
||||
@ -281,8 +249,8 @@ class Whirlpool {
|
||||
public void NESSIEinit() {
|
||||
Arrays.fill(bitLength, (byte)0);
|
||||
bufferBits = bufferPos = 0;
|
||||
buffer[0] = 0; // it's only necessary to cleanup buffer[bufferPos].
|
||||
Arrays.fill(hash, 0L); // initial value
|
||||
buffer[0] = 0;
|
||||
Arrays.fill(hash, 0L);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,10 +19,10 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
public CustomConfiguration(File file)
|
||||
{
|
||||
this.configFile = file;
|
||||
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
public void load()
|
||||
{
|
||||
try {
|
||||
@ -36,7 +36,7 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, configFile.getName() + " is no valid configuration file", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean reload() {
|
||||
boolean out = true;
|
||||
if (!configFile.exists())
|
||||
@ -46,7 +46,7 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
if (out) load();
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
super.save(configFile);
|
||||
@ -54,7 +54,7 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save config to " + configFile.getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean loadRessource(File file) {
|
||||
boolean out = true;
|
||||
if (!file.exists()) {
|
||||
@ -64,7 +64,6 @@ public class CustomConfiguration extends YamlConfiguration{
|
||||
fos = new FileOutputStream(file);
|
||||
byte[] buf = new byte[1024];
|
||||
int i = 0;
|
||||
|
||||
while ((i = fis.read(buf)) != -1) {
|
||||
fos.write(buf, 0, i);
|
||||
}
|
||||
|
@ -21,17 +21,14 @@ import java.io.File;
|
||||
public class Messages extends CustomConfiguration {
|
||||
|
||||
private static Messages singleton = null;
|
||||
|
||||
|
||||
public Messages() {
|
||||
|
||||
super(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
|
||||
loadDefaults();
|
||||
loadFile();
|
||||
singleton = this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void loadDefaults() {
|
||||
this.set("logged_in", "&cAlready logged in!");
|
||||
this.set("not_logged_in", "&cNot logged in!");
|
||||
@ -80,7 +77,6 @@ public class Messages extends CustomConfiguration {
|
||||
private void loadFile() {
|
||||
this.load();
|
||||
this.save();
|
||||
|
||||
}
|
||||
|
||||
public String _(String msg) {
|
||||
@ -90,13 +86,12 @@ public class Messages extends CustomConfiguration {
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Messages getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new Messages();
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,15 @@ package uk.org.whoami.authme.settings;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class PlayersLogs extends CustomConfiguration {
|
||||
|
||||
private static PlayersLogs pllog = null;
|
||||
public static List<String> players;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PlayersLogs() {
|
||||
super(new File("./plugins/AuthMe/players.yml"));
|
||||
@ -15,16 +19,13 @@ public class PlayersLogs extends CustomConfiguration {
|
||||
load();
|
||||
save();
|
||||
players = (List<String>) this.getList("players");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static PlayersLogs getInstance() {
|
||||
if (pllog == null) {
|
||||
pllog = new PlayersLogs();
|
||||
}
|
||||
return pllog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,14 +45,13 @@ public final class Settings extends YamlConfiguration {
|
||||
private static List<String> getRestrictedIp;
|
||||
public static List<String> getMySQLOtherUsernameColumn = null;
|
||||
public static List<String> getForcedWorlds = null;
|
||||
|
||||
public final Plugin plugin;
|
||||
private final File file;
|
||||
|
||||
public static DataSourceType getDataSource;
|
||||
public static HashAlgorithm getPasswordHash;
|
||||
public static HashAlgorithm rakamakHash;
|
||||
|
||||
public static Boolean useLogging = false;
|
||||
|
||||
public static Boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled,
|
||||
isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
|
||||
isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled,
|
||||
@ -61,8 +60,7 @@ public final class Settings extends YamlConfiguration {
|
||||
getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart,
|
||||
isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange;
|
||||
|
||||
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||
getMySQLColumnName, getMySQLColumnPassword, getMySQLColumnIp, getMySQLColumnLastLogin,
|
||||
@ -70,24 +68,16 @@ public final class Settings extends YamlConfiguration {
|
||||
getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
|
||||
rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
|
||||
getPredefinedSalt, getMailSubject, getMailText;
|
||||
|
||||
|
||||
|
||||
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
|
||||
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
|
||||
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail;
|
||||
|
||||
|
||||
protected static YamlConfiguration configFile;
|
||||
|
||||
|
||||
public Settings(Plugin plugin) {
|
||||
//super(new File(Settings.PLUGIN_FOLDER + "/config.yml"), this.plugin);
|
||||
this.file = new File(plugin.getDataFolder(),"config.yml");
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
|
||||
|
||||
//options().indent(4);
|
||||
// Override to always indent 4 spaces
|
||||
if(exists()) {
|
||||
load();
|
||||
}
|
||||
@ -95,21 +85,14 @@ public final class Settings extends YamlConfiguration {
|
||||
loadDefaults(file.getName());
|
||||
load();
|
||||
}
|
||||
|
||||
configFile = (YamlConfiguration) plugin.getConfig();
|
||||
|
||||
//saveDefaults();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loadConfigOptions() {
|
||||
|
||||
plugin.getLogger().info("Loading Configuration File...");
|
||||
|
||||
mergeConfig();
|
||||
|
||||
|
||||
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage","en"));
|
||||
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
|
||||
isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
|
||||
@ -220,16 +203,15 @@ public void loadConfigOptions() {
|
||||
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
|
||||
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
|
||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
||||
|
||||
saveDefaults();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
configFile = newConfig;
|
||||
|
||||
//plugin.getLogger().info("RELoading Configuration File...");
|
||||
|
||||
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage","en"));
|
||||
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
|
||||
isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
|
||||
@ -340,114 +322,84 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
|
||||
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
|
||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
||||
|
||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void mergeConfig() {
|
||||
|
||||
if (contains("settings.restrictions.allowedPluginTeleportHandler"))
|
||||
set("settings.restrictions.allowedPluginTeleportHandler", null);
|
||||
|
||||
if(!contains("DataSource.mySQLColumnEmail"))
|
||||
set("DataSource.mySQLColumnEmail","email");
|
||||
|
||||
if(contains("Email.GmailAccount")) {
|
||||
set("Email.mailAccount", getString("Email.GmailAccount"));
|
||||
set("Email.GmailAccount", null);
|
||||
}
|
||||
|
||||
if(contains("Email.GmailPassword")) {
|
||||
set("Email.mailPassword", getString("Email.GmailPassword"));
|
||||
set("Email.GmailPassword", null);
|
||||
}
|
||||
|
||||
if(!contains("Email.RecoveryPasswordLength"))
|
||||
set("Email.RecoveryPasswordLength", 8);
|
||||
|
||||
if(!contains("Email.mailPort"))
|
||||
set("Email.mailPort", 465);
|
||||
|
||||
if(!contains("Email.mailSMTP"))
|
||||
set("Email.mailSMTP", "smtp.gmail.com");
|
||||
|
||||
if(!contains("Email.mailAccount"))
|
||||
set("Email.mailAccount", "");
|
||||
|
||||
if(!contains("Email.mailPassword"))
|
||||
set("Email.mailPassword", "");
|
||||
|
||||
if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns"))
|
||||
set("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList<String>());
|
||||
|
||||
if(!contains("settings.restrictions.displayOtherAccounts"))
|
||||
set("settings.restrictions.displayOtherAccounts", true);
|
||||
|
||||
if(!contains("DataSource.mySQLColumnId"))
|
||||
set("DataSource.mySQLColumnId", "id");
|
||||
|
||||
if(!contains("Email.mailSenderName"))
|
||||
set("Email.mailSenderName", "");
|
||||
|
||||
if(!contains("Xenoforo.predefinedSalt"))
|
||||
set("Xenoforo.predefinedSalt", "");
|
||||
|
||||
if(!contains("Security.captcha.useCaptcha"))
|
||||
set("Security.captcha.useCaptcha", false);
|
||||
|
||||
if(!contains("Security.captcha.maxLoginTry"))
|
||||
set("Security.captcha.maxLoginTry", 5);
|
||||
|
||||
if(!contains("Security.captcha.captchaLength"))
|
||||
set("Security.captcha.captchaLength", 5);
|
||||
|
||||
if(!contains("Email.mailSubject"))
|
||||
set("Email.mailSubject", "");
|
||||
|
||||
if(!contains("Email.mailText"))
|
||||
set("Email.mailText", "Dear <playername>, \n\n This is your new AuthMe password for the server : \n\n <servername> \n\n <generatedpass>\n\n Do not forget to change password after login! \n /changepassword <generatedpass> newPassword");
|
||||
|
||||
if(!contains("settings.registration.enableEmailRegistrationSystem"))
|
||||
set("settings.registration.enableEmailRegistrationSystem", false);
|
||||
|
||||
if(!contains("settings.security.doubleMD5SaltLength"))
|
||||
set("settings.security.doubleMD5SaltLength", 8);
|
||||
|
||||
if(!contains("Email.maxRegPerEmail"))
|
||||
set("Email.maxRegPerEmail", 1);
|
||||
|
||||
if(!contains("Hooks.multiverse")) {
|
||||
set("Hooks.multiverse", true);
|
||||
set("Hooks.chestshop", true);
|
||||
set("Hooks.notifications", true);
|
||||
set("Hooks.bungeecord", false);
|
||||
}
|
||||
|
||||
if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds"))
|
||||
set("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList<String>());
|
||||
|
||||
if(!contains("settings.restrictions.banUnsafedIP"))
|
||||
set("settings.restrictions.banUnsafedIP", false);
|
||||
|
||||
if(!contains("settings.registration.doubleEmailCheck"))
|
||||
set("settings.registration.doubleEmailCheck", false);
|
||||
|
||||
if(!contains("settings.sessions.sessionExpireOnIpChange"))
|
||||
set("settings.sessions.sessionExpireOnIpChange", false);
|
||||
if(!contains("Security.console.logConsole"))
|
||||
set("Security.console.logConsole", false);
|
||||
|
||||
plugin.getLogger().info("Merge new Config Options if needed..");
|
||||
plugin.saveConfig();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
private static HashAlgorithm getPasswordHash() {
|
||||
String key = "settings.security.passwordHash";
|
||||
|
||||
try {
|
||||
return PasswordSecurity.HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
@ -455,8 +407,7 @@ public void mergeConfig() {
|
||||
return PasswordSecurity.HashAlgorithm.SHA256;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static HashAlgorithm getRakamakHash() {
|
||||
String key = "Converter.Rakamak.newPasswordHash";
|
||||
|
||||
@ -467,15 +418,9 @@ public void mergeConfig() {
|
||||
return PasswordSecurity.HashAlgorithm.SHA256;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
private static DataSourceType getDataSource() {
|
||||
String key = "DataSource.backend";
|
||||
|
||||
try {
|
||||
return DataSource.DataSourceType.valueOf(configFile.getString(key).toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
@ -490,48 +435,33 @@ public void mergeConfig() {
|
||||
* player that join the server, so player has a restricted access
|
||||
*/
|
||||
public static Boolean getRestrictedIp(String name, String ip) {
|
||||
|
||||
|
||||
Iterator<String> iter = getRestrictedIp.iterator();
|
||||
|
||||
/* setup a few boolean variables to test the parameters */
|
||||
Boolean trueonce = false;
|
||||
Boolean namefound = false;
|
||||
|
||||
while (iter.hasNext()) {
|
||||
String[] args = iter.next().split(";");
|
||||
|
||||
String testname = args[0];
|
||||
String testip = args[1];
|
||||
|
||||
/** Changing this logic to be more customized
|
||||
* test each case against the entire
|
||||
* list not just the first one in the list.*/
|
||||
|
||||
/* Fist Check the name */
|
||||
if(testname.equalsIgnoreCase(name) ) {
|
||||
namefound = true;
|
||||
/* Check to see if the IP is the same */
|
||||
if(testip.equalsIgnoreCase(ip)) {
|
||||
trueonce = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
// if the name is not found in the list let the user pass they are not being monitored
|
||||
namefound = true;
|
||||
if(testip.equalsIgnoreCase(ip)) {
|
||||
trueonce = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
if ( namefound == false){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// if the name and IP was found once in the list let the user pass they are in the config
|
||||
if ( trueonce == true ){
|
||||
return true;
|
||||
// otherwise nip them in the bud and THEY SHALL NOT PASS!
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads the configuration from disk
|
||||
*
|
||||
@ -545,7 +475,7 @@ public void mergeConfig() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final void reload() {
|
||||
load();
|
||||
loadDefaults(file.getName());
|
||||
@ -599,11 +529,9 @@ public void mergeConfig() {
|
||||
boolean success = save();
|
||||
options().copyDefaults(false);
|
||||
options().copyHeader(false);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears current configuration defaults
|
||||
*/
|
||||
@ -611,7 +539,7 @@ public void mergeConfig() {
|
||||
setDefaults(new MemoryConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Check loaded defaults against current configuration
|
||||
*
|
||||
* @return false When all defaults aren't present in config
|
||||
@ -622,17 +550,9 @@ public void mergeConfig() {
|
||||
}
|
||||
return getKeys(true).containsAll(getDefaults().getKeys(true));
|
||||
}
|
||||
/*
|
||||
public static Settings getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new Settings();
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
*/
|
||||
|
||||
public static String checkLang(String lang) {
|
||||
for(messagesLang language: messagesLang.values()) {
|
||||
//System.out.println(language.toString());
|
||||
if(lang.toLowerCase().contains(language.toString())) {
|
||||
ConsoleLogger.info("Set Language: "+lang);
|
||||
return lang;
|
||||
@ -641,8 +561,9 @@ public void mergeConfig() {
|
||||
ConsoleLogger.info("Set Default Language: En ");
|
||||
return "en";
|
||||
}
|
||||
|
||||
|
||||
public enum messagesLang {
|
||||
en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,12 @@ import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class Spawn extends CustomConfiguration {
|
||||
|
||||
|
||||
private static Spawn spawn;
|
||||
private static List<String> emptyList = new ArrayList<String>();
|
||||
|
||||
@ -19,7 +23,7 @@ public class Spawn extends CustomConfiguration {
|
||||
save();
|
||||
saveDefault();
|
||||
}
|
||||
|
||||
|
||||
private void saveDefault() {
|
||||
if (!contains("spawn")) {
|
||||
set("spawn", emptyList);
|
||||
@ -31,7 +35,6 @@ public class Spawn extends CustomConfiguration {
|
||||
set("spawn.pitch", "");
|
||||
save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Spawn getInstance() {
|
||||
@ -40,7 +43,7 @@ public class Spawn extends CustomConfiguration {
|
||||
}
|
||||
return spawn;
|
||||
}
|
||||
|
||||
|
||||
public boolean setSpawn(Location location) {
|
||||
try {
|
||||
set("spawn.world", location.getWorld().getName());
|
||||
@ -55,7 +58,7 @@ public class Spawn extends CustomConfiguration {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation() {
|
||||
try {
|
||||
if (this.getString("spawn.world").isEmpty() || this.getString("spawn.world") == "") return null;
|
||||
@ -65,4 +68,5 @@ public class Spawn extends CustomConfiguration {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SpoutCfg extends CustomConfiguration{
|
||||
|
||||
|
||||
private static SpoutCfg instance = null;
|
||||
|
||||
public SpoutCfg(File file)
|
||||
@ -21,7 +21,6 @@ public class SpoutCfg extends CustomConfiguration{
|
||||
@SuppressWarnings("serial")
|
||||
private void loadDefaults() {
|
||||
this.set("Spout GUI enabled", true);
|
||||
//Login:
|
||||
this.set("LoginScreen.enabled", true);
|
||||
this.set("LoginScreen.exit button", "Quit");
|
||||
this.set("LoginScreen.exit message", "Good Bye");
|
||||
@ -30,16 +29,13 @@ public class SpoutCfg extends CustomConfiguration{
|
||||
this.set("LoginScreen.text", new ArrayList<String>() {{
|
||||
add("Sample text");
|
||||
add("Change this at spout.yml");
|
||||
add("------------------");
|
||||
add("AuthMe Reloaded by d4rkwarriors");
|
||||
add("--- AuthMe Reloaded by ---");
|
||||
add("d4rkwarriors and Xephi59");
|
||||
}});
|
||||
//Registration:
|
||||
//this.set("RegistrationScreen.enabled",true);
|
||||
|
||||
}
|
||||
|
||||
public static SpoutCfg getInstance() {
|
||||
if (instance == null) instance = new SpoutCfg(new File("plugins/AuthMe", "spout.yml"));
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,17 +43,14 @@ public class MessageTask implements Runnable {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
player.sendMessage(msg);
|
||||
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
BukkitTask late = sched.runTaskLater(plugin, this, interval * 20);
|
||||
if(LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late.getTaskId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,13 +50,11 @@ public class TimeoutTask implements Runnable {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
|
||||
player.getServer().getScheduler().cancelTask(inv.getTimeoutTaskId());
|
||||
|
||||
if(playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ Security:
|
||||
console:
|
||||
noConsoleSpam: false
|
||||
removePassword: true
|
||||
logConsole: false
|
||||
captcha:
|
||||
useCaptcha: false
|
||||
maxLoginTry: 5
|
||||
|
@ -3,7 +3,7 @@ author: darkwarriros,Xephi
|
||||
website: http://www.multiplayer-italia.com/
|
||||
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
|
||||
main: uk.org.whoami.authme.AuthMe
|
||||
version: 2.7.13b2
|
||||
version: 2.7.14
|
||||
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag]
|
||||
commands:
|
||||
register:
|
||||
@ -134,4 +134,7 @@ permissions:
|
||||
default: op
|
||||
authme.vip:
|
||||
description: Allow vip slot when the server is full
|
||||
default: op
|
||||
authme.admin.purgebannedplayers:
|
||||
description: Purge banned players
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user