From a91e92c001607db58151f69289d97c6ffdc388c4 Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 25 Mar 2020 15:46:43 -0400 Subject: [PATCH] Remove portal listener on 1.8 --- .../com/songoda/epicanchors/EpicAnchors.java | 4 ++++ .../epicanchors/listeners/BlockListeners.java | 7 ------- .../listeners/PortalListeners.java | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java diff --git a/src/main/java/com/songoda/epicanchors/EpicAnchors.java b/src/main/java/com/songoda/epicanchors/EpicAnchors.java index 5b26d0c..e32c491 100644 --- a/src/main/java/com/songoda/epicanchors/EpicAnchors.java +++ b/src/main/java/com/songoda/epicanchors/EpicAnchors.java @@ -4,6 +4,7 @@ import com.songoda.core.SongodaCore; import com.songoda.core.SongodaPlugin; import com.songoda.core.commands.CommandManager; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.configuration.Config; import com.songoda.core.gui.GuiManager; import com.songoda.core.hooks.EconomyManager; @@ -14,6 +15,7 @@ import com.songoda.epicanchors.anchor.AnchorManager; import com.songoda.epicanchors.commands.*; import com.songoda.epicanchors.listeners.BlockListeners; import com.songoda.epicanchors.listeners.InteractListeners; +import com.songoda.epicanchors.listeners.PortalListeners; import com.songoda.epicanchors.settings.Settings; import com.songoda.epicanchors.tasks.AnchorTask; import com.songoda.epicanchors.tasks.VisualizeTask; @@ -91,6 +93,8 @@ public class EpicAnchors extends SongodaPlugin { PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.registerEvents(new BlockListeners(this), this); pluginManager.registerEvents(new InteractListeners(this), this); + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) + pluginManager.registerEvents(new PortalListeners(this), this); // Register Hologram Plugin HologramManager.load(this); diff --git a/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java b/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java index dbfa78a..7f989d8 100644 --- a/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java +++ b/src/main/java/com/songoda/epicanchors/listeners/BlockListeners.java @@ -7,7 +7,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.world.PortalCreateEvent; import org.bukkit.inventory.ItemStack; public class BlockListeners implements Listener { @@ -38,10 +37,4 @@ public class BlockListeners implements Listener { plugin.updateHologram(anchor); } - - @EventHandler - public void onPortalCreation(PortalCreateEvent e) { - if (e.getBlocks().size() < 1) return; - if (plugin.getAnchorManager().isAnchor(e.getBlocks().get(0).getLocation())) e.setCancelled(true); - } } diff --git a/src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java b/src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java new file mode 100644 index 0000000..09ecaf6 --- /dev/null +++ b/src/main/java/com/songoda/epicanchors/listeners/PortalListeners.java @@ -0,0 +1,21 @@ +package com.songoda.epicanchors.listeners; + +import com.songoda.epicanchors.EpicAnchors; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.world.PortalCreateEvent; + +public class PortalListeners implements Listener { + + private EpicAnchors plugin; + + public PortalListeners(EpicAnchors instance) { + this.plugin = instance; + } + + @EventHandler + public void onPortalCreation(PortalCreateEvent e) { + if (e.getBlocks().size() < 1) return; + if (plugin.getAnchorManager().isAnchor(e.getBlocks().get(0).getLocation())) e.setCancelled(true); + } +}