Fixed and added things

This commit is contained in:
Mysticate 2015-07-08 23:57:48 -04:00
parent 2ad2c20aaf
commit 1b3d7f1c20
5 changed files with 257 additions and 1 deletions

View File

@ -27,6 +27,7 @@ public enum GameDisplay
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),
Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21),
Lobbers("Bomb Lobbers", Material.TNT, (byte) 0, GameCategory.ARCADE, 53),
Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24),
MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27),
MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CHAMPIONS, 25),// Temp set to CHAMPIONS to fix UI bug

View File

@ -26,6 +26,7 @@ import nautilus.game.arcade.game.games.halloween.Halloween;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.holeinwall.HoleInTheWall;
import nautilus.game.arcade.game.games.horsecharge.Horse;
import nautilus.game.arcade.game.games.lobbers.BombLobbers;
import nautilus.game.arcade.game.games.micro.Micro;
import nautilus.game.arcade.game.games.milkcow.MilkCow;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
@ -84,6 +85,7 @@ public enum GameType
HideSeek(HideSeek.class, GameDisplay.HideSeek),
HoleInTheWall(HoleInTheWall.class, GameDisplay.HoleInTheWall),
Horse(Horse.class, GameDisplay.Horse),
Lobbers(BombLobbers.class, GameDisplay.Lobbers),
Micro(Micro.class, GameDisplay.Micro),
MilkCow(MilkCow.class, GameDisplay.MilkCow),
MineStrike(MineStrike.class, GameDisplay.MineStrike, "http://chivebox.com/file/c/assets.zip", true),// Temp set to CHAMPIONS to fix UI bug
@ -112,7 +114,7 @@ public enum GameType
TurfWars(TurfForts.class, GameDisplay.TurfWars),
UHC(UHC.class, GameDisplay.UHC),
WitherAssault(WitherGame.class, GameDisplay.WitherAssault),
Wizards(Wizards.class, GameDisplay.Barbarians.Wizards, "http://chivebox.com/file/c/ResWizards.zip", true),
Wizards(Wizards.class, GameDisplay.Wizards, "http://chivebox.com/file/c/ResWizards.zip", true),
ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival),
Build(Build.class, GameDisplay.Build),

View File

@ -0,0 +1,169 @@
package nautilus.game.arcade.game.games.lobbers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
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.lobbers.kits.KitCannoneer;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class BombLobbers extends TeamGame
{
private NautHashMap<GameTeam, Location> _averageSpawns = new NautHashMap<GameTeam, Location>();
private NautHashMap<TNTPrimed, String> _throwers = new NautHashMap<TNTPrimed, String>();
private NautHashMap<TNTPrimed, GameTeam> _teams = new NautHashMap<TNTPrimed, GameTeam>();
private List<Player> _allowed = new ArrayList<Player>();
public BombLobbers(ArcadeManager manager)
{
super(manager, GameType.Lobbers, new Kit[]
{
new KitCannoneer(manager)
}, new String[]
{
"Throw TNT to blow up your enemies!",
"Click with TNT to throw"
});
DamagePvP = false;
DamageSelf = false;
WorldWaterDamage = 5;
PrepareFreeze = false;
TeamArmor = true;
TeamArmorHotbar = true;
}
@EventHandler
public void loadTeamLocations(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Live)
{
for (GameTeam team : _teamList)
{
_averageSpawns.put(team, UtilAlg.getAverageLocation(team.GetSpawns()));
}
}
}
//Skywars code
@EventHandler
public void throwTNT(PlayerInteractEvent event)
{
if (!IsLive())
return;
Player player = event.getPlayer();
if (!IsAlive(player))
return;
if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0))
return;
event.setCancelled(true);
UtilInv.remove(player, Material.TNT, (byte) 0, 1);
UtilInv.Update(player);
TNTPrimed tnt = (TNTPrimed) player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()),TNTPrimed.class);
UtilAction.velocity(tnt, player.getLocation().getDirection(), 2.0D, false, 0.0D, 0.1D, 10.0D, false);
player.playSound(player.getLocation(), Sound.CREEPER_HISS, 3.0F, 1.0F);
_throwers.put(tnt, player.getName());
_teams.put(tnt, GetTeam(player));
}
@EventHandler(priority = EventPriority.HIGH)
public void onTNTExplode(ExplosionPrimeEvent event)
{
if (!IsLive())
return;
if (!(event.getEntity() instanceof TNTPrimed))
return;
TNTPrimed tnt = (TNTPrimed) event.getEntity();
if (!_throwers.containsKey(tnt))
return;
Player thrower = UtilPlayer.searchExact(_throwers.get(tnt));
if (thrower == null)
{
if (_teams.get(tnt).IsTeamAlive())
{
thrower = _teams.get(tnt).GetPlayers(true).get(0);
}
else
{
event.setCancelled(true);
event.getEntity().remove();
return;
}
}
GameTeam throwerTeam = GetTeam(thrower);
GameTeam throwerSide = getSide(tnt.getLocation());
if (throwerTeam.GetName().equalsIgnoreCase(throwerSide.GetName()))
{
event.setCancelled(true);
event.getEntity().remove();
return;
}
_allowed.add(thrower);
_throwers.remove(tnt);
_teams.remove(tnt);
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 8))
{
if (Manager.canHurt(thrower, other))
{
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, thrower, 50, 0.1, false, false);
}
}
}
private GameTeam getSide(Location entityLoc)
{
Location nearest = UtilAlg.findClosest(entityLoc, new ArrayList<Location>(_averageSpawns.values()));
for (Entry<GameTeam, Location> entry : _averageSpawns.entrySet())
{
if (entry.getValue().equals(nearest))
return entry.getKey();
}
return null;
}
}

View File

@ -0,0 +1,35 @@
package nautilus.game.arcade.game.games.lobbers.kits;
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.Player;
public class KitCannoneer extends Kit
{
public KitCannoneer(ArcadeManager manager)
{
super(manager, "Cannoneer", KitAvailability.Free, 0, new String[]
{
"Once the ammunitions expert for",
"pirates, explosives are his specialty."
}, new Perk[]
{
new PerkCraftman()
}, EntityType.ZOMBIE, new ItemBuilder(Material.TNT).build());
}
@Override
public void GiveItems(Player player)
{
}
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.lobbers.kits.perks;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class PerkCraftman extends Perk
{
private Recharge _recharge;
public PerkCraftman()
{
super("Craftman", new String[]
{
C.cGray + "Recieve 1 TNT every 2 seconds. Maximum of 4."
});
_recharge = Recharge.Instance;
}
@EventHandler
public void give(UpdateEvent event)
{
if (!Manager.GetGame().IsLive())
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!_recharge.usable(player, "TNT Give"))
continue;
_recharge.use(player, "TNT Give", 2000, false, false);
//Has 4
if (UtilInv.contains(player, Material.TNT, (byte) 0, 4))
continue;
UtilInv.insert(player, new ItemBuilder(Material.TNT).setTitle(C.cGreen + "Throwing TNT").build());
}
}
}