Update 3.3.3

This commit is contained in:
Xephi 2014-02-20 12:54:10 +01:00
parent 5a089fa690
commit 4e7e9e6cb4
21 changed files with 315 additions and 127 deletions

View File

@ -24,12 +24,12 @@
</plugin>
</plugins>
</build>
<version>3.3.2</version>
<version>3.3.3</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.2-R0.3-SNAPSHOT</version>
<version>1.7.2-R0.3</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>

View File

@ -720,7 +720,7 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
}
public Location getSpawnLocation(World world) {
public Location getSpawnLocation(String name, World world) {
Location spawnLoc = world.getSpawnLocation();
if (multiverse != null && Settings.multiverse) {
try {
@ -733,8 +733,10 @@ public class AuthMe extends JavaPlugin {
if (essentialsSpawn != null) {
spawnLoc = essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
spawnLoc = Spawn.getInstance().getLocation();
if (Spawn.getInstance().getSpawn() != null)
spawnLoc = Spawn.getInstance().getSpawn();
if (!database.isAuthAvailable(name) && Spawn.getInstance().getFirstSpawn() != null)
spawnLoc = Spawn.getInstance().getFirstSpawn();
return spawnLoc;
}

View File

@ -19,60 +19,63 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.settings.Settings;
public class Utils {
private String currentGroup;
private static Utils singleton;
int id;
public AuthMe plugin;
private String currentGroup;
private static Utils singleton;
int id;
public AuthMe plugin;
public Utils(AuthMe plugin) {
this.plugin = plugin;
}
public Utils(AuthMe plugin) {
this.plugin = plugin;
}
public void setGroup(Player player, groupType group) {
if (!player.isOnline())
return;
if(!Settings.isPermissionCheckEnabled)
return;
if(plugin.permission == null)
return;
try {
currentGroup = plugin.permission.getPrimaryGroup(player);
} catch (UnsupportedOperationException e) {
ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
plugin.permission = null;
return;
}
World world = null;
String name = player.getName();
switch(group) {
case UNREGISTERED: {
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, Settings.unRegisteredGroup);
break;
}
case REGISTERED: {
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, Settings.getRegisteredGroup);
break;
}
case NOTLOGGEDIN: {
if(!useGroupSystem()) break;
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, Settings.getUnloggedinGroup);
break;
}
case LOGGEDIN: {
if(!useGroupSystem()) break;
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
if (limbo == null) break;
String realGroup = limbo.getGroup();
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, realGroup);
break;
}
}
return;
}
public void setGroup(Player player, groupType group) {
setGroup(player.getName(), group);
}
public void setGroup(String player, groupType group) {
if(!Settings.isPermissionCheckEnabled)
return;
if(plugin.permission == null)
return;
try {
World world = null;
currentGroup = plugin.permission.getPrimaryGroup(world, player);
} catch (UnsupportedOperationException e) {
ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
plugin.permission = null;
return;
}
World world = null;
String name = player;
switch(group) {
case UNREGISTERED: {
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, Settings.unRegisteredGroup);
break;
}
case REGISTERED: {
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, Settings.getRegisteredGroup);
break;
}
case NOTLOGGEDIN: {
if(!useGroupSystem()) break;
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, Settings.getUnloggedinGroup);
break;
}
case LOGGEDIN: {
if(!useGroupSystem()) break;
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name.toLowerCase());
if (limbo == null) break;
String realGroup = limbo.getGroup();
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, realGroup);
break;
}
}
return;
}
public boolean addNormal(Player player, String group) {
if(!useGroupSystem()){

View File

@ -98,7 +98,9 @@ public class PlayerAuth {
}
public String getIp() {
return ip;
if (ip == null || ip.isEmpty())
ip = "127.0.0.1";
return ip;
}
public String getNickname() {
@ -145,6 +147,12 @@ public class PlayerAuth {
this.z = d;
}
public long getLastLogin() {
try {
if (Long.valueOf(lastLogin) == null)
lastLogin = 0L;
} catch (NullPointerException e) {
lastLogin = 0L;
}
return lastLogin;
}

View File

@ -89,7 +89,7 @@ public class LimboCache {
gameMode = GameMode.SURVIVAL;
}
if(player.isDead()) {
loc = plugin.getSpawnLocation(player.getWorld());
loc = plugin.getSpawnLocation(player.getName().toLowerCase(), player.getWorld());
}
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
}

View File

@ -13,6 +13,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -22,13 +23,16 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
import fr.xephi.authme.Utils.groupType;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.converter.FlatToSql;
import fr.xephi.authme.converter.FlatToSqlite;
import fr.xephi.authme.converter.RakamakConverter;
@ -36,11 +40,14 @@ import fr.xephi.authme.converter.RoyalAuthConverter;
import fr.xephi.authme.converter.newxAuthToFlat;
import fr.xephi.authme.converter.oldxAuthToFlat;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
import fr.xephi.authme.settings.SpoutCfg;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
public class AdminCommand implements CommandExecutor {
@ -385,6 +392,19 @@ public class AdminCommand implements CommandExecutor {
ConsoleLogger.showError(ex.getMessage());
}
return true;
} else if (args[0].equalsIgnoreCase("setfirstspawn")) {
try {
if (sender instanceof Player) {
if (Spawn.getInstance().setFirstSpawn(((Player) sender).getLocation()))
sender.sendMessage("[AuthMe] Correctly define new first spawn");
else sender.sendMessage("[AuthMe] SetFirstSpawn fail , please retry");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
} catch (NullPointerException ex) {
ConsoleLogger.showError(ex.getMessage());
}
return true;
} else if (args[0].equalsIgnoreCase("purgebannedplayers")) {
List<String> bannedPlayers = new ArrayList<String>();
for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) {
@ -413,8 +433,8 @@ public class AdminCommand implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("spawn")) {
try {
if (sender instanceof Player) {
if (Spawn.getInstance().getLocation() != null)
((Player) sender).teleport(Spawn.getInstance().getLocation());
if (Spawn.getInstance().getSpawn() != null)
((Player) sender).teleport(Spawn.getInstance().getSpawn());
else sender.sendMessage("[AuthMe] Spawn fail , please try to define the spawn");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
@ -423,6 +443,19 @@ public class AdminCommand implements CommandExecutor {
ConsoleLogger.showError(ex.getMessage());
}
return true;
} else if (args[0].equalsIgnoreCase("firstspawn")) {
try {
if (sender instanceof Player) {
if (Spawn.getInstance().getFirstSpawn() != null)
((Player) sender).teleport(Spawn.getInstance().getFirstSpawn());
else sender.sendMessage("[AuthMe] Spawn fail , please try to define the first spawn");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
} catch (NullPointerException ex) {
ConsoleLogger.showError(ex.getMessage());
}
return true;
} else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
if (args.length != 3) {
sender.sendMessage("Usage: /authme changepassword playername newpassword");
@ -467,8 +500,36 @@ public class AdminCommand implements CommandExecutor {
m._(sender, "error");
return true;
}
Player target = Bukkit.getPlayer(name);
PlayerCache.getInstance().removePlayer(name);
sender.sendMessage("unregistered");
Utils.getInstance().setGroup(name, groupType.UNREGISTERED);
if (target != null) {
if (target.isOnline()) {
if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(name, target.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
target.teleport(tpEvent.getTo());
}
}
LimboCache.getInstance().addLimboPlayer(target);
int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) {
int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("reg_msg"), interval)));
m._(target, "unregistered");
} else {
// Player isn't online, do nothing else
}
} else {
// Player does not exist, do nothing else
}
m._(sender, "unregistered");
ConsoleLogger.info(args[1] + " unregistered");
return true;
} else if (args[0].equalsIgnoreCase("purgelastpos")){

View File

@ -59,6 +59,12 @@ public class EmailCommand implements CommandExecutor {
m._(player, "usage_email_add");
return true;
}
if(Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return true;
}
}
if(args[1].equals(args[2]) && PlayerCache.getInstance().isAuthenticated(name)) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
if (auth.getEmail() == null || (!auth.getEmail().equals("your@email.com") && !auth.getEmail().isEmpty())) {
@ -87,6 +93,12 @@ public class EmailCommand implements CommandExecutor {
}
}
} else if(args[0].equalsIgnoreCase("change") && args.length == 3 ) {
if(Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return true;
}
}
if(PlayerCache.getInstance().isAuthenticated(name)) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
if (auth.getEmail() == null || auth.getEmail().equals("your@email.com") || auth.getEmail().isEmpty()) {

View File

@ -23,7 +23,6 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
@ -73,12 +72,7 @@ public class LogoutCommand implements CommandExecutor {
PlayerCache.getInstance().removePlayer(name);
if (Settings.isTeleportToSpawnEnabled) {
Location spawnLoc = player.getWorld().getSpawnLocation();
if (plugin.essentialsSpawn != null) {
spawnLoc = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
spawnLoc = Spawn.getInstance().getLocation();
Location spawnLoc = plugin.getSpawnLocation(name, player.getWorld());
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {

View File

@ -72,12 +72,21 @@ public class UnregisterCommand implements CommandExecutor {
return true;
}
if(Settings.isForcedRegistrationEnabled) {
if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
player.teleport(tpEvent.getTo());
}
}
player.getInventory().setContents(new ItemStack[36]);
player.getInventory().setArmorContents(new ItemStack[4]);
player.saveData();
PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
if (!Settings.getRegisteredGroup.isEmpty())
Utils.getInstance().setGroup(player, groupType.UNREGISTERED);
LimboCache.getInstance().addLimboPlayer(player);
Utils.getInstance().setGroup(player, groupType.UNREGISTERED);
int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
@ -86,14 +95,11 @@ public class UnregisterCommand implements CommandExecutor {
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("reg_msg"), interval)));
if(!Settings.unRegisteredGroup.isEmpty()){
Utils.getInstance().setGroup(player, Utils.groupType.UNREGISTERED);
}
m._(player, "unregistered");
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
if(plugin.notifications != null) {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
}
m._(player, "unregistered");
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
if(plugin.notifications != null) {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
}
return true;
}
if(!Settings.unRegisteredGroup.isEmpty()){
@ -114,7 +120,7 @@ public class UnregisterCommand implements CommandExecutor {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
}
if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(player.getWorld());
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {

View File

@ -14,7 +14,7 @@ public class CacheDataSource implements DataSource {
private DataSource source;
public AuthMe plugin;
private final HashMap<String, PlayerAuth> cache = new HashMap<String, PlayerAuth>();
private HashMap<String, PlayerAuth> cache = new HashMap<String, PlayerAuth>();
public CacheDataSource(AuthMe plugin, DataSource source) {
this.plugin = plugin;
@ -23,16 +23,18 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean isAuthAvailable(String user) {
return cache.containsKey(user) ? true : source.isAuthAvailable(user);
if (cache.containsKey(user.toLowerCase())) return true;
return source.isAuthAvailable(user.toLowerCase());
}
@Override
public synchronized PlayerAuth getAuth(String user) {
if(cache.containsKey(user)) {
return cache.get(user);
if(cache.containsKey(user.toLowerCase())) {
return cache.get(user.toLowerCase());
} else {
PlayerAuth auth = source.getAuth(user);
cache.put(user, auth);
PlayerAuth auth = source.getAuth(user.toLowerCase());
if (auth != null)
cache.put(user.toLowerCase(), auth);
return auth;
}
}
@ -49,7 +51,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
if (source.updatePassword(auth)) {
cache.get(auth.getNickname()).setHash(auth.getHash());
if (cache.containsKey(auth.getNickname().toLowerCase()))
cache.get(auth.getNickname()).setHash(auth.getHash());
return true;
}
return false;
@ -58,8 +61,10 @@ public class CacheDataSource implements DataSource {
@Override
public boolean updateSession(PlayerAuth auth) {
if (source.updateSession(auth)) {
cache.get(auth.getNickname()).setIp(auth.getIp());
cache.get(auth.getNickname()).setLastLogin(auth.getLastLogin());
if (cache.containsKey(auth.getNickname().toLowerCase())) {
cache.get(auth.getNickname()).setIp(auth.getIp());
cache.get(auth.getNickname()).setLastLogin(auth.getLastLogin());
}
return true;
}
return false;
@ -68,10 +73,12 @@ public class CacheDataSource implements DataSource {
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
if (source.updateQuitLoc(auth)) {
cache.get(auth.getNickname()).setQuitLocX(auth.getQuitLocX());
cache.get(auth.getNickname()).setQuitLocY(auth.getQuitLocY());
cache.get(auth.getNickname()).setQuitLocZ(auth.getQuitLocZ());
cache.get(auth.getNickname()).setWorld(auth.getWorld());
if (cache.containsKey(auth.getNickname().toLowerCase())) {
cache.get(auth.getNickname()).setQuitLocX(auth.getQuitLocX());
cache.get(auth.getNickname()).setQuitLocY(auth.getQuitLocY());
cache.get(auth.getNickname()).setQuitLocZ(auth.getQuitLocZ());
cache.get(auth.getNickname()).setWorld(auth.getWorld());
}
return true;
}
return false;
@ -110,8 +117,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean removeAuth(String user) {
if (source.removeAuth(user)) {
cache.remove(user);
if (source.removeAuth(user.toLowerCase())) {
cache.remove(user.toLowerCase());
return true;
}
return false;
@ -125,6 +132,7 @@ public class CacheDataSource implements DataSource {
@Override
public void reload() {
cache.clear();
source.reload();
for (Player player : plugin.getServer().getOnlinePlayers()) {
String user = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(user)) {
@ -141,7 +149,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updateEmail(PlayerAuth auth) {
if(source.updateEmail(auth)) {
cache.get(auth.getNickname()).setEmail(auth.getEmail());
if (cache.containsKey(auth.getNickname().toLowerCase()))
cache.get(auth.getNickname()).setEmail(auth.getEmail());
return true;
}
return false;
@ -150,7 +159,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updateSalt(PlayerAuth auth) {
if(source.updateSalt(auth)) {
cache.get(auth.getNickname()).setSalt(auth.getSalt());
if (cache.containsKey(auth.getNickname().toLowerCase()))
cache.get(auth.getNickname()).setSalt(auth.getSalt());
return true;
}
return false;

View File

@ -604,6 +604,17 @@ public class MySQLDataSource implements DataSource {
@Override
public void reload() {
try {
reconnect(true);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
private void close(Statement st) {
@ -749,7 +760,7 @@ public class MySQLDataSource implements DataSource {
} catch (Exception te) {
try {
con = null;
reconnect();
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
@ -765,7 +776,7 @@ public class MySQLDataSource implements DataSource {
throw new AssertionError(ae.getMessage());
try {
con = null;
reconnect();
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
@ -781,7 +792,7 @@ public class MySQLDataSource implements DataSource {
return con;
}
private synchronized void reconnect() throws ClassNotFoundException, SQLException, TimeoutException {
private synchronized void reconnect(boolean reload) throws ClassNotFoundException, SQLException, TimeoutException {
conPool.dispose();
Class.forName("com.mysql.jdbc.Driver");
MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
@ -791,7 +802,8 @@ public class MySQLDataSource implements DataSource {
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
if(!reload)
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
}

View File

@ -366,7 +366,7 @@ public class AuthMePlayerListener implements Listener {
}
int radius = Settings.getMovementRadius;
Location spawn = plugin.getSpawnLocation(player.getWorld());
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
event.getPlayer().teleport(spawn);
@ -542,9 +542,9 @@ public class AuthMePlayerListener implements Listener {
}
Player player = event.getPlayer();
World world = player.getWorld();
Location spawnLoc = plugin.getSpawnLocation(world);
gm = player.getGameMode();
final String name = player.getName().toLowerCase();
Location spawnLoc = plugin.getSpawnLocation(name, world);
gm = player.getGameMode();
gameMode.put(name, gm);
BukkitScheduler sched = plugin.getServer().getScheduler();
@ -588,6 +588,8 @@ public class AuthMePlayerListener implements Listener {
PlayerCache.getInstance().addPlayer(auth);
}
m._(player, "valid_session");
// Restore Permission Group
utils.setGroup(player, Utils.groupType.LOGGEDIN);
return;
} else if (!Settings.sessionExpireOnIpChange){
GameMode gM = gameMode.get(name);
@ -646,9 +648,20 @@ public class AuthMePlayerListener implements Listener {
if(!Settings.unRegisteredGroup.isEmpty()){
utils.setGroup(player, Utils.groupType.UNREGISTERED);
}
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);
if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
player.teleport(tpEvent.getTo());
}
}
if (!Settings.isForcedRegistrationEnabled) {
return;
}
}
if(Settings.protectInventoryBeforeLogInEnabled) {
try {
@ -763,8 +776,8 @@ public class AuthMePlayerListener implements Listener {
playerBackup.removeCache(name);
}
}
PlayerCache.getInstance().removePlayer(name);
try {
PlayerCache.getInstance().removePlayer(name);
PlayersLogs.players.remove(player.getName());
PlayersLogs.getInstance().save();
player.getVehicle().eject();
@ -1086,7 +1099,7 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled)
return;
Location spawn = plugin.getSpawnLocation(player.getWorld());
Location spawn = plugin.getSpawnLocation(name, player.getWorld());
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name,spawn.getX(),spawn.getY(),spawn.getZ(),spawn.getWorld().getName());
try {

View File

@ -194,19 +194,19 @@ public class AsyncronousLogin {
if (auth == null) {
return;
}
if (this.database.getAllAuthsByName(auth).isEmpty() || this.database.getAllAuthsByName(auth) == null) {
List<String> auths = this.database.getAllAuthsByName(auth);
if (auths.isEmpty() || auths == null) {
return;
}
if (this.database.getAllAuthsByName(auth).size() == 1) {
if (auths.size() == 1) {
return;
}
List<String> accountList = this.database.getAllAuthsByName(auth);
String message = "[AuthMe] ";
int i = 0;
for (String account : accountList) {
for (String account : auths) {
i++;
message = message + account;
if (i != accountList.size()) {
if (i != auths.size()) {
message = message + ", ";
} else {
message = message + ".";
@ -215,7 +215,7 @@ public class AsyncronousLogin {
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has "
+ accountList.size() + " accounts");
+ auths.size() + " accounts");
player.sendMessage(message);
}
}

View File

@ -68,7 +68,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
}
protected void teleportToSpawn() {
Location spawnL = plugin.getSpawnLocation(player.getWorld());
Location spawnL = plugin.getSpawnLocation(name, player.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
@ -187,7 +187,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
if(Settings.useWelcomeMessage)
if(Settings.broadcastWelcomeMessage) {
for (String s : Settings.welcomeMsg) {
Bukkit.getServer().broadcastMessage(s);
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
}
} else {
for (String s : Settings.welcomeMsg) {

View File

@ -66,17 +66,24 @@ public class AsyncronousRegister {
}
if(Settings.getmaxRegPerIp > 0 ){
if(!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp) {
if(!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) {
m._(player, "max_reg");
allowRegister = false;
}
}
}
public void process() {
preRegister();
if(!allowRegister) return;
if(!email.isEmpty() && email != "") {
if(Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return;
}
}
emailRegister();
return;
}

View File

@ -49,7 +49,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = plugin.getSpawnLocation(world);
Location loca = plugin.getSpawnLocation(name, world);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {

View File

@ -44,7 +44,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = plugin.getSpawnLocation(world);
Location loca = plugin.getSpawnLocation(name, world);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {

View File

@ -1,9 +1,6 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -14,7 +11,6 @@ import org.bukkit.Location;
public class Spawn extends CustomConfiguration {
private static Spawn spawn;
private static List<String> emptyList = new ArrayList<String>();
public Spawn() {
super(new File("./plugins/AuthMe/spawn.yml"));
@ -26,7 +22,6 @@ public class Spawn extends CustomConfiguration {
private void saveDefault() {
if (!contains("spawn")) {
set("spawn", emptyList);
set("spawn.world", "");
set("spawn.x", "");
set("spawn.y", "");
@ -35,6 +30,15 @@ public class Spawn extends CustomConfiguration {
set("spawn.pitch", "");
save();
}
if (!contains("firstspawn")) {
set("firstspawn.world", "");
set("firstspawn.x", "");
set("firstspawn.y", "");
set("firstspawn.z", "");
set("firstspawn.yaw", "");
set("firstspawn.pitch", "");
save();
}
}
public static Spawn getInstance() {
@ -59,7 +63,27 @@ public class Spawn extends CustomConfiguration {
}
}
public boolean setFirstSpawn(Location location) {
try {
set("firstspawn.world", location.getWorld().getName());
set("firstspawn.x", location.getX());
set("firstspawn.y", location.getY());
set("firstspawn.z", location.getZ());
set("firstspawn.yaw", location.getYaw());
set("firstspawn.pitch", location.getPitch());
save();
return true;
} catch (NullPointerException npe) {
return false;
}
}
@Deprecated
public Location getLocation() {
return getSpawn();
}
public Location getSpawn() {
try {
if (this.getString("spawn.world").isEmpty() || this.getString("spawn.world") == "") return null;
Location location = new Location(Bukkit.getWorld(this.getString("spawn.world")), this.getDouble("spawn.x"), this.getDouble("spawn.y"), this.getDouble("spawn.z"), Float.parseFloat(this.getString("spawn.yaw")), Float.parseFloat(this.getString("spawn.pitch")));
@ -70,5 +94,17 @@ public class Spawn extends CustomConfiguration {
return null;
}
}
public Location getFirstSpawn() {
try {
if (this.getString("firstspawn.world").isEmpty() || this.getString("firstspawn.world") == "") return null;
Location location = new Location(Bukkit.getWorld(this.getString("firstspawn.world")), this.getDouble("firstspawn.x"), this.getDouble("firstspawn.y"), this.getDouble("firstspawn.z"), Float.parseFloat(this.getString("firstspawn.yaw")), Float.parseFloat(this.getString("firstspawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
return null;
}
}
}

View File

@ -64,7 +64,6 @@ public class MySQLThread extends Thread implements DataSource {
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
this.columnID = Settings.getMySQLColumnId;
try {
this.connect();
this.setup();
@ -635,6 +634,17 @@ public class MySQLThread extends Thread implements DataSource {
@Override
public void reload() {
try {
reconnect(true);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
private void close(Statement st) {
@ -780,7 +790,7 @@ public class MySQLThread extends Thread implements DataSource {
} catch (Exception te) {
try {
con = null;
reconnect();
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
@ -796,7 +806,7 @@ public class MySQLThread extends Thread implements DataSource {
throw new AssertionError(ae.getMessage());
try {
con = null;
reconnect();
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
@ -812,7 +822,7 @@ public class MySQLThread extends Thread implements DataSource {
return con;
}
private synchronized void reconnect() throws ClassNotFoundException, SQLException, TimeoutException {
private synchronized void reconnect(boolean reload) throws ClassNotFoundException, SQLException, TimeoutException {
conPool.dispose();
Class.forName("com.mysql.jdbc.Driver");
MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
@ -822,7 +832,8 @@ public class MySQLThread extends Thread implements DataSource {
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
if (!reload)
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
}

View File

@ -3,7 +3,7 @@ author: Xephi59
website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: fr.xephi.authme.AuthMe
version: 3.3.2
version: 3.3.3
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
commands:
register:
@ -158,4 +158,10 @@ permissions:
default: op
authme.admin.royalauth:
description: Import RoyalAuth database into AuthMe
default: op
authme.admin.setfirstspawn:
description: Set the AuthMe First Spawn Point
default: op
authme.admin.firstspawn:
description: Teleport to AuthMe First Spawn Point
default: op

View File

@ -1,4 +1,11 @@
spawn:
world: ''
x: ''
y: ''
z: ''
yaw: ''
pitch: ''
firstspawn:
world: ''
x: ''
y: ''