Push so i can pull :O

just some xmas stuff
This commit is contained in:
Chiss 2013-12-21 08:42:49 +11:00
parent 6b33306755
commit ac723c14bd
5 changed files with 302 additions and 24 deletions

View File

@ -8,7 +8,7 @@ public enum GameType
Bridge("The Bridges"),
CastleSiege("Castle Siege"),
Champions("Champions"),
Christmas("Christmas Caper"),
Christmas("Christmas Chaos"),
DeathTag("Death Tag"),
DragonEscape("Dragon Escape"),
DragonRiders("Dragon Riders"),

View File

@ -5,33 +5,39 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
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.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.christmas.kits.KitPlayer;
import nautilus.game.arcade.game.games.christmas.parts.*;
import nautilus.game.arcade.game.games.stacker.kits.*;
import nautilus.game.arcade.kit.Kit;
public class Christmas extends SoloGame
@ -45,6 +51,8 @@ public class Christmas extends SoloGame
private ArrayList<Location> _barrier = new ArrayList<Location>();
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
public Christmas(ArcadeManager manager)
{
@ -52,16 +60,19 @@ public class Christmas extends SoloGame
new Kit[]
{
new KitDefault(manager)
new KitPlayer(manager)
},
new String[]
{
"Follow Santa Claus",
"Find the 10 Stolen Presents",
"Defeat the Thief who stole the Presents!"
});
this.BlockBreakAllow.add(4);
this.HungerSet = 20;
this.WorldTimeSet = 2000;
}
@Override
@ -118,10 +129,9 @@ public class Christmas extends SoloGame
for (Location loc : WorldData.GetCustomLocs("129"))
{
_barrier.add(loc.getBlock().getLocation());
MapUtil.QuickChangeBlockAt(loc, 20, (byte)0);
MapUtil.QuickChangeBlockAt(loc, 65, (byte)3);
}
//Parts
_parts.add(new Part1(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("BLACK"),
@ -136,16 +146,19 @@ public class Christmas extends SoloGame
WorldData.GetCustomLocs("48")));
_parts.add(new Part3(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetDataLocs("SILVER"),
WorldData.GetDataLocs("GRAY"),
WorldData.GetDataLocs("SILVER"),
WorldData.GetDataLocs("WHITE"),
WorldData.GetCustomLocs("113")));
WorldData.GetCustomLocs("121")));
_parts.add(new Part4(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)}));
_parts.add(new Part4(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetCustomLocs("56"),
WorldData.GetDataLocs("MAGENTA"),
WorldData.GetCustomLocs("22"),
WorldData.GetCustomLocs("45"),
_sleighWaypoints.get(0)));
_parts.add(new Part5(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)}));
_parts.add(new Part6(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
_parts.add(new Part5(this, _sleighWaypoints.remove(0), new Location[] {_presents.remove(0), _presents.remove(0)},
WorldData.GetCustomLocs("14"),
WorldData.GetCustomLocs("15"),
WorldData.GetCustomLocs("16"),
@ -199,10 +212,35 @@ public class Christmas extends SoloGame
@EventHandler
public void SleighSpawn(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
if (event.GetState() != GameState.Prepare)
return;
GetSleigh();
final Christmas christmas = this;
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
GetSleigh();
Location loc = christmas.GetSleigh().GetLocation();
christmas.CreatureAllowOverride = true;
for (int i=0 ; i<20 ; i++)
{
Location elfLoc = UtilBlock.getHighest(loc.getWorld(), (int)(loc.getX() + 20 - Math.random()*40), (int)(loc.getZ() + 20 - Math.random()*40)).getLocation().add(0.5, 0.5, 0.5);
Villager elf = elfLoc.getWorld().spawn(elfLoc, Villager.class);
elf.setBaby();
elf.setAgeLock(true);
elf.setCustomName("Elf");
}
christmas.CreatureAllowOverride = false;
}
}, 20);
}
@EventHandler
@ -257,6 +295,16 @@ public class Christmas extends SoloGame
Announce(C.cRed + C.Bold + "Santa: " + ChatColor.RESET + string);
}
public void BossSay(String name, String string)
{
for (Player player : UtilServer.getPlayers())
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 1f);
UtilPlayer.message(player, C.cGreen + C.Bold + name + ": " + ChatColor.RESET + string);
}
}
@EventHandler
public void Combust(EntityCombustEvent event)
{
@ -279,7 +327,7 @@ public class Christmas extends SoloGame
{
for (Player player : GetPlayers(false))
{
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Frosty Pumpkin Kings Head", 0, true);
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Snowmans Head", 0, true);
Manager.GetGame().AddGems(player, 30, "Slaying the Pumpkin King", false);
Manager.GetGame().AddGems(player, 10, "Participation", false);
}
@ -331,7 +379,7 @@ public class Christmas extends SoloGame
}
SetState(GameState.End);
SetCustomWinLine("You earned Frosty Pumpkin Kings Head!");
SetCustomWinLine("You earned Snowmans Head!");
AnnounceEnd(this.GetTeamList().get(0));
}
@ -343,9 +391,36 @@ public class Christmas extends SoloGame
}
SetState(GameState.End);
SetCustomWinLine("You lost...");
SetCustomWinLine("You all died...");
AnnounceEnd(this.GetTeamList().get(1));
}
else if (UtilTime.elapsed(GetStateTime(), 1200000))
{
for (Player player : GetPlayers(false))
{
Manager.GetGame().AddGems(player, 10, "Participation", false);
}
SetState(GameState.End);
SetCustomWinLine("You did not save Christmas in time.");
AnnounceEnd(this.GetTeamList().get(1));
}
}
public void End()
{
if (!IsLive())
return;
for (Player player : GetPlayers(false))
{
Manager.GetGame().AddGems(player, 10, "Participation", false);
}
SetState(GameState.End);
SetCustomWinLine("Santa Claus was killed by the Giant!");
AnnounceEnd(this.GetTeamList().get(1));
}
@EventHandler
@ -372,7 +447,7 @@ public class Christmas extends SoloGame
//XXX REMOVE
for (Player player : UtilServer.getPlayers())
player.teleport(_part.GetSleighWaypoint());
player.teleport(_part.GetSleighWaypoint().clone().add(0, 0, 10));
}
}
@ -385,4 +460,116 @@ public class Christmas extends SoloGame
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void DamageCancel(CustomDamageEvent event)
{
if (_sleigh != null)
GetSleigh().Damage(event);
if (event.GetCause() == DamageCause.FALL)
if (event.GetDamageeEntity().getLocation().getY() > 30)
{
event.SetCancelled("Fall Cancel");
}
else
{
event.AddMod("Christmas", "Fall Damage", 20, false);
}
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!IsLive())
return;
//Wipe Last
for (String string : _lastScoreboard)
GetScoreboard().resetScores(Bukkit.getOfflinePlayer(string));
_lastScoreboard.clear();
int index = 15;
//Rounds
String out = " ";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cWhite + "Challenge:";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cYellow + (5 - _parts.size()) + " of " + 5;
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
//Presents
out = " ";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cWhite + "Presents Found:";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cYellow + GetSleigh().GetPresents().size() + " of " + 10;
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
//Players
out = " ";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cWhite + "Players Alive:";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cYellow + GetPlayers(true).size();
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
//Time
out = " ";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cWhite + "Time Left:";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
out = C.cYellow + UtilTime.MakeStr(1200000 - (System.currentTimeMillis() - GetStateTime()));
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(index--);
}
}

