From fbe6ab2fdbca1812ef3257169512185ba02c57e9 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 1 Aug 2014 01:22:01 -0500 Subject: [PATCH] Sound effects and knockbacks! --- .../mineplex/hub/server/ServerManager.java | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index de70133ad..9aece8640 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -15,6 +15,7 @@ import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -137,16 +138,39 @@ public class ServerManager extends MiniPlugin return; } - Player player = (Player)event.getEntity(); - - if (!_hubManager.CanPortal(player) || getMillisecondsUntilPortal(player) > 0) - { - UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1, true, 0.8, 0, 1, true); - return; - } + final Player player = (Player)event.getEntity(); if (!Recharge.Instance.use(player, "Portal Server", 1000, false, false)) return; + + long timeUntilPortal = getMillisecondsUntilPortal(player); + if (!_hubManager.CanPortal(player) || timeUntilPortal > 0) + { + if (timeUntilPortal > 0) + { + player.playSound(player.getEyeLocation(), Sound.CHICKEN_EGG_POP, 2, 2); + player.sendMessage("You cannot join a server for " + C.cGreen + UtilTime.convertString(timeUntilPortal, 0, TimeUnit.SECONDS) + ChatColor.RESET + "."); + } + + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1.5, true, 0.8, 0, 1.0, true); + + // Need to set their velocity again a tick later + // Setting Y-Velocity while in a portal doesn't seem to do anything... Science! + _plugin.getServer().getScheduler().runTask(_plugin, new Runnable() + { + + @Override + public void run() + { + if (player != null && player.isOnline()) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1, true, 0.5, 0, 1.0, true); + } + } + }); + + return; + } String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector());