Solved Block all but pk commands during parkour

Discussion in 'Plugin Help/Development/Requests' started by Scorpionvssub, Nov 25, 2015.

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

    Scorpionvssub

    on my games server there is parkour but..people tend to leave to /spawn which is in the same server and that means they stick with the parkour so they can play other games and my plugin still thinks they are in parkour and will react when they hit certain blocks.. Which is not good..

    So i wanna force them to only use certain commands or allow..

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)

    Code:
                final Player p = (Player)sender;
                if (!label.equalsIgnoreCase("pk") || !label.equalsIgnoreCase("pr") || !label.equalsIgnoreCase("parkour") || !label.equalsIgnoreCase("leave")) {
                    if (this.plugin.checkpoint.containsKey(p)) {
                        sender.sendMessage("Please only use parkour commands!");
                        return true;
                    }
                }
    I thought this would do it but apperantly doesn't work and i know its probably better to use a config whitelist with commands to make it easier on me, but yea..anyway hahaha gotta start somewhere i guess :p Tried looking for examples but didnt find any what i found mainly was "how to block commands" but was general and often saying "WorldGuard" or a ton of plugins that done just this but i need it within the plugin as i dont wanna block them completely only all commands apart from /pk /pr and /leave when inside a parkour.

    Edit: Tried

    Code:
        @EventHandler
        public void onCommandBlock(PlayerCommandPreprocessEvent e) {
            String msg = e.getMessage();
            if (!msg.equalsIgnoreCase("/pk") || !msg.equalsIgnoreCase("/pr") || !msg.equalsIgnoreCase("/parkour") || !msg.equalsIgnoreCase("/leave")){
                Player p = e.getPlayer();
                if (this.plugin.arena.containsKey(p)) {
                    p.sendMessage("Please only use parkour commands!");
                    e.setCancelled(true);
                }
            }
        }
    but this seems to block all commands all together
     
    Last edited: Nov 25, 2015
  2. Offline

    ObviousEmeralds

    Try to remove the /'s. I think it might already add those for you.
     
  3. Offline

    Scorpionvssub

    while its solved ill answer, the / were needed in order for it to work. used a bukkit,help type thing where it checks if the command excists at all then checks if its allowed
     
Thread Status:
Not open for further replies.

Share This Page