Skip to content

Commit

Permalink
Fix #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya committed May 26, 2024
1 parent 0afa61b commit 590856a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package fr.euphyllia.skyllia.listeners.bukkitevents.paper;

import fr.euphyllia.skyllia.api.SkylliaAPI;
import fr.euphyllia.skyllia.api.configuration.WorldConfig;
import fr.euphyllia.skyllia.api.event.players.PlayerPrepareChangeWorldSkyblockEvent;
import fr.euphyllia.skyllia.configuration.ConfigToml;
import fr.euphyllia.skyllia.listeners.ListenersUtils;
import io.papermc.paper.event.entity.EntityInsideBlockEvent;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -29,15 +31,31 @@ public void onPlayerInsidePortal(final EntityInsideBlockEvent event) {
Block block = event.getBlock();
World world = block.getWorld();
if (!SkylliaAPI.isWorldSkyblock(world)) return;
//event.setCancelled(true); Todo ? Je ne sais plus pourquoi il est là
event.setCancelled(true);
Material blockType = block.getType();
switch (blockType) {
case NETHER_PORTAL -> {
ListenersUtils.callPlayerPrepareChangeWorldSkyblockEvent(player, PlayerPrepareChangeWorldSkyblockEvent.PortalType.NETHER, world.getName());
for (WorldConfig worldConfig : ConfigToml.worldConfigs) {
if (worldConfig.name().equalsIgnoreCase(world.getName())) {
if (worldConfig.netherPortal().enabled()) {
ListenersUtils.callPlayerPrepareChangeWorldSkyblockEvent(player, PlayerPrepareChangeWorldSkyblockEvent.PortalType.NETHER, world.getName());
}
break;
}
}
}
case END_PORTAL -> {
for (WorldConfig worldConfig : ConfigToml.worldConfigs) {
if (worldConfig.name().equalsIgnoreCase(world.getName())) {
if (worldConfig.endPortal().enabled()) {
ListenersUtils.callPlayerPrepareChangeWorldSkyblockEvent(player, PlayerPrepareChangeWorldSkyblockEvent.PortalType.END, world.getName());
}
break;
}
}
}
case END_PORTAL ->
ListenersUtils.callPlayerPrepareChangeWorldSkyblockEvent(player, PlayerPrepareChangeWorldSkyblockEvent.PortalType.END, world.getName());
}

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,6 @@ public TeleportEvent(InterneAPI interneAPI) {
this.api = interneAPI;
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerTeleportOnIsland(final PlayerTeleportEvent event) {
if (VersionUtils.IS_PAPER) return; // Use : EntityInsideBlockEvent
if (event.isCancelled()) {
return;
}
Location destination = event.getTo();
PlayerTeleportEvent.TeleportCause teleportCause = event.getCause();
if (teleportCause.equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) {
ListenersUtils.callPlayerPrepareChangeWorldSkyblockEvent(event.getPlayer(),
PlayerPrepareChangeWorldSkyblockEvent.PortalType.END, destination.getWorld().getName());
} else if (teleportCause.equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)) {
ListenersUtils.callPlayerPrepareChangeWorldSkyblockEvent(event.getPlayer(),
PlayerPrepareChangeWorldSkyblockEvent.PortalType.NETHER, destination.getWorld().getName());
}
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerUsePortal(final PlayerPortalEvent event) {
if (event.isCancelled()) return;
Expand Down

0 comments on commit 590856a

Please sign in to comment.