Merge pull request #66 from AuthMe-Team/PermissionsManager
Created permissions manager, with proper permissions support
This commit is contained in:
commit
9932242f6f
BIN
lib/EssentialsGroupManager-2.13.1.jar
Normal file
BIN
lib/EssentialsGroupManager-2.13.1.jar
Normal file
Binary file not shown.
BIN
lib/Permission-3.1.6.jar
Normal file
BIN
lib/Permission-3.1.6.jar
Normal file
Binary file not shown.
BIN
lib/bPermissions-2.12-DEV.jar
Normal file
BIN
lib/bPermissions-2.12-DEV.jar
Normal file
Binary file not shown.
BIN
lib/zPermissions-1.3beta1.jar
Normal file
BIN
lib/zPermissions-1.3beta1.jar
Normal file
Binary file not shown.
68
pom.xml
68
pom.xml
@ -180,6 +180,12 @@
|
|||||||
<id>xephi-repo</id>
|
<id>xephi-repo</id>
|
||||||
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
|
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- PermissionsEx Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>pex-repo</id>
|
||||||
|
<url>http://pex-repo.aoeu.xyz/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -317,6 +323,68 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- PermissionsEx plugin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>ru.tehkode</groupId>
|
||||||
|
<artifactId>PermissionsEx</artifactId>
|
||||||
|
<version>1.23.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>net.gravitydevelopment.updater</groupId>
|
||||||
|
<artifactId>updater</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-dbcp</artifactId>
|
||||||
|
<groupId>commons-dbcp</groupId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>AccountsClient</artifactId>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- GroupManager plugin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.anjocaido</groupId>
|
||||||
|
<artifactId>groupmanager</artifactId>
|
||||||
|
<version>2.13.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/lib/EssentialsGroupManager-2.13.1.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- bPermissions plugin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.bananaco</groupId>
|
||||||
|
<artifactId>bpermissions</artifactId>
|
||||||
|
<version>1.12-DEV</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/lib/bPermissions-2.12-DEV.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- zPermissions plugin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.tyrannyofheaven.bukkit</groupId>
|
||||||
|
<artifactId>zPermissions</artifactId>
|
||||||
|
<version>1.3-SNAPSHOT</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/lib/zPermissions-1.3beta1.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Permissions plugin (obsolete) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.nijiko</groupId>
|
||||||
|
<artifactId>permissions</artifactId>
|
||||||
|
<version>3.1.6</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${basedir}/lib/Permission-3.1.6.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Vault, http://dev.bukkit.org/bukkit-plugins/vault/ -->
|
<!-- Vault, http://dev.bukkit.org/bukkit-plugins/vault/ -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import fr.xephi.authme.listener.*;
|
||||||
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -47,13 +49,6 @@ import fr.xephi.authme.datasource.MySQL;
|
|||||||
import fr.xephi.authme.datasource.SQLite;
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
import fr.xephi.authme.hooks.BungeeCordMessage;
|
import fr.xephi.authme.hooks.BungeeCordMessage;
|
||||||
import fr.xephi.authme.hooks.EssSpawn;
|
import fr.xephi.authme.hooks.EssSpawn;
|
||||||
import fr.xephi.authme.listener.AuthMeBlockListener;
|
|
||||||
import fr.xephi.authme.listener.AuthMeEntityListener;
|
|
||||||
import fr.xephi.authme.listener.AuthMeInventoryPacketAdapter;
|
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener16;
|
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
|
||||||
import fr.xephi.authme.listener.AuthMeServerListener;
|
|
||||||
import fr.xephi.authme.modules.ModuleManager;
|
import fr.xephi.authme.modules.ModuleManager;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.settings.Messages;
|
||||||
@ -82,6 +77,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// TODO: Move this to a better place! -- timvisee
|
// TODO: Move this to a better place! -- timvisee
|
||||||
private CommandHandler commandHandler = null;
|
private CommandHandler commandHandler = null;
|
||||||
|
private PermissionsManager permsMan = null;
|
||||||
|
|
||||||
public Management management;
|
public Management management;
|
||||||
public NewAPI api;
|
public NewAPI api;
|
||||||
@ -146,6 +142,9 @@ public class AuthMe extends JavaPlugin {
|
|||||||
authmeLogger = Logger.getLogger("AuthMe");
|
authmeLogger = Logger.getLogger("AuthMe");
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
|
// Set up the permissions manager
|
||||||
|
setupPermissionsManager();
|
||||||
|
|
||||||
// Set up and initialize the command handler
|
// Set up and initialize the command handler
|
||||||
this.commandHandler = new CommandHandler(false);
|
this.commandHandler = new CommandHandler(false);
|
||||||
this.commandHandler.init();
|
this.commandHandler.init();
|
||||||
@ -335,24 +334,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
pm.registerEvents(new AuthMePlayerListener18(this), this);
|
pm.registerEvents(new AuthMePlayerListener18(this), this);
|
||||||
} catch (ClassNotFoundException ignore) {
|
} catch (ClassNotFoundException ignore) {
|
||||||
}
|
}
|
||||||
|
pm.registerEvents(new AuthMePluginListener(this), this);
|
||||||
pm.registerEvents(new AuthMeBlockListener(this), this);
|
pm.registerEvents(new AuthMeBlockListener(this), this);
|
||||||
pm.registerEvents(new AuthMeEntityListener(this), this);
|
pm.registerEvents(new AuthMeEntityListener(this), this);
|
||||||
pm.registerEvents(new AuthMeServerListener(this), this);
|
pm.registerEvents(new AuthMeServerListener(this), this);
|
||||||
|
|
||||||
// TODO: This is moved to CommandManager.registerCommands() handled by
|
|
||||||
// AuthMe.onCommand() -- timvisee
|
|
||||||
// Register commands
|
|
||||||
// getCommand("authme").setExecutor(new AdminCommand(this));
|
|
||||||
// getCommand("register").setExecutor(new RegisterCommand(this));
|
|
||||||
// getCommand("login").setExecutor(new LoginCommand(this));
|
|
||||||
// getCommand("changepassword").setExecutor(new
|
|
||||||
// ChangePasswordCommand(this));
|
|
||||||
// getCommand("logout").setExecutor(new LogoutCommand(this));
|
|
||||||
// getCommand("unregister").setExecutor(new UnregisterCommand(this));
|
|
||||||
// getCommand("email").setExecutor(new EmailCommand(this));
|
|
||||||
// getCommand("captcha").setExecutor(new CaptchaCommand(this));
|
|
||||||
// getCommand("converter").setExecutor(new ConverterCommand(this));
|
|
||||||
|
|
||||||
// Purge on start if enabled
|
// Purge on start if enabled
|
||||||
autoPurge();
|
autoPurge();
|
||||||
|
|
||||||
@ -468,6 +454,23 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the permissions manager.
|
||||||
|
*/
|
||||||
|
public void setupPermissionsManager() {
|
||||||
|
this.permsMan = new PermissionsManager(Bukkit.getServer(), this, this.authmeLogger);
|
||||||
|
this.permsMan.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the permissions manager instance.
|
||||||
|
*
|
||||||
|
* @return Permissions Manager instance.
|
||||||
|
*/
|
||||||
|
public PermissionsManager getPermissionsManager() {
|
||||||
|
return this.permsMan;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the console filter to remove the passwords
|
// Set the console filter to remove the passwords
|
||||||
private void setLog4JFilter() {
|
private void setLog4JFilter() {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||||
@ -561,17 +564,47 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a player/command sender have a permission
|
/**
|
||||||
|
* Check if a player/command sender have a permission
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated since v5.1. Use the permissions manager instead! See: getPermissionsManager()
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param perm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean authmePermissible(Player player, String perm) {
|
public boolean authmePermissible(Player player, String perm) {
|
||||||
if (player.hasPermission(perm)) {
|
// New code:
|
||||||
|
return getPermissionsManager().hasPermission(player, perm);
|
||||||
|
|
||||||
|
// Legacy code:
|
||||||
|
/*if (player.hasPermission(perm)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (permission != null) {
|
} else if (permission != null) {
|
||||||
return permission.playerHas(player, perm);
|
return permission.playerHas(player, perm);
|
||||||
}
|
}
|
||||||
return false;
|
return false;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Deprecated since v5.1. Use the permissions manager instead! See: getPermissionsManager()
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* @param perm
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean authmePermissible(CommandSender sender, String perm) {
|
public boolean authmePermissible(CommandSender sender, String perm) {
|
||||||
|
// New code:
|
||||||
|
// Handle players with the permissions manager
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
// Get the player instance
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
// Check whether the player has permission, return the result
|
||||||
|
return getPermissionsManager().hasPermission(player, perm);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy code:
|
||||||
if (sender.hasPermission(perm)) {
|
if (sender.hasPermission(perm)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (permission != null) {
|
} else if (permission != null) {
|
||||||
@ -612,7 +645,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
public Player generateKickPlayer(Collection<? extends Player> collection) {
|
public Player generateKickPlayer(Collection<? extends Player> collection) {
|
||||||
Player player = null;
|
Player player = null;
|
||||||
for (Player p : collection) {
|
for (Player p : collection) {
|
||||||
if (!(authmePermissible(p, "authme.vip"))) {
|
if (!getPermissionsManager().hasPermission(p, "authme.vip")) {
|
||||||
player = p;
|
player = p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package fr.xephi.authme.command;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -124,14 +125,14 @@ public class CommandPermissions {
|
|||||||
// Get the player instance
|
// Get the player instance
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
// // Get the permissions manager, and make sure it's instance is valid
|
// Get the permissions manager, and make sure it's instance is valid
|
||||||
// PermissionsManager permissionsManager = Core.getPermissionsManager();
|
PermissionsManager permissionsManager = AuthMe.getInstance().getPermissionsManager();
|
||||||
// if(permissionsManager == null)
|
if(permissionsManager == null)
|
||||||
// return false;
|
return false;
|
||||||
|
|
||||||
// Check whether the player has permission, return the result
|
// Check whether the player has permission, return the result
|
||||||
for(String node : this.permissionNodes)
|
for(String node : this.permissionNodes)
|
||||||
if(!AuthMe.getInstance().authmePermissible(player, node))
|
if(!permissionsManager.hasPermission(player, node, defaultPermission))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class ForceLoginCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage("Player needs to be online!");
|
sender.sendMessage("Player needs to be online!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plugin.authmePermissible(player, "authme.canbeforced")) {
|
if (!plugin.getPermissionsManager().hasPermission(player, "authme.canbeforced")) {
|
||||||
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
sender.sendMessage("You cannot force login for the player " + playerName + "!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public class HelpPrinter {
|
|||||||
for(String node : permissions.getPermissionNodes()) {
|
for(String node : permissions.getPermissionNodes()) {
|
||||||
boolean nodePermission = true;
|
boolean nodePermission = true;
|
||||||
if(sender instanceof Player)
|
if(sender instanceof Player)
|
||||||
nodePermission = AuthMe.getInstance().authmePermissible((Player) sender, node);
|
nodePermission = AuthMe.getInstance().getPermissionsManager().hasPermission((Player) sender, node);
|
||||||
final String nodePermsString = ChatColor.GRAY + (nodePermission ? ChatColor.ITALIC + " (Permission!)" : ChatColor.ITALIC + " (No Permission!)");
|
final String nodePermsString = ChatColor.GRAY + (nodePermission ? ChatColor.ITALIC + " (Permission!)" : ChatColor.ITALIC + " (No Permission!)");
|
||||||
sender.sendMessage(" " + ChatColor.YELLOW + ChatColor.ITALIC + node + nodePermsString);
|
sender.sendMessage(" " + ChatColor.YELLOW + ChatColor.ITALIC + node + nodePermsString);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -165,7 +166,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
private void checkAntiBotMod(final Player player) {
|
private void checkAntiBotMod(final Player player) {
|
||||||
if (plugin.delayedAntiBot || plugin.antibotMod)
|
if (plugin.delayedAntiBot || plugin.antibotMod)
|
||||||
return;
|
return;
|
||||||
if (plugin.authmePermissible(player, "authme.bypassantibot"))
|
if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassantibot"))
|
||||||
return;
|
return;
|
||||||
if (antibot.size() > Settings.antiBotSensibility) {
|
if (antibot.size() > Settings.antiBotSensibility) {
|
||||||
plugin.switchAntiBotMod(true);
|
plugin.switchAntiBotMod(true);
|
||||||
@ -265,8 +266,11 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the permissions manager
|
||||||
|
PermissionsManager permsMan = plugin.getPermissionsManager();
|
||||||
|
|
||||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) {
|
||||||
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
||||||
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
|
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
|
||||||
event.setKickMessage(m.send("country_banned")[0]);
|
event.setKickMessage(m.send("country_banned")[0]);
|
||||||
@ -274,7 +278,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) {
|
||||||
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
||||||
if (((code == null) || !Settings.countries.contains(code))) {
|
if (((code == null) || !Settings.countries.contains(code))) {
|
||||||
event.setKickMessage(m.send("country_banned")[0]);
|
event.setKickMessage(m.send("country_banned")[0]);
|
||||||
@ -343,7 +347,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL)
|
if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL)
|
||||||
return;
|
return;
|
||||||
if (!plugin.authmePermissible(player, "authme.vip")) {
|
if (!permsMan.hasPermission(player, "authme.vip")) {
|
||||||
event.setKickMessage(m.send("kick_fullserver")[0]);
|
event.setKickMessage(m.send("kick_fullserver")[0]);
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
|
||||||
return;
|
return;
|
||||||
@ -510,7 +514,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
if (plugin.authmePermissible(player, "authme.bypassforcesurvival"))
|
if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival"))
|
||||||
return;
|
return;
|
||||||
if (Utils.checkAuth(player))
|
if (Utils.checkAuth(player))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -0,0 +1,55 @@
|
|||||||
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
public class AuthMePluginListener implements Listener {
|
||||||
|
|
||||||
|
/** Plugin instance. */
|
||||||
|
public AuthMe instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param instance Main plugin instance.
|
||||||
|
*/
|
||||||
|
public AuthMePluginListener(AuthMe instance) {
|
||||||
|
this.instance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a plugin is enabled.
|
||||||
|
*
|
||||||
|
* @param event Event reference.
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
// Call the onPluginEnable method in the permissions manager
|
||||||
|
this.instance.getPermissionsManager().onPluginEnable(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a plugin is disabled.
|
||||||
|
*
|
||||||
|
* @param event Event reference.
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
|
// Get the plugin instance
|
||||||
|
Plugin plugin = event.getPlugin();
|
||||||
|
|
||||||
|
// Make sure the plugin instance isn't null
|
||||||
|
if(plugin == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Make sure it's not this plugin itself
|
||||||
|
if(plugin.equals(this.instance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Call the onPluginDisable method in the permissions manager
|
||||||
|
this.instance.getPermissionsManager().onPluginDisable(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
454
src/main/java/fr/xephi/authme/permission/PermissionsManager.java
Normal file
454
src/main/java/fr/xephi/authme/permission/PermissionsManager.java
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
package fr.xephi.authme.permission;
|
||||||
|
|
||||||
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
|
import de.bananaco.bpermissions.api.ApiLayer;
|
||||||
|
import de.bananaco.bpermissions.api.CalculableType;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
|
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService;
|
||||||
|
import ru.tehkode.permissions.PermissionManager;
|
||||||
|
import ru.tehkode.permissions.PermissionUser;
|
||||||
|
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PermissionsManager.
|
||||||
|
*
|
||||||
|
* A permissions manager, to manage and use various permissions systems.
|
||||||
|
* This manager supports dynamic plugin hooking and various other features.
|
||||||
|
*
|
||||||
|
* Written by Tim Visée.
|
||||||
|
*
|
||||||
|
* @author Tim Visée, http://timvisee.com
|
||||||
|
* @version 0.2.1
|
||||||
|
*/
|
||||||
|
public class PermissionsManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server instance.
|
||||||
|
*/
|
||||||
|
private Server server;
|
||||||
|
/**
|
||||||
|
* Plugin instance.
|
||||||
|
*/
|
||||||
|
private Plugin plugin;
|
||||||
|
/**
|
||||||
|
* Logger instance.
|
||||||
|
*/
|
||||||
|
private Logger log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of permissions system that is currently used.
|
||||||
|
*/
|
||||||
|
private PermissionsSystemType permsType = PermissionsSystemType.NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Essentials group manager instance.
|
||||||
|
*/
|
||||||
|
private GroupManager groupManagerPerms;
|
||||||
|
/**
|
||||||
|
* Permissions manager instance for the legacy permissions system.
|
||||||
|
*/
|
||||||
|
private PermissionHandler defaultPerms;
|
||||||
|
/**
|
||||||
|
* zPermissions service instance.
|
||||||
|
*/
|
||||||
|
private ZPermissionsService zPermissionsService;
|
||||||
|
/**
|
||||||
|
* Vault instance.
|
||||||
|
*/
|
||||||
|
public Permission vaultPerms = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param server Server instance
|
||||||
|
* @param plugin Plugin instance
|
||||||
|
* @param log Logger
|
||||||
|
*/
|
||||||
|
public PermissionsManager(Server server, Plugin plugin, Logger log) {
|
||||||
|
this.server = server;
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the permissions manager is currently hooked into any of the supported permissions systems.
|
||||||
|
*
|
||||||
|
* @return False if there isn't any permissions system used.
|
||||||
|
*/
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return !permsType.equals(PermissionsSystemType.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the permissions system where the permissions manager is currently hooked into.
|
||||||
|
*
|
||||||
|
* @return Permissions system type.
|
||||||
|
*/
|
||||||
|
public PermissionsSystemType getUsedPermissionsSystemType() {
|
||||||
|
return this.permsType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup and hook into the permissions systems.
|
||||||
|
*
|
||||||
|
* @return The detected permissions system.
|
||||||
|
*/
|
||||||
|
public PermissionsSystemType setup() {
|
||||||
|
// Define the plugin manager
|
||||||
|
final PluginManager pm = this.server.getPluginManager();
|
||||||
|
|
||||||
|
// Reset used permissions system type
|
||||||
|
permsType = PermissionsSystemType.NONE;
|
||||||
|
|
||||||
|
// PermissionsEx, check if it's available
|
||||||
|
try {
|
||||||
|
Plugin pex = pm.getPlugin("PermissionsEx");
|
||||||
|
if(pex != null) {
|
||||||
|
PermissionManager pexPerms = PermissionsEx.getPermissionManager();
|
||||||
|
if(pexPerms != null) {
|
||||||
|
permsType = PermissionsSystemType.PERMISSIONS_EX;
|
||||||
|
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into PermissionsEx!");
|
||||||
|
return permsType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into PermissionsEx!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// PermissionsBukkit, check if it's available
|
||||||
|
try {
|
||||||
|
Plugin bukkitPerms = pm.getPlugin("PermissionsBukkit");
|
||||||
|
if(bukkitPerms != null) {
|
||||||
|
permsType = PermissionsSystemType.PERMISSIONS_BUKKIT;
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into PermissionsBukkit!");
|
||||||
|
return permsType;
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into PermissionsBukkit!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// bPermissions, check if it's available
|
||||||
|
try {
|
||||||
|
Plugin bPerms = pm.getPlugin("bPermissions");
|
||||||
|
if(bPerms != null) {
|
||||||
|
permsType = PermissionsSystemType.B_PERMISSIONS;
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into bPermissions!");
|
||||||
|
return permsType;
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into bPermissions!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Essentials Group Manager, check if it's available
|
||||||
|
try {
|
||||||
|
final Plugin groupManagerPlugin = pm.getPlugin("GroupManager");
|
||||||
|
if(groupManagerPlugin != null && groupManagerPlugin.isEnabled()) {
|
||||||
|
permsType = PermissionsSystemType.ESSENTIALS_GROUP_MANAGER;
|
||||||
|
groupManagerPerms = (GroupManager) groupManagerPlugin;
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into Essentials Group Manager!");
|
||||||
|
return permsType;
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into Essentials Group Manager!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// zPermissions, check if it's available
|
||||||
|
try {
|
||||||
|
Plugin zPerms = pm.getPlugin("zPermissions");
|
||||||
|
if(zPerms != null) {
|
||||||
|
zPermissionsService = Bukkit.getServicesManager().load(ZPermissionsService.class);
|
||||||
|
if(zPermissionsService != null) {
|
||||||
|
permsType = PermissionsSystemType.Z_PERMISSIONS;
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into zPermissions!");
|
||||||
|
return permsType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into zPermissions!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vault, check if it's available
|
||||||
|
try {
|
||||||
|
final Plugin vaultPlugin = pm.getPlugin("Vault");
|
||||||
|
if(vaultPlugin != null && vaultPlugin.isEnabled()) {
|
||||||
|
RegisteredServiceProvider<Permission> permissionProvider = this.server.getServicesManager().getRegistration(Permission.class);
|
||||||
|
if(permissionProvider != null) {
|
||||||
|
vaultPerms = permissionProvider.getProvider();
|
||||||
|
if(vaultPerms.isEnabled()) {
|
||||||
|
permsType = PermissionsSystemType.VAULT;
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into Vault Permissions!");
|
||||||
|
return permsType;
|
||||||
|
} else {
|
||||||
|
System.out.println("[" + plugin.getName() + "] Not using Vault Permissions, Vault Permissions is disabled!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into Vault Permissions!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Permissions, check if it's available
|
||||||
|
try {
|
||||||
|
Plugin testPerms = pm.getPlugin("Permissions");
|
||||||
|
if(testPerms != null) {
|
||||||
|
permsType = PermissionsSystemType.PERMISSIONS;
|
||||||
|
this.defaultPerms = ((Permissions) testPerms).getHandler();
|
||||||
|
System.out.println("[" + plugin.getName() + "] Hooked into Permissions!");
|
||||||
|
return PermissionsSystemType.PERMISSIONS;
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
// An error occurred, show a warning message
|
||||||
|
System.out.println("[" + plugin.getName() + "] Error while hooking into Permissions!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// No recognized permissions system found
|
||||||
|
permsType = PermissionsSystemType.NONE;
|
||||||
|
System.out.println("[" + plugin.getName() + "] No supported permissions system found! Permissions disabled!");
|
||||||
|
return PermissionsSystemType.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Break the hook with all permission systems.
|
||||||
|
*/
|
||||||
|
public void unhook() {
|
||||||
|
// Reset the current used permissions system
|
||||||
|
this.permsType = PermissionsSystemType.NONE;
|
||||||
|
|
||||||
|
// Print a status message to the console
|
||||||
|
this.log.info("Unhooked from Permissions!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reload the permissions manager, and re-hook all permission plugins.
|
||||||
|
*
|
||||||
|
* @return True on success, false on failure.
|
||||||
|
*/
|
||||||
|
public boolean reload() {
|
||||||
|
// Unhook all permission plugins
|
||||||
|
unhook();
|
||||||
|
|
||||||
|
// Set up the permissions manager again, return the result
|
||||||
|
setup();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called when a plugin is being enabled.
|
||||||
|
*
|
||||||
|
* @param event Event instance.
|
||||||
|
*/
|
||||||
|
public void onPluginEnable(PluginEnableEvent event) {
|
||||||
|
// Get the plugin and it's name
|
||||||
|
Plugin plugin = event.getPlugin();
|
||||||
|
String pluginName = plugin.getName();
|
||||||
|
|
||||||
|
// Check if any known permissions system is enabling
|
||||||
|
if(pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") ||
|
||||||
|
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
|
||||||
|
pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
|
||||||
|
pluginName.equals("Permissions")) {
|
||||||
|
this.log.info(pluginName + " plugin enabled, dynamically updating permissions hooks!");
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called when a plugin is being disabled.
|
||||||
|
*
|
||||||
|
* @param event Event instance.
|
||||||
|
*/
|
||||||
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
|
// Get the plugin instance and name
|
||||||
|
Plugin plugin = event.getPlugin();
|
||||||
|
String pluginName = plugin.getName();
|
||||||
|
|
||||||
|
// Is the WorldGuard plugin disabled
|
||||||
|
if(pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") ||
|
||||||
|
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
|
||||||
|
pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
|
||||||
|
pluginName.equals("Permissions")) {
|
||||||
|
this.log.info(pluginName + " plugin disabled, updating hooks!");
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the logger instance.
|
||||||
|
*
|
||||||
|
* @return Logger instance.
|
||||||
|
*/
|
||||||
|
public Logger getLogger() {
|
||||||
|
return this.log;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the logger instance.
|
||||||
|
*
|
||||||
|
* @param log Logger instance.
|
||||||
|
*/
|
||||||
|
public void setLogger(Logger log) {
|
||||||
|
this.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the player has permission. If no permissions system is used, the player has to be OP.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
* @param permsNode Permissions node.
|
||||||
|
*
|
||||||
|
* @return True if the player has permission.
|
||||||
|
*/
|
||||||
|
public boolean hasPermission(Player player, String permsNode) {
|
||||||
|
return hasPermission(player, permsNode, player.isOp());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player has permission.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
* @param permsNode The permission node.
|
||||||
|
* @param def Default returned if no permissions system is used.
|
||||||
|
*
|
||||||
|
* @return True if the player has permission.
|
||||||
|
*/
|
||||||
|
public boolean hasPermission(Player player, String permsNode, boolean def) {
|
||||||
|
if(!isEnabled())
|
||||||
|
// No permissions system is used, return default
|
||||||
|
return def;
|
||||||
|
|
||||||
|
switch(this.permsType) {
|
||||||
|
case PERMISSIONS_EX:
|
||||||
|
// Permissions Ex
|
||||||
|
PermissionUser user = PermissionsEx.getUser(player);
|
||||||
|
return user.has(permsNode);
|
||||||
|
|
||||||
|
case PERMISSIONS_BUKKIT:
|
||||||
|
// Permissions Bukkit
|
||||||
|
return player.hasPermission(permsNode);
|
||||||
|
|
||||||
|
case B_PERMISSIONS:
|
||||||
|
// bPermissions
|
||||||
|
return ApiLayer.hasPermission(player.getWorld().getName(), CalculableType.USER, player.getName(), permsNode);
|
||||||
|
|
||||||
|
case ESSENTIALS_GROUP_MANAGER:
|
||||||
|
// Essentials Group Manager
|
||||||
|
final AnjoPermissionsHandler handler = groupManagerPerms.getWorldsHolder().getWorldPermissions(player);
|
||||||
|
return handler != null && handler.has(player, permsNode);
|
||||||
|
|
||||||
|
case Z_PERMISSIONS:
|
||||||
|
// zPermissions
|
||||||
|
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(player.getWorld().getName(), null, player.getName());
|
||||||
|
if(perms.containsKey(permsNode))
|
||||||
|
return perms.get(permsNode);
|
||||||
|
else
|
||||||
|
return def;
|
||||||
|
|
||||||
|
case VAULT:
|
||||||
|
// Vault
|
||||||
|
return vaultPerms.has(player, permsNode);
|
||||||
|
|
||||||
|
case PERMISSIONS:
|
||||||
|
// Permissions
|
||||||
|
return this.defaultPerms.has(player, permsNode);
|
||||||
|
|
||||||
|
case NONE:
|
||||||
|
// Not hooked into any permissions system, return default
|
||||||
|
return def;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Something went wrong, return false to prevent problems
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
|
public List<String> getGroups(Player player) {
|
||||||
|
if(!isEnabled())
|
||||||
|
// No permissions system is used, return an empty list
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
switch(this.permsType) {
|
||||||
|
case PERMISSIONS_EX:
|
||||||
|
// Permissions Ex
|
||||||
|
PermissionUser user = PermissionsEx.getUser(player);
|
||||||
|
return user.getParentIdentifiers(null);
|
||||||
|
|
||||||
|
case PERMISSIONS_BUKKIT:
|
||||||
|
// Permissions Bukkit
|
||||||
|
// Permissions Bukkit doesn't support group, return an empty list
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
case B_PERMISSIONS:
|
||||||
|
// bPermissions
|
||||||
|
return Arrays.asList(ApiLayer.getGroups(player.getName(), CalculableType.USER, player.getName()));
|
||||||
|
|
||||||
|
case ESSENTIALS_GROUP_MANAGER:
|
||||||
|
// Essentials Group Manager
|
||||||
|
final AnjoPermissionsHandler handler = groupManagerPerms.getWorldsHolder().getWorldPermissions(player);
|
||||||
|
if(handler == null)
|
||||||
|
return new ArrayList<>();
|
||||||
|
return Arrays.asList(handler.getGroups(player.getName()));
|
||||||
|
|
||||||
|
case Z_PERMISSIONS:
|
||||||
|
//zPermissions
|
||||||
|
return new ArrayList(zPermissionsService.getPlayerGroups(player.getName()));
|
||||||
|
|
||||||
|
case VAULT:
|
||||||
|
// Vault
|
||||||
|
return Arrays.asList(vaultPerms.getPlayerGroups(player));
|
||||||
|
|
||||||
|
case NONE:
|
||||||
|
// Not hooked into any permissions system, return an empty list
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Something went wrong, return an empty list to prevent problems
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PermissionsSystemType {
|
||||||
|
NONE("None"),
|
||||||
|
PERMISSIONS_EX("PermissionsEx"),
|
||||||
|
PERMISSIONS_BUKKIT("Permissions Bukkit"),
|
||||||
|
B_PERMISSIONS("bPermissions"),
|
||||||
|
ESSENTIALS_GROUP_MANAGER("Essentials Group Manager"),
|
||||||
|
Z_PERMISSIONS("zPermissions"),
|
||||||
|
VAULT("Vault"),
|
||||||
|
PERMISSIONS("Permissions");
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
PermissionsSystemType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -38,7 +38,7 @@ public class AsyncChangeEmail {
|
|||||||
String playerName = player.getName().toLowerCase();
|
String playerName = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
if (Settings.getmaxRegPerEmail > 0) {
|
||||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||||
m.send(player, "max_reg");
|
m.send(player, "max_reg");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public class AsyncronousJoin {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
|
if (Settings.getMaxJoinPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
|
||||||
if (plugin.hasJoinedIp(player.getName(), ip)) {
|
if (plugin.hasJoinedIp(player.getName(), ip)) {
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public class AsyncronousLogin {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
if (Settings.getMaxLoginPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
|
||||||
if (plugin.isLoggedIp(name, getIP())) {
|
if (plugin.isLoggedIp(name, getIP())) {
|
||||||
m.send(player, "logged_in");
|
m.send(player, "logged_in");
|
||||||
return null;
|
return null;
|
||||||
@ -236,7 +236,7 @@ public class AsyncronousLogin {
|
|||||||
* uuidaccounts + "."; } }
|
* uuidaccounts + "."; } }
|
||||||
*/
|
*/
|
||||||
for (Player player : Utils.getOnlinePlayers()) {
|
for (Player player : Utils.getOnlinePlayers()) {
|
||||||
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
|
if (plugin.getPermissionsManager().hasPermission(player, "authme.seeOtherAccounts")) {
|
||||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
||||||
player.sendMessage(message.toString());
|
player.sendMessage(message.toString());
|
||||||
// player.sendMessage(uuidaccounts.replace("%size%",
|
// player.sendMessage(uuidaccounts.replace("%size%",
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public class AsyncRegister {
|
|||||||
m.send(player, "user_regged");
|
m.send(player, "user_regged");
|
||||||
return false;
|
return false;
|
||||||
} else if (Settings.getmaxRegPerIp > 0) {
|
} else if (Settings.getmaxRegPerIp > 0) {
|
||||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) {
|
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) {
|
||||||
m.send(player, "max_reg");
|
m.send(player, "max_reg");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class AsyncRegister {
|
|||||||
return;
|
return;
|
||||||
if (!email.isEmpty() && !email.equals("")) {
|
if (!email.isEmpty() && !email.equals("")) {
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
if (Settings.getmaxRegPerEmail > 0) {
|
||||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||||
m.send(player, "max_reg");
|
m.send(player, "max_reg");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ public class AsyncRegister {
|
|||||||
|
|
||||||
protected void emailRegister() throws Exception {
|
protected void emailRegister() throws Exception {
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
if (Settings.getmaxRegPerEmail > 0) {
|
||||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||||
m.send(player, "max_reg");
|
m.send(player, "max_reg");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -225,7 +225,7 @@ public class Utils {
|
|||||||
* Used for force player GameMode
|
* Used for force player GameMode
|
||||||
*/
|
*/
|
||||||
public static void forceGM(Player player) {
|
public static void forceGM(Player player) {
|
||||||
if (!plugin.authmePermissible(player, "authme.bypassforcesurvival"))
|
if (!plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival"))
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ website: ${project.url}
|
|||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
main: ${mainClass}
|
main: ${mainClass}
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
softdepend: [Vault, Multiverse-Core, Essentials, EssentialsSpawn, ProtocolLib]
|
softdepend: [Vault, PermissionsBukkit, Permissions, PermissionsEX, EssentialsGroupManager, Multiverse-Core, Essentials, EssentialsSpawn, ProtocolLib]
|
||||||
commands:
|
commands:
|
||||||
register:
|
register:
|
||||||
description: Register an account
|
description: Register an account
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user