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

Respawn in Overworld from Nether/End #155

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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 @@ -4,6 +4,7 @@

import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.utils.PermissionTools;
import com.onarandombox.MultiverseNetherPortals.MultiverseNetherPortals;
import com.onarandombox.MultiverseNetherPortals.enums.PortalType;
Expand Down Expand Up @@ -80,11 +81,21 @@ public void onPlayerPortal(PlayerPortalEvent event) {
this.linkChecker.getNewTeleportLocation(event, currentLocation, this.nameChecker.getNormalName(currentWorld, PortalType.END));
}
} else {
if(type == PortalType.END) {
this.linkChecker.getNewTeleportLocation(event, currentLocation, this.nameChecker.getEndName(currentWorld));
} else {
this.linkChecker.getNewTeleportLocation(event, currentLocation, this.nameChecker.getNetherName(currentWorld));
MultiverseWorld toWorld;
if (type == PortalType.END) toWorld = this.worldManager.getMVWorld(this.nameChecker.getEndName(currentWorld));
else toWorld = this.worldManager.getMVWorld(this.nameChecker.getNetherName(currentWorld));

try {
if (toWorld.getPropertyValue("respawnWorld").isEmpty()) {
toWorld.setRespawnToWorld(currentWorld);
this.worldManager.saveWorldsConfig(); // is this necessary?
nicegamer7 marked this conversation as resolved.
Show resolved Hide resolved
this.plugin.log(Level.FINE, "Setting respawnWorld of " + toWorld.getName() + " to " + currentWorld + ".");
}
} catch (PropertyDoesNotExistException e) {
this.plugin.log(Level.WARNING, "Uh oh... your players may not respawn in the correct world. Please let us know about this.");
}

this.linkChecker.getNewTeleportLocation(event, currentLocation, toWorld.getName());
}
if (event.getTo() == null || event.getFrom() == null) {
return;
Expand All @@ -95,6 +106,7 @@ public void onPlayerPortal(PlayerPortalEvent event) {
event.setTo(originalTo);
return;
}

MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());

Expand Down