mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Clean up a little more from our permissions reworking.
This commit is contained in:
parent
d3c8a5565a
commit
75894c4419
@ -10,6 +10,7 @@ import com.gmail.nossr50.commands.CommandHelper;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||||
@ -20,9 +21,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
|
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
|
||||||
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
|
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
|
||||||
|
|
||||||
// DEPRECATED PERMISSION
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate") && !Permissions.admin((Player) sender)) {
|
||||||
boolean oldPermission = !CommandHelper.noCommandPermissions(sender, "mcmmo.admin");
|
|
||||||
if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate")) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (args[0].equalsIgnoreCase("reset")) {
|
||||||
if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.reset") && !Permissions.admin((Player) sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (Misc.isInt(args[0])) {
|
if (Misc.isInt(args[0])) {
|
||||||
if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.xprate.set") && !Permissions.admin((Player) sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||||
|
@ -10,49 +10,60 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McabilityCommand implements CommandExecutor {
|
public class McabilityCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
PlayerProfile profile;
|
||||||
|
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"mcability", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability") && !Permissions.mcAbility((Player) sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile = Users.getProfile((Player) sender);
|
||||||
|
|
||||||
|
if (profile.getAbilityUse()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.toggleAbilityUse();
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// DEPRECATED PERMISSION
|
case 1:
|
||||||
boolean oldPermission = !CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability");
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability.others")) {
|
||||||
|
|
||||||
if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerProfile profile = null;
|
|
||||||
|
|
||||||
if(args.length > 0 && args[0] != null) {
|
|
||||||
if (!oldPermission && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability.others")) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
OfflinePlayer modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||||
profile = Users.getProfile(modifiedPlayer);
|
profile = Users.getProfile(modifiedPlayer);
|
||||||
}
|
|
||||||
else
|
|
||||||
profile = Users.getProfile((Player) sender);
|
|
||||||
|
|
||||||
if (profile == null) {
|
// TODO:Not sure if we actually need a null check here
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
if (profile == null || !profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile.getAbilityUse()) {
|
||||||
|
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.toggleAbilityUse();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(usage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getAbilityUse()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.toggleAbilityUse();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,6 +564,14 @@ public final class Permissions {
|
|||||||
return (hasPermission(player, "mcmmo.commands.skillreset") || skillReset(player));
|
return (hasPermission(player, "mcmmo.commands.skillreset") || skillReset(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean mcAbilityCommand(Player player) {
|
||||||
|
return (hasPermission(player, "mcmmo.commands.mcability") || mcAbility(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #mcAbilityCommand(player)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean mcAbility(Player player) {
|
public static boolean mcAbility(Player player) {
|
||||||
return hasPermission(player, "mcmmo.commands.ability");
|
return hasPermission(player, "mcmmo.commands.ability");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user