Sound effects and knockbacks!

This commit is contained in:
Shaun Bennett 2014-08-01 01:22:01 -05:00
parent fd01b4933b
commit fbe6ab2fdb
1 changed files with 31 additions and 7 deletions

View File

@ -15,6 +15,7 @@ import java.util.Set;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -137,16 +138,39 @@ public class ServerManager extends MiniPlugin
return; return;
} }
Player player = (Player)event.getEntity(); final 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;
}
if (!Recharge.Instance.use(player, "Portal Server", 1000, false, false)) if (!Recharge.Instance.use(player, "Portal Server", 1000, false, false))
return; 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()); String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector());