Block Compass teleporting

Discussion in 'Plugin Development' started by mickedplay, Mar 25, 2014.

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

    mickedplay

    How do I block the teleportation with the compass when using world edit/essentials?

    Thanks!
     
  2. Offline

    rfsantos1996

    mickedplay
    Block targetblock = player.getTargetBlock;
    if(targetblock != null) {
    player.teleport(targetblock.getLocation());
    }
     
  3. Offline

    RawCode

    revoke permission for this action, refer manual for permission string
     
  4. Offline

    mickedplay

  5. mickedplay Then you're in trouble. Plugins use permissions.
     
  6. Offline

    RawCode

  7. Offline

    mymaksimus

    Maybe block the teleoort event if player is holding compass or something like that
     
  8. Offline

    KillerDucky1

    It Will be 10x easier if he just setup the perms
     
  9. Offline

    Mysticate

    Yeah... go for perms! However, you could listen for a left-click or a right-click on compass, listen for a teleport event, then cancel it.
     
  10. Offline

    mickedplay

  11. mickedplay

    If you just want to change the item you can go to /plugins/WorldEdit/config.yml, and set navigation-wand.item to another item id.

    The permissions you must deny if you want to work with permissions are:
    - worldedit.navigation.jumpto.tool
    and
    - worldedit.navigation.thru.tool
     
  12. Offline

    mymaksimus

    Maybe you read this threaad before answering? He doesnt want to use perms.

    However; you said you tried already. Can you show us the code?
     
  13. Offline

    mickedplay

    @myamaksimus
    Code:java
    1.  
    2. PlayerInteractEvent
    3. if(CaptureTheFlag.playersInGame.contains(p) && CaptureTheFlag.status.getStatus() == 2)
    4. {
    5. if((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) && p.getItemInHand().getType() == Material.COMPASS)
    6. {
    7. e.setCancelled(true);
    8. }
    9. }
     
  14. Offline

    mymaksimus

    Mhm try following, remove all the ifs and so on and only try this:

    Code:
    @EventHandler(priority=EventPriority.HIGH)
    void onPlayerInteract(PlayerInteractEvent e){
        e.setCancelled(true);
    }
    are you able to teleport with the compass now?
    Did you registered this all?
    try sysouts to check if this method is called...
     
Thread Status:
Not open for further replies.

Share This Page