Please push please

This commit is contained in:
Mysticate 2015-07-10 16:31:37 -04:00
parent 9e07be51c7
commit f812fd0530
5 changed files with 202 additions and 89 deletions

View File

@ -1,8 +1,6 @@
package nautilus.game.arcade.game.games.lobbers;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import mineplex.core.common.util.F;
@ -15,7 +13,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
@ -23,6 +20,8 @@ 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.events.TNTThrowEvent;
import nautilus.game.arcade.game.games.lobbers.kits.KitDetonator;
import nautilus.game.arcade.game.games.lobbers.kits.KitJumper;
import nautilus.game.arcade.kit.Kit;
@ -30,15 +29,13 @@ 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.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.metadata.FixedMetadataValue;
public class BombLobbers extends TeamGame
{
@ -46,14 +43,13 @@ public class BombLobbers extends TeamGame
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 KitJumper(manager)
new KitJumper(manager),
new KitDetonator(manager)
}, new String[]
{
"Throw TNT to blow up your enemies!",
@ -73,6 +69,12 @@ public class BombLobbers extends TeamGame
InventoryOpenChest = false;
InventoryOpenBlock = false;
ItemDrop = false;
BlockPlace = false;
Manager.GetExplosion().SetLiquidDamage(false);
HungerSet = 20;
}
@ -107,20 +109,25 @@ public class BombLobbers extends TeamGame
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);
tnt.setFuseTicks(60);
tnt.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), player.getUniqueId()));
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));
Manager.getPlugin().getServer().getPluginManager().callEvent(new TNTThrowEvent(player, tnt));
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler
public void onTNTExplode(ExplosionPrimeEvent event)
{
if (!IsLive())
@ -138,17 +145,13 @@ public class BombLobbers extends TeamGame
if (thrower == null)
{
if (_teams.get(tnt).IsTeamAlive())
{
thrower = _teams.get(tnt).GetPlayers(true).get(0);
}
else
{
event.setCancelled(true);
event.setCancelled(true);
event.getEntity().remove();
return;
}
_throwers.remove(tnt);
_teams.remove(tnt);
event.getEntity().remove();
return;
}
GameTeam throwerTeam = GetTeam(thrower);
@ -158,61 +161,20 @@ public class BombLobbers extends TeamGame
{
event.setCancelled(true);
_throwers.remove(tnt);
_teams.remove(tnt);
event.getEntity().remove();
return;
}
_allowed.add(thrower);
_throwers.remove(tnt);
_teams.remove(tnt);
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 8))
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), 14))
{
if (Manager.canHurt(thrower, other))
{
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, thrower, 50, 0.1, false, false);
}
}
}
//Doesn't seem to work for some reason
@EventHandler
public void removeLiquids(EntityExplodeEvent event)
{
System.out.println("EXPLOSION EVENT CALLED FROM ENTITYEXPLODEEVENT");
if (!IsLive())
return;
Iterator<Block> iterator = event.blockList().iterator();
while (iterator.hasNext())
{
if (iterator.next().isLiquid())
{
System.out.println("REMOVED A LIQUID FROM THE EXPLOSION");
iterator.remove();
}
}
}
@EventHandler
public void removeLiquids2(ExplosionEvent event)
{
System.out.println("EXPLOSION EVENT CALLED FROM EXPLOSIONEVENT");
if (!IsLive())
return;
Iterator<Block> iterator = event.GetBlocks().iterator();
while (iterator.hasNext())
{
if (iterator.next().isLiquid())
{
System.out.println("REMOVED A LIQUID FROM THE EXPLOSION");
iterator.remove();
}
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, thrower, 50, 0.1, false, false);
}
}

View File

@ -0,0 +1,37 @@
package nautilus.game.arcade.game.games.lobbers.events;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class TNTThrowEvent extends PlayerEvent
{
private static final HandlerList _handlers = new HandlerList();
private TNTPrimed _tnt;
public TNTThrowEvent(Player thrower, TNTPrimed tnt)
{
super(thrower);
_tnt = tnt;
}
public TNTPrimed getTNT()
{
return _tnt;
}
public static HandlerList getHandlerList()
{
return _handlers;
}
@Override
public HandlerList getHandlers()
{
return getHandlerList();
}
}

