Remove Item WorldChange?

Discussion in 'Plugin Development' started by Luca0212, May 7, 2020.

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

    Luca0212

    Hello I'm just trying on a plugin I made in 2017, I recently found a bug there but can't get it removed.

    My problem is that players get an item if they join a certain world, only the item should be removed as soon as they enter a 2nd specified world (or go back)

    The whole thing is a SilentLobby plugin so I created a FileManger where the worlds are registered as you can see in the code the worlds are registered in the main.

    I have now come so far that the item only works properly in the SilentLobby, but the item is not removed when you return to the lobby.

    I've tried a few things to get it removed but either I'm doing something wrong or I'm just too stupid to fix it.

    The code may not be the best since it was part of my early days but I don't want to do it from scratch now and just know how the code has to look in order to work.

    I have a link here to call the code.

    https://pastebin.com/LR4XJLHE

    About Help I would be happy.

    Greetings Luca
     
  2. Offline

    JRL1004

    @Luca0212
    You are checking the PlayerJoinEvent. This is not the correct event use as it is called when a player connects to the server, not when a player teleports between worlds. The event you may be looking for is the PlayerChangedWorldEvent. See https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerChangedWorldEvent.html. I know the link says spigot. I haven't got the slightest idea where the official CraftBukkit APIs went. Also related but possible less helpful would be the PlayerTeleportEvent.
     
Thread Status:
Not open for further replies.

Share This Page