skywars fixes

This commit is contained in:
Cheese 2015-06-26 13:15:03 +10:00
parent 5710831777
commit 2d1d65b239
3 changed files with 95 additions and 55 deletions

View File

@ -33,7 +33,7 @@ public enum AchievementCategory
SKYWARS("SkyWars",null,
new StatDisplay[]{StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
Material.INK_SACK, 0,GameCategory.SURVIVAL, "Farmer Joe Kit"),
Material.INK_SACK, 0,GameCategory.SURVIVAL, "Mad Scientist Kit"),
WIZARDS("Wizards", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },

View File

@ -16,7 +16,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.loot.ChestLoot;
import mineplex.core.loot.RandomItem;
import mineplex.core.updater.UpdateType;
@ -32,7 +32,6 @@ import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.skywars.data.TNTGenerator;
import nautilus.game.arcade.game.games.skywars.events.PlayerKillZombieEvent;
import nautilus.game.arcade.game.games.skywars.events.TNTKillEvent;
import nautilus.game.arcade.game.games.skywars.events.TNTPickupEvent;
import nautilus.game.arcade.game.games.skywars.kits.KitChicken;
import nautilus.game.arcade.game.games.skywars.kits.KitLooter;
import nautilus.game.arcade.game.games.skywars.kits.KitZoo;
@ -45,7 +44,6 @@ import nautilus.game.arcade.stats.WinWithoutOpeningChestStatTracker;
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -64,6 +62,7 @@ import org.bukkit.entity.Snowball;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
@ -81,7 +80,6 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
@SuppressWarnings("deprecation")
public class SkyWars extends SoloGame
@ -92,7 +90,12 @@ public class SkyWars extends SoloGame
private TNTGenerator _tntGen;
private boolean _alreadyAnnounced;
private ArrayList<Creature> _mobs = new ArrayList<Creature>();
private ArrayList<Block> _spawnChests = new ArrayList<Block>();
private ArrayList<Block> _middleChests = new ArrayList<Block>();
private long _lastChicken = 0;
private OreHider _oreHider;
@ -172,7 +175,8 @@ public class SkyWars extends SoloGame
setAlreadyAnnounced(false);
registerStatTrackers(new SkyWarsTNTStatTracker(this),
registerStatTrackers(
new SkyWarsTNTStatTracker(this),
new SkyWarsTNTKillStatTracker(this),
new SkyWarsKillZombieStatTracker(this),
new WinWithoutOpeningChestStatTracker(this),
@ -284,6 +288,8 @@ public class SkyWars extends SoloGame
WorldData.GetDataLocs("YELLOW").remove(loc);
loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true);
_middleChests.add(loc.getBlock());
}
}
@ -446,15 +452,19 @@ public class SkyWars extends SoloGame
}
@EventHandler
public void createIslandChickens(GameStateChangeEvent event)
public void createIslandChickens(UpdateEvent event)
{
if (event.GetState() != Game.GameState.Prepare)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.SEC)
return;
if (!UtilTime.elapsed(_lastChicken, 45000))
return;
}
CreatureAllowOverride = true;
for (Location loc : WorldData.GetDataLocs("BROWN"))
for (Location loc : GetTeamList().get(0).GetSpawns())
{
Chicken chicken = loc.getWorld().spawn(loc.clone().add(0, 1, 0), Chicken.class);
@ -465,6 +475,8 @@ public class SkyWars extends SoloGame
chicken.setHealth(4);
}
CreatureAllowOverride = false;
_lastChicken = System.currentTimeMillis();
}
@EventHandler
@ -498,8 +510,7 @@ public class SkyWars extends SoloGame
// Vein Counts
int diamondVeins = 2 + UtilMath.r(2);
int ironVeins = 3 + UtilMath.r(3);
int coalVeins = 5 + UtilMath.r(3);
int ironVeins = 4 + UtilMath.r(4);
int gravelVeins = 4 + UtilMath.r(3);
// Create Ores
@ -511,9 +522,6 @@ public class SkyWars extends SoloGame
for (int i = 0; i < ironVeins; i++)
createVein(ores, Material.IRON_ORE, 3 + UtilMath.r(3), true);
for (int i = 0; i < coalVeins; i++)
createVein(ores, Material.COAL_ORE, 4 + UtilMath.r(3), true);
for (int i = 0; i < gravelVeins; i++)
createVein(ores, Material.GRAVEL, 3 + UtilMath.r(3), false);
}
@ -645,16 +653,26 @@ public class SkyWars extends SoloGame
{
DoubleChest doubleChest = (DoubleChest) state;
fillChest(event.getPlayer(),
((Chest) doubleChest.getLeftSide()).getBlock());
fillChest(event.getPlayer(),
((Chest) doubleChest.getRightSide()).getBlock());
fillChest(event.getPlayer(), ((Chest) doubleChest.getLeftSide()).getBlock());
fillChest(event.getPlayer(), ((Chest) doubleChest.getRightSide()).getBlock());
}
else if ((state instanceof Chest))
{
fillChest(event.getPlayer(), block);
}
}
@EventHandler
public void pickupTNT(PlayerPickupItemEvent e)
{
ItemStack is = e.getItem().getItemStack();
Player player = e.getPlayer();
if (is.getType() == Material.TNT)
{
e.setCancelled(true);
_tntGen.pickup(player, e.getItem());
}
}
@EventHandler
public void onTNTThrow(PlayerInteractEvent e)
@ -706,24 +724,6 @@ public class SkyWars extends SoloGame
event.setCancelled(true);
}
@EventHandler
public void pickupTNT(PlayerPickupItemEvent e)
{
ItemStack is = e.getItem().getItemStack();
Player player = e.getPlayer();
if (is.getType() == Material.TNT)
{
e.setCancelled(true);
_tntGen.pickup(player, e.getItem());
Bukkit.getPluginManager().callEvent(new TNTPickupEvent(player));
}
if (is.getType() == Material.CHEST)
{
e.setCancelled(true);
e.getItem().remove();
}
}
@EventHandler
public void handleTNTCannon(UpdateEvent e)
{
@ -772,6 +772,11 @@ public class SkyWars extends SoloGame
public void onBlockPlaceAdd(BlockPlaceEvent e)
{
_worldBlocks.add(e.getBlock());
if (e.getBlock().getType() == Material.CHEST)
{
e.setCancelled(true);
}
}
@EventHandler
@ -793,7 +798,7 @@ public class SkyWars extends SoloGame
e.setCancelled(true);
e.getBlock().setType(Material.AIR);
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.IRON_ORE));
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0.5, 0.5, 0.5), new ItemStack(Material.IRON_INGOT));
}
}
@ -911,24 +916,19 @@ public class SkyWars extends SoloGame
if (event.GetDamage() >= 1)
return;
if (event.GetProjectile() instanceof Egg
|| event.GetProjectile() instanceof Snowball)
if (event.GetProjectile() instanceof Egg || event.GetProjectile() instanceof Snowball)
{
event.SetCancelled("Egg");
Egg egg = (Egg) event.GetProjectile();
event.SetCancelled("Egg/Snowball");
// Damage Event
Manager.GetDamage()
.NewDamageEvent(event.GetDamageeEntity(),
(LivingEntity) egg.getShooter(), egg,
DamageCause.PROJECTILE, 1, true, true, false,
UtilEnt.getName((LivingEntity) egg.getShooter()),
(LivingEntity) event.GetProjectile().getShooter(), event.GetProjectile(),
DamageCause.PROJECTILE, 1, false, true, false,
UtilEnt.getName((LivingEntity) event.GetProjectile().getShooter()),
GetName());
event.GetDamageeEntity().setVelocity(
new Vector(UtilMath.r(2), 0, UtilMath.r(2)));
event.GetDamageeEntity().setVelocity(event.GetProjectile().getVelocity().multiply(0.2));
}
}
@ -966,7 +966,7 @@ public class SkyWars extends SoloGame
chest.getBlockInventory().setItem(getIndex(used), _playerBlock.getLoot());
}
//Other
else
else if (_middleChests.contains(block))
{
//Armor
for (int i=0 ; i<1 + UtilMath.r(2) ; i++)
@ -988,6 +988,28 @@ public class SkyWars extends SoloGame
for (int i=0 ; i<1 + UtilMath.r(2) ; i++)
chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot());
}
else
{
//Armor
for (int i=0 ; i<UtilMath.r(2) ; i++)
chest.getBlockInventory().setItem(getIndex(used), _middleArmor.getLoot());
//Food
for (int i=0 ; i<UtilMath.r(3) ; i++)
chest.getBlockInventory().setItem(getIndex(used), _middleFood.getLoot());
//Tool
for (int i=0 ; i<UtilMath.r(2) ; i++)
chest.getBlockInventory().setItem(getIndex(used), _middleTool.getLoot());
//Projectile
for (int i=0 ; i<UtilMath.r(2) ; i++)
chest.getBlockInventory().setItem(getIndex(used), _middleProjectile.getLoot());
//Block
for (int i=0 ; i<UtilMath.r(2) ; i++)
chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot());
}
}
private int getIndex(HashSet<Integer> used)
@ -1034,10 +1056,10 @@ public class SkyWars extends SoloGame
_playerTool.addLoot(new RandomItem(Material.FISHING_ROD, 2));
_playerTool.addLoot(new RandomItem(Material.STONE_AXE, 2));
_playerTool.addLoot(new RandomItem(Material.STONE_PICKAXE, 2));
_playerTool.addLoot(new RandomItem(Material.STONE_PICKAXE, 3));
_playerTool.addLoot(new RandomItem(Material.IRON_AXE, 1));
_playerTool.addLoot(new RandomItem(Material.IRON_PICKAXE, 1));
_playerTool.addLoot(new RandomItem(Material.IRON_PICKAXE, 2));
//Projectile
@ -1105,4 +1127,19 @@ public class SkyWars extends SoloGame
_alreadyAnnounced = _already;
return _already;
}
@EventHandler
public void handleExplosion(ExplosionEvent event)
{
_oreHider.Explosion(event);
}
@EventHandler(priority = EventPriority.MONITOR)
public void OreReveal(BlockBreakEvent event)
{
if (event.isCancelled())
return;
_oreHider.BlockBreak(event);
}
}

View File

@ -8,10 +8,12 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.skywars.SkyWars;
import nautilus.game.arcade.game.games.skywars.events.TNTPickupEvent;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -55,7 +57,7 @@ public class TNTGenerator
return;
}
if (!UtilTime.elapsed(_time, 60000))
if (!UtilTime.elapsed(_time, 20000))
return;
// Spawn
@ -122,6 +124,7 @@ public class TNTGenerator
+ " Right Click - Short")));
player.playSound(player.getLocation(), Sound.ENDERDRAGON_HIT, 3F, 1F);
Bukkit.getPluginManager().callEvent(new TNTPickupEvent(player));
}
}