View File

@ -0,0 +1,124 @@
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.UtilInv;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.lobbers.events.TNTThrowEvent;
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.Sound;
import org.bukkit.entity.EntityType;
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;
public class KitDetonator extends Kit
{
public KitDetonator(ArcadeManager manager)
{
super(manager, "Detonator", KitAvailability.Free, 0, new String[]
{
"He doesn't like to wait.",
"",
C.cYellow + "Left Click" + C.cGray + " lever to " + C.cGreen + "Decrease Fuse Time.",
C.cYellow + "Right Click" + C.cGray + " lever to " + C.cGreen + "Increase Fuse Time."
}, new Perk[]
{
new PerkCraftman()
}, 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());
}
@EventHandler
public void setFuse(TNTThrowEvent event)
{
if (!Manager.GetGame().IsLive())
return;
if (!HasKit(event.getPlayer()))
return;
ItemStack lever = event.getPlayer().getInventory().getItem(1);
if (lever == null || lever.getType() == Material.AIR)
{
GiveItems(event.getPlayer());
}
else
{
if (lever.getAmount() <= 0 || lever.getAmount() > 3)
{
GiveItems(event.getPlayer());
}
else
{
event.getTNT().setFuseTicks(lever.getAmount() * 20);
}
}
}
@EventHandler
public void changeFuse(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
if (!Manager.GetGame().IsLive())
return;
if (!Manager.IsAlive(event.getPlayer()))
return;
if (!HasKit(event.getPlayer()))
return;
if (event.getItem().getType() != Material.LEVER)
return;
ItemStack lever = event.getPlayer().getInventory().getItem(1);
if (lever.getAmount() <= 0 || lever.getAmount() > 3)
{
GiveItems(event.getPlayer());
return;
}
//Right
if (event.getAction().toString().contains("RIGHT"))
{
if (lever.getAmount() == 3)
{
return;
}
lever.setAmount(lever.getAmount() + 1);
UtilInv.Update(event.getPlayer());
}
//Left
else
{
if (lever.getAmount() == 1)
{
return;
}
lever.setAmount(lever.getAmount() - 1);
UtilInv.Update(event.getPlayer());
}
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.CLICK, 3.0F, 1.0F);
}
}

View File

@ -24,7 +24,7 @@ public class KitJumper extends Kit
{
new PerkDoubleJump("Double Jump", 1.2, 1.2, false, 6000, true),
new PerkCraftman()
}, EntityType.ZOMBIE, new ItemBuilder(Material.TNT).build());
}, EntityType.ZOMBIE, new ItemBuilder(Material.IRON_AXE).build());
}
@Override

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.lobbers.kits.perks;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
@ -8,6 +9,7 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -19,7 +21,7 @@ public class PerkCraftman extends Perk
{
super("Craftman", new String[]
{
C.cGray + "Recieve 1 TNT every 2 seconds. Maximum of 4."
C.cGray + "Recieve 1 TNT every 2 seconds. Maximum of 3."
});
_recharge = Recharge.Instance;
@ -35,29 +37,17 @@ public class PerkCraftman extends Perk
{
if (!_recharge.usable(player, "TNT Give"))
continue;
_recharge.use(player, "TNT Give", rechargeSeconds(), false, false);
_recharge.use(player, "TNT Give", Manager.GetGame().getGameLiveTime() >= 60000 ? 3000 : (Manager.GetGame().getGameLiveTime() >= 3000 ? 4000 : 5000), false, false);
//Has 4
if (UtilInv.contains(player, Material.TNT, (byte) 0, 4))
if (UtilInv.contains(player, Material.TNT, (byte) 0, 3))
continue;
UtilInv.insert(player, new ItemBuilder(Material.TNT).setTitle(C.cGreen + "Throwing TNT").build());
UtilInv.insert(player, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).build());
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 3.0F, 1.0F);
}
}
public long rechargeSeconds()
{
if (!Manager.GetGame().IsLive())
return 0;
if (Manager.GetGame().getGameLiveTime() > 60000)
return 2000;
if (Manager.GetGame().getGameLiveTime() > 30000)
return 3000;
return 4000;
}
}