Okay, lets fix everything that depended on Permissions

This commit is contained in:
TheYeti 2012-02-06 11:24:33 -08:00
parent 5645c29dd8
commit 11e1dc7ec8
7 changed files with 24 additions and 21 deletions

View File

@ -23,7 +23,12 @@ public class AddxpCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.permissionsEnabled) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
sender.sendMessage("This command requires permissions.");
return true;
}
@ -55,8 +60,6 @@ public class AddxpCommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
if (!mcPermissions.getInstance().mmoedit(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;

View File

@ -24,7 +24,7 @@ public class MmoeditCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.permissionsEnabled) {
if (!mcPermissions.getInstance().mmoedit((Player) sender)) {
sender.sendMessage("This command requires permissions.");
return true;
}

View File

@ -33,8 +33,7 @@ public class StatsCommand implements CommandExecutor {
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
if (mcPermissions.getEnabled())
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
ChatColor header = ChatColor.GOLD;

View File

@ -6,7 +6,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
@ -14,7 +13,12 @@ import com.gmail.nossr50.locale.mcLocale;
public class McabilityCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!mcPermissions.permissionsEnabled) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player != null && player.hasPermission("mcmmo.commands.ability")) {
sender.sendMessage("This command requires permissions.");
return true;
}
@ -29,7 +33,6 @@ public class McabilityCommand implements CommandExecutor {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (PP.getAbilityUse()) {

View File

@ -28,12 +28,12 @@ public class McgodCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (mcPermissions.permissionsEnabled) {
if (!mcPermissions.getInstance().mcgod(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (!mcPermissions.getInstance().mcgod(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (mcPermissions.getInstance().mcgod(player)) {
if (PP.getGodMode()) {
player.sendMessage(mcLocale.getString("mcPlayerListener.GodModeDisabled"));
PP.toggleGodMode();

View File

@ -31,7 +31,7 @@ public class XplockCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
if (PP.getXpBarLocked()) {
PP.setSkillLock(Skills.getSkillType(args[0]));
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) }));
@ -52,7 +52,7 @@ public class XplockCommand implements CommandExecutor {
}
} else if (args.length >= 1 && !Skills.isSkill(args[0])) {
player.sendMessage("Commands.xplock.invalid");
} else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
} else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}

View File

@ -24,11 +24,9 @@ import org.bukkit.entity.Player;
public class mcPermissions
{
private static volatile mcPermissions instance;
public static void initialize(Server server)
{
Logger log = Logger.getLogger("Minecraft");
public boolean permission(Player player, String perm) {
return player.hasPermission(perm);
}
public boolean admin(Player player){