From 50455376def37d86b5b5640e92e28a5e8146c972 Mon Sep 17 00:00:00 2001 From: Max Qian Date: Mon, 15 Aug 2016 15:17:55 -0700 Subject: [PATCH 1/2] You didn't merge correctly! --- .../listeners/PortalProtect.java | 5 - .../advancedportals/portals/Portal.java | 98 ------------------- 2 files changed, 103 deletions(-) diff --git a/src/com/sekwah/advancedportals/listeners/PortalProtect.java b/src/com/sekwah/advancedportals/listeners/PortalProtect.java index dc2a1a8..c450f3f 100644 --- a/src/com/sekwah/advancedportals/listeners/PortalProtect.java +++ b/src/com/sekwah/advancedportals/listeners/PortalProtect.java @@ -54,11 +54,6 @@ public class PortalProtect implements Listener { @EventHandler(priority = EventPriority.HIGH) public void onExplosion(EntityExplodeEvent event) { - - if (!Portal.portalsActive) { - return; - } - List blockList = event.blockList(); for (int i = 0; i < blockList.size(); i++) { Block block = blockList.get(i); diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index f5caff1..fc91e1b 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -525,104 +525,6 @@ public class Portal { return false; } - public static AdvancedPortal locationInPortal(Location loc){ - return locationInPortal(loc, 0); - } - - /** - * Only returns the first portal found. May have issues with additional area but overlapping should not occour at 0. - * @param loc - * @param additionalArea - * @return - */ - public static AdvancedPortal locationInPortal(Location loc, int additionalArea){ - - if (!Portal.portalsActive) { - return null; - } - - for (AdvancedPortal portal : Portal.Portals) { - if (loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName())) { - if ((portal.pos1.getX() + 1D + additionalArea) >= loc.getX() && (portal.pos1.getY() + additionalArea) >= loc.getY() && (portal.pos1.getZ() + 1D + additionalArea) >= loc.getZ()) { - if (portal.pos2.getX() - additionalArea <= loc.getX() && portal.pos2.getY() - additionalArea <= loc.getY() && portal.pos2.getZ() - additionalArea <= loc.getZ()) { - return portal; - } - } - } - } - return null; - } - - public static AdvancedPortal blockLocationInPortal(Location loc){ - return locationInPortal(loc, 0); - } - - public static AdvancedPortal blockLocationInPortal(Location loc, int additionalArea){ - - if (!Portal.portalsActive) { - return null; - } - - for (AdvancedPortal portal : Portal.Portals) { - if (loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName())) { - if ((portal.pos1.getX() + additionalArea) >= loc.getX() && (portal.pos1.getY() + additionalArea) >= loc.getY() && (portal.pos1.getZ() + additionalArea) >= loc.getZ()) { - if (portal.pos2.getX() - additionalArea <= loc.getX() && portal.pos2.getY() - additionalArea <= loc.getY() && portal.pos2.getZ() - additionalArea <= loc.getZ()) { - return portal; - } - } - } - } - return null; - } - - - /** - * Only returns the first portal found. May have issues with additional area but overlapping should not occour at 0. - * @param player - * @param loc - * @param additionalArea - * @return - */ - public static AdvancedPortal playerInPortal(Player player, Location loc, int additionalArea){ - - if (!Portal.portalsActive) { - return null; - } - - if(loc == null){ - loc = player.getLocation(); - } - - Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ()); - - for (AdvancedPortal portal : Portal.Portals) { - if (loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName())) { - if (portal.trigger.equals(loc.getBlock().getType()) - || portal.trigger.equals(eyeLoc.getBlock().getType())) { - if ((portal.pos1.getX() + 1D + additionalArea) >= loc.getX() && (portal.pos1.getY() + additionalArea) >= loc.getY() && (portal.pos1.getZ() + 1D + additionalArea) >= loc.getZ()) { - if (portal.pos2.getX() - additionalArea <= loc.getX() && portal.pos2.getY() - additionalArea <= loc.getY() && portal.pos2.getZ() - additionalArea <= loc.getZ()) { - return portal; - } - } - - } - } - } - return null; - } - - public static AdvancedPortal playerInPortal(Player player){ - return playerInPortal(player, null, 0); - } - - public static AdvancedPortal playerInPortal(Player player, Location loc){ - return playerInPortal(player, loc, 0); - } - - public static AdvancedPortal playerInPortal(Player player, int additionalArea){ - return playerInPortal(player, null, additionalArea); - } - public static void throwPlayerBack(Player player){ // Not ensured to remove them out of the portal but it makes it feel nicer for the player. Vector velocity = player.getLocation().getDirection(); From 161a56d28100acd1c67ed87743e5c4d937e01e30 Mon Sep 17 00:00:00 2001 From: Max Qian Date: Mon, 15 Aug 2016 16:26:27 -0700 Subject: [PATCH 2/2] Add throwback config --- Resources/config.yml | 1 + src/com/sekwah/advancedportals/portals/Portal.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Resources/config.yml b/Resources/config.yml index 2940d45..4ca88cb 100644 --- a/Resources/config.yml +++ b/Resources/config.yml @@ -71,3 +71,4 @@ CustomPrefix: '&a[&eAdvancedPortals&a]' CustomPrefixFail: '&c[&7AdvancedPortals&c]' PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate. +ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java index fc91e1b..41b38e1 100644 --- a/src/com/sekwah/advancedportals/portals/Portal.java +++ b/src/com/sekwah/advancedportals/portals/Portal.java @@ -27,12 +27,14 @@ public class Portal { private static AdvancedPortalsPlugin plugin; public static ConfigAccessor portalData = new ConfigAccessor(plugin, "portals.yml"); private static boolean ShowBungeeMessage; - private static int cooldelay = 5; + private static int cooldelay; + private static double throwback; public Portal(AdvancedPortalsPlugin plugin) { ConfigAccessor config = new ConfigAccessor(plugin, "config.yml"); ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage"); - cooldelay = config.getConfig().getInt("PortalCooldown"); + cooldelay = config.getConfig().getInt("PortalCooldown", 5); + throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7); Portal.plugin = plugin; Portal.loadPortals(); @@ -527,7 +529,9 @@ public class Portal { public static void throwPlayerBack(Player player){ // Not ensured to remove them out of the portal but it makes it feel nicer for the player. - Vector velocity = player.getLocation().getDirection(); - player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(0.7D)); + if (throwback > 0) { + Vector velocity = player.getLocation().getDirection(); + player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(throwback)); + } } }