Sheep Quest

Double Gem Weekend
This commit is contained in:
Chiss 2014-03-01 10:35:06 +11:00
parent b776c1bf60
commit 7cf6391ddd
14 changed files with 1019 additions and 85 deletions

2
.gitignore vendored
View File

@ -15,3 +15,5 @@ MagicMC
update update
Reference Reference
/Plugins/Test

View File

@ -24,9 +24,13 @@ public class GemCommand extends CommandBase<DonationManager>
return; return;
} }
//Try Online
final Player target = UtilPlayer.searchOnline(caller, args[0], true); final Player target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null) return;
if (target == null)
return;
//Give Gems to Target
try try
{ {
final int gems = Integer.parseInt(args[1]); final int gems = Integer.parseInt(args[1]);

View File

@ -582,84 +582,10 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.setCancelled(true); event.setCancelled(true);
} }
//@EventHandler @EventHandler
public void MobSpawn(CreatureSpawnEvent event) public void MobSpawn(CreatureSpawnEvent event)
{ {
if (_game == null) if (_game == null)
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler//XXX
public void TEST(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().equals("/test1"))
{
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chicken.setBaby();
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 41, (byte)0);
chicken.setPassenger(a);
a.setPassenger(b);
}
if (event.getMessage().equals("/test2"))
{
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chicken.setBaby();
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 41, (byte)0);
Chicken chickenb = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chickenb.setBaby();
chickenb.setCustomName("Dinnerbone");
chicken.setPassenger(chickenb);
chickenb.setPassenger(a);
a.setPassenger(b);
}
if (event.getMessage().equals("/test3"))
{
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chicken.setBaby();
Chicken chickenb = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chickenb.setBaby();
Chicken chickenc = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chickenc.setBaby();
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 41, (byte)0);
chicken.setPassenger(chickenb);
chickenb.setPassenger(chickenc);
chickenc.setPassenger(a);
a.setPassenger(b);
}
if (event.getMessage().equals("/test4"))
{
Chicken chicken = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chicken.setBaby();
Chicken chickenb = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chickenb.setBaby();
Chicken chickenc = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chickenc.setBaby();
Chicken chickend = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Chicken.class);
chickend.setBaby();
Entity a = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 42, (byte)0);
Entity b = event.getPlayer().getWorld().spawnFallingBlock(event.getPlayer().getLocation().add(0, 5, 0), 44, (byte)0);
Entity iron = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), Skeleton.class);
chicken.setPassenger(chickenb);
chickenb.setPassenger(chickenc);
chickenc.setPassenger(chickend);
chickend.setPassenger(a);
a.setPassenger(iron);
iron.setPassenger(b);
}
}
} }

View File

@ -25,6 +25,7 @@ import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.mineware.MineWare;
import nautilus.game.arcade.game.games.quiver.Quiver; import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.runner.Runner; import nautilus.game.arcade.game.games.runner.Runner;
import nautilus.game.arcade.game.games.sheep.SheepGame;
import nautilus.game.arcade.game.games.smash.SuperSmash; import nautilus.game.arcade.game.games.smash.SuperSmash;
import nautilus.game.arcade.game.games.snake.Snake; import nautilus.game.arcade.game.games.snake.Snake;
import nautilus.game.arcade.game.games.snowfight.SnowFight; import nautilus.game.arcade.game.games.snowfight.SnowFight;
@ -69,6 +70,7 @@ public class GameFactory
else if (gameType == GameType.Quiver) return new Quiver(_manager); else if (gameType == GameType.Quiver) return new Quiver(_manager);
else if (gameType == GameType.Runner) return new Runner(_manager); else if (gameType == GameType.Runner) return new Runner(_manager);
else if (gameType == GameType.SnowFight) return new SnowFight(_manager); else if (gameType == GameType.SnowFight) return new SnowFight(_manager);
else if (gameType == GameType.Sheep) return new SheepGame(_manager);
else if (gameType == GameType.Smash) return new SuperSmash(_manager); else if (gameType == GameType.Smash) return new SuperSmash(_manager);
else if (gameType == GameType.Snake) return new Snake(_manager); else if (gameType == GameType.Snake) return new Snake(_manager);
else if (gameType == GameType.Spleef) return new Spleef(_manager); else if (gameType == GameType.Spleef) return new Spleef(_manager);

View File

