diff --git a/Resources/config.yml b/Resources/config.yml
index 0cbda12..398be97 100644
--- a/Resources/config.yml
+++ b/Resources/config.yml
@@ -70,6 +70,7 @@ 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.
+
+# Not added yet
+# 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.
diff --git a/Resources/plugin.yml b/Resources/plugin.yml
index 268de06..e75d589 100644
--- a/Resources/plugin.yml
+++ b/Resources/plugin.yml
@@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
-version: 0.0.20
+version: 0.0.21
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:
diff --git a/pom.xml b/pom.xml
index 30f463e..64240f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
- 0.0.20-snapshot
+ 0.0.21-snapshot
UTF-8
1.7
diff --git a/src/com/sekwah/advancedportals/compat/CraftBukkit.java b/src/com/sekwah/advancedportals/compat/CraftBukkit.java
index a6cfa20..ded6b85 100644
--- a/src/com/sekwah/advancedportals/compat/CraftBukkit.java
+++ b/src/com/sekwah/advancedportals/compat/CraftBukkit.java
@@ -86,7 +86,7 @@ public class CraftBukkit {
playerConnection.getClass().getMethod("sendPacket", this.packet).invoke(playerConnection, packet);
- } catch (IllegalAccessException |InvocationTargetException | NoSuchMethodException | NoSuchFieldException
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | NoSuchFieldException
| InstantiationException e) {
this.plugin.getLogger().warning("Error creating raw message, something must be wrong with reflection");
e.printStackTrace();
diff --git a/src/com/sekwah/advancedportals/listeners/Listeners.java b/src/com/sekwah/advancedportals/listeners/Listeners.java
index 9b708b9..f2b3755 100644
--- a/src/com/sekwah/advancedportals/listeners/Listeners.java
+++ b/src/com/sekwah/advancedportals/listeners/Listeners.java
@@ -25,9 +25,8 @@ public class Listeners implements Listener {
// 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;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
@@ -38,8 +37,6 @@ public class Listeners implements Listener {
String ItemID = config.getConfig().getString("AxeItemId");
- PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
-
try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
} catch (Exception e) {
@@ -55,8 +52,6 @@ public class Listeners implements Listener {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
- ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
-
String ItemID = config.getConfig().getString("AxeItemId");
try {
@@ -83,7 +78,7 @@ public class Listeners implements Listener {
Location loc = event.getTo();
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
for (AdvancedPortal portal : Portal.Portals) {
- if (Portal.locationInPortalTrigger(portal, loc) | Portal.locationInPortalTrigger(portal, eyeLoc)) {
+ if (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc)) {
if (portal.trigger.equals(Material.PORTAL)) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
diff --git a/src/com/sekwah/advancedportals/portals/Portal.java b/src/com/sekwah/advancedportals/portals/Portal.java
index 8320b6a..f5caff1 100644
--- a/src/com/sekwah/advancedportals/portals/Portal.java
+++ b/src/com/sekwah/advancedportals/portals/Portal.java
@@ -5,16 +5,13 @@ import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
+import com.sekwah.advancedportals.api.portaldata.PortalArg;
import com.sekwah.advancedportals.destinations.Destination;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.World;
+import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
-import com.sekwah.advancedportals.api.portaldata.PortalArg;
+import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
@@ -22,6 +19,7 @@ import java.util.Set;
import java.util.logging.Level;
public class Portal {
+
public static HashMap cooldown = new HashMap();
// Config values
public static boolean portalsActive = false;
@@ -34,7 +32,7 @@ public class Portal {
public Portal(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
- cooldelay = config.getConfig().getInt("Cooldown");
+ cooldelay = config.getConfig().getInt("PortalCooldown");
Portal.plugin = plugin;
Portal.loadPortals();
@@ -370,6 +368,7 @@ public class Portal {
// 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op.
if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) {
player.sendMessage(PluginMessages.customPrefix + "\u00A7c You do not have permission to use this portal!");
+ throwPlayerBack(player);
return false;
}
@@ -377,6 +376,7 @@ public class Portal {
int diff = (int) ((System.currentTimeMillis() - cooldown.get(player)) / 1000);
if (diff < cooldelay) {
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + (cooldelay - diff) + ChatColor.RED + " seconds until attempting to teleport again.");
+ throwPlayerBack(player);
return false;
}
}
@@ -395,7 +395,7 @@ public class Portal {
command = command.substring(1);
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
try{
- plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
+ plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}
catch(Exception e){
plugin.getLogger().warning("Error while executing: " + command);
@@ -446,6 +446,7 @@ public class Portal {
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or portal doesn't exist!");
+ throwPlayerBack(player);
}
}
return false;
@@ -621,4 +622,10 @@ public class Portal {
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();
+ player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(0.7D));
+ }
}