Skip to content

Commit

Permalink
Handle end portal (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
Faun471 authored Oct 21, 2023
1 parent 2b2d870 commit 6d0e8bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public Configuration() {
public boolean allowPvPOnIslands = false;
public int distance = 151;
public int netherUnlockLevel = 10;
public int endUnlockLevel = 20;
public int pasterDelayInTick = 1;
public int pasterLimitPerTick = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public Messages() {
public String voidLostItems = "%prefix% &7You've lost %items%!";
public String netherIslandsDisabled = "%prefix% &7Nether islands have been disabled.";
public String netherLocked = "%prefix% &7Reach Island level %level% to unlock the Nether.";
public String endIslandsDisabled = "%prefix% &7End islands have been disabled.";
public String endLocked = "%prefix% &7Reach Island level %level% to unlock the End.";
public String islandBorderChanged = "%prefix% &7%player% has changed your Island border to %color%.";
public String borderColorDisabled = "%prefix% &7That border color has been disabled.";
public String notAColor = "%prefix% &7That is not a valid color.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,26 @@ public void onPlayerPortal(PlayerPortalEvent event) {
}
World world = Objects.equals(event.getFrom().getWorld(), nether) ? IridiumSkyblock.getInstance().getTeamManager().getWorld(World.Environment.NORMAL) : nether;
event.setTo(island.getCenter(world));
} else if (event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL) {
if (island.getLevel() < IridiumSkyblock.getInstance().getConfiguration().endUnlockLevel) {
event.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().endLocked
.replace("%level%", String.valueOf(IridiumSkyblock.getInstance().getConfiguration().endUnlockLevel))
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
event.setCancelled(true);
return;
}
World end = IridiumSkyblock.getInstance().getIslandManager().getWorld(World.Environment.THE_END);
if (end == null) {
event.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().endIslandsDisabled
.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)
));
event.setCancelled(true);
return;
}
World world = Objects.equals(event.getFrom().getWorld(), end) ? IridiumSkyblock.getInstance().getTeamManager().getWorld(World.Environment.NORMAL) : end;
event.setTo(island.getCenter(world));
}
});
}

}

0 comments on commit 6d0e8bb

Please sign in to comment.