Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 306-command-service
This commit is contained in:
commit
a9fc658db0
203
newPlugin.yml
Normal file
203
newPlugin.yml
Normal 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
|
||||
@ -81,39 +81,18 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class AuthMe extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Defines the name of the plugin.
|
||||
*/
|
||||
// Defines the name of the plugin.
|
||||
private static final String PLUGIN_NAME = "AuthMeReloaded";
|
||||
|
||||
// Default version and build number values;
|
||||
private static String pluginVersion = "N/D";
|
||||
private static String pluginBuildNumber = "Unknown";
|
||||
|
||||
// Private Instances
|
||||
private static AuthMe plugin;
|
||||
private static Server server;
|
||||
private static Wrapper wrapper = Wrapper.getInstance();
|
||||
|
||||
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 PermissionsManager permsMan = null;
|
||||
private Settings settings;
|
||||
@ -121,9 +100,34 @@ public class AuthMe extends JavaPlugin {
|
||||
private JsonCache playerBackup;
|
||||
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
|
||||
*/
|
||||
public static AuthMe getInstance() {
|
||||
@ -132,52 +136,46 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Get the plugin's name.
|
||||
*
|
||||
* @return Plugin name.
|
||||
* @return The plugin's name.
|
||||
*/
|
||||
public static String getPluginName() {
|
||||
return PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current installed AuthMeReloaded version name.
|
||||
*
|
||||
* @return The version name of the currently installed AuthMeReloaded instance.
|
||||
* Get the plugin's version.
|
||||
* @return The plugin's version.
|
||||
*/
|
||||
public static String getPluginVersion() {
|
||||
return pluginVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current installed AuthMeReloaded version code.
|
||||
*
|
||||
* @return The version code of the currently installed AuthMeReloaded instance.
|
||||
* Get the plugin's build number.
|
||||
* @return The plugin's build number.
|
||||
*/
|
||||
public static String getPluginBuildNumber() {
|
||||
return pluginBuildNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin's Settings.
|
||||
*
|
||||
* @return Settings
|
||||
* Get the plugin's Settings.
|
||||
* @return Plugin's settings.
|
||||
*/
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Messages instance.
|
||||
*
|
||||
* @return Messages
|
||||
* Get the Messages instance.
|
||||
* @return Plugin's messages.
|
||||
*/
|
||||
public Messages getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
// Get version and build number of the plugin
|
||||
// TODO: enhance this
|
||||
private void setupConstants() {
|
||||
private void setPluginInfos() {
|
||||
String versionRaw = this.getDescription().getVersion();
|
||||
int index = versionRaw.lastIndexOf("-");
|
||||
if (index != -1) {
|
||||
@ -191,7 +189,6 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* Method called when the server enables the plugin.
|
||||
*
|
||||
* @see org.bukkit.plugin.Plugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
@ -199,7 +196,8 @@ public class AuthMe extends JavaPlugin {
|
||||
// Set various instances
|
||||
server = getServer();
|
||||
plugin = this;
|
||||
setupConstants();
|
||||
|
||||
setPluginInfos();
|
||||
|
||||
// Set up messages
|
||||
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.
|
||||
*
|
||||
@ -538,8 +533,6 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
||||
}
|
||||
|
||||
// Initialize and setup the database
|
||||
|
||||
// Stop/unload the server/plugin as defined in the configuration
|
||||
public void stopOrUnload() {
|
||||
if (Settings.isStopEnabled) {
|
||||
|
||||
@ -6,19 +6,16 @@ public class DataFileCache {
|
||||
|
||||
private final String group;
|
||||
private final boolean operator;
|
||||
private final boolean flying;
|
||||
|
||||
/**
|
||||
* Constructor for DataFileCache.
|
||||
*
|
||||
* @param group String
|
||||
* @param operator boolean
|
||||
* @param flying boolean
|
||||
*/
|
||||
public DataFileCache(String group, boolean operator, boolean flying) {
|
||||
public DataFileCache(String group, boolean operator) {
|
||||
this.group = group;
|
||||
this.operator = operator;
|
||||
this.flying = flying;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,13 +35,4 @@ public class DataFileCache {
|
||||
public boolean getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isFlying.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,7 +154,6 @@ public class JsonCache {
|
||||
JsonElement e;
|
||||
String group = null;
|
||||
boolean operator = false;
|
||||
boolean flying = false;
|
||||
|
||||
if ((e = jsonObject.get("group")) != null) {
|
||||
group = e.getAsString();
|
||||
@ -162,11 +161,8 @@ public class JsonCache {
|
||||
if ((e = jsonObject.get("operator")) != null) {
|
||||
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.addProperty("group", dataFileCache.getGroup());
|
||||
jsonObject.addProperty("operator", dataFileCache.getOperator());
|
||||
jsonObject.addProperty("flying", dataFileCache.isFlying());
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@ -4,11 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.backup.DataFileCache;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
import fr.xephi.authme.events.ResetInventoryEvent;
|
||||
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.entity.Player;
|
||||
|
||||
@ -56,10 +52,8 @@ public class LimboCache {
|
||||
public void addLimboPlayer(Player player) {
|
||||
String name = player.getName().toLowerCase();
|
||||
Location loc = player.getLocation();
|
||||
GameMode gameMode = player.getGameMode();
|
||||
boolean operator = false;
|
||||
String playerGroup = "";
|
||||
boolean flying = false;
|
||||
|
||||
// Get the permissions manager, and make sure it's valid
|
||||
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
||||
@ -72,35 +66,20 @@ public class LimboCache {
|
||||
if (cache != null) {
|
||||
playerGroup = cache.getGroup();
|
||||
operator = cache.getOperator();
|
||||
flying = cache.isFlying();
|
||||
}
|
||||
} else {
|
||||
operator = player.isOp();
|
||||
flying = player.isFlying();
|
||||
|
||||
// Check whether groups are supported
|
||||
if (permsMan.hasGroupSupport())
|
||||
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()) {
|
||||
loc = plugin.getSpawnLocation(player);
|
||||
}
|
||||
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
|
||||
|
||||
cache.put(name, new LimboPlayer(name, loc, operator, playerGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.cache.limbo;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -12,29 +11,23 @@ public class LimboPlayer {
|
||||
private Location loc = null;
|
||||
private BukkitTask timeoutTaskId = null;
|
||||
private BukkitTask messageTaskId = null;
|
||||
private GameMode gameMode = GameMode.SURVIVAL;
|
||||
private boolean operator = false;
|
||||
private String group = "";
|
||||
private boolean flying = false;
|
||||
|
||||
/**
|
||||
* Constructor for LimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
* @param loc Location
|
||||
* @param gameMode GameMode
|
||||
* @param operator boolean
|
||||
* @param group String
|
||||
* @param flying boolean
|
||||
*/
|
||||
public LimboPlayer(String name, Location loc, GameMode gameMode,
|
||||
boolean operator, String group, boolean flying) {
|
||||
public LimboPlayer(String name, Location loc,
|
||||
boolean operator, String group) {
|
||||
this.name = name;
|
||||
this.loc = loc;
|
||||
this.gameMode = gameMode;
|
||||
this.operator = operator;
|
||||
this.group = group;
|
||||
this.flying = flying;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,15 +59,6 @@ public class LimboPlayer {
|
||||
return loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getGameMode.
|
||||
*
|
||||
* @return GameMode
|
||||
*/
|
||||
public GameMode getGameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOperator.
|
||||
*
|
||||
@ -149,13 +133,4 @@ public class LimboPlayer {
|
||||
}
|
||||
timeoutTaskId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isFlying.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ public final class CommandInitializer {
|
||||
.description("Registration command")
|
||||
.detailedDescription("Command to register using AuthMeReloaded.")
|
||||
.withArgument("password", "Password", false)
|
||||
.withArgument("verifyPassword", "Verify password", false)
|
||||
.withArgument("verifyPassword", "Verify password", true)
|
||||
.permissions(ALLOWED, PlayerPermission.REGISTER)
|
||||
.executableCommand(new RegisterCommand())
|
||||
.build();
|
||||
|
||||
@ -30,7 +30,7 @@ public class RegisterCommand implements ExecutableCommand {
|
||||
|
||||
// Make sure the command arguments are valid
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -50,7 +50,7 @@ public class RegisterCommand implements ExecutableCommand {
|
||||
management.performRegister(player, thePass, email);
|
||||
return;
|
||||
}
|
||||
if (arguments.size() > 1 && Settings.getEnablePasswordVerifier) {
|
||||
if (arguments.size() > 1 && Settings.enablePasswordConfirmation) {
|
||||
if (!arguments.get(0).equals(arguments.get(1))) {
|
||||
m.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||
return;
|
||||
|
||||
@ -47,7 +47,7 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
}
|
||||
if (subChannel.equalsIgnoreCase("AuthMe")) {
|
||||
String str = in.readUTF();
|
||||
String[] args = str.split(";");
|
||||
final String[] args = str.split(";");
|
||||
final String act = args[0];
|
||||
final String name = args[1];
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@ -71,6 +71,14 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
ConsoleLogger.info("Player " + auth.getNickname()
|
||||
+ " 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);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -18,7 +18,6 @@ import fr.xephi.authme.util.GeoLiteAPI;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
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.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
@ -51,13 +49,13 @@ import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static fr.xephi.authme.listener.ListenerService.shouldCancelEvent;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
* Listener class for player's events
|
||||
*/
|
||||
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, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||
public final AuthMe plugin;
|
||||
@ -195,6 +193,11 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.isForceSurvivalModeEnabled
|
||||
&& !player.hasPermission(PlayerPermission.BYPASS_FORCE_SURVIVAL.getNode())) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
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)
|
||||
public void onPlayerShear(PlayerShearEntityEvent event) {
|
||||
if (shouldCancelEvent(event)) {
|
||||
|
||||
@ -20,7 +20,6 @@ import fr.xephi.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import fr.xephi.authme.util.Utils.GroupType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -54,26 +53,21 @@ public class AsynchronousJoin {
|
||||
return;
|
||||
}
|
||||
|
||||
AuthMePlayerListener.gameMode.put(name, player.getGameMode());
|
||||
|
||||
if (plugin.ess != null && Settings.disableSocialSpy) {
|
||||
plugin.ess.getUser(player).setSocialSpyEnabled(false);
|
||||
}
|
||||
|
||||
final String ip = plugin.getIP(player);
|
||||
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
||||
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
|
||||
player.setGameMode(gM);
|
||||
player.kickPlayer("You are not the Owner of this account, please try another name!");
|
||||
if (Settings.banUnsafeIp)
|
||||
plugin.getServer().banIP(ip);
|
||||
}
|
||||
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -96,18 +90,7 @@ public class AsynchronousJoin {
|
||||
final Location spawnLoc = plugin.getSpawnLocation(player);
|
||||
final boolean isAuthAvailable = database.isAuthAvailable(name);
|
||||
if (isAuthAvailable) {
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
|
||||
Utils.forceGM(player);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if (!Settings.noTeleport)
|
||||
if (!Settings.noTeleport) {
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@ -117,45 +100,41 @@ public class AsynchronousJoin {
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (player.isOnline() && tpEvent.getTo() != null) {
|
||||
if (tpEvent.getTo().getWorld() != null)
|
||||
if (tpEvent.getTo().getWorld() != null) {
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
placePlayerSafely(player, spawnLoc);
|
||||
LimboCache.getInstance().updateLimboPlayer(player);
|
||||
|
||||
// protect inventory
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
||||
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(ev);
|
||||
if (ev.isCancelled()) {
|
||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
||||
if (!Settings.noConsoleSpam)
|
||||
if (!Settings.noConsoleSpam) {
|
||||
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} 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()) {
|
||||
Utils.setGroup(player, Utils.GroupType.UNREGISTERED);
|
||||
}
|
||||
if (!Settings.isForcedRegistrationEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!Settings.noTeleport)
|
||||
|
||||
if (!Settings.noTeleport) {
|
||||
if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@ -165,37 +144,30 @@ public class AsynchronousJoin {
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (player.isOnline() && tpEvent.getTo() != null) {
|
||||
if (tpEvent.getTo().getWorld() != null)
|
||||
if (tpEvent.getTo().getWorld() != null) {
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
}
|
||||
Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED);
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setOp(false);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
if (Settings.isRemoveSpeedEnabled) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
@ -205,12 +177,25 @@ public class AsynchronousJoin {
|
||||
player.performCommand("motd");
|
||||
}
|
||||
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 (plugin.sessions.containsKey(name)) {
|
||||
plugin.sessions.get(name).cancel();
|
||||
|
||||
@ -7,7 +7,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
@ -204,9 +203,6 @@ public class AsynchronousLogin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (AuthMePlayerListener.gameMode != null && AuthMePlayerListener.gameMode.containsKey(name)) {
|
||||
player.setGameMode(AuthMePlayerListener.gameMode.get(name));
|
||||
}
|
||||
player.kickPlayer(m.retrieveSingle(MessageKey.WRONG_PASSWORD));
|
||||
}
|
||||
});
|
||||
|
||||
@ -67,16 +67,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
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() {
|
||||
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) {
|
||||
restoreInventory();
|
||||
}
|
||||
|
||||
@ -77,10 +77,6 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
if (Settings.applyBlindEffect)
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||
player.setOp(false);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
// Player is now logout... Time to fire event !
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||
if (Settings.bungee)
|
||||
|
||||
@ -6,7 +6,6 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -23,7 +22,6 @@ public class AsynchronousQuit {
|
||||
protected final Player player;
|
||||
private final String name;
|
||||
private boolean isOp = false;
|
||||
private boolean isFlying = false;
|
||||
private boolean needToChange = false;
|
||||
private boolean isKick = false;
|
||||
|
||||
@ -69,7 +67,6 @@ public class AsynchronousQuit {
|
||||
Utils.addNormal(player, limbo.getGroup());
|
||||
needToChange = true;
|
||||
isOp = limbo.getOperator();
|
||||
isFlying = limbo.isFlying();
|
||||
if (limbo.getTimeoutTaskId() != null)
|
||||
limbo.getTimeoutTaskId().cancel();
|
||||
if (limbo.getMessageTaskId() != null)
|
||||
@ -96,7 +93,6 @@ public class AsynchronousQuit {
|
||||
database.setUnlogged(name);
|
||||
}
|
||||
|
||||
AuthMePlayerListener.gameMode.remove(name);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, isFlying, needToChange));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package fr.xephi.authme.process.quit;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@ -12,7 +10,6 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
||||
protected final AuthMe plugin;
|
||||
protected final Player player;
|
||||
protected final boolean isOp;
|
||||
protected final boolean isFlying;
|
||||
protected final boolean needToChange;
|
||||
|
||||
/**
|
||||
@ -21,16 +18,13 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
||||
* @param plugin AuthMe
|
||||
* @param player Player
|
||||
* @param isOp boolean
|
||||
* @param isFlying boolean
|
||||
* @param needToChange boolean
|
||||
*/
|
||||
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
|
||||
, boolean isOp, boolean isFlying
|
||||
, boolean needToChange) {
|
||||
, boolean isOp, boolean needToChange) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.isOp = isOp;
|
||||
this.isFlying = isFlying;
|
||||
this.needToChange = needToChange;
|
||||
}
|
||||
|
||||
@ -41,13 +35,8 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (needToChange) {
|
||||
player.setOp(isOp);
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(isFlying);
|
||||
player.setFlying(isFlying);
|
||||
}
|
||||
}
|
||||
try {
|
||||
player.getVehicle().eject();
|
||||
|
||||
@ -15,7 +15,6 @@ import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
@ -96,7 +95,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
Utils.teleportToSpawn(player);
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
||||
@ -119,10 +117,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
if (!Settings.getmailAccount.isEmpty()) {
|
||||
m.send(player, MessageKey.ADD_EMAIL_MESSAGE);
|
||||
}
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
|
||||
if (Settings.applyBlindEffect) {
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
|
||||
@ -66,14 +66,14 @@ public final class Settings {
|
||||
isMovementAllowed, isKickNonRegisteredEnabled,
|
||||
isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled,
|
||||
isSaveQuitLocationEnabled, isForceSurvivalModeEnabled,
|
||||
isResetInventoryIfCreative, isCachingEnabled,
|
||||
isKickOnWrongPasswordEnabled, getEnablePasswordVerifier,
|
||||
isCachingEnabled,
|
||||
isKickOnWrongPasswordEnabled, enablePasswordConfirmation,
|
||||
protectInventoryBeforeLogInEnabled, isBackupActivated,
|
||||
isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport,
|
||||
rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||
useCaptcha, emailRegistration, multiverse, bungee,
|
||||
banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||
disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge,
|
||||
disableSocialSpy, useEssentialsMotd, usePurge,
|
||||
purgePlayerDat, purgeEssentialsFile, supportOldPassword,
|
||||
purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||
@ -168,8 +168,6 @@ public final class Settings {
|
||||
isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
|
||||
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", 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);
|
||||
getPasswordHash = getPasswordHash();
|
||||
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
|
||||
@ -202,7 +200,7 @@ public final class Settings {
|
||||
}
|
||||
|
||||
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);
|
||||
plugin.checkProtocolLib();
|
||||
@ -255,7 +253,6 @@ public final class Settings {
|
||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
||||
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
||||
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||
forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
|
||||
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
||||
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
||||
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
||||
@ -581,6 +578,14 @@ public final class Settings {
|
||||
set("settings.useWelcomeMessage", 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")) {
|
||||
List<String> str = new ArrayList<>();
|
||||
str.add("123456");
|
||||
|
||||
@ -10,6 +10,9 @@ import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
@ -40,7 +43,7 @@ public class ChangePasswordTask implements Runnable {
|
||||
public void run() {
|
||||
Messages m = plugin.getMessages();
|
||||
try {
|
||||
String name = player.getName().toLowerCase();
|
||||
final String name = player.getName().toLowerCase();
|
||||
String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) {
|
||||
@ -58,6 +61,23 @@ public class ChangePasswordTask implements Runnable {
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
m.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
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 {
|
||||
m.send(player, MessageKey.WRONG_PASSWORD);
|
||||
}
|
||||
|
||||
@ -7,10 +7,9 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
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
|
||||
* implementation of the server, either an array of {@link Player} instances is being returned,
|
||||
|
||||
@ -155,11 +155,6 @@ settings:
|
||||
GameMode:
|
||||
# ForceSurvivalMode to player when join ?
|
||||
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:
|
||||
# minimum Length of password
|
||||
minPasswordLength: 5
|
||||
|
||||
@ -35,8 +35,6 @@ public abstract class AbstractEncryptionMethodTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// TODO #375 Fix and unignore tests
|
||||
public void testGivenPasswords() {
|
||||
for (String password : GIVEN_PASSWORDS) {
|
||||
try {
|
||||
|
||||
@ -3,9 +3,8 @@ package fr.xephi.authme.util;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@ -50,35 +49,6 @@ public class UtilsTest {
|
||||
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
|
||||
public void shouldNotAddToNormalGroupIfPermissionsAreDisabled() {
|
||||
// given
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user