TP Stick Help

Discussion in 'Plugin Development' started by Circlestorm, Jan 29, 2021.

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

    Circlestorm

    Hello, i am making a plugin where you can craft a tp stick, and where you click on that it teleports the player to that location. The recipe works fine, but the actual teleportation does not work. Please help xD
     

    Attached Files:

  2. Offline

    Chr0mosom3

    A couple of things.

    1) You should paste in your code and format it correctly using [ CODE ] and [/ CODE ] (without the spaces between the brackets

    2) Instead of ==, you should use the .equals() method

    3) You should log messages to the system to check what works and doesn't

    4) Did you register the event? Did you check that it fires?
     
  3. Offline

    Kars

    ^ when comparing strings.

    @Circlestorm but your main problem is that getClickedBlock will only be set when the player is within range of the block he is interacting with.
    If you want to teleport at a distance, get the block using LivingEntity#getTargetBlock.

    Also there is really no reason not to use IntelliJ.
     
  4. Offline

    Circlestorm

    Ok will try that thank you guys xD

    ok, i modified my code so if e.getAction().equals(Action.RIGHT_CLICK_BLOCK) it will send back a message to me. It doesn't do that. Is clicking not registered in the player interact event?
    i imported my listener with this.getServer().getPluginManager().registerEvents(this, this)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jan 29, 2021
  5. Offline

    Kars

    Like i said, only use equals when comparing strings.
    You need to annotate the method with @EventHandler.
     
  6. Offline

    Circlestorm

    I don't know how I didn't see that thank you! xD will try

    so i tried it, it works now,
    but i noticed it throws two ender pearls instead of 1.
    Also how would i cancel ender pearl damage in PlayerTeleportEvent?
     

    Attached Files:

    Last edited by a moderator: Jan 30, 2021
  7. Offline

    Kars

    ^ @Circlestorm
     
  8. Offline

    Chr0mosom3

    PlayerInteractEvent fires twice, one for main hand and second time for off hand, just check what equipment slot it is, and if it isn't main hand return. You can find the exact solution if you google it

    Sent from my motorola one vision using Tapatalk
     
  9. Offline

    Circlestorm

    ok cool, thank you guys, as for the seoncd part about how to cancel ender pearl damage from playerteleportevent is taht possible?
     
  10. Offline

    Chr0mosom3

    Create a listener for PlayerDamageEvent, and check if e#getCause() equals to DamageCause.TELEPORT or something like that

    Sent from my motorola one vision using Tapatalk

    And objects
    Eclipse is more popular in BukkitDev and cooler ^^

    Sent from my motorola one vision using Tapatalk

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  11. Offline

    Newdel

    Maybe more popular but definitly too old and bad
    Where tf is a program without real options to customize it and without any advantages better/cooler than a fully customizable program with helpful shortcuts, plugins (literally a mc dev plugin) and many other cool features
     
    Kars likes this.
  12. Offline

    Kars

    .equals() might return true in certain implementations so == if you intend to check for instance equality.
    Eclipse is a dinosaur and IntelliJ is superior in every way.
     
    Newdel likes this.
  13. Offline

    timtower Administrator Administrator Moderator

    As side conversation: fine, but make sure that there is ontopic talk as well.
    Nothing wrong yet, just a friendly heads up.
     
Thread Status:
Not open for further replies.

Share This Page