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

Disabled nether portals in galactifun worlds #160

Merged
merged 12 commits into from
Jul 9, 2024
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ Inspiration taken from ClayTech and the mod GalactiCraft.

## Download

Download here (just click the badge!):
Download here (just click the badge!):

[![Build Status](https://thebusybiscuit.github.io/builds/Slimefun-Addon-Community/Galactifun/master/badge.svg)](https://thebusybiscuit.github.io/builds/Slimefun-Addon-Community/Galactifun/master)

## Discord

Feel free to join us on the Slimefun Addon Community Discord:

https://discord.gg/SqD3gg5SAU
https://discord.gg/SqD3gg5SAU
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.PortalCreateEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;

Expand Down Expand Up @@ -181,6 +183,20 @@ public Collection<AlienWorld> alienWorlds() {
return Collections.unmodifiableCollection(this.alienWorlds.values());
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onPortalCreate(PortalCreateEvent e) {
if (!Galactifun.instance().getConfig().getBoolean("worlds.allow-nether-portals") && getAlienWorld(e.getWorld()) != null) {
e.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void portal(PlayerPortalEvent e){
if (!Galactifun.instance().getConfig().getBoolean("worlds.allow-nether-portals") && getAlienWorld(e.getFrom().getWorld()) != null){
e.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlanetChange(@Nonnull PlayerChangedWorldEvent e) {
AlienWorld object = getAlienWorld(e.getFrom());
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ worlds:
# This should be the name main world where people work on stuff and make bases.
earth-name: world

# If set to true, players can use Nether portals in Galactifun planet worlds.
allow-nether-portals: false

aliens:

# How often aliens tick in Minecraft ticks - there are 20 ticks in 1 second
Expand Down
Loading