mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 00:30:07 +01:00
Updating permissions for the /mcgod command.
This commit is contained in:
parent
d68dfe2a32
commit
749443454d
@ -5,23 +5,29 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcgod")) {
|
||||
if (!Permissions.mcgodCommand(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
@ -36,7 +42,43 @@ public class McgodCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
case 1:
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and
|
||||
// check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check if the player is online before we try to send them a message.
|
||||
if (player.isOnline()) {
|
||||
if (profile.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,8 +83,12 @@ public final class Permissions {
|
||||
return hasPermission(sender, "mcmmo.tools.mmoedit");
|
||||
}
|
||||
|
||||
public static boolean mcgod(Player player) {
|
||||
return hasPermission(player, "mcmmo.tools.mcgod");
|
||||
/**
|
||||
* @deprecated Use {@link #mcgodCommand(player)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean mcgod(CommandSender sender) {
|
||||
return hasPermission(sender, "mcmmo.tools.mcgod");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -568,6 +572,10 @@ public final class Permissions {
|
||||
return (hasPermission(player, "mcmmo.commands.mcability") || mcAbility(player));
|
||||
}
|
||||
|
||||
public static boolean mcgodCommand(CommandSender sender) {
|
||||
return (hasPermission(sender, "mcmmo.commands.mcgod"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #mcAbilityCommand(player)} instead.
|
||||
*/
|
||||
@ -596,7 +604,6 @@ public final class Permissions {
|
||||
return hasPermission(player, "mcmmo.skillreset");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MCMMO.CHAT.*
|
||||
*/
|
||||
|
@ -337,6 +337,8 @@ permissions:
|
||||
description: Allows access to mmoedit command
|
||||
mcmmo.tools.mcgod:
|
||||
description: Allows access to mcgod command
|
||||
children:
|
||||
mcmmo.commands.mcgod: true
|
||||
mcmmo.tools.mcremove:
|
||||
decription: Allows access to mcremove and mcpurge command
|
||||
mcmmo.ability.*:
|
||||
@ -698,6 +700,8 @@ permissions:
|
||||
mcmmo.commands.inspect.far: true
|
||||
mcmmo.commands.inspect.offline: true
|
||||
mcmmo.commands.mcability.others: true
|
||||
mcmmo.commands.mcgod: true
|
||||
mcmmo.commands.mcgod.others: true
|
||||
mcmmo.commands.mmoedit: true
|
||||
mcmmo.commands.mmoedit.others: true
|
||||
mcmmo.commands.mmoupdate: true
|
||||
@ -742,6 +746,10 @@ permissions:
|
||||
description: Allows access to the mcability command
|
||||
mcmmo.commands.mcability.others:
|
||||
description: Allows access to the mcability command for other players
|
||||
mcmmo.commands.mcgod:
|
||||
description: Allows access to the mcgod command
|
||||
mcmmo.commands.mcgod.others:
|
||||
description: Allows access to the mcgod command for other players
|
||||
mcmmo.commands.mmoedit:
|
||||
description: Allows access to the mmoedit command
|
||||
mcmmo.commands.mmoedit.others:
|
||||
|
Loading…
Reference in New Issue
Block a user