From 1c7709a18b56f80a05d941e696bee518ebe95d1f Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 4 Apr 2012 10:57:13 -0400 Subject: [PATCH] Added perm checks to skill commands --- Changelog.txt | 7 ++++--- .../com/gmail/nossr50/commands/general/InspectCommand.java | 1 - .../com/gmail/nossr50/commands/general/McstatsCommand.java | 1 - .../gmail/nossr50/commands/skills/AcrobaticsCommand.java | 5 +++++ .../com/gmail/nossr50/commands/skills/ArcheryCommand.java | 4 ++++ .../com/gmail/nossr50/commands/skills/AxesCommand.java | 4 ++++ .../gmail/nossr50/commands/skills/ExcavationCommand.java | 4 ++++ .../com/gmail/nossr50/commands/skills/FishingCommand.java | 5 +++++ .../gmail/nossr50/commands/skills/HerbalismCommand.java | 5 +++++ .../com/gmail/nossr50/commands/skills/MiningCommand.java | 5 +++++ .../com/gmail/nossr50/commands/skills/RepairCommand.java | 4 ++++ .../com/gmail/nossr50/commands/skills/SwordsCommand.java | 4 ++++ .../com/gmail/nossr50/commands/skills/TamingCommand.java | 4 ++++ .../com/gmail/nossr50/commands/skills/UnarmedCommand.java | 5 +++++ .../gmail/nossr50/commands/skills/WoodcuttingCommand.java | 4 ++++ src/main/resources/plugin.yml | 1 - 16 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 842d9a8ae..fe6a7f5b4 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -9,9 +9,10 @@ Key: Version 1.3.06-dev + Added API functions for obtaining offline profiles & profiles via player names - + Changed /addlevel command to work for offline users - + Changed PlayerProfile constructor to always take a boolean - + Changed getPlayerProfile funtion to work for online & offline users + + Added permissions check to skill functions + ! Changed /addlevel command to work for offline users + ! Changed PlayerProfile constructor to always take a boolean + ! Changed getPlayerProfile funtion to work for online & offline users Version 1.3.05 + Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) diff --git a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java index 679bd575f..f4f6c1c61 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -53,7 +53,6 @@ public class InspectCommand implements CommandExecutor { return true; } else { - if (sender instanceof Player && !sender.isOp()) { sender.sendMessage(mcLocale.getString("Inspect.Offline")); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java index 66e8be2d3..8127a7dd7 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java @@ -14,7 +14,6 @@ public class McstatsCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 9688e2726..4aab9bd05 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -21,6 +22,10 @@ public class AcrobaticsCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) { + return true; + } + Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index 11c5b9c04..a1b52851e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,9 @@ public class ArcheryCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index ebbfe7d28..e985efe17 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -19,6 +20,9 @@ public class AxesCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.axes")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index 3f39acc02..17d2b6834 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,9 @@ public class ExcavationCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index 71e53fb9d..70048a867 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -21,6 +22,10 @@ public class FishingCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) { + return true; + } + Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index a60dfa90f..d9a0dfb02 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,10 @@ public class HerbalismCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) { + return true; + } + Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index 054074bd7..e541323f8 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,10 @@ public class MiningCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.mining")) { + return true; + } + Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 8ddcf3fae..a88cd64a4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; @@ -22,6 +23,9 @@ public class RepairCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.repair")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 8f0490a8c..947bf948f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,9 @@ public class SwordsCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.swords")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index a1a800444..839103052 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; @@ -21,6 +22,9 @@ public class TamingCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.taming")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index 543a652c4..fe46b41a6 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,10 @@ public class UnarmedCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.unarmed")) { + return true; + } + Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index 4cafd51ec..6eeb7803d 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; @@ -20,6 +21,9 @@ public class WoodcuttingCommand implements CommandExecutor { return true; } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.woodcutting")) { + return true; + } Player player = (Player) sender; PlayerProfile PP = Users.getProfile(player); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 898f9ee31..6fecf2faa 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,6 @@ main: com.gmail.nossr50.mcMMO version: ${project.version}-b${BUILD_NUMBER} softdepend: [Spout] authors: - - TheYeti - nossr50 - NuclearW - gmcferrin