Explorar o código

Fix issue with using /mcpurge, /mcremove, and /mmoupdate from the
console. These commands now default to OP, because frankly there are
much worse things someone can do with OP status than mess with the mcMMO
database.

GJ %!s(int64=12) %!d(string=hai) anos
pai
achega
d34a0cca30

+ 0 - 6
src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java

@@ -9,18 +9,12 @@ import org.bukkit.command.TabExecutor;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.locale.LocaleLoader;
-import com.gmail.nossr50.util.Permissions;
 
 import com.google.common.collect.ImmutableList;
 
 public class McpurgeCommand implements TabExecutor {
     @Override
     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
-        if (!Permissions.mcpurge(sender)) {
-            sender.sendMessage(command.getPermissionMessage());
-            return true;
-        }
-
         switch (args.length) {
             case 0:
                 mcMMO.getDatabaseManager().purgePowerlessUsers();

+ 0 - 6
src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java

@@ -12,7 +12,6 @@ import org.bukkit.util.StringUtil;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.datatypes.player.PlayerProfile;
 import com.gmail.nossr50.locale.LocaleLoader;
-import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.commands.CommandUtils;
 import com.gmail.nossr50.util.player.UserManager;
 
@@ -21,11 +20,6 @@ import com.google.common.collect.ImmutableList;
 public class McremoveCommand implements TabExecutor {
     @Override
     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
-        if (!Permissions.mcremove(sender)) {
-            sender.sendMessage(command.getPermissionMessage());
-            return true;
-        }
-
         switch (args.length) {
             case 1:
                 if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, new PlayerProfile(args[0], false))) {

+ 0 - 6
src/main/java/com/gmail/nossr50/commands/database/MmoupdateCommand.java

@@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.config.Config;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.runnables.database.SQLConversionTask;
-import com.gmail.nossr50.util.Permissions;
 import com.gmail.nossr50.util.player.UserManager;
 
 import com.google.common.collect.ImmutableList;
@@ -19,11 +18,6 @@ import com.google.common.collect.ImmutableList;
 public class MmoupdateCommand implements TabExecutor {
     @Override
     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
-        if (!Permissions.mmoupdate(sender)) {
-            sender.sendMessage(command.getPermissionMessage());
-            return true;
-        }
-
         if (!Config.getInstance().getUseMySQL()) {
             sender.sendMessage("SQL Mode is not enabled."); // TODO: Localize
             return true;

+ 0 - 1
src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java

@@ -140,5 +140,4 @@ public final class MobHealthbarUtils {
 
         return healthbar;
     }
-
 }

+ 3 - 0
src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java

@@ -256,6 +256,7 @@ public final class CommandRegistrationManager {
     private static void registerMcpurgeCommand() {
         PluginCommand command = mcMMO.p.getCommand("mcpurge");
         command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff()));
+        command.setPermission("mcmmo.commands.mcpurge");
         command.setPermissionMessage(permissionsMessage);
         command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
         command.setExecutor(new McpurgeCommand());
@@ -264,6 +265,7 @@ public final class CommandRegistrationManager {
     private static void registerMcremoveCommand() {
         PluginCommand command = mcMMO.p.getCommand("mcremove");
         command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
+        command.setPermission("mcmmo.commands.mcremove");
         command.setPermissionMessage(permissionsMessage);
         command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
         command.setExecutor(new McremoveCommand());
@@ -272,6 +274,7 @@ public final class CommandRegistrationManager {
     private static void registerMmoupdateCommand() {
         PluginCommand command = mcMMO.p.getCommand("mmoupdate");
         command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
+        command.setPermission("mcmmo.commands.mmoupdate");
         command.setPermissionMessage(permissionsMessage);
         command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
         command.setExecutor(new MmoupdateCommand());

+ 3 - 3
src/main/resources/plugin.yml

@@ -695,11 +695,14 @@ permissions:
             mcmmo.commands.mcability.others: true
             mcmmo.commands.mcgod: true
             mcmmo.commands.mcgod.others: true
+            mcmmo.commands.mcpurge: true
             mcmmo.commands.mcrank.others.all: true
             mcmmo.commands.mcrefresh: true
             mcmmo.commands.mcrefresh.others: true
+            mcmmo.commands.mcremove: true
             mcmmo.commands.mmoedit: true
             mcmmo.commands.mmoedit.others: true
+            mcmmo.commands.mmoupdate: true
             mcmmo.commands.ptp.world.all: true
             mcmmo.commands.skillreset.all: true
             mcmmo.commands.vampirism.all: true
@@ -796,7 +799,6 @@ permissions:
     mcmmo.commands.mcnotify:
         description: Allows access to the mcnotify command
     mcmmo.commands.mcpurge:
-        default: false
         description: Allows access to the mcpurge command
     mcmmo.commands.mcrank:
         description: Allows access to the mcrank command
@@ -822,7 +824,6 @@ permissions:
     mcmmo.commands.mcrefresh.others:
         description: Allows access to the mcrefresh command for other players
     mcmmo.commands.mcremove:
-        default: false
         description: Allows access to the mcremove command
     mcmmo.commands.mcscoreboard:
         description: Allows access to the mcscoreboard command
@@ -885,7 +886,6 @@ permissions:
     mcmmo.commands.mmoedit.others:
         description: Allows access to the mmoedit command for other players
     mcmmo.commands.mmoupdate:
-        default: false
         description: Allows access to the mmoupdate command
     mcmmo.commands.mobhealth:
          default: true