Solved God-Command

Discussion in 'Plugin Development' started by EnveRuleZZ, Jan 30, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Hey guys, unfortunately I'm back here again haha...So basically I want to make a God-Command. I tried everything but it just won't work. If god mode is enabled, the player still loses health...Yes, I registered my events :D My code:

    private Main plugin;
        public GodClass(Main plugin) {
            this.plugin = plugin;
        String noPerm = "§4You don't have permission to do that";
        public static ArrayList<String> god = new ArrayList<String>();
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("god")) {
                Player p = (Player) sender;
                String usage = "§8Usage:§6 /god (<Player>)";
                if(args.length == 0) {
                    if(p.hasPermission("freebuild.god")) {
                        if(!(god.contains(p.getName()))) {
                            p.sendMessage("§8You are now in God Mode");
                            p.sendMessage("§8You are no longer in God Mode");
                }else if(args.length == 1) {
            return false;
        public void onDamage(EntityDamageEvent e) {
        Entity ent = e.getEntity();
        if(e instanceof Player) {
            Player p = (Player) ent;
            if(god.contains(p.getName())) {
  2. Offline


    • Does your command class implement CommandExecutor/Listener?
    • Does the command work in the first place?
    • Have you tried using debugging messages (sending messages to console/player)
    • Are you sure the player is in the list (print the list to see if they're there)
    These are just a bunch of basic checks that I would run if I found something not working right.
  3. Offline


    Look closely
  4. Offline


    Oooh, oops sorry I didn't see that, thank you haha my bad :D @SuperOriginal
    SuperOriginal likes this.
Thread Status:
Not open for further replies.

Share This Page