@ -15,6 +15,7 @@ public enum GameType
Dragons("Dragons"), Dragons("Dragons"),
Draw("Draw My Thing"), Draw("Draw My Thing"),
Evolution("Evolution"), Evolution("Evolution"),
FlappyBird("Flappy Bird"),
Gravity("Gravity"), Gravity("Gravity"),
Halloween("Halloween Horror"), Halloween("Halloween Horror"),
HideSeek("Block Hunt"), HideSeek("Block Hunt"),
@ -25,6 +26,7 @@ public enum GameType
Paintball("Super Paintball"), Paintball("Super Paintball"),
Quiver("One in the Quiver"), Quiver("One in the Quiver"),
Runner("Runner"), Runner("Runner"),
Sheep("Sheep Quest"),
Smash("Super Smash Mobs"), Smash("Super Smash Mobs"),
Snake("Snake"), Snake("Snake"),
SnowFight("Snow Fight"), SnowFight("Snow Fight"),

View File

@ -14,6 +14,7 @@ import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -268,6 +269,25 @@ public class GameTeam
else return (byte)15; else return (byte)15;
} }
public Color GetColorBase()
{
if (GetColor() == ChatColor.WHITE) return Color.WHITE;
if (GetColor() == ChatColor.GOLD) return Color.ORANGE;
if (GetColor() == ChatColor.LIGHT_PURPLE) return Color.PURPLE;
if (GetColor() == ChatColor.AQUA) return Color.AQUA;
if (GetColor() == ChatColor.YELLOW) return Color.YELLOW;
if (GetColor() == ChatColor.GREEN) return Color.GREEN;
if (GetColor() == ChatColor.DARK_GRAY) return Color.GRAY;
if (GetColor() == ChatColor.GRAY) return Color.GRAY;
if (GetColor() == ChatColor.DARK_AQUA) return Color.AQUA;
if (GetColor() == ChatColor.DARK_PURPLE) return Color.PURPLE;
if (GetColor() == ChatColor.BLUE) return Color.BLUE;
if (GetColor() == ChatColor.DARK_BLUE) return Color.BLUE;
if (GetColor() == ChatColor.DARK_GREEN) return Color.GREEN;
if (GetColor() == ChatColor.RED) return Color.RED;
else return Color.WHITE;
}
public void SetTeamEntity(Creature ent) public void SetTeamEntity(Creature ent)
{ {
_teamEntity = ent; _teamEntity = ent;

View File

@ -0,0 +1,201 @@
package nautilus.game.arcade.game.games.sheep;
import java.util.ArrayList;
import mineplex.core.common.util.F;
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.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.util.Vector;
public class SheepData
{
public SheepGame Host;
public Sheep Sheep;
public long LastMoved = 0;
public Player Holder = null;
public GameTeam HolderTeam = null;
public GameTeam Owner = null;
public ArrayList<Block> OwnerPen = null;
public Location OwnerPenMiddle = null;
public Location StuckLocation = null;
public long StuckTime = System.currentTimeMillis();
public Location Target = null;
public SheepData(SheepGame host, Sheep sheep)
{
Host = host;
Sheep = sheep;
LastMoved = System.currentTimeMillis();
StuckLocation = Sheep.getLocation();
StuckTime = System.currentTimeMillis();
UtilEnt.Vegetate(Sheep);
UtilEnt.ghost(Sheep, true, false);
}
public void SetHolder(Player player)
{
Holder = player;
HolderTeam = Host.GetTeam(player);
}
public void SetOwner(GameTeam team, ArrayList<Block> locs)
{
//Holding sheep in an enemies base.
if (Sheep.getVehicle() != null)
if (HolderTeam != null && !HolderTeam.equals(team))
return;
Sheep.leaveVehicle();
Target = null;
//Already owned, dont do all the stuff
if (Owner != null && Owner.equals(team))
return;
Owner = team;
OwnerPen = locs;
//Middle
Vector vec = new Vector(0,0,0);
for (Block block : locs)
vec.add(block.getLocation().toVector());
vec.multiply(1d/(double)locs.size());
OwnerPenMiddle = vec.toLocation(OwnerPen.get(0).getWorld());
OwnerPenMiddle.add(0.5, 0, 0.5);
Sheep.setColor(DyeColor.getByWoolData(team.GetColorData()));
StuckLocation = Sheep.getLocation();
StuckTime = System.currentTimeMillis();
//Effect
Sheep.getWorld().playSound(Sheep.getLocation(), Sound.SHEEP_IDLE, 2f, 1.5f);
UtilFirework.playFirework(Sheep.getLocation().add(0, 0.5, 0), FireworkEffect.builder().flicker(false).withColor(team.GetColorBase()).with(Type.BALL).trail(false).build());
//Reward
if (Holder != null && HolderTeam != null)
{
Host.AddGems(Holder, 3, "Sheep Captured", true);
UtilPlayer.message(Holder, F.main("Game", "You captured a Sheep!"));
}
Holder = null;
HolderTeam = null;
}
public boolean Update()
{
if (!Sheep.isValid())
return true;
Host.GetTeamPen(this);
if (Sheep.getVehicle() != null)
return false;
//No Team - Not picked up for a long time
if (Owner == null || OwnerPen == null)
{
if (UtilMath.offset(Sheep.getLocation(), Host.GetSheepSpawn()) > 14)
{
UtilEnt.CreatureMoveFast(Sheep, Host.GetSheepSpawn(), 1.2f);
if (UtilMath.offset(Sheep.getLocation(), StuckLocation) > 1)
{
StuckLocation = Sheep.getLocation();
StuckTime = System.currentTimeMillis();
}
else
{
if (UtilTime.elapsed(StuckTime, 1000))
{
UtilAction.velocity(Sheep, 0.3, 0.3, 0.7, true);
}
}
}
}
else
{
if (IsInsideOwnPen())
{
LastMoved = System.currentTimeMillis();
//Roam Around in Pen
if (Target == null)
Target = UtilAlg.Random(OwnerPen).getLocation().add(0.5, 0, 0.5);
if (UtilMath.offset(Sheep.getLocation(), Target) < 1)
Target = UtilAlg.Random(OwnerPen).getLocation().add(0.5, 0, 0.5);
UtilEnt.CreatureMoveFast(Sheep, Target, 0.8f);
}
else
{
UtilEnt.CreatureMoveFast(Sheep, OwnerPenMiddle, 1.2f);
if (UtilMath.offset(Sheep.getLocation(), StuckLocation) > 1)
{
StuckLocation = Sheep.getLocation();
StuckTime = System.currentTimeMillis();
}
else
{
if (UtilTime.elapsed(StuckTime, 1000))
{
UtilAction.velocity(Sheep, 0.3, 0.3, 0.7, true);
}
}
}
}
return false;
}
public Block SheepBlock()
{
Entity ent = Sheep;
while (ent.getVehicle() != null)
{
ent = ent.getVehicle();
}
return ent.getLocation().getBlock();
}
public boolean IsInsideOwnPen()
{
if (OwnerPen == null)
return false;
return OwnerPen.contains(Sheep.getLocation().getBlock());
}
}

View File

@ -0,0 +1,545 @@
package nautilus.game.arcade.game.games.sheep;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerLeashEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilDisplay;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
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.TeamGame;
import nautilus.game.arcade.game.games.sheep.kits.*;
import nautilus.game.arcade.kit.Kit;
public class SheepGame extends TeamGame
{
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private HashMap<GameTeam, Integer> _teamScore = new HashMap<GameTeam, Integer>();
private HashMap<GameTeam, ArrayList<Block>> _sheepPens = new HashMap<GameTeam, ArrayList<Block>>();
private ArrayList<Location> _sheepSpawns;
private HashMap<Sheep, SheepData> _sheep = new HashMap<Sheep, SheepData>();
private long _sheepTimer = System.currentTimeMillis();
private long _sheepDelay = 20000;
private long _gameTime = 300000;
private long _gameEndAnnounce = 0;
public SheepGame(ArcadeManager manager)
{
super(manager, GameType.Sheep,
new Kit[]
{
new KitBeserker(manager),
new KitArcher(manager)
},
new String[]
{
"Right-Click with Saddle to Grab",
"Push Drop to Drop Sheep",
"Bring Sheep to your Team Pen!",
"Most sheep at 5 minutes wins!"
});
this.DeathOut = false;
this.DeathSpectateSecs = 8;
}
@Override
public void ParseData()
{
for (GameTeam team : this.GetTeamList())
{
ArrayList<Location> locs = null;
if (team.GetColor() == ChatColor.RED)
locs = this.WorldData.GetDataLocs("RED");
else if (team.GetColor() == ChatColor.AQUA)
locs = this.WorldData.GetDataLocs("BLUE");
else if (team.GetColor() == ChatColor.YELLOW)
locs = this.WorldData.GetDataLocs("YELLOW");
else if (team.GetColor() == ChatColor.GREEN)
locs = this.WorldData.GetDataLocs("GREEN");
if (locs == null)
{
System.out.println("ERROR! Could not find Sheep Pen for Team " + team.GetColor().toString());
return;
}
ArrayList<Block> blocks = new ArrayList<Block>();
for (Location loc : locs)
blocks.add(loc.getBlock());
_sheepPens.put(team, blocks);
}
_sheepSpawns = this.WorldData.GetDataLocs("WHITE");
}
@EventHandler
public void SheepSpawnStart(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Live)
for (int i=0 ; i<4 ; i++)
SheepSpawn();
}
@EventHandler
public void SheepSpawnUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.FAST)
return;
if (!UtilTime.elapsed(_sheepTimer, _sheepDelay))
return;
SheepSpawn();
}
public void SheepSpawn()
{
//Spawn Sheep
this.CreatureAllowOverride = true;
Sheep sheep = _sheepSpawns.get(0).getWorld().spawn(UtilAlg.Random(_sheepSpawns), Sheep.class);
sheep.setAdult();
sheep.setMaxHealth(9999);
sheep.setHealth(9999);
this.CreatureAllowOverride = false;
_sheep.put(sheep, new SheepData(this, sheep));
_sheepTimer = System.currentTimeMillis();
//Effect
sheep.getWorld().playSound(sheep.getLocation(), Sound.SHEEP_IDLE, 2f, 1.5f);
UtilFirework.playFirework(sheep.getLocation().add(0, 0.5, 0), FireworkEffect.builder().flicker(false).withColor(Color.WHITE).with(Type.BALL).trail(false).build());
}
@EventHandler
public void Stack(PlayerInteractEntityEvent event)
{
if (!IsLive())
return;
if (!(event.getRightClicked() instanceof Sheep))
return;
if (event.getRightClicked().getVehicle() != null)
return;
Player player = event.getPlayer();
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.SADDLE)
return;
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
return;
if (!IsAlive(event.getPlayer()))
return;
//Holding too many
int count = 0;
Entity top = player;
while (top.getPassenger() != null)
{
top = top.getPassenger();
count++;
}
if (count >= 3)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot hold more than 3 Sheep!"));
return;
}
for (SheepData data : _sheep.values())
{
if (data.Sheep.equals(event.getRightClicked()))
{
if (data.Owner != null && data.Owner.equals(GetTeam(event.getPlayer())) && data.IsInsideOwnPen())
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You have already captured this Sheep!"));
return;
}
data.SetHolder(event.getPlayer());
}
}
//Effect
event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35);
//Stack
top.setPassenger(event.getRightClicked());
//Audio
player.playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 3f);
}
@EventHandler
public void Drop(PlayerDropItemEvent event)
{
boolean hadSheep = false;
Entity top = event.getPlayer();
while (top.getVehicle() != null)
{
top = top.getVehicle();
top.eject();
hadSheep = true;
}
if (hadSheep)
UtilDisplay.displayTextBar(Manager.GetPlugin(), event.getPlayer(), 0f, C.cWhite + C.Bold + "You dropped your Sheep!");
event.getPlayer().setExp(0f);
}
@EventHandler
public void SheepUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Sheep> sheepIterator = _sheep.keySet().iterator();
while (sheepIterator.hasNext())
{
Sheep sheep = sheepIterator.next();
SheepData data = _sheep.get(sheep);
if (data.Update())
{
sheep.remove();
sheepIterator.remove();
}
}
}
@EventHandler
public void CarryingEffect(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : GetPlayers(true))
{
int count = 0;
Entity top = player;
while (top.getPassenger() != null)
{
top = top.getPassenger();
count++;
}
player.setExp(0.33f * (float)count);
if (count == 0)
continue;
Manager.GetCondition().Factory().Slow("Sheep Slow", player, player, 3, count-1, false, false, false, true);
UtilDisplay.displayTextBar(Manager.GetPlugin(), player, (float)count/3f, C.Bold + "Return the Sheep to your Team Pen!");
}
}
@EventHandler(priority = EventPriority.LOW)
public void DamagePasson(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetDamageeEntity().getVehicle() == null)
return;
LivingEntity bottom = event.GetDamageeEntity();
while (bottom.getVehicle() != null && bottom.getVehicle() instanceof LivingEntity)
bottom = (LivingEntity) bottom.getVehicle();
event.SetCancelled("Damage Passdown");
//Damage Event
Manager.GetDamage().NewDamageEvent(bottom, event.GetDamagerEntity(true), event.GetProjectile(),
event.GetCause(), event.GetDamageInitial(), true, false, false,
UtilEnt.getName(event.GetDamagerEntity(true)), GetName());
}
@EventHandler(priority = EventPriority.MONITOR)
public void DamageUnstack(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() != DamageCause.ENTITY_ATTACK && event.GetCause() != DamageCause.PROJECTILE && event.GetCause() != DamageCause.CUSTOM)
return;
Player player = event.GetDamageePlayer();
if (player == null) return;
boolean hadSheep = false;
Entity rider = player.getPassenger();
while (rider != null)
{
rider.leaveVehicle();
rider.setVelocity(new Vector(0.25 - Math.random()/2, Math.random()/2, 0.25 - Math.random()/2));
rider = rider.getPassenger();
hadSheep = true;
}
if (hadSheep)
UtilDisplay.displayTextBar(Manager.GetPlugin(), player, 0f, C.cRed + C.Bold + "You dropped your Sheep!");
player.setExp(0f);
}
@EventHandler
public void InventoryClick(InventoryClickEvent event)
{
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}
@EventHandler
public void ScoreboardTimer(UpdateEvent event)
{
if (GetState() != GameState.Live)
return;
if (event.getType() != UpdateType.TICK)
return;
long time = _gameTime
- (System.currentTimeMillis() - this.GetStateTime());
if (time > 0)
GetObjectiveSide().setDisplayName(
ChatColor.WHITE + "§lTime Left " + C.cGreen + "§l"
+ UtilTime.MakeStr(time));
else
GetObjectiveSide().setDisplayName(
ChatColor.WHITE + "§lTime Up!");
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!InProgress())
return;
//Wipe Last
for (String string : _lastScoreboard)
GetScoreboard().resetScores(Bukkit.getOfflinePlayer(string));
_lastScoreboard.clear();
//Write New
String out;
for (GameTeam team : _sheepPens.keySet())
{
int score = 0;
for (Sheep sheep : _sheep.keySet())
{
if (_sheepPens.get(team).contains(sheep.getLocation().getBlock()))
{
score++;
}
}
out = score + " " + team.GetColor() + team.GetName();
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
if (score == 0)
score = -1;
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(score);
_teamScore.put(team, score);
}
if (!IsLive())
return;
//Space
out = " ";
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(-2);
//Timer
out = C.Bold + "Next Sheep;";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(-3);
out = C.cGreen + C.Bold + (int)UtilTime.convert(_sheepDelay - (System.currentTimeMillis() - _sheepTimer), 0, TimeUnit.FIT) + " Seconds";
if (out.length() >= 16)
out = out.substring(0, 15);
_lastScoreboard.add(out);
GetObjectiveSide().getScore(Bukkit.getOfflinePlayer(out)).setScore(-4);
}
public void GetTeamPen(SheepData data)
{
for (GameTeam team : _sheepPens.keySet())
{
if (_sheepPens.get(team).contains(data.SheepBlock()))
{
data.SetOwner(team, _sheepPens.get(team));
}
}
}
public Location GetSheepSpawn()
{
return UtilAlg.Random(_sheepSpawns);
}
@Override
public void EndCheck()
{
if (!IsLive())
return;
ArrayList<GameTeam> teamsAlive = new ArrayList<GameTeam>();
for (GameTeam team : this.GetTeamList())
if (team.GetPlayers(true).size() > 0)
teamsAlive.add(team);
if (teamsAlive.size() <= 1)
{
//Announce
if (teamsAlive.size() > 0)
AnnounceEnd(teamsAlive.get(0));
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
}
//Actual Game End
if (_gameTime - (System.currentTimeMillis() - this.GetStateTime()) <= 0)
{
GameTeam bestTeam = null;
int bestScore = -1;
int duplicate = 0;
//Get Highest
for (GameTeam team : _teamScore.keySet())
{
if (bestTeam == null || _teamScore.get(team) > bestScore)
{
bestTeam = team;
bestScore = _teamScore.get(team);
duplicate = 0;
}
else if (_teamScore.get(team) == bestScore)
{
duplicate++;
}
}
if (duplicate > 0)
{
if (UtilTime.elapsed(_gameEndAnnounce, 10000))
{
this.Announce(C.cGold + C.Bold + "First team to take the lead will win the game!");
_gameEndAnnounce = System.currentTimeMillis();
}
}
else
{
AnnounceEnd(bestTeam);
for (GameTeam team : GetTeamList())
{
if (WinnerTeam != null && team.equals(WinnerTeam))
{
for (Player player : team.GetPlayers(false))
AddGems(player, 10, "Winning Team", false);
}
for (Player player : team.GetPlayers(false))
if (player.isOnline())
AddGems(player, 10, "Participation", false);
}
//End
SetState(GameState.End);
}
}
}
}

