mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-17 04:51:28 +01:00
Remove class permission commands.
These commands solve a very, very specific problem that it's safe to assume nobody has. It's safe to assume that most config editing happens in the actual config-file, and changing class permissions is probably one of the last things people would expect to find a command for. Removing these commands renders some methods in ArenaMaster and ArenaClass obsolete.
This commit is contained in:
parent
5699fafeb0
commit
a88556771f
@ -8,7 +8,6 @@ import com.garbagemule.MobArena.commands.admin.ForceCommand;
|
||||
import com.garbagemule.MobArena.commands.admin.KickCommand;
|
||||
import com.garbagemule.MobArena.commands.admin.RestoreCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.AddArenaCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.AddClassPermCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.AutoDegenerateCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.AutoGenerateCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.CheckDataCommand;
|
||||
@ -16,11 +15,9 @@ import com.garbagemule.MobArena.commands.setup.CheckSpawnsCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.ClassChestCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.ConfigCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.EditArenaCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.ListClassPermsCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.ListClassesCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.RemoveArenaCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.RemoveClassCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.RemoveClassPermCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.RemoveContainerCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.RemoveLeaderboardCommand;
|
||||
import com.garbagemule.MobArena.commands.setup.RemoveSpawnpointCommand;
|
||||
@ -246,9 +243,6 @@ public class CommandHandler implements CommandExecutor
|
||||
register(SetClassPriceCommand.class);
|
||||
register(RemoveClassCommand.class);
|
||||
register(ClassChestCommand.class);
|
||||
register(ListClassPermsCommand.class);
|
||||
register(AddClassPermCommand.class);
|
||||
register(RemoveClassPermCommand.class);
|
||||
|
||||
register(RemoveLeaderboardCommand.class);
|
||||
register(AutoGenerateCommand.class);
|
||||
|
@ -1,41 +0,0 @@
|
||||
package com.garbagemule.MobArena.commands.setup;
|
||||
|
||||
import com.garbagemule.MobArena.ArenaClass;
|
||||
import com.garbagemule.MobArena.commands.Command;
|
||||
import com.garbagemule.MobArena.commands.CommandInfo;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.util.TextUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandInfo(
|
||||
name = "addclassperm",
|
||||
pattern = "add(class)?perm(.*)",
|
||||
usage = "/ma addclassperm <classname> <permission>",
|
||||
desc = "add a per-class permission",
|
||||
permission = "mobarena.setup.classes"
|
||||
)
|
||||
public class AddClassPermCommand implements Command
|
||||
{
|
||||
@Override
|
||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Require classname and permission
|
||||
if (args.length != 2) return false;
|
||||
|
||||
// Grab the arena class
|
||||
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||
if (arenaClass == null) {
|
||||
am.getGlobalMessenger().tell(sender, "The class '" + TextUtils.camelCase(args[0]) + "' does not exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try to add the permission.
|
||||
if (am.addClassPermission(args[0], args[1])) {
|
||||
am.getGlobalMessenger().tell(sender, "Added permission '" + args[1] + "' to class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If it wasn't added, notify.
|
||||
am.getGlobalMessenger().tell(sender, "Permission '" + args[1] + "' was NOT added to class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.garbagemule.MobArena.commands.setup;
|
||||
|
||||
import com.garbagemule.MobArena.ArenaClass;
|
||||
import com.garbagemule.MobArena.commands.Command;
|
||||
import com.garbagemule.MobArena.commands.CommandInfo;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.things.Thing;
|
||||
import com.garbagemule.MobArena.util.TextUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandInfo(
|
||||
name = "listclassperms",
|
||||
pattern = "(list)?classperm(.*)s",
|
||||
usage = "/ma listclassperms <classname>",
|
||||
desc = "list per-class permissions",
|
||||
permission = "mobarena.setup.classes"
|
||||
)
|
||||
public class ListClassPermsCommand implements Command
|
||||
{
|
||||
@Override
|
||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Require a class name
|
||||
if (args.length != 1) return false;
|
||||
|
||||
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||
String className = TextUtils.camelCase(args[0]);
|
||||
|
||||
if (arenaClass == null) {
|
||||
am.getGlobalMessenger().tell(sender, "The class '" + className + "' does not exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
am.getGlobalMessenger().tell(sender, "Permissions for '" + className + "':");
|
||||
List<Thing> perms = arenaClass.getPermissions();
|
||||
if (perms.isEmpty()) {
|
||||
am.getGlobalMessenger().tell(sender, "<none>");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Thing perm : perms) {
|
||||
am.getGlobalMessenger().tell(sender, perm.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.garbagemule.MobArena.commands.setup;
|
||||
|
||||
import com.garbagemule.MobArena.ArenaClass;
|
||||
import com.garbagemule.MobArena.commands.Command;
|
||||
import com.garbagemule.MobArena.commands.CommandInfo;
|
||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.util.TextUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandInfo(
|
||||
name = "removeclassperm",
|
||||
pattern = "(del(.)*|r(e)?m(ove)?)(class)?perm(.*)",
|
||||
usage = "/ma removeclassperm <classname> <permission>",
|
||||
desc = "remove a per-class permission",
|
||||
permission = "mobarena.setup.classes"
|
||||
)
|
||||
public class RemoveClassPermCommand implements Command
|
||||
{
|
||||
@Override
|
||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||
// Require class name and permission
|
||||
if (args.length != 2) return false;
|
||||
|
||||
// Grab the arena class
|
||||
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||
if (arenaClass == null) {
|
||||
am.getGlobalMessenger().tell(sender, "The class '" + TextUtils.camelCase(args[0]) + "' does not exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove the permission.
|
||||
if (am.removeClassPermission(args[0], args[1])) {
|
||||
am.getGlobalMessenger().tell(sender, "Removed permission '" + args[1] + "' from class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If it wasn't removed, notify.
|
||||
am.getGlobalMessenger().tell(sender, "Permission '" + args[1] + "' was NOT removed from class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user