Micro Battle
This commit is contained in:
parent
248111749f
commit
f68586cca4
@ -2,6 +2,7 @@ package nautilus.game.arcade.addons;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -84,7 +85,7 @@ public class CompassAddon extends MiniPlugin
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
if (Manager.GetGame().CompassGiveItem)
|
||||
if (Manager.GetGame().CompassGiveItem || player.getGameMode() == GameMode.SURVIVAL)
|
||||
if (!player.getInventory().contains(Material.COMPASS))
|
||||
{
|
||||
if (player.getOpenInventory() == null || player.getOpenInventory().getCursor() == null || player.getOpenInventory().getCursor().getType() != Material.COMPASS)
|
||||
|
@ -230,6 +230,9 @@ public abstract class TeamGame extends Game
|
||||
//Display Individual Players
|
||||
if (this.GetPlayers(true).size() < 13)
|
||||
{
|
||||
if (!team.IsTeamAlive())
|
||||
continue;
|
||||
|
||||
Scoreboard.WriteBlank();
|
||||
|
||||
for (Player player : team.GetPlayers(true))
|
||||
|
@ -0,0 +1,196 @@
|
||||
package nautilus.game.arcade.game.games.micro;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
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.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.micro.kits.*;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class Micro extends TeamGame
|
||||
{
|
||||
private ArrayList<Block> _blocks = new ArrayList<Block>();
|
||||
private ArrayList<Block> _glass = new ArrayList<Block>();
|
||||
|
||||
public Micro(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Micro,
|
||||
|
||||
new Kit[]
|
||||
{
|
||||
new KitArcher(manager),
|
||||
new KitWorker(manager),
|
||||
new KitFighter(manager)
|
||||
},
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Small game, big strategy!",
|
||||
});
|
||||
|
||||
this.TeamArmor = true;
|
||||
this.TeamArmorHotbar = true;
|
||||
|
||||
this.InventoryClick = true;
|
||||
|
||||
this.ItemDrop = true;
|
||||
this.ItemPickup = true;
|
||||
|
||||
this.BlockBreak = true;
|
||||
this.BlockPlace = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
for (Location loc : WorldData.GetCustomLocs("20"))
|
||||
_glass.add(loc.getBlock());
|
||||
|
||||
for (int y= WorldData.MinY ; y < WorldData.MaxY ; y++)
|
||||
for (int x= WorldData.MinX ; x < WorldData.MaxX ; x++)
|
||||
for (int z= WorldData.MinZ ; z < WorldData.MaxZ ; z++)
|
||||
{
|
||||
Block block = WorldData.World.getBlockAt(x, y, z);
|
||||
|
||||
if (block.getType() == Material.AIR)
|
||||
continue;
|
||||
|
||||
_blocks.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
_blocks.add(event.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BlockUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (_blocks.isEmpty())
|
||||
return;
|
||||
|
||||
TimingManager.start("Block Fall");
|
||||
|
||||
for (int i = 0 ; i < 3 ; i++)
|
||||
{
|
||||
Block bestBlock = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Block block : _blocks)
|
||||
{
|
||||
double dist = UtilMath.offset2d(GetSpectatorLocation(), block.getLocation().add(0.5, 0.5, 0.5));
|
||||
|
||||
if (bestBlock == null || dist > bestDist)
|
||||
{
|
||||
bestBlock = block;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
//Shuffle Down
|
||||
while (bestBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR)
|
||||
bestBlock = bestBlock.getRelative(BlockFace.DOWN);
|
||||
|
||||
_blocks.remove(bestBlock);
|
||||
|
||||
if (bestBlock.getType() != Material.AIR)
|
||||
{
|
||||
if (Math.random() > 0.75)
|
||||
bestBlock.getWorld().spawnFallingBlock(bestBlock.getLocation().add(0.5, 0.5, 0.5), bestBlock.getType(), bestBlock.getData());
|
||||
|
||||
bestBlock.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
TimingManager.stop("Block Fall");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void TimeUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
WorldData.World.setTime(WorldData.World.getTime() + 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void FoodUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
if (player.getFoodLevel() < 2)
|
||||
player.setFoodLevel(2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BarrierUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (_glass.isEmpty())
|
||||
return;
|
||||
|
||||
if (!UtilTime.elapsed(GetStateTime(), 10000))
|
||||
return;
|
||||
|
||||
for (Block block : _glass)
|
||||
block.setType(Material.AIR);
|
||||
|
||||
_glass.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BarrierBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (_glass.contains(event.getBlock()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ArrowDecrease(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetProjectile() == null)
|
||||
return;
|
||||
|
||||
event.AddMod(GetName(), "Projectile Reduce", -2, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package nautilus.game.arcade.game.games.micro.kits;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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.PerkFletcher;
|
||||
|
||||
public class KitArcher extends Kit
|
||||
{
|
||||
public KitArcher(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Archer", KitAvailability.Free,
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Shoot shoot!"
|
||||
},
|
||||
|
||||
new Perk[]
|
||||
{
|
||||
new PerkFletcher(20, 3, true)
|
||||
},
|
||||
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.APPLE, 3));
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package nautilus.game.arcade.game.games.micro.kits;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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 KitFighter extends Kit
|
||||
{
|
||||
public KitFighter(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Fighter", KitAvailability.Free,
|
||||
|
||||
new String[]
|
||||
{
|
||||
"HE LIKES TO FIGHT!"
|
||||
},
|
||||
|
||||
new Perk[]
|
||||
{
|
||||
new PerkIronSkin(1)
|
||||
},
|
||||
EntityType.ZOMBIE,
|
||||
new ItemStack(Material.STONE_SWORD));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD));
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.APPLE, 5));
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package nautilus.game.arcade.game.games.micro.kits;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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;
|
||||
|
||||
public class KitWorker extends Kit
|
||||
{
|
||||
public KitWorker(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Worker", KitAvailability.Free,
|
||||
|
||||
new String[]
|
||||
{
|
||||
"DIG DIG!"
|
||||
},
|
||||
|
||||
new Perk[]
|
||||
{
|
||||
|
||||
},
|
||||
EntityType.ZOMBIE,
|
||||
new ItemStack(Material.STONE_PICKAXE));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD));
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SPADE));
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_PICKAXE));
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.APPLE, 4));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user