mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-26 02:48:15 +01:00
fixed majob protect bug and possibly the player move deny bug
This commit is contained in:
parent
409f3453ac
commit
4fe6bfe955
@ -71,13 +71,16 @@ public class Listeners implements Listener {
|
|||||||
// will check if the player is in the portal or not.
|
// will check if the player is in the portal or not.
|
||||||
if(Portal.portalsActive){
|
if(Portal.portalsActive){
|
||||||
Player player = event.getPlayer();
|
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;
|
Object[] portals = Portal.Portals;
|
||||||
int portalId = 0;
|
int portalId = 0;
|
||||||
for(Object portal : portals){
|
for(Object portal : portals){
|
||||||
if(Portal.worldName[portalId].equals(player.getWorld().getName())){
|
if(Portal.worldName[portalId].equals(loc.getWorld().getName())){
|
||||||
if(Portal.triggers[portalId].equals(player.getLocation().getBlock().getType())
|
if(Portal.triggers[portalId].equals(loc.getBlock().getType())
|
||||||
|| Portal.triggers[portalId].equals(player.getEyeLocation().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.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()){
|
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();
|
DataCollector.playerWarped();
|
||||||
|
|
||||||
// event.setCancelled(!warped); fix the warpback
|
if(warped){
|
||||||
|
player.teleport(fromloc);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
final Player finalplayer = event.getPlayer();
|
final Player finalplayer = event.getPlayer();
|
||||||
if(player.getGameMode().equals(GameMode.CREATIVE)){
|
if(player.getGameMode().equals(GameMode.CREATIVE)){
|
||||||
|
@ -90,7 +90,6 @@ public class PortalProtect implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onExplosion(EntityExplodeEvent event){
|
public void onExplosion(EntityExplodeEvent event){
|
||||||
// Debug this as is was working at one point but it has stopped working
|
|
||||||
List<Block> blockList = event.blockList();
|
List<Block> blockList = event.blockList();
|
||||||
for (int i = 0; i < blockList.size(); i++) {
|
for (int i = 0; i < blockList.size(); i++) {
|
||||||
Block block = blockList.get(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.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()){
|
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);
|
blockList.remove(i);
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
@ -111,6 +109,7 @@ public class PortalProtect implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
portalId++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user