View File

@ -2,19 +2,25 @@ package nautilus.game.arcade.game.games.christmas;
import java.util.ArrayList;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.christmas.parts.Part;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
@ -121,9 +127,9 @@ public class Sleigh
SleighEnts.add(new SleighPart(4, 44, 7, loc.clone(), 2, 0));
//Santa
SleighPart part = new SleighPart(3, 0, 0, loc.clone(), 0, 1);
part.AddSanta();
SleighEnts.add(part);
SleighPart santa = new SleighPart(3, 0, 0, loc.clone(), 0, 1);
santa.AddSanta();
SleighEnts.add(santa);
SleighHorses = new ArrayList<SleighHorse>();
@ -132,6 +138,11 @@ public class Sleigh
SleighHorses.add(new SleighHorse(CentralEntity, loc.clone(), -1.5, 11));
SleighHorses.add(new SleighHorse(CentralEntity, loc.clone(), 1.5, 11));
for (SleighHorse horse : SleighHorses)
{
UtilEnt.Lhorse.Ent.
}
}
public void AddPresent(FallingBlock block)
@ -204,6 +215,15 @@ public class Sleigh
UtilAction.velocity(player, UtilAlg.getTrajectory2d(CentralEntity, player), 0.4, true, 0.2, 0, 0, true);
Recharge.Instance.useForce(player, "Sleigh Bump", 400);
}
if (player.getLocation().getZ() < CentralEntity.getLocation().getZ() - 24)
{
player.damage(1);
UtilPlayer.message(player, C.cRed + C.Bold + "Santa: " + ChatColor.RESET + "Careful " + player.getName() + "! Keep up with my Sleigh!");
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player, CentralEntity), 0.6, true, 0.2, 0, 0, true);
Recharge.Instance.useForce(player, "Sleigh Bump", 400);
}
}
}
@ -216,11 +236,44 @@ public class Sleigh
{
PresentsCollected.add(loc);
loc.getBlock().setType(Material.AIR);
UtilFirework.launchFirework(loc.clone().add(0.5, 0.5, 0.5), FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(true).build(), new Vector(0,1,0), 1);
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.GLASS);
UtilFirework.launchFirework(loc.clone().add(0.5, 0.5, 0.5), FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(true).build(), new Vector(0,1,0), 0);
SleighPart part = PresentSlots.remove(0);
if (part == null) return;
part.SetPresent();
}
public ArrayList<Location> GetPresents()
{
return PresentsCollected;
}
public void Damage(CustomDamageEvent event)
{
if (event.GetDamageeEntity().equals(CentralEntity))
{
event.SetCancelled("Sleigh Damage");
return;
}
for (SleighPart part : SleighEnts)
{
if (part.HasEntity(event.GetDamageeEntity()))
{
event.SetCancelled("Sleigh Damage");
return;
}
}
for (SleighHorse part : SleighHorses)
{
if (part.HasEntity(event.GetDamageeEntity()))
{
event.SetCancelled("Sleigh Damage");
return;
}
}
}
}

