Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into commands-refactor

This commit is contained in:
ljacqu 2015-12-08 21:58:35 +01:00
commit 0710c4f531
17 changed files with 226 additions and 117 deletions

View File

@ -5,7 +5,7 @@
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
<version>5.1-SNAPSHOT</version>
<version>5.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AuthMeReloaded</name>
@ -285,7 +285,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.2</version>
<version>2.4.3</version>
<scope>compile</scope>
<exclusions>
<exclusion>

View File

@ -57,25 +57,6 @@ public class CommandDescription {
*/
private CommandPermissions permissions;
/**
* Constructor.
*
* @param executableCommand The executable command, or null.
* @param labels List of command labels.
* @param description Command description.
* @param detailedDescription Detailed comment description.
* @param parent Parent command.
*/
@Deprecated
public CommandDescription(ExecutableCommand executableCommand, List<String> labels, String description, String detailedDescription, CommandDescription parent) {
setExecutableCommand(executableCommand);
this.labels = labels;
this.description = description;
this.detailedDescription = detailedDescription;
setParent(parent);
this.arguments = new ArrayList<>();
}
/**
* Private constructor. Use {@link CommandDescription#builder()} to create instances of this class.
* <p />

View File

@ -184,7 +184,6 @@ public final class CommandInitializer {
.withArgument("player", "Player Name", false)
.build();
// Register the spawn command
CommandDescription.builder()
.executableCommand(new SpawnCommand())
@ -216,7 +215,6 @@ public final class CommandInitializer {
.permissions(OP_ONLY, AdminPermission.FIRST_SPAWN)
.build();
// Register the setfirstspawn command
CommandDescription.builder()
.executableCommand(new SetFirstSpawnCommand())
@ -242,7 +240,8 @@ public final class CommandInitializer {
CommandDescription.builder()
.executableCommand(new PurgeLastPositionCommand())
.parent(AUTHME_BASE)
.labels("resetpos", "purgelastposition", "purgelastpos", "resetposition", "resetlastposition", "resetlastpos")
.labels("resetpos", "purgelastposition", "purgelastpos", "resetposition",
"resetlastposition", "resetlastpos")
.description("Purge player's last position")
.detailedDescription("Purge the last know position of the specified player.")
.permissions(OP_ONLY, AdminPermission.PURGE_LAST_POSITION)
@ -250,7 +249,7 @@ public final class CommandInitializer {
.build();
// Register the purgebannedplayers command
CommandDescription purgeBannedPlayersCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(new PurgeBannedPlayersCommand())
.parent(AUTHME_BASE)
.labels("purgebannedplayers", "purgebannedplayer", "deletebannedplayers", "deletebannedplayer")
@ -260,7 +259,7 @@ public final class CommandInitializer {
.build();
// Register the switchantibot command
CommandDescription switchAntiBotCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(new SwitchAntiBotCommand())
.parent(AUTHME_BASE)
.labels("switchantibot", "toggleantibot", "antibot")
@ -270,26 +269,13 @@ public final class CommandInitializer {
.withArgument("mode", "ON / OFF", true)
.build();
// // Register the resetname command
// CommandDescription resetNameCommand = new CommandDescription(
// new ResetNameCommand(),
// new ArrayList<String>() {{
// add("resetname");
// add("resetnames");
// }},
// "Reset name",
// "Reset name",
// authMeCommand);
// resetNameCommand.setCommandPermissions("authme.admin.resetname",
// CommandPermissions.DefaultPermission.OP_ONLY);
// Register the reload command
CommandDescription reloadCommand = CommandDescription.builder()
.executableCommand(new PurgeLastPositionCommand())
CommandDescription.builder()
.executableCommand(new ReloadCommand())
.parent(AUTHME_BASE)
.labels("reload", "reload")
.labels("reload", "rld")
.description("Reload plugin")
.detailedDescription("Reload the AutheMeReloaded plugin.")
.detailedDescription("Reload the AuthMeReloaded plugin.")
.permissions(OP_ONLY, AdminPermission.RELOAD)
.build();
@ -315,13 +301,12 @@ public final class CommandInitializer {
.build();
// Register the help command
CommandDescription loginHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(LOGIN_BASE)
.labels(helpCommandLabels)
.description("View Help")
.detailedDescription("View detailed help pages about AuthMeReloaded login commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
@ -336,13 +321,12 @@ public final class CommandInitializer {
.build();
// Register the help command
CommandDescription logoutHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(LOGOUT_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded logout commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
@ -359,13 +343,12 @@ public final class CommandInitializer {
.build();
// Register the help command
CommandDescription registerHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(REGISTER_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded register commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
@ -381,13 +364,12 @@ public final class CommandInitializer {
.build();
// Register the help command
CommandDescription unregisterHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(UNREGISTER_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded unregister commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
@ -404,13 +386,12 @@ public final class CommandInitializer {
.build();
// Register the help command
CommandDescription changePasswordHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(CHANGE_PASSWORD_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded changepassword commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
@ -421,39 +402,37 @@ public final class CommandInitializer {
.labels("email", "mail")
.description("Email command")
.detailedDescription("The AuthMeReloaded Email command base.")
.permissions(ALLOWED)
.build();
// Register the help command
CommandDescription emailHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(EMAIL_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded email commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
// Register the add command
CommandDescription addEmailCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(new AddEmailCommand())
.parent(EMAIL_BASE)
.labels("add", "addemail", "addmail")
.description("Add Email")
.detailedDescription("Add a new Email address to your account.")
.detailedDescription("Add a new email address to your account.")
.permissions(ALLOWED, PlayerPermission.ADD_EMAIL)
.withArgument("email", "Email address", false)
.withArgument("verifyEmail", "Email address verification", false)
.build();
// Register the change command
CommandDescription changeEmailCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(new ChangeEmailCommand())
.parent(EMAIL_BASE)
.labels("change", "changeemail", "changemail")
.description("Change Email")
.detailedDescription("Change an Email address of your account.")
.detailedDescription("Change an email address of your account.")
.permissions(ALLOWED, PlayerPermission.CHANGE_EMAIL)
.withArgument("oldEmail", "Old email address", false)
.withArgument("newEmail", "New email address", false)
@ -461,12 +440,13 @@ public final class CommandInitializer {
// Register the recover command
CommandDescription recoverEmailCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(new RecoverEmailCommand())
.parent(EMAIL_BASE)
.labels("recover", "recovery", "recoveremail", "recovermail")
.description("Recover password using Email")
.detailedDescription("Recover your account using an Email address by sending a mail containing a new password.")
.detailedDescription("Recover your account using an Email address by sending a mail containing " +
"a new password.")
.permissions(ALLOWED, PlayerPermission.RECOVER_EMAIL)
.withArgument("email", "Email address", false)
.build();
@ -477,19 +457,18 @@ public final class CommandInitializer {
.parent(null)
.labels("captcha", "capt")
.description("Captcha Command")
.detailedDescription("Captcha command for AuthMeRelaoded.")
.detailedDescription("Captcha command for AuthMeReloaded.")
.permissions(ALLOWED, PlayerPermission.CAPTCHA)
.withArgument("captcha", "The Captcha", false)
.build();
// Register the help command
CommandDescription captchaHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(CAPTCHA_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded captcha commands.")
.permissions(ALLOWED)
.withArgument("query", "The command or query to view help for.", true)
.build();
@ -499,19 +478,19 @@ public final class CommandInitializer {
.parent(null)
.labels("converter", "convert", "conv")
.description("Converter Command")
.detailedDescription("Converter command for AuthMeRelaoded.")
.detailedDescription("Converter command for AuthMeReloaded.")
.permissions(OP_ONLY, AdminPermission.CONVERTER)
.withArgument("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / royalauth / vauth / sqltoflat", false)
.withArgument("job", "Conversion job: flattosql / flattosqlite /| xauth / crazylogin / rakamak / " +
"royalauth / vauth / sqltoflat", false)
.build();
// Register the help command
CommandDescription converterHelpCommand = CommandDescription.builder()
CommandDescription.builder()
.executableCommand(helpCommandExecutable)
.parent(CONVERTER_BASE)
.labels(helpCommandLabels)
.description("View help")
.detailedDescription("View detailed help pages about AuthMeReloaded converter commands.")
.permissions(OP_ONLY)
.withArgument("query", "The command or query to view help for.", true)
.build();

View File

@ -7,7 +7,6 @@ import fr.xephi.authme.permission.PermissionNode;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
/**

View File

@ -1,11 +1,10 @@
package fr.xephi.authme.command;
import java.util.List;
import fr.xephi.authme.util.CollectionUtils;
import fr.xephi.authme.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
public final class CommandUtils {
public static int getMinNumberOfArguments(CommandDescription command) {

View File

@ -1,5 +1,14 @@
package fr.xephi.authme.command.help;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandArgumentDescription;
import fr.xephi.authme.command.CommandDescription;
@ -8,15 +17,6 @@ import fr.xephi.authme.command.CommandPermissions;
import fr.xephi.authme.permission.PermissionNode;
import fr.xephi.authme.util.CollectionUtils;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
*/

View File

@ -32,6 +32,12 @@ public class AuthMeBlockListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -45,6 +51,12 @@ public class AuthMeBlockListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}

