From 4fe6bfe955735e3eb4dcceac5405e7029327c702 Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Wed, 18 Dec 2013 22:09:54 +0000 Subject: [PATCH] fixed majob protect bug and possibly the player move deny bug --- .../com/sekwah/advancedportals/Listeners.java | 16 +++++++++++----- .../sekwah/advancedportals/PortalProtect.java | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java index 0d27369d..d1b9313b 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java @@ -71,13 +71,16 @@ public class Listeners implements Listener { // will check if the player is in the portal or not. if(Portal.portalsActive){ Player player = event.getPlayer(); - Location loc = player.getLocation(); + Location fromloc = event.getFrom(); + Location loc = event.getTo(); + Location eyeloc = event.getTo(); + eyeloc.setY(eyeloc.getY() + player.getEyeHeight()); Object[] portals = Portal.Portals; int portalId = 0; for(Object portal : portals){ - if(Portal.worldName[portalId].equals(player.getWorld().getName())){ - if(Portal.triggers[portalId].equals(player.getLocation().getBlock().getType()) - || Portal.triggers[portalId].equals(player.getEyeLocation().getBlock().getType())){ + if(Portal.worldName[portalId].equals(loc.getWorld().getName())){ + if(Portal.triggers[portalId].equals(loc.getBlock().getType()) + || Portal.triggers[portalId].equals(eyeloc.getBlock().getType())){ if((Portal.pos1[portalId].getX() + 1D) >= loc.getX() && (Portal.pos1[portalId].getY() + 1D) >= loc.getY() && (Portal.pos1[portalId].getZ() + 1D) >= loc.getZ()){ if(Portal.pos2[portalId].getX() <= loc.getX() && Portal.pos2[portalId].getY() <= loc.getY() && Portal.pos2[portalId].getZ() <= loc.getZ()){ @@ -85,7 +88,10 @@ public class Listeners implements Listener { DataCollector.playerWarped(); - // event.setCancelled(!warped); fix the warpback + if(warped){ + player.teleport(fromloc); + event.setCancelled(true); + } final Player finalplayer = event.getPlayer(); if(player.getGameMode().equals(GameMode.CREATIVE)){ diff --git a/Advanced Portals/src/com/sekwah/advancedportals/PortalProtect.java b/Advanced Portals/src/com/sekwah/advancedportals/PortalProtect.java index b2787019..06273026 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/PortalProtect.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/PortalProtect.java @@ -90,7 +90,6 @@ public class PortalProtect implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onExplosion(EntityExplodeEvent event){ - // Debug this as is was working at one point but it has stopped working List blockList = event.blockList(); for (int i = 0; i < blockList.size(); i++) { Block block = blockList.get(i); @@ -102,7 +101,6 @@ public class PortalProtect implements Listener { if((Portal.pos1[portalId].getX() + PortalProtectionRadius) >= block.getX() && (Portal.pos1[portalId].getY() + PortalProtectionRadius) >= block.getY() && (Portal.pos1[portalId].getZ() + PortalProtectionRadius) >= block.getZ()){ if((Portal.pos2[portalId].getX() - PortalProtectionRadius) <= block.getX() && (Portal.pos2[portalId].getY() - PortalProtectionRadius) <= block.getY() && (Portal.pos2[portalId].getZ() - PortalProtectionRadius) <= block.getZ()){ - System.out.println("Remove"); blockList.remove(i); i--; @@ -111,6 +109,7 @@ public class PortalProtect implements Listener { } } + portalId++; } } }