View File

@ -5,7 +5,7 @@ import mineplex.core.common.util.UtilEnt;
import org.bukkit.Location;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
public class SleighHorse
{
@ -23,4 +23,12 @@ public class SleighHorse
OffsetX = x;
OffsetZ = z;
}
public boolean HasEntity(LivingEntity ent)
{
if (Ent.equals(ent))
return true;
return false;
}
}

View File

@ -3,14 +3,20 @@ package nautilus.game.arcade.game.games.christmas;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_6_R3.Packet40EntityMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftFallingSand;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
@ -45,6 +51,12 @@ public class SleighPart
top = newTop;
}
//Invis
((CraftEntity)Ent).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
for (Player player : UtilServer.getPlayers())
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new Packet40EntityMetadata(Ent.getEntityId(), ((CraftEntity)Ent).getHandle().getDataWatcher(), true));
//Block
if (id != 0)
{
@ -109,7 +121,7 @@ public class SleighPart
ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
meta = (LeatherArmorMeta)legs.getItemMeta();
meta.setColor(Color.WHITE);
meta.setColor(Color.RED);
legs.setItemMeta(meta);
skel.getEquipment().setLeggings(legs);
@ -128,4 +140,22 @@ public class SleighPart
top.setPassenger(skel);
}
public boolean HasEntity(LivingEntity ent)
{
if (Ent.equals(ent))
return true;
Entity top = Ent;
while (top.getPassenger() != null)
{
top = top.getPassenger();
if (top.equals(ent))
return true;
}
return false;
}
}