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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1469971648312
+
+ 1469971648312
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Advanced-Portals:jar
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.7
+
+
+
+
+
+
+
+
+
+
+
+ Advanced-Portals
+
+
+
+
+
+
+
+
+
+
+
+ all versions
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Resources/config.yml b/Resources/config.yml
index bac75c91..0cbda123 100644
--- a/Resources/config.yml
+++ b/Resources/config.yml
@@ -69,3 +69,7 @@ UseCustomPrefix: false
CustomPrefix: '&a[&eAdvancedPortals&a]'
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
+
+PortalCooldownJoin: 5 # How long after the player joins the server until they will be warped. (if a player joins in a portal it will be disabled until they exit it). 0 or lower to deactivate.
+
+PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
diff --git a/src/com/sekwah/advancedportals/listeners/Listeners.java b/src/com/sekwah/advancedportals/listeners/Listeners.java
index 8a8c1350..1521d316 100644
--- a/src/com/sekwah/advancedportals/listeners/Listeners.java
+++ b/src/com/sekwah/advancedportals/listeners/Listeners.java
@@ -20,17 +20,33 @@ import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.metadata.FixedMetadataValue;
+import java.util.HashMap;
+
public class Listeners implements Listener {
+ // TODO rewrite and remove unneeded listeners and also fix the warp delay using a hashmap of users last attempt times.
+
// The needed config values will be stored so they are easier to access later
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
private static boolean UseOnlyServerAxe = false;
- private static Material WandMaterial;
- private static boolean ShowBungeeMessage;
- private final AdvancedPortalsPlugin plugin;
- private int PortalMessagesDisplay = 2;
- private boolean teleportDuringMove = false;
+ /**
+ * Can't enter another portal until this time has passed.
+ */
+ private HashMap hasPortalCooldown = new HashMap();
+
+ /**
+ * Cant use portals until they leave one.
+ */
+ private HashMap hasPortalImmunity = new HashMap();
+
+ private static Material WandMaterial;
+
+ //private static boolean ShowBungeeMessage;
+
+ private final AdvancedPortalsPlugin plugin;
+
+ private int PortalMessagesDisplay = 2;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
@@ -58,7 +74,7 @@ public class Listeners implements Listener {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
- ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
+ //ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
String ItemID = config.getConfig().getString("AxeItemId");
@@ -77,8 +93,6 @@ public class Listeners implements Listener {
return;
}
- teleportDuringMove = false;
-
Player player = event.getPlayer();
Location fromloc = event.getFrom();
@@ -119,11 +133,9 @@ public class Listeners implements Listener {
//event.setCancelled(true);
} else {
- //player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
- //plugin.getLogger().info(String.valueOf(teleportDuringMove));
- if(!teleportDuringMove){
- event.setCancelled(true);
- }
+ player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
+
+ event.setCancelled(true);
}
}
@@ -146,32 +158,27 @@ public class Listeners implements Listener {
}
- @EventHandler(ignoreCancelled = false, priority = EventPriority.LOWEST)
- public void onPlayerTeleport(final PlayerTeleportEvent event){
+ /*@EventHandler(ignoreCancelled = false, priority = EventPriority.LOWEST)
+ public void onPlayerTeleport(PlayerTeleportEvent event){
Player player = event.getPlayer();
plugin.getLogger().info(String.valueOf(event.getCause()));
- if(event.getCause() != PlayerTeleportEvent.TeleportCause.NETHER_PORTAL && event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL){
- teleportDuringMove = true;
- }
- else{
- Location loc = player.getLocation();
- Object[] portals = Portal.Portals;
- for (AdvancedPortal portal : Portal.Portals) {
- if (portal.worldName.equals(player.getWorld().getName())) {
+ Location loc = player.getLocation();
+ Object[] portals = Portal.Portals;
+ for (AdvancedPortal portal : Portal.Portals) {
+ if (portal.worldName.equals(player.getWorld().getName())) {
- if ((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()) {
+ if ((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()) {
- if ((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()) {
+ if ((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()) {
- event.setCancelled(true);
+ event.setCancelled(true);
- }
}
-
}
+
}
}
- }
+ }*/
// These are here because java 7 can only take finals straight into a runnable
class RemoveLavaData implements Runnable{
diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java
index ecb48f55..3225db9e 100644
--- a/src/com/sekwah/advancedportals/portals/Portal.java
+++ b/src/com/sekwah/advancedportals/portals/Portal.java
@@ -485,4 +485,34 @@ public class Portal {
return false;
}
}
+
+
+ public AdvancedPortal playerInPortal(Player player, Location loc){
+
+ 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) >= loc.getX() && (portal.pos1.getY()) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()) {
+ if (portal.pos2.getX() <= loc.getX() && portal.pos2.getY() <= loc.getY() && portal.pos2.getZ() <= loc.getZ()) {
+ return portal;
+ }
+ }
+
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public AdvancedPortal playerInPortal(Player player){
+ return playerInPortal(player, null);
+ }
}