PlayerMoveEvent

Discussion in 'Plugin Development' started by TomTheDeveloper, Feb 25, 2013.

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

    TomTheDeveloper

    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (command.getName().equalsIgnoreCase("Parkourblock")){
                if ( sender instanceof Player){
                    if (args.length == 2){
                        Player p = (Player) sender;
                        if(args[0] == "1"){
                        config.set("Parkour.block.one.x", p.getLocation().getX());
                        config.set("Parkour.block.one.y", p.getLocation().getY());
                        config.set("Parkour.block.one.z", p.getLocation().getZ());
                        SaveConfig();
                        }else if(args[0] == "2"){
                        config.set("Parkour.block.two.x", p.getLocation().getX());
                        config.set("Parkour.block.two.y", p.getLocation().getY());
                        config.set("Parkour.block.two.z", p.getLocation().getZ());
                        SaveConfig();
                        }else if(args[0] == "3"){
                        config.set("Parkour.block.three.x", p.getLocation().getX());
                        config.set("Parkour.block.three.y", p.getLocation().getY());
                        config.set("Parkour.block.three.z", p.getLocation().getZ());
                        SaveConfig();
                        }else if(args[0] == "4"){
                        config.set("Parkour.block.four.x", p.getLocation().getX());
                        config.set("Parkour.block.four.y", p.getLocation().getY());
                        config.set("Parkour.block.four.z", p.getLocation().getZ());
                        SaveConfig();
                        }
                    }
                     
                }
            }
         
            return false;
        }
     
     
     
        @EventHandler
        public void PlayerMove(PlayerMoveEvent e){
            Location ploc = e.getPlayer().getLocation();
            if(  config.getDouble("Parkour.block.one.x") <  plocx < config.getDouble("Parkour.block.two.x") || config.getDouble("Parkour.block.one.x")> ploc.getX() > config.getDouble("Parkour.block.two.x")) {
    }
    What is wrong about this?
    It says The operator < is undefined for the argument type(s) boolean, double??
    I tried many different things but it didn't work, plz help :)
    Code:
    if(  config.getDouble("Parkour.block.one.x") <  plocx < config.getDouble("Parkour.block.two.x") || config.getDouble("Parkour.block.one.x")> ploc.getX() > config.getDouble("Parkour.block.two.x")) 
    }[/CODE]
     
  2. Offline

    masacrewayne

    Where is plocx initiated? Also, it means what it says at the line:

    Code:
    if( config.getDouble("Parkour.block.one.x") < plocx < config.getDouble("Parkour.block.two.x") || config.getDouble("Parkour.block.one.x")> ploc.getX() > config.getDouble("Parkour.block.two.x"))
    you are comparing a boolean with a double, I'll guess you have initiated plocx somewhere as a boolean and you mean to do ploc.getX()?
     
  3. Offline

    TomTheDeveloper

    oh, yes, but if i do ploc.getX() it doesn't work.
     
  4. Offline

    masacrewayne

    what error do you get then? Either way, you can't compare a boolean with a double, so if plocx is a boolean, you have to replace it.
     
  5. Offline

    skore87

    The reason you're seeing that message is because it evaluates the first part of the expression and this becomes a boolean:

    It then is trying to evaluate a boolean against a double.

    What you want to do instead is something like this (didn't care to look at your logic that carefully, but at least remember what I mentioned above):

    Code:
    if(  config.getDouble("Parkour.block.one.x") <  plocx && plocx < config.getDouble("Parkour.block.two.x") || config.getDouble("Parkour.block.one.x")> ploc.getX() && ploc.getX() > config.getDouble("Parkour.block.two.x")) {
     
  6. Offline

    TKramez

    Even if plocx is a double he is still comparing a boolean to a double because his statement goes like (thisconfig.getDouble("Parkour.block.one.x") < plocx) < config.getDouble("Parkour.block.two.x")
    ^is boolean ^is a double
     
  7. Offline

    TomTheDeveloper

    skore87, thx man, you solved it
    TKramez nope, that is not a boolean, if you do config.getDouble, then you say that you want a double from your configuration not a boolean.
     
  8. Offline

    TKramez

    I am pointing at what is in parentheses. For whatever reason it ate all my extra spaces.
     
Thread Status:
Not open for further replies.

Share This Page