Teleport error with ProtocolLib

Discussion in 'Plugin Development' started by themixray, Mar 4, 2022.

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

    themixray

    Code:
    java.lang.IllegalArgumentException: location
    occurs in this part of the code
    Code:
    ProtocolLibrary.getProtocolManager().addPacketListener(
       new PacketAdapter(plugin,PacketType.Play.Client.USE_ENTITY) {
          @Override
          public void onPacketReceiving(PacketEvent event) {
               event.getPlayer().teleport(new Location(Bukkit.getWorld("hub"),0,65,-1)); // here
               // "hub" world has already been created via Bukkit.createWorld(new WorldCreator("hub"))
          }
       }
    );
    
    please help if someone has a solution
     
    Last edited: Mar 5, 2022
  2. Offline

    timtower Administrator Administrator Moderator

    @themixray What is the end goal of this function, seems way more complicated than it needs to be
     
  3. Offline

    themixray

    I'm trying to just teleport the player to the hub when he right-clicks on any entity or npc
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    themixray

    no, it doesn't work with npcs

    After fixing some bugs, I came to this
    Code:
    java.lang.IllegalStateException: PlayerTeleportEvent cannot be triggered asynchronously from another thread.
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 5, 2022
Thread Status:
Not open for further replies.

Share This Page