diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index a2a9272d5..fec6f0710 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -4,11 +4,16 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import net.minecraft.server.v1_7_R4.Blocks; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.WorldServer; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.inventory.ItemStack; public class UtilBlock @@ -304,7 +309,13 @@ public class UtilBlock return blockList; } + public static HashMap getInRadius(Block block, double dR) + { + return getInRadius(block, dR, false); + } + + public static HashMap getInRadius(Block block, double dR, boolean hollow) { HashMap blockList = new HashMap(); int iR = (int)dR + 1; @@ -317,8 +328,10 @@ public class UtilBlock double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation()); - if (offset <= dR) - blockList.put(curBlock, 1 - (offset/dR)); + if (offset <= dR && !(hollow && offset < dR - 1)) + { + blockList.put(curBlock, 1 - (offset / dR)); + } } return blockList; @@ -369,6 +382,74 @@ public class UtilBlock return block.getRelative(BlockFace.UP); } + + /** + * + * @param location of explosion + * @param strength of explosion + * @param damageBlocksEqually - Treat all blocks as durability of dirt + * @param ensureDestruction - Ensure that the closest blocks are destroyed at least + * @return + */ + public static ArrayList getExplosionBlocks(Location location, float strength, boolean damageBlocksEqually) + { + ArrayList toExplode = new ArrayList(); + WorldServer world = ((CraftWorld) location.getWorld()).getHandle(); + + for (int i = 0; i < 16; i++) + { + for (int j = 0; j < 16; j++) + { + for (int k = 0; k < 16; k++) + { + if ((i == 0) || (i == 16 - 1) || (j == 0) || (j == 16 - 1) || (k == 0) || (k == 16 - 1)) + { + double d3 = i / (16 - 1.0F) * 2.0F - 1.0F; + double d4 = j / (16 - 1.0F) * 2.0F - 1.0F; + double d5 = k / (16 - 1.0F) * 2.0F - 1.0F; + double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + + d3 /= d6; + d4 /= d6; + d5 /= d6; + float f1 = strength * (0.7F + UtilMath.random.nextFloat() * 0.6F); + + double d0 = location.getX(); + double d1 = location.getY(); + double d2 = location.getZ(); + + for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) + { + int l = MathHelper.floor(d0); + int i1 = MathHelper.floor(d1); + int j1 = MathHelper.floor(d2); + Block block = location.getWorld().getBlockAt(l, i1, j1); + + if (block.getType() != Material.AIR) + { + float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(block.getX(), block.getY(), + block.getZ())).a((net.minecraft.server.v1_7_R4.Entity) null); + + f1 -= (f3 + 0.3F) * f2; + } + + if ((f1 > 0.0F) && (i1 < 256) && (i1 >= 0)) + { + toExplode.add(block); + } + + d0 += d3 * f2; + d1 += d4 * f2; + d2 += d5 * f2; + } + } + } + } + } + + return toExplode; + } + public static ArrayList getSurrounding(Block block, boolean diagonals) { ArrayList blocks = new ArrayList(); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index 1c42b669e..0cd02d837 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -1,127 +1,225 @@ package mineplex.core.common.util; - + import java.lang.reflect.Field; import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.Material; import org.bukkit.entity.Player; - + public class UtilParticle { public enum ParticleType { - HUGE_EXPLOSION("hugeexplosion"), - LARGE_EXPLODE("largeexplode"), - FIREWORKS_SPARK("fireworksSpark"), - BUBBLE("bubble"), - SUSPEND("suspended"), - DEPTH_SUSPEND("depthSuspend"), - TOWN_AURA("townaura"), - CRIT("crit"), - MAGIC_CRIT("magicCrit"), - MOB_SPELL("mobSpell"), - MOB_SPELL_AMBIENT("mobSpellAmbient"), - SPELL("spell"), - INSTANT_SPELL("instantSpell"), - WITCH_MAGIC("witchMagic"), - NOTE("note"), - PORTAL("portal"), - ENCHANTMENT_TABLE("enchantmenttable"), - EXPLODE("explode"), - FLAME("flame"), - LAVA("lava"), - FOOTSTEP("footstep"), - SPLASH("splash"), - LARGE_SMOKE("largesmoke"), - CLOUD("cloud"), - RED_DUST("reddust"), - SNOWBALL_POOF("snowballpoof"), - DRIP_WATER("dripWater"), - DRIP_LAVA("dripLava"), - DROPLET("droplet"), - SNOW_SHOVEL("snowshovel"), - SLIME("slime"), - HEART("heart"), - ANGRY_VILLAGER("angryVillager"), - HAPPY_VILLAGER("happyVillager"); + ANGRY_VILLAGER("angryVillager"), - public String particleName; - - ParticleType(String particleName) - { - this.particleName = particleName; - } + BLOCK_CRACK("blockcrack_1_0") + { + @Override + public String getParticle(Material type, int data) + { + return "blockcrack_" + type.getId() + "_" + data; + } + }, + + BLOCK_DUST("blockdust_1_0") + { + @Override + public String getParticle(Material type, int data) + { + return "blockdust_" + type.getId() + "_" + data; + } + }, + + BUBBLE("bubble"), + + CLOUD("cloud"), + + CRIT("crit"), + + DEPTH_SUSPEND("depthSuspend"), + + DRIP_LAVA("dripLava"), + + DRIP_WATER("dripWater"), + + DROPLET("droplet"), + + ENCHANTMENT_TABLE("enchantmenttable"), + + EXPLODE("explode"), + + FIREWORKS_SPARK("fireworksSpark"), + + FLAME("flame"), + + FOOTSTEP("footstep"), + + HAPPY_VILLAGER("happyVillager"), + + HEART("heart"), + + HUGE_EXPLOSION("hugeexplosion"), + + ICON_CRACK("iconcrack_1_0") + { + @Override + public String getParticle(Material type, int data) + { + return "iconcrack_" + type.getId() + "_" + data; + } + }, + + INSTANT_SPELL("instantSpell"), + + LARGE_EXPLODE("largeexplode"), + + LARGE_SMOKE("largesmoke"), + + LAVA("lava"), + + MAGIC_CRIT("magicCrit"), + + /** + * Can be colored if count is 0, color is RGB and depends on the offset of xyz + */ + MOB_SPELL("mobSpell"), + + /** + * Can be colored if count is 0, color is RGB and depends on the offset of xyz + */ + MOB_SPELL_AMBIENT("mobSpellAmbient"), + + NOTE("note"), + + PORTAL("portal"), + + /** + * Can be colored if count is 0, color is RGB and depends on the offset of xyz. Offset y if 0 will default to 1, counter by making it 0.0001 + */ + RED_DUST("reddust"), + + SLIME("slime"), + + SNOW_SHOVEL("snowshovel"), + + SNOWBALL_POOF("snowballpoof"), + + SPELL("spell"), + + SPLASH("splash"), + + SUSPEND("suspended"), + + TOWN_AURA("townaura"), + + WITCH_MAGIC("witchMagic"); + + public String particleName; + + ParticleType(String particleName) + { + this.particleName = particleName; + } + + public String getParticle(Material type, int data) + { + return particleName; + } } - - public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) - { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(); - - for (Field field : packet.getClass().getDeclaredFields()) - { - try - { - field.setAccessible(true); - String fieldName = field.getName(); - switch (fieldName) - { - case "a": - field.set(packet, type.particleName); //Particle name - break; - case "b": - field.setFloat(packet, (float)location.getX()); //Block X - break; - case "c": - field.setFloat(packet, (float)location.getY()); //Block Y - break; - case "d": - field.setFloat(packet, (float)location.getZ()); //Block Z - break; - case "e": - field.setFloat(packet, offsetX); //Random X Offset - break; - case "f": - field.setFloat(packet, offsetY); //Random Y Offset - break; - case "g": - field.setFloat(packet, offsetZ); //Random Z Offset - break; - case "h": - field.setFloat(packet, speed); //Speed/data of particles - break; - case "i": - field.setInt(packet, count); //Amount of particles - break; - } - } - catch (Exception e) - { - System.out.println(e.getMessage()); - return; - } - } - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - - public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) + private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY, + float offsetZ, float speed, int count) { + + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(); + + for (Field field : packet.getClass().getDeclaredFields()) + { + try + { + field.setAccessible(true); + String fieldName = field.getName(); + switch (fieldName) + { + case "a": + field.set(packet, particleName); // Particle name + break; + case "b": + field.setFloat(packet, (float) location.getX()); // Block X + break; + case "c": + field.setFloat(packet, (float) location.getY()); // Block Y + break; + case "d": + field.setFloat(packet, (float) location.getZ()); // Block Z + break; + case "e": + field.setFloat(packet, offsetX); // Random X Offset + break; + case "f": + field.setFloat(packet, offsetY); // Random Y Offset + break; + case "g": + field.setFloat(packet, offsetZ); // Random Z Offset + break; + case "h": + field.setFloat(packet, speed); // Speed/data of particles + break; + case "i": + field.setInt(packet, count); // Amount of particles + break; + } + } + catch (Exception e) + { + System.out.println(e.getMessage()); + } + } + + return packet; + } + + public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, + float speed, int count) + { + PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count); + } + + public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, + float offsetZ, float speed, int count) + { + PlayParticle(player, type.particleName, location, offsetX, offsetY, offsetZ, speed, count); + } + + public static void PlayParticle(Player player, String particleName, Location location, float offsetX, float offsetY, + float offsetZ, float speed, int count) + { + PacketPlayOutWorldParticles packet = getPacket(particleName, location, offsetX, offsetY, offsetZ, speed, count); + + UtilPlayer.sendPacket(player, packet); + } + + public static void PlayParticle(String particleName, Location location, float offsetX, float offsetY, float offsetZ, + float speed, int count) + { + PacketPlayOutWorldParticles packet = getPacket(particleName, location, offsetX, offsetY, offsetZ, speed, count); + for (Player player : UtilServer.getPlayers()) { - //Dont send to players who cannot see it! - if (type != ParticleType.FIREWORKS_SPARK && - type != ParticleType.LARGE_EXPLODE && - type != ParticleType.HUGE_EXPLOSION) + // Dont send to players who cannot see it! + if (!particleName.equals(ParticleType.FIREWORKS_SPARK.particleName) + && !particleName.equals(ParticleType.LARGE_EXPLODE.particleName) + && !particleName.equals(ParticleType.HUGE_EXPLOSION.particleName)) { if (UtilMath.offset(player.getLocation(), location) > 24) { continue; } } - - PlayParticle(player, type, location, offsetX, offsetY, offsetZ, speed, count); + + UtilPlayer.sendPacket(player, packet); } } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilShapes.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilShapes.java index b632af579..c5443b0d1 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilShapes.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilShapes.java @@ -9,181 +9,237 @@ import org.bukkit.util.Vector; public class UtilShapes { - private final static BlockFace[] diagonalFaces = - { - BlockFace.SOUTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_EAST, BlockFace.SOUTH_EAST - }; + private final static BlockFace[] diagonalFaces = + { + BlockFace.SOUTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_EAST, BlockFace.SOUTH_EAST + }; - private final static BlockFace[] radial = - { - BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, - BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST - }; + private final static BlockFace[] radial = + { + BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, + BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST + }; - private final static BlockFace[] squareFaces = - { - BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST - }; + private final static BlockFace[] squareFaces = + { + BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST + }; - public static ArrayList getCircle(Location loc, double radius, boolean hollow) - { - return getCircleBlocks(loc, radius, 0, hollow, false); - } + public static ArrayList getCircle(Location loc, double radius, boolean hollow) + { + return getCircleBlocks(loc, radius, 0, hollow, false); + } - public static ArrayList getSphereBlocks(Location loc, double radius, double height, boolean hollow) - { - return getCircleBlocks(loc, radius, height, hollow, true); - } + public static ArrayList getSphereBlocks(Location loc, double radius, double height, boolean hollow) + { + return getCircleBlocks(loc, radius, height, hollow, true); + } - private static ArrayList getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere) - { - ArrayList circleblocks = new ArrayList(); - double cx = loc.getBlockX(); - double cy = loc.getBlockY(); - double cz = loc.getBlockZ(); + private static ArrayList getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere) + { + ArrayList circleblocks = new ArrayList(); + double cx = loc.getBlockX(); + double cy = loc.getBlockY(); + double cz = loc.getBlockZ(); - for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++) - { - for (double x = cx - radius; x <= cx + radius; x++) - { - for (double z = cz - radius; z <= cz + radius; z++) - { - double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0); + for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++) + { + for (double x = cx - radius; x <= cx + radius; x++) + { + for (double z = cz - radius; z <= cz + radius; z++) + { + double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0); - if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1))) - { - Location l = new Location(loc.getWorld(), x, y, z); - circleblocks.add(l); - } - } - } - } + if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1))) + { + Location l = new Location(loc.getWorld(), x, y, z); + circleblocks.add(l); + } + } + } + } - return circleblocks; - } + return circleblocks; + } - /** - * Gets the block at the exact corners, will return a diagonal. - * - * @Yeah ik this code sucks. - */ - public static BlockFace[] getCornerBlockFaces(Block b, BlockFace facing) - { - BlockFace left = null; - BlockFace right = null; - for (int i = 0; i < radial.length; i++) - { - if (radial[i] == facing) - { - int high = i + 2; - if (high >= radial.length) - high = high - radial.length; - int low = i - 2; - if (low < 0) - low = radial.length + low; - left = radial[low]; - right = radial[high]; - return new BlockFace[] - { - left, right - }; - } - } - return null; - } + /** + * Gets the block at the exact corners, will return a diagonal. + * + * @Yeah ik this code sucks. + */ + public static BlockFace[] getCornerBlockFaces(Block b, BlockFace facing) + { + BlockFace left = null; + BlockFace right = null; + for (int i = 0; i < radial.length; i++) + { + if (radial[i] == facing) + { + int high = i + 2; + if (high >= radial.length) + high = high - radial.length; + int low = i - 2; + if (low < 0) + low = radial.length + low; + left = radial[low]; + right = radial[high]; + return new BlockFace[] + { + left, right + }; + } + } + return null; + } - public static Block[] getCornerBlocks(Block b, BlockFace facing) - { - BlockFace[] faces = getSideBlockFaces(b, facing); - return new Block[] - { - b.getRelative(faces[0]), b.getRelative(faces[1]) - }; - } + public static Block[] getCornerBlocks(Block b, BlockFace facing) + { + BlockFace[] faces = getSideBlockFaces(facing); + return new Block[] + { + b.getRelative(faces[0]), b.getRelative(faces[1]) + }; + } - public static BlockFace getFacing(float yaw) - { - return radial[Math.round(yaw / 45f) & 0x7]; - } + public static BlockFace getFacing(float yaw) + { + return radial[Math.round(yaw / 45f) & 0x7]; + } - public static ArrayList getLinesDistancedPoints(Location startingPoint, Location endingPoint, - double distanceBetweenParticles) - { - return getLinesLimitedPoints(startingPoint, endingPoint, - (int) Math.ceil(startingPoint.distance(endingPoint) / distanceBetweenParticles)); - } + public static ArrayList getLinesDistancedPoints(Location startingPoint, Location endingPoint, + double distanceBetweenParticles) + { + return getLinesLimitedPoints(startingPoint, endingPoint, + (int) Math.ceil(startingPoint.distance(endingPoint) / distanceBetweenParticles)); + } - public static ArrayList getLinesLimitedPoints(Location startingPoint, Location endingPoint, int amountOfPoints) - { - startingPoint = startingPoint.clone(); - Vector vector = endingPoint.toVector().subtract(startingPoint.toVector()); - vector.normalize(); - vector.multiply(startingPoint.distance(endingPoint) / (amountOfPoints + 1D)); + public static ArrayList getLinesLimitedPoints(Location startingPoint, Location endingPoint, int amountOfPoints) + { + startingPoint = startingPoint.clone(); + Vector vector = endingPoint.toVector().subtract(startingPoint.toVector()); + vector.normalize(); + vector.multiply(startingPoint.distance(endingPoint) / (amountOfPoints + 1D)); - ArrayList locs = new ArrayList(); - for (int i = 0; i < amountOfPoints; i++) - { - locs.add(startingPoint.add(vector).clone()); - } - return locs; - } + ArrayList locs = new ArrayList(); + for (int i = 0; i < amountOfPoints; i++) + { + locs.add(startingPoint.add(vector).clone()); + } + return locs; + } - public static ArrayList getPointsInCircle(Location center, int pointsAmount, double circleRadius) - { - ArrayList locs = new ArrayList(); + public static ArrayList getPointsInCircle(Location center, int pointsAmount, double circleRadius) + { + ArrayList locs = new ArrayList(); - for (int i = 0; i < pointsAmount; i++) - { - double angle = ((2 * Math.PI) / pointsAmount) * i; - double x = circleRadius * Math.cos(angle); - double z = circleRadius * Math.sin(angle); - Location loc = center.clone().add(x, 0, z); - locs.add(loc); - } - return locs; - } + for (int i = 0; i < pointsAmount; i++) + { + double angle = ((2 * Math.PI) / pointsAmount) * i; + double x = circleRadius * Math.cos(angle); + double z = circleRadius * Math.sin(angle); + Location loc = center.clone().add(x, 0, z); + locs.add(loc); + } + return locs; + } - public static ArrayList getDistancedCircle(Location center, double pointsDistance, double circleRadius) - { - return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius); - } + public static ArrayList getDistancedCircle(Location center, double pointsDistance, double circleRadius) + { + return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius); + } - /** - * Returns a north/west/east/south block, never a diagonal. - */ - public static BlockFace[] getSideBlockFaces(Block b, BlockFace facing) - { - BlockFace left = null; - BlockFace right = null; - for (int i = 0; i < 4; i++) - { - int modifierUp = (diagonalFaces[i] == facing ? 2 : squareFaces[i] == facing ? 1 : 0); - if (modifierUp != 0) - { - int high = i + modifierUp; - if (high >= squareFaces.length) - high = high - squareFaces.length; - int low = i - 1; - if (low < 0) - low = squareFaces.length + low; - left = squareFaces[low]; - right = squareFaces[high]; - return new BlockFace[] - { - left, right - }; - } - } - return null; - } + /** + * Returns a north/west/east/south block, never a diagonal. + */ + public static BlockFace[] getSideBlockFaces(BlockFace facing) + { + return getSideBlockFaces(facing, true); + } - public static Block[] getSideBlocks(Block b, BlockFace facing) - { - BlockFace[] faces = getSideBlockFaces(b, facing); - return new Block[] - { - b.getRelative(faces[0]), b.getRelative(faces[1]) - }; - } + public static BlockFace[] getSideBlockFaces(BlockFace facing, boolean allowDiagonal) + { + + int[][] facesXZ; + allowDiagonal = !allowDiagonal && (facing.getModX() != 0 && facing.getModZ() != 0); + + facesXZ = new int[][] + { + + new int[] + { + allowDiagonal ? facing.getModX() : facing.getModZ(), allowDiagonal ? 0 : -facing.getModX() + }, + + new int[] + { + allowDiagonal ? 0 : -facing.getModZ(), allowDiagonal ? facing.getModZ() : facing.getModX() + } + }; + + BlockFace[] faces = new BlockFace[2]; + + for (int i = 0; i < 2; i++) + { + int[] f = facesXZ[i]; + + for (BlockFace face : BlockFace.values()) + { + if (face.getModY() == 0) + { + if (f[0] == face.getModX() && f[1] == face.getModZ()) + { + faces[i] = face; + break; + } + } + } + } + + if (allowDiagonal && (facing == BlockFace.NORTH_EAST || facing == BlockFace.SOUTH_WEST)) + { + faces = new BlockFace[] + { + faces[1], faces[0] + }; + } + + return faces; + } + + public static ArrayList getDiagonalBlocks(Block block, BlockFace facing, int blockWidth) + { + ArrayList blocks = new ArrayList(); + + if (facing.getModX() == 0 || facing.getModZ() == 0) + { + return blocks; + } + + BlockFace[] faces = getSideBlockFaces(facing); + + for (BlockFace face : faces) + { + Location loc = block.getLocation().add(0.5 + (facing.getModX() / 2D), 0, 0.5 + (facing.getModZ() / 2D)); + + blocks.add(loc.add(face.getModX() / 2D, 0, face.getModZ() / 2D).getBlock()); + + for (int i = 1; i < blockWidth; i++) + { + blocks.add(loc.add(face.getModX(), 0, face.getModZ()).getBlock()); + } + } + + return blocks; + } + + public static Block[] getSideBlocks(Block b, BlockFace facing) + { + BlockFace[] faces = getSideBlockFaces(facing); + + return new Block[] + { + b.getRelative(faces[0]), b.getRelative(faces[1]) + }; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index f07adb266..b53fccd66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -25,7 +25,6 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; @@ -303,6 +302,11 @@ public class Explosion extends MiniPlugin } public void BlockExplosion(Collection blockSet, Location mid, boolean onlyAbove) + { + BlockExplosion(blockSet, mid, onlyAbove, true); + } + + public void BlockExplosion(Collection blockSet, Location mid, boolean onlyAbove, boolean removeBlock) { if (blockSet.isEmpty()) return; @@ -320,7 +324,10 @@ public class Explosion extends MiniPlugin blocks.put(cur, new AbstractMap.SimpleEntry(cur.getTypeId(), cur.getData())); - cur.setType(Material.AIR); + if (removeBlock) + { + cur.setType(Material.AIR); + } } //DELAY diff --git a/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java b/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java index 069c67cb1..4dcf4eab3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/loot/ChestLoot.java @@ -4,37 +4,32 @@ import java.util.ArrayList; import mineplex.core.common.util.UtilMath; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; public class ChestLoot { - private int _totalLoot; private ArrayList _randomItems = new ArrayList(); + private int _totalLoot; private boolean _unbreakableLoot; - public ChestLoot(boolean unbreakableLoot) - { - _unbreakableLoot = unbreakableLoot; - } - public ChestLoot() { this(false); } + public ChestLoot(boolean unbreakableLoot) + { + _unbreakableLoot = unbreakableLoot; + } + public void cloneLoot(ChestLoot loot) { _totalLoot += loot._totalLoot; _randomItems.addAll(loot._randomItems); } - public void registerLoot(RandomItem item) - { - _totalLoot += item.getAmount(); - _randomItems.add(item); - } - public ItemStack getLoot() { int no = UtilMath.r(_totalLoot); @@ -60,4 +55,30 @@ public class ChestLoot return null; } + + public void addLoot(ItemStack item, int amount) + { + addLoot(item, amount, item.getAmount(), item.getAmount()); + } + + public void addLoot(ItemStack item, int amount, int minStackSize, int maxStackSize) + { + addLoot(new RandomItem(item, amount, minStackSize, maxStackSize)); + } + + public void addLoot(Material material, int amount) + { + addLoot(material, amount, 1, 1); + } + + public void addLoot(Material material, int amount, int minStackSize, int maxStackSize) + { + addLoot(new ItemStack(material), amount, minStackSize, maxStackSize); + } + + public void addLoot(RandomItem item) + { + _totalLoot += item.getAmount(); + _randomItems.add(item); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java b/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java index ebcce4fc4..c903c6fa3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/loot/RandomItem.java @@ -11,6 +11,11 @@ public class RandomItem private ItemStack _item; private int _min, _max; + public RandomItem(ItemStack item, int amount) + { + this(item, amount, item.getAmount(), item.getAmount()); + } + public RandomItem(ItemStack item, int amount, int minStackSize, int maxStackSize) { _amount = amount; @@ -19,9 +24,9 @@ public class RandomItem _max = maxStackSize; } - public RandomItem(ItemStack item, int amount) + public RandomItem(Material material, int amount) { - this(item, amount, item.getAmount(), item.getAmount()); + this(material, amount, 1, 1); } public RandomItem(Material material, int amount, int minStackSize, int maxStackSize) @@ -32,9 +37,9 @@ public class RandomItem _max = maxStackSize; } - public RandomItem(Material material, int amount) + public int getAmount() { - this(material, amount, 1, 1); + return _amount; } public ItemStack getItemStack() @@ -43,9 +48,4 @@ public class RandomItem return _item; } - - public int getAmount() - { - return _amount; - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java new file mode 100644 index 000000000..cbc2c24ff --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResPackManager.java @@ -0,0 +1,41 @@ +package mineplex.core.resourcepack; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import mineplex.core.resourcepack.redis.RedisUnloadResPack; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; +import mineplex.serverdata.commands.ServerCommandManager; + +public class ResPackManager implements CommandCallback +{ + private ResUnloadCheck _packUnloadCheck; + + public ResPackManager(ResUnloadCheck packUnloadCheck) + { + _packUnloadCheck = packUnloadCheck; + + ServerCommandManager.getInstance().registerCommandType("RedisUnloadResPack", RedisUnloadResPack.class, this); + } + + @Override + public void run(ServerCommand command) + { + if (command instanceof RedisUnloadResPack) + { + RedisUnloadResPack redisCommand = (RedisUnloadResPack) command; + + Player player = Bukkit.getPlayerExact(redisCommand.getPlayer()); + + if (player != null) + { + if (_packUnloadCheck.canSendUnload(player)) + { + player.setResourcePack("http://www.chivebox.com/file/c/empty.zip"); + } + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java new file mode 100644 index 000000000..c25175c58 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/ResUnloadCheck.java @@ -0,0 +1,9 @@ +package mineplex.core.resourcepack; + +import org.bukkit.entity.Player; + +public interface ResUnloadCheck +{ + + public boolean canSendUnload(Player player); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/redis/RedisUnloadResPack.java b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/redis/RedisUnloadResPack.java new file mode 100644 index 000000000..ecd970213 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/resourcepack/redis/RedisUnloadResPack.java @@ -0,0 +1,19 @@ +package mineplex.core.resourcepack.redis; + +import mineplex.serverdata.commands.ServerCommand; + +public class RedisUnloadResPack extends ServerCommand +{ + private String _player; + + public RedisUnloadResPack(String player) + { + + _player = player; + } + + public String getPlayer() + { + return _player; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 1ff7875a9..17b648f21 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -36,6 +36,8 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; +import mineplex.core.resourcepack.ResUnloadCheck; +import mineplex.core.resourcepack.ResPackManager; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.spawn.Spawn; import mineplex.core.stats.StatsManager; @@ -127,6 +129,13 @@ public class Hub extends JavaPlugin implements IRelation new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new CustomTagFix(this, packetHandler); new TablistFix(this); + new ResPackManager(new ResUnloadCheck() + { + public boolean canSendUnload(Player player) + { + return true; + } + }); //new Replay(this, packetHandler); new PersonalServerManager(this, clientManager); 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 181a230db..4cdf04c68 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 @@ -1,6 +1,8 @@ package mineplex.minecraft.game.core.explosion; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -45,8 +47,15 @@ public class CustomExplosion extends Explosion private boolean _createFire; private boolean _ignoreRate = true; private float _blockExplosionSize; + private boolean _fallingBlockExplosion; + private mineplex.core.explosion.Explosion _explosion; + private float _damage; + private boolean _useCustomDamage; + private int _maxFallingBlocks = -1; + private float _maxDamage = 1000; - public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause) + public CustomExplosion(DamageManager manager, mineplex.core.explosion.Explosion explosion, Location loc, float explosionSize, + String deathCause) { super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize); @@ -54,6 +63,25 @@ public class CustomExplosion extends Explosion _manager = manager; _damageReason = deathCause; _blockExplosionSize = explosionSize; + _explosion = explosion; + } + + /** + * Center of explosion does this much damage + */ + public CustomExplosion setExplosionDamage(float damage) + { + _damage = damage; + _useCustomDamage = true; + + return this; + } + + public CustomExplosion setMaxDamage(float maxDamage) + { + _maxDamage = maxDamage; + + return this; } public CustomExplosion setBlockExplosionSize(float explosionSize) @@ -70,6 +98,20 @@ public class CustomExplosion extends Explosion return this; } + public CustomExplosion setFallingBlockExplosion(boolean fallingBlockExplosion) + { + _fallingBlockExplosion = fallingBlockExplosion; + + return this; + } + + public CustomExplosion setFallingBlockExplosionAmount(int maxFallingBlocks) + { + _maxFallingBlocks = maxFallingBlocks; + + return this; + } + public CustomExplosion setDamageBlocks(boolean damageBlocks) { b = damageBlocks; @@ -204,9 +246,21 @@ public class CustomExplosion extends Explosion d0 /= d8; d1 /= d8; d2 /= d8; + + // Performs a raytrace that determines the percentage of solid blocks between the two double d9 = this._world.a(vec3d, entity.boundingBox); double d10 = (1.0D - d7) * d9; - int damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D); + float damage; + + if (_useCustomDamage) + { + damage = Math.max(0, (int) ((_damage * d9) * (d8 / size))); + } + else + { + damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D); + damage = Math.min(damage, _maxDamage); + } if (entity.getBukkitEntity() instanceof LivingEntity) { @@ -282,6 +336,27 @@ public class CustomExplosion extends Explosion return; } + if (_fallingBlockExplosion) + { + Collection blocks = event.GetBlocks(); + + if (blocks.size() > _maxFallingBlocks) + { + blocks = new ArrayList(blocks); + + Collections.shuffle((ArrayList) blocks); + + int toRemove = blocks.size() - _maxFallingBlocks; + + for (int i = 0; i < toRemove; i++) + { + blocks.remove(0); + } + } + + _explosion.BlockExplosion(blocks, new Location(_world.getWorld(), posX, posY, posZ), false, false); + } + Iterator iterator = this.blocks.iterator(); while (iterator.hasNext()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 3410e0604..92fa0ebe6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -3,12 +3,15 @@ package nautilus.game.arcade; import java.io.File; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; +import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.OfflinePlayer; +import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Entity; @@ -30,6 +33,8 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.util.Vector; +import com.google.common.base.Objects; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -39,11 +44,12 @@ import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.disguise.DisguiseManager; @@ -55,12 +61,19 @@ import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.movement.Movement; +import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.packethandler.PacketPlayResourcePackStatus; +import mineplex.core.packethandler.PacketPlayResourcePackStatus.EnumResourcePackStatus; import mineplex.core.party.PartyManager; import mineplex.core.pet.PetManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; +import mineplex.core.resourcepack.ResUnloadCheck; +import mineplex.core.resourcepack.ResPackManager; +import mineplex.core.resourcepack.redis.RedisUnloadResPack; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.rewards.PetReward; import mineplex.core.stats.StatsManager; @@ -68,7 +81,6 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.timing.TimingManager; -import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; @@ -169,6 +181,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation private PacketHandler _packetHandler; + private IPacketHandler _resourcePacketHandler; + private String _resourcePackUrl; + private boolean _resourcePackRequired; + private NautHashMap _resourcePackUsers = new NautHashMap(); + private NautHashMap _resourcePackNoResponse = new NautHashMap(); // Observers private HashSet _specList = new HashSet(); @@ -301,6 +318,76 @@ public class ArcadeManager extends MiniPlugin implements IRelation } }, 80L); } + + _resourcePacketHandler = new IPacketHandler() + { + + @Override + public void handle(PacketInfo packetInfo) + { + if (_resourcePackUrl != null && packetInfo.getPacket() instanceof PacketPlayResourcePackStatus) + { + + final Player player = packetInfo.getPlayer(); + final EnumResourcePackStatus response = ((PacketPlayResourcePackStatus) packetInfo.getPacket()) + .getResourcePackStatus(); + + Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + + @Override + public void run() + { + if (_resourcePackRequired) + { + if (response == EnumResourcePackStatus.ACCEPTED) + { + _resourcePackNoResponse.remove(player.getName()); + } + else if (response == EnumResourcePackStatus.DECLINED) + { + _resourcePackNoResponse.remove(player.getName()); + + returnHubNoResPack(player, "Failed to download resource pack!"); + } + else if (response == EnumResourcePackStatus.FAILED_DOWNLOAD) + { + _resourcePackNoResponse.remove(player.getName()); + + returnHubNoResPack(player, "Failed to download resource pack!"); + + return; + } + } + + if (response == EnumResourcePackStatus.ACCEPTED || response == EnumResourcePackStatus.LOADED) + { + _resourcePackUsers.put(player.getName(), response); + } + else + { + _resourcePackUsers.remove(player.getName()); + } + } + }); + } + } + }; + + new ResPackManager(new ResUnloadCheck() + { + public boolean canSendUnload(Player player) + { + if (_resourcePackUsers.containsKey(player.getName())) + { + return false; + } + + return true; + } + }); + + getPacketHandler().addPacketHandler(_resourcePacketHandler); } @Override @@ -1225,4 +1312,129 @@ public class ArcadeManager extends MiniPlugin implements IRelation return UtilPlayer.isSpectator((Player)player); return false; } + + @EventHandler + public void onSecond(UpdateEvent event) + { + Iterator> itel = _resourcePackNoResponse.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (UtilTime.elapsed(entry.getValue(), 10000)) + { + Player player = Bukkit.getPlayerExact(entry.getKey()); + + if (player != null) + { + // Send it again, enforce it! + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + player.setResourcePack(_resourcePackUrl); + } + else + { + itel.remove(); + } + } + } + } + + @EventHandler + public void ResourcePackQuit(PlayerQuitEvent event) + { + + Player player = event.getPlayer(); + + EnumResourcePackStatus status = _resourcePackUsers.get(player.getName()); + + if (status == EnumResourcePackStatus.ACCEPTED || status == EnumResourcePackStatus.LOADED) + { + + new RedisUnloadResPack(player.getName()).publish(); + + _resourcePackUsers.remove(player.getName()); + } + } + + @EventHandler + public void outdatedVersion(GameStateChangeEvent event) + { + if (!_resourcePackRequired) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!UtilPlayer.is1_8(player)) + returnHubNoResPack(player, "You need to be using 1.8 to play " + GetGame().GetName() + "!"); + } + } + + private void returnHubNoResPack(Player player, String message) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cGold + C.Bold + message); + UtilPlayer.message(player, " "); + + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + GetPortal().sendPlayerToServer(player, "Lobby"); + } + + @EventHandler + public void ResourcePackJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + + if (!UtilPlayer.is1_8(player) && _resourcePackRequired) + { + returnHubNoResPack(player, "You need to be using 1.8 to play " + GetGame().GetName() + "!"); + + return; + } + + if (_resourcePackUrl != null) + { + if (_resourcePackRequired) + { + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + } + + _resourcePackUsers.put(player.getName(), null); + player.setResourcePack(_resourcePackUrl); + } + } + + public void setResourcePack(String resourcePack, boolean forceResourcePack) + { + if (!Objects.equal(resourcePack, _resourcePackUrl) || forceResourcePack != _resourcePackRequired) + { + _resourcePackNoResponse.clear(); + _resourcePackUsers.clear(); + _resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack; + _resourcePackRequired = forceResourcePack; + + if (_resourcePackUrl == null || _resourcePackUrl.isEmpty()) + { + _resourcePackRequired = false; + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.setResourcePack("http://www.chivebox.com/file/c/empty.zip"); + } + } + else + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_resourcePackRequired) + { + _resourcePackNoResponse.put(player.getName(), System.currentTimeMillis()); + } + + _resourcePackUsers.put(player.getName(), null); + player.setResourcePack(_resourcePackUrl); + } + } + } + } } 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 6b1531435..0c40897fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -8,11 +8,10 @@ public enum GameType BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1), Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.ARCADE, 2), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3), - CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4), - ChampionsTDM("Champions TDM", "Champions", Material.GOLD_SWORD, (byte)0, GameCategory.CHAMPIONS, 5), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6), ChampionsMOBA("Champions MOBA", "Champions", Material.SKULL_ITEM, (byte)0, GameCategory.CHAMPIONS, 7), + ChampionsTDM("Champions TDM", "Champions", Material.GOLD_SWORD, (byte)0, GameCategory.CHAMPIONS, 5), Christmas("Christmas Chaos", Material.SNOW_BALL, (byte)0, GameCategory.CLASSICS, 8), DeathTag("Death Tag", Material.SKULL_ITEM, (byte)0, GameCategory.ARCADE, 9), DragonEscape("Dragon Escape", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 10), @@ -27,12 +26,10 @@ public enum GameType Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19), HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21), - SurvivalGames("Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 22), - SurvivalGamesTeams("Survival Games Teams", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 23), 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.CLASSICS, 25), MineWare("MineWare", Material.PAPER, (byte)0, GameCategory.ARCADE, 26), - MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27), Paintball("Super Paintball", Material.ENDER_PEARL, (byte)0, GameCategory.ARCADE, 28), Quiver("One in the Quiver", Material.ARROW, (byte)0, GameCategory.ARCADE, 29), QuiverTeams("One in the Quiver Teams", Material.ARROW, (byte)0, GameCategory.ARCADE, 30), @@ -40,24 +37,25 @@ public enum GameType SearchAndDestroy("Search and Destroy", Material.TNT, (byte)0, GameCategory.SURVIVAL, 32), Sheep("Sheep Quest", Material.WOOL, (byte)4, GameCategory.ARCADE, 33), Smash("Super Smash Mobs", Material.SKULL_ITEM, (byte)4, GameCategory.CLASSICS, 34), - SmashTeams("Super Smash Mobs Teams", "Super Smash Mobs", Material.SKULL_ITEM, (byte)4, GameCategory.CLASSICS, 35), SmashDomination("Super Smash Mobs Domination", "Super Smash Mobs", Material.SKULL_ITEM, (byte)4, GameCategory.CLASSICS, 36), + SmashTeams("Super Smash Mobs Teams", "Super Smash Mobs", Material.SKULL_ITEM, (byte)4, GameCategory.CLASSICS, 35), Snake("Snake", Material.WOOL, (byte)0, GameCategory.ARCADE, 37), SneakyAssassins("Sneaky Assassins", Material.INK_SACK, (byte)0, GameCategory.ARCADE, 38), SnowFight("Snow Fight", Material.SNOW_BALL, (byte)0, GameCategory.ARCADE, 39), Spleef("Super Spleef", Material.IRON_SPADE, (byte)0, GameCategory.ARCADE, 40), SpleefTeams("Super Spleef Teams", Material.IRON_SPADE, (byte)0, GameCategory.ARCADE, 41), - Stacker("Super Stacker", Material.BOWL, (byte)0, GameCategory.ARCADE, 42), SquidShooter("Squid Shooter", Material.FIREWORK_CHARGE, (byte)0, GameCategory.ARCADE, 43), + Stacker("Super Stacker", Material.BOWL, (byte)0, GameCategory.ARCADE, 42), + SurvivalGames("Survival Games", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 22), + SurvivalGamesTeams("Survival Games Teams", Material.IRON_SWORD, (byte)0, GameCategory.SURVIVAL, 23), Tug("Tug of Wool", Material.WHEAT, (byte)0, GameCategory.ARCADE, 44), TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45), UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46), WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47), - Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48), + Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48, "https://www.dropbox.com/s/qrtc9c91ktvmf3q/WizPack.zip?dl=1", true), ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49), - Build("Master Builders", Material.BRICK, (byte)0, GameCategory.CLASSICS, 50), - + Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); String _name; @@ -65,6 +63,8 @@ public enum GameType Material _mat; byte _data; GameCategory _gameCategory; + boolean _enforceResourcePack; + String _resourcePack; private int _gameId; // Unique identifying id for this gamemode (used for statistics) public int getGameId() { return _gameId; } @@ -73,8 +73,18 @@ public enum GameType { this(name, name, mat, data, gameCategory, gameId); } - + + GameType(String name, Material mat, byte data, GameCategory gameCategory, int gameId, String resourcePackUrl, boolean enforceResourcePack) + { + this(name, name, mat, data, gameCategory, gameId, resourcePackUrl, enforceResourcePack); + } + GameType(String name, String lobbyName, Material mat, byte data, GameCategory gameCategory, int gameId) + { + this(name, lobbyName, mat, data, gameCategory, gameId, null, false); + } + + GameType(String name, String lobbyName, Material mat, byte data, GameCategory gameCategory, int gameId, String resourcePackUrl, boolean enforceResourcePack) { _name = name; _lobbyName = lobbyName; @@ -82,6 +92,18 @@ public enum GameType _data = data; _gameCategory = gameCategory; _gameId = gameId; + _resourcePack = resourcePackUrl; + _enforceResourcePack = enforceResourcePack; + } + + public boolean isEnforceResourcePack() + { + return _enforceResourcePack; + } + + public String getResourcePackUrl() + { + return _resourcePack; } public String GetName() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 63471b2ba..647de8bc1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -316,6 +316,8 @@ public abstract class Game implements Listener new TeamKillsStatTracker(this) ); } + + Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack()); System.out.println("Loading " + GetName() + "..."); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index d1c49d258..dfc4a6ab2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -1844,129 +1844,129 @@ public class SurvivalGames extends SoloGame private void setupLoot() { // Food - _baseLoot.registerLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3)); - _baseLoot.registerLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.CARROT_ITEM, 30, 1, 3)); - _baseLoot.registerLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1)); - _baseLoot.registerLoot(new RandomItem(Material.WHEAT, 30, 1, 6)); - _baseLoot.registerLoot(new RandomItem(Material.APPLE, 30, 1, 4)); - _baseLoot.registerLoot(new RandomItem(Material.PORK, 30, 1, 4)); - _baseLoot.registerLoot(new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6)); + _baseLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3)); + _baseLoot.addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.CARROT_ITEM, 30, 1, 3)); + _baseLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1)); + _baseLoot.addLoot(new RandomItem(Material.WHEAT, 30, 1, 6)); + _baseLoot.addLoot(new RandomItem(Material.APPLE, 30, 1, 4)); + _baseLoot.addLoot(new RandomItem(Material.PORK, 30, 1, 4)); + _baseLoot.addLoot(new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6)); // Weapons - _baseLoot.registerLoot(new RandomItem(Material.WOOD_AXE, 80)); - _baseLoot.registerLoot(new RandomItem(Material.WOOD_SWORD, 70)); - _baseLoot.registerLoot(new RandomItem(Material.STONE_AXE, 60)); - _baseLoot.registerLoot(new RandomItem(Material.STONE_SWORD, 30)); + _baseLoot.addLoot(new RandomItem(Material.WOOD_AXE, 80)); + _baseLoot.addLoot(new RandomItem(Material.WOOD_SWORD, 70)); + _baseLoot.addLoot(new RandomItem(Material.STONE_AXE, 60)); + _baseLoot.addLoot(new RandomItem(Material.STONE_SWORD, 30)); // Leather armor - _baseLoot.registerLoot(new RandomItem(Material.LEATHER_BOOTS, 30)); - _baseLoot.registerLoot(new RandomItem(Material.LEATHER_CHESTPLATE, 30)); - _baseLoot.registerLoot(new RandomItem(Material.LEATHER_HELMET, 30)); - _baseLoot.registerLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30)); + _baseLoot.addLoot(new RandomItem(Material.LEATHER_BOOTS, 30)); + _baseLoot.addLoot(new RandomItem(Material.LEATHER_CHESTPLATE, 30)); + _baseLoot.addLoot(new RandomItem(Material.LEATHER_HELMET, 30)); + _baseLoot.addLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30)); // Gold armor - _baseLoot.registerLoot(new RandomItem(Material.GOLD_BOOTS, 25)); - _baseLoot.registerLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); - _baseLoot.registerLoot(new RandomItem(Material.GOLD_HELMET, 25)); - _baseLoot.registerLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); + _baseLoot.addLoot(new RandomItem(Material.GOLD_BOOTS, 25)); + _baseLoot.addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); + _baseLoot.addLoot(new RandomItem(Material.GOLD_HELMET, 25)); + _baseLoot.addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); // Chain armor - _baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); - _baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); - _baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); - _baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); + _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); + _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); + _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); + _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); // Throwable - _baseLoot.registerLoot(new RandomItem(Material.FISHING_ROD, 30)); - _baseLoot.registerLoot(new RandomItem(Material.BOW, 20)); - _baseLoot.registerLoot(new RandomItem(Material.ARROW, 20, 1, 3)); - _baseLoot.registerLoot(new RandomItem(Material.SNOW_BALL, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.EGG, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.FISHING_ROD, 30)); + _baseLoot.addLoot(new RandomItem(Material.BOW, 20)); + _baseLoot.addLoot(new RandomItem(Material.ARROW, 20, 1, 3)); + _baseLoot.addLoot(new RandomItem(Material.SNOW_BALL, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.EGG, 30, 1, 2)); // Misc - _baseLoot.registerLoot(new RandomItem(Material.EXP_BOTTLE, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.COMPASS, 20)); - _baseLoot.registerLoot(new RandomItem(Material.STICK, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.BOAT, 15)); - _baseLoot.registerLoot(new RandomItem(Material.FLINT, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.FEATHER, 30, 1, 2)); - _baseLoot.registerLoot(new RandomItem(Material.GOLD_INGOT, 20)); - _baseLoot.registerLoot(new RandomItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT")), 15)); - _spawnLoot.registerLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); + _baseLoot.addLoot(new RandomItem(Material.EXP_BOTTLE, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.COMPASS, 20)); + _baseLoot.addLoot(new RandomItem(Material.STICK, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.BOAT, 15)); + _baseLoot.addLoot(new RandomItem(Material.FLINT, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.FEATHER, 30, 1, 2)); + _baseLoot.addLoot(new RandomItem(Material.GOLD_INGOT, 20)); + _baseLoot.addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT")), 15)); + _spawnLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); _spawnLoot.cloneLoot(_baseLoot); // Food - _spawnLoot.registerLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); - _spawnLoot.registerLoot(new RandomItem(Material.CAKE, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); - _spawnLoot.registerLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); - _spawnLoot.registerLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); - _spawnLoot.registerLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); - _spawnLoot.registerLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); - _spawnLoot.registerLoot(new RandomItem(Material.COOKIE, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); - _spawnLoot.registerLoot(new RandomItem(Material.APPLE, 30, 2, 6)); + _spawnLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); + _spawnLoot.addLoot(new RandomItem(Material.CAKE, 30)); + _spawnLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); + _spawnLoot.addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); + _spawnLoot.addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); + _spawnLoot.addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); + _spawnLoot.addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); + _spawnLoot.addLoot(new RandomItem(Material.COOKIE, 30)); + _spawnLoot.addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); + _spawnLoot.addLoot(new RandomItem(Material.APPLE, 30, 2, 6)); // Loot for chests in spawn // Weaponry and ores - _spawnLoot.registerLoot(new RandomItem(Material.STONE_SWORD, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.IRON_AXE, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2)); - _spawnLoot.registerLoot(new RandomItem(Material.DIAMOND, 30)); + _spawnLoot.addLoot(new RandomItem(Material.STONE_SWORD, 30)); + _spawnLoot.addLoot(new RandomItem(Material.IRON_AXE, 30)); + _spawnLoot.addLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2)); + _spawnLoot.addLoot(new RandomItem(Material.DIAMOND, 30)); // Iron gear - _spawnLoot.registerLoot(new RandomItem(Material.IRON_BOOTS, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.IRON_HELMET, 30)); - _spawnLoot.registerLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); + _spawnLoot.addLoot(new RandomItem(Material.IRON_BOOTS, 30)); + _spawnLoot.addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); + _spawnLoot.addLoot(new RandomItem(Material.IRON_HELMET, 30)); + _spawnLoot.addLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); // Supply crate loot // Diamond gear - _crateLoot.registerLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); - _crateLoot.registerLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); - _crateLoot.registerLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); - _crateLoot.registerLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); + _crateLoot.addLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); + _crateLoot.addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); + _crateLoot.addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); + _crateLoot.addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); // Iron gear - _crateLoot.registerLoot(new RandomItem(Material.IRON_HELMET, 30)); - _crateLoot.registerLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); - _crateLoot.registerLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); - _crateLoot.registerLoot(new RandomItem(Material.IRON_BOOTS, 30)); + _crateLoot.addLoot(new RandomItem(Material.IRON_HELMET, 30)); + _crateLoot.addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); + _crateLoot.addLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); + _crateLoot.addLoot(new RandomItem(Material.IRON_BOOTS, 30)); // Weapons - _crateLoot.registerLoot(new RandomItem(Material.IRON_SWORD, 24)); - _crateLoot.registerLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); - _crateLoot.registerLoot(new RandomItem(Material.DIAMOND_AXE, 16)); + _crateLoot.addLoot(new RandomItem(Material.IRON_SWORD, 24)); + _crateLoot.addLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); + _crateLoot.addLoot(new RandomItem(Material.DIAMOND_AXE, 16)); // Cooked furnace - _cookedFurnace.registerLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); - _cookedFurnace.registerLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); - _cookedFurnace.registerLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); - _cookedFurnace.registerLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); - _cookedFurnace.registerLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); - _cookedFurnace.registerLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); - _cookedFurnace.registerLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); + _cookedFurnace.addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); + _cookedFurnace.addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); + _cookedFurnace.addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); + _cookedFurnace.addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); + _cookedFurnace.addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); + _cookedFurnace.addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); + _cookedFurnace.addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); // Raw furnace - _rawFurnace.registerLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); - _rawFurnace.registerLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); - _rawFurnace.registerLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); - _rawFurnace.registerLoot(new RandomItem(Material.PORK, 1, 1, 3)); - _rawFurnace.registerLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); + _rawFurnace.addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); + _rawFurnace.addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); + _rawFurnace.addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); + _rawFurnace.addLoot(new RandomItem(Material.PORK, 1, 1, 3)); + _rawFurnace.addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); // Deathmatch Loot - _deathMatchLoot.registerLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); - _deathMatchLoot.registerLoot(new RandomItem(Material.BAKED_POTATO, 4)); - _deathMatchLoot.registerLoot(new RandomItem(Material.CAKE, 4)); - _deathMatchLoot.registerLoot(new RandomItem(Material.APPLE, 4)); - _deathMatchLoot.registerLoot(new RandomItem(Material.CARROT_ITEM, 4)); - _deathMatchLoot.registerLoot(new RandomItem(Material.WOOD_SWORD, 3)); - _deathMatchLoot.registerLoot(new RandomItem(Material.WOOD_AXE, 3)); - _deathMatchLoot.registerLoot(new RandomItem(Material.STONE_AXE, 3)); - _deathMatchLoot.registerLoot(new RandomItem(Material.STONE_SWORD, 1)); + _deathMatchLoot.addLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); + _deathMatchLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 4)); + _deathMatchLoot.addLoot(new RandomItem(Material.CAKE, 4)); + _deathMatchLoot.addLoot(new RandomItem(Material.APPLE, 4)); + _deathMatchLoot.addLoot(new RandomItem(Material.CARROT_ITEM, 4)); + _deathMatchLoot.addLoot(new RandomItem(Material.WOOD_SWORD, 3)); + _deathMatchLoot.addLoot(new RandomItem(Material.WOOD_AXE, 3)); + _deathMatchLoot.addLoot(new RandomItem(Material.STONE_AXE, 3)); + _deathMatchLoot.addLoot(new RandomItem(Material.STONE_SWORD, 1)); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java index 8069d6ddf..5550dbfda 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java @@ -10,31 +10,46 @@ import org.bukkit.event.inventory.ClickType; public class SpellButton implements IButton { - private SpellType _spell; - private SpellMenuPage _spellPage; + private SpellType _spell; + private SpellMenuPage _spellPage; - public SpellButton(SpellMenuPage spellPage, SpellType spell) - { - _spell = spell; - _spellPage = spellPage; - } + public SpellButton(SpellMenuPage spellPage, SpellType spell) + { + _spell = spell; + _spellPage = spellPage; + } - @Override - public void onClick(Player player, ClickType clickType) - { - Wizard wizard = _spellPage.getWizards().getWizard(player); + @Override + public void onClick(Player player, ClickType clickType) + { + Wizard wizard = _spellPage.getWizards().getWizard(player); - if (wizard != null) - { - wizard.setSpell(player.getInventory().getHeldItemSlot(), _spell); + if (player.getInventory().getHeldItemSlot() >= wizard.getWandsOwned()) + { + return; + } - player.sendMessage(C.cBlue + "Set spell on wand to " + _spell.getElement().getColor() + _spell.getSpellName()); + if (wizard != null) + { + if (clickType.isLeftClick()) + { + wizard.setSpell(player.getInventory().getHeldItemSlot(), _spell); - player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 1); + player.sendMessage(C.cBlue + "Spell on wand set to " + _spell.getElement().getColor() + _spell.getSpellName()); - _spellPage.getWizards().drawUtilTextBottom(player); - _spellPage.getWizards().changeWandsTitles(player); - } - } + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 1); + } + else + { + _spellPage.getWizards().castSpell(player, wizard, _spell, null); + } + + _spellPage.getWizards().drawUtilTextBottom(player); + _spellPage.getWizards().changeWandsTitles(player); + _spellPage.getWizards().changeWandsType(player, -1, player.getInventory().getHeldItemSlot()); + + player.closeInventory(); + } + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java index a623eb102..8e2a33cf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.wizards; import java.util.ArrayList; - import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; @@ -15,94 +14,113 @@ import org.bukkit.entity.Player; public class SpellMenuPage extends ShopPageBase { - private Wizards _wizard; + private Wizards _wizard; - public SpellMenuPage(WizardSpellMenu plugin, WizardSpellMenuShop shop, CoreClientManager clientManager, - DonationManager donationManager, Player player, Wizards wizard) - { - super(plugin, shop, clientManager, donationManager, "Spell Menu", player); - _wizard = wizard; - buildPage(); - } + public SpellMenuPage(WizardSpellMenu plugin, WizardSpellMenuShop shop, CoreClientManager clientManager, + DonationManager donationManager, Player player, Wizards wizard) + { + super(plugin, shop, clientManager, donationManager, "Spell Menu", player); + _wizard = wizard; + buildPage(); + } - @Override - protected void buildPage() - { - Wizard wizard = getWizards().getWizard(getPlayer()); + @Override + protected void buildPage() + { + Wizard wizard = getWizards().getWizard(getPlayer()); - ArrayList usedNumbers = new ArrayList(); + ArrayList usedNumbers = new ArrayList(); - for (SpellElement ele : SpellElement.values()) - { - addItem(ele.getSlot(), new ShopItem(ele.getIcon(), ele.name(), ele.name(), 1, true, true)); + for (SpellElement ele : SpellElement.values()) + { + addItem(ele.getSlot(), new ShopItem(ele.getIcon(), ele.name(), ele.name(), 1, true, true)); - for (int i = ele.getFirstSlot(); i <= ele.getSecondSlot(); i++) - { - usedNumbers.add(i); - } - } + for (int i = ele.getFirstSlot(); i <= ele.getSecondSlot(); i++) + { + usedNumbers.add(i); + } + } - for (int i = 0; i < 54; i++) - { - SpellType spell = null; - for (SpellType spells : SpellType.values()) - { - if (spells.getSlot() == i) - { - spell = spells; - break; - } - } + for (int i = 0; i < 54; i++) + { + SpellType spell = null; - if (usedNumbers.contains(i % 9) && spell != null) - { + for (SpellType spells : SpellType.values()) + { + if (spells.getSlot() == i) + { + spell = spells; + break; + } + } - int spellLevel = wizard == null ? 1 : wizard.getSpellLevel(spell); + if (usedNumbers.contains(i % 9) && spell != null) + { - if (spellLevel > 0) - { - ItemBuilder builder = new ItemBuilder(spell.getSpellItem()); - builder.setTitle(spell.getElement().getColor() + spell.getSpellName()); - builder.addLore(""); - builder.addLore(C.cBlue + C.Bold + "Spell Level: " + C.cWhite + spellLevel); - builder.addLore(C.cBlue + C.Bold + "Mana Cost: " + C.cWhite - + (wizard == null ? spell.getBaseManaCost() : spell.getManaCost(wizard))); - builder.addLore(C.cBlue + C.Bold + "Cooldown: " + C.cWhite - + (wizard == null ? spell.getBaseCooldown() : spell.getSpellCooldown(wizard)) + " seconds"); - builder.addLore(""); + int spellLevel = wizard == null ? 1 : wizard.getSpellLevel(spell); - for (String lore : spell.getDesc()) - { - builder.addLore(C.cGray + lore, 35); - } + if (spellLevel > 0) + { + ItemBuilder builder = new ItemBuilder(spell.getSpellItem()); - if (wizard == null) - { - addItem(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true)); - } - else - { - addButton(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true), new SpellButton( - this, spell)); - } - } - else - { - addItem(i, new ShopItem(new ItemBuilder(Material.INK_SACK, 1, (byte) 8).setTitle(C.cRed + C.Bold + "Unknown") - .build(), "Unknown", "Unknown", 1, true, true)); - } - } - else if (!usedNumbers.contains(i % 9)) - { - addItem(i, new ShopItem(new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (byte) 15).setTitle(C.cRed + "").build(), - "No Item", "No Item", 1, true, true)); - } - } - } + builder.setTitle(spell.getElement().getColor() + C.Bold + spell.getSpellName()); - public Wizards getWizards() - { - return _wizard; - } + builder.setAmount(spellLevel); + builder.addLore(""); + + if (wizard == null) + { + builder.addLore(C.cYellow + C.Bold + "Max Level: " + C.cWhite + spell.getMaxLevel()); + } + else + { + builder.addLore(C.cYellow + C.Bold + "Spell Level: " + C.cWhite + spellLevel); + } + + builder.addLore(C.cYellow + C.Bold + "Mana Cost: " + C.cWhite + + (wizard == null ? spell.getBaseManaCost() : spell.getManaCost(wizard))); + builder.addLore(C.cYellow + C.Bold + "Cooldown: " + C.cWhite + + (wizard == null ? spell.getBaseCooldown() : spell.getSpellCooldown(wizard)) + " seconds"); + builder.addLore(""); + + for (String lore : spell.getDesc()) + { + builder.addLore(C.cGray + lore, 40); + } + + if (wizard == null) + { + addItem(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true)); + } + else + { + builder.addLore(""); + + builder.addLore(C.cGreen + C.Bold + "Left-Click" + C.cWhite + " Bind to Wand"); + + builder.addLore(C.cGreen + C.Bold + "Right-Click" + C.cWhite + " Quickcast Spell"); + + addButton(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true), new SpellButton( + this, spell)); + } + } + else + { + addItem(i, new ShopItem(new ItemBuilder(Material.INK_SACK, 1, (byte) 6).setTitle(C.cRed + C.Bold + "Unknown") + .build(), "Unknown", "Unknown", 1, true, true)); + } + } + else if (!usedNumbers.contains(i % 9)) + { + addItem(i, new ShopItem(new ItemBuilder(Material.INK_SACK, 1, (byte) 9).setTitle(C.cRed + "").build(), "No Item", + "No Item", 1, true, true)); + } + } + } + + public Wizards getWizards() + { + return _wizard; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java index 9818bc2f1..9dbf0f330 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellType.java @@ -1,60 +1,25 @@ package nautilus.game.arcade.game.games.wizards; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; + import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; import mineplex.core.itemstack.ItemBuilder; -import nautilus.game.arcade.game.games.wizards.spells.SpellBridge; -import nautilus.game.arcade.game.games.wizards.spells.SpellDroom; -import nautilus.game.arcade.game.games.wizards.spells.SpellExplosiveRune; -import nautilus.game.arcade.game.games.wizards.spells.SpellFireball; -import nautilus.game.arcade.game.games.wizards.spells.SpellFlash; -import nautilus.game.arcade.game.games.wizards.spells.SpellHeal; -import nautilus.game.arcade.game.games.wizards.spells.SpellHealingRune; -import nautilus.game.arcade.game.games.wizards.spells.SpellImplode; -import nautilus.game.arcade.game.games.wizards.spells.SpellLance; -import nautilus.game.arcade.game.games.wizards.spells.SpellLaunch; -import nautilus.game.arcade.game.games.wizards.spells.SpellLaunchRune; -import nautilus.game.arcade.game.games.wizards.spells.SpellLightningStrike; -import nautilus.game.arcade.game.games.wizards.spells.SpellMagicMissile; -import nautilus.game.arcade.game.games.wizards.spells.SpellRainbowBeam; -import nautilus.game.arcade.game.games.wizards.spells.SpellRumble; -import nautilus.game.arcade.game.games.wizards.spells.SpellSpeedBoost; -import nautilus.game.arcade.game.games.wizards.spells.SpellSpiderman; -import nautilus.game.arcade.game.games.wizards.spells.SpellStoneWall; -import nautilus.game.arcade.game.games.wizards.spells.SpellSummonWolves; -import nautilus.game.arcade.game.games.wizards.spells.SpellTeleportRune; -import nautilus.game.arcade.game.games.wizards.spells.SpellTrapRune; -import nautilus.game.arcade.game.games.wizards.spells.SpellWizardsCompass; +import nautilus.game.arcade.game.games.wizards.spells.*; import org.bukkit.Material; -import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; public enum SpellType // ❤ { - - Bridge(SpellElement.MISC, // Spell element - "Bridge", // Spell name - new ItemStack(Material.FENCE), // Spell icon - SpellBridge.class, // Spell class - 3, // Spell max level - 50, // Mana cost - 20, // Spell cooldown - 0, // Mana cost change per level - -5, // Cooldown change per level - 3, // Item amount in loot - - C.cGold + C.Bold + "Length: " + C.Bold + C.cWhite + "Spell Level x 10", - - "", - - "Left click on the block before the chasm", - - "and a mighty dirt bridge will appear!"), - - Droom(SpellElement.ATTACK, // Spell element - "Droom", // Spell name - new ItemStack(Material.ANVIL), // Spell icon - SpellDroom.class, // Spell class + AnvilDrop(SpellElement.ATTACK, // Spell element + WandElement.EARTH, // Wand element + "Anvil Drop", // Spell name + new ItemStack(Material.NETHER_BRICK_ITEM), // Spell icon + SpellAnvilDrop.class, // Spell class 3, // Spell max level 40, // Mana cost 15, // Spell cooldown @@ -62,53 +27,18 @@ public enum SpellType // ❤ -4, // Cooldown change per level 10, // Item amount in loot - C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "(Spell Level / 2) + 1", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level x 2) + 3", "", - "Summons exploding anvils over everyone near you!"), + "Summons exploding anvils over everyone near you!", - /*Drain(SpellElement.MISC, // Spell element - "Drain", // Spell name - new ItemStack(Material.BUCKET), // Spell icon - SpellDrain.class, // Spell class - 3, // Spell max level - 30, // Mana cost - 20, // Spell cooldown - -3, // Mana cost change per level - -4, // Cooldown change per level - 3, // Item amount in loot - - "", - - "Right click other players with this spell", - - "to empty their mana reserves!", TODO Make this area based and drain completely of mana or a rune and drain passively. - - "You gain a third of the absorbed mana!"),*/ - - ExplosiveRune(SpellElement.RUNES, // Spell element - "Explosive Rune", // Spell name - new ItemStack(Material.FIREBALL), // Spell icon - SpellExplosiveRune.class, // Spell class - 3, // Spell max level - 60, // Mana cost - 30, // Spell cooldown - 0, // Mana cost change per level - 0, // Cooldown change per level - 5, // Item amount in loot - - C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "Spell Level", - - C.cGold + C.Bold + "Rune Size: " + C.Bold + C.cWhite + "Spell Level + 1", - - "", - - "Draws a rune that explodes after a delay!"), + "This also includes the caster!"), Fireball(SpellElement.ATTACK, // Spell element + WandElement.FIRE, // Wand element "Fireball", // Spell name - new ItemStack(Material.FIREBALL), // Spell icon + new ItemStack(Material.COAL), // Spell icon SpellFireball.class, // Spell class 3, // Spell max level 30, // Mana cost @@ -117,7 +47,7 @@ public enum SpellType // ❤ -2, // Cooldown change per level 10, // Item amount in loot - C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "(Spell Level x 0.25) + 0.8", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 3", "", @@ -126,25 +56,67 @@ public enum SpellType // ❤ "Summon a blazing fireball!"), Flash(SpellElement.SUPPORT, // Spell element + WandElement.LIFE, // Wand element "Flash", // Spell name - new ItemStack(Material.REDSTONE_TORCH_ON), // Spell icon + new ItemStack(Material.GOLD_NUGGET), // Spell icon SpellFlash.class, // Spell class 3, // Spell max level - 50, // Mana cost + 20, // Mana cost 50, // Spell cooldown 0, // Mana cost change per level -5, // Cooldown change per level 3, // Item amount in loot - C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 10) + 20", + C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 10) + 20", "", "Teleport to the block you are looking at!"), + FrostBarrier(SpellElement.MISC, // Spell element + WandElement.ICE, // Wand element + "Frost Barrier", // Spell name + new ItemStack(Material.CLAY_BALL), // Spell icon + SpellFrostBarrier.class, // Spell class + 3, // Spell max level + 10, // Mana cost + 20, // Spell cooldown + 0, // Mana cost change per level + -5, // Cooldown change per level + 3, // Item amount in loot + + C.cYellow + C.Bold + "Height: " + C.Bold + C.cWhite + "Spell Level + 1", + + C.cYellow + C.Bold + "Width: " + C.Bold + C.cWhite + "(Spell Level x 2) + 4", + + "", + + "Create a wall of ice!"), + + Gust(SpellElement.MISC, // Spell element + WandElement.AIR, // Wand element + "Gust", // Spell name + new ItemStack(Material.SULPHUR), // Spell icon + SpellGust.class, // Spell class + 3, // Spell max level + 15, // Mana cost + 20, // Spell cooldown + 0, // Mana cost change per level + 0, // Cooldown change per level + 5, // Item amount in loot + + C.cYellow + C.Bold + "Gust Size: " + C.Bold + C.cWhite + "10 x Spell Level blocks", + + C.cYellow + C.Bold + "Gust Strength: " + C.Bold + C.cWhite + "Spell Level x 30%", + + "", + + "Cast the spell and watch your enemies fly!"), + Heal(SpellElement.SUPPORT, // Spell element + WandElement.LIFE, // Wand element "Heal", // Spell name - new ItemStack(Material.POTION, 1, (short) 8261), // Spell icon + new ItemStack(Material.QUARTZ), // Spell icon SpellHeal.class, // Spell class 5, // Spell max level 50, // Mana cost @@ -153,7 +125,7 @@ public enum SpellType // ❤ -1, // Cooldown change per level 5, // Item amount in loot - C.cGold + C.Bold + "Heals: " + C.Bold + C.cWhite + "(Spell Level / 2) + 1.5", + C.cYellow + C.Bold + "Heals: " + C.Bold + C.cWhite + "(Spell Level / 2) + 1.5", "", @@ -161,30 +133,56 @@ public enum SpellType // ❤ "Use this! Heal yourself up!"), - HealingRune(SpellElement.RUNES, // Spell element - "Rune of Healing", // Spell name - new ItemStack(Material.POTION, 1, (short) 8197), // Spell icon - SpellHealingRune.class, // Spell class + IcePrison(SpellElement.MISC, // Spell element + WandElement.ICE, // Wand element + "Ice Prison", // Spell name + new ItemStack(Material.EYE_OF_ENDER), // Spell icon + SpellIcePrison.class, // Spell class 3, // Spell max level - 60, // Mana cost - 30, // Spell cooldown - 0, // Mana cost change per level - -5, // Cooldown change per level + 25, // Mana cost + 20, // Spell cooldown + 2, // Mana cost change per level + 0, // Cooldown change per level 3, // Item amount in loot - C.cGold + C.Bold + "Size: " + C.Bold + C.cWhite + "(Spell Level x 0.5) + 2", - - C.cGold + C.Bold + "Lasts for: " + C.Bold + C.cWhite + "(Spell Level x 3) + 5 seconds", + C.cYellow + C.Bold + "Size: " + C.Bold + C.cWhite + "Spell Level + 3", "", - "Draws a rune of healing players can step inside", + "On impact creates a mighty ice", - "to recover their health."), + "prison to capture thy enemies!"), + + IceShards(SpellElement.ATTACK, // Spell element + WandElement.ICE, // Wand element + "Ice Shards", // Spell name + new ItemStack(Material.GOLDEN_CARROT), // Spell icon + SpellIceShards.class, // Spell class + 5, // Spell max level + 30, // Mana cost + 20, // Spell cooldown + 0, // Mana cost change per level + -2, // Cooldown change per level + 3, // Item amount in loot + + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "2", + + C.cYellow + C.Bold + "Shards: " + C.Bold + C.cWhite + "Spell Level + 1", + + "", + + "Overwhelm your opponent with shards!", + + "Each shard is fired half a second after", + + "the last allowing you to pummel your", + + "enemies senseless!"), Implode(SpellElement.MISC, // Spell element + WandElement.EARTH, // Wand element "Implode", // Spell name - new ItemStack(Material.TNT), // Spell icon + new ItemStack(Material.GLOWSTONE_DUST), // Spell icon SpellImplode.class, // Spell class 3, // Spell max level 50, // Mana cost @@ -193,11 +191,11 @@ public enum SpellType // ❤ -3, // Cooldown change per level 3, // Item amount in loot - C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "50", + C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "50", - C.cGold + C.Bold + "Implosion Height: " + C.Bold + C.cWhite + "Spell Level", + C.cYellow + C.Bold + "Implosion Height: " + C.Bold + C.cWhite + "Spell Level", - C.cGold + C.Bold + "Implosion Width: " + C.Bold + C.cWhite + "Spell Level x 2", + C.cYellow + C.Bold + "Implosion Width: " + C.Bold + C.cWhite + "Spell Level x 2", "", @@ -205,70 +203,10 @@ public enum SpellType // ❤ "and scatters them about the area"), - Lance(SpellElement.ATTACK, // Spell element - "Lance", // Spell name - new ItemStack(Material.STICK), // Spell icon - SpellLance.class, // Spell class - 3, // Spell max level - 75, // Mana cost - 50, // Spell cooldown - 0, // Mana cost change per level - -10, // Cooldown change per level - 10, // Item amount in loot - - C.cGold + C.Bold + "Lance Size: " + C.Bold + C.cWhite + "Spell Level x 6", - - "", - - "Summon an lance of explosions!"), - - Launch(SpellElement.MISC, // Spell element - "Launch", // Spell name - new ItemStack(Material.FEATHER), // Spell icon - SpellLaunch.class, // Spell class - 3, // Spell max level - 60, // Mana cost - 20, // Spell cooldown - 0, // Mana cost change per level - 0, // Cooldown change per level - 5, // Item amount in loot - - C.cGold + C.Bold + "Launch Height: " + C.Bold + C.cWhite + "(Spell Level x 3) + 5 blocks", - - "", - - "Cast the spell by hitting the victim", - - "and they will be sent flying into the air!"), - - LaunchRune(SpellElement.RUNES, // Spell element - "Launch Rune", // Spell name - new ItemStack(Material.FEATHER), // Spell icon - SpellLaunchRune.class, // Spell class - 3, // Spell max level - 60, // Mana cost - 30, // Spell cooldown - 0, // Mana cost change per level - 0, // Cooldown change per level - 5, // Item amount in loot - - C.cGold + C.Bold + "Launch Height: " + C.Bold + C.cWhite + "(Spell Level x 2) + 5 blocks", - - C.cGold + C.Bold + "Rune Size: " + C.Bold + C.cWhite + "Spell Level x 0.8", - - "", - - "Draws a white rune on the ground", - - "Rune lasts for a minute and will", - - "activate when stepped on to launch", - - "the people into the air"), - LightningStrike(SpellElement.ATTACK, // Spell element + WandElement.AIR, // Wand element "Lightning Strike", // Spell name - new ItemStack(Material.WOOD_AXE), // Spell icon + new ItemStack(Material.INK_SACK, 1, (short) 12), // Spell icon SpellLightningStrike.class, // Spell class 3, // Spell max level 50, // Mana cost @@ -277,16 +215,21 @@ public enum SpellType // ❤ 0, // Cooldown change per level 10, // Item amount in loot + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level x 2) + 2", + "", "Summon a mighty lightning strike", - - "to hit the target you point out!"), - MagicMissile(SpellElement.ATTACK, // Spell element - "Magic Missile", // Spell name - new ItemStack(Material.STICK), // Spell icon - SpellMagicMissile.class, // Spell class + "to hit the target you point out!", + + "The lightning also contains fire!"), + + ManaBolt(SpellElement.ATTACK, // Spell element + WandElement.AIR, // Wand element + "Mana Bolt", // Spell name + new ItemStack(Material.MELON_SEEDS), // Spell icon + SpellManaBolt.class, // Spell class 3, // Spell max level 15, // Mana cost 5, // Spell cooldown @@ -294,19 +237,41 @@ public enum SpellType // ❤ 0, // Cooldown change per level 15, // Item amount in loot - C.cGold + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level / 2) + 2", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 2", - C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 15", + C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 10) + 20", "", - "The basic spell all beginner mages are taught.", + "Basic spell all beginner mages are taught," + " this creates a mana missile commonly attributed towards " + + "the magic profession and homes in towards the closest target!"), - "This creates a magic missile that is commonly attributed to the magic profession."), + Napalm(SpellElement.ATTACK, // Spell element + WandElement.FIRE, // Wand element + "Napalm", // Spell name + new ItemStack(Material.CARROT_STICK), // Spell icon + SpellNapalm.class, // Spell class + 5, // Spell max level + 60, // Mana cost + 60, // Spell cooldown + 5, // Mana cost change per level + -10, // Cooldown change per level + 1, // Item amount in loot + + C.cYellow + C.Bold + "Length: " + C.Bold + C.cWhite + "(Spell Level x 10) + 5", + + "", + + "Creates a ball of fire that grows", + + "the longer it lives. At an large size", + + "it even burns away nearby blocks!"), RainbowBeam(SpellElement.ATTACK, // Spell element + WandElement.FIRE, // Wand element "Rainbow Beam", // Spell name - new ItemStack(Material.EMERALD), // Spell icon + new ItemStack(Material.INK_SACK, 1, (short) 10), // Spell icon SpellRainbowBeam.class, // Spell class 5, // Spell max level 5, // Mana cost @@ -315,99 +280,117 @@ public enum SpellType // ❤ 1, // Cooldown change per level 10, // Item amount in loot - C.cGold + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 3", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 2", - C.cGold + C.Bold + "Ramge: " + C.Bold + C.cWhite + "Spell Level x 20", + C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "80", "", - "Magical girl beam of rainbows!", + "Firing rainbow beams of love and hope!", - "This may not do much damage,", + "This spell damages the target instantly!", - "but it sure is pretty!"), + "The thing is, to make this fit in with our", - Rumble(SpellElement.ATTACK, // Spell element - "Rumble", // Spell name - new ItemStack(Material.DIRT), // Spell icon - SpellRumble.class, // Spell class - 5, // Spell max level - 30, // Mana cost - 5, // Spell cooldown - 0, // Mana cost change per level - 0, // Cooldown change per level - 10, // Item amount in loot + "budget the damage will decrease after", - C.cGold + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 2", + "30 blocks by 0.2 damage per block!"), - C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 10", - - "", - - "Creates an targeted earthquake", - - "in the direction you point", - - "from the block you left click!"), - - SpeedBoost(SpellElement.SUPPORT, // Spell element - "Speed Boost", // Spell name - new ItemStack(Material.FEATHER), // Spell icon - SpellSpeedBoost.class, // Spell class - 2, // Spell max level - 20, // Mana cost - 100, // Spell cooldown + RainbowRoad(SpellElement.MISC, // Spell element + WandElement.AIR, // Wand element + "Rainbow Road", // Spell name + new ItemStack(Material.SADDLE), // Spell icon + SpellRainbowRoad.class, // Spell class + 3, // Spell max level + 10, // Mana cost + 20, // Spell cooldown 0, // Mana cost change per level 0, // Cooldown change per level 3, // Item amount in loot - C.cGold + C.Bold + "Length: " + C.Bold + C.cWhite + "Spell Level x 30", + C.cYellow + C.Bold + "Length: " + C.Bold + C.cWhite + "Spell Level x 10", - C.cGold + C.Bold + "Strength: " + C.Bold + C.cWhite + "Spell Level", + "", + + "Summon into being a mighty road", + + "of rainbows for thee to walk on!"), + + Rumble(SpellElement.ATTACK, // Spell element + WandElement.EARTH, // Wand element + "Rumble", // Spell name + new ItemStack(Material.PUMPKIN_SEEDS), // Spell icon + SpellRumble.class, // Spell class + 5, // Spell max level + 30, // Mana cost + 15, // Spell cooldown + 0, // Mana cost change per level + -1, // Cooldown change per level + 10, // Item amount in loot + + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level + 2", + + C.cYellow + C.Bold + "Explosion Damage: " + C.Bold + C.cWhite + "Spell Level / 4", + + C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 10", + + C.cYellow + C.Bold + "Slowness Level: " + C.Bold + C.cWhite + "Spell Level", + + "", + + "Creates a targeted earthquake", + + "in the direction you face!", + + "Explodes with damage at the end!", + + "Effected players lose their footing!"), + + SpectralArrow(SpellElement.ATTACK, // Spell element + WandElement.DEATH, // Wand element + "Spectral Arrow", // Spell name + new ItemBuilder(Material.INK_SACK, 1, (short) 13).addEnchantment(UtilInv.getDullEnchantment(), 1).build(), // Spell + // icon + SpellSpectralArrow.class, // Spell class + 3, // Spell max level + 40, // Mana cost + 15, // Spell cooldown + -5, // Mana cost change per level + -2, // Cooldown change per level + 3, // Item amount in loot + + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Blocks / (7 - Spell Level)) + 3", + + "", + + "Shoot an arrow that penetrates!", + + "Further the distance, higher the damage!"), + + SpeedBoost(SpellElement.SUPPORT, // Spell element + WandElement.LIFE, // Wand element + "Speed Boost", // Spell name + new ItemStack(Material.INK_SACK, 1, (short) 2), // Spell icon + SpellSpeedBoost.class, // Spell class + 2, // Spell max level + 20, // Mana cost + 40, // Spell cooldown + 0, // Mana cost change per level + 0, // Cooldown change per level + 3, // Item amount in loot + + C.cYellow + C.Bold + "Length: " + C.Bold + C.cWhite + "20 seconds", + + C.cYellow + C.Bold + "Strength: " + C.Bold + C.cWhite + "Spell Level + 1", "", "Gain a speed potion effect to outrun your enemies"), - Spiderman(SpellElement.MISC, // Spell element - "Spiderman", // Spell name - new ItemStack(Material.WEB), // Spell icon - SpellSpiderman.class, // Spell class - 3, // Spell max level - 40, // Mana cost - 20, // Spell cooldown - -5, // Mana cost change per level - -5, // Cooldown change per level - 3, // Item amount in loot - - C.cGold + C.Bold + "Webs: " + C.Bold + C.cWhite + "Spell Level x 2", - - "", - - "Shoot webs just like your favorite hero!"), - - StoneWall(SpellElement.MISC, // Spell element - "Stone Wall", // Spell name - new ItemStack(Material.STONE), // Spell icon - SpellStoneWall.class, // Spell class - 3, // Spell max level - 60, // Mana cost - 30, // Spell cooldown - 0, // Mana cost change per level - -5, // Cooldown change per level - 3, // Item amount in loot - - C.cGold + C.Bold + "Height: " + C.Bold + C.cWhite + "Spell Level + 1", - - C.cGold + C.Bold + "Width: " + C.Bold + C.cWhite + "Spell Level x 5", - - "", - - "Create a wall of stone!"), - - SummonWolves(SpellElement.ATTACK, // Spell element + SummonWolves(SpellElement.MISC, // Spell element + WandElement.LIFE, // Wand element "Summon Wolves", // Spell name - new ItemStack(Material.MONSTER_EGG, 1, EntityType.WOLF.getTypeId()), // Spell icon + new ItemStack(Material.MILK_BUCKET), // Spell icon SpellSummonWolves.class, // Spell class 3, // Spell max level 80, // Mana cost @@ -416,7 +399,7 @@ public enum SpellType // ❤ 0, // Cooldown change per level 8, // Item amount in loot - C.cGold + C.Bold + "Wolves: " + C.Bold + C.cWhite + "Spell Level + 2", + C.cYellow + C.Bold + "Wolves: " + C.Bold + C.cWhite + "Spell Level + 2", "", @@ -424,47 +407,23 @@ public enum SpellType // ❤ "They will fight for you and after 30 seconds, will disappear"), - TeleportRune(SpellElement.RUNES, // Spell element - "Teleport Rune", // Spell name - new ItemStack(Material.ENDER_PEARL), // Spell icon - SpellTeleportRune.class, // Spell class - 3, // Spell max level - 70, // Mana cost - 40, // Spell cooldown - -5, // Mana cost change per level - -5, // Cooldown change per level - 4, // Item amount in loot - - C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 25", - - C.cGold + C.Bold + "Size: " + C.Bold + C.cWhite + "Spell Level x 1.5", - - "", - - "This draws a teleport rune on the ground", - - "The created rune is usable by anyone and lasts", - - "for 5 seconds after the 2 second warmup period.", - - "The teleport is one way, you cannot return."), - - TrapRune(SpellElement.RUNES, // Spell element + TrapRune(SpellElement.MISC, // Spell element + WandElement.DEATH, // Wand element "Trap Rune", // Spell name - new ItemStack(Material.TRAP_DOOR), // Spell icon + new ItemStack(Material.SHEARS), // Spell icon SpellTrapRune.class, // Spell class 3, // Spell max level - 50, // Mana cost + 25, // Mana cost 30, // Spell cooldown 0, // Mana cost change per level -5, // Cooldown change per level 3, // Item amount in loot - C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 4) + 12", + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level x 2) + 3", - C.cGold + C.Bold + "Rune Size: " + C.Bold + C.cWhite + "Spell Level", + C.cYellow + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 4) + 12", - C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "Spell Level", + C.cYellow + C.Bold + "Rune Size: " + C.Bold + C.cWhite + "Spell Level", "", @@ -472,9 +431,30 @@ public enum SpellType // ❤ "The rune takes 5 seconds to prepare and will damage even you!"), + WebShot(SpellElement.MISC, // Spell element + WandElement.DEATH, // Wand element + "Web Shot", // Spell name + new ItemStack(Material.SPIDER_EYE), // Spell icon + SpellWebShot.class, // Spell class + 3, // Spell max level + 40, // Mana cost + 20, // Spell cooldown + -5, // Mana cost change per level + 0, // Cooldown change per level + 3, // Item amount in loot + + C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "1 heart", + + C.cYellow + C.Bold + "Webs: " + C.Bold + C.cWhite + "Spell Level x 2", + + "", + + "Shoot webs just like your favorite hero!"), + WizardsCompass(SpellElement.MISC, // Spell element + WandElement.LIFE, // Wand element "Wizard's Compass", // Spell name - new ItemStack(Material.COMPASS), // Spell icon + new ItemStack(Material.SUGAR), // Spell icon SpellWizardsCompass.class, // Spell class 1, // Spell max level 5, // Mana cost @@ -489,19 +469,16 @@ public enum SpellType // ❤ public enum SpellElement { - ATTACK(0, 0, 1, new ItemBuilder(Material.IRON_SWORD).setTitle(C.cRed + "Attack Spells") + ATTACK(1, 0, 2, new ItemBuilder(Material.INK_SACK, 1, (short) 7).setTitle(C.cRed + "Attack Spells") .addLore(C.cGray + "Spells of destruction").build(), C.cRed), - MISC(7, 7, 8, new ItemBuilder(Material.COAL_BLOCK).setTitle(C.cDGray + "Misc Spells").addLore( + MISC(7, 6, 8, new ItemBuilder(Material.INK_SACK, 1, (short) 11).setTitle(C.cDGray + "Misc Spells").addLore( C.cGray + "Misc spells that don't fit in", "These spells generally effect the world itself").build(), C.cGray), - RUNES(3, 3, 3, new ItemBuilder(Material.NETHER_STAR).setTitle(C.cGold + "Rune Spells") - .addLore(C.cGray + "Spells for creation of runes").build(), C.cGold), - - SUPPORT(5, 5, 5, new ItemBuilder(Material.IRON_BOOTS).setTitle(C.cDGreen + "Support Spells") + SUPPORT(4, 4, 4, new ItemBuilder(Material.INK_SACK, 1, (short) 14).setTitle(C.cDGreen + "Support Spells") .addLore(C.cGray + "Spells of assistance").build(), C.cDGreen); private String _chatColor; @@ -551,13 +528,59 @@ public enum SpellType // ❤ } } + public enum WandElement + { + AIR(Material.IRON_HOE), + + DEATH(Material.STICK), + + EARTH(Material.STONE_HOE), + + FIRE(Material.GOLD_HOE), + + ICE(Material.DIAMOND_HOE), + + LIFE(Material.WOOD_HOE); + + private Material _material; + + private WandElement(Material material) + { + _material = material; + } + + public Material getMaterial() + { + return _material; + } + } + static { - for (SpellType spell : values()) - { - spell._slot = 9 + spell.getElement().getFirstSlot(); + ArrayList spells = new ArrayList(Arrays.asList(SpellType.values())); - for (SpellType spell2 : values()) + Collections.sort(spells, new Comparator() + { + + @Override + public int compare(SpellType o1, SpellType o2) + { + int number = new Integer(o2.getItemAmount()).compareTo(o1.getItemAmount()); + + if (number == 0) + { + return o1.getSpellName().compareToIgnoreCase(o2.getSpellName()); + } + + return number; + } + }); + + for (SpellType spell : spells) + { + spell._slot = 18 + spell.getElement().getFirstSlot(); + + for (SpellType spell2 : spells) { if (spell != spell2 && spell.getElement() == spell2.getElement() && spell._slot <= spell2._slot) { @@ -610,10 +633,13 @@ public enum SpellType // ❤ private int _spellCost; private String _spellName; private SpellElement _type; + private WandElement _wandElement; - private SpellType(SpellElement type, String spellName, ItemStack spellItem, Class spell, int maxLevel, - int spellCost, int spellCooldown, int manaChangePerLevel, int cooldownChangePerLevel, int itemAmount, String... desc) + private SpellType(SpellElement type, WandElement wandElement, String spellName, ItemStack spellItem, + Class spell, int maxLevel, int spellCost, int spellCooldown, int manaChangePerLevel, + int cooldownChangePerLevel, int itemAmount, String... desc) { + _wandElement = wandElement; _maxLevel = maxLevel; _item = spellItem; _desc = desc; @@ -627,6 +653,16 @@ public enum SpellType // ❤ _itemAmount = itemAmount; } + public int getBaseCooldown() + { + return _spellCooldown; + } + + public int getBaseManaCost() + { + return _spellCost; + } + public String[] getDesc() { return _desc; @@ -642,16 +678,6 @@ public enum SpellType // ❤ return _itemAmount; } - public int getBaseManaCost() - { - return _spellCost; - } - - public int getBaseCooldown() - { - return _spellCooldown; - } - public int getManaCost(Wizard wizard) { return Math.max(0, @@ -677,7 +703,11 @@ public enum SpellType // ❤ public ItemStack getSpellBook(Wizards wizards) { - return makeSpell(wizards, new ItemBuilder(Material.ENCHANTED_BOOK).addLore(C.cAqua + "Click to level up this spell") + return makeSpell(wizards, + + new ItemBuilder(_item) + + .addLore(C.cAqua + "Click to level up this spell") .build()); } @@ -710,10 +740,17 @@ public enum SpellType // ❤ return _spellName; } + public WandElement getWandType() + { + return _wandElement; + } + public ItemStack makeSpell(Wizards wizards, ItemStack item) { ItemBuilder builder = new ItemBuilder(item); + builder.setTitle(C.cDBlue + C.Bold + "Spell: " + _type._chatColor + getSpellName() + wizards.buildTime()); + return builder.build(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizard.java index 3cae1c5c6..735b4d4e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizard.java @@ -1,106 +1,141 @@ package nautilus.game.arcade.game.games.wizards; +import java.util.Set; + import mineplex.core.common.util.NautHashMap; public class Wizard { - private NautHashMap _cooldowns = new NautHashMap(); - private NautHashMap _knownSpells = new NautHashMap(); - private SpellType[] _assignedWands = new SpellType[5]; - private float _mana; - private float _manaPerTick = 2.5F / 20F; - private float _maxMana; - private int _soulStars; - private float _cooldownModifier = 1; + private NautHashMap _cooldowns = new NautHashMap(); + private NautHashMap _knownSpells = new NautHashMap(); + private SpellType[] _assignedWands = new SpellType[5]; + private float _mana; + private float _manaPerTick = 2.5F / 20F; + private float _maxMana; + private int _soulStars; + private float _cooldownModifier = 1; + private int _wandsOwned; - public float getCooldownModifier() - { - return _cooldownModifier; - } + public void setWandsOwned(int wandsOwned) + { + _wandsOwned = wandsOwned; + } - public void decreaseCooldown() - { - _cooldownModifier -= 0.1; - } + public int getWandsOwned() + { + return _wandsOwned; + } - public void addSoulStar() - { - _soulStars++; - } + public float getCooldownModifier() + { + return _cooldownModifier; + } - public Wizard(float maxMana) - { - learnSpell(SpellType.MagicMissile); - learnSpell(SpellType.WizardsCompass); - _maxMana = maxMana; - } + public void decreaseCooldown() + { + _cooldownModifier -= 0.1; + } - public SpellType getSpell(int slot) - { - return _assignedWands[slot]; - } + public void addSoulStar() + { + _soulStars++; + } - public void setSpell(int slot, SpellType spell) - { - _assignedWands[slot] = spell; - } + public Wizard(float maxMana) + { + learnSpell(SpellType.ManaBolt); + learnSpell(SpellType.WizardsCompass); - public long getCooldown(SpellType type) - { - if (_cooldowns.containsKey(type) && _cooldowns.get(type) >= System.currentTimeMillis()) - { - return _cooldowns.get(type); - } + _maxMana = maxMana; + } - return 0; - } + public SpellType getSpell(int slot) + { + return _assignedWands[slot]; + } - public float getMana() - { - return _mana; - } + public void setSpell(int slot, SpellType spell) + { + _assignedWands[slot] = spell; + } - public float getManaPerTick() - { - return _manaPerTick + ((_soulStars * 0.1F) / 20); - } + public long getCooldown(SpellType type) + { + if (_cooldowns.containsKey(type) && _cooldowns.get(type) >= System.currentTimeMillis()) + { + return _cooldowns.get(type); + } - public float getMaxMana() - { - return _maxMana; - } + return 0; + } - public int getSpellLevel(SpellType type) - { - if (_knownSpells.containsKey(type)) - { - return _knownSpells.get(type); - } - return 0; - } + public float getMana() + { + return _mana; + } - public void learnSpell(SpellType type) - { - _knownSpells.put(type, getSpellLevel(type) + 1); - } + public float getManaPerTick() + { + return _manaPerTick + ((_soulStars * 0.2F) / 20); + } - public void setMana(float newMana) - { - _mana = newMana; - } + public float getMaxMana() + { + return _maxMana; + } - public void setUsedSpell(SpellType spell) - { - int cooldown = spell.getSpellCooldown(this); - if (cooldown > 0) - { - _cooldowns.put(spell, System.currentTimeMillis() + (1000L * cooldown)); - } - } + public int getSpellLevel(SpellType type) + { + if (_knownSpells.containsKey(type)) + { + return _knownSpells.get(type); + } + return 0; + } - public void setManaPerTick(float manaPerTick) - { - _manaPerTick = manaPerTick; - } + public void learnSpell(SpellType type) + { + _knownSpells.put(type, getSpellLevel(type) + 1); + } + + public void addMana(float newMana) + { + _mana += newMana; + + if (_mana > _maxMana) + { + _mana = _maxMana; + } + } + + public void setMana(float newMana) + { + _mana = newMana; + } + + public void setUsedSpell(SpellType spell) + { + int cooldown = spell.getSpellCooldown(this); + + if (cooldown > 0) + { + _cooldowns.put(spell, System.currentTimeMillis() + (1000L * cooldown)); + } + } + + public NautHashMap getCooldowns() + { + return _cooldowns; + } + + public void setManaPerTick(float manaPerTick) + { + _manaPerTick = manaPerTick; + } + + public Set getKnownSpells() + { + return _knownSpells.keySet(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java index 9ba3d42ec..b63acd54c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java @@ -20,93 +20,89 @@ import org.bukkit.plugin.java.JavaPlugin; public class WizardSpellMenu extends MiniPlugin { - private Wizards _wizards; - private WizardSpellMenuShop _wizardShop; - private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells") - .addLore(C.cGray + "Right click with this to view the spells").build(); + private Wizards _wizards; + private WizardSpellMenuShop _wizardShop; + private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells") + .addLore(C.cGray + "Right click with this to view the spells").build(); - public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards) - { - super("Wizard Spell Menu", plugin); - _wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager() - .GetDonation(), wizards); - _wizards = wizards; - } + public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards) + { + super("Wizard Spell Menu", plugin); + _wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager() + .GetDonation(), wizards); + _wizards = wizards; + } - @EventHandler - public void onJoin(PlayerJoinEvent event) - { + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_wizards.GetState() == GameState.Recruit || _wizards.GetState() == GameState.Live) + { + event.getPlayer().getInventory().setItem(0, _wizardSpells); + } + } - if (_wizards.GetState() == GameState.Recruit || _wizards.GetState() == GameState.Live) - { - event.getPlayer().getInventory().addItem(_wizardSpells); - } - } + @EventHandler + public void onDeath(final PlayerDeathEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + if (_wizards.IsLive()) + { + event.getEntity().getInventory().setItem(0, _wizardSpells); + } + } + }); + } - @EventHandler - public void onDeath(final PlayerDeathEvent event) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() - { - public void run() - { - if (_wizards.IsLive()) - { - event.getEntity().getInventory().addItem(_wizardSpells); - } - } - }); - } + @EventHandler + public void onJoin(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Recruit) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + player.getInventory().setItem(0, _wizardSpells); + } + } + } - @EventHandler - public void onJoin(GameStateChangeEvent event) - { + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.PHYSICAL && event.getAction().name().contains("RIGHT") + && (!_wizards.IsLive() || !_wizards.IsAlive(event.getPlayer()))) + { - if (event.GetState() == GameState.Recruit) - { - for (Player player : Bukkit.getOnlinePlayers()) - { - player.getInventory().addItem(_wizardSpells); - } - } - } + ItemStack item = event.getItem(); - @EventHandler - public void onInteract(PlayerInteractEvent event) - { - if (event.getAction() != Action.PHYSICAL && (!_wizards.IsLive() || !_wizards.IsAlive(event.getPlayer()))) - { + if (item != null && item.isSimilar(_wizardSpells)) + { - ItemStack item = event.getItem(); + _wizardShop.attemptShopOpen(event.getPlayer()); + } + } - if (item != null && item.isSimilar(_wizardSpells)) - { + if (_wizards.IsLive() && _wizards.IsAlive(event.getPlayer())) + { + Player p = event.getPlayer(); - _wizardShop.attemptShopOpen(event.getPlayer()); - } - } - - if (_wizards.IsLive() && _wizards.IsAlive(event.getPlayer())) - { - - ItemStack item = event.getItem(); - if (item != null && item.getType() == Material.BLAZE_ROD) - { - - Player p = event.getPlayer(); - - if (event.getAction().name().contains("RIGHT")) - { - if (p.getInventory().getHeldItemSlot() < 5) - { - if (event.getClickedBlock() == null || !(event.getClickedBlock().getState() instanceof InventoryHolder)) - { - _wizardShop.attemptShopOpen(p); - } - } - } - } - } - } + if (p.getInventory().getHeldItemSlot() < _wizards.getWizard(p).getWandsOwned()) + { + if (event.getAction().name().contains("RIGHT")) + { + if (p.getInventory().getHeldItemSlot() < 5) + { + if (event.getClickedBlock() == null || !(event.getClickedBlock().getState() instanceof InventoryHolder)) + { + _wizardShop.attemptShopOpen(p); + } + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java index 41d677de8..4c7cb0154 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenuShop.java @@ -10,26 +10,26 @@ import org.bukkit.entity.Player; public class WizardSpellMenuShop extends ShopBase { - private Wizards _wizards; + private Wizards _wizards; - public WizardSpellMenuShop(WizardSpellMenu plugin, CoreClientManager clientManager, DonationManager donationManager, - Wizards wizard, CurrencyType... currencyTypes) - { - super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); - _wizards = wizard; - } + public WizardSpellMenuShop(WizardSpellMenu plugin, CoreClientManager clientManager, DonationManager donationManager, + Wizards wizard, CurrencyType... currencyTypes) + { + super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); + _wizards = wizard; + } - @Override - protected ShopPageBase> buildPagesFor(Player player) - { - return new SpellMenuPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _wizards); - } + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new SpellMenuPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _wizards); + } - public void update() - { - for (ShopPageBase> shopPage : getPlayerPageMap().values()) - { - shopPage.refresh(); - } - } + public void update() + { + for (ShopPageBase> shopPage : getPlayerPageMap().values()) + { + shopPage.refresh(); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index 9e3ee69af..5984c0601 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -1,18 +1,22 @@ package nautilus.game.arcade.game.games.wizards; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; import java.util.Random; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -20,13 +24,15 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilWorld; import mineplex.core.hologram.Hologram; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.loot.ChestLoot; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatManager.AttackReason; @@ -45,6 +51,8 @@ import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; import nautilus.game.arcade.kit.Kit; import net.minecraft.server.v1_7_R4.EntityFireball; +import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot; +import net.minecraft.server.v1_7_R4.PacketPlayOutWindowItems; import org.apache.commons.lang.IllegalClassException; import org.bukkit.Bukkit; @@ -58,6 +66,7 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFireball; +import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Fireball; @@ -68,6 +77,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.ItemSpawnEvent; @@ -84,6 +94,7 @@ import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; @@ -96,1435 +107,1917 @@ import org.bukkit.util.Vector; public class Wizards extends SoloGame { - private NautHashMap> _learnedSpellChests = new NautHashMap>(); - /** - * The entry is so I can randomize the amounts of the items found - */ - private ArrayList> _randomItems = new ArrayList>(); - private NautHashMap _spells = new NautHashMap(); - private NautHashMap _timeSinceDisplayedMiddle = new NautHashMap(); - private WizardSpellMenu _wizard; - private ArrayList _droppedWandsBooks = new ArrayList(); - private NautHashMap _wizards = new NautHashMap(); - private float _fireballSize = 1.5F; - private int _fireballCounter; - private float _fireballAdd = 0.05F; - private float _fireballsToSpawn; - - public Wizards(ArcadeManager manager) - { - super(manager, GameType.Wizards, new Kit[0], new String[] - { - - "Find loot and spells in chests", - - "Right click wands to assign spells", - - "Left click with wands to cast magic", - - "The last wizard alive wins!" - - }); - - setKits(new Kit[] - { - new KitMage(manager), - - new KitSorcerer(manager), - - new KitMystic(manager), - - new KitWitchDoctor(manager), - - // new KitWarlock(manager) - }); - - _wizard = new WizardSpellMenu("Wizard Spell Menu", getArcadeManager().getPlugin(), this); - - BlockBreak = true; - BlockPlace = true; - ItemPickup = true; - ItemDrop = true; - InventoryOpenBlock = true; - InventoryOpenChest = true; - InventoryClick = true; - WorldBlockBurn = true; - DisableKillCommand = false; - SoupEnabled = false; - DamageTeamSelf = true; - - Manager.getCosmeticManager().setHideParticles(true); - Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.DefaultWeaponName); - - createLoot(); - } - - @EventHandler - public void joinMessage(PlayerJoinEvent event) - { - if (!UtilPlayer.is1_8(event.getPlayer())) - returnToHub(event.getPlayer()); - } - - public void returnToHub(Player player) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cGold + C.Bold + "Wizards requires you to be using Minecraft 1.8!"); - UtilPlayer.message(player, " "); - - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); - Manager.GetPortal().sendPlayerToServer(player, "Lobby"); - } - - @EventHandler - public void outdatedVersion(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Player player : UtilServer.getPlayers()) - { - if (!UtilPlayer.is1_8(player)) - returnToHub(player); - } - } - - private void addMiddleText(Player p, String message) - { - ArrayList arraylist = new ArrayList(); - - if (_learnedSpellChests.containsKey(p.getName())) - { - arraylist = _learnedSpellChests.get(p.getName()); - } - else - { - _learnedSpellChests.put(p.getName(), arraylist); - } - - arraylist.add(message); - } - - private void addRandomItem(int amount, Material itemType, int newDurability, int minAmount, int maxAmount) - { - HashMap.SimpleEntry entry = new HashMap.SimpleEntry(new ItemStack(itemType, minAmount, (short) newDurability), maxAmount - - minAmount); - - for (int i = 0; i < amount; i++) - { - _randomItems.add(entry); - } - } - - public String buildTime() - { - String s = ""; - - for (char c : ("" + System.nanoTime()).toCharArray()) - { - s += "§" + c; - } - - return s; - } - - public void changeWandsTitles(Player player) - { - PlayerInventory inv = player.getInventory(); - Wizard wizard = getWizard(player); - - for (int slot = 0; slot < 5; slot++) - { - ItemStack item = inv.getItem(slot); - SpellType type = wizard.getSpell(slot); - - if (item != null && item.getType() == Material.BLAZE_ROD) - { - ItemMeta meta = item.getItemMeta(); - String display; - - if (type != null) - { - display = C.cYellow + "Mana " + ChatColor.RESET + type.getManaCost(wizard) - - + " " + - - C.cYellow + "Cooldown " + ChatColor.RESET - - + UtilTime.convertString((long) (type.getSpellCooldown(wizard) * 1000), 1, TimeUnit.FIT); - } - else - { - display = C.cWhite + "Right click to set a spell"; - } - - if (!meta.hasDisplayName() || !meta.getDisplayName().equals(display)) - { - meta.setDisplayName(display); - item.setItemMeta(meta); - } - } - } - } - - private void CreateChestCraftEnchant() - { - ArrayList chests = WorldData.GetCustomLocs("54"); - - System.out.println("Map Chest Locations: " + chests.size()); - - int spawn = 0; - Location spawnPoint = UtilWorld.averageLocation(GetTeamList().get(0).GetSpawns()); - - // Chests - System.out.println("Chests: " + Math.min(250, chests.size())); - for (int i = 0; i < 250 && !chests.isEmpty(); i++) - { - Location loc = chests.remove(UtilMath.r(chests.size())); - - fillWithLoot(loc.getBlock()); - if (UtilMath.offset2d(loc, spawnPoint) < 8) - spawn++; - } - - for (Location loc : chests) - { - if (spawn < 10 && UtilMath.offset(loc, spawnPoint) < 8) - { - spawn++; - fillWithLoot(loc.getBlock()); - continue; - } - - loc.getBlock().setType(Material.AIR); - } - } - - private void createLoot() - { - for (SpellType spellType : SpellType.values()) - { - for (int i = 0; i < spellType.getItemAmount(); i++) - { - _randomItems.add(new HashMap.SimpleEntry(spellType.getSpellBook(this), 0)); - } - } - - for (int i = 0; i < 4; i++) - { - _randomItems.add(new HashMap.SimpleEntry(makeUnusedWand(), 0)); - } - - addRandomItem(5, Material.RAW_FISH, 0, 1, 2); - addRandomItem(5, Material.RAW_BEEF, 0, 1, 2); - addRandomItem(5, Material.RAW_CHICKEN, 0, 1, 2); - addRandomItem(5, Material.POTATO_ITEM, 0, 1, 2); - addRandomItem(5, Material.CARROT_ITEM, 0, 1, 2); - addRandomItem(5, Material.WHEAT, 0, 1, 2); - addRandomItem(1, Material.TNT, 0, 1, 1); - addRandomItem(5, Material.ROTTEN_FLESH, 0, 1, 2); - addRandomItem(5, Material.STICK, 0, 1, 2); - addRandomItem(5, Material.WOOD, 0, 1, 10); - addRandomItem(5, Material.BOAT, 0, 1, 2); - addRandomItem(5, Material.FLINT, 0, 1, 2); - addRandomItem(5, Material.FEATHER, 0, 1, 2); - addRandomItem(5, Material.GOLD_INGOT, 0, 1, 2); - addRandomItem(5, Material.LEATHER_BOOTS, 0, 1, 1); - addRandomItem(5, Material.LEATHER_CHESTPLATE, 0, 1, 1); - addRandomItem(5, Material.LEATHER_HELMET, 0, 1, 1); - addRandomItem(5, Material.LEATHER_LEGGINGS, 0, 1, 1); - addRandomItem(3, Material.CHAINMAIL_BOOTS, 0, 1, 1); - addRandomItem(3, Material.CHAINMAIL_CHESTPLATE, 0, 1, 1); - addRandomItem(3, Material.CHAINMAIL_HELMET, 0, 1, 1); - addRandomItem(3, Material.CHAINMAIL_LEGGINGS, 0, 1, 1); - addRandomItem(3, Material.FISHING_ROD, 0, 1, 1); - // addRandomItem(5, Material.BOW, 0, 1, 1); - // addRandomItem(5, Material.ARROW, 0, 1, 5); - addRandomItem(5, Material.PORK, 0, 1, 2); - addRandomItem(5, Material.BAKED_POTATO, 0, 1, 2); - addRandomItem(5, Material.CAKE, 0, 1, 1); - addRandomItem(5, Material.COOKED_BEEF, 0, 1, 2); - addRandomItem(5, Material.COOKED_CHICKEN, 0, 1, 2); - addRandomItem(5, Material.COOKED_FISH, 0, 1, 2); - addRandomItem(5, Material.GRILLED_PORK, 0, 1, 2); - addRandomItem(5, Material.COOKIE, 0, 1, 2); - addRandomItem(5, Material.PUMPKIN_PIE, 0, 1, 2); - addRandomItem(5, Material.APPLE, 0, 1, 2); - addRandomItem(5, Material.IRON_INGOT, 0, 1, 2); - addRandomItem(2, Material.DIAMOND, 0, 1, 1); - addRandomItem(5, Material.EXP_BOTTLE, 0, 1, 2); - addRandomItem(1, Material.IRON_BOOTS, 0, 1, 1); - addRandomItem(1, Material.IRON_CHESTPLATE, 0, 1, 1); - addRandomItem(1, Material.IRON_HELMET, 0, 1, 1); - addRandomItem(1, Material.IRON_LEGGINGS, 0, 1, 1); - } - - @EventHandler - public void CreateRandomChests(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - HashSet ignore = new HashSet(); - - ignore.add(Material.LEAVES); - - int xDiff = WorldData.MaxX - WorldData.MinX; - int zDiff = WorldData.MaxZ - WorldData.MinZ; - - int done = 0; - - while (done < 40) - { - - Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX + UtilMath.r(xDiff), - WorldData.MinZ + UtilMath.r(zDiff), ignore); - - if (!UtilBlock.airFoliage(block) || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) - continue; - - block.setTypeIdAndData(54, (byte) UtilMath.r(4), true); - fillWithLoot(block); - done++; - } - } - - public void drawUtilTextBottom(Player player) - { - int heldSlot = player.getInventory().getHeldItemSlot(); - - if (heldSlot >= 0 && heldSlot < 5) - { - Wizard wizard = getWizard(player); - - if (wizard != null) - { - - SpellType type = wizard.getSpell(heldSlot); - - if (type != null) - { - - double usableTime = 0;// Time in seconds till usable - - if (wizard.getMana() < type.getManaCost(wizard)) - { - usableTime = (type.getManaCost(wizard) - wizard.getMana()) / (20 * wizard.getManaPerTick()); - } - - double cooldown = wizard.getCooldown(type) != 0 ? (double) (wizard.getCooldown(type) - System - .currentTimeMillis()) / 1000D : 0; - boolean displayCooldown = false; - - if (cooldown > 0 && cooldown > usableTime) - { - usableTime = cooldown; - displayCooldown = true; - } - - if (usableTime > 0) - { - - usableTime = UtilMath.trim(1, usableTime); - - double maxSeconds = Math.max(type.getSpellCooldown(wizard), - type.getManaCost(wizard) / (wizard.getManaPerTick() * 20)); - - displayProgress(displayCooldown ? C.cRed : C.cDPurple, - type.getElement().getColor() + type.getSpellName(), 1f - (usableTime / maxSeconds), - - (displayCooldown ? - - UtilTime.convertString((long) (usableTime * 1000), 1, TimeUnit.FIT) - - : - - usableTime + (usableTime < 60 ? "s" : "m") + " for mana"), - - player); - - } - else - { - UtilTextBottom.display(type.getElement().getColor() + C.Bold + type.getSpellName(), player); - } - } - else - { - UtilTextBottom.display("Spell Wand", player); - } - } - } - } - - private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players) - { - // Generate Bar - int bars = 52; - String progressBar = C.cGreen + ""; - boolean colorChange = false; - for (int i = 0; i < bars; i++) - { - if (!colorChange && (float) i / (float) bars >= amount) - { - progressBar += progressColor;// C.cRed; - colorChange = true; - } - - progressBar += "|"; - } - - // Send to Player - for (Player player : players) - { - // 1.7 - Add Color - if (!UtilPlayer.is1_8(player)) - { - UtilTextTop.displayProgress((prefix == null ? "" : C.cYellow + C.Bold + prefix) - + (suffix == null ? "" : ChatColor.RESET + C.Bold + " - " + C.cGreen + C.Bold + suffix), amount, player); - } - // 1.8 - else - { - UtilTextBottom.display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar - + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players); - } - } - } - - private void dropSpells(Player player) - { - HashSet spells = new HashSet(); - ArrayList itemsToDrop = new ArrayList(); - ArrayList normalItemsToDrop = UtilInv.getItems(player); - - Wizard wizard = getWizard(player); - int wandsHeld = 0; - - for (int i = 0; i < 5; i++) - { - SpellType type = wizard.getSpell(i); - - if (type != null && type != SpellType.MagicMissile) - { - spells.add(type); - } - } - - Iterator itel = normalItemsToDrop.iterator(); - - while (itel.hasNext()) - { - ItemStack item = itel.next(); - if (item.getType() == Material.BLAZE_ROD) - { - wandsHeld++; - itel.remove(); - } - else if (item.getType() == Material.STAINED_GLASS_PANE) - { - itel.remove(); - } - else - { - player.getWorld().dropItemNaturally(player.getLocation(), item); - } - } - - for (SpellType type : spells) - { - itemsToDrop.add(type.getSpellBook(this)); - } - - if (wandsHeld > 3 || UtilMath.random.nextBoolean()) - { - itemsToDrop.add(makeUnusedWand()); - } - - itemsToDrop.add(new ItemBuilder(Material.NETHER_STAR).setTitle(buildTime()).build()); - - Collections.shuffle(itemsToDrop, new Random()); - - double beginnerAngle = Math.random() * 360; - - for (ItemStack itemstack : itemsToDrop) - { - Item item = player.getWorld().dropItem(player.getLocation(), itemstack); - item.setPickupDelay(60); - - beginnerAngle += 360D / itemsToDrop.size(); - double angle = (((2 * Math.PI) / 360) * beginnerAngle) % 360; - double x = 0.2 * Math.cos(angle); - double z = 0.2 * Math.sin(angle); - - item.setVelocity(new Vector(x, 0.3, z)); - } - } - - private void fillWithLoot(Block block) - { - BlockState state = block.getState(); - if (state instanceof InventoryHolder) - { - - InventoryHolder holder = (InventoryHolder) state; - Inventory inv = holder.getInventory(); - boolean containsSpell = false; - - for (int i = 0; i < 5 || !containsSpell; i++) - { - - Entry entry = _randomItems.get(UtilMath.r(_randomItems.size())); - ItemStack item = entry.getKey().clone(); - - // Every chest has a spell. - if (i > 5 && item.getType() != Material.ENCHANTED_BOOK) - { - continue; - } - - if (!containsSpell) - { - containsSpell = item.getType() == Material.ENCHANTED_BOOK; - } - - item.setAmount(item.getAmount() + UtilMath.r(entry.getValue() + 1)); - inv.setItem(UtilMath.r(inv.getSize()), item); - } - - state.update(); - } - } - - private SpellType getSpell(ItemStack item) - { - if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) - { - String title = item.getItemMeta().getDisplayName(); - title = ChatColor.stripColor(title.substring(title.split(" ")[0].length() + 1)); - - for (SpellType spell : SpellType.values()) - { - if (spell.getSpellName().equals(title)) - return spell; - } - } - - return null; - } - - public Wizard getWizard(org.bukkit.entity.Player player) - { - return _wizards.get(player.getName()); - } - - public ItemStack makeUnusedWand() - { - ItemBuilder builder = new ItemBuilder(Material.BLAZE_ROD); - builder.setTitle(ChatColor.WHITE + "Spell Wand" + buildTime()); - - builder.addLore( - - C.cPurple + C.Bold + "LEFT CLICK" + C.cDGreen + " Cast spell", - - C.cGreen + C.Bold + "RIGHT CLICK" + C.cBlue + " Open Spellbook"); - - return builder.build(); - } - - private void onCastSpell(Player player, Object obj) - { - ItemStack item = player.getItemInHand(); - - if (IsLive() && IsAlive(player) && item != null && item.getType() == Material.BLAZE_ROD - && player.getInventory().getHeldItemSlot() < 5) - { - - Wizard wizard = getWizard(player); - SpellType spell = wizard.getSpell(player.getInventory().getHeldItemSlot()); - - if (spell != null) - { - - int spellLevel = wizard.getSpellLevel(spell); - if (spellLevel > 0) - { - - if (wizard.getCooldown(spell) == 0) - { - - if (wizard.getMana() >= spell.getManaCost(wizard)) - { - - Spell sp = _spells.get(spell); - - if (obj instanceof Block && sp instanceof SpellClickBlock) - { - ((SpellClickBlock) sp).castSpell(player, (Block) obj); - } - - if (wizard.getCooldown(spell) == 0 && obj instanceof Entity && sp instanceof SpellClickEntity) - { - ((SpellClickEntity) sp).castSpell(player, (Entity) obj); - } - - if (wizard.getCooldown(spell) == 0 && sp instanceof SpellClick) - { - ((SpellClick) sp).castSpell(player); - } - } - else - { - player.playSound(player.getLocation(), Sound.FIZZ, 300, 1); - player.sendMessage(ChatColor.BLUE + "The spell sputters and dies."); - player.sendMessage(ChatColor.BLUE + "You do not have enough mana!"); - } - } - else - { - - player.playSound(player.getLocation(), Sound.FIZZ, 300, 1); - player.sendMessage(ChatColor.BLUE + "The spell hasn't recharged yet!"); - - } - - } - - } - } - } - - @EventHandler - public void onChat(PlayerChatEvent event) - { - if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER)) - { - if (event.getMessage().equalsIgnoreCase("spells")) - { - Wizard wizard = getWizard(event.getPlayer()); - for (SpellType type : SpellType.values()) - { - if (wizard.getSpellLevel(type) < type.getMaxLevel()) - { - wizard.learnSpell(type); - } - } - - event.setCancelled(true); - event.getPlayer().sendMessage("All spells leveled up once"); - } - - if (event.getMessage().equalsIgnoreCase("overtime")) - { - setGameLiveTime(System.currentTimeMillis() - (10 * 60 * 1000)); - } - - if (event.getMessage().equalsIgnoreCase("hit me")) - { - summonMeteor(event.getPlayer()); - } - - if (event.getMessage().startsWith("setyield")) - { - _fireballSize = Float.parseFloat(event.getMessage().split(" ")[1]); - } - - if (event.getMessage().equalsIgnoreCase("end game")) - { - sendMeteors(); - event.setCancelled(true); - } - } - } - - @EventHandler - public void onClick(InventoryClickEvent event) - { - ItemStack item = event.getCurrentItem(); - - if (item != null) - { - Player p = (Player) event.getWhoClicked(); - - if (event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest) - { - - if (item != null && item.getType() == Material.ENCHANTED_BOOK) - { - - SpellType spell = getSpell(item); - - if (spell != null) - { - if (onSpellLearn(p, spell)) - { - event.setCurrentItem(new ItemStack(Material.AIR)); - - addMiddleText(p, spell.getElement().getColor() + spell.getSpellName() + " leveled to " - + spell.getElement().getColor() + getWizard(p).getSpellLevel(spell)); - } - } - } - } - - if (item.getType() == Material.BLAZE_ROD - && (event.getClickedInventory().getType() != InventoryType.PLAYER || event.getSlot() > 4)) - { - - if (onGainWand(p)) - { - event.setCancelled(true); - event.setCurrentItem(new ItemStack(Material.AIR)); - } - } - - } - } + private ArrayList _droppedWandsBooks = new ArrayList(); + private int _endgameMessageCounter; + private double _accuracy = 0; + private float _endgameSize = 1.5F; + private float _fireballSpeed = 0.05F; + private long _lastEndgameStrike; + private long _lastGhastMoan; + private int _lastGamePace; + /** + * @0 for meteors + * @1 for lightning + */ + private int _endGameEvent; + private int _nextEndgameStrike = 6000; + private ChestLoot _chestLoot = new ChestLoot(); + private NautHashMap _spells = new NautHashMap(); + private WizardSpellMenu _wizard; + private NautHashMap _wizards = new NautHashMap(); + private Field _itemField; + private IPacketHandler _wizardSpellLevelHandler; + + public Wizards(ArcadeManager manager) + { + super(manager, GameType.Wizards, new Kit[0], new String[] + { + + "Find loot and spells in chests", + + "Right click wands to assign spells", + + "Left click with wands to cast magic", + + "The last wizard alive wins!" + + }); + + setKits(new Kit[] + { + new KitMage(manager), + + new KitSorcerer(manager), + + new KitMystic(manager), + + new KitWitchDoctor(manager) + }); + + _wizard = new WizardSpellMenu("Wizard Spell Menu", getArcadeManager().getPlugin(), this); + + BlockBreak = true; + BlockPlace = true; + ItemPickup = true; + ItemDrop = true; + InventoryOpenBlock = true; + InventoryOpenChest = true; + InventoryClick = true; + DisableKillCommand = false; + SoupEnabled = false; + DamageTeamSelf = true; + + try + { + _itemField = PacketPlayOutSetSlot.class.getDeclaredField("c"); + _itemField.setAccessible(true); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + Manager.getCosmeticManager().setHideParticles(true); + Manager.GetDamage().GetCombatManager().setUseWeaponName(AttackReason.DefaultWeaponName); + + createLoot(); + + _wizardSpellLevelHandler = new IPacketHandler() + { + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutWindowItems + || packetInfo.getPacket() instanceof PacketPlayOutSetSlot) + { + Inventory inv = packetInfo.getPlayer().getOpenInventory().getTopInventory(); + + if (inv.getType() == InventoryType.CHEST) + { + if (packetInfo.getPacket() instanceof PacketPlayOutWindowItems) + { + Wizard wizard = getWizard(packetInfo.getPlayer()); + + if (wizard != null) + { + PacketPlayOutWindowItems packet = (PacketPlayOutWindowItems) packetInfo.getPacket(); + boolean ownPacket = false; + + ItemStack[] items = new ItemStack[packet.b.length]; + + for (int i = 0; i < items.length; i++) + { + items[i] = CraftItemStack.asBukkitCopy(packet.b[i]); + + ItemStack item = items[i]; + + if (item != null && item.getType() != Material.AIR) + { + SpellType spellType = getSpell(item); + + if (spellType != null) + { + if (wizard.getSpellLevel(spellType) < spellType.getMaxLevel()) + { + item.setAmount(wizard.getSpellLevel(spellType) + 1); + } + else + { + item.setAmount(0); + } + + ownPacket = true; + } + } + } + + if (ownPacket) + { + List list = new ArrayList(); + + for (ItemStack item : items) + { + list.add(CraftItemStack.asNMSCopy(item)); + } + + packetInfo.setCancelled(true); + + packet = new PacketPlayOutWindowItems(packet.a, list); + + packetInfo.getVerifier().bypassProcess(packet); + } + } + } + else + { + PacketPlayOutSetSlot packet = (PacketPlayOutSetSlot) packetInfo.getPacket(); + + ItemStack item = null; + + try + { + item = CraftItemStack.asBukkitCopy((net.minecraft.server.v1_7_R4.ItemStack) _itemField + .get(packet)); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + if (item != null && item.getType() != Material.AIR) + { + SpellType spellType = getSpell(item); + + if (spellType != null) + { + Wizard wizard = getWizard(packetInfo.getPlayer()); + + if (wizard != null) + { + if (wizard.getSpellLevel(spellType) < spellType.getMaxLevel()) + { + item.setAmount(wizard.getSpellLevel(spellType) + 1); + } + else + { + item.setAmount(0); + } + + packetInfo.setCancelled(true); + + packet = new PacketPlayOutSetSlot(packet.a, packet.b, CraftItemStack.asNMSCopy(item)); + + packetInfo.getVerifier().bypassProcess(packet); + } + } + } + } + } + } + } + }; + } + + @EventHandler + public void onFireballDamage(EntityDamageByEntityEvent event) + { + if (event.getDamager() instanceof Fireball) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (!event.IgnoreArmor()) + { + double percentProtected = 0; + + if (event.GetDamageePlayer() == null) + { + return; + } + + for (ItemStack item : event.GetDamageePlayer().getInventory().getArmorContents()) + { + if (item != null) + { + double percent = 0; + String name = item.getType().name(); + + if (name.contains("LEATHER")) + { + percent = 8; + } + else if (name.contains("GOLDEN") || name.contains("CHAINMAIL")) + { + percent = 12; + } + else if (name.contains("IRON")) + { + percent = 15; + } + else if (name.contains("DIAMOND")) + { + percent = 20; + } + + if (name.contains("BOOTS")) + { + percent /= 3; + } + else if (name.contains("LEGGINGS")) + { + percent /= 1.5; + } + else if (name.contains("CHESTPLATE")) + { + } + else if (name.contains("HELMET")) + { + percent /= 2; + } + + percentProtected += (percent / 100); + } + } + + if (percentProtected > 0) + { + event.SetIgnoreArmor(true); + event.AddMult("Armor Rebalancing", "Armor Rebalancing", 1 - percentProtected, false); + } + } + } + + public String buildTime() + { + String s = ""; + + for (char c : ("" + System.nanoTime()).toCharArray()) + { + s += "§" + c; + } + + return s; + } + + @EventHandler + public void spellCooldown(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (!IsLive()) + { + return; + } + + for (Player player : GetPlayers(true)) + { + int heldSlot = player.getInventory().getHeldItemSlot(); + Wizard wizard = getWizard(player); + + for (int i = 0; i < 5; i++) + { + if (i == heldSlot) + continue; + + ItemStack item = player.getInventory().getItem(i); + + if (item != null) + { + SpellType spell = wizard.getSpell(i); + + if (spell != null) + { + int timeLeft = (int) Math.ceil(getUsableTime(wizard, spell).getKey()); + + timeLeft = Math.max(0, Math.min(63, timeLeft)) + 1; + + if (timeLeft != item.getAmount()) + { + item.setAmount(timeLeft); + + player.getInventory().setItem(i, item); + } + } + } + } + } + } + + public void castSpell(Player player, Wizard wizard, SpellType spell, Object interacted) + { + int spellLevel = wizard.getSpellLevel(spell); + + if (spellLevel > 0) + { + + if (wizard.getCooldown(spell) == 0) + { + + if (wizard.getMana() >= spell.getManaCost(wizard)) + { + + Spell sp = _spells.get(spell); + + if (interacted instanceof Block && sp instanceof SpellClickBlock) + { + ((SpellClickBlock) sp).castSpell(player, (Block) interacted); + } + + if (wizard.getCooldown(spell) == 0 && interacted instanceof Entity && sp instanceof SpellClickEntity) + { + ((SpellClickEntity) sp).castSpell(player, (Entity) interacted); + } + + if (wizard.getCooldown(spell) == 0 && sp instanceof SpellClick) + { + ((SpellClick) sp).castSpell(player); + } + } + else + { + player.playSound(player.getLocation(), Sound.FIZZ, 300, 1); + player.sendMessage(ChatColor.BLUE + "The spell sputters and dies."); + player.sendMessage(ChatColor.BLUE + "You do not have enough mana!"); + } + } + else + { + + player.playSound(player.getLocation(), Sound.FIZZ, 300, 1); + player.sendMessage(ChatColor.BLUE + "The spell hasn't recharged yet!"); + + } + + } + } + + public void changeWandsType(Player player, int oldSlot, int newSlot) + { + PlayerInventory inv = player.getInventory(); + Wizard wizard = getWizard(player); + + if (oldSlot >= 0 && oldSlot < 5) + { + SpellType spell = wizard.getSpell(oldSlot); + + if (spell != null) + { + int timeLeft = (int) Math.ceil(getUsableTime(wizard, spell).getKey()); + + timeLeft = Math.max(0, Math.min(63, timeLeft)) + 1; + + ItemStack item = inv.getItem(oldSlot); + + item.setType(spell.getSpellItem().getType()); + + item.setDurability(spell.getSpellItem().getDurability()); + + item.setAmount(timeLeft); - @EventHandler - public void onDamage(EntityDamageByEntityEvent event) - { - if (IsAlive(event.getDamager())) - { - onCastSpell((Player) event.getDamager(), event.getEntity()); + inv.setItem(oldSlot, item); + } + } + + if (newSlot >= 0 && newSlot < 5) + { + SpellType spell = wizard.getSpell(newSlot); + + if (spell != null) + { + ItemStack item = inv.getItem(newSlot); + + item.setDurability((short) 0); + + item.setType(spell.getWandType().getMaterial()); + + item.setAmount(1); + + inv.setItem(newSlot, item); + } + } + } + + public void changeWandsTitles(Player player) + { + PlayerInventory inv = player.getInventory(); + Wizard wizard = getWizard(player); + + for (int slot = 0; slot < 5; slot++) + { + if (slot < wizard.getWandsOwned()) + { + ItemStack item = inv.getItem(slot); + SpellType type = wizard.getSpell(slot); + String display; + + if (type != null) + { + display = C.cYellow + "Mana " + ChatColor.RESET + type.getManaCost(wizard) + + + " " + + + C.cYellow + "Cooldown " + ChatColor.RESET + + + UtilTime.convertString((long) (type.getSpellCooldown(wizard) * 1000), 1, TimeUnit.FIT); + } + else + { + display = C.cWhite + "Right click to set a spell"; + } + + ItemMeta meta = item.getItemMeta(); + + if (!meta.hasDisplayName() || !meta.getDisplayName().equals(display)) + { + meta.setDisplayName(display); + item.setItemMeta(meta); + } + } + } + } + + @EventHandler + public void checkPickupBooks(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK && IsLive()) + { + Iterator itel = _droppedWandsBooks.iterator(); + + while (itel.hasNext()) + { + Item item = itel.next(); + + if (item.isValid()) + { + Player player = UtilPlayer.getClosest(item.getLocation(), (Entity) null); + + if (player != null && player.getLocation().distance(item.getLocation()) < 1.7) + { + onPickup(new PlayerPickupItemEvent(player, item, 0)); + } + } + + if (!item.isValid()) + { + itel.remove(); + } + } + } + } + + private void CreateChestCraftEnchant() + { + ArrayList chests = WorldData.GetCustomLocs("54"); + + System.out.println("Map Chest Locations: " + chests.size()); + + int spawn = 0; + Location spawnPoint = UtilWorld.averageLocation(GetTeamList().get(0).GetSpawns()); + + // Chests + System.out.println("Chests: " + Math.min(250, chests.size())); + for (int i = 0; i < 250 && !chests.isEmpty(); i++) + { + Location loc = chests.remove(UtilMath.r(chests.size())); + + fillWithLoot(loc.getBlock()); + if (UtilMath.offset2d(loc, spawnPoint) < 8) + spawn++; + } + + for (Location loc : chests) + { + if (spawn < 10 && UtilMath.offset(loc, spawnPoint) < 8) + { + spawn++; + fillWithLoot(loc.getBlock()); + continue; + } + + loc.getBlock().setType(Material.AIR); + } + } + + @EventHandler + public void handleEntityPacket(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + getArcadeManager().getPacketHandler().addPacketHandler(_wizardSpellLevelHandler); + } + else if (event.GetState() == GameState.Dead) + { + getArcadeManager().getPacketHandler().removePacketHandler(_wizardSpellLevelHandler); + } + } + + private void createLoot() + { + for (SpellType spellType : SpellType.values()) + { + _chestLoot.addLoot(spellType.getSpellBook(this), spellType.getItemAmount()); + } + + _chestLoot.addLoot( + new ItemBuilder(makeBlankWand()).setTitle(C.cWhite + "Spell Wand" + buildTime()) + .addEnchantment(UtilInv.getDullEnchantment(), 1).build(), 4); + + _chestLoot.addLoot(Material.CARROT_ITEM, 15, 1, 2); + _chestLoot.addLoot(Material.COOKED_BEEF, 15, 1, 2); + _chestLoot.addLoot(Material.BREAD, 15, 1, 2); + _chestLoot.addLoot(new ItemBuilder(Material.COOKED_CHICKEN).setTitle(C.cWhite + "Cheese").build(), 15, 1, 2); + + _chestLoot.addLoot(Material.WHEAT, 5, 1, 2); + _chestLoot.addLoot(Material.WOOD, 5, 1, 10); + _chestLoot.addLoot(Material.BOAT, 5, 1, 2); + _chestLoot.addLoot(Material.FISHING_ROD, 3, 1, 1); + + _chestLoot.addLoot(Material.GOLD_INGOT, 5, 1, 2); + _chestLoot.addLoot(Material.IRON_INGOT, 5, 1, 2); + _chestLoot.addLoot(Material.DIAMOND, 3, 1, 1); + + _chestLoot.addLoot(Material.LEATHER_BOOTS, 6, 1, 1); + _chestLoot.addLoot(Material.LEATHER_LEGGINGS, 6, 1, 1); + _chestLoot.addLoot(Material.LEATHER_CHESTPLATE, 6, 1, 1); + _chestLoot.addLoot(Material.LEATHER_HELMET, 6, 1, 1); + + _chestLoot.addLoot(Material.CHAINMAIL_BOOTS, 5, 1, 1); + _chestLoot.addLoot(Material.CHAINMAIL_CHESTPLATE, 5, 1, 1); + _chestLoot.addLoot(Material.CHAINMAIL_HELMET, 5, 1, 1); + _chestLoot.addLoot(Material.CHAINMAIL_LEGGINGS, 5, 1, 1); + + _chestLoot.addLoot(Material.IRON_BOOTS, 2, 1, 1); + _chestLoot.addLoot(Material.IRON_CHESTPLATE, 2, 1, 1); + _chestLoot.addLoot(Material.IRON_HELMET, 2, 1, 1); + _chestLoot.addLoot(Material.IRON_LEGGINGS, 2, 1, 1); + } + + @EventHandler + public void CreateRandomChests(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + HashSet ignore = new HashSet(); + + ignore.add(Material.LEAVES); + + int xDiff = WorldData.MaxX - WorldData.MinX; + int zDiff = WorldData.MaxZ - WorldData.MinZ; + + int done = 0; + + while (done < 40) + { + + Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX + UtilMath.r(xDiff), + WorldData.MinZ + UtilMath.r(zDiff), ignore); + + if (!UtilBlock.airFoliage(block) || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) + continue; + + block.setTypeIdAndData(54, (byte) UtilMath.r(4), true); + fillWithLoot(block); + done++; + } + } + + private void displayProgress(String progressColor, String prefix, double amount, String suffix, Player... players) + { + // Generate Bar + int bars = 52; + String progressBar = C.cGreen + ""; + boolean colorChange = false; + for (int i = 0; i < bars; i++) + { + if (!colorChange && (float) i / (float) bars >= amount) + { + progressBar += progressColor;// C.cRed; + colorChange = true; + } + + progressBar += "|"; + } + + // Send to Player + for (Player player : players) + { + // 1.7 - Add Color + if (!UtilPlayer.is1_8(player)) + { + UtilTextTop.displayProgress((prefix == null ? "" : C.cYellow + C.Bold + prefix) + + (suffix == null ? "" : ChatColor.RESET + C.Bold + " - " + C.cGreen + C.Bold + suffix), amount, player); + } + // 1.8 + else + { + UtilTextBottom.display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players); + } + } + } + + public void drawUtilTextBottom(Player player) + { + int heldSlot = player.getInventory().getHeldItemSlot(); + + if (heldSlot >= 0 && heldSlot < 5) + { + Wizard wizard = getWizard(player); + + if (wizard != null) + { + + SpellType type = wizard.getSpell(heldSlot); + + if (type != null) + { + Entry entry = getUsableTime(wizard, type); + + double usableTime = entry.getKey();// Time in seconds till usable + + if (usableTime > 0) + { + usableTime = UtilMath.trim(1, usableTime); + + double maxSeconds = Math.max(type.getSpellCooldown(wizard), + type.getManaCost(wizard) / (wizard.getManaPerTick() * 20)); + + displayProgress(C.cRed, C.cRed + type.getSpellName(), 1f - (usableTime / maxSeconds), + + (entry.getValue() ? + + UtilTime.convertString((long) (usableTime * 1000), 1, TimeUnit.FIT) + + : + + usableTime + (usableTime < 60 ? "s" : "m") + " for mana"), + + player); + + } + else + { + UtilTextBottom.display(C.cGreen + C.Bold + type.getSpellName(), player); + } + } + else + { + UtilTextBottom.display("Spell Wand", player); + } + } + } + } + + private Entry getUsableTime(Wizard wizard, SpellType type) + { + double usableTime = 0; + + if (wizard.getMana() < type.getManaCost(wizard)) + { + usableTime = (type.getManaCost(wizard) - wizard.getMana()) / (20 * wizard.getManaPerTick()); + } + + double cooldown = wizard.getCooldown(type) != 0 ? (double) (wizard.getCooldown(type) - System.currentTimeMillis()) / 1000D + : 0; + boolean displayCooldown = false; + + if (cooldown > 0 && cooldown > usableTime) + { + usableTime = cooldown; + displayCooldown = true; + } + + return new HashMap.SimpleEntry(usableTime, displayCooldown); + } + + private ArrayList getItems(Player player) + { + ArrayList items = new ArrayList(); + PlayerInventory inv = player.getInventory(); + + for (int i = 5; i < inv.getSize(); i++) + { + ItemStack item = inv.getItem(i); + + if (item != null && item.getType() != Material.AIR) + { + items.add(item.clone()); + } + } + + for (ItemStack item : inv.getArmorContents()) + { + if (item != null && item.getType() != Material.AIR) + { + items.add(item.clone()); + } + } - if (event.getDamage() > 0.5) - { - event.setDamage(0.5); - if (event.getEntity() instanceof LivingEntity) - { - UtilParticle.PlayParticle((Player) event.getDamager(), ParticleType.HEART, - ((LivingEntity) event.getEntity()).getEyeLocation(), 0, 0, 0, 0, 1); - } - } - } - } - - @EventHandler - public void onDeath(PlayerDeathEvent event) - { - if (IsAlive(event.getEntity())) - { - dropSpells(event.getEntity()); + ItemStack cursorItem = player.getItemOnCursor(); - Iterator itel = event.getDrops().iterator(); + if (cursorItem != null && cursorItem.getType() != Material.AIR) + items.add(cursorItem.clone()); - while (itel.hasNext()) - { - ItemStack item = itel.next(); + return items; + } - if (item.getType() == Material.BLAZE_ROD || item.getType() == Material.STAINED_GLASS_PANE) - { - itel.remove(); - } - } - } + private void dropSpells(Player player) + { + HashSet spells = new HashSet(); + ArrayList itemsToDrop = new ArrayList(); - _wizards.remove(event.getEntity().getName()); - } + Wizard wizard = getWizard(player); - @EventHandler - public void onDropItem(ItemSpawnEvent event) - { - ItemStack item = event.getEntity().getItemStack(); + for (int i = 0; i < 5; i++) + { + SpellType type = wizard.getSpell(i); - if (item.getType() == Material.ENCHANTED_BOOK) - { - - SpellType spell = getSpell(item); - - if (spell != null) - { - - Hologram holo = new Hologram(getArcadeManager().getHologramManager(), - - event.getEntity().getLocation().add(0, 1, 0), - - C.cDPurple + C.Bold + "Spellbook", - - spell.getElement().getColor() + spell.getSpellName()); - - holo.setFollowEntity(event.getEntity()); - - holo.setRemoveOnEntityDeath(); - - holo.start(); - - _droppedWandsBooks.add(event.getEntity()); - - } - } - else if (item.getType() == Material.BLAZE_ROD) - { - - Hologram holo = new Hologram(getArcadeManager().getHologramManager(), - - event.getEntity().getLocation().add(0, 1, 0), - - C.Bold + "Spell Wand"); - - holo.setFollowEntity(event.getEntity()); - - holo.setRemoveOnEntityDeath(); - - holo.start(); - - _droppedWandsBooks.add(event.getEntity()); - } - else if (item.getType() == Material.NETHER_STAR) - { - Hologram holo = new Hologram(getArcadeManager().getHologramManager(), - - event.getEntity().getLocation().add(0, 1, 0), - - C.Bold + "Wizard Soul"); - - holo.setFollowEntity(event.getEntity()); - - holo.setRemoveOnEntityDeath(); - - holo.start(); - - _droppedWandsBooks.add(event.getEntity()); - } - else if (item.getType() == Material.BOOK) - { - event.getEntity().remove(); - } - } - - @EventHandler - public void onDropItem(PlayerDropItemEvent event) - { - if (event.getPlayer().getInventory().getHeldItemSlot() < 5) - { - event.setCancelled(true); - } - } - - @EventHandler - public void onEndOrPrepare(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Live) - { - for (SpellType spells : SpellType.values()) - { - try - { - Spell spell = spells.getSpellClass().newInstance(); - - if (!(spell instanceof SpellClick || spell instanceof SpellClickBlock || spell instanceof SpellClickEntity)) - throw new IllegalClassException(spells.getSpellName() + "'s spell class doesn't extend a spell interface"); - - spell.setSpellType(spells); - spell.Wizards = this; - - _spells.put(spells, spell); - - Bukkit.getPluginManager().registerEvents(spell, getArcadeManager().getPlugin()); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } - else if (event.GetState() == GameState.Dead || event.GetState() == GameState.End) - { - for (Spell spell : _spells.values()) - { - HandlerList.unregisterAll(spell); - } - _spells.clear(); - } - } - - private boolean onGainWand(Player p) - { - int slot = p.getInventory().first(Material.STAINED_GLASS_PANE); - - if (slot >= 0 && slot < 5) - { - p.getInventory().setItem(slot, - new ItemBuilder(makeUnusedWand()).setTitle(C.cWhite + "Right click to set a spell").build()); - - p.updateInventory(); - - addMiddleText(p, C.cGold + "Gained a wand"); - } - else - { - Wizard wizard = getWizard(p); - - if (wizard.getMana() < wizard.getMaxMana()) - { - wizard.setMana(wizard.getMaxMana()); - addMiddleText(p, ChatColor.GOLD + "Converted wand into mana"); - } - } - - return true; - } - - private void onGainSoulStar(Player p) - { - Wizard wizard = getWizard(p); - addMiddleText(p, ChatColor.GOLD + "Absorbed Wizard Soul"); - wizard.addSoulStar(); - drawUtilTextBottom(p); - } - - @EventHandler - public void onGameEnd(GameStateChangeEvent event) - { - if (event.GetState() == GameState.End || event.GetState() == GameState.Dead) - { - HandlerList.unregisterAll(_wizard); - } - } - - @EventHandler - public void onInteract(PlayerInteractEvent event) - { - ItemStack item = event.getItem(); - if (item != null) - { - - Player p = event.getPlayer(); - if (event.getAction().name().contains("LEFT")) - { - - if (item.getType() == Material.BLAZE_ROD) - { - - onCastSpell(p, event.getClickedBlock()); - } - } - } - } - - @EventHandler - public void onItemClick(InventoryClickEvent event) - { - int slot = event.getClick().isKeyboardClick() ? event.getHotbarButton() : event.getSlot(); - - if (slot >= 0 && slot < 5 - && (event.getClickedInventory().getType() == InventoryType.PLAYER || event.getClick() == ClickType.NUMBER_KEY)) - { - event.setCancelled(true); - ((Player) event.getWhoClicked()).updateInventory(); - } - } - - @EventHandler - public void onLive(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Live) - { - for (Player player : GetPlayers(true)) - { - Kit kit = GetKit(player); - Wizard wizard = new Wizard(kit instanceof KitWitchDoctor ? 150 : 100); - - _wizards.put(player.getName(), wizard); - - if (kit instanceof KitMage) - { - for (int a = 0; a < 2; a++) - { - for (int i = 0; i < 100; i++) - { - SpellType spell = SpellType.values()[UtilMath.r(SpellType.values().length)]; - - if (wizard.getSpellLevel(spell) < spell.getMaxLevel()) - { - onSpellLearn(player, spell); - - addMiddleText(player, spell.getElement().getColor() + spell.getSpellName() + " leveled to " - + spell.getElement().getColor() + wizard.getSpellLevel(spell)); - - break; - } - } - } - } - else if (kit instanceof KitMystic) - { - wizard.setManaPerTick(wizard.getManaPerTick() * 1.1F); - } - - changeWandsTitles(player); - } - } - } - - @EventHandler - public void onPickup(PlayerPickupItemEvent event) - { - ItemStack item = event.getItem().getItemStack(); - Player p = event.getPlayer(); - - if (IsAlive(p)) - { - - if (item.getType() == Material.BLAZE_ROD) - { - - if (onGainWand(p)) - { - event.setCancelled(true); - event.getItem().remove(); - } - - } - else if (item.getType() == Material.ENCHANTED_BOOK) - { - - SpellType spell = getSpell(item); - - if (spell != null) - { - - if (onSpellLearn(p, spell)) - { - Wizard wizard = getWizard(p); - - addMiddleText(p, spell.getElement().getColor() + spell.getSpellName() + " leveled to " - + spell.getElement().getColor() + wizard.getSpellLevel(spell)); - - event.setCancelled(true); - event.getItem().remove(); - } - } - - } - else if (item.getType() == Material.NETHER_STAR) - { - onGainSoulStar(p); - - event.setCancelled(true); - event.getItem().remove(); - } - } - } - - @EventHandler - public void onQuit(PlayerQuitEvent event) - { - Player p = event.getPlayer(); - - if (IsAlive(p)) - { - dropSpells(p); - } - - _wizards.remove(p.getName()); - _learnedSpellChests.remove(p.getName()); - } - - @EventHandler - public void checkPickupBooks(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK && IsLive()) - { - Iterator itel = _droppedWandsBooks.iterator(); - - while (itel.hasNext()) - { - Item item = itel.next(); - - if (item.isValid()) - { - Player player = UtilPlayer.getClosest(item.getLocation(), (Entity) null); - - if (player != null && player.getLocation().distance(item.getLocation()) < 1.7) - { - onPickup(new PlayerPickupItemEvent(player, item, 0)); - } - } - - if (!item.isValid()) - { - itel.remove(); - } - } - } - } - - @EventHandler - public void updateMiddleText(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK && IsLive()) - { - Iterator>> itel = _learnedSpellChests.entrySet().iterator(); - - while (itel.hasNext()) - { - - Entry> entry = itel.next(); - - Player p = Bukkit.getPlayerExact(entry.getKey()); - - if (p != null && IsAlive(p)) - { - // If 40 ticks has passed since last sent the middle text, send another. - - if ((!_timeSinceDisplayedMiddle.containsKey(entry.getKey()) || _timeSinceDisplayedMiddle.get(entry.getKey()) <= System - .currentTimeMillis()) && p.getOpenInventory().getTopInventory().getHolder() == p) - { - - UtilTextMiddle.display("", entry.getValue().remove(0), 5, 30, 5, p); - - if (entry.getValue().isEmpty()) - { - itel.remove(); - } - - else - { - - _timeSinceDisplayedMiddle.put(entry.getKey(), System.currentTimeMillis() + 3000L); - - } - - } - } - else - { - itel.remove(); - _timeSinceDisplayedMiddle.remove(entry.getKey()); - } - } - } - } - - private boolean onSpellLearn(Player p, SpellType spell) - { - Wizard wiz = getWizard(p); - - int spellLevel = wiz.getSpellLevel(spell); - - if (spellLevel < spell.getMaxLevel()) - { - wiz.learnSpell(spell); - } - else if (wiz.getMana() < wiz.getMaxMana()) - { - wiz.setMana(Math.min(wiz.getMaxMana(), wiz.getMana() + 50)); - addMiddleText(p, ChatColor.GOLD + "Converted spellbook into mana"); - } - - return true; - } - - @EventHandler - public void onSwapItem(PlayerItemHeldEvent event) - { - if (IsLive()) - { - Player p = event.getPlayer(); - - if (event.getNewSlot() >= 0 && event.getNewSlot() < 5) - { - drawUtilTextBottom(p); - } - else - { - - // Get rid of the old wand message - if (event.getPreviousSlot() >= 0 && event.getPreviousSlot() < 5) - { - UtilTextBottom.display(C.Bold, p); - } - } - } - } - - @EventHandler - public void updateMana(UpdateEvent event) - { - if ((event.getType() == UpdateType.TICK) && GetState() == GameState.Live) - { - Iterator> itel = _wizards.entrySet().iterator(); - - while (itel.hasNext()) - { - Entry entry = itel.next(); - Player player = Bukkit.getPlayerExact(entry.getKey()); - - Wizard wizard = getWizard(player); - float newMana = wizard.getMana(); - - if (newMana < wizard.getMaxMana()) - { - newMana = Math.min(newMana + wizard.getManaPerTick(), wizard.getMaxMana()); - wizard.setMana(newMana); - } - - float percentage = Math.min(1, wizard.getMana() / wizard.getMaxMana()); - - String text = (int) Math.floor(wizard.getMana()) + "/" + (int) wizard.getMaxMana() + " mana " - + UtilTime.convert((int) (wizard.getManaPerTick() * 20000), 1, TimeUnit.SECONDS) + "mps"; - - UtilTextTop.displayTextBar(player, percentage, text); - - drawUtilTextBottom(player); - } - } - } - - @EventHandler - public void onUnplaceablePlace(BlockPlaceEvent event) - { - if (event.getPlayer().getInventory().getHeldItemSlot() < 5) - { - event.setCancelled(true); - } - } - - @EventHandler - public void onWeaponCraft(PrepareItemCraftEvent event) - { - Recipe recipe = event.getRecipe(); - - ItemStack result = recipe != null ? recipe.getResult() : null; - - if (result != null && (result.getType().name().contains("_SWORD") || result.getType().name().contains("_AXE"))) - { - event.getInventory().setResult(new ItemStack(Material.AIR)); - UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft weaponsa"); - } - } - - @Override - public void ParseData() - { - CreateChestCraftEnchant(); - } - - private int _lastGamePace; - - @EventHandler - public void increaseGamePace(UpdateEvent event) - { - - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - int timesShouldIncrease = (int) Math.floor((System.currentTimeMillis() - getGameLiveTime()) / 60000D); - - if (timesShouldIncrease < 10 && timesShouldIncrease != _lastGamePace - && (timesShouldIncrease % 2 == 0 || timesShouldIncrease == 9)) - { - _lastGamePace = timesShouldIncrease; - - Announce(C.cYellow + C.Bold + "Power surges through the battlefield!"); - Announce(C.cYellow + C.Bold + "Mana cost and spell cooldown has been lowered!", false); - - for (Player player : GetPlayers(true)) - { - Wizard wizard = getWizard(player); - - wizard.decreaseCooldown(); - - changeWandsTitles(player); - } - } - } - - @EventHandler - public void onMeteorHit(ProjectileHitEvent event) - { - Projectile projectile = event.getEntity(); - - if (projectile.hasMetadata("Meteor")) - { - projectile.remove(); - - CustomExplosion explosion = new CustomExplosion(getArcadeManager().GetDamage(), projectile.getLocation(), - _fireballSize, "Meteor"); - - explosion.setDropItems(false); - - explosion.setBlocksDamagedEqually(true); - - explosion.explode(); - } - } - - @EventHandler - public void summonMeteors(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - if (System.currentTimeMillis() > getGameLiveTime() + (20 * 60 * 1000)) - { - ArrayList players = new ArrayList(GetPlayers(true)); - - Collections.sort(players, new Comparator() - { - - @Override - public int compare(Player o1, Player o2) - { - // Compare them backwards so the lesser health people are last - // Just so the bigger camper loses more. - return new Double(o2.getHealth()).compareTo(o1.getHealth()); - } - }); - - Iterator itel = players.iterator(); - - while (itel.hasNext()) - { - Player player = itel.next(); - - // Don't kill them if they are the last person in this list. - if (itel.hasNext()) - { - this.getArcadeManager() - .GetDamage() - .NewDamageEvent(player, null, null, DamageCause.ENTITY_EXPLOSION, 9999, false, true, true, "Meteor", - "Meteor"); - } - } - } - - else if (System.currentTimeMillis() > getGameLiveTime() + (10 * 60 * 1000)) - { - sendMeteors(); - } - } - - private void sendMeteors() - { - if (_fireballCounter < 7) - { - if (_fireballCounter == 0) - { - Announce(C.cYellow + C.Bold + "Broken is the cage, the skies scream with rage!"); - } - else if (_fireballCounter == 2) - { - Announce(C.cYellow + C.Bold + "The ground trembles with fear, our doom is here!"); - } - else if (_fireballCounter == 4) - { - Announce(C.cYellow + C.Bold + "Where the wizards stand, meteors strike the land!"); - } - else if (_fireballCounter == 6) - { - Announce(C.cYellow + C.Bold + "Fight to the death! Fight with your dying breath!"); - _fireballsToSpawn = 1.1F; - } - - _fireballCounter++; - } - else - { - _fireballsToSpawn += _fireballAdd; - } - - for (int i = 0; i < _fireballsToSpawn; i++) - { - _fireballAdd += 0.01; - _fireballSize += 0.08; - _fireballsToSpawn -= 1; - - for (Player player : GetPlayers(true)) - { - summonMeteor(player); - } - } - } - - private void summonMeteor(Player player) - { - - Vector vector = new Vector(UtilMath.random.nextDouble() - 0.5D, 0.8, UtilMath.random.nextDouble() - 0.5D).normalize(); - - vector.multiply(40); - - Location loc = player.getLocation(); - - loc.add((UtilMath.random.nextDouble() - 0.5) * 7, 0, (UtilMath.random.nextDouble() - 0.5) * 7); - - loc.add(vector); - - final Fireball fireball = (Fireball) player.getWorld().spawnEntity(loc, EntityType.FIREBALL); - - fireball.setMetadata("Meteor", new FixedMetadataValue(getArcadeManager().getPlugin(), true)); - - new BukkitRunnable() - { - int i; - - public void run() - { - if (fireball.isValid() && IsLive()) - { - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, fireball.getLocation(), 0.3F, 0.3F, 0.3F, 0, 3); - - if (i++ % 6 == 0) - { - fireball.getWorld().playSound(fireball.getLocation(), Sound.CAT_HISS, 1.6F, 0F); - } - } - else - { - cancel(); - } - } - }.runTaskTimer(getArcadeManager().getPlugin(), 0, 0); - - vector.normalize().multiply(-(0.04 + ((_fireballAdd - 0.05) / 2))); - - // We can't call the bukkit methods because for some weird reason, it enforces a certain speed. - EntityFireball eFireball = ((CraftFireball) fireball).getHandle(); - eFireball.dirX = vector.getX(); - eFireball.dirY = vector.getY(); - eFireball.dirZ = vector.getZ(); - - fireball.setBounce(false); - fireball.setYield(0); - fireball.setIsIncendiary(true); - fireball.setFireTicks(9999); - } - - @EventHandler - public void removeDamageToLevel(CustomDamageEvent event) - { - event.SetDamageToLevel(false); - } - - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - GetScoreboard().Reset(); - - GetScoreboard().WriteBlank(); - - GetScoreboard().Write(C.cYellow + C.Bold + "Wizards"); - GetScoreboard().Write(C.cWhite + GetPlayers(true).size()); - - GetScoreboard().WriteBlank(); - - double time = UtilTime.convert(( + if (type != null && type != SpellType.ManaBolt) + { + spells.add(type); + } + } + + for (SpellType spell : wizard.getKnownSpells()) + { + if (spell != SpellType.ManaBolt && UtilMath.random.nextInt(5) == 0) + { + spells.add(spell); + } + } + + for (ItemStack item : getItems(player)) + { + player.getWorld().dropItemNaturally(player.getLocation(), item); + } + + for (SpellType type : spells) + { + ItemStack item = type.getSpellBook(this); + + UtilInv.addDullEnchantment(item); + + itemsToDrop.add(item); + } + + if (wizard.getWandsOwned() > 3 || UtilMath.random.nextBoolean()) + { + itemsToDrop.add(makeBlankWand()); + } + + itemsToDrop.add(new ItemBuilder(Material.NETHER_STAR).setTitle(buildTime()).build()); + + Collections.shuffle(itemsToDrop, new Random()); + + double beginnerAngle = Math.random() * 360; + + for (ItemStack itemstack : itemsToDrop) + { + Item item = player.getWorld().dropItem(player.getLocation(), itemstack); + item.setPickupDelay(60); + + beginnerAngle += 360D / itemsToDrop.size(); + double angle = (((2 * Math.PI) / 360) * beginnerAngle) % 360; + double x = 0.2 * Math.cos(angle); + double z = 0.2 * Math.sin(angle); + + item.setVelocity(new Vector(x, 0.3, z)); + } + } + + private void fillWithLoot(Block block) + { + BlockState state = block.getState(); + + if (state instanceof InventoryHolder) + { + InventoryHolder holder = (InventoryHolder) state; + Inventory inv = holder.getInventory(); + boolean containsSpell = false; - (getGameLiveTime() == 0 ? System.currentTimeMillis() : getGameLiveTime()) + for (int i = 0; i < 5 || !containsSpell; i++) + { - + (10 * 60 * 1000)) - System.currentTimeMillis(), 1, TimeUnit.MINUTES); + ItemStack item = _chestLoot.getLoot(); - GetScoreboard().Write((time >= 0 ? C.cYellow : C.cRed) + C.Bold + (time >= 0 ? "Time Left" : "Overtime")); - GetScoreboard().Write(C.cWhite + Math.abs(time) + " Minute" + (Math.abs(time) != 1 ? "s" : "")); + SpellType spellType = getSpell(item); - GetScoreboard().Draw(); - } + // Every chest has a spell. + if (i > 5 && spellType == null) + { + continue; + } + + if (spellType != null) + { + containsSpell = true; + UtilInv.addDullEnchantment(item); + } + + inv.setItem(UtilMath.r(inv.getSize()), item); + } + + state.update(); + } + } + + private SpellType getSpell(ItemStack item) + { + if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) + { + String title = item.getItemMeta().getDisplayName(); + + if (title.contains(" ")) + { + title = ChatColor.stripColor(title.substring(title.split(" ")[0].length() + 1)); + + for (SpellType spell : SpellType.values()) + { + if (spell.getSpellName().equals(title)) + return spell; + } + } + } + + return null; + } + + public Wizard getWizard(org.bukkit.entity.Player player) + { + return _wizards.get(player.getName()); + } + + @EventHandler + public void increaseGamePace(UpdateEvent event) + { + + if (event.getType() != UpdateType.SEC) + return; + + if (!IsLive()) + return; + + int timesShouldIncrease = (int) Math.floor((System.currentTimeMillis() - getGameLiveTime()) / 60000D); + + if (timesShouldIncrease < 10 && timesShouldIncrease != _lastGamePace + && (timesShouldIncrease % 2 == 0 || timesShouldIncrease == 9)) + { + _lastGamePace = timesShouldIncrease; + + Announce(C.cYellow + C.Bold + "Power surges through the battlefield!"); + Announce(C.cYellow + C.Bold + "Mana cost and spell cooldown has been lowered!", false); + + for (Player player : GetPlayers(true)) + { + Wizard wizard = getWizard(player); + + wizard.decreaseCooldown(); + + changeWandsTitles(player); + } + } + } + + @EventHandler + public void joinMessage(PlayerJoinEvent event) + { + if (!UtilPlayer.is1_8(event.getPlayer())) + returnToHub(event.getPlayer()); + } + + public ItemStack makeBlankWand() + { + ItemBuilder builder = new ItemBuilder(Material.BLAZE_ROD); + + builder.setTitle(C.cWhite + "Right click to set a spell" + buildTime()); + + builder.addLore(C.cGreen + C.Bold + "Left-Click" + C.cWhite + " Bind to Wand"); + + builder.addLore(C.cGreen + C.Bold + "Right-Click" + C.cWhite + " Quickcast Spell"); + + return builder.build(); + } + + private void onCastSpell(Player player, Object obj) + { + ItemStack item = player.getItemInHand(); + + if (IsLive() && IsAlive(player) && item != null && player.getInventory().getHeldItemSlot() < 5) + { + Wizard wizard = getWizard(player); + + SpellType spell = wizard.getSpell(player.getInventory().getHeldItemSlot()); + + if (spell != null) + { + castSpell(player, wizard, spell, obj); + } + } + } + + @EventHandler + public void onChat(PlayerChatEvent event) + { + if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.ADMIN)) + { + if (event.getMessage().equalsIgnoreCase("spells")) + { + Wizard wizard = getWizard(event.getPlayer()); + for (SpellType type : SpellType.values()) + { + if (wizard.getSpellLevel(type) < type.getMaxLevel()) + { + wizard.learnSpell(type); + } + } + + event.setCancelled(true); + event.getPlayer().sendMessage(F.main("Wizards", "All spells leveled up by one")); + } + + if (event.getMessage().equalsIgnoreCase("allspells")) + { + for (Player player : GetPlayers(true)) + { + Wizard wizard = getWizard(player); + for (SpellType type : SpellType.values()) + { + if (wizard.getSpellLevel(type) < type.getMaxLevel()) + { + wizard.learnSpell(type); + } + } + + player.sendMessage(F.main("Wizards", "All spells leveled up by one")); + } + + event.setCancelled(true); + } + + if (event.getMessage().equalsIgnoreCase("overtime")) + { + setGameLiveTime(System.currentTimeMillis() - (int) (9.95 * 60 * 1000)); + event.setCancelled(true); + } + + if (event.getMessage().equalsIgnoreCase("hit me")) + { + summonMeteor(event.getPlayer().getLocation(), _endgameSize); + event.setCancelled(true); + } + + if (event.getMessage().startsWith("setyield")) + { + _endgameSize = Float.parseFloat(event.getMessage().split(" ")[1]); + event.setCancelled(true); + } + } + } + + @EventHandler + public void onClick(InventoryClickEvent event) + { + ItemStack item = event.getCurrentItem(); + + if (item != null) + { + Player p = (Player) event.getWhoClicked(); + + if (event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest) + { + + SpellType spell = getSpell(item); + + if (spell != null) + { + onSpellLearn(p, spell); + + event.setCancelled(true); + event.setCurrentItem(new ItemStack(Material.AIR)); + + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 0.7F, 0); + } + + } + + if (item.getType() == Material.BLAZE_ROD + && (event.getClickedInventory().getType() != InventoryType.PLAYER || event.getSlot() > 4)) + { + + if (onGainWand(p)) + { + event.setCancelled(true); + event.setCurrentItem(new ItemStack(Material.AIR)); + + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 0.7F, 0); + } + } + + } + } + + @EventHandler + public void onDamage(EntityDamageByEntityEvent event) + { + if (!IsLive()) + { + return; + } + + if (IsAlive(event.getDamager())) + { + onCastSpell((Player) event.getDamager(), event.getEntity()); + + if (event.getDamage() > 0.5) + { + event.setDamage(0.5); + + if (event.getEntity() instanceof Player) + { + UtilParticle.PlayParticle((Player) event.getDamager(), ParticleType.HEART, + ((LivingEntity) event.getEntity()).getEyeLocation(), 0, 0, 0, 0, 1); + } + } + } + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + Player p = event.getEntity(); + + if (IsLive() && IsAlive(p)) + { + dropSpells(p); + } + + _wizards.remove(p.getName()); + } + + @EventHandler + public void onDropItem(ItemSpawnEvent event) + { + ItemStack item = event.getEntity().getItemStack(); + + SpellType spell = getSpell(item); + + if (spell != null) + { + Hologram holo = new Hologram(getArcadeManager().getHologramManager(), + + event.getEntity().getLocation().add(0, 1, 0), + + C.cDPurple + C.Bold + "Spell", + + spell.getElement().getColor() + spell.getSpellName()); + + holo.setFollowEntity(event.getEntity()); + + holo.setRemoveOnEntityDeath(); + + holo.setViewDistance(16); + + holo.start(); + + _droppedWandsBooks.add(event.getEntity()); + + } + else if (item.getType() == Material.BLAZE_ROD) + { + item.removeEnchantment(UtilInv.getDullEnchantment()); + + Hologram holo = new Hologram(getArcadeManager().getHologramManager(), + + event.getEntity().getLocation().add(0, 1, 0), + + C.Bold + "Spell Wand"); + + holo.setFollowEntity(event.getEntity()); + + holo.setRemoveOnEntityDeath(); + + holo.setViewDistance(16); + + holo.start(); + + _droppedWandsBooks.add(event.getEntity()); + } + else if (item.getType() == Material.NETHER_STAR) + { + Hologram holo = new Hologram(getArcadeManager().getHologramManager(), + + event.getEntity().getLocation().add(0, 1, 0), + + C.Bold + "Wizard Soul"); + + holo.setFollowEntity(event.getEntity()); + + holo.setRemoveOnEntityDeath(); + + holo.start(); + + _droppedWandsBooks.add(event.getEntity()); + } + else if (item.getType() == Material.BOOK || item.getType() == Material.STICK) + { + event.getEntity().remove(); + } + } + + @EventHandler + public void onDropItem(PlayerDropItemEvent event) + { + if (event.getPlayer().getInventory().getHeldItemSlot() < 5) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onEndOrPrepare(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Live) + { + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (kit instanceof KitMage) + { + Wizard wizard = getWizard(player); + + for (int a = 0; a < 2; a++) + { + for (int i = 0; i < 100; i++) + { + SpellType spell = SpellType.values()[UtilMath.r(SpellType.values().length)]; + + if (wizard.getSpellLevel(spell) == 0 && UtilMath.r(10) < spell.getItemAmount()) + { + onSpellLearn(player, spell); + break; + } + } + } + } + } + for (SpellType spells : SpellType.values()) + { + try + { + Spell spell = spells.getSpellClass().newInstance(); + + if (!(spell instanceof SpellClick || spell instanceof SpellClickBlock || spell instanceof SpellClickEntity)) + throw new IllegalClassException(spells.getSpellName() + "'s spell class doesn't extend a spell interface"); + + spell.setSpellType(spells); + spell.Wizards = this; + + _spells.put(spells, spell); + + Bukkit.getPluginManager().registerEvents(spell, getArcadeManager().getPlugin()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + else if (event.GetState() == GameState.Dead || event.GetState() == GameState.End) + { + for (Spell spell : _spells.values()) + { + HandlerList.unregisterAll(spell); + } + _spells.clear(); + } + } + + private void onGainSoulStar(Player p) + { + Wizard wizard = getWizard(p); + p.sendMessage(C.cGold + "Wizards" + C.cDGray + "> " + C.cGray + "Wizard Soul absorbed, mana regeneration increased"); + wizard.addSoulStar(); + drawUtilTextBottom(p); + } + + private boolean onGainWand(Player p) + { + Wizard wizard = getWizard(p); + + int slot = wizard.getWandsOwned(); + + if (slot >= 0 && slot < 5) + { + wizard.setWandsOwned(wizard.getWandsOwned() + 1); + + p.getInventory().setItem(slot, makeBlankWand()); + + p.updateInventory(); + + p.sendMessage(C.cGold + "Wizards" + C.cDGray + "> " + C.cGray + "Extra wand gained"); + } + else + { + wizard.addMana(100); + p.sendMessage(C.cGold + "Wizards" + C.cDGray + "> " + C.cGray + "Wand converted into mana"); + } + + return true; + } + + @EventHandler + public void onGameEnd(GameStateChangeEvent event) + { + if (event.GetState() == GameState.End || event.GetState() == GameState.Dead) + { + HandlerList.unregisterAll(_wizard); + } + } + + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction().name().contains("LEFT")) + { + onCastSpell(event.getPlayer(), event.getClickedBlock()); + } + } + + @EventHandler + public void onItemClick(InventoryClickEvent event) + { + int slot = event.getClick().isKeyboardClick() ? event.getHotbarButton() : event.getSlot(); + + if (slot >= 0 && slot < 5 + && (event.getClickedInventory().getType() == InventoryType.PLAYER || event.getClick() == ClickType.NUMBER_KEY)) + { + event.setCancelled(true); + ((Player) event.getWhoClicked()).updateInventory(); + } + } + + public void setupWizard(Player player) + { + Kit kit = GetKit(player); + Wizard wizard = new Wizard(kit instanceof KitWitchDoctor ? 150 : 100); + + _wizards.put(player.getName(), wizard); + + if (kit instanceof KitMystic) + { + wizard.setManaPerTick(wizard.getManaPerTick() * 1.1F); + } + + wizard.setWandsOwned(kit instanceof KitSorcerer ? 3 : 2); + + for (int i = 0; i < 5; i++) + { + if (i < wizard.getWandsOwned()) + { + player.getInventory().addItem(((Wizards) Manager.GetGame()).makeBlankWand()); + } + else + { + player.getInventory().addItem( + + new ItemBuilder(Material.INK_SACK, 1, (short) 5) + + .setTitle(C.cGray + "Empty wand slot" + ((Wizards) Manager.GetGame()).buildTime()) + + .addLore(C.cGray + C.Italics + "Wands can be found in chests and dead players") + + .build()); + } + } + + changeWandsTitles(player); + } + + @EventHandler + public void onMeteorHit(ProjectileHitEvent event) + { + Projectile projectile = event.getEntity(); + + if (projectile.hasMetadata("Meteor")) + { + projectile.remove(); + + CustomExplosion explosion = new CustomExplosion(getArcadeManager().GetDamage(), getArcadeManager().GetExplosion(), + projectile.getLocation(), _endgameSize, "Meteor"); + + explosion.setBlockExplosionSize(explosion.size * 1.4F); + + explosion.setFallingBlockExplosionAmount(20); + + explosion.setFallingBlockExplosion(true); + + explosion.setDropItems(false); + + explosion.setBlocksDamagedEqually(true); + + explosion.explode(); + } + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (!IsLive()) + { + event.setCancelled(true); + return; + } + + ItemStack item = event.getItem().getItemStack(); + Player p = event.getPlayer(); + + if (IsAlive(p)) + { + + if (item.getType() == Material.BLAZE_ROD) + { + if (onGainWand(p)) + { + event.setCancelled(true); + event.getItem().remove(); + } + + } + else if (getSpell(item) != null) + { + + SpellType spell = getSpell(item); + + onSpellLearn(p, spell); + + event.setCancelled(true); + event.getItem().remove(); + + } + else if (item.getType() == Material.NETHER_STAR) + { + onGainSoulStar(p); + + event.setCancelled(true); + event.getItem().remove(); + } + else + { + return; + } + + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 0.7F, 0); + } + } + + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + Player p = event.getPlayer(); + + if (IsLive() && _wizards.containsKey(p.getName())) + { + dropSpells(p); + } + + _wizards.remove(p.getName()); + } + + private void onSpellLearn(Player p, SpellType spell) + { + Wizard wiz = getWizard(p); + + int spellLevel = wiz.getSpellLevel(spell); + + if (spellLevel < spell.getMaxLevel()) + { + wiz.learnSpell(spell); + + p.sendMessage(spell.getElement().getColor() + spell.getSpellName() + C.cDGray + "> " + C.cGray + "Leveled up to " + + getWizard(p).getSpellLevel(spell)); + } + else + { + wiz.addMana(50); + p.sendMessage(C.cGold + "Wizards" + C.cDGray + "> " + C.cGray + "Spellbook converted into mana"); + } + } + + @EventHandler + public void onSwapItem(PlayerItemHeldEvent event) + { + if (!IsLive()) + { + return; + } + Player p = event.getPlayer(); + + if (!_wizards.containsKey(p.getName())) + { + return; + } + + changeWandsType(p, event.getPreviousSlot(), event.getNewSlot()); + + if (event.getNewSlot() >= 0 && event.getNewSlot() < 5) + { + drawUtilTextBottom(p); + } + else + { + // Get rid of the old wand message + if (event.getPreviousSlot() >= 0 && event.getPreviousSlot() < 5) + { + UtilTextBottom.display(C.Bold, p); + } + } + } + + @EventHandler + public void onUnplaceablePlace(BlockPlaceEvent event) + { + if (event.getPlayer().getInventory().getHeldItemSlot() < 5) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onWeaponCraft(PrepareItemCraftEvent event) + { + Recipe recipe = event.getRecipe(); + + ItemStack result = recipe != null ? recipe.getResult() : null; + + if (result != null) + { + Material mat = result.getType(); + + if (mat.name().contains("_SWORD") || mat.name().contains("_AXE")) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + + UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft weapons"); + } + else if (mat == Material.STICK || mat.name().contains("_HOE")) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + + UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft this item"); + } + else + { + for (SpellType spell : SpellType.values()) + { + if (mat == spell.getSpellItem().getType()) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + + UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft this item"); + break; + } + } + } + } + } + + @EventHandler + public void outdatedVersion(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!UtilPlayer.is1_8(player)) + returnToHub(player); + } + } + + @Override + public void ParseData() + { + CreateChestCraftEnchant(); + _endGameEvent = UtilMath.r(2); + + System.out.print("Endgame event: " + (_endGameEvent == 0 ? "Meteors" : "Lightning")); + } + + public void returnToHub(Player player) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cGold + C.Bold + "Wizards requires you to be using Minecraft 1.8!"); + UtilPlayer.message(player, " "); + + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + Manager.GetPortal().sendPlayerToServer(player, "Lobby"); + } + + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + GetScoreboard().Reset(); + + GetScoreboard().WriteBlank(); + + GetScoreboard().Write(C.cYellow + C.Bold + "Wizards"); + GetScoreboard().Write(C.cWhite + GetPlayers(true).size()); + + GetScoreboard().WriteBlank(); + + double time = UtilTime.convert(( + + (getGameLiveTime() == 0 ? System.currentTimeMillis() : getGameLiveTime()) + + + (10 * 60 * 1000)) - System.currentTimeMillis(), 1, TimeUnit.MINUTES); + + GetScoreboard().Write((time >= 0 ? C.cYellow : C.cRed) + C.Bold + (time >= 0 ? "Time Left" : "Overtime")); + GetScoreboard().Write(C.cWhite + Math.abs(time) + " Minute" + (Math.abs(time) != 1 ? "s" : "")); + + GetScoreboard().Draw(); + } + + @EventHandler + public void endGameEvent(UpdateEvent event) + { + if (!IsLive()) + { + return; + } + + if (System.currentTimeMillis() <= getGameLiveTime() + (10 * 60 * 1000)) + { + return; + } + + if (_endgameMessageCounter <= 6) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (_endGameEvent == 0) + { + if (_endgameMessageCounter == 0) + { + Announce(C.cYellow + C.Bold + "Broken is the cage, the skies scream with rage!"); + } + else if (_endgameMessageCounter == 2) + { + Announce(C.cYellow + C.Bold + "The ground trembles with fear, your doom is here!"); + } + else if (_endgameMessageCounter == 4) + { + Announce(C.cYellow + C.Bold + "Where the wizards stand, meteors strike the land!"); + } + else if (_endgameMessageCounter == 6) + { + Announce(C.cYellow + C.Bold + "Fight to the death! Fight with your dying breath!"); + } + } + else if (_endGameEvent == 1) + { + if (_endgameMessageCounter == 0) + { + Announce(C.cYellow + C.Bold + "Storm rumbles through the sky, birds fly high!"); + } + else if (_endgameMessageCounter == 2) + { + Announce(C.cYellow + C.Bold + "Lightning strikes the earth, terror given birth!"); + } + else if (_endgameMessageCounter == 4) + { + Announce(C.cYellow + C.Bold + "Lightning flickering through the air, doom is here!"); + } + else if (_endgameMessageCounter == 6) + { + Announce(C.cYellow + C.Bold + "Fight to the death! Fight with your dying breath!"); + } + } + + if (_endgameMessageCounter == 6) + { + WorldTimeSet = 0; + WorldData.World.setTime(15000); + } + + _endgameMessageCounter++; + } + else + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (_nextEndgameStrike > 750) + { + _nextEndgameStrike -= 2; + } + + if (UtilTime.elapsed(_lastEndgameStrike, _nextEndgameStrike)) + { + _lastEndgameStrike = System.currentTimeMillis(); + + if (_endGameEvent == 0) + { + makeMeteor(); + } + else if (_endGameEvent == 1) + { + makeLightning(); + } + } + + if (_lastGhastMoan < System.currentTimeMillis()) + { + Sound sound = null; + + switch (UtilMath.r(3)) + { + case 0: + sound = Sound.GHAST_MOAN; + break; + case 1: + sound = Sound.CAT_HIT; + break; + case 2: + sound = Sound.GHAST_SCREAM; + break; + default: + break; + } + + for (Player player : GetPlayers(false)) + { + player.playSound(player.getLocation(), sound, 0.7F, 0 + (UtilMath.random.nextFloat() / 10)); + } + + _lastGhastMoan = System.currentTimeMillis() + 5000 + (UtilMath.r(8) * 1000); + } + } + } + + private Location getEndgameLocation() + { + int chance = UtilMath.r(50) + 3; + int accuracy = Math.max((int) (chance - (_accuracy * chance)), 1); + _accuracy += 0.0001; + + ArrayList players = GetPlayers(true); + + for (int a = 0; a < 50; a++) + { + Player player = players.get(UtilMath.r(players.size())); + + Location location = player.getLocation().add(UtilMath.r(accuracy * 2) - accuracy, 0, + UtilMath.r(accuracy * 2) - accuracy); + + location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5); + + if (location.getBlockY() > 0 && location.getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR) + { + return location; + } + } + + return null; + } + + private void makeLightning() + { + + Location loc = getEndgameLocation(); + + if (loc == null) + { + return; + } + + loc.getWorld().spigot().strikeLightningEffect(loc, true); + loc.getWorld().playSound(loc, Sound.AMBIENCE_THUNDER, 5F, 0.8F + UtilMath.random.nextFloat()); + loc.getWorld().playSound(loc, Sound.EXPLODE, 2F, 0.9F + (UtilMath.random.nextFloat() / 3)); + + UtilBlock.getExplosionBlocks(loc, 3 * _endgameSize, false); + + // Blocks + ArrayList blocks = new ArrayList(UtilBlock.getInRadius(loc, 3 * _endgameSize).keySet()); + Collections.shuffle(blocks); + + while (blocks.size() > 20) + { + blocks.remove(0).setType(Material.AIR); + } + + Manager.GetExplosion().BlockExplosion(blocks, loc, false); + + HashMap inRadius = UtilEnt.getInRadius(loc, 4D * _endgameSize); + + // The damage done at ground zero + double baseDamage = 6 * _endgameSize; + + for (LivingEntity entity : inRadius.keySet()) + { + double damage = baseDamage * inRadius.get(entity); + + if (damage > 0) + { + getArcadeManager().GetDamage().NewDamageEvent(entity, null, null, DamageCause.LIGHTNING, damage, true, false, + true, "Lightning", "Lightning"); + } + } + } + + @EventHandler + public void preventEnchanting(EnchantItemEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void preventAnvil(InventoryClickEvent event) + { + if (event.getView().getTopInventory() != null && event.getView().getTopInventory() instanceof AnvilInventory) + { + event.setCancelled(true); + } + } + + private void makeMeteor() + { + _fireballSpeed += 0.002; + + if (_endgameSize < 10) + { + _endgameSize += 0.04; + } + + Location loc = getEndgameLocation(); + + if (loc == null) + { + return; + } + + summonMeteor(loc, 1.5F * _endgameSize); + + } + + private void summonMeteor(Location loc, float fireballSize) + { + Vector vector = new Vector(UtilMath.random.nextDouble() - 0.5D, 0.8, UtilMath.random.nextDouble() - 0.5D).normalize(); + + vector.multiply(40); + + loc.add((UtilMath.random.nextDouble() - 0.5) * 7, 0, (UtilMath.random.nextDouble() - 0.5) * 7); + + loc.add(vector); + + final Fireball fireball = (Fireball) loc.getWorld().spawnEntity(loc, EntityType.FIREBALL); + + fireball.setMetadata("Meteor", new FixedMetadataValue(getArcadeManager().getPlugin(), fireballSize)); + + new BukkitRunnable() + { + int i; + + public void run() + { + if (fireball.isValid() && IsLive()) + { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, fireball.getLocation(), 0.3F, 0.3F, 0.3F, 0, 3); + + if (i++ % 6 == 0) + { + fireball.getWorld().playSound(fireball.getLocation(), Sound.CAT_HISS, 1.3F, 0F); + } + } + else + { + cancel(); + } + } + }.runTaskTimer(getArcadeManager().getPlugin(), 0, 0); + + vector.normalize().multiply(-(0.04 + ((_fireballSpeed - 0.05) / 2))); + + // We can't call the bukkit methods because for some weird reason, it enforces a certain speed. + EntityFireball eFireball = ((CraftFireball) fireball).getHandle(); + eFireball.dirX = vector.getX(); + eFireball.dirY = vector.getY(); + eFireball.dirZ = vector.getZ(); + + fireball.setBounce(false); + fireball.setYield(0); + fireball.setIsIncendiary(true); + fireball.setFireTicks(9999); + } + + @EventHandler + public void instantDeath(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + if (!IsLive()) + return; + + if (System.currentTimeMillis() > getGameLiveTime() + (20 * 60 * 1000)) + { + ArrayList players = new ArrayList(GetPlayers(true)); + + Collections.sort(players, new Comparator() + { + + @Override + public int compare(Player o1, Player o2) + { + // Compare them backwards so the lesser health people are last + // Just so the bigger camper loses more. + return new Double(o2.getHealth()).compareTo(o1.getHealth()); + } + }); + + Iterator itel = players.iterator(); + + while (itel.hasNext()) + { + Player player = itel.next(); + + // Don't kill them if they are the last person in this list. + if (itel.hasNext()) + { + getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.ENTITY_EXPLOSION, 9999, false, + true, true, "Magic", "Magic"); + } + } + } + } + + @EventHandler + public void updateMana(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + if (!IsLive()) + { + return; + } + + for (Player player : GetPlayers(true)) + { + Wizard wizard = getWizard(player); + + float newMana = wizard.getMana(); + + if (newMana < wizard.getMaxMana()) + { + newMana = Math.min(newMana + wizard.getManaPerTick(), wizard.getMaxMana()); + wizard.setMana(newMana); + } + + float percentage = Math.min(1, wizard.getMana() / wizard.getMaxMana()); + + String text = (int) Math.floor(wizard.getMana()) + "/" + (int) wizard.getMaxMana() + " mana " + + UtilTime.convert((int) (wizard.getManaPerTick() * 20000), 1, TimeUnit.SECONDS) + "mps"; + + UtilTextTop.displayTextBar(player, percentage, text); + + drawUtilTextBottom(player); + } + + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMage.java index 5372ce4cf..72aa5c7af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMage.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.games.wizards.kit; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.kit.Kit; @@ -15,35 +13,17 @@ import org.bukkit.inventory.ItemStack; public class KitMage extends Kit { - public KitMage(ArcadeManager manager) - { - super(manager, "Mage", KitAvailability.Free, new String[] - { - "Start with two extra spells" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); - } + public KitMage(ArcadeManager manager) + { + super(manager, "Mage", KitAvailability.Free, new String[] + { + "Start with two extra spells" + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); + } - @Override - public void GiveItems(Player player) - { - for (int i = 0; i < 5; i++) - { - if (i < 2) - { - player.getInventory().addItem(((Wizards) Manager.GetGame()).makeUnusedWand()); - } - else - { - player.getInventory().addItem( - - new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 8) - - .setTitle(C.cGray + "Empty wand slot" + ((Wizards) Manager.GetGame()).buildTime()) - - .addLore(C.cGray + C.Italics + "Wands can be found in chests and on dead players") - - .build()); - } - } - } + @Override + public void GiveItems(Player player) + { + ((Wizards) this.Manager.GetGame()).setupWizard(player); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java index 7b5320365..66c2e13e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.games.wizards.kit; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.kit.Kit; @@ -15,35 +13,17 @@ import org.bukkit.inventory.ItemStack; public class KitMystic extends Kit { - public KitMystic(ArcadeManager manager) - { - super(manager, "Mystic", KitAvailability.Free, new String[] - { - "Mana regeneration increased by 10%" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); - } + public KitMystic(ArcadeManager manager) + { + super(manager, "Mystic", KitAvailability.Free, new String[] + { + "Mana regeneration increased by 10%" + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.WOOD_HOE)); + } - @Override - public void GiveItems(Player player) - { - for (int i = 0; i < 5; i++) - { - if (i < 2) - { - player.getInventory().addItem(((Wizards) Manager.GetGame()).makeUnusedWand()); - } - else - { - player.getInventory().addItem( - - new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 8) - - .setTitle(C.cGray + "Empty wand slot" + ((Wizards) Manager.GetGame()).buildTime()) - - .addLore(C.cGray + C.Italics + "Wands can be found in chests and on dead players") - - .build()); - } - } - } + @Override + public void GiveItems(Player player) + { + ((Wizards) this.Manager.GetGame()).setupWizard(player); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java index 0ed52b42d..d8497fa81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.games.wizards.kit; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.kit.Kit; @@ -15,35 +13,17 @@ import org.bukkit.inventory.ItemStack; public class KitSorcerer extends Kit { - public KitSorcerer(ArcadeManager manager) - { - super(manager, "Sorcerer", KitAvailability.Free, new String[] - { - "Start out with an extra wand" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); - } + public KitSorcerer(ArcadeManager manager) + { + super(manager, "Sorcerer", KitAvailability.Free, new String[] + { + "Start out with an extra wand" + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.STONE_HOE)); + } - @Override - public void GiveItems(Player player) - { - for (int i = 0; i < 5; i++) - { - if (i < 3) - { - player.getInventory().addItem(((Wizards) Manager.GetGame()).makeUnusedWand()); - } - else - { - player.getInventory().addItem( - - new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 8) - - .setTitle(C.cGray + "Empty wand slot" + ((Wizards) Manager.GetGame()).buildTime()) - - .addLore(C.cGray + C.Italics + "Wands can be found in chests and on dead players") - - .build()); - } - } - } + @Override + public void GiveItems(Player player) + { + ((Wizards) this.Manager.GetGame()).setupWizard(player); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java index 5ae610300..570fc9540 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java @@ -1,8 +1,6 @@ package nautilus.game.arcade.game.games.wizards.kit; import mineplex.core.achievement.Achievement; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.kit.Kit; @@ -16,40 +14,22 @@ import org.bukkit.inventory.ItemStack; public class KitWitchDoctor extends Kit { - public KitWitchDoctor(ArcadeManager manager) - { - super(manager, "Witch Doctor", KitAvailability.Free, new String[] - { - "Max mana increased to 150" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); + public KitWitchDoctor(ArcadeManager manager) + { + super(manager, "Witch Doctor", KitAvailability.Free, new String[] + { + "Max mana increased to 150" + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.IRON_HOE)); - this.setAchievementRequirements(new Achievement[] - { - Achievement.BACON_BRAWL_WINS - }); - } + this.setAchievementRequirements(new Achievement[] + { + Achievement.BACON_BRAWL_WINS + }); + } - @Override - public void GiveItems(Player player) - { - for (int i = 0; i < 5; i++) - { - if (i < 2) - { - player.getInventory().addItem(((Wizards) Manager.GetGame()).makeUnusedWand()); - } - else - { - player.getInventory().addItem( - - new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 8) - - .setTitle(C.cGray + "Empty wand slot" + ((Wizards) Manager.GetGame()).buildTime()) - - .addLore(C.cGray + C.Italics + "Wands can be found in chests and on dead players") - - .build()); - } - } - } + @Override + public void GiveItems(Player player) + { + ((Wizards) this.Manager.GetGame()).setupWizard(player); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellAnvilDrop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellAnvilDrop.java new file mode 100644 index 000000000..26486168e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellAnvilDrop.java @@ -0,0 +1,138 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.minecraft.game.core.explosion.CustomExplosion; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.metadata.FixedMetadataValue; + +public class SpellAnvilDrop extends Spell implements SpellClick +{ + private ArrayList _fallingBlocks = new ArrayList(); + + @Override + public void castSpell(Player player) + { + ArrayList players = new ArrayList(); + players.add(player); + int radius = 4 + (getSpellLevel(player) * 2); + + for (Entity entity : player.getNearbyEntities(radius, radius * 3, radius)) + { + if (entity instanceof Player && Wizards.IsAlive(entity)) + { + players.add((Player) entity); + } + } + + ArrayList newFallingBlocks = new ArrayList(); + + for (Player p : players) + { + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, p.getLocation(), 0, 0, 0, 0, 1); + + Location loc = p.getLocation().clone().add(0, 15 + (getSpellLevel(player) * 3), 0); + int lowered = 0; + + while (lowered < 5 && loc.getBlock().getType() != Material.AIR) + { + lowered++; + loc = loc.add(0, -1, 0); + } + + if (loc.getBlock().getType() == Material.AIR) + { + + FallingBlock anvil = p.getWorld().spawnFallingBlock(loc.getBlock().getLocation().add(0.5, 0.5, 0.5), + Material.ANVIL, (byte) 0); + + anvil.setMetadata("SpellLevel", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), + getSpellLevel(player))); + + anvil.setMetadata("Wizard", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), player)); + + anvil.getWorld().playSound(anvil.getLocation(), Sound.ANVIL_USE, 1.9F, 0); + + newFallingBlocks.add(anvil); + + } + + } + + if (!newFallingBlocks.isEmpty()) + { + _fallingBlocks.addAll(newFallingBlocks); + charge(player); + } + } + + private void handleAnvil(Entity entity) + { + _fallingBlocks.remove(entity); + + int spellLevel = entity.getMetadata("SpellLevel").get(0).asInt(); + + CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager() + .GetExplosion(), entity.getLocation(), 1 + (spellLevel / 2F), "Anvil Drop"); + + explosion.setPlayer((Player) entity.getMetadata("Wizard").get(0).value(), true); + + explosion.setFallingBlockExplosion(true); + + explosion.setDropItems(false); + + explosion.setMaxDamage(6 + (spellLevel * 4)); + + explosion.explode(); + + entity.remove(); + } + + @EventHandler + public void onDrop(ItemSpawnEvent event) + { + Iterator itel = _fallingBlocks.iterator(); + FallingBlock b = null; + + while (itel.hasNext()) + { + FallingBlock block = itel.next(); + + if (block.isDead()) + { + b = block; + break; + } + } + + if (b != null) + { + event.setCancelled(true); + handleAnvil(b); + } + } + + @EventHandler + public void onPlace(EntityChangeBlockEvent event) + { + if (_fallingBlocks.contains(event.getEntity())) + { + handleAnvil(event.getEntity()); + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellBridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellBridge.java deleted file mode 100644 index 0a83385d6..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellBridge.java +++ /dev/null @@ -1,102 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilShapes; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; - -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.scheduler.BukkitRunnable; - -public class SpellBridge extends Spell implements SpellClickBlock -{ - final BlockFace[] radial = - { - BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, - BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST - }; - private HashMap _wallExpires = new HashMap(); - - @EventHandler - public void onUpdate(UpdateEvent event) - { - Iterator> itel = _wallExpires.entrySet().iterator(); - - while (itel.hasNext()) - { - Entry entry = itel.next(); - - if (entry.getValue() < System.currentTimeMillis()) - { - itel.remove(); - - if (entry.getKey().getType() == Material.DIRT) - { - entry.getKey().setType(Material.AIR); - } - } - } - } - - @Override - public void castSpell(Player p, final Block target) - { - final BlockFace facing = radial[Math.round(p.getEyeLocation().getYaw() / 45f) & 0x7]; - - p.getWorld().playEffect(target.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId()); - - final int maxDist = 10 * getSpellLevel(p); - - new BukkitRunnable() - { - Block block = target; - int blocks = 0; - - @Override - public void run() - { - if (!Wizards.IsLive() || blocks++ >= maxDist) - { - cancel(); - return; - } - - block = block.getRelative(facing); - Block bs[] = UtilShapes.getSideBlocks(block, facing); - - bs = new Block[] - { - bs[0], bs[1], block - }; - - for (Block b : bs) - { - if (UtilBlock.solid(b)) - { - continue; - } - - b.setType(Material.DIRT); - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); - - _wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); - } - - } - }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 1); - - charge(p); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellDrain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellDrain.java deleted file mode 100644 index 9acf218ee..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellDrain.java +++ /dev/null @@ -1,35 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.Wizard; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; - -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public class SpellDrain extends Spell implements SpellClickEntity -{ - - @Override - public void castSpell(Player player, Entity entity) - { - if (entity instanceof Player) - { - if (Wizards.IsAlive(entity)) - { - - Wizard wiz = Wizards.getWizard((Player) entity); - - if (wiz.getMana() > 10) - { - wiz.setMana(0); - - player.getWorld().playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0); - - charge(player); - } - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellDroom.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellDroom.java deleted file mode 100644 index e5dda6b10..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellDroom.java +++ /dev/null @@ -1,128 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.ArrayList; -import java.util.Iterator; - -import mineplex.minecraft.game.core.explosion.CustomExplosion; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityChangeBlockEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.metadata.FixedMetadataValue; - -public class SpellDroom extends Spell implements SpellClick -{ - private ArrayList _fallingBlocks = new ArrayList(); - - @Override - public void castSpell(Player player) - { - ArrayList players = new ArrayList(); - players.add(player); - int radius = 4 + (getSpellLevel(player) * 2); - - for (Entity entity : player.getNearbyEntities(radius, radius * 3, radius)) - { - if (entity instanceof Player && Wizards.IsAlive(entity)) - { - players.add((Player) entity); - } - } - - ArrayList newFallingBlocks = new ArrayList(); - - for (Player p : players) - { - Location loc = p.getLocation().clone().add(0, 15 + (getSpellLevel(player) * 3), 0); - int lowered = 0; - - while (lowered < 5 && loc.getBlock().getType() != Material.AIR) - { - lowered++; - loc = loc.add(0, -1, 0); - } - - if (loc.getBlock().getType() == Material.AIR) - { - - FallingBlock anvil = p.getWorld().spawnFallingBlock(loc.getBlock().getLocation().add(0.5, 0.5, 0.5), - Material.ANVIL, (byte) 0); - - anvil.setMetadata("ExplosionSize", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), - 1 + (getSpellLevel(player) / 2F))); - - anvil.setMetadata("Wizard", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), player)); - - anvil.getWorld().playSound(anvil.getLocation(), Sound.ANVIL_USE, 1.9F, 0); - - newFallingBlocks.add(anvil); - - } - - } - - if (!newFallingBlocks.isEmpty()) - { - _fallingBlocks.addAll(newFallingBlocks); - charge(player); - } - } - - private void handleAnvil(Entity entity) - { - _fallingBlocks.remove(entity); - - CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), entity.getLocation(), - (float) entity.getMetadata("ExplosionSize").get(0).asDouble(), "Droom"); - - explosion.setPlayer((Player) entity.getMetadata("Wizard").get(0).value(), true); - - explosion.setDropItems(false); - - explosion.explode(); - - entity.remove(); - } - - @EventHandler - public void onDrop(ItemSpawnEvent event) - { - Iterator itel = _fallingBlocks.iterator(); - FallingBlock b = null; - - while (itel.hasNext()) - { - FallingBlock block = itel.next(); - - if (block.isDead()) - { - b = block; - break; - } - } - - if (b != null) - { - event.setCancelled(true); - handleAnvil(b); - } - } - - @EventHandler - public void onPlace(EntityChangeBlockEvent event) - { - if (_fallingBlocks.contains(event.getEntity())) - { - handleAnvil(event.getEntity()); - event.setCancelled(true); - } - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellExplosiveRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellExplosiveRune.java deleted file mode 100644 index 1bda5fc75..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellExplosiveRune.java +++ /dev/null @@ -1,79 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; -import nautilus.game.arcade.game.games.wizards.spells.subclasses.ExplosiveRune; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - -public class SpellExplosiveRune extends Spell implements SpellClick -{ - private ArrayList _explosiveRunes = new ArrayList(); - - @Override - public void castSpell(Player p) - { - Vector vector = p.getEyeLocation().getDirection(); - vector.normalize().multiply(0.5); - - float trapSize = Math.max(1, 1 + getSpellLevel(p)); - - List list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (int) ((trapSize * 4) + 12)); - - if (list.size() > 1) - { - Location loc = list.get(0).getLocation().add(0.5, 0, 0.5); - - ExplosiveRune rune = new ExplosiveRune(Wizards.getArcadeManager().GetDamage(), loc, p, trapSize); - - if (!isValid(rune)) - { - p.sendMessage(C.cGreen + "Cannot draw rune on wall"); - return; - } - - _explosiveRunes.add(rune); - charge(p); - } - } - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK) - { - Iterator itel = _explosiveRunes.iterator(); - - while (itel.hasNext()) - { - - ExplosiveRune rune = itel.next(); - - if (rune.onTick()) - { - itel.remove(); - } - - } - } - } - - private boolean isValid(ExplosiveRune rune) - { - return !UtilBlock.solid(rune.getLocation().getBlock()) - || UtilBlock.solid(rune.getLocation().getBlock().getRelative(BlockFace.DOWN)); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFireball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFireball.java index fbc442780..7bcb923ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFireball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFireball.java @@ -18,49 +18,53 @@ import org.bukkit.util.Vector; public class SpellFireball extends Spell implements SpellClick { - @EventHandler - public void onHit(ProjectileHitEvent event) - { - Projectile projectile = event.getEntity(); - if (projectile.hasMetadata("FireballSpell")) - { - projectile.remove(); + @EventHandler + public void onHit(ProjectileHitEvent event) + { + Projectile projectile = event.getEntity(); - CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), projectile.getLocation(), - projectile.getMetadata("FireballYield").get(0).asFloat(), "Fireball"); + if (projectile.hasMetadata("FireballSpell")) + { + projectile.remove(); - explosion.setPlayer((Player) projectile.getMetadata("FireballSpell").get(0).value(), true); + int spellLevel = projectile.getMetadata("SpellLevel").get(0).asInt(); - explosion.setDropItems(false); + CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager() + .GetExplosion(), projectile.getLocation(), (spellLevel * 0.3F) + 1F, "Fireball"); - explosion.explode(); + explosion.setPlayer((Player) projectile.getMetadata("FireballSpell").get(0).value(), true); - } - } + explosion.setFallingBlockExplosion(true); - @Override - public void castSpell(Player p) - { - org.bukkit.entity.Fireball fireball = (org.bukkit.entity.Fireball) p.getWorld().spawnEntity(p.getEyeLocation(), - EntityType.FIREBALL); + explosion.setDropItems(false); - Vector vector = p.getEyeLocation().getDirection().normalize().multiply(0.14); + explosion.setMaxDamage(spellLevel + 6); - // We can't call the bukkit methods because for some weird reason, it enforces a certain speed. - EntityFireball eFireball = ((CraftFireball) fireball).getHandle(); - eFireball.dirX = vector.getX(); - eFireball.dirY = vector.getY(); - eFireball.dirZ = vector.getZ(); + explosion.explode(); + } + } - fireball.setBounce(false); - fireball.setShooter(p); - fireball.setYield(0); - fireball.setMetadata("FireballSpell", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), p)); - fireball.setMetadata("FireballYield", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), - (getSpellLevel(p) * 0.25F) + 0.8F)); + @Override + public void castSpell(Player p) + { + org.bukkit.entity.Fireball fireball = (org.bukkit.entity.Fireball) p.getWorld().spawnEntity(p.getEyeLocation(), + EntityType.FIREBALL); - p.getWorld().playSound(p.getLocation(), Sound.BLAZE_BREATH, 0.5F, 5F); - charge(p); - } + Vector vector = p.getEyeLocation().getDirection().normalize().multiply(0.14); + // We can't call the bukkit methods because for some weird reason, it enforces a certain speed. + EntityFireball eFireball = ((CraftFireball) fireball).getHandle(); + eFireball.dirX = vector.getX(); + eFireball.dirY = vector.getY(); + eFireball.dirZ = vector.getZ(); + + fireball.setBounce(false); + fireball.setShooter(p); + fireball.setYield(0); + fireball.setMetadata("FireballSpell", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), p)); + fireball.setMetadata("SpellLevel", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), getSpellLevel(p))); + + p.getWorld().playSound(p.getLocation(), Sound.BLAZE_BREATH, 0.5F, 5F); + charge(p); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFlash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFlash.java index c7b1407cd..f20eec657 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFlash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFlash.java @@ -1,48 +1,69 @@ package nautilus.game.arcade.game.games.wizards.spells; -import java.util.List; - import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import org.bukkit.Effect; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; public class SpellFlash extends Spell implements SpellClick { - @Override - public void castSpell(Player player) - { - int maxTeleportDistance = 20 + (10 * getSpellLevel(player)); - - List list = player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, maxTeleportDistance); - - if (list.size() > 1 && list.get(1).getType() != Material.AIR) - { - Block b = list.get(0); - - if (b.getLocation().distance(player.getLocation()) > 2) - { - - Location loc = b.getLocation().clone().add(0.5, 0.5, 0.5); - - player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F); - player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9); - - player.setFallDistance(0); - player.teleport(loc); - - player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F); - player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9); - - charge(player); - - } - } - } + @Override + public void castSpell(Player player) + { + int maxRange = 20 + (10 * getSpellLevel(player)); + + double curRange = 0; + + while (curRange <= maxRange) + { + Location newTarget = player.getEyeLocation().add(new Vector(0, 0.2, 0)) + .add(player.getLocation().getDirection().multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock()) + || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) + break; + + // Progress Forwards + curRange += 0.2; + + // Smoke Trail + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1); + } + + // Modify Range + curRange -= 0.4; + if (curRange < 0) + curRange = 0; + + // Destination + Location loc = player.getEyeLocation().add(new Vector(0, 0.2, 0)) + .add(player.getLocation().getDirection().multiply(curRange)).add(new Vector(0, 0.4, 0)); + + if (curRange > 0) + { + + player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F); + player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9); + + player.setFallDistance(0); + + player.eject(); + player.leaveVehicle(); + + player.teleport(loc); + + player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F); + player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9); + + charge(player); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFrostBarrier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFrostBarrier.java new file mode 100644 index 000000000..5e78ee191 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellFrostBarrier.java @@ -0,0 +1,140 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.scheduler.BukkitRunnable; + +public class SpellFrostBarrier extends Spell implements SpellClick, SpellClickBlock +{ + private HashMap _wallExpires = new HashMap(); + + @Override + public void castSpell(Player player) + { + Location loc = player.getLocation().add(player.getLocation().getDirection().setY(0).normalize().multiply(1.5)); + + castSpell(player, loc.getBlock().getRelative(BlockFace.DOWN)); + } + + @Override + public void castSpell(Player player, Block block) + { + final Block starter = block.getRelative(BlockFace.UP); + final int wallWidth = 4 + (getSpellLevel(player) * 2); + final BlockFace facing = UtilShapes.getFacing(player.getEyeLocation().getYaw()); + final int wallHeight = 1 + getSpellLevel(player); + + new BukkitRunnable() + { + Block block = starter; + int currentRun; + + @Override + public void run() + { + + currentRun++; + + BlockFace[] faces = UtilShapes.getCornerBlockFaces(block, facing); + + if (block.getType() == Material.AIR) + { + block.setTypeIdAndData(Material.ICE.getId(), (byte) 0, false); + _wallExpires.put(block, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); + } + + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + + for (BlockFace face : faces) + { + for (int i = 1; i < wallWidth; i++) + { + + Block b = block.getRelative(face.getModX() * i, 0, face.getModZ() * i); + + if (!UtilBlock.airFoliage(b)) + break; + + b.setTypeIdAndData(Material.ICE.getId(), (byte) 0, false); + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); + + _wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); + } + } + + block = block.getRelative(BlockFace.UP); + if (currentRun >= wallHeight) + { + cancel(); + } + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 5); + + charge(player); + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + Block block = event.getBlock(); + + if (_wallExpires.containsKey(block)) + { + event.setCancelled(true); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + block.setType(Material.AIR); + } + } + + @EventHandler + public void onBlockMelt(BlockFadeEvent event) + { + Block block = event.getBlock(); + + if (_wallExpires.containsKey(block)) + { + event.setCancelled(true); + block.setType(Material.AIR); + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + Iterator> itel = _wallExpires.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (entry.getValue() < System.currentTimeMillis()) + { + itel.remove(); + + if (entry.getKey().getType() == Material.ICE) + { + entry.getKey().setType(Material.AIR); + } + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java new file mode 100644 index 000000000..da0c492d1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellGust.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class SpellGust extends Spell implements SpellClick +{ + + @Override + public void castSpell(final Player player) + { + final Vector vector = player.getLocation().getDirection().setY(0).normalize().multiply(1.5).setY(0.3) + .multiply(1.2 + (getSpellLevel(player) * 0.4D)); + + final HashMap effected = UtilPlayer.getPlayersInPyramid(player, 45, 10 * getSpellLevel(player)); + + if (!effected.isEmpty()) + { + charge(player); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() + { + public void run() + { + for (Player target : effected.keySet()) + { + if (!Wizards.IsAlive(target)) + { + continue; + } + + Wizards.getArcadeManager().GetCondition().Factory().Falling("Gust", target, player, 10, false, true); + + target.setVelocity(vector); + + target.getWorld().playSound(target.getLocation(), Sound.BAT_TAKEOFF, 1, 0.7F); + } + + player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1, 0.7F); + } + }); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHeal.java index 5cc960576..06e82bcf1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHeal.java @@ -2,42 +2,27 @@ package nautilus.game.arcade.game.games.wizards.spells; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; - import org.bukkit.Effect; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -public class SpellHeal extends Spell implements SpellClick, SpellClickEntity +public class SpellHeal extends Spell implements SpellClick { - @Override - public void castSpell(Player p) - { - castSpell(p, p); - } + @Override + public void castSpell(Player p) + { + if (p.getHealth() < p.getMaxHealth()) + { + double health = p.getHealth() + (3 + getSpellLevel(p)); - @Override - public void castSpell(Player p, Entity target) - { - if (!(target instanceof LivingEntity)) - return; + if (health > p.getMaxHealth()) + health = p.getMaxHealth(); - LivingEntity entity = (LivingEntity) target; + p.setHealth(health); - if (entity.getHealth() < entity.getMaxHealth()) - { - double health = entity.getHealth() + (3 + getSpellLevel(p)); + p.getWorld().spigot().playEffect(p.getEyeLocation(), Effect.HEART, 0, 0, 0.8F, 0.4F, 0.8F, 0, 6, 30); - if (health > entity.getMaxHealth()) - health = entity.getMaxHealth(); - - entity.setHealth(health); - - entity.getWorld().spigot().playEffect(entity.getEyeLocation(), Effect.HEART, 0, 0, 0.8F, 0.4F, 0.8F, 0, 6, 30); - - charge(p); - } - } + charge(p); + } + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHealingRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHealingRune.java deleted file mode 100644 index 7c755bf45..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellHealingRune.java +++ /dev/null @@ -1,70 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.ArrayList; -import java.util.Iterator; - -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; -import nautilus.game.arcade.game.games.wizards.spells.subclasses.HealingRune; - -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -public class SpellHealingRune extends Spell implements SpellClick -{ - private ArrayList _healingRunes = new ArrayList(); - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK) - { - Iterator itel = _healingRunes.iterator(); - - while (itel.hasNext()) - { - HealingRune rune = itel.next(); - - if (rune.onTick()) - { - itel.remove(); - } - } - } - } - - @Override - public void castSpell(Player player) - { - Block b = player.getTargetBlock(null, 25 * getSpellLevel(player)); - - while (b.getType() != Material.AIR && b.getY() < 250) - { - b = b.getRelative(BlockFace.UP); - } - - if (b.getRelative(BlockFace.DOWN).getType() == Material.AIR) - { - player.sendMessage(ChatColor.RED + "Unable to place a rune!"); - return; - } - - Location firstTeleport = player.getLocation(); - - firstTeleport.setY(firstTeleport.getBlockY()); - - HealingRune healingRune = new HealingRune(Wizards, firstTeleport, getSpellLevel(player)); - - _healingRunes.add(healingRune); - - charge(player); - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java new file mode 100644 index 000000000..baabb5ae0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIcePrison.java @@ -0,0 +1,149 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.metadata.FixedMetadataValue; + +public class SpellIcePrison extends Spell implements SpellClick, IThrown +{ + + private HashMap _prisonExpires = new HashMap(); + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + Block block = event.getBlock(); + + if (_prisonExpires.containsKey(block)) + { + event.setCancelled(true); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + block.setType(Material.AIR); + } + } + + @EventHandler + public void onBlockMelt(BlockFadeEvent event) + { + Block block = event.getBlock(); + + if (_prisonExpires.containsKey(block)) + { + event.setCancelled(true); + block.setType(Material.AIR); + } + } + + @Override + public void castSpell(final Player player) + { + shoot(player, getSpellLevel(player)); + + charge(player); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target != data.GetThrower()) + { + IcePrison(data); + } + } + + @Override + public void Expire(ProjectileUser data) + { + IcePrison(data); + } + + public void IcePrison(ProjectileUser data) + { + Location loc = data.GetThrown().getLocation(); + data.GetThrown().remove(); + + HashMap blocks = UtilBlock.getInRadius(loc.getBlock(), + data.GetThrown().getMetadata("PrisonStrength").get(0).asDouble(), true); + + for (Block block : blocks.keySet()) + { + if (_prisonExpires.containsKey(block) || UtilBlock.airFoliage(block)) + { + block.setType(Material.ICE); + + _prisonExpires.put(block, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); + } + } + + // Effect + loc.getWorld().playSound(loc, Sound.SILVERFISH_HIT, 2f, 1f); + } + + @Override + public void Idle(ProjectileUser data) + { + IcePrison(data); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + Iterator> itel = _prisonExpires.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (entry.getValue() < System.currentTimeMillis()) + { + itel.remove(); + + if (entry.getKey().getType() == Material.ICE) + { + entry.getKey().setType(Material.AIR); + } + } + } + } + + private void shoot(Player player, int spellLevel) + { + + if (Wizards.IsAlive(player)) + { + org.bukkit.entity.Item ent = player.getWorld().dropItem( + player.getEyeLocation(), + ItemStackFactory.Instance.CreateStack(Material.PACKED_ICE, (byte) 0, 1, "Ice Prison" + player.getName() + " " + + System.currentTimeMillis())); + + ent.setMetadata("PrisonStrength", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), 3 + spellLevel)); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 1.7, false, 0, 0.2, 10, false); + Wizards.getArcadeManager().GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 2f); + + player.getWorld().playSound(player.getLocation(), Sound.CREEPER_HISS, 1.2F, 0.8F); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java new file mode 100644 index 000000000..f293d3c25 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java @@ -0,0 +1,152 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class SpellIceShards extends Spell implements SpellClick, IThrown +{ + private HashMap _lastParticles = new HashMap(); + + @Override + public void castSpell(final Player player) + { + shoot(player); + + for (int i = 1; i <= getSpellLevel(player); i++) + { + + Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() + { + + @Override + public void run() + { + shoot(player); + } + + }, i * 5); + } + + charge(player); + } + + private void shoot(Player player) + { + + if (Wizards.IsAlive(player)) + { + // Boost + + org.bukkit.entity.Item ent = player.getWorld().dropItem( + player.getEyeLocation(), + ItemStackFactory.Instance.CreateStack(Material.GHAST_TEAR, (byte) 0, 1, "Ice Shard " + player.getName() + " " + + System.currentTimeMillis())); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 2, false, 0, 0.2, 10, false); + Wizards.getArcadeManager().GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 2f); + + player.getWorld().playSound(player.getLocation(), Sound.CLICK, 1.2F, 0.8F); + + _lastParticles.put(ent, ent.getLocation()); + + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target != null && target instanceof Player) + { + + // Damage Event + Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 4 /*+ (timesHit * 2)*/, true, true, + false, "Ice Shard", "Ice Shard"); + + } + + handleShard(data); + } + + private void handleShard(ProjectileUser data) + { + data.GetThrown().remove(); + Location loc = data.GetThrown().getLocation(); + + UtilParticle.PlayParticle(ParticleType.BLOCK_CRACK.getParticle(Material.PACKED_ICE, 0), loc, 0.3F, 0.3F, 0.3F, 0, 12); + loc.getWorld().playSound(loc, Sound.GLASS, 1.2F, 1); + + for (int x = -1; x <= 1; x++) + { + for (int y = -1; y <= 1; y++) + { + for (int z = -1; z <= 1; z++) + { + Block block = loc.clone().add(x, y, z).getBlock(); + + if (block.getType() == Material.FIRE) + { + block.setType(Material.AIR); + } + } + } + } + + _lastParticles.remove(data.GetThrown()); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Entity entity : _lastParticles.keySet()) + { + for (Location loc : UtilShapes.getLinesDistancedPoints(_lastParticles.get(entity), entity.getLocation(), 0.3)) + { + UtilParticle.PlayParticle(ParticleType.BLOCK_CRACK.getParticle(Material.PACKED_ICE, 0), loc, 0, 0, 0, 0, 1); + } + + _lastParticles.put(entity, entity.getLocation()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + handleShard(data); + } + + @Override + public void Expire(ProjectileUser data) + { + handleShard(data); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java index 760f7ab89..592e55b16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java @@ -1,8 +1,15 @@ package nautilus.game.arcade.game.games.wizards.spells; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; import java.util.List; +import java.util.Random; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; @@ -12,74 +19,143 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryHolder; +import org.bukkit.scheduler.BukkitRunnable; public class SpellImplode extends Spell implements SpellClick { - @Override - public void castSpell(Player p) - { - List list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 50); + @Override + public void castSpell(final Player p) + { + List list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 50); - if (list.size() > 1) - { - BlockFace face = list.get(0).getFace(list.get(1)); + if (list.size() > 1) + { - Block centerBlock = list.get(0); + Block centerBlock = list.get(0); - int maxDist = (int) Math.floor(centerBlock.getLocation().distance(p.getLocation().getBlock().getLocation())) / 2; + final Location centerLocation = centerBlock.getLocation().clone().add(0.5, 0.5, 0.5); + final ArrayList effectedBlocks = new ArrayList(); + int size = (int) (1.5F + (getSpellLevel(p) * 0.7F)); - for (int i = 0; i < Math.min(maxDist, getSpellLevel(p) * 2); i++) - { - if (centerBlock.getRelative(face) != null) - { - centerBlock = centerBlock.getRelative(face); - } - } + for (int x = -size * 2; x <= size * 2; x++) + { + for (int y = -size * 2; y <= size * 2; y++) + { + for (int z = -size * 2; z <= size * 2; z++) + { + Block effectedBlock = centerBlock.getRelative(x, y, z); - Location centerLocation = centerBlock.getLocation().clone().add(0.5, 0.5, 0.5); - int size = (int) (1.5F + (getSpellLevel(p) * 0.7F)); + if (effectedBlock.getType() == Material.AIR || effectedBlock.getType() == Material.BEDROCK + || effectedBlocks.contains(effectedBlock)) + { + continue; + } - for (int x = -size * 2; x <= size * 2; x++) - { - for (int y = -size; y <= size; y++) - { - for (int z = -size * 2; z <= size * 2; z++) - { - Block effectedBlock = centerBlock.getRelative(x, y, z); + if ((centerLocation.distance(effectedBlock.getLocation().add(0.5, 0.5, 0.5)) + Math.abs(y / 4D)) - if (effectedBlock.getLocation().distance(centerBlock.getLocation()) <= size * 2 - && !(effectedBlock.getState() instanceof InventoryHolder)) - { + <= ((size * 2) + UtilMath.random.nextFloat()) - if (effectedBlock.getType() == Material.BEDROCK) - { - continue; - } + && !(effectedBlock.getState() instanceof InventoryHolder)) + { - FallingBlock block = effectedBlock.getWorld().spawnFallingBlock(effectedBlock.getLocation(), - effectedBlock.getType(), effectedBlock.getData()); + effectedBlocks.add(effectedBlock); + } + } + } + } - block.setVelocity(centerLocation.toVector() - .subtract(effectedBlock.getLocation().add(0.5, 0.5, 0.5).toVector()).normalize()); + Collections.shuffle(effectedBlocks); - block.setDropItem(false); + new BukkitRunnable() + { + int timesRan; + Iterator bItel; - effectedBlock.setType(Material.AIR); - } - } - } - } + public void run() + { + { + Block block = effectedBlocks.get(UtilMath.r(effectedBlocks.size())); + block.getWorld().playSound(block.getLocation(), + new Random().nextBoolean() ? Sound.DIG_GRAVEL : Sound.DIG_GRASS, 2, + UtilMath.random.nextFloat() / 4); + } - for (Player player : Bukkit.getOnlinePlayers()) - { - player.playSound(player == p ? p.getLocation() : centerBlock.getLocation(), Sound.ENDERDRAGON_GROWL, 1.5F, 1.5F); - } + if (timesRan % 3 == 0) + { + for (int a = 0; a < Math.ceil(effectedBlocks.size() / 3D); a++) + { + if (bItel == null || !bItel.hasNext()) + { + bItel = effectedBlocks.iterator(); + } - charge(p); - } - } + Block block = bItel.next(); + + if (block.getType() == Material.AIR) + { + continue; + } + + for (int i = 0; i < 6; i++) + { + BlockFace face = BlockFace.values()[i]; + + Block b = block.getRelative(face); + + if (UtilBlock.airFoliage(b)) + { + UtilParticle.PlayParticle( + ParticleType.BLOCK_CRACK.getParticle(block.getType(), block.getData()), + + block.getLocation().add( + + 0.5 + (face.getModX() * 0.6D), + + 0.5 + (face.getModY() * 0.6D), + + 0.5 + (face.getModZ() * 0.6D)), + + face.getModX() / 2F, face.getModX() / 2F, face.getModX() / 2F, 0, 6); + } + } + } + } + + if (effectedBlocks.isEmpty()) + { + cancel(); + } + else if (timesRan++ >= 20) + { + Iterator itel = effectedBlocks.iterator(); + + while (itel.hasNext()) + { + Block block = itel.next(); + + if (block.getType() == Material.AIR || block.getState() instanceof InventoryHolder) + { + itel.remove(); + continue; + } + } + + Wizards.getArcadeManager().GetExplosion().BlockExplosion(effectedBlocks, centerLocation, false); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player == p ? p.getLocation() : centerLocation, Sound.ENDERDRAGON_GROWL, 1.5F, 1.5F); + } + + cancel(); + } + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0); + + charge(p); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLance.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLance.java deleted file mode 100644 index 68928a930..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLance.java +++ /dev/null @@ -1,101 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilShapes; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.explosion.CustomExplosion; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -public class SpellLance extends Spell implements SpellClick -{ - private ArrayList, Player>> _locations = new ArrayList, Player>>(); - - @Override - public void castSpell(Player player) - { - // Player p = UtilPlayer.getPlayerInSight(player, 10 * getSpellLevel(player), true); - Location l = null; - // if (p == null) - // { - List b = player.getLastTwoTargetBlocks(UtilBlock.blockPassSet, 6 * getSpellLevel(player)); - if (!b.isEmpty()) - l = b.get(0).getLocation().add(0.5, 0.5, 0.5).add(player.getEyeLocation().getDirection().normalize().multiply(2)); - /* } - else - { - l = p.getEyeLocation(); - }*/ - if (l != null) - { - ArrayList locs = UtilShapes.getLinesDistancedPoints(player.getLocation(), l, 1.5); - - Iterator itel = locs.iterator(); - while (itel.hasNext()) - { - Location loc = itel.next(); - - if (loc.distance(player.getLocation()) <= 1.5) - { - itel.remove(); - } - } - - if (!locs.isEmpty()) - { - charge(player); - - explode(locs.remove(0), player); - - if (!locs.isEmpty()) - { - _locations.add(new HashMap.SimpleEntry(locs, player)); - } - } - } - } - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK) - { - Iterator, Player>> itel = _locations.iterator(); - while (itel.hasNext()) - { - Entry, Player> next = itel.next(); - explode(next.getKey().remove(0), next.getValue()); - - if (next.getKey().isEmpty()) - { - itel.remove(); - } - } - } - } - - private void explode(Location loc, Player player) - { - CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), loc, 1.2F, "Lance"); - - explosion.setPlayer(player, false); - - explosion.setDropItems(false); - - explosion.setIgnoreRate(false); - - explosion.explode(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLaunch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLaunch.java deleted file mode 100644 index 886a5986a..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLaunch.java +++ /dev/null @@ -1,40 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickEntity; - -import org.bukkit.Bukkit; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class SpellLaunch extends Spell implements SpellClickEntity -{ - - @Override - public void castSpell(Player player, final Entity entity) - { - if (entity instanceof LivingEntity) - { - - Wizards.getArcadeManager().GetCondition().Factory() - .Falling("Launch", (LivingEntity) entity, player, 10, false, false); - - final int spellLevel = getSpellLevel(player); - - Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() - { - public void run() - { - ((LivingEntity) entity).setVelocity(new Vector(0, 1F + (spellLevel * 0.15F), 0)); - entity.getWorld().playSound(((LivingEntity) entity).getLocation(), Sound.BAT_TAKEOFF, 2, 0); - entity.setFallDistance(-spellLevel * 1.5F); - } - }); - - charge(player); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLaunchRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLaunchRune.java deleted file mode 100644 index a08fd13c7..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLaunchRune.java +++ /dev/null @@ -1,100 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.ArrayList; -import java.util.Iterator; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; -import nautilus.game.arcade.game.games.wizards.spells.subclasses.LaunchRune; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - -public class SpellLaunchRune extends Spell implements SpellClick -{ - private ArrayList _launchRunes = new ArrayList(); - - @Override - public void castSpell(Player p) - { - Vector vector = p.getEyeLocation().getDirection(); - vector.normalize().multiply(0.5); - - Vector v = p.getEyeLocation().toVector(); - int i = 0; - Location loc = null; - int spellLevel = getSpellLevel(p); - final float trapSize = Math.max(1, spellLevel * 0.8F); - - while (i++ < (trapSize * 4) + 12) - { - v.add(vector); - - Block b = v.toLocation(p.getWorld()).getBlock(); - - if (UtilBlock.solid(b)) - { - while (UtilBlock.solid(b)) - { - - double dist = Math.sqrt(Math.pow(v.getX() - v.getBlockX(), 2) + Math.pow(v.getY() - v.getBlockY(), 2) - + Math.pow(v.getZ() - v.getBlockZ(), 2)) + 0.01; - b = v.subtract(vector.normalize().multiply(dist)).toLocation(p.getWorld()).getBlock(); - } - - loc = v.toLocation(p.getWorld()); - loc.setY(loc.getBlockY()); - - } - } - - if (loc == null) - return; - - LaunchRune rune = new LaunchRune(Wizards, p, loc, trapSize, spellLevel); - - if (!isValid(rune)) - { - p.sendMessage(C.cGreen + "Cannot draw rune on wall"); - return; - } - - _launchRunes.add(rune); - charge(p); - } - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK) - { - Iterator itel = _launchRunes.iterator(); - - while (itel.hasNext()) - { - - LaunchRune rune = itel.next(); - - if (rune.onTick()) - { - itel.remove(); - } - - } - } - } - - private boolean isValid(LaunchRune rune) - { - return !UtilBlock.solid(rune.getLocation().getBlock()) - || UtilBlock.solid(rune.getLocation().getBlock().getRelative(BlockFace.DOWN)); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLightningStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLightningStrike.java index 0fb2fb9cd..ae1e5e480 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLightningStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellLightningStrike.java @@ -1,12 +1,17 @@ package nautilus.game.arcade.game.games.wizards.spells; -import java.util.List; +import java.util.ArrayList; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; +import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.LightningStrike; @@ -16,53 +21,131 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.util.Vector; public class SpellLightningStrike extends Spell implements SpellClick { - @Override - public void castSpell(Player p) - { - List list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 150); - if (list.size() > 1) - { - Location loc = list.get(0).getLocation(); + @Override + public void castSpell(final Player p) + { + double curRange = 0; - while (UtilBlock.solid(loc.getBlock().getRelative(BlockFace.UP))) - { - loc.add(0, 1, 0); - } + while (curRange <= 150) + { + Location newTarget = p.getEyeLocation().add(new Vector(0, 0.2, 0)) + .add(p.getLocation().getDirection().multiply(curRange)); - LightningStrike lightning = p.getWorld().strikeLightning(loc); + if (!UtilBlock.airFoliage(newTarget.getBlock()) + || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) + break; - lightning.setMetadata("Damager", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), p)); + // Progress Forwards + curRange += 0.2; + } - charge(p); - } - } + if (curRange < 2) + { + return; + } - @EventHandler - public void onEntityDamage(EntityDamageByEntityEvent event) - { - if (event.getDamager() instanceof LightningStrike && event.getEntity() instanceof LivingEntity) - { - LightningStrike lightning = (LightningStrike) event.getDamager(); - if (lightning.hasMetadata("Damager")) - { - event.setCancelled(true); + // Destination + final Location loc = p.getLocation().add(p.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0))); - if (!lightning.hasMetadata("IgnoreDamage")) - { - lightning.setMetadata("IgnoreDamage", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), null)); + while (UtilBlock.solid(loc.getBlock().getRelative(BlockFace.UP))) + { + loc.add(0, 1, 0); + } - Wizards.getArcadeManager() - .GetDamage() - .NewDamageEvent((LivingEntity) event.getEntity(), - (Player) lightning.getMetadata("Damager").get(0).value(), null, DamageCause.LIGHTNING, - event.getDamage(), false, true, false, "Lightning Strike", "Lightning Strike"); - } - } - } - } + UtilParticle.PlayParticle(ParticleType.ANGRY_VILLAGER, loc.clone().add(0, 1.3, 0), 0.5F, 0.3F, 0.5F, 0, 7); + + Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() + { + + @Override + public void run() + { + LightningStrike lightning = p.getWorld().strikeLightning(loc); + + lightning.setMetadata("Damager", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), p)); + + Block b = loc.getWorld().getHighestBlockAt(loc); + + b = b.getRelative(BlockFace.DOWN); + + ArrayList toExplode = new ArrayList(); + ArrayList toFire = new ArrayList(); + + for (int x = -1; x <= 1; x++) + { + for (int y = -1; y <= 1; y++) + { + for (int z = -1; z <= 1; z++) + { + if (x == 0 || (Math.abs(x) != Math.abs(z) || UtilMath.r(3) == 0)) + { + Block block = b.getRelative(x, y, z); + + if ((y == 0 || (x == 0 && z == 0)) && block.getType() != Material.AIR + && block.getType() != Material.BEDROCK) + { + if (y == 0 || UtilMath.random.nextBoolean()) + { + toExplode.add(block); + toFire.add(block); + } + } + else if (block.getType() == Material.AIR) + { + toFire.add(block); + } + } + } + } + } + + Wizards.getArcadeManager().GetExplosion().BlockExplosion(toExplode, b.getLocation(), false); + + for (Block block : toFire) + { + if (UtilMath.random.nextBoolean()) + { + block.setType(Material.FIRE); + } + } + } + + }, 20); + + charge(p); + } + + @EventHandler + public void onEntityDamage(EntityDamageByEntityEvent event) + { + if (event.getDamager() instanceof LightningStrike && event.getEntity() instanceof LivingEntity) + { + LightningStrike lightning = (LightningStrike) event.getDamager(); + + if (lightning.hasMetadata("Damager")) + { + event.setCancelled(true); + + if (!lightning.hasMetadata("IgnoreDamage")) + { + lightning.setMetadata("IgnoreDamage", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), null)); + + event.getEntity().setFireTicks(80); + + Player player = (Player) lightning.getMetadata("Damager").get(0).value(); + + Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent((LivingEntity) event.getEntity(), player, null, DamageCause.LIGHTNING, + 4 + (4 * getSpellLevel(player)), false, true, false, "Lightning Strike", "Lightning Strike"); + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellMagicMissile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellMagicMissile.java deleted file mode 100644 index 8135e800f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellMagicMissile.java +++ /dev/null @@ -1,166 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.Vector; - -public class SpellMagicMissile extends Spell implements SpellClick -{ - - public void castSpell(final Player player) - { - final Location missileLocation = player.getEyeLocation(); - final Location shotFrom = missileLocation.clone(); - final Vector direction = missileLocation.getDirection().normalize().multiply(0.3); - final int maxRange = 15 * getSpellLevel(player); - final int maxDings = maxRange * 3; - final int damage = 4 + getSpellLevel(player); - - new BukkitRunnable() - { - private int dingsDone; - - private void burst() - { - for (Entity cur : missileLocation.getWorld().getEntities()) - { - - if (cur == player || !(cur instanceof LivingEntity) - || (cur instanceof Player && UtilPlayer.isSpectator(cur))) - continue; - - LivingEntity entity = (LivingEntity) cur; - - Location eLoc = entity.getLocation(); - - // If they are less than 0.5 blocks away - if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7) - { - // If it is in their body height - if (Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.5)) - missileLocation.getY()) <= entity - .getEyeHeight() / 2) - { - - if (entity != player && (!(entity instanceof Player) || Wizards.IsAlive(entity))) - { - Wizards.Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, - true, true, false, "Magic Missile", "Magic Missile"); - } - } - } - } - - UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT, missileLocation, 0.5F, 0.5F, 0.5F, 0, 40); - missileLocation.getWorld().playSound(missileLocation, Sound.BAT_TAKEOFF, 1.2F, 1); - cancel(); - } - - public void run() - { - if (dingsDone >= maxDings || !player.isOnline() || !Wizards.Manager.IsAlive(player)) - { - burst(); - } - else - { - for (int i = 0; i < 2; i++) - { - Player closestPlayer = null; - double dist = 0; - - // This lot of code makes the magic missile change direction towards the closest player in its path - // Not entirely accurate, it doesn't go only for the people it can hit. - // This makes magic missile pretty cool in my opinion - for (Player closest : Wizards.GetPlayers(true)) - { - - Location loc = closest.getLocation(); - - if (closest != player) - { - double dist1 = loc.distance(shotFrom); - // If the player is a valid target - if (dist1 < maxRange + 10) - { - double dist2 = missileLocation.distance(loc); - // If the player is closer to the magic missile than the other dist - if (closestPlayer == null || dist2 < dist) - { - double dist3 = missileLocation.clone().add(direction).distance(loc); - - if (dist3 < dist2) - { - // If the magic missile grows closer when it moves - closestPlayer = closest; - dist = dist2; - } - } - } - } - } - - if (closestPlayer != null) - { - Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector() - .subtract(missileLocation.toVector()); - - direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.3); - } - - missileLocation.add(direction); - - for (Entity cur : missileLocation.getWorld().getEntities()) - { - - if (cur == player || !(cur instanceof LivingEntity) - || (cur instanceof Player && UtilPlayer.isSpectator(cur))) - continue; - - LivingEntity ent = (LivingEntity) cur; - - Location eLoc = ent.getLocation(); - - // If they are less than 0.5 blocks away - if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7) - { - // If it is in their body height - if (Math.abs((eLoc.getY() + (ent.getEyeHeight() / 1.5)) - missileLocation.getY()) <= ent - .getEyeHeight() / 2) - { - burst(); - return; - } - } - } - - if (UtilBlock.solid(missileLocation.getBlock())) - { - burst(); - return; - } - - dingsDone++; - } - - UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT, missileLocation, 0, 0, 0, 0, 1); - missileLocation.getWorld().playSound(missileLocation, Sound.ORB_PICKUP, 0.7F, 0); - } - } - }.runTaskTimer(Wizards.Manager.getPlugin(), 0, 0); - - charge(player); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellManaBolt.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellManaBolt.java new file mode 100644 index 000000000..361a0fdcc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellManaBolt.java @@ -0,0 +1,213 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.ArrayList; +import java.util.Random; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +public class SpellManaBolt extends Spell implements SpellClick +{ + + public void castSpell(final Player player) + { + final Location missileLocation = player.getEyeLocation(); + final Location shotFrom = missileLocation.clone(); + final Vector direction = missileLocation.getDirection().normalize().multiply(0.3); + final int maxRange = 20 + (10 * getSpellLevel(player)); + final int maxDings = maxRange * 3; + final int damage = 4 + (getSpellLevel(player) * 2); + + new BukkitRunnable() + { + private int dingsDone; + private Location previousLocation = missileLocation; + + private void burst() + { + for (Entity cur : missileLocation.getWorld().getEntities()) + { + + if (cur == player || !(cur instanceof LivingEntity) || (cur instanceof Player && UtilPlayer.isSpectator(cur))) + continue; + + LivingEntity entity = (LivingEntity) cur; + + Location eLoc = entity.getLocation(); + + // If they are less than 0.5 blocks away + if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7) + { + // If it is in their body height + if (Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.5)) - missileLocation.getY()) <= entity + .getEyeHeight() / 2) + { + + if (entity != player && (!(entity instanceof Player) || Wizards.IsAlive(entity))) + { + Wizards.Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.MAGIC, damage, true, + true, false, "Mana Bolt", "Mana Bolt"); + } + } + } + } + + playParticle(missileLocation, previousLocation); + + for (int i = 0; i < 120; i++) + { + Vector vector = new Vector(new Random().nextFloat() - 0.5F, new Random().nextFloat() - 0.5F, + new Random().nextFloat() - 0.5F); + + if (vector.length() >= 1) + { + i--; + continue; + } + + Location loc = missileLocation.clone(); + + loc.add(vector.multiply(2)); + + UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, -1, 1, 1, 1, 0); + } + + missileLocation.getWorld().playSound(missileLocation, Sound.BAT_TAKEOFF, 1.2F, 1); + cancel(); + } + + public void run() + { + if (dingsDone >= maxDings || !player.isOnline() || !Wizards.Manager.IsAlive(player)) + { + burst(); + } + else + { + for (int i = 0; i < 2; i++) + { + Player closestPlayer = null; + double dist = 0; + + // This lot of code makes the magic missile change direction towards the closest player in its path + // Not entirely accurate, it doesn't go only for the people it can hit. + // This makes magic missile pretty cool in my opinion + for (Player closest : Wizards.GetPlayers(true)) + { + + Location loc = closest.getLocation(); + + if (closest != player) + { + double dist1 = loc.distance(shotFrom); + // If the player is a valid target + if (dist1 < maxRange + 10) + { + double dist2 = missileLocation.distance(loc); + // If the player is closer to the magic missile than the other dist + if (closestPlayer == null || dist2 < dist) + { + double dist3 = missileLocation.clone().add(direction).distance(loc); + + if (dist3 < dist2) + { + // If the magic missile grows closer when it moves + closestPlayer = closest; + dist = dist2; + } + } + } + } + } + + if (closestPlayer != null) + { + Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector() + .subtract(missileLocation.toVector()); + + direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.3); + } + + missileLocation.add(direction); + + for (Entity cur : missileLocation.getWorld().getEntities()) + { + + if (cur == player || !(cur instanceof LivingEntity) + || (cur instanceof Player && UtilPlayer.isSpectator(cur))) + continue; + + LivingEntity ent = (LivingEntity) cur; + + Location eLoc = ent.getLocation(); + + // If they are less than 0.5 blocks away + if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7) + { + // If it is in their body height + if (Math.abs((eLoc.getY() + (ent.getEyeHeight() / 1.5)) - missileLocation.getY()) <= ent + .getEyeHeight() / 2) + { + burst(); + return; + } + } + } + + if (UtilBlock.solid(missileLocation.getBlock())) + { + burst(); + return; + } + + playParticle(missileLocation, previousLocation); + previousLocation = missileLocation.clone(); + + dingsDone++; + } + + missileLocation.getWorld().playSound(missileLocation, Sound.ORB_PICKUP, 0.7F, 0); + } + } + }.runTaskTimer(Wizards.Manager.getPlugin(), 0, 0); + + charge(player); + } + + private void playParticle(Location start, Location end) + { + final ArrayList locations = UtilShapes.getLinesDistancedPoints(start, end, 0.1); + + new BukkitRunnable() + { + int timesRan; + + public void run() + { + for (Location loc : locations) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, -1, 1, 1, 1, 0); + } + + if (timesRan++ > 1) + { + cancel(); + } + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellNapalm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellNapalm.java new file mode 100644 index 000000000..c56787d0e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellNapalm.java @@ -0,0 +1,268 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Random; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +public class SpellNapalm extends Spell implements SpellClick +{ + private HashMap _glazedBlocks = new HashMap(); + + public SpellNapalm() + { + _glazedBlocks.put(Material.STONE, Material.COBBLESTONE); + _glazedBlocks.put(Material.GRASS, Material.DIRT); + _glazedBlocks.put(Material.FENCE, Material.NETHER_FENCE); + _glazedBlocks.put(Material.WOOD_STAIRS, Material.NETHER_BRICK_STAIRS); + _glazedBlocks.put(Material.SMOOTH_STAIRS, Material.NETHER_BRICK_STAIRS); + _glazedBlocks.put(Material.SAND, Material.GLASS); + _glazedBlocks.put(Material.SMOOTH_BRICK, Material.NETHER_BRICK); + _glazedBlocks.put(Material.LOG, Material.NETHERRACK); + _glazedBlocks.put(Material.LOG_2, Material.NETHERRACK); + _glazedBlocks.put(Material.SMOOTH_BRICK, Material.COBBLESTONE); + _glazedBlocks.put(Material.CLAY, Material.STAINED_CLAY); + } + + @Override + public void castSpell(final Player player) + { + final int length = 5 + (10 * getSpellLevel(player)); + + final Vector vector = player.getLocation().getDirection().normalize().multiply(0.15); + + final Location playerLoc = player.getLocation().add(0, 2, 0); + final Location napalmLoc = playerLoc.clone().add(playerLoc.getDirection().normalize().multiply(2)); + + new BukkitRunnable() + { + + ArrayList litOnFire = new ArrayList(); + HashMap tempIgnore = new HashMap(); + double blocksTravelled; + double size = 1; + double lastTick; + + public void run() + { + Random r = new Random(); + napalmLoc.add(vector); + + if (!UtilBlock.airFoliage(napalmLoc.getBlock())) + { + cancel(); + return; + } + + for (int b = 0; b < size * 20; b++) + { + + float x = r.nextFloat(); + float y = r.nextFloat(); + float z = r.nextFloat(); + + while (Math.sqrt((x * x) + (y * y) + (z * z)) >= 1) + { + x = r.nextFloat(); + y = r.nextFloat(); + z = r.nextFloat(); + } + + UtilParticle.PlayParticle(ParticleType.RED_DUST, + + napalmLoc.clone().add( + + (size * (x - 0.5)) / 5, + + (size * (y - 0.5)) / 5, + + (size * (z - 0.5)) / 5), + + -0.3F, + + 0.35F + (r.nextFloat() / 8), + + 0.1F, 1, 0); + } + + if (lastTick % 3 == 0) + { + for (Entity entity : napalmLoc.getWorld().getEntities()) + { + if (!UtilPlayer.isSpectator(entity)) + { + double heat = (size * 1.1) - entity.getLocation().distance(napalmLoc); + + if (heat > 0) + { + if (lastTick % 10 == 0 && heat > 0.2) + { + if (entity instanceof LivingEntity) + { + Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent((LivingEntity) entity, player, null, DamageCause.FIRE, + heat / 1.5, false, true, true, "Napalm", "Napalm"); + } + else + { + entity.remove(); + continue; + } + } + + if (entity instanceof LivingEntity && !UtilPlayer.isSpectator(entity) + && entity.getFireTicks() < heat * 40) + { + entity.setFireTicks((int) (heat * 40)); + } + } + } + } + + int bSize = (int) Math.ceil(size * 0.75); + + for (int y = -bSize; y <= bSize; y++) + { + if (napalmLoc.getBlockY() + y < 256 && napalmLoc.getBlockY() + y > 0) + { + for (int x = -bSize; x <= bSize; x++) + { + for (int z = -bSize; z <= bSize; z++) + { + Block block = napalmLoc.clone().add(x, y, z).getBlock(); + + if (litOnFire.contains(block)) + { + continue; + } + + if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), playerLoc) < 2.5) + { + continue; + } + + double heat = bSize - UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), napalmLoc); + + if (tempIgnore.containsKey(block)) + { + if (tempIgnore.remove(block) > heat) + { + litOnFire.add(block); + continue; + } + } + + if (heat > 0) + { + if (block.getType() != Material.AIR) + { + float strength = net.minecraft.server.v1_7_R4.Block.getById(block.getTypeId()).a( + (net.minecraft.server.v1_7_R4.Entity) null) * 0.7F; + + if (strength <= heat) + { + block.setType(Material.AIR); + + block.getWorld().playSound(block.getLocation(), Sound.FIZZ, 1.3F, + 0.6F + ((new Random().nextFloat() - 0.5F) / 3F)); + } + else if (0.2 <= heat) + { + if (_glazedBlocks.containsKey(block.getType())) + { + block.setType(_glazedBlocks.get(block.getType())); + + if (block.getType() == Material.STAINED_CLAY) + { + block.setData((byte) 8); + } + + block.getWorld().playSound(block.getLocation(), Sound.FIZZ, 1.3F, + 0.6F + ((new Random().nextFloat() - 0.5F) / 3F)); + } + } + else if (strength * 2 > size) + { + tempIgnore.put(block, heat); + continue; + } + } + + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) + { + if (heat > 1) + { + block.setType(Material.AIR); + + block.getWorld().playSound(block.getLocation(), Sound.FIZZ, 1.3F, 0); + + litOnFire.add(block); + } + } + else if (block.getType() == Material.AIR) + { + if (UtilMath.random.nextBoolean()) + { + for (int a = 0; a < 6; a++) + { + Block b = block.getRelative(BlockFace.values()[a]); + + if (b.getType() != Material.AIR) + { + block.setType(Material.FIRE); + block.getWorld().playSound(block.getLocation(), Sound.DIG_WOOL, 1.3F, + 0.6F + ((new Random().nextFloat() - 0.5F) / 3F)); + + break; + } + } + } + + litOnFire.add(block); + } + } + } + } + } + } + + size = Math.min(8, size + 0.06); + } + + blocksTravelled += 0.15; + + if (lastTick++ % 8 == 0) + { + napalmLoc.getWorld().playSound(napalmLoc, Sound.CAT_HISS, Math.min(0.8F + (float) (size * 0.09F), 1.8f), 0F); + } + + if (blocksTravelled >= length) + { + cancel(); + } + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 1); + + charge(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java index a67f63a51..4be60e6c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowBeam.java @@ -17,47 +17,57 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class SpellRainbowBeam extends Spell implements SpellClick { - @Override - public void castSpell(Player p) - { - Entity entityTarget = UtilPlayer.getEntityInSight(p, 20 * getSpellLevel(p), true, true, true, 1.9F); + @Override + public void castSpell(Player p) + { + Entity entityTarget = UtilPlayer.getEntityInSight(p, 80, true, true, true, 1.9F); - if (!(entityTarget instanceof LivingEntity)) - { - entityTarget = null; - } + if (!(entityTarget instanceof LivingEntity)) + { + entityTarget = null; + } - Location loc; - if (entityTarget != null) - { + Location loc; + if (entityTarget != null) + { - loc = p.getEyeLocation().add( - p.getEyeLocation().getDirection().normalize() - .multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation()))); + loc = p.getEyeLocation().add( + p.getEyeLocation().getDirection().normalize() + .multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation()))); - // The above code makes the beam appear to hit them where you aimed. - Wizards.getArcadeManager() - .GetDamage() - .NewDamageEvent((LivingEntity) entityTarget, p, null, DamageCause.CUSTOM, (getSpellLevel(p) * 2) + 4F, true, - true, false, "Rainbow Beam", "Rainbow Beam"); + double damage = (getSpellLevel(p) * 2) + 4; + double dist = loc.distance(p.getLocation()) - (80 * .2D); - p.playSound(entityTarget.getLocation(), Sound.LEVEL_UP, (getSpellLevel(p) * 2) + 6, 1); + // If target is more than 20% away + if (dist > 0) + { + damage -= damage * (dist / (80 * .8D)); - } - else - { - loc = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 20 * getSpellLevel(p)).get(0).getLocation() - .add(0.5, 0.5, 0.5); - } + damage = Math.max(1, damage); + } - for (Location l : UtilShapes.getLinesDistancedPoints(p.getEyeLocation().subtract(0, 0.1, 0), loc, 1)) - { - l.getWorld().spigot().playEffect(l, Effect.POTION_SWIRL, 0, 0, 0, 0, 0, 500, 1, 30); - } + // The above code makes the beam appear to hit them where you aimed. + Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent((LivingEntity) entityTarget, p, null, DamageCause.MAGIC, damage, true, true, false, + "Rainbow Beam", "Rainbow Beam"); - p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.5F, 1); + p.playSound(entityTarget.getLocation(), Sound.LEVEL_UP, (getSpellLevel(p) * 2) + 6, 1); - charge(p); - } + } + else + { + loc = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 80).get(0).getLocation().add(0.5, 0.5, 0.5); + } + + for (Location l : UtilShapes.getLinesDistancedPoints(p.getEyeLocation().subtract(0, 0.1, 0), loc, 0.3)) + { + l.getWorld().spigot().playEffect(l, Effect.POTION_SWIRL, 0, 0, 0, 0, 0, 500, 1, 30); + } + + p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.5F, 1); + + charge(p); + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowRoad.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowRoad.java new file mode 100644 index 000000000..b968c5ebd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRainbowRoad.java @@ -0,0 +1,147 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +public class SpellRainbowRoad extends Spell implements SpellClick +{ + final BlockFace[] radial = + { + BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, + BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST + }; + final int[] _rainbow = new int[] + { + 1, 2, 3, 4, 5, 6, 9, 10, 11, 13, 14 + }; + + private HashMap _wallExpires = new HashMap(); + + @EventHandler + public void onUpdate(UpdateEvent event) + { + Iterator> itel = _wallExpires.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if (entry.getValue() < System.currentTimeMillis()) + { + itel.remove(); + + if (entry.getKey().getType() == Material.STAINED_GLASS) + { + entry.getKey().setType(Material.AIR); + } + } + } + } + + @Override + public void castSpell(Player p) + { + final BlockFace face = radial[Math.round(p.getLocation().getYaw() / 45f) & 0x7]; + + double yMod = Math.min(Math.max(p.getLocation().getPitch() / 30, -1), 1); + + final Vector vector = new Vector(face.getModX(), -yMod, face.getModZ()); + + final Location loc = p.getLocation().getBlock().getLocation().add(0.5, -0.5, 0.5); + + final int maxDist = 3 + (10 * getSpellLevel(p)); + + makeRoad(loc, face, 0); + + new BukkitRunnable() + { + int blocks; + int colorProgress; + + @Override + public void run() + { + if (!Wizards.IsLive() || blocks++ >= maxDist) + { + cancel(); + return; + } + + colorProgress = makeRoad(loc, face, colorProgress); + + loc.add(vector); + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 5); + + charge(p); + } + + private int makeRoad(Location loc, BlockFace face, int colorProgress) + { + Block block = loc.getBlock(); + + BlockFace[] faces = UtilShapes.getSideBlockFaces(face); + + ArrayList bs = new ArrayList(); + + bs.add(block); + + for (int i = 0; i < 2; i++) + { + bs.add(block.getRelative(faces[i])); + } + + bs.addAll(UtilShapes.getDiagonalBlocks(block, face, 1)); + + boolean playSound = false; + + for (Block b : bs) + { + if (!Wizards.isInsideMap(b.getLocation())) + { + continue; + } + + if (!_wallExpires.containsKey(block) && UtilBlock.solid(b)) + { + continue; + } + + b.setType(Material.STAINED_GLASS); + b.setData((byte) _rainbow[colorProgress++ % _rainbow.length]); + + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WOOL, b.getData()); + + _wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); + + playSound = true; + } + + if (playSound) + { + block.getWorld().playSound(block.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1); + } + + return colorProgress; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRumble.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRumble.java index 6830b93bd..59d85e116 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRumble.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellRumble.java @@ -3,13 +3,17 @@ package nautilus.game.arcade.game.games.wizards.spells; import java.util.ArrayList; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilShapes; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.AnimalTamer; @@ -17,164 +21,332 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; +import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.scheduler.BukkitRunnable; public class SpellRumble extends Spell implements SpellClickBlock, SpellClick { - final private BlockFace[] _radial = - { - BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, - BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST - }; + final private BlockFace[] _radial = + { + BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, + BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST + }; - public void castSpell(Player player) - { - Block block = player.getLocation().add(0, -1, 0).getBlock(); + public void castSpell(Player player) + { + Block block = player.getLocation().add(0, -1, 0).getBlock(); - if (!UtilBlock.solid(block)) - { - block = block.getRelative(BlockFace.DOWN); - } + if (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } - castSpell(player, block); - } + castSpell(player, block); + } - @Override - public void castSpell(final Player player, final Block target) - { + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetReason() != null && event.GetReason().equals("Rumble")) + { + event.AddKnockback("Rumble", 1); + } + } - if (UtilBlock.solid(target)) - { + @Override + public void castSpell(final Player player, final Block target) + { - final BlockFace moveDirection = _radial[Math.round(player.getEyeLocation().getYaw() / 45f) & 0x7]; - final int spellLevel = getSpellLevel(player); - final int damage = 4 + (spellLevel * 2); - final int maxDist = 10 * spellLevel; + if (UtilBlock.solid(target)) + { - player.getWorld().playEffect(target.getLocation(), Effect.STEP_SOUND, target.getTypeId()); + final BlockFace moveDirection = _radial[Math.round(player.getEyeLocation().getYaw() / 45f) & 0x7]; + final int spellLevel = getSpellLevel(player); + final int damage = 4 + (spellLevel * 2); + final int maxDist = 10 * spellLevel; - new BukkitRunnable() - { - private Block _currentBlock = target; - private int _distTravelled = 0; - private ArrayList _effected = new ArrayList(); - private ArrayList _previousBlocks = new ArrayList(); + playBlockEffect(target); - @Override - public void run() - { - if (!player.isOnline() || !Wizards.IsAlive(player)) - { - cancel(); - return; - } + new BukkitRunnable() + { + private Block _currentBlock = target; + private int _distTravelled = 0; + private ArrayList _effected = new ArrayList(); + private ArrayList _previousBlocks = new ArrayList(); - _currentBlock = _currentBlock.getRelative(moveDirection); + private void endRun() + { + ArrayList bs = new ArrayList(); - if (UtilBlock.solid(_currentBlock.getRelative(BlockFace.UP))) - { + BlockFace[] faces = UtilShapes.getSideBlockFaces(moveDirection); - _currentBlock = _currentBlock.getRelative(BlockFace.UP); + bs.add(_currentBlock); - if (UtilBlock.solid(_currentBlock.getRelative(BlockFace.UP))) - { - cancel(); - return; - } + for (int i = 1; i <= Math.min(4, Math.floor(_distTravelled / (8D - spellLevel))) + 1; i++) + { + for (int a = 0; a < faces.length; a++) + { + Block b = _currentBlock.getRelative(faces[a], i); - } - else if (!UtilBlock.solid(_currentBlock) && _currentBlock.getY() > 0) - { + if (UtilBlock.solid(b)) + { + bs.add(b); + } + } + } - _currentBlock = _currentBlock.getRelative(BlockFace.DOWN); + for (Block block : bs) + { - } + ArrayList toExplode = new ArrayList(); - if (!UtilBlock.solid(_currentBlock)) - { - cancel(); - return; - } + toExplode.add(block); - ArrayList bs = new ArrayList(); + for (BlockFace face : new BlockFace[] + { + BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH, BlockFace.UP, + BlockFace.DOWN + }) + { + if (UtilMath.random.nextBoolean()) + { + Block b = block.getRelative(face); - BlockFace[] faces = UtilShapes.getSideBlockFaces(_currentBlock, moveDirection); + if (b.getType() != Material.AIR && b.getType() != Material.BEDROCK) + { + if (!toExplode.contains(b)) + { + toExplode.add(b); + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); + } + } + } + } - bs.add(_currentBlock); + Wizards.getArcadeManager().GetExplosion() + .BlockExplosion(toExplode, block.getLocation().add(0.5, 0, 0.5), false); - for (int i = 1; i <= Math.min(4, Math.floor(_distTravelled / (8D - spellLevel))) + 1; i++) - { - for (int a = 0; a < faces.length; a++) - { - Block b = _currentBlock.getRelative(faces[a], i); + for (LivingEntity entity : block.getWorld().getEntitiesByClass(LivingEntity.class)) + { + if (!UtilPlayer.isSpectator(entity)) + { + if (entity instanceof Tameable) + { + AnimalTamer tamer = ((Tameable) entity).getOwner(); - if (UtilBlock.solid(b)) - { - bs.add(b); - } - } - } + if (tamer != null && tamer == player) + { + continue; + } + } - _previousBlocks.addAll(bs); + double dist = 999; - for (Block b : _previousBlocks) - { - for (Entity entity : b.getChunk().getEntities()) - { - if (entity instanceof LivingEntity && player != entity && !_effected.contains(entity.getEntityId())) - { + for (Block b : toExplode) + { + double currentDist = b.getLocation().add(0.5, 0.5, 0.5).distance(entity.getLocation()); - if (entity instanceof Tameable) - { - AnimalTamer tamer = ((Tameable) entity).getOwner(); + if (dist > currentDist) + { + dist = currentDist; + } + } - if (tamer != null && tamer == player) - { - continue; - } - } + if (dist < 2) + { + Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent(entity, player, null, DamageCause.ENTITY_EXPLOSION, + (1 + (spellLevel / 5D)) * (2 - dist), true, true, false, "Rumble Explosion", + "Rumble Explosion"); + } + } + } + } - Location loc = entity.getLocation(); + cancel(); + } - if (loc.getBlockX() == b.getX() && loc.getBlockZ() == b.getZ()) - { + @Override + public void run() + { + if (!player.isOnline() || !Wizards.IsAlive(player)) + { + endRun(); + return; + } - if (entity instanceof Player && !Wizards.IsAlive(entity)) - { - continue; - } + boolean found = false; - double height = loc.getY() - b.getY(); - if (height >= 0 && height <= 2) - { - Wizards.Manager.GetDamage().NewDamageEvent((LivingEntity) entity, player, null, - DamageCause.CUSTOM, damage, false, true, false, "Rumble", "Rumble"); - } + for (int y : new int[] + { + 0, 1, -1, -2 + }) + { + if (_currentBlock.getY() + y <= 0) + { + continue; + } - _effected.add(entity.getEntityId()); - } - } - } - } + Block b = _currentBlock.getRelative(moveDirection).getRelative(0, y, 0); - _previousBlocks = bs; + if (UtilBlock.solid(b) && !UtilBlock.solid(b.getRelative(0, 1, 0))) + { + found = true; + _currentBlock = b; - for (Block b : bs) - { - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId(), 19); // 19 being particle view - // distance - } + break; + } + } - if (_distTravelled++ >= maxDist) - { - cancel(); - } - } - }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 1); + if (!found) + { + endRun(); + return; + } - charge(player); - } - } + ArrayList effectedBlocks = new ArrayList(); + + BlockFace[] faces = UtilShapes.getSideBlockFaces(moveDirection); + + effectedBlocks.add(_currentBlock); + + playBlockEffect(_currentBlock); + + int size = (int) (Math.min(4, Math.floor(_distTravelled / (8D - spellLevel))) + 1); + + for (int i = 1; i <= size; i++) + { + for (int a = 0; a < faces.length; a++) + { + Block b = _currentBlock.getRelative(faces[a], i); + + if (UtilBlock.solid(b)) + { + effectedBlocks.add(b); + playBlockEffect(b); + } + } + } + + for (Block b : UtilShapes.getDiagonalBlocks(_currentBlock, moveDirection, size - 2)) + { + if (UtilBlock.solid(b)) + { + effectedBlocks.add(b); + playBlockEffect(b); + } + } + + _previousBlocks.addAll(effectedBlocks); + + for (Block b : _previousBlocks) + { + for (Entity entity : b.getChunk().getEntities()) + { + if (entity instanceof LivingEntity && player != entity && !_effected.contains(entity.getEntityId())) + { + + if (entity instanceof Tameable) + { + AnimalTamer tamer = ((Tameable) entity).getOwner(); + + if (tamer != null && tamer == player) + { + continue; + } + } + + Location loc = entity.getLocation(); + + if (loc.getBlockX() == b.getX() && loc.getBlockZ() == b.getZ()) + { + + if (entity instanceof Player && !Wizards.IsAlive(entity)) + { + continue; + } + + double height = loc.getY() - b.getY(); + if (height >= 0 && height <= 3) + { + Wizards.Manager.GetDamage().NewDamageEvent((LivingEntity) entity, player, null, + DamageCause.CONTACT, damage, true, true, false, "Rumble", "Rumble"); + + if (entity instanceof Player) + { + Wizards.getArcadeManager() + .GetCondition() + .Factory() + .Slow("Rumble", (LivingEntity) entity, player, 3, spellLevel, false, false, + false, false); + } + } + + _effected.add(entity.getEntityId()); + } + } + } + } + + _previousBlocks = effectedBlocks; + + if (_distTravelled++ >= maxDist) + { + endRun(); + } + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 1); + + charge(player); + } + } + + private void playBlockEffect(Block block) + { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); + Block b = block.getRelative(BlockFace.UP); + + if (UtilBlock.airFoliage(b)) + { + b.breakNaturally(); + } + /* + + final int entityId = UtilEnt.getNewEntityId(); + + PacketPlayOutSpawnEntity fallingSpawn = new PacketPlayOutSpawnEntity(); + fallingSpawn.a = entityId; + fallingSpawn.b = (block.getX() * 32) + 16; + fallingSpawn.c = (block.getY() * 32) + 4; + fallingSpawn.d = (block.getZ() * 32) + 16; + fallingSpawn.i = 70; + fallingSpawn.k = block.getTypeId() | block.getData() << 16; + fallingSpawn.f = 10000; + + final Collection players = Bukkit.getOnlinePlayers(); + + for (Player player : players) + { + UtilPlayer.sendPacket(player, fallingSpawn); + } + + Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() + { + public void run() + { + PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(new int[] + { + entityId + }); + + for (Player player : players) + { + UtilPlayer.sendPacket(player, destroyPacket); + } + } + }, 15);*/ + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpectralArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpectralArrow.java new file mode 100644 index 000000000..7636ab883 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpectralArrow.java @@ -0,0 +1,103 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.metadata.FixedMetadataValue; + +public class SpellSpectralArrow extends Spell implements SpellClick +{ + private HashMap _spectralArrows = new HashMap(); + + @Override + public void castSpell(Player player) + { + Arrow arrow = player.launchProjectile(Arrow.class); + + arrow.setVelocity(arrow.getVelocity().multiply(2.3)); + + arrow.setMetadata("SpellLevel", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), getSpellLevel(player))); + + ((CraftArrow) arrow).getHandle().fromPlayer = 0; + + _spectralArrows.put(arrow, new Location[] + { + player.getLocation(), player.getLocation() + }); + + charge(player); + } + + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + Iterator> itel = _spectralArrows.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + for (Location loc : UtilShapes.getLinesDistancedPoints(entry.getValue()[1], entry.getKey().getLocation(), 0.7D)) + { + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc, 0, 0, 0, 0, 1); + } + + entry.getValue()[1] = entry.getKey().getLocation(); + } + } + + @EventHandler + public void onSecond(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + Iterator itel = _spectralArrows.keySet().iterator(); + + while (itel.hasNext()) + { + Arrow entity = itel.next(); + + if (entity.isOnGround() || !entity.isValid()) + { + itel.remove(); + } + } + } + + @EventHandler + public void onDamage(CustomDamageEvent event) + { + Location[] loc = _spectralArrows.remove(event.GetProjectile()); + + if (loc != null) + { + int spellLevel = event.GetProjectile().getMetadata("SpellLevel").get(0).asInt(); + + event.AddMod("Negate Damage", "Negate Damage", -event.GetDamage(), false); + event.AddMod("Spectral Arrow", "Spectral Arrow", 6 + loc[0].distance(event.GetDamageeEntity().getLocation()) + / (7D - spellLevel), true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpeedBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpeedBoost.java index 0892dfa4c..526028a03 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpeedBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpeedBoost.java @@ -7,14 +7,11 @@ import org.bukkit.entity.Player; public class SpellSpeedBoost extends Spell implements SpellClick { - @Override - public void castSpell(Player p) - { - int ticks = 30 * getSpellLevel(p) * 20; - int potionLevel = getSpellLevel(p); + @Override + public void castSpell(Player p) + { + Wizards.getArcadeManager().GetCondition().Factory().Speed("Speed Boost", p, p, 20, getSpellLevel(p), false, false, false); - Wizards.getArcadeManager().GetCondition().Factory().Speed("Speed Boost", p, p, ticks, potionLevel, false, false, false); - - charge(p); - } + charge(p); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpiderman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpiderman.java deleted file mode 100644 index 11b125400..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpiderman.java +++ /dev/null @@ -1,77 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import mineplex.core.common.util.UtilBlock; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -public class SpellSpiderman extends Spell implements SpellClick -{ - - @Override - public void castSpell(final Player player) - { - shoot(player); - - for (int i = 1; i < getSpellLevel(player) * 2; i++) - { - - Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() - { - - @Override - public void run() - { - shoot(player); - } - - }, i * 10); - } - - charge(player); - } - - private void shoot(Player player) - { - - if (Wizards.IsAlive(player)) - { - - final FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), Material.WEB, (byte) 0); - block.setVelocity(player.getEyeLocation().getDirection().multiply(2)); - block.getWorld().playSound(block.getLocation(), Sound.CLICK, 0.5F, 0); - block.setDropItem(false); - - new BukkitRunnable() - { - public void run() - { - - if (!Wizards.IsLive()) - { - cancel(); - } - else if (!block.isValid()) - { - cancel(); - - Block b = block.getLocation().getBlock(); - - if (UtilBlock.airFoliage(b) && b.getType() != Material.WEB) - { - b.setType(Material.WEB); - } - } - } - }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0); - - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellStoneWall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellStoneWall.java deleted file mode 100644 index 870808c19..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellStoneWall.java +++ /dev/null @@ -1,103 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map.Entry; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilShapes; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; - -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.scheduler.BukkitRunnable; - -public class SpellStoneWall extends Spell implements SpellClickBlock -{ - private HashMap _wallExpires = new HashMap(); - - @EventHandler - public void onUpdate(UpdateEvent event) - { - Iterator> itel = _wallExpires.entrySet().iterator(); - - while (itel.hasNext()) - { - Entry entry = itel.next(); - - if (entry.getValue() < System.currentTimeMillis()) - { - itel.remove(); - - if (entry.getKey().getType() == Material.STONE) - { - entry.getKey().setType(Material.AIR); - } - } - } - } - - @Override - public void castSpell(Player player, Block obj) - { - final Block starter = obj.getRelative(BlockFace.UP); - final int wallWidth = getSpellLevel(player) * 5; - final BlockFace facing = UtilShapes.getFacing(player.getEyeLocation().getYaw()); - final int wallHeight = 1 + getSpellLevel(player); - - new BukkitRunnable() - { - Block block = starter; - int currentRun; - - @Override - public void run() - { - - currentRun++; - - BlockFace[] faces = UtilShapes.getCornerBlockFaces(block, facing); - - if (block.getType() == Material.AIR) - { - block.setTypeIdAndData(Material.STONE.getId(), (byte) 0, false); - _wallExpires.put(block, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); - } - - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); - - for (BlockFace face : faces) - { - for (int i = 1; i < wallWidth; i++) - { - - Block b = block.getRelative(face.getModX() * i, 0, face.getModZ() * i); - - if (!UtilBlock.airFoliage(b)) - break; - - b.setTypeIdAndData(Material.STONE.getId(), (byte) 0, false); - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId()); - - _wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L)); - } - } - - block = block.getRelative(BlockFace.UP); - if (currentRun >= wallHeight) - { - cancel(); - } - } - }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 5); - - charge(player); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSummonWolves.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSummonWolves.java index 00b9e58be..d1805417a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSummonWolves.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSummonWolves.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.wizards.spells; import java.util.HashMap; import java.util.Iterator; +import java.util.Random; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; @@ -29,137 +30,137 @@ import org.bukkit.event.EventHandler; public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBlock { - private HashMap _summonedWolves = new HashMap(); + private HashMap _summonedWolves = new HashMap(); - @Override - public void castSpell(Player player, Block block) - { - block = block.getRelative(BlockFace.UP); + @Override + public void castSpell(Player player, Block block) + { + block = block.getRelative(BlockFace.UP); - if (!UtilBlock.airFoliage(block)) - { - block = player.getLocation().getBlock(); - } + if (!UtilBlock.airFoliage(block)) + { + block = player.getLocation().getBlock(); + } - Location loc = block.getLocation().add(0.5, 0, 0.5); + Location loc = block.getLocation().add(0.5, 0, 0.5); - for (int i = 0; i < 2 + getSpellLevel(player); i++) - { - Wizards.CreatureAllowOverride = true; + for (int i = 0; i < getSpellLevel(player); i++) + { + Wizards.CreatureAllowOverride = true; - Wolf wolf = (Wolf) player.getWorld().spawnEntity(loc, EntityType.WOLF); + Wolf wolf = (Wolf) player.getWorld().spawnEntity( + loc.clone().add(new Random().nextFloat() - 0.5F, 0, new Random().nextFloat() - 0.5F), EntityType.WOLF); - Wizards.CreatureAllowOverride = false; + Wizards.CreatureAllowOverride = false; - wolf.setCollarColor(DyeColor.YELLOW); - wolf.setTamed(true); - wolf.setOwner(player); - wolf.setBreed(false); - wolf.setCustomName(player.getDisplayName() + "'s Wolf"); - wolf.setRemoveWhenFarAway(false); - wolf.setMaxHealth(2); - wolf.setHealth(2); - // wolf.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 9001, 0)); + wolf.setCollarColor(DyeColor.YELLOW); + wolf.setTamed(true); + wolf.setOwner(player); + wolf.setBreed(false); + wolf.setCustomName(player.getDisplayName() + "'s Wolf"); + wolf.setRemoveWhenFarAway(false); + wolf.setMaxHealth(0.5); + wolf.setHealth(0.5); - this._summonedWolves.put(wolf, System.currentTimeMillis() + (30L * 1000L)); - } + _summonedWolves.put(wolf, System.currentTimeMillis() + (30L * 1000L)); + } - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0.8F, 0, 0.8F, 0, 4); - player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.2F, 1); - charge(player); - } + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0.8F, 0, 0.8F, 0, 4); + player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.2F, 1); + charge(player); + } - @EventHandler - public void onDamage(CustomDamageEvent event) - { - if (event.GetDamagerEntity(false) instanceof Wolf) - { - Wolf wolf = (Wolf) event.GetDamagerEntity(false); - event.AddMult("Summoned Wolf", "Summoned Wolf", 0.3, true); - - AnimalTamer tamer = wolf.getOwner(); - if (tamer instanceof Player) - { - event.SetDamager((Player) tamer); - event.setKnockbackOrigin(wolf.getLocation()); - } - } - } + @EventHandler + public void onDamage(CustomDamageEvent event) + { + if (event.GetDamagerEntity(false) instanceof Wolf) + { + Wolf wolf = (Wolf) event.GetDamagerEntity(false); + event.AddMult("Summoned Wolf", "Summoned Wolf", 0.3, true); - @EventHandler - public void onSecond(UpdateEvent event) - { - if (event.getType() == UpdateType.SEC) - { + AnimalTamer tamer = wolf.getOwner(); + if (tamer instanceof Player) + { + event.SetDamager((Player) tamer); + event.setKnockbackOrigin(wolf.getLocation()); + } + } + } - Iterator itel = _summonedWolves.keySet().iterator(); + @EventHandler + public void onSecond(UpdateEvent event) + { + if (event.getType() == UpdateType.SEC) + { - while (itel.hasNext()) - { - Wolf wolf = itel.next(); - AnimalTamer wolfOwner = wolf.getOwner(); + Iterator itel = _summonedWolves.keySet().iterator(); - if (!wolf.isValid() || _summonedWolves.get(wolf) < System.currentTimeMillis() || !(wolfOwner instanceof Player) - || !Wizards.IsAlive((Entity) wolfOwner)) - { - if (wolf.isValid()) - { - wolf.getWorld().playEffect(wolf.getLocation(), Effect.EXPLOSION_HUGE, 0); - } + while (itel.hasNext()) + { + Wolf wolf = itel.next(); + AnimalTamer wolfOwner = wolf.getOwner(); - wolf.remove(); - itel.remove(); - } - else - { + if (!wolf.isValid() || _summonedWolves.get(wolf) < System.currentTimeMillis() || !(wolfOwner instanceof Player) + || !Wizards.IsAlive((Entity) wolfOwner)) + { + if (wolf.isValid()) + { + wolf.getWorld().playEffect(wolf.getLocation(), Effect.EXPLOSION_HUGE, 0); + } - if (wolf.getTarget() == null || !wolf.getTarget().isValid() || !Wizards.IsAlive(wolf.getTarget()) - || wolf.getTarget().getLocation().distance(wolf.getLocation()) > 16) - { + wolf.remove(); + itel.remove(); + } + else + { - double dist = 0; - Player target = null; + if (wolf.getTarget() == null || !wolf.getTarget().isValid() || !Wizards.IsAlive(wolf.getTarget()) + || wolf.getTarget().getLocation().distance(wolf.getLocation()) > 16) + { - for (Player player : Wizards.GetPlayers(true)) - { + double dist = 0; + Player target = null; - if (!player.equals(wolfOwner)) - { + for (Player player : Wizards.GetPlayers(true)) + { - double newDist = player.getLocation().distance(wolf.getLocation()); + if (!player.equals(wolfOwner)) + { - if (newDist < 16 && (target == null || dist > newDist)) - { - dist = newDist; - target = player; - } - } - } + double newDist = player.getLocation().distance(wolf.getLocation()); - if (target != null) - { - wolf.setTarget(target); - } - else - { - Location loc = ((Player) wolfOwner).getLocation(); + if (newDist < 16 && (target == null || dist > newDist)) + { + dist = newDist; + target = player; + } + } + } - if (loc.distance(wolf.getLocation()) > 16) - { - wolf.teleport(loc); - } - } + if (target != null) + { + wolf.setTarget(target); + } + else + { + Location loc = ((Player) wolfOwner).getLocation(); - } - } - } + if (loc.distance(wolf.getLocation()) > 16) + { + wolf.teleport(loc); + } + } - } - } + } + } + } - @Override - public void castSpell(Player player) - { - castSpell(player, player.getLocation().getBlock().getRelative(BlockFace.DOWN)); - } + } + } + + @Override + public void castSpell(Player player) + { + castSpell(player, player.getLocation().getBlock().getRelative(BlockFace.DOWN)); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTeleportRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTeleportRune.java deleted file mode 100644 index e6f562a6b..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTeleportRune.java +++ /dev/null @@ -1,87 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells; - -import java.util.ArrayList; -import java.util.Iterator; - -import mineplex.core.common.util.UtilBlock; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.game.games.wizards.Spell; -import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; -import nautilus.game.arcade.game.games.wizards.spells.subclasses.TeleportRune; - -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -public class SpellTeleportRune extends Spell implements SpellClick -{ - private ArrayList _teleportRunes = new ArrayList(); - - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK) - { - Iterator itel = _teleportRunes.iterator(); - - while (itel.hasNext()) - { - TeleportRune rune = itel.next(); - - if (rune.tickRune()) - { - itel.remove(); - } - } - } - } - - @Override - public void castSpell(Player player) - { - Block b = player.getTargetBlock(null, 25 * getSpellLevel(player)); - - while (b.getType() != Material.AIR && b.getY() < 250) - { - b = b.getRelative(BlockFace.UP); - } - - if (b.getRelative(BlockFace.DOWN).getType() == Material.AIR) - { - player.sendMessage(ChatColor.RED + "Unable to place a rune!"); - return; - } - - Location firstTeleport = player.getLocation(); - - for (int i = 0; i < 3 && firstTeleport.getBlockY() > 1 - && !UtilBlock.solid(firstTeleport.getBlock().getRelative(BlockFace.DOWN)); i++) - { - firstTeleport.add(0, -1, 0); - } - - firstTeleport = firstTeleport.getBlock().getLocation().add(firstTeleport.getX() % 1, 0, firstTeleport.getZ() % 1); - - Location secondTeleport = b.getLocation().add(0.5, 0, 0.5); - - double runeSize = 1.5D * getSpellLevel(player); - - if (firstTeleport.distance(secondTeleport) > runeSize * 2) - { - TeleportRune teleportRune = new TeleportRune(firstTeleport, secondTeleport, runeSize); - - _teleportRunes.add(teleportRune); - - charge(player); - } - else - { - player.sendMessage(ChatColor.RED + "Target location too close"); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTrapRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTrapRune.java index 6ec3eb59f..fc1b29dfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTrapRune.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellTrapRune.java @@ -6,19 +6,14 @@ import java.util.List; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilShapes; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.explosion.CustomExplosion; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spells.subclasses.TrapRune; -import org.bukkit.Effect; -import org.bukkit.GameMode; import org.bukkit.Location; -import org.bukkit.Sound; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -26,179 +21,52 @@ import org.bukkit.event.EventHandler; public class SpellTrapRune extends Spell implements SpellClick { - private ArrayList _runes = new ArrayList(); + private ArrayList _runes = new ArrayList(); - @EventHandler - public void onTick(UpdateEvent event) - { - if (event.getType() == UpdateType.TICK) - { - Iterator itel = _runes.iterator(); - while (itel.hasNext()) - { - TrapRune rune = itel.next(); - if (!rune.RuneCaster.isOnline() || UtilPlayer.isSpectator(rune.RuneCaster)) - { - itel.remove(); - } - else if (rune.TicksLived++ > 2000) - { - itel.remove(); - } - else - { - if (rune.TicksLived <= 100) - { - if (rune.TicksLived % 15 == 0) - initialParticles(rune.RuneLocation, rune.RuneSize); - } - else - { - if (!isValid(rune)) - { - trapCard(rune); - itel.remove(); - } - else - { - for (Player player : Wizards.GetPlayers(true)) - { - if (isInTrap(rune.RuneLocation, player.getLocation(), rune.RuneSize)) - { - trapCard(rune); - itel.remove(); - break; - } - } - } - } - } - } - } - } + @EventHandler + public void onTick(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + Iterator itel = _runes.iterator(); + while (itel.hasNext()) + { + TrapRune rune = itel.next(); - public void initialParticles(Location trapLocation, double trapSize) - { - for (Location loc : getBox(trapLocation, trapSize, 0.3)) - { - for (double y = 0; y < 1; y += 0.2) - { - trapLocation.getWorld().spigot().playEffect(loc, Effect.FLAME, 0, 0, 0, 0, 0, 0, 1, 30); - } - } - } + if (rune.onRuneTick()) + { + itel.remove(); + } + } + } + } - private ArrayList getBox(Location trapLocation, double trapSize, double spacing) - { - ArrayList boxLocs = getBoxCorners(trapLocation, trapSize); - ArrayList returns = new ArrayList(); + @Override + public void castSpell(Player p) + { + List list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (getSpellLevel(p) * 4) + 4); - for (int i = 0; i < boxLocs.size(); i++) - { + if (list.size() > 1) + { + Location loc = list.get(0).getLocation().add(0.5, 0, 0.5); - int a = i + 1 >= boxLocs.size() ? 0 : i + 1; - returns.addAll(UtilShapes.getLinesDistancedPoints(boxLocs.get(i), boxLocs.get(a), spacing)); - returns.add(boxLocs.get(i)); + if (loc.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) + { + return; + } - } - return returns; - } + TrapRune rune = new TrapRune(Wizards, p, loc, getSpellLevel(p)); + if (!rune.isValid()) + { + p.sendMessage(C.cGreen + "Cannot draw rune on wall"); + return; + } - private ArrayList getBoxCorners(Location center, double boxSize) - { - ArrayList boxPoints = new ArrayList(); + rune.initialParticles(); - boxPoints.add(center.clone().add(-boxSize, 0, -boxSize)); - boxPoints.add(center.clone().add(boxSize, 0, -boxSize)); - boxPoints.add(center.clone().add(boxSize, 0, boxSize)); - boxPoints.add(center.clone().add(-boxSize, 0, boxSize)); - - return boxPoints; - } - - private boolean isInTrap(Location trapLocation, Location loc, double trapSize) - { - if (loc.getX() >= trapLocation.getX() - trapSize && loc.getX() <= trapLocation.getX() + trapSize) - { - if (loc.getZ() >= trapLocation.getZ() - trapSize && loc.getZ() <= trapLocation.getZ() + trapSize) - { - if (loc.getY() >= trapLocation.getY() - 0.1 && loc.getY() <= trapLocation.getY() + 0.9) - { - return true; - } - } - } - return false; - } - - private boolean isValid(TrapRune rune) - { - return !UtilBlock.solid(rune.RuneLocation.getBlock()) - || UtilBlock.solid(rune.RuneLocation.getBlock().getRelative(BlockFace.DOWN)); - /* - for (double x = -rune.RuneSize; x <= rune.RuneSize; x++) - { - for (double z = -rune.RuneSize; z <= rune.RuneSize; z++) - { - - Block b = rune.RuneLocation.clone().add(x, 0, z).getBlock(); - if (UtilBlock.solid(b) || !UtilBlock.solid(b.getRelative(BlockFace.DOWN))) - { - return false; - } - - } - }*/ - } - - public void trapCard(TrapRune rune) - { - rune.RuneLocation.getWorld().playSound(rune.RuneLocation, Sound.WITHER_SHOOT, 5, (float) rune.RuneSize * 2); - - CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), rune.RuneLocation.clone().add(0, - 0.3, 0), (float) rune.RuneSize * 1.2F, "Trap Rune"); - - explosion.setPlayer(rune.RuneCaster, true); - - explosion.setDropItems(false); - - explosion.explode(); - - for (Location loc : getBox(rune.RuneLocation, rune.RuneSize, 0.3)) - { - for (double y = 0; y < 1; y += 0.2) - { - rune.RuneLocation.getWorld().spigot().playEffect(loc, Effect.FLAME, 0, 0, 0, 0, 0, 0, 1, 30); - } - } - } - - @Override - public void castSpell(Player p) - { - List list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (getSpellLevel(p) * 4) + 4); - - if (list.size() > 1) - { - Location loc = list.get(0).getLocation().add(0.5, 0, 0.5); - - float trapSize = Math.max(1, getSpellLevel(p) * 0.8F); - - TrapRune rune = new TrapRune(); - rune.RuneCaster = p; - rune.RuneSize = trapSize; - rune.RuneLocation = loc; - - if (!isValid(rune)) - { - p.sendMessage(C.cGreen + "Cannot draw rune on wall"); - return; - } - - initialParticles(loc, trapSize); - _runes.add(rune); - charge(p); - } - } + _runes.add(rune); + charge(p); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java new file mode 100644 index 000000000..c3763e50b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWebShot.java @@ -0,0 +1,170 @@ +package nautilus.game.arcade.game.games.wizards.spells; + +import java.util.HashMap; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.wizards.Spell; +import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class SpellWebShot extends Spell implements SpellClick, IThrown +{ + + @Override + public void castSpell(final Player player) + { + shoot(player); + + for (int i = 1; i < getSpellLevel(player) * 2; i++) + { + + Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable() + { + + @Override + public void run() + { + shoot(player); + } + + }, i * 10); + } + + charge(player); + } + + private void shoot(Player player) + { + + if (Wizards.IsAlive(player)) + { + org.bukkit.entity.Item ent = player.getWorld().dropItem( + player.getEyeLocation(), + ItemStackFactory.Instance.CreateStack(Material.WEB, (byte) 0, 1, + "Web " + player.getName() + " " + System.currentTimeMillis())); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 1.5, false, 0, 0.2, 10, false); + Wizards.getArcadeManager().GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 2f); + + player.getWorld().playSound(player.getLocation(), Sound.CLICK, 1.2F, 0.8F); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target != data.GetThrower()) + { + Location loc = data.GetThrown().getLocation(); + + if (target != null) + { + Location l = target.getLocation(); + + l.setY(loc.getY()); + + if (!UtilBlock.airFoliage(getValidLocation(l))) + { + l = target.getLocation().add(0, UtilMath.random.nextFloat(), 0); + + if (UtilBlock.airFoliage(getValidLocation(l))) + { + loc = l; + } + } + else + { + loc = l; + } + + // Damage Event + Wizards.getArcadeManager() + .GetDamage() + .NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 2, false, false, false, + "Web Shot", "Web Shot"); + } + + Web(data, loc); + } + } + + private Block getValidLocation(Location loc) + { + double[] doubles = new double[] + { + 0, -0.5, 0.5 + }; + + HashMap commonBlocks = new HashMap(); + int most = 0; + + for (double x : doubles) + { + for (double y : doubles) + { + for (double z : doubles) + { + Block b = loc.clone().add(x, y, z).getBlock(); + + if (UtilBlock.airFoliage(b)) + { + int amount = (commonBlocks.containsKey(b) ? commonBlocks.get(b) : 0) + 1; + + commonBlocks.put(b, amount); + + if (amount > most) + { + most = amount; + } + } + } + } + } + + for (Entry entry : commonBlocks.entrySet()) + { + if (entry.getValue() == most) + { + return entry.getKey(); + } + } + + return loc.getBlock(); + } + + @Override + public void Idle(ProjectileUser data) + { + Web(data, data.GetThrown().getLocation()); + } + + @Override + public void Expire(ProjectileUser data) + { + Web(data, data.GetThrown().getLocation()); + } + + public void Web(ProjectileUser data, Location loc) + { + data.GetThrown().remove(); + + Block block = getValidLocation(loc); + + if (UtilBlock.airFoliage(block)) + block.setType(Material.WEB); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWizardsCompass.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWizardsCompass.java index af4fa7c1d..d68fb677f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWizardsCompass.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellWizardsCompass.java @@ -1,62 +1,128 @@ package nautilus.game.arcade.game.games.wizards.spells; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilShapes; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.hologram.Hologram; +import mineplex.core.hologram.Hologram.HologramTarget; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; -import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; public class SpellWizardsCompass extends Spell implements SpellClick { - @Override - public void castSpell(Player p) - { - double dist = 9999; - Player closestPlayer = null; + @Override + public void castSpell(Player p) + { + Location loc = p.getEyeLocation().subtract(0, 1, 0); - for (Player player : Wizards.GetPlayers(true)) - { - double newDist = player.getLocation().distance(p.getLocation()); + final ArrayList colors = new ArrayList(); - if (newDist > 10 && (closestPlayer == null || newDist < dist)) - { + for (int x = -1; x <= 1; x++) + { - closestPlayer = player; - dist = newDist; + for (int y = -1; y <= 1; y++) + { - } - } + for (int z = -1; z <= 1; z++) + { + colors.add(new Integer[] + { + x, y, z + }); + } + } + } - if (closestPlayer != null) - { - int particlesPlayed = 0; + Collections.shuffle(colors); - for (Location loc : UtilShapes.getLinesDistancedPoints( - p.getEyeLocation().subtract(p.getEyeLocation().getDirection().normalize().multiply(-0.3)).subtract(0, .5, 0), - closestPlayer.getEyeLocation(), 0.3)) - { + for (Player enemy : Wizards.GetPlayers(true)) + { + if (enemy == p) + { + continue; + } - if (particlesPlayed++ > 13) - { - break; - } + final double playerDist = Math.min(7, UtilMath.offset(enemy, p)); - loc.getWorld().spigot().playEffect(loc, Effect.HAPPY_VILLAGER, 0, 0, 0.1F, 0.1F, 0.1F, 0, 4, 25); + final Vector traj = UtilAlg.getTrajectory(p.getLocation(), enemy.getEyeLocation()).multiply(0.1); - } + final Hologram hologram = new Hologram(Wizards.getArcadeManager().getHologramManager(), loc.clone().add(0, 0.3, 0) + .add(traj.clone().normalize().multiply(playerDist)), enemy.getName()); - charge(p); - } - else - { + hologram.setHologramTarget(HologramTarget.WHITELIST); + hologram.addPlayer(p); - p.sendMessage(C.cRed + "All players are less than 10 blocks from you!"); + hologram.start(); - } + final Location location = loc.clone(); + final Integer[] ints = colors.remove(0); - } + new BukkitRunnable() + { + int dist; + int tick; + HashMap locations = new HashMap(); + + public void run() + { + tick++; + + Iterator> itel = locations.entrySet().iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + + if ((entry.getValue() + tick) % 3 == 0) + { + // Colored redstone dust + UtilParticle.PlayParticle(ParticleType.RED_DUST, entry.getKey(), ints[0], ints[1], ints[2], 1, 0); + } + + if (entry.getValue() < tick) + { + itel.remove(); + } + } + + if (dist <= playerDist * 10) + { + for (int a = 0; a < 2; a++) + { + // Colored redstone dust + UtilParticle.PlayParticle(ParticleType.RED_DUST, location, ints[0], ints[1], ints[2], 1, 0); + + locations.put(location.clone(), tick + 50); + + location.add(traj); + dist++; + } + } + else if (locations.isEmpty()) + { + hologram.stop(); + cancel(); + } + } + }.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0); + } + + p.playSound(p.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1); + + charge(p); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/ExplosiveRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/ExplosiveRune.java deleted file mode 100644 index d103843df..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/ExplosiveRune.java +++ /dev/null @@ -1,62 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells.subclasses; - -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.minecraft.game.core.damage.DamageManager; -import mineplex.minecraft.game.core.explosion.CustomExplosion; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public class ExplosiveRune -{ - private Location _explosiveLocation; - private Player _explosiveOwner; - private float _explosiveSize; - private int _ticksTillExplode = 60; - private DamageManager _damageManager; - - public boolean onTick() - { - _ticksTillExplode--; - - if (_ticksTillExplode <= 0) - { - CustomExplosion explosion = new CustomExplosion(_damageManager, _explosiveLocation, _explosiveSize, "Explosive Rune"); - - explosion.setPlayer(_explosiveOwner, true); - - explosion.setDropItems(false); - - explosion.explode(); - - drawBoxParticles(); - return true; - - } - return false; - } - - public ExplosiveRune(DamageManager damageManager, Location loc, Player player, float size) - { - _explosiveLocation = loc; - _explosiveOwner = player; - _explosiveSize = size; - _damageManager = damageManager; - drawBoxParticles(); - } - - public Location getLocation() - { - return _explosiveLocation; - } - - private void drawBoxParticles() - { - for (Location loc : UtilShapes.getDistancedCircle(_explosiveLocation, 0.3, _explosiveSize * 1.3D)) - { - UtilParticle.PlayParticle(ParticleType.FLAME, loc, 0, 0, 0, 0, 1); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/HealingRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/HealingRune.java deleted file mode 100644 index b685e3885..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/HealingRune.java +++ /dev/null @@ -1,84 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells.subclasses; - -import java.util.ArrayList; - -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilShapes; -import nautilus.game.arcade.game.games.wizards.Wizards; - -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class HealingRune -{ - private Location _location; - private int _ticksToLive; - private double _runeSize; - private Wizards _wizards; - - public HealingRune(Wizards wizards, Location location, int spellLevel) - { - _location = location; - _ticksToLive = 100 + (spellLevel * 60); - _runeSize = 2 + (spellLevel * .5D); - _wizards = wizards; - } - - public boolean onTick() - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (player.getGameMode() == GameMode.CREATIVE) - { - continue; - } - - Location loc = player.getLocation().clone(); - - if (loc.getY() >= _location.getY() && loc.getY() <= _location.getY() + 2) - { - loc.setY(_location.getY()); - - if (loc.distance(_location) <= _runeSize) - { - _wizards.getArcadeManager().GetCondition().Factory().Regen("Healing Rune", player, null, 50, 0, false, false, true); - } - } - } - - double currentY = 0; - ArrayList locs = UtilShapes.getDistancedCircle(_location, 0.2D, _runeSize); - double addY = 1.5D / locs.size(); - - int a = UtilMath.r(locs.size()); - for (int b = 0; b < 2; b++) - { - for (int i = 0; i < locs.size(); i++) - { - a++; - - if (i % 30 == _ticksToLive % 30) - { - Location loc = locs.get(a % locs.size()); - - UtilParticle.PlayParticle(ParticleType.HEART, loc.clone().add(0, currentY, 0), 0, 0, 0, 0, 1); - } - - currentY += addY; - } - } - - if (_ticksToLive-- <= 0) - { - return true; - } - - return false; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/LaunchRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/LaunchRune.java deleted file mode 100644 index bf936f7ad..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/LaunchRune.java +++ /dev/null @@ -1,112 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells.subclasses; - -import java.util.HashMap; -import java.util.UUID; - -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilParticle.ParticleType; -import nautilus.game.arcade.game.games.wizards.Wizards; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class LaunchRune -{ - private Player _caster; - private Wizards _wizards; - private Location _runeLocation; - private float _runeSize; - private int _ticksTillActive = 60; - private int _spellLevel; - private HashMap _launchedEntities = new HashMap(); - - public boolean onTick() - { - _ticksTillActive--; - boolean launched = false; - - if (_ticksTillActive <= 0) - { - for (LivingEntity entity : _runeLocation.getWorld().getEntitiesByClass(LivingEntity.class)) - { - - if (!(entity instanceof Player) || !UtilPlayer.isSpectator(entity)) - { - - UUID uuid = entity.getUniqueId(); - - if (!_launchedEntities.containsKey(uuid) || _launchedEntities.get(uuid) < System.currentTimeMillis()) - { - - Location loc = entity.getLocation(); - - if (loc.getY() >= _runeLocation.getY() - 0.1 && loc.getY() <= _runeLocation.getY() + 1.3) - { - - loc.setY(_runeLocation.getY()); - - if (loc.distance(_runeLocation) <= _runeSize) - { - _wizards.getArcadeManager().GetCondition().Factory() - .Falling("Launch Rune", entity, _caster, 10, false, false); - - Vector vector = entity.getLocation().getDirection().normalize().multiply(0.1); - vector.setY(1F + (_spellLevel * 0.15F)); - entity.setVelocity(vector); - entity.setFallDistance(-_spellLevel * 1.5F); - - launched = true; - - _launchedEntities.put(uuid, System.currentTimeMillis() + (long) (_runeSize * 2500L)); - } - } - } - } - } - } - - if (launched) - { - _runeLocation.getWorld().playSound(_runeLocation, Sound.BAT_TAKEOFF, 1.2F, 1F); - displayCircle(5); - } - else if (_ticksTillActive % (_ticksTillActive >= 0 ? 20 : 7) == 0) - { - displayCircle(1); - } - - return _ticksTillActive < -60 * 20; - } - - private void displayCircle(int loops) - { - for (double y = 0; y < loops * 0.2D; y += 0.2D) - { - for (Location loc : UtilShapes.getDistancedCircle(_runeLocation, 0.3D, _runeSize)) - { - UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0, 0, 0, 0, 1); - } - } - } - - public LaunchRune(Wizards wizards, Player caster, Location loc, float size, int spellLevel) - { - _wizards = wizards; - _caster = caster; - _runeLocation = loc; - _runeSize = size; - _spellLevel = spellLevel; - displayCircle(1); - } - - public Location getLocation() - { - return _runeLocation; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TeleportRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TeleportRune.java deleted file mode 100644 index 407206350..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TeleportRune.java +++ /dev/null @@ -1,118 +0,0 @@ -package nautilus.game.arcade.game.games.wizards.spells.subclasses; - -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilShapes; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class TeleportRune -{ - private Location _firstLoc, _secondLoc; - private int _ticksLived = -60; - private double _runeSize; - - public TeleportRune(Location firstLocation, Location secondLocation, double runeSize) - { - _firstLoc = firstLocation; - _secondLoc = secondLocation; - _runeSize = runeSize; - } - - /** - * Returns true on remove - */ - public boolean tickRune() - { - if (_ticksLived >= 150) - { - return true; - } - - if (_ticksLived % 5 == 0) - { - resendRunes(); - } - - if (_ticksLived >= 0) - { - if (_ticksLived % 40 == 0) - { - _firstLoc.getWorld().playSound(_firstLoc, Sound.PORTAL, 1.5F, 0F); - _firstLoc.getWorld().playSound(_secondLoc, Sound.PORTAL, 1.5F, 0F); - } - - for (LivingEntity entity : _firstLoc.getWorld().getEntitiesByClass(LivingEntity.class)) - { - if (entity instanceof Player && UtilPlayer.isSpectator(entity)) - { - continue; - } - - Location loc = entity.getLocation(); - - if (loc.distance(_firstLoc) <= _runeSize && loc.getBlockY() >= _firstLoc.getBlockY() - && loc.getBlockY() <= _firstLoc.getBlockY() + 2) - { - - for (double y = 0; y < 2; y += 0.5) - { - UtilParticle.PlayParticle(ParticleType.PORTAL, _secondLoc.clone().add(0, y, 0), 1.5F, 1.5F, 1.5F, 0F, 40); - } - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, _secondLoc.clone().add(0, 1, 0), 0, 0, 0, 0, 5); - - _secondLoc.getWorld().playSound(_secondLoc, Sound.ENDERMAN_TELEPORT, 3, 0); - - Location newLoc = _secondLoc.clone(); - newLoc.setDirection(entity.getEyeLocation().getDirection()); - entity.setFallDistance(0F); - - entity.teleport(newLoc); - } - } - } - - _ticksLived++; - return false; - } - - private void makeCircle(Location loc, double distance) - { - for (Location l : UtilShapes.getPointsInCircle(loc, (int) Math.ceil(Math.PI * distance * 2), distance)) - { - UtilParticle.PlayParticle(_ticksLived >= 0 ? ParticleType.FIREWORKS_SPARK : ParticleType.RED_DUST, l, 0, 0, 0, 0, 1); - } - } - - private void redrawRunes(Location runeLoc) - { - runeLoc = runeLoc.clone(); - if (_ticksLived >= 0) - { - for (double y = 0; y < 1; y += 0.4) - { - runeLoc.add(0, y, 0); - makeCircle(runeLoc, _runeSize); - makeCircle(runeLoc, (_runeSize / 3) * 2); - } - } - else - { - makeCircle(runeLoc, _runeSize); - } - } - - /** - * Resending runes resends the particles. - */ - public void resendRunes() - { - redrawRunes(_firstLoc); - redrawRunes(_secondLoc); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TrapRune.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TrapRune.java index b4b558c79..73abced3d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TrapRune.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/TrapRune.java @@ -1,15 +1,188 @@ package nautilus.game.arcade.game.games.wizards.spells.subclasses; +import java.util.ArrayList; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.minecraft.game.core.explosion.CustomExplosion; +import nautilus.game.arcade.game.games.wizards.Wizards; + +import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; public class TrapRune { - // TODO Methods and potentially move code into here - public Location RuneLocation; - public float RuneSize; - public Player RuneCaster; - public int TicksLived; + private Location _runeLocation; + private float _runeSize; + private Player _runeCaster; + private int _ticksLived; + private Wizards _wizards; + private int _spellLevel; + public boolean onRuneTick() + { + + if (!_runeCaster.isOnline() || UtilPlayer.isSpectator(_runeCaster)) + { + return true; + } + else if (_ticksLived++ > 2000) + { + return true; + } + else + { + if (_ticksLived <= 100) + { + if (_ticksLived % 15 == 0) + { + initialParticles(); + } + + if (_ticksLived == 100) + { + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _runeLocation, 0, _runeSize / 4, 0, _runeSize / 4, + (int) (_runeSize * 10)); + } + } + else + { + if (!isValid()) + { + trapCard(); + return true; + } + else + { + for (Player player : _wizards.GetPlayers(true)) + { + if (isInTrap(player.getLocation())) + { + trapCard(); + return true; + } + } + } + } + } + return false; + } + + public TrapRune(Wizards wizards, Player player, Location location, int spellLevel) + { + _wizards = wizards; + _runeCaster = player; + _runeLocation = location; + _spellLevel = spellLevel; + _runeSize = Math.max(1, spellLevel * 0.8F); + } + + public void initialParticles() + { + for (Location loc : getBox(0.3)) + { + for (double y = 0; y < 1; y += 0.2) + { + _runeLocation.getWorld().spigot().playEffect(loc, Effect.SMALL_SMOKE, 0, 0, 0, 0, 0, 0, 1, 30); + } + } + } + + public ArrayList getBox(double spacing) + { + ArrayList boxLocs = getBoxCorners(); + ArrayList returns = new ArrayList(); + + for (int i = 0; i < boxLocs.size(); i++) + { + + int a = i + 1 >= boxLocs.size() ? 0 : i + 1; + returns.addAll(UtilShapes.getLinesDistancedPoints(boxLocs.get(i), boxLocs.get(a), spacing)); + returns.add(boxLocs.get(i)); + + } + return returns; + } + + public ArrayList getBoxCorners() + { + ArrayList boxPoints = new ArrayList(); + + boxPoints.add(_runeLocation.clone().add(-_runeSize, 0, -_runeSize)); + boxPoints.add(_runeLocation.clone().add(_runeSize, 0, -_runeSize)); + boxPoints.add(_runeLocation.clone().add(_runeSize, 0, _runeSize)); + boxPoints.add(_runeLocation.clone().add(-_runeSize, 0, _runeSize)); + + return boxPoints; + } + + public boolean isInTrap(Location loc) + { + if (loc.getX() >= _runeLocation.getX() - _runeSize && loc.getX() <= _runeLocation.getX() + _runeSize) + { + if (loc.getZ() >= _runeLocation.getZ() - _runeSize && loc.getZ() <= _runeLocation.getZ() + _runeSize) + { + if (loc.getY() >= _runeLocation.getY() - 0.1 && loc.getY() <= _runeLocation.getY() + 0.9) + { + return true; + } + } + } + return false; + } + + public boolean isValid() + { + return !UtilBlock.solid(_runeLocation.getBlock()) + || UtilBlock.solid(_runeLocation.getBlock().getRelative(BlockFace.DOWN)); + /* + for (double x = -RuneSize; x <= RuneSize; x++) + { + for (double z = -RuneSize; z <= RuneSize; z++) + { + + Block b = RuneLocation.clone().add(x, 0, z).getBlock(); + if (UtilBlock.solid(b) || !UtilBlock.solid(b.getRelative(BlockFace.DOWN))) + { + return false; + } + + } + }*/ + } + + public void trapCard() + { + _runeLocation.getWorld().playSound(_runeLocation, Sound.WITHER_SHOOT, 5, (float) _runeSize * 2); + + CustomExplosion explosion = new CustomExplosion(_wizards.getArcadeManager().GetDamage(), _wizards.getArcadeManager() + .GetExplosion(), _runeLocation.clone().add(0, 0.3, 0), (float) _runeSize * 1.2F, "Trap Rune"); + + explosion.setPlayer(_runeCaster, true); + + explosion.setBlockExplosionSize((float) _runeSize * 2F); + + explosion.setFallingBlockExplosion(true); + + explosion.setDropItems(false); + + explosion.setMaxDamage((_spellLevel * 4) + 6); + + explosion.explode(); + + for (Location loc : getBox(0.3)) + { + for (double y = 0; y < 1; y += 0.2) + { + _runeLocation.getWorld().spigot().playEffect(loc, Effect.SMOKE, 0, 0, 0, 0, 0, 0, 1, 30); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/IcePathData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/IcePathData.java index b308da2e1..9375879d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/IcePathData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/data/IcePathData.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import mineplex.core.common.util.UtilMath; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -76,10 +77,10 @@ public class IcePathData loc.add(dir.clone().multiply(0.2)); - if (loc.getBlock().getTypeId() == 79) + if (loc.getBlock().getType() == Material.ICE) continue; - if (loc.getBlock().getTypeId() == 0 || loc.getBlock().getTypeId() == 78) + if (loc.getBlock().getType() == Material.AIR || loc.getBlock().getType() == Material.SNOW) { if (!_blocks.contains(loc.getBlock())) {