Solved Prevent Compass Teleportation?

Discussion in 'Plugin Development' started by CoderMusgrove, May 29, 2014.

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

    CoderMusgrove

    I've been looking on how to cancel the compass teleportation when left/right clicking, but all I ever turn up with is the CompassNavigation plugin. I'm trying to create a custom GUI to open when interacting with the compass, and I have that complete. The only problem is I keep teleporting. The code I am currently using to do everything:

    Code:
    if (item.getItemMeta().getDisplayName().equals(tools.getTeleporterItem().getItemMeta().getDisplayName())) {
        e.setCancelled(true);
        p.openInventory(Manager.getInstance().getServerTools().getTeleporterInventory().getInventory());
    }
    I would have expected to cancel the interaction event to allow it to work. I have looked into the PlayerTeleportEvent, and none of the causes list the reason for the compass. How would I cancel a teleportation event caused by a compass?
     
  2. its caused by worldedit. There isnt a teleport event caused by a compass. i think worldedit does it with
    Code:
    @EventHAndler
    public void onRightClick(PlayerInteractEvent e){
    if(e.getAction()==Action.RIGHT_CLICK_AIR){
    Player p = e.getPlayer();
    Block block = p.getTargetBlock(null, 500);
    if(block != null){
    p.teleport(block.getLocation().add(0,2,0));
    }else{
    p.sendMessage("You need to look to a block");
    }
    }
    }
    
    :/
     
  3. Offline

    CoderMusgrove

    Ok thanks, ;P
     
  4. Offline

    mickedplay

    I had the same problem a few weeks ago. :p
    You can change the teleportation item in the config of WorldEdit I think.
     
Thread Status:
Not open for further replies.

Share This Page