Added two new kits.

This commit is contained in:
Mysticate 2015-07-11 10:25:04 -04:00
parent 0353b8571d
commit d0180910e9
6 changed files with 289 additions and 32 deletions

View File

@ -21,8 +21,10 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent;
import nautilus.game.arcade.game.games.lobbers.kits.KitArmorer;
import nautilus.game.arcade.game.games.lobbers.kits.KitDetonator;
import nautilus.game.arcade.game.games.lobbers.kits.KitJumper;
import nautilus.game.arcade.game.games.lobbers.kits.KitWaller;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.ChatColor;
@ -49,14 +51,15 @@ public class BombLobbers extends TeamGame
super(manager, GameType.Lobbers, new Kit[]
{
new KitJumper(manager),
new KitDetonator(manager)
new KitArmorer(manager),
new KitDetonator(manager),
new KitWaller(manager)
}, new String[]
{
"Throw TNT to blow up your enemies!",
"Click with TNT to throw"
});
DamagePvP = false;
DamageSelf = false;
WorldWaterDamage = 5;
@ -73,6 +76,8 @@ public class BombLobbers extends TeamGame
BlockPlace = false;
DamageFall = true;
Manager.GetExplosion().SetLiquidDamage(false);
HungerSet = 20;
@ -153,11 +158,8 @@ public class BombLobbers extends TeamGame
event.getEntity().remove();
return;
}
GameTeam throwerTeam = GetTeam(thrower);
GameTeam throwerSide = getSide(tnt.getLocation());
if (throwerTeam.GetName().equalsIgnoreCase(throwerSide.GetName()))
if (GetTeam(thrower) == getSide(tnt.getLocation()))
{
event.setCancelled(true);
@ -172,7 +174,7 @@ public class BombLobbers extends TeamGame
_throwers.remove(tnt);
_teams.remove(tnt);
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14))
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 5))
{
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, thrower, 50, 0.1, false, false);
}

View File

@ -0,0 +1,53 @@
package nautilus.game.arcade.game.games.lobbers.kits;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitArmorer extends Kit
{
public KitArmorer(ArcadeManager manager)
{
super(manager, "Armorer", KitAvailability.Free, 0, new String[]
{
"He uses his expert armor-making",
"skills to block excess damage!",
"",
C.cGray + "Recieve " + C.cYellow + "Full Gold Armor"
}, new Perk[]
{
new PerkCraftman()
}, EntityType.ZOMBIE,
new ItemStack(Material.AIR));
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build());
player.getInventory().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setUnbreakable(true).build());
player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build());
player.getInventory().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setUnbreakable(true).build());
}
@Override
public void SpawnCustom(LivingEntity ent)
{
ent.getEquipment().setHelmet(new ItemBuilder(Material.GOLD_HELMET).build());
ent.getEquipment().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).build());
ent.getEquipment().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).build());
ent.getEquipment().setBoots(new ItemBuilder(Material.GOLD_BOOTS).build());
}
}

View File

@ -2,6 +2,8 @@ package nautilus.game.arcade.game.games.lobbers.kits;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
@ -14,9 +16,9 @@ import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
@ -37,12 +39,18 @@ public class KitDetonator extends Kit
}, EntityType.ZOMBIE,
new ItemBuilder(Material.LEVER).build());
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setItem(1, new ItemBuilder(Material.LEVER).setTitle(F.item("Fuse Selector (Seconds)")).setAmount(2).build());
}
@Override
public void SpawnCustom(LivingEntity ent)
{
}
@EventHandler
public void setFuse(TNTThrowEvent event)
@ -75,9 +83,6 @@ public class KitDetonator extends Kit
@EventHandler
public void changeFuse(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
if (!Manager.GetGame().IsLive())
return;
@ -87,38 +92,29 @@ public class KitDetonator extends Kit
if (!HasKit(event.getPlayer()))
return;
if (event.getItem().getType() != Material.LEVER)
if (!UtilInv.IsItem(event.getItem(), Material.LEVER, (byte) 0))
return;
ItemStack lever = event.getPlayer().getInventory().getItem(1);
if (lever.getAmount() <= 0 || lever.getAmount() > 3)
{
GiveItems(event.getPlayer());
return;
}
int amount = event.getPlayer().getInventory().getItem(1).getAmount();
//Right
if (event.getAction().toString().contains("RIGHT"))
if (UtilEvent.isAction(event, ActionType.R))
{
if (lever.getAmount() == 3)
{
if (amount >= 3)
return;
}
lever.setAmount(lever.getAmount() + 1);
UtilInv.insert(event.getPlayer(), new ItemBuilder(Material.LEVER).setTitle(F.item("Fuse Selector (Seconds)")).build());
UtilInv.Update(event.getPlayer());
}
//Left
else
else if (UtilEvent.isAction(event, ActionType.L))
{
if (lever.getAmount() == 1)
{
if (amount <= 1)
return;
}
lever.setAmount(lever.getAmount() - 1);
UtilInv.remove(event.getPlayer(), Material.LEVER, (byte) 0, 1);
UtilInv.Update(event.getPlayer());
}
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CLICK, 3.0F, 1.0F);
}
}

