Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 306-command-service

This commit is contained in:
ljacqu 2015-12-23 18:09:21 +01:00
commit a9fc658db0
23 changed files with 335 additions and 295 deletions

203
newPlugin.yml Normal file
View File

@ -0,0 +1,203 @@
name: ${pluginName}
authors: [${pluginAuthors}]
website: ${project.url}
description: ${project.description}
main: ${mainClass}
version: ${project.version}-b${buildNumber}
softdepend:
- Vault
- PermissionsBukkit
- PermissionsEX
- EssentialsGroupManager
- Multiverse-Core
- Essentials
- EssentialsSpawn
- ProtocolLib
commands:
authme:
description: AuthMe admin commands
usage: '/authme reload|register playername password|changepassword playername password|unregister playername|version|converter datatype'
permission: authme.admin
register:
description: Register an account
usage: /register password confirmpassword
aliases: [reg]
permission: authme.player.register
login:
description: Login into a account
usage: /login password
aliases: [l,log]
permission: authme.player.login
changepassword:
description: Change password of a account
usage: /changepassword oldPassword newPassword
permission: authme.player.changepassword
logout:
description: Logout from the server
usage: /logout
permission: authme.player.logout
unregister:
description: unregister your account
usage: /unregister password
permission: authme.player.unregister
email:
description: Add Email or recover password
usage: '/email add your@email.com your@email.com|change oldEmail newEmail|recovery your@email.com'
permission: authme.player.email
captcha:
description: Captcha command
usage: /captcha theCaptcha
permission: authme.player.captcha
permissions:
authme.canbeforced:
description: Allow the user to be forced-logged via API
default: true
authme.player:
description: Gives access to all authme player commands
default: true
children:
authme.player.login: true
authme.player.logout: true
authme.player.register: true
authme.player.unregister: true
authme.player.changepassword: true
authme.player.captcha: true
authme.player.email: true
authme.player.register:
description: Register your account
default: false
authme.player.unregister:
description: Unregister your account
default: false
authme.player.login:
description: Login into your account
default: false
authme.player.logout:
description: Logout from your account
default: false
authme.player.changepassword:
description: Change password of your account
default: false
authme.player.email:
description: Gives access to player's email commands
default: false
children:
authme.player.email.add: true
authme.player.email.change: true
authme.player.email.recover: true
authme.player.email.add:
description: Add an email to your account
default: false
authme.player.email.change:
description: Change email of your account
default: false
authme.player.email.recover:
description: Recover your account
default: false
authme.player.captcha:
description: Captcha command
default: false
authme.admin:
description: Gives access to all authme admin commands
default: op
children:
authme.admin.forcelogin: true
authme.admin.forcelogout: true
authme.admin.register: true
authme.admin.unregister: true
authme.admin.changemail: true
authme.admin.changepassword: true
authme.admin.lastlogin: true
authme.admin.accounts: true
authme.admin.getemail: true
authme.admin.getip: true
authme.admin.resetposition: true
authme.admin.setspawn: true
authme.admin.spawn: true
authme.admin.setfirstspawn: true
authme.admin.firstspawn: true
authme.admin.purge: true
authme.admin.purgebannedplayers: true
authme.admin.purgelastpos: true
authme.admin.converter: true
authme.admin.reload: true
authme.admin.switchantibot: true
authme.admin.seeotheraccounts: true
authme.admin.register:
description: Register an account
default: false
authme.admin.unregister:
description: Unregister an account
default: false
authme.admin.forcelogin:
description: Force login for that player
default: false
authme.admin.forcelogout:
description: Force logout for that player
default: false
authme.admin.changepassword:
description: Change the password of an account
default: false
authme.admin.getemail:
description: Get last email about a player
default: false
authme.admin.changeemail:
description: Change a player email
default: false
authme.admin.accounts:
description: Display Players Accounts
default: false
authme.admin.seeotheraccounts:
description: Display other accounts about a player when he logs in
default: false
authme.admin.lastlogin:
description: Get last login date about a player
default: false
authme.admin.getip:
description: Get IP from a player (fake and real)
default: false
authme.admin.resetposition:
description: Reset last position for a player
default: false
authme.admin.setspawn:
description: Set the AuthMe spawn point
default: false
authme.admin.spawn:
description: Teleport to AuthMe spawn point
default: false
authme.admin.setfirstspawn:
description: Set the AuthMe First Spawn Point
default: false
authme.admin.firstspawn:
description: Teleport to AuthMe First Spawn Point
default: false
authme.admin.switchantibot:
description: Switch AntiBot mode on/off
default: false
authme.admin.purge:
description: Database purge command
default: false
authme.admin.purgebannedplayers:
description: Purge banned players
default: false
authme.admin.purgelastpos:
description: Purge last pos of players
default: false
authme.admin.converter:
description: Allow the /authme converter command
default: false
authme.admin.reload:
description: Reload the plugin
default: false
authme.vip:
description: Allow vip slot when the server is full
default: false
authme.bypassantibot:
description: Bypass the AntiBot check
default: false
authme.allowmultipleaccounts:
description: Allow more accounts for same ip
default: false
authme.bypassforcesurvival:
description: Bypass all ForceSurvival features
default: false