View File

@ -0,0 +1,78 @@
package nautilus.game.arcade.game.games.sheep.kits;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitArcher extends Kit
{
public KitArcher(ArcadeManager manager)
{
super(manager, "Archer", KitAvailability.Free,
new String[]
{
"Highly trained with a bow, probably an elf or something..."
},
new Perk[]
{
new PerkFletcher(2, 5, true),
new PerkBarrage(5, 250, true, false),
},
EntityType.ZOMBIE,
new ItemStack(Material.BOW));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();
metaHelm.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
helm.setItemMeta(metaHelm);
player.getInventory().setHelmet(helm);
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
armor.setItemMeta(meta);
player.getInventory().setChestplate(armor);
ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta();
metaLegs.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
legs.setItemMeta(metaLegs);
player.getInventory().setLeggings(legs);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta();
metaBoots.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
boots.setItemMeta(metaBoots);
player.getInventory().setBoots(boots);
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
}
}

View File

@ -0,0 +1,75 @@
package nautilus.game.arcade.game.games.sheep.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitBeserker extends Kit
{
public KitBeserker(ArcadeManager manager)
{
super(manager, "Beserker", KitAvailability.Free,
new String[]
{
"Agile warrior trained in the ways axe combat."
},
new Perk[]
{
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000)
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_AXE));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();
metaHelm.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
helm.setItemMeta(metaHelm);
player.getInventory().setHelmet(helm);
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
armor.setItemMeta(meta);
player.getInventory().setChestplate(armor);
ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta();
metaLegs.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
legs.setItemMeta(metaLegs);
player.getInventory().setLeggings(legs);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta();
metaBoots.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
boots.setItemMeta(metaBoots);
player.getInventory().setBoots(boots);
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
}
}

