PermissionsEx Group Create

Discussion in 'Plugin Development' started by Hectiq, Feb 17, 2018.

Thread Status:
Not open for further replies.
  1. Hello, I Have A Problem. I Tried To Make A Little Script Where I Can Easily Create Pex Groups With A Short Command The Script:

    Code:
    package de.Groupcreate.commands;
    
    import org.bukkit.Sound;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import de.Createpexgroup.main.Main;
    
    public class CMD_creategroup implements CommandExecutor {
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
         
            Player Player = (Player)sender;
         
            if (cmd.getName().equalsIgnoreCase("creategroup")) {
                if (args.length == 0) {
                    if (Player.hasPermission("Groupcreate.creategroup")) {
                        Player.sendMessage(Main.prefix + "Usage: /creategroup (Groupname)");
                        Player.playSound(Player.getLocation(), Sound.ANVIL_USE, 3, 1);
                    } else {
                        Player.sendMessage(Main.noPerms);
                        Player.playSound(Player.getLocation(), Sound.BLAZE_DEATH, 3, 1);
                    }
                } if (args.length == 1) {
                    if (Player.hasPermission("Groupcreate.creategroup")) {
                        Player.sendMessage(Main.prefix + "Creating Group...");
                        Player.performCommand("pex group" + args[1] + "create");
                        Player.sendMessage(Main.prefix + "§aSUCCESS!");
                        Player.playSound(Player.getLocation(), Sound.LEVEL_UP, 3, 1);
                    }
                } if (args.length > 1) {
                    Player.sendMessage(Main.error);
                }
            }
         
            return false;
        }
     
    }
    
    But Always When I Run The Command This Happens:

    View attachment 31308

    If You Could Help Me That Would Be Great

    LG Hectiq
     
  2. Offline

    Zombie_Striker

    @Hectiq
    1. All variables should start with a lower case letter. "Player" should be "player"
    2. The sender can be a player, but it can also be the console, a command block, or any other entity that can send commands. Do an instanceof check before you cast sender to a player.
    3. Main problem: Arrays start at 0. To get the first object in the args array (the group name), use args[0]
     
  3. Well, I Tried The Main Problem Still The Same.
    Also I Tried 2 Still The Same.
    But Ill Test 1 Now
     
Thread Status:
Not open for further replies.

Share This Page