Added portal fail launchback

This commit is contained in:
Alastair 2016-08-04 03:26:08 +00:00
parent 5312eab16b
commit 4134b77502
6 changed files with 23 additions and 20 deletions

View File

@ -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.

View File

@ -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:

View File

@ -16,7 +16,7 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<version>0.0.20-snapshot</version>
<version>0.0.21-snapshot</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>

View File

@ -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();

View File

@ -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));

View File

@ -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<Player, Long> cooldown = new HashMap<Player, Long>();
// 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));
}
}