View File

@ -0,0 +1,75 @@
package nautilus.game.arcade.game.games.sheep.kits;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitBrute extends Kit
{
public KitBrute(ArcadeManager manager)
{
super(manager, "Brute", KitAvailability.Free,
new String[]
{
"Can throw sheep at enemies!"
},
new Perk[]
{
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000)
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_AXE));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE));
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta();
metaHelm.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
helm.setItemMeta(metaHelm);
player.getInventory().setHelmet(helm);
ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta();
meta.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
armor.setItemMeta(meta);
player.getInventory().setChestplate(armor);
ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta();
metaLegs.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
legs.setItemMeta(metaLegs);
player.getInventory().setLeggings(legs);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta();
metaBoots.setColor(Manager.GetGame().GetTeam(player).GetColorBase());
boots.setItemMeta(metaBoots);
player.getInventory().setBoots(boots);
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
}
}

View File

@ -1,6 +0,0 @@
package nautilus.game.arcade.game.games.shootinggallery;
public class ShootingGallery
{
}

View File

@ -30,6 +30,8 @@ public class GameGemManager implements Listener
{ {
ArcadeManager Manager; ArcadeManager Manager;
boolean DoubleGem = true;
public GameGemManager(ArcadeManager manager) public GameGemManager(ArcadeManager manager)
{ {
Manager = manager; Manager = manager;
@ -145,7 +147,8 @@ public class GameGemManager implements Listener
else if (Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA) || Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA")) else if (Manager.GetClients().Get(player).GetRank().Has(Rank.ULTRA) || Manager.GetDonation().Get(player.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"))
total = total * 2; total = total * 2;
if (DoubleGem)
total = total * 2;
total = (int) (total * gameMult); total = (int) (total * gameMult);
@ -197,6 +200,13 @@ public class GameGemManager implements Listener
earnedGems = earnedGems * 2; earnedGems = earnedGems * 2;
} }
//Double Gem
if (DoubleGem)
{
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend"));
earnedGems = earnedGems * 2;
}
//Inform //Inform
UtilPlayer.message(player, ""); UtilPlayer.message(player, "");
if (give) if (give)