View File

@ -10,6 +10,7 @@ import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class KitJumper extends Kit
@ -30,7 +31,13 @@ public class KitJumper extends Kit
@Override
public void GiveItems(Player player)
{
}
@Override
public void SpawnCustom(LivingEntity ent)
{
}
}

View File

@ -0,0 +1,37 @@
package nautilus.game.arcade.game.games.lobbers.kits;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkWaller;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class KitWaller extends Kit
{
public KitWaller(ArcadeManager manager)
{
super(manager, "Waller", KitAvailability.Free, 0, new String[]
{
"When the times get tough,",
"build yourself a wall!"
}, new Perk[]
{
new PerkWaller()
}, EntityType.ZOMBIE,
new ItemBuilder(Material.SMOOTH_BRICK).setUnbreakable(true).build());
}
@Override
public void GiveItems(Player player)
{
player.getInventory().setItem(1, new ItemBuilder(Material.STONE_SPADE).setAmount(3).setTitle(F.item("Wall Builder")).build());
}
}

View File

@ -0,0 +1,162 @@
package nautilus.game.arcade.game.games.lobbers.kits.perks;
import java.util.HashSet;
import java.util.Set;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class PerkWaller extends Perk
{
private BlockFace[] axis = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
private Set<TNTPrimed> _tnt = new HashSet<TNTPrimed>();
private Set<Location> _wallBlocks = new HashSet<Location>();
public PerkWaller()
{
super("Waller", new String[]
{
C.cYellow + "Click Block" + C.cGray + " with shovel to " + C.cGreen + "Place Wall",
C.cGray + "Walls can absorb 1 hit before breaking.",
C.cGray + "TNT that touches a wall will explode instantly."
});
}
@EventHandler
public void onThrow(TNTThrowEvent event)
{
_tnt.add(event.getTNT());
}
@EventHandler
public void onExplode(EntityExplodeEvent event)
{
if (_tnt.contains(event.getEntity()))
{
_tnt.remove(event.getEntity());
}
}
@EventHandler
public void onPlace(PlayerInteractEvent event)
{
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
return;
if (!Manager.GetGame().IsLive())
return;
if (!Manager.IsAlive(event.getPlayer()))
return;
if (!Kit.HasKit(event.getPlayer()))
return;
if (!UtilInv.IsItem(event.getItem(), Material.STONE_SPADE, (byte) 0))
return;
_wallBlocks.addAll(buildWall(event.getClickedBlock().getLocation(), event.getPlayer().getLocation().getYaw(), getFace(event.getPlayer().getLocation().getYaw())));
}
@SuppressWarnings("deprecation")
@EventHandler
public void explode(ExplosionEvent event)
{
if (!Manager.GetGame().IsLive())
return;
for (Block block : event.GetBlocks())
{
if (_wallBlocks.contains(block.getLocation()))
{
if (block.getData() != 2)
{
block.setData((byte) 2);
}
}
}
}
@EventHandler
public void explodeTNT(UpdateEvent event)
{
if (!Manager.GetGame().IsLive())
return;
if (event.getType() != UpdateType.FAST)
return;
for (TNTPrimed tnt : _tnt)
{
for (Block near : UtilBlock.getInRadius(tnt.getLocation(), 1.5F).keySet())
{
if (_wallBlocks.contains(near.getLocation()))
{
tnt.setFuseTicks(0);
}
}
}
}
private Set<Location> buildWall(final Location source, final float playerYaw, final BlockFace facing)
{
Set<Location> allWallBlocks = new HashSet<Location>();
Set<Location> baseWallBlocks = new HashSet<Location>();
Location centerWallBlock = source.getBlock().getRelative(facing).getRelative(BlockFace.UP).getLocation();
float leftYaw = playerYaw - 90;
float rightYaw = playerYaw + 90;
BlockFace leftSide = getFace(leftYaw);
BlockFace rightSide = getFace(rightYaw);
baseWallBlocks.add(centerWallBlock.getBlock().getRelative(leftSide).getRelative(leftSide).getLocation());
baseWallBlocks.add(centerWallBlock.getBlock().getRelative(leftSide).getLocation());
baseWallBlocks.add(centerWallBlock);
baseWallBlocks.add(centerWallBlock.getBlock().getRelative(rightSide).getLocation());
baseWallBlocks.add(centerWallBlock.getBlock().getRelative(rightSide).getRelative(rightSide).getLocation());
for (Location base : baseWallBlocks)
{
for (int height = 0 ; height < 3 ; height++)
{
allWallBlocks.add(base.clone().add(0, height, 0));
}
}
for (Location block : allWallBlocks)
{
block.getBlock().setType(Material.SMOOTH_BRICK);
block.getWorld().playEffect(block, Effect.STEP_SOUND, 1.0F);
}
return allWallBlocks;
}
private BlockFace getFace(float yaw)
{
if (yaw < 0)
yaw = yaw * (-1);
return axis[Math.round(yaw / 90F) & 0x3];
}
}