Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make entities appear at world spawn when they go trough exit end portal #265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.event.MVPlayerTouchedPortalEvent;
import com.onarandombox.MultiverseCore.utils.PermissionTools;
import com.onarandombox.MultiverseNetherPortals.MultiverseNetherPortals;
Expand Down Expand Up @@ -146,9 +147,12 @@ private Location getLocation(Entity e, Location currentLocation, PortalType type
} else {
String destinationWorld = "";

boolean shouldAppearAtSpawn = false;

if (this.nameChecker.isValidEndName(currentWorld)) {
if (type == PortalType.ENDER) {
destinationWorld = this.nameChecker.getNormalName(currentWorld, type);
shouldAppearAtSpawn = true;
} else if (type == PortalType.NETHER) {
destinationWorld = this.nameChecker.getNetherName(this.nameChecker.getNormalName(currentWorld, type));
}
Expand All @@ -166,7 +170,14 @@ private Location getLocation(Entity e, Location currentLocation, PortalType type
}
}

newTo = this.linkChecker.findNewTeleportLocation(currentLocation, destinationWorld, e);
if (shouldAppearAtSpawn) {
MultiverseWorld tpTo = this.worldManager.getMVWorld(destinationWorld);
SafeTTeleporter teleporter = this.plugin.getCore().getSafeTTeleporter();
Location safeSpawn = teleporter.getSafeLocation(tpTo.getSpawnLocation());
newTo = this.linkChecker.findNewTeleportLocation(safeSpawn, destinationWorld, e);
} else {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, destinationWorld, e);
}
}
}

Expand Down
Loading