View File

@ -81,39 +81,18 @@ import java.util.logging.Logger;
*/ */
public class AuthMe extends JavaPlugin { public class AuthMe extends JavaPlugin {
/** // Defines the name of the plugin.
* Defines the name of the plugin.
*/
private static final String PLUGIN_NAME = "AuthMeReloaded"; private static final String PLUGIN_NAME = "AuthMeReloaded";
// Default version and build number values;
private static String pluginVersion = "N/D"; private static String pluginVersion = "N/D";
private static String pluginBuildNumber = "Unknown"; private static String pluginBuildNumber = "Unknown";
// Private Instances
private static AuthMe plugin; private static AuthMe plugin;
private static Server server; private static Server server;
private static Wrapper wrapper = Wrapper.getInstance(); private static Wrapper wrapper = Wrapper.getInstance();
private Management management; private Management management;
public NewAPI api;
public SendMailSSL mail;
public DataManager dataManager;
public DataSource database;
public OtherAccounts otherAccounts;
public Location essentialsSpawn;
// Hooks TODO: Move into modules
public Essentials ess;
public MultiverseCore multiverse;
public CombatTagPlus combatTagPlus;
public AuthMeInventoryPacketAdapter inventoryProtector;
// Data maps and stuff
// TODO: Move into a manager
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
private CommandHandler commandHandler = null; private CommandHandler commandHandler = null;
private PermissionsManager permsMan = null; private PermissionsManager permsMan = null;
private Settings settings; private Settings settings;
@ -121,9 +100,34 @@ public class AuthMe extends JavaPlugin {
private JsonCache playerBackup; private JsonCache playerBackup;
private ModuleManager moduleManager; private ModuleManager moduleManager;
// Public Instances
public NewAPI api;
public SendMailSSL mail;
public DataManager dataManager;
public DataSource database;
public OtherAccounts otherAccounts;
public Location essentialsSpawn;
/*
* Plugin Hooks
* TODO: Move into modules
*/
public Essentials ess;
public MultiverseCore multiverse;
public CombatTagPlus combatTagPlus;
public AuthMeInventoryPacketAdapter inventoryProtector;
/*
* Maps and stuff
* TODO: Clean up and Move into a manager
*/
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
/** /**
* Returns the plugin's instance. * Get the plugin's instance.
*
* @return AuthMe * @return AuthMe
*/ */
public static AuthMe getInstance() { public static AuthMe getInstance() {
@ -132,52 +136,46 @@ public class AuthMe extends JavaPlugin {
/** /**
* Get the plugin's name. * Get the plugin's name.
* * @return The plugin's name.
* @return Plugin name.
*/ */
public static String getPluginName() { public static String getPluginName() {
return PLUGIN_NAME; return PLUGIN_NAME;
} }
/** /**
* Get the current installed AuthMeReloaded version name. * Get the plugin's version.
* * @return The plugin's version.
* @return The version name of the currently installed AuthMeReloaded instance.
*/ */
public static String getPluginVersion() { public static String getPluginVersion() {
return pluginVersion; return pluginVersion;
} }
/** /**
* Get the current installed AuthMeReloaded version code. * Get the plugin's build number.
* * @return The plugin's build number.
* @return The version code of the currently installed AuthMeReloaded instance.
*/ */
public static String getPluginBuildNumber() { public static String getPluginBuildNumber() {
return pluginBuildNumber; return pluginBuildNumber;
} }
/** /**
* Returns the plugin's Settings. * Get the plugin's Settings.
* * @return Plugin's settings.
* @return Settings
*/ */
public Settings getSettings() { public Settings getSettings() {
return settings; return settings;
} }
/** /**
* Returns the Messages instance. * Get the Messages instance.
* * @return Plugin's messages.
* @return Messages
*/ */
public Messages getMessages() { public Messages getMessages() {
return messages; return messages;
} }
// Get version and build number of the plugin // Get version and build number of the plugin
// TODO: enhance this private void setPluginInfos() {
private void setupConstants() {
String versionRaw = this.getDescription().getVersion(); String versionRaw = this.getDescription().getVersion();
int index = versionRaw.lastIndexOf("-"); int index = versionRaw.lastIndexOf("-");
if (index != -1) { if (index != -1) {
@ -191,7 +189,6 @@ public class AuthMe extends JavaPlugin {
/** /**
* Method called when the server enables the plugin. * Method called when the server enables the plugin.
*
* @see org.bukkit.plugin.Plugin#onEnable() * @see org.bukkit.plugin.Plugin#onEnable()
*/ */
@Override @Override
@ -199,7 +196,8 @@ public class AuthMe extends JavaPlugin {
// Set various instances // Set various instances
server = getServer(); server = getServer();
plugin = this; plugin = this;
setupConstants();
setPluginInfos();
// Set up messages // Set up messages
messages = Messages.getInstance(); messages = Messages.getInstance();
@ -505,9 +503,6 @@ public class AuthMe extends JavaPlugin {
} }
} }
// Show the exception message and stop/unload the server/plugin as defined
// in the configuration
/** /**
* Method onDisable. * Method onDisable.
* *
@ -538,8 +533,6 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!"); ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
} }
// Initialize and setup the database
// Stop/unload the server/plugin as defined in the configuration // Stop/unload the server/plugin as defined in the configuration
public void stopOrUnload() { public void stopOrUnload() {
if (Settings.isStopEnabled) { if (Settings.isStopEnabled) {

View File

@ -6,19 +6,16 @@ public class DataFileCache {
private final String group; private final String group;
private final boolean operator; private final boolean operator;
private final boolean flying;
/** /**
* Constructor for DataFileCache. * Constructor for DataFileCache.
* *
* @param group String * @param group String
* @param operator boolean * @param operator boolean
* @param flying boolean
*/ */
public DataFileCache(String group, boolean operator, boolean flying) { public DataFileCache(String group, boolean operator) {
this.group = group; this.group = group;
this.operator = operator; this.operator = operator;
this.flying = flying;
} }
/** /**
@ -38,13 +35,4 @@ public class DataFileCache {
public boolean getOperator() { public boolean getOperator() {
return operator; return operator;
} }
/**
* Method isFlying.
*
* @return boolean
*/
public boolean isFlying() {
return flying;
}
} }

View File

@ -154,7 +154,6 @@ public class JsonCache {
JsonElement e; JsonElement e;
String group = null; String group = null;
boolean operator = false; boolean operator = false;
boolean flying = false;
if ((e = jsonObject.get("group")) != null) { if ((e = jsonObject.get("group")) != null) {
group = e.getAsString(); group = e.getAsString();
@ -162,11 +161,8 @@ public class JsonCache {
if ((e = jsonObject.get("operator")) != null) { if ((e = jsonObject.get("operator")) != null) {
operator = e.getAsBoolean(); operator = e.getAsBoolean();
} }
if ((e = jsonObject.get("flying")) != null) {
flying = e.getAsBoolean();
}
return new DataFileCache(group, operator, flying); return new DataFileCache(group, operator);
} }
} }
@ -187,7 +183,6 @@ public class JsonCache {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("group", dataFileCache.getGroup()); jsonObject.addProperty("group", dataFileCache.getGroup());
jsonObject.addProperty("operator", dataFileCache.getOperator()); jsonObject.addProperty("operator", dataFileCache.getOperator());
jsonObject.addProperty("flying", dataFileCache.isFlying());
return jsonObject; return jsonObject;
} }

View File

@ -4,11 +4,7 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.backup.DataFileCache; import fr.xephi.authme.cache.backup.DataFileCache;
import fr.xephi.authme.cache.backup.JsonCache; import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.events.ResetInventoryEvent;
import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -56,10 +52,8 @@ public class LimboCache {
public void addLimboPlayer(Player player) { public void addLimboPlayer(Player player) {
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
Location loc = player.getLocation(); Location loc = player.getLocation();
GameMode gameMode = player.getGameMode();
boolean operator = false; boolean operator = false;
String playerGroup = ""; String playerGroup = "";
boolean flying = false;
// Get the permissions manager, and make sure it's valid // Get the permissions manager, and make sure it's valid
PermissionsManager permsMan = this.plugin.getPermissionsManager(); PermissionsManager permsMan = this.plugin.getPermissionsManager();
@ -72,35 +66,20 @@ public class LimboCache {
if (cache != null) { if (cache != null) {
playerGroup = cache.getGroup(); playerGroup = cache.getGroup();
operator = cache.getOperator(); operator = cache.getOperator();
flying = cache.isFlying();
} }
} else { } else {
operator = player.isOp(); operator = player.isOp();
flying = player.isFlying();
// Check whether groups are supported // Check whether groups are supported
if (permsMan.hasGroupSupport()) if (permsMan.hasGroupSupport())
playerGroup = permsMan.getPrimaryGroup(player); playerGroup = permsMan.getPrimaryGroup(player);
} }
if (Settings.isForceSurvivalModeEnabled) {
if (Settings.isResetInventoryIfCreative && gameMode == GameMode.CREATIVE) {
ResetInventoryEvent event = new ResetInventoryEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
player.getInventory().clear();
player.sendMessage("Your inventory has been cleaned!");
}
}
if (gameMode == GameMode.CREATIVE) {
flying = false;
}
gameMode = GameMode.SURVIVAL;
}
if (player.isDead()) { if (player.isDead()) {
loc = plugin.getSpawnLocation(player); loc = plugin.getSpawnLocation(player);
} }
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
cache.put(name, new LimboPlayer(name, loc, operator, playerGroup));
} }
/** /**

View File

@ -1,6 +1,5 @@
package fr.xephi.authme.cache.limbo; package fr.xephi.authme.cache.limbo;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -12,29 +11,23 @@ public class LimboPlayer {
private Location loc = null; private Location loc = null;
private BukkitTask timeoutTaskId = null; private BukkitTask timeoutTaskId = null;
private BukkitTask messageTaskId = null; private BukkitTask messageTaskId = null;
private GameMode gameMode = GameMode.SURVIVAL;
private boolean operator = false; private boolean operator = false;
private String group = ""; private String group = "";
private boolean flying = false;
/** /**
* Constructor for LimboPlayer. * Constructor for LimboPlayer.
* *
* @param name String * @param name String
* @param loc Location * @param loc Location
* @param gameMode GameMode
* @param operator boolean * @param operator boolean
* @param group String * @param group String
* @param flying boolean
*/ */
public LimboPlayer(String name, Location loc, GameMode gameMode, public LimboPlayer(String name, Location loc,
boolean operator, String group, boolean flying) { boolean operator, String group) {
this.name = name; this.name = name;
this.loc = loc; this.loc = loc;
this.gameMode = gameMode;
this.operator = operator; this.operator = operator;
this.group = group; this.group = group;
this.flying = flying;
} }
/** /**
@ -66,15 +59,6 @@ public class LimboPlayer {
return loc; return loc;
} }
/**
* Method getGameMode.
*
* @return GameMode
*/
public GameMode getGameMode() {
return gameMode;
}
/** /**
* Method getOperator. * Method getOperator.
* *
@ -149,13 +133,4 @@ public class LimboPlayer {
} }
timeoutTaskId = null; timeoutTaskId = null;
} }
/**
* Method isFlying.
*
* @return boolean
*/
public boolean isFlying() {
return flying;
}
} }

View File

@ -297,7 +297,7 @@ public final class CommandInitializer {
.description("Registration command") .description("Registration command")
.detailedDescription("Command to register using AuthMeReloaded.") .detailedDescription("Command to register using AuthMeReloaded.")
.withArgument("password", "Password", false) .withArgument("password", "Password", false)
.withArgument("verifyPassword", "Verify password", false) .withArgument("verifyPassword", "Verify password", true)
.permissions(ALLOWED, PlayerPermission.REGISTER) .permissions(ALLOWED, PlayerPermission.REGISTER)
.executableCommand(new RegisterCommand()) .executableCommand(new RegisterCommand())
.build(); .build();

View File

@ -30,7 +30,7 @@ public class RegisterCommand implements ExecutableCommand {
// Make sure the command arguments are valid // Make sure the command arguments are valid
final Player player = (Player) sender; final Player player = (Player) sender;
if (arguments.isEmpty() || (Settings.getEnablePasswordVerifier && arguments.size() < 2)) { if (arguments.isEmpty() || (Settings.enablePasswordConfirmation && arguments.size() < 2)) {
m.send(player, MessageKey.USAGE_REGISTER); m.send(player, MessageKey.USAGE_REGISTER);
return; return;
} }
@ -50,7 +50,7 @@ public class RegisterCommand implements ExecutableCommand {
management.performRegister(player, thePass, email); management.performRegister(player, thePass, email);
return; return;
} }
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) { if (arguments.size() > 1 && Settings.enablePasswordConfirmation) {
if (!arguments.get(0).equals(arguments.get(1))) { if (!arguments.get(0).equals(arguments.get(1))) {
m.send(player, MessageKey.PASSWORD_MATCH_ERROR); m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
return; return;

View File

@ -47,7 +47,7 @@ public class BungeeCordMessage implements PluginMessageListener {
} }
if (subChannel.equalsIgnoreCase("AuthMe")) { if (subChannel.equalsIgnoreCase("AuthMe")) {
String str = in.readUTF(); String str = in.readUTF();
String[] args = str.split(";"); final String[] args = str.split(";");
final String act = args[0]; final String act = args[0];
final String name = args[1]; final String name = args[1];
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@ -71,6 +71,14 @@ public class BungeeCordMessage implements PluginMessageListener {
ConsoleLogger.info("Player " + auth.getNickname() ConsoleLogger.info("Player " + auth.getNickname()
+ " has registered out from one of your server!"); + " has registered out from one of your server!");
} }
else if ("changepassword".equals(act)) {
final String password = args[2];
auth.setHash(password);
if (args.length == 4)
auth.setSalt(args[3]);
PlayerCache.getInstance().updatePlayer(auth);
plugin.database.updatePassword(auth);
}
} }
}); });

