From 1b3eeb32ba69617bb4ce074e3491c7def5eca638 Mon Sep 17 00:00:00 2001 From: jojo Date: Sat, 29 Aug 2020 00:29:56 +0200 Subject: [PATCH] Add PortalListener for joining to the Bau World --- src/de/steamwar/lobby/LobbySystem.java | 1 + .../lobby/listener/EnderPearlListener.java | 2 +- .../steamwar/lobby/listener/PortalListener.java | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/de/steamwar/lobby/listener/PortalListener.java diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 3e96350..31e9cfa 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -23,6 +23,7 @@ public class LobbySystem extends JavaPlugin { pm.registerEvents(new ParticleListener(), instance); pm.registerEvents(new PlayerHiderListener(), instance); pm.registerEvents(new EnderPearlListener(), instance); + pm.registerEvents(new PortalListener(), instance); } diff --git a/src/de/steamwar/lobby/listener/EnderPearlListener.java b/src/de/steamwar/lobby/listener/EnderPearlListener.java index ac388f7..3446ef3 100644 --- a/src/de/steamwar/lobby/listener/EnderPearlListener.java +++ b/src/de/steamwar/lobby/listener/EnderPearlListener.java @@ -39,7 +39,7 @@ public class EnderPearlListener implements Listener { if(player == null) //in case of player leave return; LobbyInventory.givePlayerLobbyItems(player); - }, 20 * 3); + }, 20 * 4); } @EventHandler diff --git a/src/de/steamwar/lobby/listener/PortalListener.java b/src/de/steamwar/lobby/listener/PortalListener.java new file mode 100644 index 0000000..cd5895d --- /dev/null +++ b/src/de/steamwar/lobby/listener/PortalListener.java @@ -0,0 +1,15 @@ +package de.steamwar.lobby.listener; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerPortalEvent; + +public class PortalListener implements Listener { + + @EventHandler + public void portalEnter(PlayerPortalEvent event) { + event.setCancelled(true); + event.getPlayer().performCommand("/bau"); + } + +}