From 7d1e4f1d596a70b8aa7568d7c8e55f14ef43a68e Mon Sep 17 00:00:00 2001 From: Joshua Freedman Date: Fri, 31 Mar 2017 07:24:36 -0700 Subject: [PATCH] Think I fixed the event crash --- .../plugin/listener/BlockChangeListener.java | 12 ++++++++++-- .../foxguard/plugin/listener/ExplosionListener.java | 2 +- .../plugin/listener/SpawnEntityListener.java | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/BlockChangeListener.java b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/BlockChangeListener.java index 137544c..ea5dab5 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/BlockChangeListener.java +++ b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/BlockChangeListener.java @@ -94,18 +94,26 @@ public void handle(ChangeBlockEvent event) throws Exception { //FoxGuardMain.instance().getLogger().info(player.getName()); List handlerList; - World world = event.getTargetWorld(); + +// System.err.println(event); +// System.err.println(event.getClass()); +// System.err.println(event.getTransactions()); +// System.exit(1); + +// if (1 == 1) return; List> transactions = event.getTransactions(); Set handlerSet = new HashSet<>(); if (transactions.size() == 1) { - Vector3i pos = transactions.get(0).getFinal().getLocation().get().getBlockPosition(); + final World world = transactions.get(0).getFinal().getLocation().get().getExtent(); + final Vector3i pos = transactions.get(0).getFinal().getLocation().get().getBlockPosition(); FGManager.getInstance().getRegionsInChunkAtPos(world, pos).stream() .filter(region -> region.contains(pos, world)) .forEach(region -> region.getHandlers().stream() .filter(IFGObject::isEnabled) .forEach(handlerSet::add)); } else { + final World world = transactions.get(0).getFinal().getLocation().get().getExtent(); FGManager.getInstance().getRegionsAtMultiPosI( world, transactions.stream() diff --git a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/ExplosionListener.java b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/ExplosionListener.java index d0fc945..bc9ebc6 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/ExplosionListener.java +++ b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/ExplosionListener.java @@ -81,7 +81,7 @@ public void handle(ExplosionEvent event) throws Exception { } else user = null; } - World world = event.getTargetWorld(); + final World world = event.getExplosion().getLocation().getExtent(); FlagBitSet flags = FLAG_SET.clone(); Set handlerSet = new HashSet<>(); diff --git a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/SpawnEntityListener.java b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/SpawnEntityListener.java index 088e1e4..1618368 100644 --- a/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/SpawnEntityListener.java +++ b/src/main/java/net/foxdenstudio/sponge/foxguard/plugin/listener/SpawnEntityListener.java @@ -107,10 +107,11 @@ public void handle(SpawnEntityEvent event) throws Exception { } List handlerList = new ArrayList<>(); - World world = event.getTargetWorld(); +// World world = event.getTargetWorld(); for (Entity entity : event.getEntities()) { Vector3d pos = entity.getLocation().getPosition(); + final World world = entity.getLocation().getExtent(); FGManager.getInstance().getRegionsInChunkAtPos(world, pos).stream() .filter(region -> region.contains(pos, world)) .forEach(region -> region.getHandlers().stream()