Add BaseCommand#canRun, OpCommand and MapAdminCommand for permissions
This commit is contained in:
parent
8c49ddf6f6
commit
a9eac7f7e7
@ -25,6 +25,11 @@ public abstract class BaseCommand
|
||||
_aliases = Arrays.asList(aliases);
|
||||
}
|
||||
|
||||
public boolean canRun(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract boolean execute(Player player, String alias, String[] args);
|
||||
|
||||
public String getDescription()
|
||||
|
@ -0,0 +1,32 @@
|
||||
package mineplex.mapparser.command;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.mapparser.MapParser;
|
||||
|
||||
public abstract class MapAdminCommand extends BaseCommand
|
||||
{
|
||||
public MapAdminCommand(MapParser plugin, String... aliases)
|
||||
{
|
||||
super(plugin, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRun(Player player)
|
||||
{
|
||||
if (player.isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
World world = player.getWorld();
|
||||
|
||||
if (world.getName().equals("world_lobby"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return getPlugin().getData(world.getName()).HasAccess(player);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package mineplex.mapparser.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.mapparser.MapParser;
|
||||
|
||||
public abstract class OpCommand extends BaseCommand
|
||||
{
|
||||
public OpCommand(MapParser plugin, String... aliases)
|
||||
{
|
||||
super(plugin, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRun(Player player)
|
||||
{
|
||||
return player.isOp();
|
||||
}
|
||||
}
|
@ -95,6 +95,11 @@ public class CommandModule extends Module
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!baseCommand.canRun(player))
|
||||
{
|
||||
player.sendMessage(F.main(getPlugin().getName(), "You don't have permission to do that."));
|
||||
}
|
||||
|
||||
if (!baseCommand.execute(player, commandLabel, args))
|
||||
{
|
||||
UtilPlayerBase.message(player, F.main("Parser", "Invalid Input."));
|
||||
|
Loading…
Reference in New Issue
Block a user