Solved Eject() not working

Discussion in 'Plugin Development' started by Ahrigumi, Jun 5, 2019.

  1. Offline


    Hi there! so... the title says all hehe, im trying to eject the passenger but doesnt work. (I dont hace null on cmd or errors)
            Player mensaje = event.getPlayer();
            Horse caballo = (Horse) event.getRightClicked();
            UUID uuid = caballo.getUniqueId();
            AnimalTamer propietario = (AnimalTamer) caballo.getOwner();
            String UUID = main.dueƱosConfig.getString("Horses." + mensaje.getUniqueId().toString() + "." + uuid + ".Owner");
            String caballoName = main.dueƱosConfig
                    .getString("Horses." + mensaje.getUniqueId().toString() + "." + uuid + ".Name");
                if (caballo instanceof Horse) {
                    if (caballo.getOwner() != null) {
                        if (((Tameable) caballo).isTamed()) {
                            if (main.color(caballo.getName()).equals(main.color(caballoName))) {
                                if (propietario.getName().equals(UUID)) {
                                    mensaje.sendMessage("You are the owner of " + main.color(caballoName));
                                } else {
  2. Offline


    @Ahrigumi Try ejecting the player 1 tick later, it might have something to do with the fact that the player hasn't gotten on the horse yet.
  3. @Ahrigumi FYI instead of doing tons of nested ifs you can just do 1 and use && for each check.
    Example: if (function() && uuid.equals(player.getUniqueId()))

    Also, it seems your final if won't ever be true, if a name equals a UUID?
  4. Offline


  5. @KarimAKL Doesn't matter if its a string, never complained about it being a type mismatch. The fact is he's comparing a player name to a players UUID

    Look at the code ;)
  6. Offline


    @bwfcwalshy Oh, i thought that's what you meant, my bad.
    But looking at this thread, it seems that 'Owner' is a name, not a UUID, so i would say it's more of an inappropriate name.
    bwfcwalshy likes this.

Share This Page