View File

@ -52,6 +52,11 @@ public class AuthMeEntityListener implements Listener {
if (Utils.checkAuth(player) ) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(player)) {
return;
}
player.setFireTicks(0);
event.setDamage(0);
event.setCancelled(true);
@ -73,6 +78,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) entity)) {
return;
}
event.setTarget(null);
event.setCancelled(true);
}
@ -83,7 +93,7 @@ public class AuthMeEntityListener implements Listener {
* @param event EntityDamageByEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDmg(EntityDamageByEntityEvent event) {
public void onDamage(EntityDamageByEntityEvent event) {
Entity entity = event.getDamager();
if (entity == null || !(entity instanceof Player)) {
return;
@ -94,6 +104,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
}
@ -113,6 +128,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) entity)) {
return;
}
event.setCancelled(true);
}
@ -132,6 +152,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) entity)) {
return;
}
event.setAmount(0);
event.setCancelled(true);
}
@ -152,6 +177,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) entity)) {
return;
}
event.setCancelled(true);
}
@ -171,6 +201,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) entity)) {
return;
}
event.setCancelled(true);
}
@ -210,6 +245,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
}
@ -230,6 +270,11 @@ public class AuthMeEntityListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
}

View File

@ -28,7 +28,24 @@ import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
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;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import java.util.concurrent.ConcurrentHashMap;
@ -53,7 +70,6 @@ public class AuthMePlayerListener implements Listener {
}
final Player player = event.getPlayer();
if (Utils.checkAuth(player)) {
for (Player p : Utils.getOnlinePlayers()) {
if (!PlayerCache.getInstance().isAuthenticated(p.getName())) {
@ -64,6 +80,11 @@ public class AuthMePlayerListener implements Listener {
}
event.setCancelled(true);
sendLoginRegisterMSG(player);
}
// TODO: new name
private void sendLoginRegisterMSG(final Player player) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@ -93,6 +114,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
event.setCancelled(true);
sendLoginRegisterMSG(event.getPlayer());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
@ -169,17 +191,22 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null || Utils.isNPC(event.getPlayer())) {
final Player player = event.getPlayer();
if (player == null) {
return;
}
final Player player = event.getPlayer();
/* IMPOSSIBLE!!!! TODO: check this!
if(Utils.isNPC(player)) {
return;
}
*/
String name = player.getName().toLowerCase();
String joinMsg = event.getJoinMessage();
boolean delay = Settings.delayJoinLeaveMessages && joinMsg != null;
// Remove the join message while the player isn't logging in
if (delay) {
if (Settings.delayJoinLeaveMessages && joinMsg != null) {
event.setJoinMessage(null);
joinMessage.put(name, joinMsg);
}
@ -237,11 +264,16 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event) {
if (event.getPlayer() == null || Utils.isUnrestricted(event.getPlayer())) {
final Player player = event.getPlayer();
if (player == null || Utils.isUnrestricted(player)) {
return;
}
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL) {
// Get the permissions manager
PermissionsManager permsMan = plugin.getPermissionsManager();
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL
&& permsMan.hasPermission(player, PlayerPermission.IS_VIP)) {
int playersOnline = Utils.getOnlinePlayers().size();
if (playersOnline > plugin.getServer().getMaxPlayers()) {
event.allow();
@ -262,10 +294,6 @@ public class AuthMePlayerListener implements Listener {
return;
}
// Get the permissions manager
PermissionsManager permsMan = plugin.getPermissionsManager();
final Player player = event.getPlayer();
if (event.getResult() == PlayerLoginEvent.Result.KICK_FULL && !permsMan.hasPermission(player, PlayerPermission.IS_VIP)) {
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_FULL_SERVER));
event.setResult(PlayerLoginEvent.Result.KICK_FULL);
@ -311,12 +339,12 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer() == null) {
Player player = event.getPlayer();
if (player == null) {
return;
}
Player player = event.getPlayer();
if (Settings.delayJoinLeaveMessages && !Utils.checkAuth(player)) {
event.setQuitMessage(null);
}
@ -326,7 +354,9 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
if (event.getPlayer() == null) {
Player player = event.getPlayer();
if (player == null) {
return;
}
@ -336,13 +366,15 @@ public class AuthMePlayerListener implements Listener {
return;
}
Player player = event.getPlayer();
plugin.getManagement().performQuit(player, true);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (Utils.checkAuth(event.getPlayer())) {
Player player = event.getPlayer();
// TODO: npc status can be used to bypass security!!!
if (Utils.checkAuth(player) || Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
@ -350,7 +382,10 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent event) {
if (Utils.checkAuth(event.getPlayer())) {
Player player = event.getPlayer();
// TODO: npc status can be used to bypass security!!!
if (Utils.checkAuth(player) || Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
@ -358,7 +393,10 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
if (Utils.checkAuth(event.getPlayer())) {
Player player = event.getPlayer();
// TODO: npc status can be used to bypass security!!!
if (Utils.checkAuth(player) || Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
@ -367,7 +405,9 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
final Player player = (Player) event.getPlayer();
if (Utils.checkAuth(player)) {
// TODO: npc status can be used to bypass security!!!
if (Utils.checkAuth(player) || Utils.isNPC(player)) {
return;
}
event.setCancelled(true);
@ -392,6 +432,10 @@ public class AuthMePlayerListener implements Listener {
return;
if (Utils.checkAuth((Player) event.getWhoClicked()))
return;
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) event.getWhoClicked()))
return;
event.setCancelled(true);
}
@ -404,6 +448,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth((Player) damager)) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC((Player) damager)) {
return;
}
event.setCancelled(true);
}
@ -412,6 +461,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -420,6 +474,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -428,6 +487,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -436,6 +500,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -445,6 +514,11 @@ public class AuthMePlayerListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
Location spawn = plugin.getSpawnLocation(player);
@ -463,6 +537,11 @@ public class AuthMePlayerListener implements Listener {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
Player player = event.getPlayer();
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
return;
@ -481,6 +560,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}
@ -489,6 +573,11 @@ public class AuthMePlayerListener implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}

View File

@ -32,6 +32,11 @@ public class AuthMePlayerListener16 implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}

View File

@ -32,6 +32,11 @@ public class AuthMePlayerListener18 implements Listener {
if (Utils.checkAuth(event.getPlayer())) {
return;
}
// TODO: npc status can be used to bypass security!!!
if (Utils.isNPC(event.getPlayer())) {
return;
}
event.setCancelled(true);
}

View File

@ -328,7 +328,8 @@ public class PermissionsManager implements PermissionsService {
}
public boolean hasPermission(Player player, CommandDescription command) {
if (CollectionUtils.isEmpty(command.getCommandPermissions().getPermissionNodes())) {
if (command.getCommandPermissions() == null
|| CollectionUtils.isEmpty(command.getCommandPermissions().getPermissionNodes())) {
return true;
}

View File

@ -80,15 +80,12 @@ public class AsynchronousLogin {
plugin.captcha.remove(name);
plugin.captcha.putIfAbsent(name, i);
}
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
plugin.cap.put(name, rdm.nextString());
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
plugin.cap.putIfAbsent(name, rdm.nextString());
for (String s : m.retrieve(MessageKey.USAGE_CAPTCHA)) {
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
}
return true;
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
plugin.captcha.remove(name);
plugin.cap.remove(name);
}
}
return false;

View File

@ -47,7 +47,7 @@ public class AsynchronousQuit {
public void process() {
if (player == null)
return;
if (Utils.isNPC(player) || Utils.isUnrestricted(player)) {
if (Utils.isUnrestricted(player)) {
return;
}

View File

@ -137,7 +137,7 @@ public final class Utils {
// TODO: Move to a Manager
public static boolean checkAuth(Player player) {
if (player == null || Utils.isUnrestricted(player) || Utils.isNPC(player)) {
if (player == null || Utils.isUnrestricted(player)) {
return true;
}

View File

@ -13,19 +13,16 @@ import org.bukkit.Server;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.*;

View File

@ -3,4 +3,4 @@ if "%jarfile%" == "" (
call setvars.bat
)
mvn clean install -f "%pomfile%"
mvn clean install -f "%pomfile%" -B