Started work on Permissions/isOP() support.

This commit is contained in:
Rigby 2011-03-14 22:55:36 +00:00
parent b8ee4c7f53
commit 178b15926f
3 changed files with 54 additions and 6 deletions

View File

@ -20,8 +20,13 @@ public class MVCoord extends MVCommandHandler {
@Override
public boolean perform(CommandSender sender, String[] args) {
// TODO: Add Permissions
// Check if the command was sent from a Player.
if(sender instanceof Player){
// If this command was sent from a Player then we need to check Permissions
if(!(plugin.ph.has(((Player) sender), "multiverse.coord"))){
sender.sendMessage("You do not have access to this command.");
return true;
}
Player p = (Player) sender;
p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName());
@ -29,6 +34,8 @@ public class MVCoord extends MVCommandHandler {
p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + locMan.strCoords(p.getLocation()));
p.sendMessage(ChatColor.RED + "Direction: " + ChatColor.WHITE + locMan.getDirection(p.getLocation()));
p.sendMessage(ChatColor.RED + "Block: " + ChatColor.WHITE + Material.getMaterial(p.getWorld().getBlockTypeIdAt(p.getLocation())));
} else {
sender.sendMessage("This command needs to be used from a Player.");
}
return true;
}

View File

@ -1,21 +1,55 @@
package com.onarandombox.MultiVerseCore.commands;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.onarandombox.MultiVerseCore.MVCommandHandler;
import com.onarandombox.MultiVerseCore.MVWorld;
import com.onarandombox.MultiVerseCore.MultiVerseCore;
public class MVList extends MVCommandHandler {
public MVList(MultiVerseCore plugin) {
super(plugin);
// TODO Auto-generated constructor stub
}
@Override
public boolean perform(CommandSender sender, String[] args) {
// TODO Auto-generated method stub
return false;
}
Player p = null;
if(sender instanceof Player){
p = (Player) sender;
if(!(plugin.ph.has(p, "multiverse.world.list"))){
sender.sendMessage("You do not have access to this command.");
return true;
}
}
String output = ChatColor.GREEN + "Worlds which you can view - \n";
MultiVerseCore.debugMsg("Size - " + plugin.worlds.size());
for(int i=0;i<plugin.getServer().getWorlds().size();i++){
World world = plugin.getServer().getWorlds().get(i);
if(!(plugin.worlds.containsKey(world.getName()))){ continue; }
if(p!=null && (!plugin.ph.canEnterWorld(p, world))){ continue; }
ChatColor color;
if (world.getEnvironment() == Environment.NETHER)
color = ChatColor.RED;
else
color = ChatColor.GREEN;
output += color + world.getName() + " - " + world.getEnvironment().toString() + " \n";
}
String[] response = output.split("\n");
for(String msg : response){
sender.sendMessage(msg);
}
return true;
}
}

View File

@ -20,7 +20,14 @@ public class MVWho extends MVCommandHandler {
@Override
public boolean perform(CommandSender sender, String[] args) {
// TODO: Permissions
// If this command was sent from a Player then we need to check Permissions
if(sender instanceof Player){
if(!(plugin.ph.has(((Player) sender), "multiverse.who"))){
sender.sendMessage("You do not have access to this command.");
return true;
}
}
List<World> worlds = new ArrayList<World>();
if(args.length>1){