diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java index 95ebe63d8..1fb24bde3 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/block/schematic/SchematicRunnable.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.plugin.java.JavaPlugin; @@ -19,6 +20,7 @@ public class SchematicRunnable implements Runnable private BukkitTask _task; private List _changedBlocks; private Callback> _callback; + private ArrayList _spawns; private Schematic _schematic; private Block _startBlock; @@ -27,7 +29,7 @@ public class SchematicRunnable implements Runnable private int _currentZ = 0; private int _blocksPerTick = 1000; - public SchematicRunnable(JavaPlugin plugin, Schematic schematic, Block startBlock, Callback> callback) + public SchematicRunnable(JavaPlugin plugin, Schematic schematic, Block startBlock, Callback> callback, ArrayList spawns) { _plugin = plugin; _changedBlocks = new ArrayList(schematic.getSize()); @@ -36,6 +38,7 @@ public class SchematicRunnable implements Runnable _schematic = schematic; _startBlock = startBlock; + _spawns = spawns; } public void start() @@ -85,7 +88,8 @@ public class SchematicRunnable implements Runnable // We are done System.out.println("Finished importing schematic with setblockrunnable!"); - if (_callback != null) _callback.run(_changedBlocks); + if (_callback != null) + _callback.run(_changedBlocks); _task.cancel(); return; @@ -108,6 +112,12 @@ public class SchematicRunnable implements Runnable return; } + if (material == Material.COMMAND) + { + material = Material.AIR; + _spawns.add(block.getLocation().add(0.5, 0, 0.5)); + } + if (block.getTypeId() == materialId && block.getData() == data) return; @@ -115,4 +125,9 @@ public class SchematicRunnable implements Runnable _changedBlocks.add(blockData); block.setTypeIdAndData(materialId, data, false); } + + public ArrayList getSpawns() + { + return _spawns; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java index 925ced50c..477c4e851 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/blockrestore/BlockRestoreMap.java @@ -170,6 +170,11 @@ public class BlockRestoreMap return _currentIterator.next(); } + + @Override + public void remove() + { + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index c30bb11eb..ab9c70d52 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -29,6 +29,7 @@ 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.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemSpawnEvent; @@ -175,6 +176,7 @@ public class Explosion extends MiniPlugin if (Math.random() > Math.min(0.975, chance)) { FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue()); + fall.setDropItem(false); Vector vec = UtilAlg.getTrajectory(fEnt, fall); if (vec.getY() < 0) vec.setY(vec.getY() * -1); @@ -207,6 +209,13 @@ public class Explosion extends MiniPlugin }, 1); } + @EventHandler + public void ExplosionChangeBlock(EntityChangeBlockEvent event) + { + if (_explosionBlocks.contains(event.getEntity())) + event.setCancelled(true); + } + @EventHandler public void ExplosionBlockUpdate(UpdateEvent event) { @@ -256,14 +265,6 @@ public class Explosion extends MiniPlugin } } - @EventHandler - public void ExplosionItemSpawn(ItemSpawnEvent event) - { - for (FallingBlock block : _explosionBlocks) - if (UtilMath.offset(event.getEntity().getLocation(), block.getLocation()) < 1) - event.setCancelled(true); - } - @EventHandler(priority = EventPriority.LOW) public void ExplosionBlocks(EntityExplodeEvent event) { @@ -347,6 +348,7 @@ public class Explosion extends MiniPlugin if (Math.random() > Math.min(0.98, chance)) { FallingBlock fall = cur.getWorld().spawnFallingBlock(cur.getLocation().add(0.5, 0.5, 0.5), blocks.get(cur).getKey(), blocks.get(cur).getValue()); + fall.setDropItem(false); Vector vec = UtilAlg.getTrajectory(fLoc, fall.getLocation()); if (vec.getY() < 0) vec.setY(vec.getY() * -1); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java index 894c1e4d1..0217485cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemPaintbrush.java @@ -163,7 +163,7 @@ public class ItemPaintbrush extends ItemGadget continue; //Color - Manager.getBlockRestore().Add(block, 35, _brushColor.get(player.getName()), 30000); + Manager.getBlockRestore().add(block, 35, _brushColor.get(player.getName()), 30000); //Join Dots if (_brushPrevious.containsKey(player.getName())) @@ -177,7 +177,7 @@ public class ItemPaintbrush extends ItemGadget if (fixBlock.getType() != Material.WOOL) continue; - Manager.getBlockRestore().Add(fixBlock, 35, _brushColor.get(player.getName()), 30000); + Manager.getBlockRestore().add(fixBlock, 35, _brushColor.get(player.getName()), 30000); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 37d826e6c..1d66c4c91 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -7,6 +7,7 @@ public enum GameDisplay //Mini BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1), Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2), + BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3), CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6), diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java index aee8eaee7..082dd636c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/map/ItemMapRenderer.java @@ -1,11 +1,12 @@ package mineplex.game.clans.clans.map; import java.awt.Color; + import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.clans.worldevent.event.EventState; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -204,7 +205,7 @@ public class ItemMapRenderer extends MapRenderer double mapX = (point.getX() - info.getX()) / zoom; double mapZ = (point.getZ() - info.getZ()) / zoom; - // To make these appear at the edges of the map, just change it from 64 to something like 128 for double the map size + // To make these appear at the edges of the map, just change it from 64 to something like 128 for double the map size if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64) { byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D); @@ -212,7 +213,7 @@ public class ItemMapRenderer extends MapRenderer byte cursorType = 4; // http://i.imgur.com/wpH6PT8.png // Those are byte 5 and 6 - byte rotation = (byte) (int) ((point.getYaw() * 16D) / 360D); + byte rotation = (byte) ((int) Math.floor(System.currentTimeMillis() / 1000D) % 16); MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java index 43da47d9a..13af8311e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/WorldEventManager.java @@ -140,6 +140,7 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement { assert(event != null); + event.loadMap(); event.start(); getPlugin().getServer().getPluginManager().registerEvents(event, getPlugin()); _events.add(event); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java index 380d2f1fe..7027980c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/command/StartCommand.java @@ -6,8 +6,8 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.game.clans.clans.worldevent.event.WorldEvent; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.minecraft.game.core.boss.WorldEvent; public class StartCommand extends CommandBase { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java index bc4261f35..2b9f4bd73 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/kinghill/KingHill.java @@ -58,7 +58,7 @@ public class KingHill extends WorldEvent @Override protected void customStart() { - setMap(new EventMap(_hill.getSchematic(), getCenterLocation(), 10, 10, 10, 10, 10, 10), new Runnable() + setMap(new EventMap(_hill.getSchematic(), getCenterLocation()), new Runnable() { @Override public void run() diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java index c8445cc8d..0232e06e0 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/EventMap.java @@ -16,17 +16,16 @@ public class EventMap private double _yLength; private double _zLength; - public EventMap(Schematic schematic, Location cornerLocation, double xDiff, double yDiff, double zDiff, double xLength, - double yLength, double zLength) + public EventMap(Schematic schematic, Location cornerLocation) { _schematic = schematic; _cornerLocation = cornerLocation; - _xDiff = xDiff; - _yDiff = yDiff; - _zDiff = zDiff; - _xLength = xLength; - _yLength = yLength; - _zLength = zLength; + _xLength = schematic.getWidth(); + _yLength = schematic.getHeight(); + _zLength = schematic.getLength(); + _xDiff = _xLength / 2D; + _yDiff = _yLength / 2D; + _zDiff = _zLength / 2D; _centerLocation = _cornerLocation.clone().add(_xDiff, _yDiff, _zDiff); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java index 06bb620d3..ea1d6289f 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/WorldEvent.java @@ -1,5 +1,7 @@ package mineplex.minecraft.game.core.boss; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -7,7 +9,9 @@ import java.util.Random; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestoreMap; import mineplex.core.common.block.BlockData; +import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.SchematicRunnable; +import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; @@ -43,6 +47,8 @@ public abstract class WorldEvent implements Listener private Random _random; private int _ticks; private long _lastActive; + private Schematic _schematic; + private ArrayList _spawns = new ArrayList(); // Creatures private List _creatures; @@ -51,6 +57,12 @@ public abstract class WorldEvent implements Listener public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, Location cornerLocation) + { + this(damageManager, blockRestore, conditionManager, name, cornerLocation, null); + } + + public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name, + Location cornerLocation, String schematicName) { _damageManager = damageManager; _conditionManager = conditionManager; @@ -58,20 +70,55 @@ public abstract class WorldEvent implements Listener _name = name; _state = EventState.PREPARE; _cornerLocation = cornerLocation; - _map = null; _random = new Random(); _ticks = 0; _creatures = new ArrayList(); _blocks = blockRestore.createMap(); _lastActive = System.currentTimeMillis(); + + if (schematicName != null) + { + try + { + _schematic = UtilSchematic.loadSchematic(new File(schematicName)); + } + catch (IOException e) + { + e.printStackTrace(); + setState(EventState.COMPLETE); + } + } + } + + public void loadMap() + { + loadMap(new Runnable() + { + @Override + public void run() + { + System.out.println("Runnable on complete"); + } + }); + } + + public void loadMap(Runnable runnable) + { + if (_schematic == null) + { + return; + } + + EventMap map = new EventMap(_schematic, _cornerLocation); + setMap(map, runnable); } public ConditionManager getCondition() { return _conditionManager; } - + public final void start() { customStart(); @@ -226,12 +273,17 @@ public abstract class WorldEvent implements Listener onComplete.run(); } - }); + }, _spawns); task.setBlocksPerTick(100); task.start(); } + public ArrayList getSpawns() + { + return _spawns; + } + protected BlockRestoreMap getBlocks() { return _blocks; diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java index e23ec20c9..6fc450904 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemBoss.java @@ -1,13 +1,7 @@ package mineplex.minecraft.game.core.boss.ironwizard; -import java.io.File; -import java.io.IOException; - import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.common.block.schematic.Schematic; -import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.minecraft.game.core.boss.EventCreature; -import mineplex.minecraft.game.core.boss.EventMap; import mineplex.minecraft.game.core.boss.EventState; import mineplex.minecraft.game.core.boss.WorldEvent; import mineplex.minecraft.game.core.condition.ConditionManager; @@ -21,29 +15,7 @@ public class GolemBoss extends WorldEvent public GolemBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, Location corner) { - super(damageManager, blockRestore, conditionManager, "Iron Wizard", corner); - - Schematic schematic = null; - - try - { - schematic = UtilSchematic.loadSchematic(new File("schematic/Golem.schematic")); - } - catch (IOException e) - { - e.printStackTrace(); - setState(EventState.COMPLETE); - } - - EventMap map = new EventMap(schematic, corner, 15, 15, 15, 15, 15, 15); - setMap(map, new Runnable() - { - @Override - public void run() - { - System.out.println("Runnable on complete"); - } - }); + super(damageManager, blockRestore, conditionManager, "Iron Wizard", corner, "schematic/Golem.schematic"); } @Override @@ -80,7 +52,7 @@ public class GolemBoss extends WorldEvent private GolemCreature spawnGolem(Location location) { - GolemCreature slimeCreature = new GolemCreature(this, location, 100); + GolemCreature slimeCreature = new GolemCreature(this, location, 2500); registerCreature(slimeCreature); return slimeCreature; } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java index b672c7a3d..93443c7a2 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/GolemCreature.java @@ -157,13 +157,13 @@ public class GolemCreature extends EventCreature if (hp < 0.7) { // Earthquake - ArrayList players = getPlayers(dist, 8); + ArrayList players = getPlayers(dist, 10); double score = 0; for (Player player : players) { - score += (8 - dist.get(player)) / 4; + score += (8 - dist.get(player)) / 2; } if (players.size() >= 3) @@ -206,9 +206,8 @@ public class GolemCreature extends EventCreature } } - if (_canCaveIn <= 0) - { // Cave in - + if (_canCaveIn <= 0)// Cave in + { ArrayList players = getPlayers(dist, 30); for (GolemAbility ability : _currentAbilities) @@ -478,6 +477,31 @@ public class GolemCreature extends EventCreature } } + @EventHandler + public void onRangedAttack(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(getEntity())) + { + if (event.GetDamageePlayer() != null) + { + double dist = event.GetDamageePlayer().getLocation().distance(getEntity().getLocation()); + + double maxRange = _usedFinalAttack ? 20 : 45; + + double modifier = (maxRange - dist) / maxRange; + + if (modifier > 0) + { + event.AddMod("Ranged Resistance", modifier); + } + else + { + event.SetCancelled("Range too far"); + } + } + } + } + @Override public void dieCustom() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java index a627bf5a2..47361630a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemAbility.java @@ -7,11 +7,13 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.IronGolem; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; public abstract class GolemAbility implements Listener diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java index 1dccc1e36..51e0a7468 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemCaveIn.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; @@ -245,6 +246,15 @@ public class GolemCaveIn extends GolemAbility } } + if (_tick % 5 == 0) + { + for (Player player : UtilPlayer.getNearby(getLocation(), 2.5, true)) + { + player.teleport(player.getLocation().add(0, 4, 0)); + UtilAction.velocity(player, new Vector(UtilMath.r(10) - 5, 3, UtilMath.r(10) - 5).normalize()); + } + } + if (_tick < 200) { Location loc = getLocation(); diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java index 8fad751c2..796ec50da 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/ironwizard/abilities/GolemExplodingAura.java @@ -410,18 +410,6 @@ public class GolemExplodingAura extends GolemAbility } } - @EventHandler - public void onDamage(CustomDamageEvent event) - { - if (event.GetDamageeEntity().equals(getEntity())) - { - if (event.GetProjectile() != null) - { - event.AddMod("Ranged Resistance", 0.1); - } - } - } - @Override public boolean inProgress() { diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java index 9b968809d..9618a13a7 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/boss/slimeking/SlimeBoss.java @@ -28,31 +28,9 @@ public class SlimeBoss extends WorldEvent public SlimeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, ProjectileManager projectileManager, Location corner) { - super(damageManager, blockRestore, conditionManager, "Slime King", corner); + super(damageManager, blockRestore, conditionManager, "Slime King", corner, "schematic/ClansSlimeFinal.schematic"); _projectileManager = projectileManager; - - Schematic schematic = null; - - try - { - schematic = UtilSchematic.loadSchematic(new File("schematic/ClansSlimeFinal.schematic")); - } - catch (IOException e) - { - e.printStackTrace(); - setState(EventState.COMPLETE); - } - - EventMap map = new EventMap(schematic, corner, 15, 15, 15, 15, 15, 15); - setMap(map, new Runnable() - { - @Override - public void run() - { - System.out.println("Runnable on complete"); - } - }); } public ProjectileManager getProjectileManager() diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java index 9599b9a5d..636cca24a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/explosion/CustomExplosion.java @@ -8,15 +8,6 @@ import java.util.Iterator; import java.util.List; import java.util.Random; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - import mineplex.core.explosion.ExplosionEvent; import mineplex.minecraft.game.core.damage.DamageManager; import net.minecraft.server.v1_7_R4.AxisAlignedBB; @@ -34,6 +25,15 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutExplosion; import net.minecraft.server.v1_7_R4.Vec3D; import net.minecraft.server.v1_7_R4.World; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + public class CustomExplosion extends Explosion { private org.bukkit.entity.LivingEntity _owner; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 875e86e77..064bae164 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -5,6 +5,7 @@ import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; +import nautilus.game.arcade.game.games.bossbattles.BossBattles; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.build.Build; import nautilus.game.arcade.game.games.cards.Cards; @@ -66,6 +67,7 @@ public enum GameType //Mini BaconBrawl(BaconBrawl.class, GameDisplay.BaconBrawl), Barbarians(Barbarians.class, GameDisplay.Barbarians), + BossBattles(BossBattles.class, GameDisplay.BossBattles), Bridge(Bridge.class, GameDisplay.Bridge), CastleSiege(CastleSiege.class, GameDisplay.CastleSiege), ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java new file mode 100644 index 000000000..1d404936f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BattleBoss.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.bossbattles; + +import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public enum BattleBoss +{ + GOLEM(GolemBoss.class, new ItemStack(Material.IRON_BLOCK)), + + SLIME(SlimeBoss.class, new ItemStack(Material.EMERALD_BLOCK)); + + private Class _bossClass; + private ItemStack _bossHead; + + private BattleBoss(Class bossClass, ItemStack bossHead) + { + _bossClass = bossClass; + _bossHead = bossHead; + } + + public Class getBoss() + { + return _bossClass; + } + + public ItemStack getItem() + { + return _bossHead; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java new file mode 100644 index 000000000..9544a2478 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bossbattles/BossBattles.java @@ -0,0 +1,271 @@ +package nautilus.game.arcade.game.games.bossbattles; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.boss.EventState; +import mineplex.minecraft.game.core.boss.WorldEvent; +import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.champions.kits.KitAssassin; +import nautilus.game.arcade.game.games.champions.kits.KitBrute; +import nautilus.game.arcade.game.games.champions.kits.KitKnight; +import nautilus.game.arcade.game.games.champions.kits.KitMage; +import nautilus.game.arcade.game.games.champions.kits.KitRanger; +import nautilus.game.arcade.kit.Kit; + +public class BossBattles extends SoloGame +{ + private WorldEvent _currentBoss; + private HashMap _bosses = new HashMap(); + private ArrayList _normalSpawns = new ArrayList(); + + public BossBattles(ArcadeManager manager) + { + super(manager, GameType.BossBattles, new Kit[] + { + new KitBrute(manager), new KitRanger(manager), + new KitKnight(manager), new KitMage(manager), + new KitAssassin(manager), + }, new String[] + { + "Fight some bosses" + }); + + Damage = false; + DamagePvP = false; + DamageSelf = false; + DamageTeamOther = false; + + DeathOut = false; + } + + @EventHandler + public void checkBossIsDead(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (_currentBoss == null) + { + return; + } + + if (GetPlayers(true).isEmpty()) + { + _currentBoss.cancel(); + } + + if (_currentBoss.getState() != EventState.COMPLETE + && _currentBoss.getState() != EventState.CANCELLED) + { + return; + } + + endCurrentBoss(); + } + + private void endCurrentBoss() + { + CreatureAllowOverride = false; + + HandlerList.unregisterAll(_currentBoss); + + GetTeamList().get(0).SetSpawns(_normalSpawns); + + // If the event was cancelled, we don't need to run a cleanup + if (_currentBoss.getState() == EventState.COMPLETE) + _currentBoss.cleanup(); + + _currentBoss = null; + Damage = false; + + SpectatorSpawn = UtilWorld.averageLocation(GetTeamList().get(0) + .GetSpawns()); + + for (Player player : GetPlayers(false)) + { + if (!IsAlive(player)) + { + RespawnPlayer(player); + } + else + { + player.teleport(GetTeamList().get(0).GetSpawn()); + } + } + } + + @Override + public void ParseData() + { + _normalSpawns = GetTeamList().get(0).GetSpawns(); + + WorldData.MinX = -1500; + WorldData.MinZ = -1500; + + WorldData.MaxX = 1500; + WorldData.MaxZ = 1500; + + int i = 0; + + for (Location loc : UtilShapes.getPointsInCircle(new Location( + WorldData.World, 0, 8, 0), BattleBoss.values().length, 4)) + { + BattleBoss boss = BattleBoss.values()[i++]; + + Block block = loc.getBlock(); + + block.setType(boss.getItem().getType()); + + block.getRelative(0, -2, 0).setType(Material.QUARTZ_BLOCK); + + _bosses.put(block, boss); + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + if (!IsLive()) + { + return; + } + + if (_currentBoss != null) + { + return; + } + + if (!_bosses.containsKey(event.getClickedBlock())) + { + return; + } + + BattleBoss boss = _bosses.get(event.getClickedBlock()); + + Announce(event.getPlayer().getName() + + " has started a boss fight against " + boss.name()); + + setNewBoss(boss); + } + + @EventHandler + public void onGameStateChange(GameStateChangeEvent event) + { + if (_currentBoss == null) + { + return; + } + + endCurrentBoss(); + } + + public WorldEvent createInstance(Class clazz, Location centerLocation) + { + WorldEvent worldEvent = null; + + try + { + for (Constructor con : clazz.getConstructors()) + { + if (clazz != SlimeBoss.class) + { + worldEvent = (WorldEvent) con.newInstance( + getArcadeManager().GetDamage(), getArcadeManager() + .GetBlockRestore(), getArcadeManager() + .GetCondition(), centerLocation); + } + else + { + worldEvent = (WorldEvent) con.newInstance( + getArcadeManager().GetDamage(), getArcadeManager() + .GetBlockRestore(), getArcadeManager() + .GetCondition(), getArcadeManager() + .GetProjectile(), centerLocation); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + return worldEvent; + } + + private void setNewBoss(BattleBoss boss) + { + _currentBoss = createInstance(boss.getBoss(), new Location( + WorldData.World, 1000, 10, 0)); + + _currentBoss.loadMap(new Runnable() + { + public void run() + { + CreatureAllowOverride = true; + + _currentBoss.start(); + + Bukkit.getPluginManager().registerEvents(_currentBoss, + getArcadeManager().getPlugin()); + + Announce("Teleportation shall commence in T-MINUS 5 seconds"); + + Bukkit.getScheduler().scheduleSyncDelayedTask( + getArcadeManager().getPlugin(), new Runnable() + { + public void run() + { + ArrayList spawns = _currentBoss + .getSpawns(); + + if (spawns.isEmpty()) + { + spawns.add(_currentBoss.getCenterLocation()); + } + + GetTeamList().get(0).SetSpawns(spawns); + + SpectatorSpawn = UtilWorld + .averageLocation(spawns); + + for (Player player : GetPlayers(true)) + { + player.teleport(GetTeamList().get(0) + .GetSpawn()); + } + + Damage = true; + } + }, 20 * 5); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index 6e255aea9..d4691b620 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; @@ -11,7 +12,6 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.data.BlockData; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java index 925d0d6fb..cf672d0e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wither/WitherGame.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import mineplex.core.common.block.BlockData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -21,7 +22,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; -import mineplex.core.data.BlockData; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -368,7 +368,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer { UtilParticle.PlayParticle(ParticleType.FLAME, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); - Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000); + Manager.GetBlockRestore().add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000); } } }.runTaskLater(Manager.getPlugin(), 5); @@ -700,7 +700,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer if (dist < radius) { - Manager.GetBlockRestore().Add(data.Block, 0, (byte) 0, + Manager.GetBlockRestore().add(data.Block, 0, (byte) 0, data.Material.getId(), data.Data, (long) (6000 * (dist / radius))); dataIt.remove();