1.16.5 Can't teleport player to another world via end portal.

Discussion in 'Spigot Plugin Development' started by Diaburo, Oct 4, 2021.

  1. Code (Java):
    World world;
    List<Location> portal;
    Code (Java):
        public void onPortal(EntityPortalEnterEvent event) {
            if (portal != null && portal.contains(event.getLocation())) {
                if (world == null) {
                    event.getEntity().sendMessage("World not set");
                else {
    Code (Java):
    File[] files = Bukkit.getWorldContainer().listFiles();
    for (File file : files) {
       if (file.isDirectory() && file.getName().equalsIgnoreCase(args[1])) {
          WorldCreator creator = new WorldCreator(file.getName());
          world = Bukkit.createWorld(creator);
          sender.sendMessage(ChatColor.GREEN + "World Found!");
    so, i want to make the player to be teleported when he enter a specific end portal, but it wont work and he is teleported to the end, im since yesterday trying a bunch of stuff but none works, thank you if you can help
  2. Have you tried cancelling the event with event#setCancelled?
  3. yes but i cant cancel EntityPortalEnterEvent
  4. Hmmm have you tried PlayerPortalEvent and then using event#setTo?
  5. Code (Java):
    isn't working
  6. Code (Text):

    public void onPlayerEnterPortal(PlayerPortalEvent e) {
        e.setTo(new Location(Bukkit.getWorld("parkour"), 0, 100, 0));
    I tried the above and it worked, did you register your listener?
  7. i just tested it, its working, but if i try to put this:
    Code (Java):
    if (portal != null && portal.contains(event.getFrom())) {
    it wont work
  8. Obviously your list of locations doesnt exactly contain the location where the player stood since a location uses doubles as coordinates.

    I‘d create a wrapper class for location that simply uses the block/int coordinates in its equals(Object) method
    • Like Like x 2