Added project start

This commit is contained in:
Morten 2015-07-16 01:34:57 +02:00
parent 5f73e50b2a
commit d46ac59e10

View File

@ -57,76 +57,74 @@ public class WitherGame extends TeamGame implements IBlockRestorer
private GameTeam _withers;
private double _witherFactor = 2.5;
private int _yLimit = 0;
private long _gameTime = 300000;
private HashMap<Player, PlayerCopy> _doubles = new HashMap<Player, PlayerCopy>();
// private int _livesPerPlayer = 3;
// private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
// private int _livesPerPlayer = 3;
// private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
private HashSet<BlockData> _blocks = new HashSet<BlockData>();
public WitherGame(ArcadeManager manager)
{
super(manager, GameType.WitherAssault,
new Kit[]
{
new KitHumanArcher(manager),
//new KitHumanBuilder(manager),
//new KitHumanRunner(manager),
new NullKit(manager),
new NullKit(manager),
new NullKit(manager),
new Kit[]
{
new KitHumanArcher(manager), new NullKit(manager),
new NullKit(manager), new NullKit(manager),
new KitWitherMinion(manager),
//new KitWitherWeb(manager),
//new KitWitherWeb(manager),
},
},
new String[]
{
C.cGreen + "Humans" + C.cWhite + " Run and hide from the Withers",
new String[]
{
C.cGreen + "Humans" + C.cWhite
+ " Run and hide from the Withers",
C.cGreen + "Humans" + C.cWhite + " Revive your dead allies!",
C.cGreen + "Humans" + C.cWhite + " Win by surviving for 5 minutes",
C.cGreen + "Humans" + C.cWhite
+ " Win by surviving for 5 minutes",
" ",
C.cRed + "Withers" + C.cWhite + " Moves very slowly when near ground",
C.cRed + "Withers" + C.cWhite + " Kill all the Humans within 5 Minutes",
});
C.cRed + "Withers" + C.cWhite
+ " Moves very slowly when near ground",
C.cRed + "Withers" + C.cWhite
+ " Kill all the Humans within 5 Minutes",
});
this.DeathOut = true;
this.DamageTeamSelf = false;
this.DamageSelf = false;
this.DeathSpectateSecs = 4;
this.HungerSet = 20;
this.WorldBoundaryKill = false;
this.CompassEnabled = true;
this.CompassGiveItem = false;
this.KitRegisterState = GameState.Prepare;
this.TeamArmor = true;
this.TeamArmorHotbar = false;
_help = new String[]
{
C.cRed + C.Bold + "This game is still under development!",
};
_help = new String[]
{
C.cRed + C.Bold + "This game is still under development!",
};
}
@Override
public void ParseData()
public void ParseData()
{
_yLimit = WorldData.GetDataLocs("RED").get(0).getBlockY();
}
@EventHandler
public void teamSetup(GameStateChangeEvent event)
public void teamSetup(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
return;
@ -140,7 +138,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
_withers = team;
_withers.SetName("Withers");
_withers.SetColor(ChatColor.RED);
if (!kit.GetName().contains("Wither"))
team.GetRestrictedKits().add(kit);
}
@ -149,7 +147,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
_runners = team;
_runners.SetName("Humans");
_runners.SetColor(ChatColor.GREEN);
if (kit.GetName().contains("Wither"))
team.GetRestrictedKits().add(kit);
}
@ -166,95 +164,106 @@ public class WitherGame extends TeamGame implements IBlockRestorer
if (event.getType() != UpdateType.FAST)
return;
//Not Enough Players
// Not Enough Players
if (_runners.GetPlayers(true).size() < 2)
return;
//Enough Withers
if (_withers.GetPlayers(true).size() * _witherFactor >= _runners.GetPlayers(true).size())
// Enough Withers
if (_withers.GetPlayers(true).size() * _witherFactor >= _runners
.GetPlayers(true).size())
return;
Player player = UtilAlg.Random(_runners.GetPlayers(true));
setWither(player, true);
}
public void setWither(Player player, boolean forced)
{
// _lives.remove(player);
// _lives.remove(player);
SetPlayerTeam(player, _withers, true);
//Kit
Kit newKit = GetKits()[4];
// Kit
Kit newKit = GetKits()[4];
SetKit(player, newKit, false);
newKit.ApplyKit(player);
player.teleport(_withers.GetSpawn());
if (forced)
{
AddGems(player, 10, "Forced Wither", false, false);
Announce(F.main("Game", F.elem(_withers.GetColor() + player.getName()) + " has become a " +
F.elem(_withers.GetColor() + newKit.GetName()) + "."));
Announce(F.main(
"Game",
F.elem(_withers.GetColor() + player.getName())
+ " has become a "
+ F.elem(_withers.GetColor() + newKit.GetName())
+ "."));
player.getWorld().strikeLightningEffect(player.getLocation());
}
}
// @EventHandler
// public void playerLoseLife(final PlayerDeathOutEvent event)
// {
// Player player = event.GetPlayer();
//
// if (_lives.containsKey(player))
// {
// int lives = _lives.get(player);
//
// if (lives <= 1)
// return;
//
// _lives.put(player, lives - 1);
//
// UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + C.Bold + lives + " Lives Remaining") + "."));
//
// event.setCancelled(true);
// }
// }
// @EventHandler
// public void playerLoseLife(final PlayerDeathOutEvent event)
// {
// Player player = event.GetPlayer();
//
// if (_lives.containsKey(player))
// {
// int lives = _lives.get(player);
//
// if (lives <= 1)
// return;
//
// _lives.put(player, lives - 1);
//
// UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen +
// C.Bold + lives + " Lives Remaining") + "."));
//
// event.setCancelled(true);
// }
// }
@EventHandler
public void gameStart(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
UtilTextMiddle.display(C.cGreen + "Humans Hiding", "15 Seconds until Assault", 10, 80, 10);
UtilTextMiddle.display(C.cGreen + "Humans Hiding",
"15 Seconds until Assault", 10, 80, 10);
for (Player player : _withers.GetPlayers(true))
{
Manager.GetCondition().Factory().Blind("Game Start", player, null, 15, 0, false, false, false);
Manager.GetCondition()
.Factory()
.Blind("Game Start", player, null, 15, 0, false, false,
false);
}
}
// @EventHandler
// public void playerLivesDisplay(PlayerKitGiveEvent event)
// {
// if (!_runners.HasPlayer(event.GetPlayer()))
// return;
//
// //Player Lives
// if (!_lives.containsKey(event.GetPlayer()))
// _lives.put(event.GetPlayer(), _livesPerPlayer);
//
// int lives = _lives.get(event.GetPlayer());
//
// if (lives <= 0)
// return;
//
// event.GetPlayer().getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, lives, C.cGreen + C.Bold + lives + " Lives Remaining"));
// }
// @EventHandler
// public void playerLivesDisplay(PlayerKitGiveEvent event)
// {
// if (!_runners.HasPlayer(event.GetPlayer()))
// return;
//
// //Player Lives
// if (!_lives.containsKey(event.GetPlayer()))
// _lives.put(event.GetPlayer(), _livesPerPlayer);
//
// int lives = _lives.get(event.GetPlayer());
//
// if (lives <= 0)
// return;
//
// event.GetPlayer().getInventory().setItem(8,
// ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, lives,
// C.cGreen + C.Bold + lives + " Lives Remaining"));
// }
@Override
public void EndCheck()
@ -262,23 +271,23 @@ public class WitherGame extends TeamGame implements IBlockRestorer
if (!IsLive())
return;
//Players Quit
// Players Quit
if (GetPlayers(true).size() < 2)
{
SetState(GameState.End);
}
GameTeam winner = null;
//Wither Win
// Wither Win
if (UtilTime.elapsed(this.GetStateTime(), _gameTime))
winner = _runners;
//Runner Win
// Runner Win
if (_runners.GetPlayers(true).isEmpty())
winner = _withers;
//Set Win
// Set Win
if (winner != null)
{
AnnounceEnd(winner);
@ -296,7 +305,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
AddGems(player, 10, "Participation", false, false);
}
//End
// End
SetState(GameState.End);
}
}
@ -307,33 +316,40 @@ public class WitherGame extends TeamGame implements IBlockRestorer
{
if (!InProgress())
return;
if (event.getType() != UpdateType.FAST)
return;
// int lives = 0;
// for (int i : _lives.values())
// lives += i;
//Wipe Last
// int lives = 0;
// for (int i : _lives.values())
// lives += i;
// Wipe Last
Scoreboard.Reset();
Scoreboard.WriteBlank();
Scoreboard.Write(_runners.GetColor() + C.Bold + _runners.GetName());
Scoreboard.Write(_runners.GetColor() + "" + _runners.GetPlayers(true).size() + " Players");
Scoreboard.Write(_runners.GetColor() + ""
+ _runners.GetPlayers(true).size() + " Players");
Scoreboard.WriteBlank();
Scoreboard.Write(_withers.GetColor() + C.Bold + _withers.GetName());
Scoreboard.Write(_withers.GetColor() + "" + _withers.GetPlayers(true).size() + " Players");
// Scoreboard.WriteBlank();
// Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive");
// Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer));
Scoreboard.Write(_withers.GetColor() + ""
+ _withers.GetPlayers(true).size() + " Players");
// Scoreboard.WriteBlank();
// Scoreboard.Write(C.cYellow + C.Bold + "Humans Alive");
// Scoreboard.Write(lives + " / " + (_lives.size() * _livesPerPlayer));
Scoreboard.WriteBlank();
Scoreboard.Write(C.cYellow + C.Bold + "Time Left");
Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _gameTime - (System.currentTimeMillis() - this.GetStateTime())), 1));
Scoreboard.Write(UtilTime.MakeStr(
Math.max(
0,
_gameTime
- (System.currentTimeMillis() - this
.GetStateTime())), 1));
Scoreboard.Draw();
}
@ -345,7 +361,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
return _runners;
}
@Override
public boolean CanJoinTeam(GameTeam team)
{
@ -353,42 +369,42 @@ public class WitherGame extends TeamGame implements IBlockRestorer
{
return team.GetSize() < getRequiredWithers();
}
return team.GetSize() < GetPlayers(true).size() - getRequiredWithers();
}
public int getRequiredWithers()
{
return (int)(GetPlayers(true).size()/_witherFactor);
return (int) (GetPlayers(true).size() / _witherFactor);
}
@EventHandler
public void witherMovement(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.FASTER)
return;
for (Player player : _withers.GetPlayers(true))
{
ArrayList<Location> collisions = new ArrayList<Location>();
//Fly Speed
// Fly Speed
double speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006;
if (speed > 0.16)
speed = 0.16;
if (speed < 0.016)
speed = 0.016;
player.setFlySpeed((float)speed);
//Bump
for (Block block : UtilBlock.getInRadius(player.getLocation().add(0, 0.5, 0), 1.5d).keySet())
player.setFlySpeed((float) speed);
// Bump
for (Block block : UtilBlock.getInRadius(
player.getLocation().add(0, 0.5, 0), 1.5d).keySet())
{
if (!UtilBlock.airFoliage(block))
{
@ -396,15 +412,17 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
}
Vector vec = UtilAlg.getAverageBump(player.getLocation(), collisions);
Vector vec = UtilAlg.getAverageBump(player.getLocation(),
collisions);
if (vec == null)
continue;
UtilAction.velocity(player, vec, 0.6, false, 0, 0.4, 10, true);
// if (player.getLocation().getY() < _yLimit + 6)
// UtilAction.velocity(player, new Vector(0, 1, 0), 0.6, false, 0, 0, 10, true);
// if (player.getLocation().getY() < _yLimit + 6)
// UtilAction.velocity(player, new Vector(0, 1, 0), 0.6, false, 0,
// 0, 10, true);
}
}
@ -412,139 +430,153 @@ public class WitherGame extends TeamGame implements IBlockRestorer
public void addBlocks(Set<Block> blocks)
{
Iterator<Block> blockIter = blocks.iterator();
while (blockIter.hasNext())
{
Block block = blockIter.next();
if (block.getType() == Material.BEDROCK || block.getType() == Material.IRON_BLOCK)
if (block.getType() == Material.BEDROCK
|| block.getType() == Material.IRON_BLOCK)
blockIter.remove();
else if (!isInsideMap(block.getLocation()))
blockIter.remove();
// else if (UtilAlg.inBoundingBox(block.getLocation(), _safeA, _safeB) || UtilAlg.inBoundingBox(block.getLocation(), _spawnA, _spawnB))
// blockIter.remove();
// else if (UtilAlg.inBoundingBox(block.getLocation(), _safeA,
// _safeB) || UtilAlg.inBoundingBox(block.getLocation(), _spawnA,
// _spawnB))
// blockIter.remove();
}
for (Block block : blocks)
_blocks.add(new BlockData(block));
}
@Override
public void restoreBlock(Location loc, double radius)
{
Iterator<BlockData> dataIt = _blocks.iterator();
while (dataIt.hasNext())
{
BlockData data = dataIt.next();
double dist = UtilMath.offset(loc, data.Block.getLocation().add(0.5, 0.5, 0.5));
double dist = UtilMath.offset(loc,
data.Block.getLocation().add(0.5, 0.5, 0.5));
if (dist < radius)
{
Manager.GetBlockRestore().Add(data.Block, 0, (byte)0, data.Material.getId(), data.Data, (long) (6000 * (dist/radius)));
Manager.GetBlockRestore().Add(data.Block, 0, (byte) 0,
data.Material.getId(), data.Data,
(long) (6000 * (dist / radius)));
dataIt.remove();
}
}
}
// @EventHandler
// public void cleanLives(PlayerQuitEvent event)
// {
// _lives.remove(event.getPlayer());
// }
// @EventHandler
// public void livesUpdate(UpdateEvent event)
// {
// if (!IsLive())
// return;
//
// if (event.getType() != UpdateType.FASTER)
// return;
//
// Iterator<Player> playerIter = _lives.keySet().iterator();
//
// while (playerIter.hasNext())
// {
// Player player = playerIter.next();
//
// if (!player.isOnline() || !_runners.HasPlayer(player))
// playerIter.remove();
// }
// }
// @EventHandler
// public void cleanLives(PlayerQuitEvent event)
// {
// _lives.remove(event.getPlayer());
// }
// @EventHandler
// public void livesUpdate(UpdateEvent event)
// {
// if (!IsLive())
// return;
//
// if (event.getType() != UpdateType.FASTER)
// return;
//
// Iterator<Player> playerIter = _lives.keySet().iterator();
//
// while (playerIter.hasNext())
// {
// Player player = playerIter.next();
//
// if (!player.isOnline() || !_runners.HasPlayer(player))
// playerIter.remove();
// }
// }
@EventHandler
public void arrowDamage(CustomDamageEvent event)
{
if (event.GetProjectile() == null)
return;
event.AddMult(GetName(), "Arrow Mod", 0.75, false);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void damageOut(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetDamageePlayer() == null)
return;
if (event.GetDamage() < event.GetDamageePlayer().getHealth())
return;
event.SetCancelled("Fake Death");
event.GetDamageePlayer().playEffect(EntityEffect.HURT);
playerOut(event.GetDamageePlayer());
if (event.GetDamagerPlayer(true) != null)
{
AddGems(event.GetDamagerPlayer(true), 2, "Humans Stunned", true, true);
Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen + event.GetDamageePlayer().getName() + C.cGray + " was killed by " + C.cRed + event.GetDamagerPlayer(true).getName() + C.cGray + ".");
AddGems(event.GetDamagerPlayer(true), 2, "Humans Stunned", true,
true);
Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen
+ event.GetDamageePlayer().getName() + C.cGray
+ " was killed by " + C.cRed
+ event.GetDamagerPlayer(true).getName() + C.cGray + ".");
}
else
{
Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen + event.GetDamageePlayer().getName() + C.cGray + " was killed.");
Bukkit.broadcastMessage(C.cBlue + "Death> " + C.cGreen
+ event.GetDamageePlayer().getName() + C.cGray
+ " was killed.");
}
}
public void playerOut(Player player)
{
//State
// State
SetPlayerState(player, PlayerState.OUT);
player.setHealth(20);
player.setFlySpeed(0.1f);
//Conditions
Manager.GetCondition().Factory().Blind("Hit", player, player, 1.5, 0, false, false, false);
Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false);
// Conditions
Manager.GetCondition().Factory()
.Blind("Hit", player, player, 1.5, 0, false, false, false);
Manager.GetCondition().Factory()
.Cloak("Hit", player, player, 9999, false, false);
//Settings
// Settings
player.setAllowFlight(true);
player.setFlying(true);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer)player).getHandle().k = false;
((CraftPlayer) player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().k = false;
player.setVelocity(new Vector(0,1.2,0));
player.setVelocity(new Vector(0, 1.2, 0));
_doubles.put(player, new PlayerCopy(this, player, ChatColor.YELLOW));
}
public void playerIn(final Player player, final LivingEntity copy)
{
//State
// State
SetPlayerState(player, PlayerState.IN);
player.setHealth(20);
//Teleport
// Teleport
if (copy != null)
{
Location loc = player.getLocation();
@ -554,43 +586,49 @@ public class WitherGame extends TeamGame implements IBlockRestorer
player.teleport(loc);
}
//Settings
// Settings
player.setAllowFlight(false);
player.setFlying(false);
((CraftPlayer)player).getHandle().spectating = false;
((CraftPlayer)player).getHandle().k = true;
//Items
((CraftPlayer) player).getHandle().spectating = false;
((CraftPlayer) player).getHandle().k = true;
// Items
player.getInventory().remove(Material.WATCH);
player.getInventory().remove(Material.COMPASS);
//Inform
// Inform
UtilPlayer.message(player, F.main("Game", "You have been revived!"));
//Delayed Visibility
// Delayed Visibility
if (copy != null)
{
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{
public void run()
{
//Remove Invis
if (IsAlive(player))
Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null);
UtilServer
.getServer()
.getScheduler()
.scheduleSyncDelayedTask(Manager.getPlugin(),
new Runnable()
{
public void run()
{
// Remove Invis
if (IsAlive(player))
Manager.GetCondition().EndCondition(
player, ConditionType.CLOAK,
null);
//Remove Copy
copy.remove();
}
}, 4);
// Remove Copy
copy.remove();
}
}, 4);
}
}
@EventHandler
public void revive(ProjectileHitEvent event)
{
if (!IsLive())
return;
if (!(event.getEntity() instanceof ThrownPotion))
return;
@ -600,12 +638,13 @@ public class WitherGame extends TeamGame implements IBlockRestorer
if (!(event.getEntity().getShooter() instanceof Player))
return;
Player thrower = (Player)event.getEntity().getShooter();
Player thrower = (Player) event.getEntity().getShooter();
GameTeam throwerTeam = GetTeam(thrower);
if (throwerTeam == null) return;
if (throwerTeam == null)
return;
//Revive
// Revive
Iterator<PlayerCopy> copyIterator = _doubles.values().iterator();
while (copyIterator.hasNext())
{
@ -615,7 +654,8 @@ public class WitherGame extends TeamGame implements IBlockRestorer
if (otherTeam == null || !otherTeam.equals(throwerTeam))
continue;
if (UtilMath.offset(copy.GetEntity().getLocation().add(0,1,0), event.getEntity().getLocation()) > 3)
if (UtilMath.offset(copy.GetEntity().getLocation().add(0, 1, 0),
event.getEntity().getLocation()) > 3)
continue;
playerIn(copy.GetPlayer(), copy.GetEntity());
@ -624,30 +664,31 @@ public class WitherGame extends TeamGame implements IBlockRestorer
AddGems(thrower, 3, "Revived Ally", true, true);
}
//Revive
// Revive
for (Player player : GetPlayers(true))
{
GameTeam otherTeam = GetTeam(player);
if (otherTeam == null || !otherTeam.equals(throwerTeam))
continue;
if (UtilMath.offset(player.getLocation().add(0,1,0), event.getEntity().getLocation()) > 3)
if (UtilMath.offset(player.getLocation().add(0, 1, 0), event
.getEntity().getLocation()) > 3)
continue;
playerIn(player, null);
}
}
@EventHandler
public void removePotionEffect(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
player.removePotionEffect(PotionEffectType.WATER_BREATHING);
}
@EventHandler
public void skeletonDamage(CustomDamageEvent event)
{
@ -660,7 +701,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
}
}
@EventHandler
public void skeletonCombust(EntityCombustEvent event)
{