Bug fixes

This commit is contained in:
Mysticate 2015-07-09 12:03:56 -04:00
parent 1b3d7f1c20
commit 9e07be51c7
3 changed files with 132 additions and 10 deletions

View File

@ -1,29 +1,42 @@
package nautilus.game.arcade.game.games.lobbers; package nautilus.game.arcade.game.games.lobbers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle;
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.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; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.lobbers.kits.KitCannoneer; import nautilus.game.arcade.game.games.lobbers.kits.KitJumper;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; 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.entity.ExplosionPrimeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -40,7 +53,7 @@ public class BombLobbers extends TeamGame
{ {
super(manager, GameType.Lobbers, new Kit[] super(manager, GameType.Lobbers, new Kit[]
{ {
new KitCannoneer(manager) new KitJumper(manager)
}, new String[] }, new String[]
{ {
"Throw TNT to blow up your enemies!", "Throw TNT to blow up your enemies!",
@ -56,6 +69,11 @@ public class BombLobbers extends TeamGame
TeamArmor = true; TeamArmor = true;
TeamArmorHotbar = true; TeamArmorHotbar = true;
InventoryOpenChest = false;
InventoryOpenBlock = false;
HungerSet = 20;
} }
@EventHandler @EventHandler
@ -70,10 +88,12 @@ public class BombLobbers extends TeamGame
} }
} }
//Skywars code
@EventHandler @EventHandler
public void throwTNT(PlayerInteractEvent event) public void throwTNT(PlayerInteractEvent event)
{ {
if (event.getAction() == Action.PHYSICAL)
return;
if (!IsLive()) if (!IsLive())
return; return;
@ -155,6 +175,93 @@ public class BombLobbers extends TeamGame
} }
} }
//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();
}
}
}
@EventHandler
public void updateParticles(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!IsLive())
return;
for (Entry<TNTPrimed, GameTeam> tnt : _teams.entrySet())
{
if (tnt.getKey() != null && tnt.getKey().isValid() && !tnt.getKey().isOnGround())
{
if (tnt.getValue().GetColor() == ChatColor.AQUA)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, tnt.getKey().getLocation().clone().add(0.0, 0.5, 0.0), -1, -1, 1, 1, 0,
ViewDist.LONG, UtilServer.getPlayers());
}
else
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, tnt.getKey().getLocation().clone().add(0.0, 0.5, 0.0), 0.0F, 0.0F, 0.0F, 0.0F, 3, ViewDist.LONG, UtilServer.getPlayers());
}
}
}
}
@EventHandler
public void preventCheating(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!IsLive())
return;
for (Player player : GetPlayers(true))
{
if (GetTeam(player) != getSide(player.getLocation()))
{
player.damage(500);
UtilPlayer.message(player, F.main("Game", "You were killed for trying to cheat!"));
continue;
}
}
}
private GameTeam getSide(Location entityLoc) private GameTeam getSide(Location entityLoc)
{ {
Location nearest = UtilAlg.findClosest(entityLoc, new ArrayList<Location>(_averageSpawns.values())); Location nearest = UtilAlg.findClosest(entityLoc, new ArrayList<Location>(_averageSpawns.values()));

View File

@ -6,22 +6,23 @@ import nautilus.game.arcade.game.games.lobbers.kits.perks.PerkCraftman;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class KitCannoneer extends Kit public class KitJumper extends Kit
{ {
public KitCannoneer(ArcadeManager manager) public KitJumper(ArcadeManager manager)
{ {
super(manager, "Cannoneer", KitAvailability.Free, 0, new String[] super(manager, "Jumper", KitAvailability.Free, 0, new String[]
{ {
"Once the ammunitions expert for", "Use your jumping abilities to leap away from trouble!"
"pirates, explosives are his specialty."
}, new Perk[] }, new Perk[]
{ {
new PerkDoubleJump("Double Jump", 1.2, 1.2, false, 6000, true),
new PerkCraftman() new PerkCraftman()
}, EntityType.ZOMBIE, new ItemBuilder(Material.TNT).build()); }, EntityType.ZOMBIE, new ItemBuilder(Material.TNT).build());
} }

View File

@ -36,7 +36,7 @@ public class PerkCraftman extends Perk
if (!_recharge.usable(player, "TNT Give")) if (!_recharge.usable(player, "TNT Give"))
continue; continue;
_recharge.use(player, "TNT Give", 2000, false, false); _recharge.use(player, "TNT Give", rechargeSeconds(), false, false);
//Has 4 //Has 4
if (UtilInv.contains(player, Material.TNT, (byte) 0, 4)) if (UtilInv.contains(player, Material.TNT, (byte) 0, 4))
@ -46,4 +46,18 @@ public class PerkCraftman extends Perk
} }
} }
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;
}
} }