Gravity fixes

This commit is contained in:
Chiss 2014-03-14 20:17:06 +11:00
parent 24efe3d0d8
commit aa206d9c91
3 changed files with 73 additions and 31 deletions

View File

@ -0,0 +1,40 @@
package nautilus.game.arcade.events;
import nautilus.game.arcade.game.Game;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerPrepareTeleportEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Game _game;
private Player _player;
public PlayerPrepareTeleportEvent(Game game, Player player)
{
_game = game;
_player = player;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Game GetGame()
{
return _game;
}
public Player GetPlayer()
{
return _player;
}
}

View File

@ -47,6 +47,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.gravity.kits.*;
import nautilus.game.arcade.game.games.gravity.objects.GravityBomb;
@ -64,7 +65,7 @@ public class Gravity extends SoloGame
private HashMap<Player, GravityHook> _hooks = new HashMap<Player, GravityHook>();
private HashMap<Arrow, Vector> _arrows = new HashMap<Arrow, Vector>();
private ArrayList<Location> _powerups = new ArrayList<Location>();
private Location _powerup = null;
private long _lastPowerup = 0;
@ -106,7 +107,7 @@ public class Gravity extends SoloGame
this.CompassEnabled = true;
}
@Override
public void ParseData()
{
@ -114,26 +115,22 @@ public class Gravity extends SoloGame
}
@EventHandler
public void CreatePlayerObjects(GameStateChangeEvent event)
public void CreatePlayerObjects(PlayerPrepareTeleportEvent event)
{
if (event.GetState() != GameState.Prepare)
return;
Player player = event.GetPlayer();
for (Player player : GetPlayers(true))
{
GravityPlayer obj = new GravityPlayer(this, player, 60, null);
_objects.add(obj);
GravityPlayer obj = new GravityPlayer(this, player, 60, null);
_objects.add(obj);
player.setExp(0.9999f);
}
player.setExp(0.9999f);
}
@EventHandler
public void AnnounceBoost(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
Announce(C.Bold + C.cPurple + "Press " + C.Bold + C.cWhite + "DROP WEAPON" + C.Bold + C.cPurple + " to boost yourself off platforms!");
}
@ -522,17 +519,17 @@ public class Gravity extends SoloGame
{
if (UtilMath.offset(obj.Base.getLocation().add(0, 0.5, 0), arrow.getLocation()) > obj.Size)
continue;
if (obj instanceof GravityPlayer)
{
if (obj.Ent.equals(arrow.getShooter()))
continue;
}
BowExplode(arrow);
break;
}
if (!arrow.isValid() || arrow.getTicksLived() > 200)
{
arrow.remove();
@ -565,7 +562,7 @@ public class Gravity extends SoloGame
obj.AddVelocity(UtilAlg.getTrajectory(proj, obj.Base).multiply(0.4), 10);
//obj.CustomCollide(null);
if (obj.Ent instanceof Player)
{
//Damage Event
@ -574,7 +571,7 @@ public class Gravity extends SoloGame
UtilEnt.getName(proj.getShooter()), "Sonic Blast");
}
obj.GrabDelay = System.currentTimeMillis();
obj.SetMovingBat(true);
}
@ -614,50 +611,50 @@ public class Gravity extends SoloGame
//Remove
proj.remove();
}
@EventHandler
public void PowerupUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.SEC)
return;
if (!UtilTime.elapsed(_lastPowerup, 15000))
return;
if (_powerup == null)
_powerup = UtilAlg.Random(_powerups);
else
{
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.GREEN).with(Type.BALL).trail(false).build();
UtilFirework.playFirework(_powerup, effect);
}
}
@EventHandler
public void PowerupCollect(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_powerup == null)
return;
for (Player player : GetPlayers(true))
{
if (UtilMath.offset(player.getLocation(), _powerup) < 3)
{
UtilPlayer.message(player, F.main("Game", "You collected " + F.skill("Jetpack Fuel") + "!"));
player.setExp(Math.min(0.9999f, player.getExp() + 0.25f));
player.getWorld().playSound(player.getLocation(), Sound.DRINK, 1f, 0.5f);
_powerup = null;
_lastPowerup = System.currentTimeMillis();
break;
}
}

View File

@ -17,10 +17,12 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -489,9 +491,8 @@ public class GameManager implements Listener
public void run()
{
//Teleport
if (team != null)
team.SpawnTeleport(player);
team.SpawnTeleport(player);
Manager.Clear(player);
UtilInv.Clear(player);
@ -499,6 +500,10 @@ public class GameManager implements Listener
if (game.GetKit(player) != null)
game.GetKit(player).ApplyKit(player);
//Event
PlayerPrepareTeleportEvent playerStateEvent = new PlayerPrepareTeleportEvent(game, player);
UtilServer.getServer().getPluginManager().callEvent(playerStateEvent);
}
}, i);
}