View File

@ -18,7 +18,6 @@ import fr.xephi.authme.util.GeoLiteAPI;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,7 +34,6 @@ import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
@ -51,13 +49,13 @@ import org.bukkit.event.player.PlayerShearEntityEvent;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static fr.xephi.authme.listener.ListenerService.shouldCancelEvent; import static fr.xephi.authme.listener.ListenerService.shouldCancelEvent;
import org.bukkit.GameMode;
/** /**
* Listener class for player's events * Listener class for player's events
*/ */
public class AuthMePlayerListener implements Listener { public class AuthMePlayerListener implements Listener {
public static final ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
public final AuthMe plugin; public final AuthMe plugin;
@ -195,6 +193,11 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if (Settings.isForceSurvivalModeEnabled
&& !player.hasPermission(PlayerPermission.BYPASS_FORCE_SURVIVAL.getNode())) {
player.setGameMode(GameMode.SURVIVAL);
}
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
String joinMsg = event.getJoinMessage(); String joinMsg = event.getJoinMessage();
@ -493,25 +496,6 @@ public class AuthMePlayerListener implements Listener {
} }
} }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
if (!shouldCancelEvent(event)) {
return;
}
Player player = event.getPlayer();
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
return;
}
String name = player.getName().toLowerCase();
if (causeByAuthMe.containsKey(name)) {
causeByAuthMe.remove(name);
return;
}
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerShear(PlayerShearEntityEvent event) { public void onPlayerShear(PlayerShearEntityEvent event) {
if (shouldCancelEvent(event)) { if (shouldCancelEvent(event)) {

View File

@ -20,7 +20,6 @@ import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.Utils.GroupType; import fr.xephi.authme.util.Utils.GroupType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,26 +53,21 @@ public class AsynchronousJoin {
return; return;
} }
AuthMePlayerListener.gameMode.put(name, player.getGameMode());
if (plugin.ess != null && Settings.disableSocialSpy) { if (plugin.ess != null && Settings.disableSocialSpy) {
plugin.ess.getUser(player).setSocialSpyEnabled(false); plugin.ess.getUser(player).setSocialSpyEnabled(false);
} }
final String ip = plugin.getIP(player); final String ip = plugin.getIP(player);
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) { if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true); AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
player.setGameMode(gM);
player.kickPlayer("You are not the Owner of this account, please try another name!"); player.kickPlayer("You are not the Owner of this account, please try another name!");
if (Settings.banUnsafeIp) if (Settings.banUnsafeIp)
plugin.getServer().banIP(ip); plugin.getServer().banIP(ip);
} }
}); });
return; return;
} }
@ -96,18 +90,7 @@ public class AsynchronousJoin {
final Location spawnLoc = plugin.getSpawnLocation(player); final Location spawnLoc = plugin.getSpawnLocation(player);
final boolean isAuthAvailable = database.isAuthAvailable(name); final boolean isAuthAvailable = database.isAuthAvailable(name);
if (isAuthAvailable) { if (isAuthAvailable) {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) { if (!Settings.noTeleport) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
Utils.forceGM(player);
}
});
}
if (!Settings.noTeleport)
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -117,45 +100,41 @@ public class AsynchronousJoin {
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) { if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) { if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null) if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo()); player.teleport(tpEvent.getTo());
}
} }
} }
} }
}); });
} }
}
placePlayerSafely(player, spawnLoc); placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player); LimboCache.getInstance().updateLimboPlayer(player);
// protect inventory // protect inventory
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) { if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
ProtectInventoryEvent ev = new ProtectInventoryEvent(player); ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
plugin.getServer().getPluginManager().callEvent(ev); plugin.getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) { if (ev.isCancelled()) {
plugin.inventoryProtector.sendInventoryPacket(player); plugin.inventoryProtector.sendInventoryPacket(player);
if (!Settings.noConsoleSpam) if (!Settings.noConsoleSpam) {
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
}
} }
} }
} else { } else {
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
Utils.forceGM(player);
}
});
}
if (!Settings.unRegisteredGroup.isEmpty()) { if (!Settings.unRegisteredGroup.isEmpty()) {
Utils.setGroup(player, Utils.GroupType.UNREGISTERED); Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
} }
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
return; return;
} }
if (!Settings.noTeleport)
if (!Settings.noTeleport) {
if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@ -165,37 +144,30 @@ public class AsynchronousJoin {
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) { if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null) { if (player.isOnline() && tpEvent.getTo() != null) {
if (tpEvent.getTo().getWorld() != null) if (tpEvent.getTo().getWorld() != null) {
player.teleport(tpEvent.getTo()); player.teleport(tpEvent.getTo());
}
} }
} }
} }
}); });
} }
}
} }
if (!LimboCache.getInstance().hasLimboPlayer(name)) { if (!LimboCache.getInstance().hasLimboPlayer(name)) {
LimboCache.getInstance().addLimboPlayer(player); LimboCache.getInstance().addLimboPlayer(player);
} }
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
final int timeOut = Settings.getRegistrationTimeout * 20; final int timeOut = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (timeOut > 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
sched.scheduleSyncDelayedTask(plugin, new Runnable() { sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
player.setOp(false); player.setOp(false);
if (!Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}
if (Settings.isRemoveSpeedEnabled) { if (Settings.isRemoveSpeedEnabled) {
player.setFlySpeed(0.0f); player.setFlySpeed(0.0f);
player.setWalkSpeed(0.0f); player.setWalkSpeed(0.0f);
@ -205,12 +177,25 @@ public class AsynchronousJoin {
player.performCommand("motd"); player.performCommand("motd");
} }
if (Settings.applyBlindEffect) { if (Settings.applyBlindEffect) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeOut, 2)); int blindTimeOut;
// Allow infinite blindness effect
if(timeOut <= 0) {
blindTimeOut = 99999;
} else {
blindTimeOut = timeOut;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2));
} }
} }
}); });
int msgInterval = Settings.getWarnMessageInterval;
if (timeOut > 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) { if (Settings.isSessionsEnabled && isAuthAvailable && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) {
if (plugin.sessions.containsKey(name)) { if (plugin.sessions.containsKey(name)) {
plugin.sessions.get(name).cancel(); plugin.sessions.get(name).cancel();

View File

@ -7,7 +7,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent; import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.permission.PlayerPermission; import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.RandomString; import fr.xephi.authme.security.RandomString;
@ -204,9 +203,6 @@ public class AsynchronousLogin {
@Override @Override
public void run() { public void run() {
if (AuthMePlayerListener.gameMode != null && AuthMePlayerListener.gameMode.containsKey(name)) {
player.setGameMode(AuthMePlayerListener.gameMode.get(name));
}
player.kickPlayer(m.retrieveSingle(MessageKey.WRONG_PASSWORD)); player.kickPlayer(m.retrieveSingle(MessageKey.WRONG_PASSWORD));
} }
}); });

View File

@ -67,16 +67,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
player.setOp(limbo.getOperator()); player.setOp(limbo.getOperator());
} }
protected void restoreFlyghtState() {
if (Settings.isForceSurvivalModeEnabled) {
player.setAllowFlight(false);
player.setFlying(false);
return;
}
player.setAllowFlight(limbo.isFlying());
player.setFlying(limbo.isFlying());
}
protected void packQuitLocation() { protected void packQuitLocation() {
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player); Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
} }
@ -160,13 +150,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
} }
} }
if (Settings.isForceSurvivalModeEnabled && Settings.forceOnlyAfterLogin) {
Utils.forceGM(player);
} else {
player.setGameMode(limbo.getGameMode());
}
restoreFlyghtState();
if (Settings.protectInventoryBeforeLogInEnabled) { if (Settings.protectInventoryBeforeLogInEnabled) {
restoreInventory(); restoreInventory();
} }

View File

@ -77,10 +77,6 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
if (Settings.applyBlindEffect) if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
player.setOp(false); player.setOp(false);
if (!Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}
// Player is now logout... Time to fire event ! // Player is now logout... Time to fire event !
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player)); Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
if (Settings.bungee) if (Settings.bungee)

View File

@ -6,7 +6,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -23,7 +22,6 @@ public class AsynchronousQuit {
protected final Player player; protected final Player player;
private final String name; private final String name;
private boolean isOp = false; private boolean isOp = false;
private boolean isFlying = false;
private boolean needToChange = false; private boolean needToChange = false;
private boolean isKick = false; private boolean isKick = false;
@ -69,7 +67,6 @@ public class AsynchronousQuit {
Utils.addNormal(player, limbo.getGroup()); Utils.addNormal(player, limbo.getGroup());
needToChange = true; needToChange = true;
isOp = limbo.getOperator(); isOp = limbo.getOperator();
isFlying = limbo.isFlying();
if (limbo.getTimeoutTaskId() != null) if (limbo.getTimeoutTaskId() != null)
limbo.getTimeoutTaskId().cancel(); limbo.getTimeoutTaskId().cancel();
if (limbo.getMessageTaskId() != null) if (limbo.getMessageTaskId() != null)
@ -96,7 +93,6 @@ public class AsynchronousQuit {
database.setUnlogged(name); database.setUnlogged(name);
} }
AuthMePlayerListener.gameMode.remove(name); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, isFlying, needToChange));
} }
} }

View File

@ -1,8 +1,6 @@
package fr.xephi.authme.process.quit; package fr.xephi.authme.process.quit;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.settings.Settings;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
@ -12,7 +10,6 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
protected final AuthMe plugin; protected final AuthMe plugin;
protected final Player player; protected final Player player;
protected final boolean isOp; protected final boolean isOp;
protected final boolean isFlying;
protected final boolean needToChange; protected final boolean needToChange;
/** /**
@ -21,16 +18,13 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
* @param plugin AuthMe * @param plugin AuthMe
* @param player Player * @param player Player
* @param isOp boolean * @param isOp boolean
* @param isFlying boolean
* @param needToChange boolean * @param needToChange boolean
*/ */
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
, boolean isOp, boolean isFlying , boolean isOp, boolean needToChange) {
, boolean needToChange) {
this.plugin = plugin; this.plugin = plugin;
this.player = player; this.player = player;
this.isOp = isOp; this.isOp = isOp;
this.isFlying = isFlying;
this.needToChange = needToChange; this.needToChange = needToChange;
} }
@ -41,13 +35,8 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
*/ */
@Override @Override
public void run() { public void run() {
if (needToChange) { if (needToChange) {
player.setOp(isOp); player.setOp(isOp);
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(isFlying);
player.setFlying(isFlying);
}
} }
try { try {
player.getVehicle().eject(); player.getVehicle().eject();

View File

@ -15,7 +15,6 @@ import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask; import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
@ -96,7 +95,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
public void run() { public void run() {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name); LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo != null) { if (limbo != null) {
player.setGameMode(limbo.getGameMode());
Utils.teleportToSpawn(player); Utils.teleportToSpawn(player);
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) { if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
@ -119,10 +117,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
if (!Settings.getmailAccount.isEmpty()) { if (!Settings.getmailAccount.isEmpty()) {
m.send(player, MessageKey.ADD_EMAIL_MESSAGE); m.send(player, MessageKey.ADD_EMAIL_MESSAGE);
} }
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(false);
player.setFlying(false);
}
if (Settings.applyBlindEffect) { if (Settings.applyBlindEffect) {
player.removePotionEffect(PotionEffectType.BLINDNESS); player.removePotionEffect(PotionEffectType.BLINDNESS);

View File

@ -66,14 +66,14 @@ public final class Settings {
isMovementAllowed, isKickNonRegisteredEnabled, isMovementAllowed, isKickNonRegisteredEnabled,
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled, isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
isSaveQuitLocationEnabled, isForceSurvivalModeEnabled, isSaveQuitLocationEnabled, isForceSurvivalModeEnabled,
isResetInventoryIfCreative, isCachingEnabled, isCachingEnabled,
isKickOnWrongPasswordEnabled, getEnablePasswordVerifier, isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
protectInventoryBeforeLogInEnabled, isBackupActivated, protectInventoryBeforeLogInEnabled, isBackupActivated,
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport, isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
useCaptcha, emailRegistration, multiverse, bungee, useCaptcha, emailRegistration, multiverse, bungee,
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge, disableSocialSpy, useEssentialsMotd, usePurge,
purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgePlayerDat, purgeEssentialsFile, supportOldPassword,
purgeLimitedCreative, purgeAntiXray, purgePermissions, purgeLimitedCreative, purgeAntiXray, purgePermissions,
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
@ -168,8 +168,6 @@ public final class Settings {
isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true); isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false); isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false); isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative", false);
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1); getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
getPasswordHash = getPasswordHash(); getPasswordHash = getPasswordHash();
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup"); getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
@ -202,7 +200,7 @@ public final class Settings {
} }
getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", ""); getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true); enablePasswordConfirmation = configFile.getBoolean("settings.restrictions.enablePasswordConfirmation", true);
protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true); protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
plugin.checkProtocolLib(); plugin.checkProtocolLib();
@ -255,7 +253,6 @@ public final class Settings {
useLogging = configFile.getBoolean("Security.console.logConsole", false); useLogging = configFile.getBoolean("Security.console.logConsole", false);
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true); disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10); bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false); useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
usePurge = configFile.getBoolean("Purge.useAutoPurge", false); usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60); purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
@ -581,6 +578,14 @@ public final class Settings {
set("settings.useWelcomeMessage", true); set("settings.useWelcomeMessage", true);
changes = true; changes = true;
} }
if (!contains("settings.restrictions.enablePasswordConfirmation")) {
set("settings.restrictions.enablePasswordConfirmation", true);
changes = true;
}
if (contains("settings.restrictions.enablePasswordVerifier")) {
set("settings.restrictions.enablePasswordVerifier", null);
changes = true;
}
if (!contains("settings.security.unsafePasswords")) { if (!contains("settings.security.unsafePasswords")) {
List<String> str = new ArrayList<>(); List<String> str = new ArrayList<>();
str.add("123456"); str.add("123456");

View File

@ -10,6 +10,9 @@ import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
/** /**
@ -40,7 +43,7 @@ public class ChangePasswordTask implements Runnable {
public void run() { public void run() {
Messages m = plugin.getMessages(); Messages m = plugin.getMessages();
try { try {
String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name); String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
PlayerAuth auth = PlayerCache.getInstance().getAuth(name); PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) { if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) {
@ -58,6 +61,23 @@ public class ChangePasswordTask implements Runnable {
PlayerCache.getInstance().updatePlayer(auth); PlayerCache.getInstance().updatePlayer(auth);
m.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS); m.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
ConsoleLogger.info(player.getName() + " changed his password"); ConsoleLogger.info(player.getName() + " changed his password");
if (Settings.bungee)
{
final String hash = auth.getHash();
final String salt = auth.getSalt();
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
@Override
public void run() {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("AuthMe");
out.writeUTF("changepassword;" + name + ";" + hash + ";" + salt);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
});
}
} else { } else {
m.send(player, MessageKey.WRONG_PASSWORD); m.send(player, MessageKey.WRONG_PASSWORD);
} }

View File

@ -7,10 +7,9 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.events.AuthMeTeleportEvent; import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -195,17 +194,6 @@ public final class Utils {
}); });
} }
/**
* Force the game mode of a player.
*
* @param player the player to modify.
*/
public static void forceGM(Player player) {
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
player.setGameMode(GameMode.SURVIVAL);
}
}
/** /**
* Safe way to retrieve the list of online players from the server. Depending on the * Safe way to retrieve the list of online players from the server. Depending on the
* implementation of the server, either an array of {@link Player} instances is being returned, * implementation of the server, either an array of {@link Player} instances is being returned,

View File

@ -155,11 +155,6 @@ settings:
GameMode: GameMode:
# ForceSurvivalMode to player when join ? # ForceSurvivalMode to player when join ?
ForceSurvivalMode: false ForceSurvivalMode: false
# if player join with CreativeMode and ForceSurvivalMode: true
# inventory will be wipped
ResetInventoryIfCreative: false
# Do we need to force the survival mode ONLY after /login process?
ForceOnlyAfterLogin: false
security: security:
# minimum Length of password # minimum Length of password
minPasswordLength: 5 minPasswordLength: 5

View File

@ -35,8 +35,6 @@ public abstract class AbstractEncryptionMethodTest {
} }
@Test @Test
@Ignore
// TODO #375 Fix and unignore tests
public void testGivenPasswords() { public void testGivenPasswords() {
for (String password : GIVEN_PASSWORDS) { for (String password : GIVEN_PASSWORDS) {
try { try {

View File

@ -3,9 +3,8 @@ package fr.xephi.authme.util;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ReflectionTestUtils; import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -50,35 +49,6 @@ public class UtilsTest {
when(authMeMock.getPermissionsManager()).thenReturn(permissionsManagerMock); when(authMeMock.getPermissionsManager()).thenReturn(permissionsManagerMock);
} }
@Test
public void shouldForceSurvivalGameMode() {
// given
Player player = mock(Player.class);
given(permissionsManagerMock.hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)).willReturn(false);
// when
Utils.forceGM(player);
// then
verify(authMeMock).getPermissionsManager();
verify(player).setGameMode(GameMode.SURVIVAL);
}
@Test
public void shouldNotForceGameModeForUserWithBypassPermission() {
// given
Player player = mock(Player.class);
given(permissionsManagerMock.hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)).willReturn(true);
// when
Utils.forceGM(player);
// then
verify(authMeMock).getPermissionsManager();
verify(permissionsManagerMock).hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL);
verify(player, never()).setGameMode(any(GameMode.class));
}
@Test @Test
public void shouldNotAddToNormalGroupIfPermissionsAreDisabled() { public void shouldNotAddToNormalGroupIfPermissionsAreDisabled() {
// given // given