diff --git a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml index cd4447b88..3f5cae6e4 100644 --- a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml +++ b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index b260e2fe0..25c4be6ac 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -4,7 +4,7 @@ - + @@ -12,6 +12,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -22,13 +48,15 @@ + + + + - - diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutWorldParticles.java b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutWorldParticles.java new file mode 100644 index 000000000..c68e25f76 --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutWorldParticles.java @@ -0,0 +1,179 @@ +package net.minecraft.server.v1_7_R4; + +import java.io.IOException; +import java.util.HashMap; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketDataSerializer; +import net.minecraft.server.v1_7_R4.PacketListener; +import net.minecraft.server.v1_7_R4.PacketPlayOutListener; + +public class PacketPlayOutWorldParticles extends Packet { + private String a; + private float b; + private float c; + private float d; + private float e; + private float f; + private float g; + private float h; + private int i; + private boolean _displayFar; + + public PacketPlayOutWorldParticles() { + } + + public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i) { + this(s, f, f1, f2, f3, f4, f5, f6, i, false); + } + + public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i, boolean displayFar) { + this.a = s; + this.b = f; + this.c = f1; + this.d = f2; + this.e = f3; + this.f = f4; + this.g = f5; + this.h = f6; + this.i = i; + + _displayFar = displayFar; + } + + public void a(PacketDataSerializer packetdataserializer) throws IOException { + this.a = packetdataserializer.c(64); + this.b = packetdataserializer.readFloat(); + this.c = packetdataserializer.readFloat(); + this.d = packetdataserializer.readFloat(); + this.e = packetdataserializer.readFloat(); + this.f = packetdataserializer.readFloat(); + this.g = packetdataserializer.readFloat(); + this.h = packetdataserializer.readFloat(); + this.i = packetdataserializer.readInt(); + } + + public void b(PacketDataSerializer packetdataserializer) throws IOException { + String[] parts = this.a.split("_"); + PacketPlayOutWorldParticles.Particle particle = PacketPlayOutWorldParticles.Particle.find(parts[0]); + if(particle == null) { + particle = PacketPlayOutWorldParticles.Particle.CRIT; + } + + if(packetdataserializer.version < 17) { + packetdataserializer.a(this.a); + } else { + packetdataserializer.writeInt(particle.ordinal()); + packetdataserializer.writeBoolean(_displayFar); + } + + packetdataserializer.writeFloat(this.b); + packetdataserializer.writeFloat(this.c); + packetdataserializer.writeFloat(this.d); + packetdataserializer.writeFloat(this.e); + packetdataserializer.writeFloat(this.f); + packetdataserializer.writeFloat(this.g); + packetdataserializer.writeFloat(this.h); + packetdataserializer.writeInt(this.i); + if(packetdataserializer.version >= 17) { + for(int i = 0; i < particle.extra; ++i) { + int toWrite = 0; + if(parts.length - 1 > i) { + try { + toWrite = Integer.parseInt(parts[i + 1]); + if(particle.extra == 1 && parts.length == 3) { + ++i; + toWrite |= Integer.parseInt(parts[i + 1]) << 12; + } + } catch (NumberFormatException var7) { + ; + } + } + + packetdataserializer.b(toWrite); + } + } + + } + + public void a(PacketPlayOutListener packetplayoutlistener) { + packetplayoutlistener.a(this); + } + + public void handle(PacketListener packetlistener) { + this.a((PacketPlayOutListener)packetlistener); + } + + private static enum Particle { + EXPLOSION_NORMAL("explode"), + EXPLOSION_LARGE("largeexplode"), + EXPLOSION_HUGE("hugeexplosion"), + FIREWORKS_SPARK("fireworksSpark"), + WATER_BUBBLE("bubble"), + WATER_SPLASH("splash"), + WATER_WAKE("wake"), + SUSPENDED("suspended"), + SUSPENDED_DEPTH("depthsuspend"), + CRIT("crit"), + CRIT_MAGIC("magicCrit"), + SMOKE_NORMAL("smoke"), + SMOKE_LARGE("largesmoke"), + SPELL("spell"), + SPELL_INSTANT("instantSpell"), + SPELL_MOB("mobSpell"), + SPELL_MOB_AMBIENT("mobSpellAmbient"), + SPELL_WITCH("witchMagic"), + DRIP_WATER("dripWater"), + DRIP_LAVA("dripLava"), + VILLAGER_ANGRY("angryVillager"), + VILLAGER_HAPPY("happyVillager"), + TOWN_AURA("townaura"), + NOTE("note"), + PORTAL("portal"), + ENCHANTMENT_TABLE("enchantmenttable"), + FLAME("flame"), + LAVA("lava"), + FOOTSTEP("footstep"), + CLOUD("cloud"), + REDSTONE("reddust"), + SNOWBALL("snowballpoof"), + SNOW_SHOVEL("snowshovel"), + SLIME("slime"), + HEART("heart"), + BARRIER("barrier"), + ICON_CRACK("iconcrack", 2), + BLOCK_CRACK("blockcrack", 1), + BLOCK_DUST("blockdust", 1), + WATER_DROP("droplet"), + ITEM_TAKE("take"), + MOB_APPEARANCE("mobappearance"); + + public final String name; + public final int extra; + private static final HashMap particleMap; + + private Particle(String name) { + this(name, 0); + } + + private Particle(String name, int extra) { + this.name = name; + this.extra = extra; + } + + public static PacketPlayOutWorldParticles.Particle find(String part) { + return (PacketPlayOutWorldParticles.Particle)particleMap.get(part); + } + + static { + particleMap = new HashMap(); + PacketPlayOutWorldParticles.Particle[] var0 = values(); + int var1 = var0.length; + + for(int var2 = 0; var2 < var1; ++var2) { + PacketPlayOutWorldParticles.Particle particle = var0[var2]; + particleMap.put(particle.name, particle); + } + + } + } +} \ No newline at end of file diff --git a/Plugins/Libraries/craftbukkit.jar b/Plugins/Libraries/craftbukkit.jar index 2fb5e8580..74d42a85b 100644 Binary files a/Plugins/Libraries/craftbukkit.jar and b/Plugins/Libraries/craftbukkit.jar differ diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index e420dfaa7..c1e19b5f8 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -1,5 +1,6 @@ package mineplex.bungee.motd; +import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; @@ -53,23 +54,13 @@ public class MotdManager implements Listener, Runnable public void run() { // Add in default MOTD listing to database - /* - if (!_repository.elementExists("MainMotd")) - { - _repository.removeElement("MainMotd"); List lines = new ArrayList(); - lines.add(" §a§lDouble Gems for 1.8 Players!"); - lines.add(" §e§lChampions Update §a§lBalance Patch"); - lines.add(" §6§lSpecial Egg Baskets!"); - lines.add(" §e§lBunny Morph §a§lLimited Time!"); - lines.add(" §d§lHero Sale §a§l33% Off"); - lines.add(" §a§lDouble Gems for 1.8 Players!"); + lines.add(" §d§lMaster Builders§f - §d§lWizards§f - §d§lGravity"); + //lines.add(" §d§lRank Sale §a§l40% Off"); updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines); - } - */ - + GlobalMotd motd = _repository.getElement("MainMotd"); if (motd != null) 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..33d33f950 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,231 @@ package mineplex.core.common.util; - + import java.lang.reflect.Field; +import mineplex.core.common.util.UtilParticle.ViewDist; 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 + public enum ViewDist { - 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"); - - public String particleName; - - ParticleType(String particleName) - { - this.particleName = particleName; - } + SHORT(8), + NORMAL(24), + LONG(48), + LONGER(96), + MAX(256); + + private int _dist; + + ViewDist(int dist) + { + _dist = dist; + } + + public int getDist() + { + return _dist; + } } - 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) + public enum ParticleType { - for (Player player : UtilServer.getPlayers()) + ANGRY_VILLAGER("angryVillager", "Lightning Cloud", Material.INK_SACK, (byte) 11), + + BLOCK_CRACK("blockcrack_1_0") { - //Dont send to players who cannot see it! - if (type != ParticleType.FIREWORKS_SPARK && - type != ParticleType.LARGE_EXPLODE && - type != ParticleType.HUGE_EXPLOSION) + @Override + public String getParticle(Material type, int data) { - if (UtilMath.offset(player.getLocation(), location) > 24) - { - continue; - } + 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", "White Smoke", Material.INK_SACK, (byte) 7), + + CRIT("crit", "Brown Magic", Material.INK_SACK, (byte) 14), + + DEPTH_SUSPEND("depthSuspend"), + + DRIP_LAVA("dripLava", "Lava Drip", Material.LAVA_BUCKET, (byte) 0), + + DRIP_WATER("dripWater", "Water Drop", Material.WATER_BUCKET, (byte) 0), + + DROPLET("droplet", "Water Splash", Material.INK_SACK, (byte) 4), + + ENCHANTMENT_TABLE("enchantmenttable", "Enchantment Words", Material.BOOK, (byte) 0), + + EXPLODE("explode", "Big White Smoke", Material.INK_SACK, (byte) 15), + + FIREWORKS_SPARK("fireworksSpark", "White Sparkle", Material.GHAST_TEAR, (byte) 0), + + FLAME("flame", "Flame", Material.BLAZE_POWDER, (byte) 0), + + FOOTSTEP("footstep", "Foot Step", Material.LEATHER_BOOTS, (byte) 0), + + HAPPY_VILLAGER("happyVillager", "Emerald Sparkle", Material.EMERALD, (byte) 0), + + HEART("heart", "Love Heart", Material.APPLE, (byte) 0), + + HUGE_EXPLOSION("hugeexplosion", "Huge Explosion", Material.TNT, (byte) 0), + + ICON_CRACK("iconcrack_1_0") + { + @Override + public String getParticle(Material type, int data) + { + return "iconcrack_" + type.getId() + "_" + data; + } + }, + + INSTANT_SPELL("instantSpell"), + + LARGE_EXPLODE("largeexplode", "Explosion", Material.FIREBALL, (byte) 0), + + LARGE_SMOKE("largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0), + + LAVA("lava", "Lava Debris", Material.LAVA, (byte) 0), + + MAGIC_CRIT("magicCrit", "Teal Magic", Material.INK_SACK, (byte) 6), + + /** + * Can be colored if count is 0, color is RGB and depends on the offset of xyz + */ + MOB_SPELL("mobSpell", "Black Swirls", Material.getMaterial(2263), (byte) 0), + + /** + * Can be colored if count is 0, color is RGB and depends on the offset of xyz + */ + MOB_SPELL_AMBIENT("mobSpellAmbient", "Transparent Black Swirls", Material.getMaterial(2266), (byte) 0), + + NOTE("note", "Musical Note", Material.JUKEBOX, (byte) 0), + + PORTAL("portal", "Portal Effect", Material.INK_SACK, (byte) 5), + + /** + * 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", "Red Smoke", Material.INK_SACK, (byte) 1), + + SLIME("slime", "Slime Particles", Material.SLIME_BALL, (byte) 0), + + SNOW_SHOVEL("snowshovel", "Snow Puffs", Material.SNOW_BALL, (byte) 0), + + SNOWBALL_POOF("snowballpoof"), + + SPELL("spell", "White Swirls", Material.getMaterial(2264), (byte) 0), + + SPLASH("splash"), + + SUSPEND("suspended"), + + TOWN_AURA("townaura", "Black Specks", Material.COAL, (byte) 0), + + WITCH_MAGIC("witchMagic", "Purple Magic", Material.INK_SACK, (byte) 13); + + public String particleName; + private boolean _friendlyData; + private String _friendlyName; + private Material _material; + private byte _data; + + ParticleType(String particleName) + { + this.particleName = particleName; + _friendlyData = false; + } + + ParticleType(String particleName, String friendlyName, Material material, byte data) + { + this.particleName = particleName; + _friendlyData = true; + _friendlyName = friendlyName; + _material = material; + _data = data; + } + + public String getParticle(Material type, int data) + { + return particleName; + } + + public boolean hasFriendlyData() + { + return _friendlyData; + } + + public String getFriendlyName() + { + if (_friendlyName == null) + { + return toString(); } - PlayParticle(player, type, location, offsetX, offsetY, offsetZ, speed, count); + return _friendlyName; + } + + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public static ParticleType getFromFriendlyName(String name) + { + for (ParticleType type : values()) + { + if (type.hasFriendlyData() && type.getFriendlyName().equals(name)) + return type; + } + return null; + } + } + + private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY, + float offsetZ, float speed, int count, boolean displayFar) + { + + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, displayFar); + return packet; + } + + public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ, + float speed, int count, ViewDist dist, Player... players) + { + PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, players); + } + + public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ, + float speed, int count, ViewDist dist, Player... players) + { + PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true); + + for (Player player : players) + { + //Out of range for player + if (UtilMath.offset(player.getLocation(), location) > dist.getDist()) + continue; + + 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.Common/src/mineplex/core/common/util/UtilSkull.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java new file mode 100644 index 000000000..14925bf49 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilSkull.java @@ -0,0 +1,82 @@ +package mineplex.core.common.util; + +import org.bukkit.entity.*; + +public class UtilSkull +{ + public static byte getSkullData(Entity entity) + { + if (entity instanceof Skeleton) + { + Skeleton sk = ((Skeleton) entity); + if (sk.getSkeletonType() == Skeleton.SkeletonType.WITHER) + return 1; + else return 0; + } + else if (entity instanceof Zombie || entity instanceof Giant) + { + return 2; + } + else if (entity instanceof Creeper) + { + return 4; + } + else + return 3; + } + + public static boolean isPlayerHead(byte data) + { + return data == 3; + } + + public static String getPlayerHeadName(Entity entity) + { + String name = "MHF_Alex"; + + // order is important for some of these + if (entity instanceof Blaze) + name = "MHF_Blaze"; + else if (entity instanceof CaveSpider) + name = "MHF_CaveSpider"; + else if (entity instanceof Spider) + name = "MHF_Spider"; + else if (entity instanceof Chicken) + name = "MHF_Chicken"; + else if (entity instanceof MushroomCow) + name = "MHF_MushroomCow"; + else if (entity instanceof Cow) + name = "MHF_Cow"; + else if (entity instanceof Creeper) + name = "MHF_Creeper"; + else if (entity instanceof Enderman) + name = "MHF_Enderman"; + else if (entity instanceof Ghast) + name = "MHF_Ghast"; + else if (entity instanceof Golem) + name = "MHF_Golem"; + else if (entity instanceof PigZombie) + name = "MHF_PigZombie"; + else if (entity instanceof MagmaCube) + name = "MHF_LavaSlime"; + else if (entity instanceof Slime) + name = "MHF_Slime"; + else if (entity instanceof Ocelot) + name = "MHF_Ocelot"; + else if (entity instanceof PigZombie) + name = "MHF_PigZombie"; + else if (entity instanceof Pig) + name = "MHF_Pig"; + else if (entity instanceof Sheep) + name = "MHF_Pig"; + else if (entity instanceof Squid) + name = "MHF_Squid"; + else if (entity instanceof HumanEntity) + name = "MHF_Steve"; + else if (entity instanceof Villager) + name = "MHF_Villager"; + + return name; + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java index 26300c36d..56e4f6770 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTextBottom.java @@ -46,7 +46,7 @@ public class UtilTextBottom amount = 1 - amount; //Generate Bar - int bars = 52; + int bars = 24; String progressBar = C.cGreen + ""; boolean colorChange = false; for (int i=0 ; i> _log = new NautHashMap>(); + + private boolean _shopEnabled = true; public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager) { @@ -177,6 +179,9 @@ public class AchievementManager extends MiniPlugin @EventHandler public void openShop(PlayerInteractEvent event) { + if (!_shopEnabled) + return; + if (event.hasItem() && event.getItem().getType() == Material.SKULL_ITEM) { event.setCancelled(true); @@ -217,4 +222,9 @@ public class AchievementManager extends MiniPlugin return Achievement.getExperienceString(level) + " " + ChatColor.RESET; } + + public void setShopEnabled(boolean var) + { + _shopEnabled = var; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java index 652a4fb6d..c67a3286a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/chat/Chat.java @@ -207,82 +207,59 @@ public class Chat extends MiniPlugin if (event.isAsynchronous()) { - final Player player = event.getPlayer(); - //final String plyrname = player.toString(); - final String plyrname = player.getUniqueId().toString(); - final String msg = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim(); - //final String filtertype = "chat"; - final String filtertype = "moderate"; - final String dname = player.getPlayerListName(); - - - JSONObject message = buildJsonChatObject(filtertype, dname, plyrname, msg, _serverName, 1); - String response = getResponseFromCleanSpeak(message, filtertype); + String filteredMessage = getFilteredMessage(event.getPlayer(), event.getMessage()); - if (response == null) + for (Player onlinePlayer : event.getRecipients()) { - System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak."); - return; + onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage)); } - /* TESTING OUTPUT - POSSIBLY USEFUL - System.out.println(message); - System.out.println(response); - System.out.println(JSONValue.parse(response)); - //NullPointerException occasionally happening, JSONValue.parse(String) returns null randomly, why? + event.setCancelled(true); + } + } + + public String getFilteredMessage(Player player, String originalMessage) + { + final String playerName = player.getUniqueId().toString(); + originalMessage = originalMessage.replaceAll("[^\\x00-\\x7F]", "").trim(); + final String filterType = "moderate"; + final String displayName = player.getPlayerListName(); + + JSONObject message = buildJsonChatObject(filterType, displayName, playerName, originalMessage, _serverName, 1); + String response = getResponseFromCleanSpeak(message, filterType); + + if (response == null) + { + System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak."); + return originalMessage; + } + + /* TESTING OUTPUT - POSSIBLY USEFUL + System.out.println(message); + System.out.println(response); + System.out.println(JSONValue.parse(response)); + //NullPointerException occasionally happening, JSONValue.parse(String) returns null randomly, why? + + for (Object o : ((JSONObject)JSONValue.parse(response)).values()) + { + System.out.println(o.toString()); + } + */ + + String filteredMsg = ""; + + filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString(); + if (filteredMsg.contains("parts")) + { + filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("parts").toString(); + filteredMsg = filteredMsg.replace('[', ' ').replace(']', ' ').trim(); + filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("replacement").toString(); - for (Object o : ((JSONObject)JSONValue.parse(response)).values()) - { - System.out.println(o.toString()); - } - */ - - String filteredMsg = ""; - - filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString(); - if (filteredMsg.contains("parts")) - { - filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("parts").toString(); - filteredMsg = filteredMsg.replace('[', ' ').replace(']', ' ').trim(); - filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("replacement").toString(); - - for (Player onlinePlayer : event.getRecipients()) - { - onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMsg)); - } - - event.setCancelled(true); - } - - /* - int risk = Integer.parseInt(((JSONObject) JSONValue.parse(response)).get("risk").toString()); - - if (risk >= 5) - { - String filteredMessage = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim(); - - if (parseHashes(response) == null) - event.setMessage(ChatColor.RED + msg); - else - { - JSONArray hashindex = parseHashes(response); - String newmessage = hasher(hashindex, msg); - String badmessage = (new StringBuilder().append(newmessage)).toString(); - - if (newmessage.contains("*")) - { - filteredMessage = badmessage; - } - } - - for (Player onlinePlayer : event.getRecipients()) - { - onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage)); - } - - event.setCancelled(true); - } - */ + return filteredMsg; + } + else + { + return originalMessage; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java index 7d5b830fe..d41da36a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/CosmeticManager.java @@ -154,15 +154,22 @@ public class CosmeticManager extends MiniPlugin _gadgetManager.setActiveItemSlot(i-1); } - public void setActive(boolean b) + public void setActive(boolean showInterface) { - _showInterface = b; - - if (!b) + _showInterface = showInterface; + + if (!showInterface) + { for (Player player : UtilServer.getPlayers()) - player.getOpenInventory().close(); + { + if (player.getOpenInventory().getTopInventory().getHolder() != player) + { + player.closeInventory(); + } + } + } } - + public void disableItemsForGame() { _gadgetManager.DisableAll(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index b8b2bf46b..fc4699c30 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -40,9 +40,10 @@ public class DonationManager extends MiniDbClientPlugin @Override public void addCommands() { - addCommand(new GemCommand(this)); - addCommand(new CoinCommand(this)); - addCommand(new GoldCommand(this)); + // TODO: Re-add commands? Where are command implementations, seen as missing at the moment. + //addCommand(new GemCommand(this)); + //addCommand(new CoinCommand(this)); + //addCommand(new GoldCommand(this)); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index e984d3432..0345fbf59 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -145,7 +145,8 @@ public class Donor public void addGold(int amount) { - _gold += amount; + _gold = Math.max(0, _gold + amount); + } public List getCoinTransactions() 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/gadget/gadgets/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemBatGun.java index 24e3bbd85..990221e3c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ItemBatGun.java @@ -21,6 +21,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ItemGadget; import mineplex.core.recharge.Recharge; @@ -117,7 +118,8 @@ public class ItemBatGun extends ItemGadget //Effect bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f); - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, + ViewDist.NORMAL, UtilServer.getPlayers()); bat.remove(); @@ -138,7 +140,8 @@ public class ItemBatGun extends ItemGadget for (Bat bat : _bats.get(player)) { if (bat.isValid()) - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, + ViewDist.NORMAL, UtilServer.getPlayers()); bat.remove(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java index 541acc959..c93152737 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlaze.java @@ -11,7 +11,9 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBlaze; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.MorphGadget; @@ -65,8 +67,12 @@ public class MorphBlaze extends MorphGadget player.eject(); player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.2f, (float)(Math.random())); - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0f, 3); - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 1, 0), 0.1f, 0.1f, 0.1f, 0f, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0f, 3, + ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 1, 0), + 0.1f, 0.1f, 0.1f, 0f, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); UtilAction.velocity(player, 0.8, 0.1, 1, true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java index 5026ebbd7..7d84e2457 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBunny.java @@ -31,6 +31,7 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilServer; @@ -239,7 +240,8 @@ public class MorphBunny extends MorphGadget } else { - UtilParticle.PlayParticle(ParticleType.SPELL, egg.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1); + UtilParticle.PlayParticle(ParticleType.SPELL, egg.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java index 5a22b0fa7..965207894 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphCreeper.java @@ -17,7 +17,9 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCreeper; import mineplex.core.updater.UpdateType; @@ -98,7 +100,8 @@ public class MorphCreeper extends MorphGadget continue; //Explode - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0.5f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0.5f, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.8f); player.playEffect(EntityEffect.HURT); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java index b77c840ff..62ff23a36 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java @@ -23,8 +23,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.recharge.Recharge; @@ -115,7 +117,8 @@ public class MorphWither extends MorphGadget WitherSkull skull = (WitherSkull)event.getEntity(); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, skull.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, skull.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 2f, 1f); HashMap players = UtilPlayer.getInRadius(event.getLocation(), 6); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleBlizzard.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleBlizzard.java index f20373576..22732373a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleBlizzard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleBlizzard.java @@ -15,7 +15,9 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import mineplex.core.blood.BloodEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -53,7 +55,8 @@ public class ParticleBlizzard extends ParticleGadget if (Manager.isMoving(player)) { - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { @@ -68,11 +71,13 @@ public class ParticleBlizzard extends ParticleGadget double x = Math.sin(r + (i * (Math.PI/4))) * (r%(Math.PI * 4)) * 0.4; double z = Math.cos(r + (i * (Math.PI/4))) * (r%(Math.PI * 4)) * 0.4; - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(x, scale * 3, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(x, scale * 3, z), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); if (scale > 0.95 && Recharge.Instance.use(player, GetName(), 1000, false, false)) { - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, scale * 3.5, 0), 0f, 0f, 0f, 0.2f, 60); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, scale * 3.5, 0), 0f, 0f, 0f, 0.2f, 60, + ViewDist.NORMAL, UtilServer.getPlayers()); player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 1f, 1.5f); } } @@ -88,7 +93,8 @@ public class ParticleBlizzard extends ParticleGadget if (!event.getPlayer().isFlying()) if (IsActive(event.getPlayer())) - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getPlayer().getLocation(), 0f, 0f, 0f, 0.6f, 100); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getPlayer().getLocation(), 0f, 0f, 0f, 0.6f, 100, + ViewDist.NORMAL, UtilServer.getPlayers()); } @EventHandler @@ -115,7 +121,8 @@ public class ParticleBlizzard extends ParticleGadget if (!_arrows.remove(event.getEntity())) return; - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getEntity().getLocation(), 0f, 0f, 0f, 0.4f, 12); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getEntity().getLocation(), 0f, 0f, 0f, 0.4f, 12, + ViewDist.NORMAL, UtilServer.getPlayers()); } @EventHandler @@ -134,7 +141,8 @@ public class ParticleBlizzard extends ParticleGadget } else { - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, arrow.getLocation(), 0f, 0f, 0f, 0f, 1); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, arrow.getLocation(), 0f, 0f, 0f, 0f, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleEnchant.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleEnchant.java index 6de447af5..1225728a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleEnchant.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleEnchant.java @@ -7,7 +7,9 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -41,11 +43,13 @@ public class ParticleEnchant extends ParticleGadget if (Manager.isMoving(player)) { - UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4); + UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { - UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1.4, 0), 0f, 0f, 0f, 1, 4); + UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1.4, 0), 0f, 0f, 0f, 1, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFairyData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFairyData.java index ee7c601b9..00d4cd895 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFairyData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFairyData.java @@ -3,7 +3,9 @@ package mineplex.core.gadget.gadgets; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import org.bukkit.Location; import org.bukkit.Sound; @@ -72,8 +74,10 @@ public class ParticleFairyData Fairy.add(Direction.clone().multiply(Speed)); //Particle - UtilParticle.PlayParticle(ParticleType.FLAME, Fairy, 0, 0, 0, 0, 1); - UtilParticle.PlayParticle(ParticleType.LAVA, Fairy, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, Fairy, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LAVA, Fairy, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); //Sound Fairy.getWorld().playSound(Fairy, Sound.CAT_PURREOW, 0.1f, 3f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFireRings.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFireRings.java index bba47592d..3537558d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFireRings.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFireRings.java @@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -42,7 +44,8 @@ public class ParticleFireRings extends ParticleGadget if (Manager.isMoving(player)) { - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1f, 0), 0.2f, 0.2f, 0.2f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1f, 0), 0.2f, 0.2f, 0.2f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { @@ -55,7 +58,8 @@ public class ParticleFireRings extends ParticleGadget float y = (float) (Math.sin(player.getTicksLived()/5d + lead) + 1f); - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } for (int i=0 ; i < 1 ; i++) @@ -67,7 +71,8 @@ public class ParticleFireRings extends ParticleGadget float y = (float) (Math.sin(player.getTicksLived()/5d + lead) + 1f); - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } //Sound diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFoot.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFoot.java index e89548b0e..1e68a3d93 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFoot.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleFoot.java @@ -18,8 +18,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -90,9 +92,11 @@ public class ParticleFoot extends ParticleGadget _steps.put(loc, System.currentTimeMillis()); - UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc.clone().add(0, 0.1, 0), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc.clone().add(0, 0.1, 0), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java index cc8ec0128..9a370fad1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleGreen.java @@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -44,7 +46,8 @@ public class ParticleGreen extends ParticleGadget float z = (float) (Math.cos(player.getTicksLived()/7d) * 1f); float y = (float) (Math.cos(player.getTicksLived()/17d) * 1f + 1f); - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); // if (Manager.isMoving(player)) // { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHeart.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHeart.java index 4418644cc..61d602440 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHeart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHeart.java @@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -79,9 +80,11 @@ public class ParticleHeart extends ParticleGadget { } if (Manager.isMoving(player)) - UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); else - UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } @@ -96,7 +99,8 @@ public class ParticleHeart extends ParticleGadget { entry.getValue().add(UtilAlg.getTrajectory(entry.getValue(), entry.getKey().getEyeLocation()).multiply(0.6)); - UtilParticle.PlayParticle(ParticleType.HEART, entry.getValue(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, entry.getValue(), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); if (UtilMath.offset(entry.getValue(), entry.getKey().getEyeLocation()) < 0.6) heartIterator.remove(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHelix.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHelix.java index c9f615e7d..f573629ee 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHelix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleHelix.java @@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -42,7 +44,8 @@ public class ParticleHelix extends ParticleGadget if (Manager.isMoving(player)) { - UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4); + UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { @@ -59,7 +62,8 @@ public class ParticleHelix extends ParticleGadget float y = 0.15f * height; - UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(x * (1d - height/22d), y, z * (1d - height/22d)), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(x * (1d - height/22d), y, z * (1d - height/22d)), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleRain.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleRain.java index 42da0ef93..4300b5369 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleRain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleRain.java @@ -10,6 +10,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -43,17 +44,21 @@ public class ParticleRain extends ParticleGadget if (Manager.isMoving(player)) { - UtilParticle.PlayParticle(ParticleType.SPLASH, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4); + UtilParticle.PlayParticle(ParticleType.SPLASH, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { - UtilParticle.PlayParticle(player, ParticleType.EXPLODE, player.getLocation().add(0, 3.5, 0), 0.6f, 0f, 0.6f, 0, 8); + UtilParticle.PlayParticle(ParticleType.EXPLODE, player.getLocation().add(0, 3.5, 0), 0.6f, 0f, 0.6f, 0, 8, + ViewDist.NORMAL, player); for (Player other : UtilServer.getPlayers()) if (!player.equals(other)) - UtilParticle.PlayParticle(other, ParticleType.CLOUD, player.getLocation().add(0, 3.5, 0), 0.6f, 0.1f, 0.6f, 0, 8); + UtilParticle.PlayParticle(ParticleType.CLOUD, player.getLocation().add(0, 3.5, 0), 0.6f, 0.1f, 0.6f, 0, 8, + ViewDist.NORMAL, other); - UtilParticle.PlayParticle(ParticleType.DRIP_WATER, player.getLocation().add(0, 3.5, 0), 0.4f, 0.1f, 0.4f, 0, 2); + UtilParticle.PlayParticle(ParticleType.DRIP_WATER, player.getLocation().add(0, 3.5, 0), 0.4f, 0.1f, 0.4f, 0, 2, + ViewDist.NORMAL, UtilServer.getPlayers()); //Sound player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.1f, 1f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java index de334ad2a..c8751e8c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/SongData.java @@ -1,7 +1,9 @@ package mineplex.core.gadget.gadgets; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import org.bukkit.Material; import org.bukkit.block.Block; @@ -29,7 +31,8 @@ public class SongData return true; } - UtilParticle.PlayParticle(ParticleType.NOTE, Block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2); + UtilParticle.PlayParticle(ParticleType.NOTE, Block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2, + ViewDist.NORMAL, UtilServer.getPlayers()); return false; } 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/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 82081ee85..b531744a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -13,6 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -46,11 +47,12 @@ public class MessageManager extends MiniClientPlugin private HashMap _messageTimeouts = new HashMap(); private PreferencesManager _preferences; private Punish _punish; + private Chat _chat; private LinkedList _randomMessage; private String _serverName; public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, - IgnoreManager ignoreManager, Punish punish, FriendManager friendManager) + IgnoreManager ignoreManager, Punish punish, FriendManager friendManager, Chat chat) { super("Message", plugin); @@ -59,6 +61,7 @@ public class MessageManager extends MiniClientPlugin _ignoreManager = ignoreManager; _punish = punish; _friendsManager = friendManager; + _chat = chat; _serverName = getPlugin().getConfig().getString("serverstatus.name"); MessageHandler messageHandler = new MessageHandler(this); @@ -181,6 +184,8 @@ public class MessageManager extends MiniClientPlugin return; } + message = _chat.getFilteredMessage(from, message); + // Inform UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); @@ -278,6 +283,9 @@ public class MessageManager extends MiniClientPlugin _randomMessage.add("i like pie."); _randomMessage.add("Do you play Clash of Clans?"); _randomMessage.add("Mmm...Steak!"); + _randomMessage.add("Poop! Poop everywhere!"); + _randomMessage.add("I'm so forgetful. Like I was going to say somethin...wait what were we talking about?"); + _randomMessage.add("Mmm...Steak!"); } public CoreClientManager GetClientManager() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java index 5841acb1d..bf8d15f97 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountDragon.java @@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.mount.DragonData; @@ -42,17 +43,11 @@ public class MountDragon extends DragonMount if (event.getType() == UpdateType.TICK) { for (DragonData data : GetActive().values()) - for (Player player : UtilServer.getPlayers()) - { - try - { - UtilParticle.PlayParticle(player, ParticleType.WITCH_MAGIC, data.Dragon.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0f, 20); - } - catch (Exception e) - { - e.printStackTrace(); - } - } + { + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, data.Dragon.getLocation().add(0, 1, 0), + 1f, 1f, 1f, 0f, 20, + ViewDist.NORMAL, UtilServer.getPlayers()); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java index b34feedfb..e5b2d2bf8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java @@ -9,7 +9,9 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; import mineplex.core.updater.UpdateType; @@ -37,7 +39,9 @@ public class MountFrost extends HorseMount { if (event.getType() == UpdateType.TICK) for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0.1f, 4); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0.1f, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } // @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java index 50601382c..20a398d80 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java @@ -12,6 +12,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; import mineplex.core.updater.UpdateType; @@ -38,11 +39,15 @@ public class MountUndead extends HorseMount { if (event.getType() == UpdateType.TICK) for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 2); + UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 2, + ViewDist.NORMAL, UtilServer.getPlayers()); if (event.getType() == UpdateType.FAST) for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java index 251022932..a19cf5caa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/projectile/ProjectileUser.java @@ -6,7 +6,9 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseSquid; import net.minecraft.server.v1_7_R4.AxisAlignedBB; @@ -93,7 +95,8 @@ public class ProjectileUser _thrown.getWorld().playEffect(_thrown.getLocation(), _effect, _effectData); if (_particle != null) - UtilParticle.PlayParticle(_particle, _thrown.getLocation(), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(_particle, _thrown.getLocation(), 0f, 0f, 0f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } 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.Core/src/mineplex/core/serverConfig/ServerConfiguration.java b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java index d0c29b368..02cc887b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/serverConfig/ServerConfiguration.java @@ -50,7 +50,7 @@ public class ServerConfiguration extends MiniPlugin _plugin.getServer().setWhitelist(_serverGroup.getWhitelist()); ((CraftServer)_plugin.getServer()).getServer().setPvP(_serverGroup.getPvp()); - ((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack()); + //((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack()); } @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index 3f5b9d4ef..08680f868 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -13,12 +13,14 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers; import org.bukkit.entity.Player; -import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; +import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.hologram.HologramManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; @@ -133,7 +135,8 @@ public class Treasure if (_treasureType == TreasureType.OLD) { - UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4); + UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4, + ViewDist.NORMAL, UtilServer.getPlayers()); } else if (_treasureType == TreasureType.ANCIENT) { @@ -141,11 +144,13 @@ public class Treasure double xDif = 0.7 * Math.sin(Math.PI * (_tickCount / 5.0)); double zDif = 0.7 * Math.cos(Math.PI * (_tickCount / 5.0)); float red = 0.1F + (float)( 0.4 * (1 + Math.cos(Math.PI * (_tickCount / 20.0)))); - UtilParticle.PlayParticle(type, block.getLocation().add(0.5 + xDif, 0.5 + yDif, 0.5 + zDif), red, 0.2F, 0.2F, 1F, 0); + UtilParticle.PlayParticle(type, block.getLocation().add(0.5 + xDif, 0.5 + yDif, 0.5 + zDif), red, 0.2F, 0.2F, 1F, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { - UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0); + UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); } } } @@ -327,7 +332,8 @@ public class Treasure if (block.getType().equals(Material.CHEST)) { - UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10); + UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10, + ViewDist.NORMAL, UtilServer.getPlayers()); // block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F); } block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java index cc12d2eb0..545bc55e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ChestSpawnAnimation.java @@ -12,10 +12,11 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.util.Vector; import net.minecraft.server.v1_7_R4.MathHelper; - import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.treasure.BlockInfo; import mineplex.core.treasure.Treasure; import mineplex.core.treasure.TreasureType; @@ -82,7 +83,8 @@ public class ChestSpawnAnimation extends Animation //Play Particels if (getTreasure().getTreasureType() == TreasureType.OLD) { - UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } else if (getTreasure().getTreasureType() == TreasureType.ANCIENT) { @@ -93,7 +95,8 @@ public class ChestSpawnAnimation extends Animation newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale)); newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale)); - UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL) { @@ -107,7 +110,8 @@ public class ChestSpawnAnimation extends Animation float x = (float) (Math.sin(getTicks()/4D + lead)); float z = (float) (Math.cos(getTicks()/4D + lead)); - UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } @@ -122,7 +126,8 @@ public class ChestSpawnAnimation extends Animation if (particleType != null) { - UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50); + UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50, + ViewDist.NORMAL, UtilServer.getPlayers()); } else { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java index 7cd5e4742..aa2b224de 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootLegendaryAnimation.java @@ -11,6 +11,8 @@ import org.bukkit.block.Block; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.treasure.Treasure; /** @@ -55,7 +57,8 @@ public class LootLegendaryAnimation extends Animation double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; Location location = _centerLocation.clone().add(xDiff, 0, zDiff); - UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } else if (getTicks() < 40) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java index 33aadf2f0..5824c2db3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootRareAnimation.java @@ -8,6 +8,8 @@ import org.bukkit.FireworkEffect.Type; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.treasure.Treasure; /** @@ -52,7 +54,8 @@ public class LootRareAnimation extends Animation Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff); - UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } //Particle Spiral Up @@ -64,7 +67,8 @@ public class LootRareAnimation extends Animation double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; Location location = _centerLocation.clone().add(xDiff, -1.3, zDiff); - UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java index 3c3fdec93..c294d4840 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/LootUncommonAnimation.java @@ -9,6 +9,8 @@ import org.bukkit.block.Block; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.treasure.Treasure; /** @@ -42,7 +44,8 @@ public class LootUncommonAnimation extends Animation } else if (getTicks() % 2 == 0) { - UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java index 7c600900d..b717b39a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/animation/ParticleAnimation.java @@ -5,6 +5,8 @@ import java.util.ArrayList; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.treasure.Treasure; /** @@ -54,7 +56,8 @@ public class ParticleAnimation extends Animation { Vector position = PATH.get(pathPosition); - UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); pathPosition = (pathPosition + 1) % PATH.size(); } diff --git a/Plugins/Mineplex.Game.Clans/.classpath b/Plugins/Mineplex.Game.Clans/.classpath index 075cca472..d60d74d9e 100644 --- a/Plugins/Mineplex.Game.Clans/.classpath +++ b/Plugins/Mineplex.Game.Clans/.classpath @@ -8,5 +8,6 @@ + diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index b54f0b8bd..65c36c0e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,11 +1,13 @@ package mineplex.game.clans; +import org.bukkit.Location; import org.bukkit.plugin.java.JavaPlugin; -import net.minecraft.server.v1_7_R4.MinecraftServer; +import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.donation.DonationManager; import mineplex.core.explosion.Explosion; @@ -16,6 +18,7 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.memory.MemoryFix; import mineplex.core.message.MessageManager; import mineplex.core.monitor.LagMeter; +import mineplex.core.packethandler.PacketHandler; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Punish; @@ -28,6 +31,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; +import mineplex.game.clans.items.GearManager; import mineplex.game.clans.shop.building.BuildingShop; import mineplex.game.clans.shop.pvp.PvpShop; @@ -66,7 +70,10 @@ public class Clans extends JavaPlugin PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); - new Spawn(this, serverStatusManager.getCurrentServerName()); + + // TODO: Add spawn locations to a configuration file of some sort? + Spawn spawn = new Spawn(this, serverStatusManager.getCurrentServerName()); + Teleport teleport = new Teleport(this); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); @@ -79,7 +86,8 @@ public class Clans extends JavaPlugin BlockRestore blockRestore = new BlockRestore(this); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal)); + Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MemoryFix(this); new Explosion(this, blockRestore); @@ -91,7 +99,11 @@ public class Clans extends JavaPlugin new Farming(this); new BuildingShop(clans, _clientManager, _donationManager); new PvpShop(clans, _clientManager, _donationManager); - + + // Enable custom-gear related managers + PacketHandler packetHandler = new PacketHandler(this); + GearManager customGear = new GearManager(this, packetHandler); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ChunkData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ChunkData.java new file mode 100644 index 000000000..9eccb5170 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ChunkData.java @@ -0,0 +1,28 @@ +package mineplex.game.clans.clans; + +import org.bukkit.ChatColor; +import org.bukkit.Color; + +public class ChunkData +{ + + private int _x; + public int getX() { return _x; } + + private int _z; + public int getZ() { return _z; } + + private ChatColor _color; + public ChatColor getColor() { return _color; } + + private String _clanName; + public String getClanName() { return _clanName; } + + public ChunkData(int x, int z, ChatColor color, String clanName) + { + _x = x; + _z = z; + _color = color; + _clanName = clanName; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java index aa14e48e6..95524615c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyManager.java @@ -32,7 +32,7 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable for (final ClanInfo clanInfo : _clansManager.getClanMap().values()) { - if (clanInfo.isAdmin()) + if (clanInfo.isAdmin() || true) // TODO: Remove || true and implement ability to purchase Energy continue; int energyPerMinute = clanInfo.getEnergyCostPerMinute(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanRole.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanRole.java index 83901e238..3c70a4d80 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanRole.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanRole.java @@ -4,3 +4,4 @@ public enum ClanRole { NONE, RECRUIT, MEMBER, ADMIN, LEADER } + diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 0082036aa..b662d544e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -3,6 +3,7 @@ package mineplex.game.clans.clans; import java.util.HashSet; import java.util.TimeZone; +import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -10,6 +11,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.CustomTagFix; @@ -44,6 +46,7 @@ import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; import mineplex.game.clans.fields.Field; import mineplex.game.clans.gameplay.Gameplay; +import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; @@ -60,6 +63,9 @@ import mineplex.minecraft.game.core.mechanics.Weapon; public class ClansManager extends MiniClientPlugin implements IRelation { + public static final int FIELD_RADIUS = 128; + public static final int CLAIMABLE_RADIUS = 800; + public static final int WORLD_RADIUS = 1200; private static final TimeZone TIME_ZONE = TimeZone.getDefault(); private String _serverName; @@ -92,6 +98,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat private NautHashMap _claimMap = new NautHashMap(); private NautHashMap _unclaimMap = new NautHashMap(); + // Spawn area + public String[] denyClan = new String[] { "neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home"}; @@ -103,6 +111,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat _clientManager = clientManager; _combatManager = new CombatManager(plugin); + _blockRestore = blockRestore; _teleport = teleport; @@ -115,12 +124,14 @@ public class ClansManager extends MiniClientPlugin implements IRelat Energy energy = new Energy(plugin); PacketHandler packetHandler = new PacketHandler(plugin); - new CustomTagFix(plugin, packetHandler); + // TODO: Re-enable customtagfix with NCP update? + //new CustomTagFix(plugin, packetHandler); DisguiseManager disguiseManager = new DisguiseManager(plugin, packetHandler); _condition = new SkillConditionManager(plugin); Creature creature = new Creature(plugin); new Field(plugin, creature, _condition, energy, serverName); + new Spawn(plugin); DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager); @@ -186,6 +197,23 @@ public class ClansManager extends MiniClientPlugin implements IRelat return _clanMemberMap; } + public static boolean isClaimable(Location location) + { + int x = Math.abs(location.getBlockX()); + int z = Math.abs(location.getBlockZ()); + + return (x > FIELD_RADIUS || z > FIELD_RADIUS) + && (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS); + } + + public static boolean isFields(Location location) + { + int x = Math.abs(location.getBlockX()); + int z = Math.abs(location.getBlockZ()); + + return x <= FIELD_RADIUS && z <= FIELD_RADIUS; + } + public ClanInfo getClan(Player player) { return _clanMemberMap.get(player.getName()); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index a9ac01df5..2b0272a6f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -1,11 +1,15 @@ package mineplex.game.clans.clans; +import java.awt.Color; +import java.util.ArrayList; import java.util.LinkedList; +import java.util.List; import java.util.Map.Entry; import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.C; @@ -33,7 +37,49 @@ public class ClansUtility ADMIN, SAFE } - + + /** + * + * @param location + * @param radius + * @return a 2D array of {@link ClanTerritory} with uniform dimension of ({@code radius} * 2 + 1). The region represented by + * the array of territories is centered on {@code location} chunk with a given chunk {@code radius}. + */ + public List getTerritory(Location location, int radius, ClanInfo surveyorClan) + { + World world = location.getWorld(); + Chunk chunk = location.getChunk(); + int chunkX = chunk.getX(); + int chunkZ = chunk.getZ(); + int width = radius*2 + 1; + + List chunks = new ArrayList(); + + for (int x = 0; x < width; x++) + { + for (int z = 0; z < width; z++) + { + int territoryX = chunkX - radius + x; + int territoryZ = chunkZ - radius + z; + ClanTerritory territory = getClaim(world.getChunkAt(territoryX, territoryZ)); + + if (territory != null) + { + ClanInfo clan = getOwner(territory); + String clanName = territory.Owner; + ClanRelation relationship = rel(surveyorClan, clan); + ChatColor color = relChatColor(relationship, false); + + ChunkData data = new ChunkData(territoryX, territoryZ, color, clanName); + + chunks.add(data); + } + } + } + + return chunks; + } + public ClanInfo searchClanPlayer(Player caller, String name, boolean inform) { //CLAN @@ -197,11 +243,16 @@ public class ClansUtility return clan.getHome().getChunk().equals(chunk); } - + + public ClanTerritory getClaim(Chunk chunk) + { + String chunkTag = UtilWorld.chunkToStr(chunk); + return Clans.getClaimMap().get(chunkTag); + } + public ClanTerritory getClaim(Location loc) { - String chunk = UtilWorld.chunkToStr(loc.getChunk()); - return Clans.getClaimMap().get(chunk); + return getClaim(loc.getChunk()); } public ClanTerritory getClaim(String chunk) @@ -486,8 +537,9 @@ public class ClansUtility return true; } + public boolean isBorderlands(Location loc) { - return (Math.abs(loc.getX()) > 400 || Math.abs(loc.getZ()) > 400); + return Math.abs(loc.getBlockX()) > ClansManager.CLAIMABLE_RADIUS || Math.abs(loc.getBlockZ()) > ClansManager.CLAIMABLE_RADIUS; } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index bc5ee1494..11bed4f18 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -25,9 +25,13 @@ import mineplex.game.clans.clans.ClientClan; public class ClansCommand extends CommandBase { + private ClansManager _manager; + public ClansCommand(ClansManager plugin) { super(plugin, Rank.ALL, "c", "clans", "f", "factions"); + + _manager = plugin; } @Override @@ -784,12 +788,9 @@ public class ClansCommand extends CommandBase return; } - if (caller.getLocation().getChunk().getX() < -24 || - caller.getLocation().getChunk().getX() > 23 || - caller.getLocation().getChunk().getZ() < -24 || - caller.getLocation().getChunk().getZ() > 23) + if (!ClansManager.isClaimable(caller.getLocation())) { - UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory this far away.")); + UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!")); return; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 1d5437992..849f20a5f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -105,6 +105,7 @@ public class WarManager extends MiniPlugin { Player player = event.getEntity(); Player killer = player.getKiller(); + if (killer == null) return; // Wasn't killed by player ClanInfo playerClan = _clansManager.getClan(player); ClanInfo killerClan = _clansManager.getClan(killer); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java new file mode 100644 index 000000000..2268a2034 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/economy/GoldManager.java @@ -0,0 +1,114 @@ +package mineplex.game.clans.economy; + +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.game.clans.items.economy.GoldToken; +import mineplex.core.MiniPlugin; +import mineplex.core.common.CurrencyType; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.creature.Creature; +import mineplex.core.donation.DonationManager; +import mineplex.core.donation.Donor; +import mineplex.core.energy.Energy; +import mineplex.game.clans.Clans; +import mineplex.game.clans.fields.repository.FieldRepository; +import mineplex.game.clans.items.generation.WeightSet; +import mineplex.minecraft.game.core.condition.ConditionFactory; +import mineplex.minecraft.game.core.condition.ConditionManager; + +public class GoldManager extends MiniPlugin +{ + public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death + + private static GoldManager _instance; + public static GoldManager getInstance() { return _instance; } + + private DonationManager _donationManager; + + public GoldManager(JavaPlugin plugin, DonationManager donationManager) + { + super("Clans Gold", plugin); + + _instance = this; + _donationManager = donationManager; + } + + @EventHandler + public void onPlayerDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + Player killer = player.getKiller(); + + int gold = getGold(player); + int droppedGold = (int) (gold * DEATH_TAX); + + if (droppedGold > 0) + { + deductGold(player, droppedGold); + notify(player, String.format("You dropped %d gold on your death!", droppedGold)); + + if (killer != null) + { + addGold(killer, droppedGold); + notify(killer, String.format("You looted %d gold off of %s's corpse!", droppedGold, player.getName())); + } + } + } + + @EventHandler + public void playerCmd(PlayerCommandPreprocessEvent event) + { + if (event.getMessage().startsWith("/gold")) + { + notify(event.getPlayer(), "Your Balance is " + C.cYellow + getGold(event.getPlayer()) + "g"); + event.setCancelled(true); + } + } + + public int getGold(Player player) + { + return getDonor(player).getGold(); + } + + public void addGold(Player player, int amount) + { + getDonor(player).addGold(amount); + } + + public void deductGold(Player player, int amount) + { + addGold(player, -amount); + } + + public void cashIn(Player player, GoldToken token) + { + int value = token.getGoldValue(); + addGold(player, value); + notify(player, String.format("You have cashed in a gold token worth %dg!", value)); + } + + private Donor getDonor(Player player) + { + return _donationManager.Get(player.getName()); + } + + private void notify(Player player, String message) + { + UtilPlayer.message(player, F.main("Gold", message)); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java index aa98cb5d2..a9fc37918 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/FieldBlock.java @@ -26,6 +26,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.energy.Energy; +import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.fields.commands.FieldBlockCommand; import mineplex.game.clans.fields.commands.FieldOreCommand; import mineplex.game.clans.fields.repository.FieldBlockToken; @@ -206,17 +207,19 @@ public class FieldBlock extends MiniPlugin event.setCancelled(true); } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void BlockBreak(BlockBreakEvent event) - { - if (event.isCancelled()) - return; + { + if (ClansManager.isFields(event.getBlock().getLocation())) + { + event.setCancelled(true); // Cancel all block breaks in fields. Handle custom breaking for FieldBlocks and Ores. - FieldBlockData fieldBlock = getFieldBlock(event.getBlock()); - if (fieldBlock == null) return; - - fieldBlock.handleMined(event.getPlayer()); - event.setCancelled(true); + FieldBlockData fieldBlock = getFieldBlock(event.getBlock()); + if (fieldBlock != null) + { + fieldBlock.handleMined(event.getPlayer()); + } + } } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/LoggingManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/LoggingManager.java new file mode 100644 index 000000000..c2b1601cf --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/LoggingManager.java @@ -0,0 +1,251 @@ +package mineplex.game.clans.gameplay.safelog; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import mineplex.core.MiniPlugin; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.damage.DamageManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.items.commands.GearCommand; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Biome; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.plugin.java.JavaPlugin; + +public class LoggingManager extends MiniPlugin +{ + public static final double SAFE_LOG_RANGE = 32d; + public static final int LOGOUT_DURATION = 10000; // Duration of safe-log (in milliseconds) + public static final long REJOIN_TIME = 60000; + + //Track Offline Players + private HashMap _logouts; + + public LoggingManager(JavaPlugin plugin) + { + super("Logout Manager", plugin); + + _logouts = new HashMap(); + } + + private Set getNearbyHostilePlayers(Location location, double radius) + { + Set nearbyPlayers = new HashSet(); + + for (Player player : location.getWorld().getPlayers()) + { + double radiusSquared = radius * radius; + + if (player.getLocation().distanceSquared(location) <= radiusSquared) // TODO: Check to see if they're in a clan? + { + nearbyPlayers.add(player); + } + } + + return nearbyPlayers; + } + + public void onPlayerQuit(Player player) + { + LogoutData logoutData = _logouts.remove(player); + + boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout() && !player.isDead(); + + if (!isSafeLog && getNearbyHostilePlayers(player.getLocation(), 32d).size() == 1) // No other players within 32 blocks + { + isSafeLog = true; + } + + // TODO: Check to see if player was attacked or attacked another player within last 15 seconds and set isSafeLog=false... + if (!isSafeLog) + { + onCombatLog(player); + } + } + + public void onPlayerJoin(Player player) + { + // TODO: Check to see if the player has a combat-log bot in place + // and if so, remove/un-use it as they have logged back in. + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) + { + onPlayerQuit(event.getPlayer()); + } + + @EventHandler + public void onPlayerKicked(PlayerKickEvent event) + { + onPlayerQuit(event.getPlayer()); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + onPlayerJoin(event.getPlayer()); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + tick(); + } + + @Override + public void addCommands() + { + addCommand(new QuitCommand(this)); + } + + private LogoutData getLogoutData(Player player) + { + return _logouts.get(player.getName()); + } + + public LogoutData insertLogoutData(Player player, long duration) + { + LogoutData data = new LogoutData(player, duration); + _logouts.put(player.getName(), data); + + return data; + } + + public LogoutData insertLogoutData(Player player) + { + return insertLogoutData(player, LOGOUT_DURATION); + } + + public boolean hasLogoutData(Player player) + { + return getLogoutData(player) != null; + } + + /** + * Tick the internal logic of this manager and update it's state. + * Intended to be ticked/updated every in-game tick. + */ + private void tick() + { + for (String playerName : _logouts.keySet()) + { + LogoutData data = _logouts.get(playerName); + + if (data.isOnline()) + { + double distance = data.getDistanceTravelled(); + + if (distance >= SAFE_LOG_RANGE) + { + cancelSafeLog(data.getPlayer()); + } + else if (data.hasSafeLogout()) + { + // TODO: Log out player safely. + } + } + else + { + _logouts.remove(playerName); + } + } + } + + private void cancelSafeLog(Player player) + { + _logouts.remove(player.getName()); + // TODO: Notify player that safe-log was cancelled + } + + public void onCombatLog(Player player) + { + UtilInv.drop(player, true); // Drop player's inventory belongigs to ground + } + + @EventHandler(ignoreCancelled = true) + public void onPlayerInteract(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (hasLogoutData(player)) + { + cancelSafeLog(player); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onEntityDamaged(EntityDamageByEntityEvent event) + { + Entity victim = event.getEntity(); + + if (victim instanceof Player) + { + Player player = (Player) victim; + + if (hasLogoutData(player)) + { + cancelSafeLog(player); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onItemPickup(PlayerPickupItemEvent event) + { + if (hasLogoutData(event.getPlayer())) + { + event.setCancelled(true); // Prevent players that are safe-logging from picking up items. + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/LogoutData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/LogoutData.java new file mode 100644 index 000000000..5f311f35a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/LogoutData.java @@ -0,0 +1,46 @@ +package mineplex.game.clans.gameplay.safelog; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class LogoutData +{ + + private String _playerName; + public Player getPlayer() { return Bukkit.getPlayer(_playerName); } + + private long _endTime; + public boolean hasSafeLogout() { return System.currentTimeMillis() >= _endTime; } + + private long _startTime; + + private Location _location; + public Location getLocation() { return _location; } + + public LogoutData(Player player, long duration) + { + _startTime = System.currentTimeMillis(); + _endTime = _startTime + duration; + _location = player.getLocation(); + _playerName = player.getName(); + } + + public boolean isOnline() + { + Player player = getPlayer(); + return player != null && player.isOnline(); + } + + public double getDistanceTravelled() + { + if (isOnline()) + { + Player player = getPlayer(); + + return player.getLocation().distance(_location); + } + + return -1d; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/QuitCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/QuitCommand.java new file mode 100644 index 000000000..6b0d144c6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/QuitCommand.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.gameplay.safelog; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInput; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.ClientClan; +import mineplex.game.clans.items.CustomItem; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; +import mineplex.game.clans.items.attributes.weapon.FrostedAttribute; +import mineplex.game.clans.items.attributes.weapon.SharpAttribute; +import mineplex.game.clans.items.legendaries.LegendaryItem; +import mineplex.game.clans.items.legendaries.WindBlade; + +public class QuitCommand extends CommandBase +{ + + private LoggingManager _loggingManager; + + public QuitCommand(LoggingManager plugin) + { + super(plugin, Rank.ALL, "quit", "log", "logout"); + + _loggingManager = plugin; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (_loggingManager.hasLogoutData(caller)) + { + UtilPlayer.message(caller, F.main("SafeLog", "You are already safe-logging!")); + } + else + { + _loggingManager.insertLogoutData(caller); + UtilPlayer.message(caller, F.main("SafeLog", "Successfully initiated safe-log!")); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java new file mode 100644 index 000000000..8840581ea --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/CustomItem.java @@ -0,0 +1,226 @@ +package mineplex.game.clans.items; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Material; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +/** + * Represents a customizable wrapper for an {@link ItemStack}, enabling the possession + * of special abilities, attributes, and triggers on item. + * @author MrTwiggy + * + */ +public class CustomItem +{ + + private ItemAttribute _superPrefix; + public void setSuperPrefix(ItemAttribute attribute) { _superPrefix = attribute; } + + private ItemAttribute _prefix; + public void setPrefix(ItemAttribute attribute) { _prefix = attribute; } + + private ItemAttribute _suffix; + public void setSuffix(ItemAttribute attribute) { _suffix = attribute; } + + protected String _displayName; + private String _description; + private Material _material; + + private String _uuid; + public String getUuid() { return _uuid; } + + public CustomItem(String displayName, String description, Material material) + { + _displayName = displayName; + _description = description; + _material = material; + _uuid = UUID.randomUUID().toString(); + } + + public CustomItem(Material material) + { + this(prettifyName(material), null, material); + } + + /** + * @return the name displayed to players for the item. + */ + public String getDisplayName() + { + // Concatenate attribute prefixes/suffixes to display name. + String display = _displayName; + + if (_prefix != null) + { + display = _prefix.getDisplayName() + " " + display; + } + + if (_superPrefix != null) + { + display = _superPrefix.getDisplayName() + " " + display; + } + + if (_suffix != null) + { + display += " of " + _suffix.getDisplayName(); + } + + return display; + } + + public String getDescription() + { + return _description; + } + + public List getLore() + { + String serialization = GearManager.getItemSerialization(this); + + List lore = new ArrayList(); + + if (getDescription() != null) + { + lore.add(getDescription()); + } + + // Display attribute descriptions and stats in lore + for (ItemAttribute attribute : getAttributes()) + { + String attributeLine = attribute.getDisplayName() + " - " + attribute.getDescription(); + lore.add(attributeLine); + } + + // Tack on serialized JSON encoded line for utility purposes. (Not seen by user) + List serializedLines = new ArrayList(); + String[] seri = serialization.split("\n"); + for (String line : seri) + { + serializedLines.add(line); + } + lore.addAll(serializedLines); + + return lore; + } + + public ItemStack toItemStack(int amount) + { + ItemStack item = new ItemStack(_material, amount); + update(item); + + // TODO: Add non-descript enchantment for glowing efect? + return item; + } + + public ItemStack toItemStack() + { + return toItemStack(1); + } + + public void onInteract(PlayerInteractEvent event) + { + System.out.println("Triggered interact!"); + for (ItemAttribute attribute : getAttributes()) + { + attribute.onInteract(event); + } + } + + public void onAttack(CustomDamageEvent event) + { + System.out.println("Triggered attack!"); + for (ItemAttribute attribute : getAttributes()) + { + attribute.onAttack(event); + } + } + + public void onAttacked(CustomDamageEvent event) + { + System.out.println("Triggered damage!"); + for (ItemAttribute attribute : getAttributes()) + { + attribute.onAttacked(event); + } + } + + /** + * @return the (possibly empty) set of {@link ItemAttribute}s attached to this item. + */ + public Set getAttributes() + { + Set attributes = new HashSet(); + if (_superPrefix != null) attributes.add(_superPrefix); + if (_prefix != null) attributes.add(_prefix); + if (_suffix != null) attributes.add(_suffix); + return attributes; + } + + /** + * @param item - the item to check for a matching link + * @return true, if {@code item} matches this CustomItem via UUID, false otherwise. + */ + public boolean matches(CustomItem item) + { + return item.getUuid().equals(_uuid); + } + + /** + * Update {@code item} with the proper meta properties suited for this + * {@link CustomItem}. + * @param item - the item whose meta properties are being updated to become a version of this updated custom item. + */ + public void update(ItemStack item) + { + ItemMeta meta = item.getItemMeta(); + + String displayName = getDisplayName(); + List lore = getLore(); + + meta.setDisplayName(displayName); + meta.setLore(lore); + + item.setItemMeta(meta); + } + + public void addAttribute(ItemAttribute attribute) + { + if (_superPrefix == null) + { + _superPrefix = attribute; + } + else if (_prefix == null) + { + _prefix = attribute; + } + else if (_suffix == null) + { + _suffix = attribute; + } + } + + public static String prettifyName(Material material) + { + String name = ""; + String[] words = material.toString().split("_"); + + for (String word : words) + { + word = word.toLowerCase(); + name += word.substring(0, 1).toUpperCase() + word.substring(1) + " "; + } + + return name; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java new file mode 100644 index 000000000..5e322196f --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -0,0 +1,379 @@ +package mineplex.game.clans.items; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilServer; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.portal.TransferHandler; +import mineplex.core.portal.Commands.SendCommand; +import mineplex.core.portal.Commands.ServerCommand; +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.attributes.weapon.*; +import mineplex.game.clans.items.attributes.armor.*; +import mineplex.game.clans.items.commands.GearCommand; +import mineplex.game.clans.items.generation.Weight; +import mineplex.game.clans.items.generation.WeightSet; +import mineplex.game.clans.items.legendaries.*; +import mineplex.game.clans.items.smelting.SmeltingListener; +import mineplex.serverdata.Region; +import mineplex.serverdata.Utility; +import mineplex.serverdata.commands.ServerCommandManager; +import mineplex.serverdata.commands.TransferCommand; +import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; +import mineplex.serverdata.servers.ServerManager; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot; +import net.minecraft.util.com.google.common.collect.Sets; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Manages creation and retrieval of associated {@link PlayerGear}s with online players, as well + * as offering methods for parsing and handling {@link CustomItem}s. + * @author MrTwiggy + * + */ +public class GearManager extends MiniPlugin implements IPacketHandler, Runnable +{ + private static final String ITEM_SERIALIZATION_TAG = "-JSON-"; + private static Random random = new Random(); + private static Gson _gson; + private static GearManager _instance; // Singleton instance + + + private Map _playerGears; // Mapping of player names (key) to cached gear set (value). + private WeightSet _attributeWeights; // Weightings for randomly selecting number of attributes (1, 2, 3) + private WeightSet _typeWeights; // Weightings for randomly selecting item type (legendary/weapon/armour/bow) + + // Legendary generation + private WeightSet> _legendaryWeights; + + // Weapon generation + private WeightSet _weaponTypes; + + // Armour generation + private WeightSet _armourTypes; + + // Attribute generation + private WeightSet> _weaponAttributes; + private WeightSet> _armourAttributes; + private WeightSet> _bowAttributes; + + public GearManager(JavaPlugin plugin, PacketHandler packetHandler) + { + super("CustomGear", plugin); + + _instance = this; + + _playerGears = new HashMap(); + // TODO: Introduce configurable non-hardcoded values for generation weights? + _attributeWeights = new WeightSet(new Weight(3, 3), new Weight(20, 2), new Weight(77, 1)); + _typeWeights = new WeightSet(new Weight(10, ItemType.LEGENDARY), + new Weight(45, ItemType.ARMOUR), + new Weight(22, ItemType.WEAPON), + new Weight(0, ItemType.BOW)); + + // Weapon-based attributes + _weaponAttributes = new WeightSet>(FrostedAttribute.class, SharpAttribute.class, + JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class); + + // Armour-based attributes + _armourAttributes = new WeightSet>(SlantedAttribute.class, ReinforcedAttribute.class, + ProtectionAttribute.class, PaddedAttribute.class, LavaAttribute.class); + + // Bow-based attributes + //_bowAttributes = new WeightSet>(); // TODO: Add in bow-attributes + + // Weapon material types + _weaponTypes = new WeightSet(Material.DIAMOND_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.STONE_SWORD, + Material.DIAMOND_AXE, Material.GOLD_AXE, Material.IRON_AXE, Material.STONE_AXE); + + // Armour material types + _armourTypes = new WeightSet(Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS, + Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, + Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS); + + // TODO: Initialize list of attributes and types + + // Initialize various LegendaryItem types + _legendaryWeights = new WeightSet>(AlligatorsTooth.class, WindBlade.class, + GiantsBroadsword.class, HyperBlade.class, MagneticBlade.class); + // TODO: Add rest of legendaries, find better way? + + // Register listeners + UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(), getPlugin()); + UtilServer.getServer().getPluginManager().registerEvents(new SmeltingListener(), getPlugin()); + + // Initialize attribute types factory for JSON handling of polymorphism. + RuntimeTypeAdapterFactory attributeFactory = RuntimeTypeAdapterFactory + .of(ItemAttribute.class); + + for (Class attributeType : _armourAttributes.elements()) + { + attributeFactory.registerSubtype(attributeType); + } + for (Class attributeType : _weaponAttributes.elements()) + { + attributeFactory.registerSubtype(attributeType); + } + + // Initialize legendary item type factory for JSON handling of polymorphism. + RuntimeTypeAdapterFactory customItemType = RuntimeTypeAdapterFactory + .of(CustomItem.class); + customItemType.registerSubtype(CustomItem.class); + customItemType.registerSubtype(LegendaryItem.class); + for (Class itemType : _legendaryWeights.elements()) + { + customItemType.registerSubtype(itemType); + } + + // Build GSON instance off factories for future serialization of items. + _gson = new GsonBuilder() + .registerTypeAdapterFactory(attributeFactory) + .registerTypeAdapterFactory(customItemType) + .create(); + + packetHandler.addPacketHandler(this); + + plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1l, 1l); + } + + @Override + public void addCommands() + { + addCommand(new GearCommand(this)); + } + + /** + * Tick & update internal logic for {@link GearManager}. Called once per tick. + */ + @Override + public void run() + { + for (PlayerGear gear : _playerGears.values()) + { + gear.update(); + } + } + + /** + * @param player - the player whose {@link PlayerGear} set is to be fetched. + * @return the cached or newly instantiated {@link PlayerGear} associated with {@code player}. + */ + public PlayerGear getPlayerGear(Player player) + { + String playerName = player.getName(); + if (!_playerGears.containsKey(playerName)) + { + PlayerGear gear = new PlayerGear(playerName); + _playerGears.put(playerName, gear); + } + + return _playerGears.get(playerName); + } + + public CustomItem generateItem() + { + int attributeCount = _attributeWeights.generateRandom(); + ItemType itemType = _typeWeights.generateRandom(); + + System.out.println("Generating item of type " + itemType.toString() + " with attribute count of " + attributeCount); + CustomItem item = generateItem(itemType); + System.out.println("Generated item!"); + + if (itemType != ItemType.LEGENDARY) // Only non-legendaries have attributes + { + for (ItemAttribute attribute : generateAttributes(itemType, attributeCount)) + { + item.addAttribute(attribute); + } + // Add up to attributeCount attributes + } + + return item; + } + + private CustomItem generateItem(ItemType itemType) + { + switch(itemType) + { + case LEGENDARY: // Legendary weapon + Class legendaryClass = _legendaryWeights.generateRandom(); + System.out.println("Legendary: " + legendaryClass.getName()); + return instantiate(legendaryClass); + case WEAPON: // Sword or axe + return new CustomItem(_weaponTypes.generateRandom()); + case ARMOUR: // Helmet, chestplate, leggings, or boots + return new CustomItem(_armourTypes.generateRandom()); + case BOW: // A bow + return new CustomItem(Material.BOW); + default: + return null;// Never reached, yet required for compilation purposes. + } + } + + private Set generateAttributes(ItemType type, int count) + { + Set attributes = new HashSet(); + + for (int i = 0; i < count; i++) + { + switch (type) + { + case ARMOUR: + attributes.add(instantiate(_armourAttributes.generateRandom())); + break; + case WEAPON: + attributes.add(instantiate(_weaponAttributes.generateRandom())); + break; + default: + break; + } + } + + return attributes; + } + + public void spawnItem(Location location) + { + CustomItem item = generateItem(); + location.getWorld().dropItem(location, item.toItemStack()); + } + + public static CustomItem parseItem(ItemStack item) + { + String serialization = getItemSerialization(item); + + if (serialization != null) + { + CustomItem customItem = deserialize(serialization); + return customItem; + } + + return null; // No serialization found in item's lore, not a custom item! + } + + public static boolean isCustomItem(ItemStack item) + { + return getItemSerialization(item) != null; + } + + public static String getItemSerialization(CustomItem customItem) + { + String serialization = serialize(customItem); + + return ITEM_SERIALIZATION_TAG + serialization; + } + + /** + * @param type - the class-type of the object to be instantiated. (must have zero-argument constructor) + * @return a newly instantiated instance of {@code type} class-type. Instantied with zero argument constructor. + */ + private static T instantiate(Class type) + { + try + { + return type.newInstance(); + } + catch (Exception e) + { + return null; + } + } + + private static String getItemSerialization(ItemStack item) + { + if (item == null || item.getItemMeta() == null + || item.getItemMeta().getLore() == null) return null; + + ItemMeta meta = item.getItemMeta(); + + for (String lore : meta.getLore()) + { + if (lore.startsWith(ITEM_SERIALIZATION_TAG)) // Found serialization lore-line + { + int tagLength = ITEM_SERIALIZATION_TAG.length(); + String serialization = lore.substring(tagLength); + + return serialization; + } + } + + return null; // Unable to find any serialized lore lines, hence not a CustomItem. + } + + public static String serialize(CustomItem customItem) + { + return _gson.toJson(customItem, CustomItem.class); + } + + public static CustomItem deserialize(String serialization) + { + return _gson.fromJson(serialization, CustomItem.class); + } + + /** + * @return singleton instance of {@link GearManager}. + */ + public static GearManager getInstane() + { + return _instance; + } + + @Override + public void handle(PacketInfo packetInfo) + { + Packet packet = packetInfo.getPacket(); + + if (packet instanceof PacketPlayOutSetSlot) + { + System.out.println("Item slot packet!"); + PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet; + + net.minecraft.server.v1_7_R4.ItemStack original = slotPacket.c; + CraftItemStack originalItem = CraftItemStack.asCraftMirror(original); + ItemMeta originalMeta = originalItem.getItemMeta(); + if (originalMeta == null || originalMeta.getLore() == null) return; // No need to modify item packets with no lore + + List lore = new ArrayList(); + + for (String line : originalMeta.getLore()) + { + if (!line.startsWith(ITEM_SERIALIZATION_TAG)) // Remove serialization lines from out-going lore + { + lore.add(line); + } + } + + net.minecraft.server.v1_7_R4.ItemStack newItem = CraftItemStack.asNMSCopy(originalItem); + CraftItemStack newCopy = CraftItemStack.asCraftMirror(newItem); + ItemMeta newMeta = newCopy.getItemMeta(); + newMeta.setLore(lore); + newCopy.setItemMeta(newMeta); + slotPacket.c = newItem; + //CraftItemStack.setItemMeta(slotPacket.c, meta); + // TODO: Modify spigot build so that slotPacket's itemstack lore can be modified + // to 'hide' json-encoded lore from players. + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java new file mode 100644 index 000000000..d54b217d1 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemListener.java @@ -0,0 +1,95 @@ +package mineplex.game.clans.items; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; + +/** + * Listens for item-related trigger events and accordingly triggers appropriate + * {@link PlayerGear} events for {@link CustomItem} abilities and attributes. + * @author MrTwiggy + * + */ +public class ItemListener implements Listener +{ + + /** + * Handle players shuffling CustomItems around by properly updating + * and managing their movement. + * @param event + */ + @EventHandler + public void onInventoryClick(InventoryClickEvent event) + { + // TODO: Update any custom-items that are selected/moved to save proper stats if they + // TODO: are active. (IE: PlayerGear possesses it as armor slot or weapon) + } + + /** + * Handle updated CustomItem stats and lore upon player + * switching items. + * @param event + */ + @EventHandler + public void onItemHeldChanged(PlayerItemHeldEvent event) + { + Player player = event.getPlayer(); + PlayerGear gear = getGear(player); + + gear.onItemHeldChanged(event); + } + + /** + * Handle the trigger of custom gear related effects and abilities. + * @param event + */ + @EventHandler + public void onPlayerAttack(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(true); + Player damagee = event.GetDamageePlayer(); + + // Trigger custom gear effects for attacker + if (damager != null) + { + PlayerGear attackerGear = getGear(damager); + attackerGear.onAttack(event); + } + + // Trigger custom gear effects for defender + if (damagee != null) + { + PlayerGear defenderGear = getGear(damagee); + defenderGear.onAttacked(event); + } + } + + /** + * Handle weapon ability activation of custom gear. + * @param event + */ + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + // Activate weapon interact abilities + PlayerGear playerGear = getGear(event.getPlayer()); + playerGear.onInteract(event); + } + + /** + * @param player - the player whose gear is to be fetched + * @return the {@link PlayerGear} associated with {@code player}. + */ + private PlayerGear getGear(Player player) + { + return GearManager.getInstane().getPlayerGear(player); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java new file mode 100644 index 000000000..ed32a8115 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java @@ -0,0 +1,18 @@ +package mineplex.game.clans.items; + +import com.google.common.collect.Sets; + +import mineplex.game.clans.items.generation.WeightSet; +import mineplex.game.clans.items.legendaries.AlligatorsTooth; +import mineplex.game.clans.items.legendaries.WindBlade; + +public enum ItemType +{ + LEGENDARY, + + ARMOUR, + + WEAPON, + + BOW; +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java new file mode 100644 index 000000000..25191f7b6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/PlayerGear.java @@ -0,0 +1,225 @@ +package mineplex.game.clans.items; + +import java.util.HashSet; +import java.util.Set; + +import mineplex.game.clans.items.legendaries.LegendaryItem; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +/** + * PlayerGear caches and manages a players set of {@link CustomItem}s that + * they currently wield. + * @author MrTwiggy + * + */ +public class PlayerGear +{ + private String _playerName; // Name of player who owns the gear + + // Cached custom item information for player's gear + private CustomItem weapon; + private CustomItem helmet; + private CustomItem chestplate; + private CustomItem leggings; + private CustomItem boots; + + /** + * Class constructor + * @param playerName + */ + public PlayerGear(String playerName) + { + _playerName = playerName; + } + + /** + * Tick & update internal logic for the PlayerGear and required custom items that are + * equipped. + */ + public void update() + { + if (isOnline()) + { + CustomItem item = getWeapon(); + + if (item != null && item instanceof LegendaryItem) + { + LegendaryItem legendary = (LegendaryItem) item; + legendary.update(getPlayer()); + } + } + } + + public boolean isOnline() + { + Player player = getPlayer(); + return player != null && player.isOnline(); + } + + /** + * @return the {@link Player} that owns this gear set. + */ + public Player getPlayer() + { + return Bukkit.getPlayer(_playerName); + } + + /** + * @return the {@link PlayerInventory} associated with the owner of this {@link PlayerGear}. + */ + public PlayerInventory getInventory() + { + return getPlayer().getInventory(); + } + + /** + * Trigger interact events for the set of equipped {@link CustomItem}s in gear set. + * @param event - the triggering interact event + */ + public void onInteract(PlayerInteractEvent event) + { + for (CustomItem item : getGear()) + { + item.onInteract(event); + } + } + + /** + * Trigger on-attack events for the set of equipped {@link CustomItem}s in gear set. + * @param event - the triggering on-attack event + */ + public void onAttack(CustomDamageEvent event) + { + for (CustomItem item : getGear()) + { + item.onAttack(event); + } + } + + /** + * Trigger attacked events for the set of equipped {@link CustomItem}s in gear set. + * @param event - the triggering attacked event + */ + public void onAttacked(CustomDamageEvent event) + { + for (CustomItem item : getGear()) + { + item.onAttacked(event); + } + } + + /** + * Update appropriate gear status and item lores. + * @param event - the triggering item held change event. + */ + public void onItemHeldChanged(PlayerItemHeldEvent event) + { + ItemStack item = getPlayer().getItemInHand(); + CustomItem weapon = getWeapon(); + + if (weapon != null) + { + weapon.update(item); // Update held-item's stats. + } + } + + public CustomItem getWeapon() + { + ItemStack weaponItem = getPlayer().getInventory().getItemInHand(); + + if (!itemsMatch(weapon, weaponItem)) + { + weapon = parseItem(weaponItem); + } + + return weapon; + } + + public CustomItem getHelmet() + { + ItemStack helmetItem = getPlayer().getInventory().getHelmet(); + + if (!itemsMatch(helmet, helmetItem)) + { + helmet = parseItem(helmetItem); + } + + return helmet; + } + + public CustomItem getChestplate() + { + ItemStack chestplateItem = getPlayer().getInventory().getChestplate(); + + if (!itemsMatch(chestplate, chestplateItem)) + { + chestplate = parseItem(chestplateItem); + } + + return chestplate; + } + + public CustomItem getLeggings() + { + ItemStack leggingsItem = getPlayer().getInventory().getLeggings(); + + if (!itemsMatch(leggings, leggingsItem)) + { + leggings = parseItem(leggingsItem); + } + + return leggings; + } + + public CustomItem getBoots() + { + ItemStack bootsItem = getPlayer().getInventory().getBoots(); + + if (!itemsMatch(boots, bootsItem)) + { + boots = parseItem(bootsItem); + } + + return boots; + } + + /** + * @return set of currently equipped {@link CustomItem}s in the gear set. + */ + public Set getGear() + { + Set items = new HashSet(); + if (getWeapon() != null) items.add(getWeapon()); + if (getHelmet() != null) items.add(getHelmet()); + if (getChestplate() != null) items.add(getChestplate()); + if (getLeggings() != null) items.add(getLeggings()); + if (getBoots() != null) items.add(getBoots()); + return items; + } + + private boolean itemsMatch(CustomItem customItem, ItemStack item) + { + if (customItem == null || item == null) return false; + + if (GearManager.isCustomItem(item)) + { + CustomItem customItem2 = GearManager.parseItem(item); + return customItem2.matches(customItem); + } + + return false; + } + + private CustomItem parseItem(ItemStack item) + { + return GearManager.parseItem(item); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java new file mode 100644 index 000000000..540918364 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/ItemAttribute.java @@ -0,0 +1,53 @@ +package mineplex.game.clans.items.attributes; + +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +/** + * Represents an attribute that can be attached to {@link CustomItem} to augment their abilities + * and special effects on trigger. + * @author MrTwiggy + * + */ +public abstract class ItemAttribute +{ + + /** + * @return the attribute name display to players. + */ + public abstract String getDisplayName(); + + /** + * @return a user-friendly description of this attribute, entailing it's effects + * and current associated values. + */ + public String getDescription() { return "???IMPLEMENT"; } + + public void onInteract(PlayerInteractEvent event) + { + // Implementation left to subclasses. + } + + public void onAttack(CustomDamageEvent event) + { + // Implementation left to subclasses. + } + + public void onAttacked(CustomDamageEvent event) + { + // Implementation left to subclasses. + } + + /** + * @param minValue - the minimum value for attribute value range + * @param maxValue - the maximum value for attribute value range + * @return newly instantiated {@link ValueDistribution} for attribute values in range [{@code minValue}. {@code maxValue}]. + */ + public static ValueDistribution generateDistribution(double minValue, double maxValue) + { + return new ValueDistribution(minValue, maxValue); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java new file mode 100644 index 000000000..5e79f4679 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/EscapeAttribute.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.items.attributes.armor; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class EscapeAttribute extends ItemAttribute +{ + // TODO: Replace with your generators + private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount + + private int _healPercent; + + public EscapeAttribute() + { + _healPercent = healGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return ""; // TODO: Fill in name + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java new file mode 100644 index 000000000..7df8fe1c5 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/FlatReductionAttribute.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.items.attributes.armor; + +import mineplex.game.clans.items.generation.ValueDistribution; + +public abstract class FlatReductionAttribute extends ReductionAttribute +{ + + private double _reduction; + public double getFlatReduction() { return _reduction; } + + public FlatReductionAttribute(ValueDistribution reductionGen, ReductionConfig config) + { + super(config); + + _reduction = reductionGen.generateValue(); + } + + @Override + public double getDamageReduction(double originalDamage) + { + return _reduction; + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java new file mode 100644 index 000000000..12e76c9a0 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/LavaAttribute.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.items.attributes.armor; + +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class LavaAttribute extends PercentReductionAttribute +{ + private static ValueDistribution reductionGen = generateDistribution(0.2d, 1.0d); // Value generator for heal amount + private static ReductionConfig lavaConfig = new ReductionConfig(DamageCause.FIRE, DamageCause.LAVA, DamageCause.FIRE_TICK); + + public LavaAttribute() + { + + super(reductionGen, lavaConfig); + } + + @Override + public String getDisplayName() + { + return "Lava Forged"; + } + + @Override + public String getDescription() + { + return String.format("Reduce fire-related damage by %.2f percent.", getReductionPercent()); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java new file mode 100644 index 000000000..f3a4458a9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PaddedAttribute.java @@ -0,0 +1,29 @@ +package mineplex.game.clans.items.attributes.armor; + +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class PaddedAttribute extends FlatReductionAttribute +{ + private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d); + private static ReductionConfig config = new ReductionConfig(DamageCause.FALL); + + public PaddedAttribute() + { + super(reductionGen, config); + } + + @Override + public String getDisplayName() + { + return "Padded"; + } + + @Override + public String getDescription() + { + return String.format("Reduce fall damage by %.2f half-hearts.", getFlatReduction()); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java new file mode 100644 index 000000000..aeee83b22 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/PercentReductionAttribute.java @@ -0,0 +1,22 @@ +package mineplex.game.clans.items.attributes.armor; + +import mineplex.game.clans.items.generation.ValueDistribution; + +public abstract class PercentReductionAttribute extends ReductionAttribute +{ + private double _reductionPercent; + public double getReductionPercent() { return _reductionPercent; } + + public PercentReductionAttribute(ValueDistribution reductionGen, ReductionConfig config) + { + super(config); + _reductionPercent = reductionGen.generateValue(); + } + + @Override + public double getDamageReduction(double originalDamage) + { + return originalDamage * _reductionPercent; + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ProtectionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ProtectionAttribute.java new file mode 100644 index 000000000..ec97366ec --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ProtectionAttribute.java @@ -0,0 +1,31 @@ +package mineplex.game.clans.items.attributes.armor; + +import org.bukkit.entity.EntityType; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +// A.K.A Conquering for Armor +public class ProtectionAttribute extends FlatReductionAttribute +{ + private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d); + private static ReductionConfig config = new ReductionConfig(EntityType.values()); + + public ProtectionAttribute() + { + super(reductionGen, config); + } + + @Override + public String getDisplayName() + { + return "Protection"; + } + + @Override + public String getDescription() + { + return String.format("Reduce incoming attack damage by %.2f half-hearts.", getFlatReduction()); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java new file mode 100644 index 000000000..196f187ef --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionAttribute.java @@ -0,0 +1,45 @@ +package mineplex.game.clans.items.attributes.armor; + +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public abstract class ReductionAttribute extends ItemAttribute +{ + + private ReductionConfig _config; + + public ReductionAttribute(ReductionConfig config) + { + _config = config; + } + + @Override + public void onAttacked(CustomDamageEvent event) + { + DamageCause cause = event.GetCause(); + Entity attacker = event.GetDamagerEntity(true); + + if (_config.reducesDamage(cause, attacker)) + { + double damage = event.GetDamage(); + double reduction = getDamageReduction(damage); + event.AddMod("Reduction Armor", reduction); + System.out.println("Reduced damage by " + reduction); + } + else + { + System.out.println("Armour doesn't reduce " + cause); + } + } + + public abstract double getDamageReduction(double originalDamage); +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionConfig.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionConfig.java new file mode 100644 index 000000000..034f52f24 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReductionConfig.java @@ -0,0 +1,46 @@ +package mineplex.game.clans.items.attributes.armor; + +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class ReductionConfig +{ + + private Set _reducedAttackers; // EntityTypes whose attacks are reduced by this attribute + private Set _reducedCauses; // DamageCauses that are reduced by this attribute + + public ReductionConfig() + { + _reducedAttackers = new HashSet(); + _reducedCauses = new HashSet(); + } + + public ReductionConfig(DamageCause... reducedCauses) + { + this(); + + for (DamageCause cause : reducedCauses) + { + _reducedCauses.add(cause); + } + } + + public ReductionConfig(EntityType... reducedAttackers) + { + this(); + + for (EntityType attacker : reducedAttackers) + { + _reducedAttackers.add(attacker); + } + } + + public boolean reducesDamage(DamageCause cause, Entity attacker) + { + return _reducedCauses.contains(cause) || (attacker != null && _reducedAttackers.contains(attacker.getType())); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java new file mode 100644 index 000000000..36f385e73 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/ReinforcedAttribute.java @@ -0,0 +1,28 @@ +package mineplex.game.clans.items.attributes.armor; + +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.generation.ValueDistribution; + +public class ReinforcedAttribute extends FlatReductionAttribute +{ + private static ValueDistribution reductionGen = generateDistribution(0.5d, 1.0d); + private static ReductionConfig config = new ReductionConfig(DamageCause.ENTITY_ATTACK); + + public ReinforcedAttribute() + { + super(reductionGen, config); + } + + @Override + public String getDisplayName() + { + return "Reinforced"; + } + + @Override + public String getDescription() + { + return String.format("Reduce incoming enemy attacks by %.2f half-hearts.", getFlatReduction()); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java new file mode 100644 index 000000000..3b90c71d6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SeaAttribute.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.items.attributes.armor; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class SeaAttribute extends ItemAttribute +{ + // TODO: Replace with your generators + private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount + + private int _healPercent; + + public SeaAttribute() + { + _healPercent = healGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return ""; // TODO: Fill in name + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java new file mode 100644 index 000000000..b1bcfffe7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/armor/SlantedAttribute.java @@ -0,0 +1,29 @@ +package mineplex.game.clans.items.attributes.armor; + +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class SlantedAttribute extends FlatReductionAttribute +{ + private static ValueDistribution reductionGen = generateDistribution(0.5d, 1.5d); + private static ReductionConfig config = new ReductionConfig(DamageCause.PROJECTILE); + + public SlantedAttribute() + { + super(reductionGen, config); + } + + @Override + public String getDisplayName() + { + return "Slanted"; + } + + @Override + public String getDescription() + { + return String.format("Reduce arrow damage by %.2f half-hearts.", getFlatReduction()); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/AttackAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/AttackAttribute.java new file mode 100644 index 000000000..5b3448c1a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/AttackAttribute.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.entity.Entity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +/** + * Represents an attribute that triggers a special ability after a specified number + * of attacks with a weapon possessing the attribute. + * @author MrTwiggy + * + */ +public abstract class AttackAttribute extends ItemAttribute +{ + + private int _attackLimit; + public int getAttackLimit() { return _attackLimit; } + + private int _attackCount; + + public AttackAttribute(int attackLimit) + { + _attackLimit = attackLimit; + _attackCount = 0; + } + + @Override + public void onAttack(CustomDamageEvent event) + { + _attackCount++; + System.out.println("Attack count " + _attackCount + " - " + _attackLimit); + if (_attackCount >= _attackLimit) + { + _attackCount = 0; + triggerAttack(event.GetDamagerEntity(true), event.GetDamageeEntity()); + } + } + + public abstract void triggerAttack(Entity attacker, Entity defender); +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java new file mode 100644 index 000000000..1ab6a9c2b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/ConqueringAttribute.java @@ -0,0 +1,35 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +public class ConqueringAttribute extends DamageAttribute +{ + private static ValueDistribution damageGen = generateDistribution(1.0d, 6.0d); + + public ConqueringAttribute() + { + super(damageGen); + } + + @Override + public String getDisplayName() + { + return "Conquering"; + } + + @Override + public String getDescription() + { + return String.format("Deal an extra %.2f hearts of damage to mobs.", getBonusDamage()); + } + + @Override + public boolean grantBonusDamage(Entity entity) + { + return !(entity instanceof Player); // TODO: Check to see if entity is mob and/or a boss! + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/DamageAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/DamageAttribute.java new file mode 100644 index 000000000..3848efeff --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/DamageAttribute.java @@ -0,0 +1,30 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.entity.Entity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +public abstract class DamageAttribute extends ItemAttribute +{ + private double _bonusDamage; + public double getBonusDamage() { return _bonusDamage; } + + public DamageAttribute(ValueDistribution damageGen) + { + _bonusDamage = damageGen.generateValue(); + } + + @Override + public void onAttack(CustomDamageEvent event) + { + if (grantBonusDamage(event.GetDamageeEntity())) + { + event.AddMod("Damage Attribute", _bonusDamage); + } + } + + public abstract boolean grantBonusDamage(Entity defender); +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java new file mode 100644 index 000000000..61e48715d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FlamingAttribute.java @@ -0,0 +1,38 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.entity.Entity; + +public class FlamingAttribute extends AttackAttribute +{ + private static ValueDistribution attackGen = generateDistribution(2, 4); + private static ValueDistribution fireGen = generateDistribution(60, 120); + + private int _fireDuration; + + public FlamingAttribute() + { + super(attackGen.generateIntValue()); + _fireDuration = fireGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return "Flaming"; // TODO: Fill in name + } + + @Override + public String getDescription() + { + return String.format("Enemies catch fire for %d ticks every %d attacks.", _fireDuration, getAttackLimit()); + } + + @Override + public void triggerAttack(Entity attacker, Entity defender) + { + defender.setFireTicks(_fireDuration); + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java new file mode 100644 index 000000000..6109b9cee --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/FrostedAttribute.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +/** + * Frosted attribute to be added onto custom armour. Applies a slowing effect to players that + * attack the wearer of a Frosted {@link CustomItem}. + * @author MrTwiggy + * + */ +public class FrostedAttribute extends ItemAttribute +{ + private static ValueDistribution amountGen = generateDistribution(0, 3); // Value generator for slow amount range + private static ValueDistribution durationGen = generateDistribution(20, 60); // Value generator for slow duration range + + private int _slowAmount; // The slowness level/amplifier + private int _slowDuration; // The duration (in ticks) of slow effect + + /** + * Class constructor + */ + public FrostedAttribute() + { + _slowAmount = amountGen.generateIntValue(); + _slowDuration = durationGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return "Frosted"; + } + + @Override + public String getDescription() + { + return String.format("Apply slowness %d for %d ticks to enemies.", _slowAmount, _slowDuration); + } + + @Override + public void onAttacked(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(true); + + if (damager != null) + { + damager.addPotionEffect(generateSlowEffect()); // Slow attacking player + } + } + + private PotionEffect generateSlowEffect() + { + return new PotionEffect(PotionEffectType.SLOW, _slowDuration, _slowAmount); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java new file mode 100644 index 000000000..0c2cd3adf --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HasteAttribute.java @@ -0,0 +1,50 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +public class HasteAttribute extends AttackAttribute +{ + private static ValueDistribution attackGen = generateDistribution(2, 4); + private static ValueDistribution speedGen = generateDistribution(0, 2); + private static ValueDistribution durationGen = generateDistribution(60, 120); + + private int _speedAmount; + private int _speedDuration; + + public HasteAttribute() + { + super(attackGen.generateIntValue()); + + _speedAmount = speedGen.generateIntValue(); + _speedDuration = durationGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return "Haste"; + } + + @Override + public String getDescription() + { + return String.format("Gain speed %d for %d ticks every %d attacks.", _speedAmount, _speedDuration, getAttackLimit()); + } + + @Override + public void triggerAttack(Entity attacker, Entity defender) + { + if (attacker instanceof Player) + { + Player player = (Player) attacker; + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount)); + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java new file mode 100644 index 000000000..338950352 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/HeavyAttribute.java @@ -0,0 +1,25 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class HeavyAttribute extends ItemAttribute +{ + // TODO: Replace with your generators + private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount + + private int _healPercent; + + public HeavyAttribute() + { + _healPercent = healGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return ""; // TODO: Fill in name + } + + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java new file mode 100644 index 000000000..3794c8b0a --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/JaggedAttribute.java @@ -0,0 +1,35 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.entity.Entity; +import org.bukkit.util.Vector; + +public class JaggedAttribute extends AttackAttribute +{ + private static ValueDistribution attackGen = generateDistribution(2, 4); + + public JaggedAttribute() + { + super(attackGen.generateIntValue()); + } + + @Override + public String getDisplayName() + { + return "Jagged"; + } + + @Override + public String getDescription() + { + return String.format("Temporarily halt enemies every %d attacks.", getAttackLimit()); + } + + @Override + public void triggerAttack(Entity attacker, Entity defender) + { + defender.setVelocity(new Vector(0, 0, 0)); + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java new file mode 100644 index 000000000..48c2c285b --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SharpAttribute.java @@ -0,0 +1,34 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.entity.Entity; + +public class SharpAttribute extends DamageAttribute +{ + private static ValueDistribution damageGen = generateDistribution(0.5d, 1.5d); + + public SharpAttribute() + { + super(damageGen); + } + + @Override + public String getDisplayName() + { + return "Sharp"; + } + + @Override + public String getDescription() + { + return String.format("Deal an extra %.2f damage.", getBonusDamage()); + } + + @Override + public boolean grantBonusDamage(Entity defender) + { + return true; + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java new file mode 100644 index 000000000..0a50290aa --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SmashingAttribute.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class SmashingAttribute extends ItemAttribute +{ + // TODO: Replace with your generators + private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount + + private int _healPercent; + + public SmashingAttribute() + { + _healPercent = healGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return ""; // TODO: Fill in name + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java new file mode 100644 index 000000000..1cfce1379 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/SwiftAttribute.java @@ -0,0 +1,24 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +public class SwiftAttribute extends ItemAttribute +{ + // TODO: Replace with your generators + private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount + + private int _healPercent; + + public SwiftAttribute() + { + _healPercent = healGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return ""; // TODO: Fill in name + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java new file mode 100644 index 000000000..2cfe356fe --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/attributes/weapon/VampiricAttribute.java @@ -0,0 +1,47 @@ +package mineplex.game.clans.items.attributes.weapon; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +public class VampiricAttribute extends ItemAttribute +{ + private static ValueDistribution healGen = generateDistribution(4, 12); + + private int _healPercent; + + public VampiricAttribute() + { + _healPercent = healGen.generateIntValue(); + } + + @Override + public String getDisplayName() + { + return "Vampiric"; + } + + @Override + public String getDescription() + { + return String.format("Heal yourself for %d percentage of damage dealt to enemy players.", _healPercent); + } + + @Override + public void onAttack(CustomDamageEvent event) + { + Player damager = event.GetDamagerPlayer(true); + + double damage = event.GetDamage(); + double healAmount = damage * (_healPercent / 100d); + heal(damager, healAmount); + } + + private void heal(Player player, double healAmount) + { + player.setHealth(player.getHealth() + healAmount); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java new file mode 100644 index 000000000..7729093e2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/commands/GearCommand.java @@ -0,0 +1,66 @@ +package mineplex.game.clans.items.commands; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInput; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.recharge.Recharge; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClansUtility.ClanRelation; +import mineplex.game.clans.clans.ClientClan; +import mineplex.game.clans.items.CustomItem; +import mineplex.game.clans.items.GearManager; +import mineplex.game.clans.items.attributes.weapon.FlamingAttribute; +import mineplex.game.clans.items.attributes.weapon.FrostedAttribute; +import mineplex.game.clans.items.attributes.weapon.SharpAttribute; +import mineplex.game.clans.items.legendaries.LegendaryItem; +import mineplex.game.clans.items.legendaries.WindBlade; + +public class GearCommand extends CommandBase +{ + + private GearManager _gearManager; + + public GearCommand(GearManager plugin) + { + super(plugin, Rank.ALL, "gear", "custom-gear"); + _gearManager = plugin; + } + + @Override + public void Execute(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main("Gear", "Opening custom gear GUI!")); + + if (args == null || args.length == 0) + { + Vector direction = caller.getLocation().getDirection().normalize(); + _gearManager.spawnItem(caller.getEyeLocation().add(direction)); + } + else + { + Vector direction = caller.getLocation().getDirection().normalize(); + _gearManager.spawnItem(caller.getEyeLocation().add(direction)); + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/economy/GoldToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/economy/GoldToken.java new file mode 100644 index 000000000..1f8fff16d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/economy/GoldToken.java @@ -0,0 +1,25 @@ +package mineplex.game.clans.items.economy; + +import org.bukkit.Material; + +import mineplex.game.clans.items.CustomItem;; + +public class GoldToken extends CustomItem +{ + + private int _goldValue; + public int getGoldValue() { return _goldValue; } + + public GoldToken(int goldValue) + { + super("Gold Token", null, Material.GOLD_INGOT); + + _goldValue = goldValue; + } + + @Override + public String getDescription() + { + return String.format("A gold token worth %s gold coins.", _goldValue); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/ValueDistribution.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/ValueDistribution.java new file mode 100644 index 000000000..15d13691c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/ValueDistribution.java @@ -0,0 +1,56 @@ +package mineplex.game.clans.items.generation; + +import java.util.Random; + +/** + * Handles the random generation of attribute values in specified value range + * and probability distribution. + * @author MrTwiggy + * + */ +public class ValueDistribution +{ + private static Random random = new Random(); // Used for RNG of value generation + + private double _min; // Minimum value range available for distribution + private double _max; // Maximum value range available for distribution + private double _lambdaScaler; // Scales exponential probability distribution to skew range values + + /** + * Class constructor for distribution of range [min, max] + * @param min - the minimum value for generation range + * @param max - the maximum value for generation range + */ + public ValueDistribution(double min, double max) + { + _min = min; + _max = max; + } + + /** + * @return randomly generated value conforming to the range and value distribution. + */ + public double generateValue() + { + double roll = random.nextDouble() * random.nextDouble(); + + double delta = getRange() * roll; + return _min + delta; + } + + /** + * @return randomly generated distribution value, rounding to nearest integer. + */ + public int generateIntValue() + { + return (int) Math.round(generateValue()); + } + + /** + * @return the value range associated with this distribution. + */ + public double getRange() + { + return _max - _min; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/Weight.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/Weight.java new file mode 100644 index 000000000..108347832 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/Weight.java @@ -0,0 +1,19 @@ +package mineplex.game.clans.items.generation; + +public class Weight +{ + + private int _weight; + public int getWeight() { return _weight; } + + private T _value; + public T getValue() { return _value; } + + public Weight(int weight, T value) + { + _weight = weight; + _value = value; + } + + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/WeightSet.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/WeightSet.java new file mode 100644 index 000000000..68ee5f5ab --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/WeightSet.java @@ -0,0 +1,94 @@ +package mineplex.game.clans.items.generation; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Random; +import java.util.Set; + +public class WeightSet +{ + + private static Random random = new Random(); + + private Set> _weights; + + private WeightSet() + { + _weights = new HashSet>(); + } + + @SafeVarargs + public WeightSet(Weight... weights) + { + this(); + + for (Weight weight : weights) + { + _weights.add(weight); + } + } + + @SafeVarargs + public WeightSet(T... elements) + { + this(); + + for (T element : elements) + { + _weights.add(new Weight(1, element)); // Constant weight of 1 means all elements are equally likely + } + } + + public WeightSet(Collection elements) + { + this(); + + for (T element : elements) + { + _weights.add(new Weight(1, element)); // Constant weight of 1 means all elements are equally likely + } + } + + private int getTotalWeight() + { + int total = 0; + + for (Weight weight : _weights) + { + total += weight.getWeight(); + } + + return total; + } + + public T generateRandom() + { + int totalWeight = getTotalWeight(); + int roll = random.nextInt(totalWeight); + + for (Weight weight : _weights) + { + roll -= weight.getWeight(); + + if (roll <= 0) + { + return weight.getValue(); + } + } + + // Should never reach here. + return null; + } + + public Set elements() + { + Set elements = new HashSet(); + + for (Weight weight : _weights) + { + elements.add(weight.getValue()); + } + + return elements; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java new file mode 100644 index 000000000..e43868f99 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/AlligatorsTooth.java @@ -0,0 +1,61 @@ +package mineplex.game.clans.items.legendaries; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; + +public class AlligatorsTooth extends LegendaryItem +{ + + private static ValueDistribution boostGen = generateDistribution(0.6d, 1.2d); + private static ValueDistribution damageGen = generateDistribution(1.0d, 6.0d); + + private double _damageBonus; + private double _swimSpeed; + + public AlligatorsTooth() + { + super("Alligators Tooth", "Grants bonus damage in water and special ability to swim fast!", Material.RAW_FISH); + + _damageBonus = damageGen.generateValue(); + _swimSpeed = boostGen.generateValue(); + } + + @Override + public void update(Player wielder) + { + if (isHoldingRightClick() && isInWater(wielder)) + { + propelPlayer(wielder); + } + } + + @Override + public void onAttack(CustomDamageEvent event, Player wielder) + { + if (isInWater(wielder)) + { + event.AddMod("Alligators Tooth", _damageBonus); + event.AddKnockback("Alligators Tooth", 0.5d); + } + + super.onAttack(event); + } + + private void propelPlayer(Player player) + { + Vector direction = player.getLocation().getDirection().normalize(); + direction.multiply(_swimSpeed); + player.setVelocity(direction); + } + + private boolean isInWater(Player player) + { + return player.getLocation().getBlock().isLiquid(); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java new file mode 100644 index 000000000..2835846cb --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/GiantsBroadsword.java @@ -0,0 +1,54 @@ +package mineplex.game.clans.items.legendaries; + +import java.util.HashSet; +import java.util.Set; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class GiantsBroadsword extends LegendaryItem +{ + + public GiantsBroadsword() + { + super("Giants Broadsword", "Deal huge damage and block to gain defensive abilities!", Material.PAPER); + } + + @Override + public void update(Player wielder) + { + if (isHoldingRightClick()) + { + buffPlayer(wielder); + } + } + + @Override + public void onAttack(CustomDamageEvent event, Player wielder) + { + double bonusDamage = 2.0d; // Too much? + event.AddMod("Giants Bonus", bonusDamage); + event.AddKnockback("Giants Sword", 0.5d); + } + + private void buffPlayer(Player player) + { + player.addPotionEffects(generateBlockBuff()); + } + + private Set generateBlockBuff() + { + Set potions = new HashSet(); + + // Slow 5 and Regen 1 for 5 ticks + potions.add(new PotionEffect(PotionEffectType.SLOW, 4, 5)); + potions.add(new PotionEffect(PotionEffectType.REGENERATION, 0, 5)); + + return potions; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperBlade.java new file mode 100644 index 000000000..92e103bb3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/HyperBlade.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.items.legendaries; + +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class HyperBlade extends LegendaryItem +{ + public static final long ATTACK_RATE_DURATION = 100; + private static ValueDistribution amountGen = generateDistribution(0, 3); // [1, 4] speed amount + private static ValueDistribution durationGen = generateDistribution(80, 320); // [4, 16] seconds speed duration + + private int _speedAmount; + private int _speedDuration; + + private long _lastAttack; + public long timeSinceLastAttack() { return System.currentTimeMillis() - _lastAttack; } + + public HyperBlade() + { + super("Hyper Blade", "Increased attack speed!", Material.STICK); + _speedAmount = amountGen.generateIntValue(); + _speedDuration = durationGen.generateIntValue(); + _lastAttack = 0; + } + + @Override + public void update(Player wielder) + { + if (isHoldingRightClick() && canBuff()) + { + buffPlayer(wielder); + } + } + + @Override + public void onAttack(CustomDamageEvent event, Player wielder) + { + if (timeSinceLastAttack() >= ATTACK_RATE_DURATION) + { + event.SetIgnoreRate(true); + log("Ignoring rate!"); + } + } + + private void buffPlayer(Player wielder) + { + // Give player speed buff + wielder.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount)); + log("Buffing"); + } + + private boolean canBuff() + { + return true; // TODO: Implement cooldown? (None specified in docs, sounds OP) + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java new file mode 100644 index 000000000..3257e5811 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/LegendaryItem.java @@ -0,0 +1,80 @@ +package mineplex.game.clans.items.legendaries; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +import mineplex.game.clans.items.CustomItem; +import mineplex.game.clans.items.generation.ValueDistribution; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class LegendaryItem extends CustomItem +{ + + public final long BLOCK_COOLDOWN = 200l; // Right clicking activates right click for 200ms + + private long _lastBlock; // Timestamp of last block from wielder + public long timeSinceLastBlock() { return System.currentTimeMillis() - _lastBlock; } + + public LegendaryItem(String name, String description, Material material) + { + super(name, description, material); + + _lastBlock = 0l; + } + + public void update(Player wielder) + { + // Leave implementation to potential subtypes + } + + public void onAttack(CustomDamageEvent event, Player wielder) + { + // Leave implementation to potential subtypes + } + + @Override + public void onAttack(CustomDamageEvent event) + { + if (event.GetDamagerPlayer(true) != null) + { + onAttack(event, event.GetDamagerPlayer(true)); + } + + super.onAttack(event); + } + + public void onInteract(PlayerInteractEvent event) + { + Action action = event.getAction(); + + if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) + { + _lastBlock = System.currentTimeMillis(); + } + + super.onInteract(event); + } + + public boolean isHoldingRightClick() + { + return timeSinceLastBlock() <= BLOCK_COOLDOWN; + } + + protected void log(String message) + { + System.out.println("[Custom Item - " + _displayName + "] " + message); + } + + /** + * @param minValue - the minimum value for attribute value range + * @param maxValue - the maximum value for attribute value range + * @return newly instantiated {@link ValueDistribution} for attribute values in range [{@code minValue}. {@code maxValue}]. + */ + public static ValueDistribution generateDistribution(double minValue, double maxValue) + { + return new ValueDistribution(minValue, maxValue); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java new file mode 100644 index 000000000..7934f5de2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MagneticBlade.java @@ -0,0 +1,66 @@ +package mineplex.game.clans.items.legendaries; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; + +public class MagneticBlade extends LegendaryItem +{ + + public static final double PULL_RANGE = 10d; + + public MagneticBlade() + { + super("Magnetic Blade", "Pull enemies closer with special abilities!", Material.STICK); + } + + @Override + public void update(Player wielder) + { + if (isHoldingRightClick() && canPull()) + { + pullPlayers(wielder); + } + } + + @Override + public void onAttack(CustomDamageEvent event, Player wielder) + { + event.AddKnockback("Magnetic Blade", -0.5d); // Pull players with negative knockback + log("Negative knockback!"); + // TODO: Apply negative knockback with [???] velocity/power to victims of attacks + } + + private void pullPlayers(Player player) + { + log("Pulling players!"); + Vector direction = player.getLocation().getDirection().normalize().multiply(10.0d); + Location target = player.getEyeLocation().add(direction); + + double targetDistance = player.getLocation().distance(target); + + for (Player other : player.getWorld().getPlayers()) + { + double otherDistance = player.getLocation().distance(other.getLocation()); + double otherTargetDistance = target.distance(other.getLocation()); + + // If player is in-front of us and within pulling range + if (otherTargetDistance < targetDistance && otherDistance <= PULL_RANGE) + { + UtilAction.velocity(other, UtilAlg.getTrajectory(other, player), 0.3, false, 0, 0, 1, true); + } + } + } + + private boolean canPull() + { + return true; // TODO: Implement cooldown? (Sounds OP without one) + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeteorBow.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeteorBow.java new file mode 100644 index 000000000..6bc437489 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeteorBow.java @@ -0,0 +1,42 @@ +package mineplex.game.clans.items.legendaries; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +public class MeteorBow extends LegendaryItem +{ + + public static final int MAX_FLIGHT_TIME = 80; // Max flight of 80 ticks + + private long _flightTime; // Time (in ticks) since last touching ground and flying + + public MeteorBow() + { + super("Meteor Bow", "Shoot explosive arrows!", Material.BOW); + _flightTime = 0; + } + + @Override + public void update(Player wielder) + { + if (isHoldingRightClick() && canPropel()) + { + propelPlayer(wielder); + } + } + + private void propelPlayer(Player player) + { + _flightTime++; + // TODO: Propel player forward with ??? velocity + } + + private boolean canPropel() + { + return _flightTime <= MAX_FLIGHT_TIME; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java new file mode 100644 index 000000000..47fd1bee3 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/WindBlade.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.items.legendaries; + +import mineplex.game.clans.items.attributes.ItemAttribute; +import mineplex.game.clans.items.generation.ValueDistribution; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.util.Vector; + +public class WindBlade extends LegendaryItem +{ + + public static final double FLIGHT_VELOCITY = 0.75d; + public static final int MAX_FLIGHT_TIME = 80; // Max flight of 80 ticks + + private long _flightTime; // Time (in ticks) since last touching ground and flying + + public WindBlade() + { + super("Wind Blade", "Activate flying ability to take flight for 80 ticks before landing!", Material.STICK); // TODO: Configurable? + + _flightTime = 0; + } + + @Override + public void update(Player wielder) + { + Entity entity = (Entity) wielder; + + // Check if player is attempting to fly and activate + if (isHoldingRightClick() && canPropel()) + { + propelPlayer(wielder); + } + + // Check if player has touched down + if (entity.isOnGround()) + { + _flightTime = 0; + } + } + + private void propelPlayer(Player player) + { + _flightTime++; + Vector direction = player.getLocation().getDirection().normalize(); + direction.multiply(FLIGHT_VELOCITY); // Set velocity magnitude + + player.setVelocity(direction); + } + + private boolean canPropel() + { + return _flightTime <= MAX_FLIGHT_TIME; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java new file mode 100644 index 000000000..7fb1195bc --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java @@ -0,0 +1,112 @@ +package mineplex.game.clans.items.smelting; + +import mineplex.game.clans.items.GearManager; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class Smelter +{ + + public static void smeltItemInHand(Player player) + { + ItemStack item = player.getInventory().getItemInHand(); + + if (isSmeltable(item)) + { + ItemStack returns = smeltItem(item); + player.getInventory().setItemInHand(returns); + } + + // TODO: Notify player of smelt success/failure? + } + + public static ItemStack smeltItem(ItemStack item) + { + Material material = getSmeltedType(item.getType()); + int maxAmount = getSmeltAmount(item.getType()); + int amount = maxAmount; + + if (!GearManager.isCustomItem(item)) + { + short maxDurability = item.getType().getMaxDurability(); + int durability = maxDurability - item.getDurability(); + double percent = durability / (double) maxDurability; + System.out.println("Durability: " + item.getDurability() + " -- max: " + item.getType().getMaxDurability() + " --- percent: " + percent); + amount = Math.max(1, (int) (maxAmount * percent)); + } + + return new ItemStack(material, amount); + } + + private static int getSmeltAmount(Material itemType) + { + switch (itemType) + { + case IRON_BOOTS: + case DIAMOND_BOOTS: + case GOLD_BOOTS: + return 4; + case IRON_HELMET: + case DIAMOND_HELMET: + case GOLD_HELMET: + return 5; + case IRON_LEGGINGS: + case DIAMOND_LEGGINGS: + case GOLD_LEGGINGS: + return 7; + case IRON_CHESTPLATE: + case DIAMOND_CHESTPLATE: + case GOLD_CHESTPLATE: + return 8; + case IRON_SWORD: + case DIAMOND_SWORD: + case GOLD_SWORD: + return 2; + case IRON_AXE: + case DIAMOND_AXE: + case GOLD_AXE: + return 3; + default: + return 0; + } + } + + private static boolean isSmeltable(ItemStack item) + { + if (item == null) return false; + + return getSmeltedType(item.getType()) != null; + } + + private static Material getSmeltedType(Material itemType) + { + switch (itemType) + { + case IRON_BOOTS: + case IRON_LEGGINGS: + case IRON_CHESTPLATE: + case IRON_HELMET: + case IRON_SWORD: + case IRON_AXE: + return Material.IRON_ORE; + case DIAMOND_BOOTS: + case DIAMOND_LEGGINGS: + case DIAMOND_CHESTPLATE: + case DIAMOND_HELMET: + case DIAMOND_SWORD: + case DIAMOND_AXE: + return Material.DIAMOND_ORE; + case GOLD_BOOTS: + case GOLD_LEGGINGS: + case GOLD_CHESTPLATE: + case GOLD_HELMET: + case GOLD_SWORD: + case GOLD_AXE: + return Material.GOLD_ORE; + default: + return null; + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/SmeltingListener.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/SmeltingListener.java new file mode 100644 index 000000000..afa056e00 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/SmeltingListener.java @@ -0,0 +1,34 @@ +package mineplex.game.clans.items.smelting; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +/** + * Listens for smelting related events triggered by players to carry out + * item smelting for base resources and ores. + * @author MrTwiggy + * + */ +public class SmeltingListener implements Listener +{ + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.getAction() == Action.LEFT_CLICK_BLOCK) + { + Block clicked = event.getClickedBlock(); + + if (clicked.getType() == Material.FURNACE) + { + Smelter.smeltItemInHand(event.getPlayer()); + } + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java index 962ea019c..d4ba81878 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java @@ -26,6 +26,7 @@ public class PvpShopButton> imple Item = item; } + @Override public void onClick(final Player player, ClickType clickType) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingShop.java index f39503c57..84f1d0e92 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingShop.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingShop.java @@ -24,14 +24,4 @@ public class BuildingShop extends ShopBase { return new BuildingPage(getPlugin(), this, getClientManager(), getDonationManager(), player); } - - @EventHandler - public void playerCmd(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().startsWith("/gold")) - { - UtilPlayer.message(event.getPlayer(), F.main("Gold", "Your Balance is " + C.cYellow + getDonationManager().Get(event.getPlayer().getName()).getGold() + "g")); - event.setCancelled(true); - } - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java new file mode 100644 index 000000000..8c0c0aea9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -0,0 +1,120 @@ +package mineplex.game.clans.spawn; + +import java.util.Random; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.creature.Creature; +import mineplex.core.energy.Energy; +import mineplex.game.clans.fields.repository.FieldRepository; +import mineplex.game.clans.items.generation.WeightSet; +import mineplex.minecraft.game.core.condition.ConditionFactory; +import mineplex.minecraft.game.core.condition.ConditionManager; + +public class Spawn extends MiniPlugin +{ + public static final int SPAWN_RADIUS = 32; + + private static Spawn _instance; + public static Spawn getInstance() { return _instance; } + + private WeightSet _spawns; + + public Spawn(JavaPlugin plugin) + { + super("Clan Spawn Zones", plugin); + + _instance = this; + _spawns = new WeightSet(new Location(null, -200, 107, 0), new Location(null, 200, 107, 0)); + } + + @EventHandler + public void onRespawn(PlayerRespawnEvent event) + { + System.out.println("On respawn"); + event.setRespawnLocation(getSpawnLocation()); + } + + @EventHandler + public void onBlockBreak(BlockBreakEvent event) + { + if (isInSpawn(event.getBlock().getLocation())) + { + event.setCancelled(true); + } + else if (isInSpawn(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerAttacked(EntityDamageByEntityEvent event) + { + Entity defender = event.getEntity(); + + if (defender instanceof Player) + { + Player player = (Player) defender; + + if (isInSpawn(player) && !isCombatTagged(player)) + { + event.setCancelled(true); + } + } + } + + public World getSpawnWorld() + { + return Bukkit.getWorld("world"); + } + + public Location getSpawnLocation() + { + Location spawn = _spawns.generateRandom().clone(); + spawn.setWorld(getSpawnWorld()); + return spawn; + } + + public boolean isInSpawn(Location location) + { + for(Location spawn : _spawns.elements()) + { + int xOffset = Math.abs(location.getBlockX() - spawn.getBlockX()); + int zOffset = Math.abs(location.getBlockZ() - spawn.getBlockZ()); + + if (xOffset <= SPAWN_RADIUS + && zOffset <= SPAWN_RADIUS) + { + return true; + } + } + + return false; + } + + public boolean isInSpawn(Player player) + { + return isInSpawn(player.getLocation()); + } + + private boolean isCombatTagged(Player player) + { + return false; // TODO: Check for implemented combat tagging? + } + + private void notify(Player player, String message) + { + + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 1ff7875a9..7e4dc80e3 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; @@ -109,8 +111,7 @@ public class Hub extends JavaPlugin implements IRelation IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); - FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); - new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager); + FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal); StatsManager statsManager = new StatsManager(this, clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager); @@ -122,11 +123,19 @@ public class Hub extends JavaPlugin implements IRelation QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager); - new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + Chat chat = new Chat(this, clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); new MemoryFix(this); 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.Hub/src/mineplex/hub/modules/HubVisibilityManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java index f7ce210aa..7c43be8c9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HubVisibilityManager.java @@ -17,6 +17,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -26,34 +27,34 @@ import mineplex.hub.HubManager; public class HubVisibilityManager extends MiniPlugin { public HubManager Manager; - + private HashMap _particle = new HashMap(); private HashSet _hiddenPlayers = new HashSet(); - + public HubVisibilityManager(HubManager manager) { super("Visibility Manager", manager.getPlugin()); - + Manager = manager; } public void addHiddenPlayer(Player player) { _hiddenPlayers.add(player); - + } - + public void removeHiddenPlayer(Player player) { _hiddenPlayers.remove(player); } - + @EventHandler public void removeHiddenPlayerOnQuit(PlayerQuitEvent event) { _hiddenPlayers.remove(event.getPlayer()); } - + @EventHandler public void updateVisibility(UpdateEvent event) { @@ -63,18 +64,18 @@ public class HubVisibilityManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) { boolean hideMe = Manager.GetTutorial().InTutorial(player) || - UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || - Manager.getPreferences().Get(player).Invisibility || - _hiddenPlayers.contains(player); - + UtilMath.offset2d(player.getLocation(), Manager.GetSpawn()) == 0 || + Manager.getPreferences().Get(player).Invisibility || + _hiddenPlayers.contains(player); + for (Player other : UtilServer.getPlayers()) { if (player.equals(other)) continue; if (hideMe || - !Manager.getPreferences().Get(other).ShowPlayers || - Manager.GetTutorial().InTutorial(other)) + !Manager.getPreferences().Get(other).ShowPlayers || + Manager.GetTutorial().InTutorial(other)) { VisibilityManager.Instance.setVisibility(player, false, other); } @@ -85,22 +86,22 @@ public class HubVisibilityManager extends MiniPlugin } } } - + @EventHandler public void ParticleSwap(PlayerInteractEvent event) { Player player = event.getPlayer(); - + if (!player.isOp()) return; - + if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_NUGGET)) return; - + int past = 0; if (_particle.containsKey(player)) past = _particle.get(player); - + if (UtilEvent.isAction(event, ActionType.R)) { past = (past+1)%ParticleType.values().length; @@ -111,24 +112,24 @@ public class HubVisibilityManager extends MiniPlugin if (past < 0) past = ParticleType.values().length - 1; } - + _particle.put(player, past); - + player.sendMessage("Particle: " + ParticleType.values()[past]); } - + @EventHandler public void Particles(UpdateEvent event) { if (event.getType() != UpdateType.FAST) return; - + for (Player player : _particle.keySet()) { - for (Player other : UtilServer.getPlayers()) - { - UtilParticle.PlayParticle(other, ParticleType.values()[_particle.get(player)], player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1); - } + + UtilParticle.PlayParticle(ParticleType.values()[_particle.get(player)], player.getLocation().add(1, 1, 0), 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java index 870943f65..f69d45a1e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java @@ -97,8 +97,8 @@ public class TextManager extends MiniPlugin UtilBlockText.MakeText("SUPER SMASH MOBS", locClassics.clone().add(0, 14, -15), faceOther, 159, (byte)4, TextAlign.CENTER); UtilBlockText.MakeText("SUPER SMASH MOBS", locClassics.clone().add(0, 14, -16), faceOther, (Manager.Type == HubType.Halloween) ? 89 : 159, (Manager.Type == HubType.Halloween) ? (byte)0 : (byte)15, TextAlign.CENTER); - UtilBlockText.MakeText("MINE STRIKE", locClassics.clone().add(0, 21, -15), faceOther, 159, (byte)1, TextAlign.CENTER); - UtilBlockText.MakeText("MINE STRIKE", locClassics.clone().add(0, 21, -16), faceOther, (Manager.Type == HubType.Halloween) ? 89 : 159, (Manager.Type == HubType.Halloween) ? (byte)0 : (byte)15, TextAlign.CENTER); + UtilBlockText.MakeText("MASTER BUILDERS", locClassics.clone().add(0, 21, -15), faceOther, 159, (byte)1, TextAlign.CENTER); + UtilBlockText.MakeText("MASTER BUILDERS", locClassics.clone().add(0, 21, -16), faceOther, (Manager.Type == HubType.Halloween) ? 89 : 159, (Manager.Type == HubType.Halloween) ? (byte)0 : (byte)15, TextAlign.CENTER); UtilBlockText.MakeText("BLOCK HUNT", locClassics.clone().add(0, 28, -15), faceOther, 159, (byte)14, TextAlign.CENTER); UtilBlockText.MakeText("BLOCK HUNT", locClassics.clone().add(0, 28, -16), faceOther, (Manager.Type == HubType.Halloween) ? 89 : 159, (Manager.Type == HubType.Halloween) ? (byte)0 : (byte)15, TextAlign.CENTER); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 597de1c2b..c1a058b9c 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -76,6 +76,7 @@ public class ServerManager extends MiniPlugin private NautHashMap> _serverKeyInfoMap = new NautHashMap>(); private NautHashMap _serverKeyTagMap = new NautHashMap(); + private NautHashMap _serverPlayerCounts = new NautHashMap(); private NautHashMap _serverNpcShopMap = new NautHashMap(); private NautHashMap _serverInfoMap = new NautHashMap(); private NautHashMap _serverUpdate = new NautHashMap(); @@ -411,6 +412,8 @@ public class ServerManager extends MiniPlugin { public void run(Collection serverStatusList) { + _serverPlayerCounts.clear(); + for (MinecraftServer serverStatus : serverStatusList) { if (!_serverInfoMap.containsKey(serverStatus.getName())) @@ -451,6 +454,11 @@ public class ServerManager extends MiniPlugin if (_serverKeyTagMap.containsKey(tag)) { _serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo); + + if (!_serverPlayerCounts.containsKey(tag)) + _serverPlayerCounts.put(tag, 0); + + _serverPlayerCounts.put(tag, _serverPlayerCounts.get(tag) + serverInfo.CurrentPlayers); } } @@ -744,4 +752,22 @@ public class ServerManager extends MiniPlugin { return _serverNpcShopMap.get("Mine-Strike"); } + + public ShopBase getWizardShop() + { + return _serverNpcShopMap.get("Wizards"); + } + + public int getGroupTagPlayerCount(String tag) + { + if (_serverPlayerCounts.containsKey(tag)) + return _serverPlayerCounts.get(tag); + else + return 0; + } + + public ShopBase getBuildShop() + { + return _serverNpcShopMap.get("Master Builders"); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 6acd08b2d..6c8cbe089 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -15,6 +15,7 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; import mineplex.hub.server.ui.button.SelectBHButton; +import mineplex.hub.server.ui.button.SelectBLDButton; import mineplex.hub.server.ui.button.SelectBRButton; import mineplex.hub.server.ui.button.SelectCSButton; import mineplex.hub.server.ui.button.SelectDMTButton; @@ -24,6 +25,7 @@ import mineplex.hub.server.ui.button.SelectMSButton; import mineplex.hub.server.ui.button.SelectSGButton; import mineplex.hub.server.ui.button.SelectSSMButton; import mineplex.hub.server.ui.button.SelectTDMButton; +import mineplex.hub.server.ui.button.SelectWIZButton; public class ServerGameMenu extends ShopPageBase { @@ -35,7 +37,7 @@ public class ServerGameMenu extends ShopPageBase public ServerGameMenu(ServerManager plugin, QuickShop quickShop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { - super(plugin, quickShop, clientManager, donationManager, name, player, 27); + super(plugin, quickShop, clientManager, donationManager, name, player, 56); createSuperSmashCycle(); createMinigameCycle(); @@ -47,91 +49,141 @@ public class ServerGameMenu extends ShopPageBase @Override protected void buildPage() { - this.setItem(0, ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "The Bridges " + C.cGray + "4 Team Survival", new String[] + setItem(0, ItemStackFactory.Instance.CreateStack(Material.IRON_PICKAXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "The Bridges " + C.cGray + "4 Team Survival", new String[] { ChatColor.RESET + "", ChatColor.RESET + "4 Teams get 10 minutes to prepare.", ChatColor.RESET + "Then the bridges drop, and all hell", ChatColor.RESET + "breaks loose as you battle to the", ChatColor.RESET + "death with the other teams.", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BR") + ChatColor.RESET + " other players!", })); - this.setItem(2, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Survival Games " + C.cGray + "Last Man Standing", new String[] + setItem(2, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Survival Games " + C.cGray + "Last Man Standing", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Search for chests to find loot and ", ChatColor.RESET + "fight others to be the last man standing. ", ChatColor.RESET + "Beware of the deep freeze!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("HG") + ChatColor.RESET + " other players!", })); - this.setItem(4, ItemStackFactory.Instance.CreateStack(Material.TNT.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Mine-Strike " + C.cGray + "Team Survival", new String[] + setItem(4, ItemStackFactory.Instance.CreateStack(Material.TNT.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Mine-Strike " + C.cGray + "Team Survival", new String[] { ChatColor.RESET + "", ChatColor.RESET + "One team must defend two bomb sites from", ChatColor.RESET + "the other team, who are trying to plant a bomb", ChatColor.RESET + "and blow them up!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("MS") + ChatColor.RESET + " other players!", })); - this.setItem(6, _superSmashCycle.get(_ssmIndex)); + setItem(6, _superSmashCycle.get(_ssmIndex)); - this.setItem(8, ItemStackFactory.Instance.CreateStack(Material.GRASS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Block Hunt " + C.cGray + "Cat and Mouse", new String[] + setItem(8, ItemStackFactory.Instance.CreateStack(Material.BLAZE_ROD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Wizards " + C.cGray + "Last Man Standing", new String[] { ChatColor.RESET + "", - ChatColor.RESET + "Hide as blocks/animals, upgrade your ", - ChatColor.RESET + "weapon and fight to survive against", - ChatColor.RESET + "the Hunters!", + ChatColor.RESET + "Wield powerful spells to fight", + ChatColor.RESET + "against other players in this", + ChatColor.RESET + "exciting free-for-all brawl!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("WIZ") + ChatColor.RESET + " other players!", })); - this.setItem(18, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Draw My Thing " + C.cGray + "Pictionary!", new String[] + setItem(18, ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Draw My Thing " + C.cGray + "Pictionary!", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Players take turns at drawing a random", ChatColor.RESET + "word. Whoever guesses it within the time", ChatColor.RESET + "limit gets some points!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("DMT") + ChatColor.RESET + " other players!", })); - this.setItem(20, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_CHESTPLATE, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Castle Siege " + C.cGray + "Team Game", new String[] + setItem(20, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_CHESTPLATE, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Castle Siege " + C.cGray + "Team Game", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Defenders must protect King Sparklez", ChatColor.RESET + "from the endless waves of Undead", ChatColor.RESET + "until the sun rises!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("CS") + ChatColor.RESET + " other players!", })); - this.setItem(22, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Dominate " + C.cGray + "Team Game", new String[] + setItem(22, ItemStackFactory.Instance.CreateStack(Material.BEACON.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Dominate " + C.cGray + "Team Game", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Customize one of five exciting champions", ChatColor.RESET + "and battle with the opposing team for the", ChatColor.RESET + "control points on the map.", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("DOM") + ChatColor.RESET + " other players!", })); - this.setItem(24, ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Team Deathmatch " + C.cGray + "Team Game", new String[] + setItem(24, ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Team Deathmatch " + C.cGray + "Team Game", new String[] { ChatColor.RESET + "", ChatColor.RESET + "Customize one of five exciting champions", ChatColor.RESET + "and battle with the opposing team to the", ChatColor.RESET + "last man standing.", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("TDM") + ChatColor.RESET + " other players!", + })); + + setItem(26, ItemStackFactory.Instance.CreateStack(Material.GRASS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Block Hunt " + C.cGray + "Cat and Mouse", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Hide as blocks/animals, upgrade your ", + ChatColor.RESET + "weapon and fight to survive against", + ChatColor.RESET + "the Hunters!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BH") + ChatColor.RESET + " other players!", })); - this.setItem(26, _minigameCycle.get(_minigameIndex)); + setItem(36, ItemStackFactory.Instance.CreateStack(Material.WOOD.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Master Builders " + C.cGray + "Creative Build", new String[] + { + ChatColor.RESET + "", + ChatColor.RESET + "Players are given a Build Theme and ", + ChatColor.RESET + "must use blocks, monsters and more", + ChatColor.RESET + "to create a masterpiece!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("BLD") + ChatColor.RESET + " other players!", + })); + + setItem(44, _minigameCycle.get(_minigameIndex)); getButtonMap().put(0, new SelectBRButton(this)); getButtonMap().put(2, new SelectSGButton(this)); getButtonMap().put(4, new SelectMSButton(this)); getButtonMap().put(6, new SelectSSMButton(this)); - getButtonMap().put(8, new SelectBHButton(this)); + getButtonMap().put(8, new SelectWIZButton(this)); getButtonMap().put(18, new SelectDMTButton(this)); getButtonMap().put(20, new SelectCSButton(this)); getButtonMap().put(22, new SelectDOMButton(this)); getButtonMap().put(24, new SelectTDMButton(this)); - getButtonMap().put(26, new SelectMINButton(this)); + getButtonMap().put(26, new SelectBHButton(this)); + getButtonMap().put(36, new SelectBLDButton(this)); + getButtonMap().put(44, new SelectMINButton(this)); } @SuppressWarnings("deprecation") private void createMinigameCycle() { + int playerCount = getPlugin().getGroupTagPlayerCount("MIN") + + getPlugin().getGroupTagPlayerCount("DR") + + getPlugin().getGroupTagPlayerCount("DE") + + getPlugin().getGroupTagPlayerCount("PB") + + getPlugin().getGroupTagPlayerCount("TF") + + getPlugin().getGroupTagPlayerCount("RUN") + + getPlugin().getGroupTagPlayerCount("SN") + + getPlugin().getGroupTagPlayerCount("DT") + + getPlugin().getGroupTagPlayerCount("SQ") + + getPlugin().getGroupTagPlayerCount("SA") + + getPlugin().getGroupTagPlayerCount("SS") + + getPlugin().getGroupTagPlayerCount("OITQ"); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(98, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] { ChatColor.RESET + "", @@ -148,6 +200,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.GOLD_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -165,7 +219,9 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Super Paintball", ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", - ChatColor.RESET + "Bacon Brawl" + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(122, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -184,6 +240,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -202,6 +260,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -220,6 +280,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.MILK_BUCKET.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -238,6 +300,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.MILK_BUCKET.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -256,6 +320,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -274,6 +340,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(159, (byte)14, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -292,6 +360,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(309, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -310,6 +380,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag", ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(319, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -328,6 +400,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Turf Wars", ChatColor.RESET + "Death Tag", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + playerCount + ChatColor.RESET + " other players!", })); } @@ -339,6 +413,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Pick from a selection of monsters,", ChatColor.RESET + "then battle other players to the ", ChatColor.RESET + "death with your monsters skills!", + ChatColor.RESET + "", + ChatColor.RESET + "Join " + ChatColor.GREEN + getPlugin().getGroupTagPlayerCount("SSM") + ChatColor.RESET + " other players!", }; _superSmashCycle.add(ItemStackFactory.Instance.CreateStack(397, (byte)4, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Super Smash Mobs", desc)); @@ -407,4 +483,14 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getMinestrikeShop().attemptShopOpen(player); } + + public void OpenWIZ(Player player) + { + getPlugin().getWizardShop().attemptShopOpen(player); + } + + public void OpenBLD(Player player) + { + getPlugin().getBuildShop().attemptShopOpen(player); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBLDButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBLDButton.java new file mode 100644 index 000000000..38fdf404c --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectBLDButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectBLDButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectBLDButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.OpenBLD(player); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectWIZButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectWIZButton.java new file mode 100644 index 000000000..d82bc7a23 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectWIZButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectWIZButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectWIZButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.OpenWIZ(player); + } +} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java index 66b2682dd..d4e2ffb3d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Blink.java @@ -19,9 +19,11 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -124,7 +126,8 @@ public class Blink extends SkillActive curRange += 0.2; //Smoke Trail - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); lastSmoke = newTarget.getBlock(); } @@ -180,7 +183,8 @@ public class Blink extends SkillActive curRange += 0.2; //Smoke Trail - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); lastSmoke = newTarget.getBlock(); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java index 5b4d9d855..4bbff3d67 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Evade.java @@ -23,7 +23,9 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -155,7 +157,8 @@ public class Evade extends SkillActive //Effect UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, damagee.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10, + ViewDist.NORMAL, UtilServer.getPlayers()); //Action damagee.teleport(target); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java index 58f2a0046..f250c0839 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Flash.java @@ -20,7 +20,9 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -132,7 +134,8 @@ public class Flash extends SkillActive curRange += 0.2; //Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); } //Modify Range diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java index dc0d6aef1..f8be1c8c7 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Illusion.java @@ -33,6 +33,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilWorld; import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.disguise.disguises.DisguisePlayer; @@ -204,7 +205,8 @@ public class Illusion extends SkillActive } //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, skel.getLocation().add(0, 1, 0), 0.3f, 0.3f, 0.3f, 0.06f, 30); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, skel.getLocation().add(0, 1, 0), 0.3f, 0.3f, 0.3f, 0.06f, 30, + ViewDist.LONGER, UtilServer.getPlayers()); for (int i=0 ; i<2 ; i++) skel.getWorld().playSound(skel.getLocation(), Sound.FIZZ, 2f, 0.4f); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/MarkedForDeath.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/MarkedForDeath.java index b8c48c011..615508a77 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/MarkedForDeath.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/MarkedForDeath.java @@ -25,7 +25,9 @@ import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -177,7 +179,8 @@ public class MarkedForDeath extends SkillActive for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.MOB_SPELL, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.MOB_SPELL, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java index b15f4756c..518cb9969 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Recall.java @@ -14,7 +14,9 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; @@ -93,7 +95,8 @@ public class Recall extends Skill while (UtilMath.offset(current, target) > 0.5) { - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, current, 0, 1f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, current, 0, 1f, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); current = current.add(UtilAlg.getTrajectory(current, target).multiply(0.1)); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/RecallOld.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/RecallOld.java index 703602986..a52083c7c 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/RecallOld.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/RecallOld.java @@ -23,8 +23,10 @@ import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -109,7 +111,8 @@ public class RecallOld extends Skill player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 133); player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, player.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 20); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 20, + ViewDist.LONGER, UtilServer.getPlayers()); //Return Item item = _items.remove(player); @@ -122,7 +125,8 @@ public class RecallOld extends Skill //Effect player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, player.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 20); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 20, + ViewDist.LONGER, UtilServer.getPlayers()); Reset(player); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SilencingArrow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SilencingArrow.java index 2a9b18a2f..059dec01d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SilencingArrow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SilencingArrow.java @@ -24,7 +24,9 @@ import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -153,7 +155,8 @@ public class SilencingArrow extends SkillActive for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.SPELL, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.SPELL, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeArrow.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeArrow.java index 9327aafa9..58465104e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeArrow.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeArrow.java @@ -23,7 +23,9 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -140,7 +142,8 @@ public class SmokeArrow extends SkillActive event.AddMod(damager.getName(), GetName(), 0, true); //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); //Remove projectile.remove(); @@ -154,7 +157,8 @@ public class SmokeArrow extends SkillActive for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java index 96de20042..41f70572b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/SmokeBomb.java @@ -8,7 +8,9 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -82,7 +84,8 @@ public class SmokeBomb extends Skill Factory.Condition().Factory().Cloak(GetName(), player, player, 1 + 2 * level, false, true); //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); for (Player other : UtilPlayer.getNearby(player.getLocation(), 2 + level)) { diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java index 30b98a300..e1e285ae8 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Assassin/Stealth.java @@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -113,7 +114,8 @@ public class Stealth extends Skill //Effect UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, player.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10, + ViewDist.MAX, UtilServer.getPlayers()); } public void Remove(Player player, LivingEntity source) @@ -128,7 +130,8 @@ public class Stealth extends Skill //Effect UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, player.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10, + ViewDist.MAX, UtilServer.getPlayers()); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Bloodlust.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Bloodlust.java index 1101d4d65..d4e0fd75b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Bloodlust.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Bloodlust.java @@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; @@ -135,7 +136,8 @@ public class Bloodlust extends Skill for (Entity ent : _str.keySet()) { UtilParticle.PlayParticle(ParticleType.RED_DUST, ent.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, _str.get(ent) * 2); + (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, _str.get(ent) * 2, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Stampede.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Stampede.java index 134ebae0a..a4512e929 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Stampede.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Stampede.java @@ -15,6 +15,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent; @@ -120,7 +121,8 @@ public class Stampede extends Skill for (Entity ent : _sprintStr.keySet()) { UtilParticle.PlayParticle(ParticleType.CRIT, ent.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, _sprintStr.get(ent) * 2); + (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, _sprintStr.get(ent) * 2, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Takedown.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Takedown.java index 7c02a07ed..dde2e6a1b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Takedown.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Takedown.java @@ -23,8 +23,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -195,7 +197,8 @@ public class Takedown extends SkillActive for (Entity ent : _live.keySet()) { UtilParticle.PlayParticle(ParticleType.CRIT, ent.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 4); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 4, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Taunt.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Taunt.java index 982616076..9ac75a47a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Taunt.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/Taunt.java @@ -20,8 +20,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -121,7 +123,8 @@ public class Taunt extends SkillActive for (Entity ent : _live.keySet()) { UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, ent.getLocation().add(0, 2, 0), - 0, 0, 0, 6f, 8); + 0, 0, 0, 6f, 8, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/WhirlwindAxe.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/WhirlwindAxe.java index ec172fd73..6f9282477 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/WhirlwindAxe.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/WhirlwindAxe.java @@ -19,7 +19,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -109,12 +111,14 @@ public class WhirlwindAxe extends SkillActive double x = Math.sin(j + (ticksLived/50d)) * (j%(Math.PI/2d)) * 3; double z = Math.cos(j + (ticksLived/50d)) * (j%(Math.PI/2d)) * 3; - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); x = Math.sin(j + (ticksLived/50d) + Math.PI/4) * (j%(Math.PI/2d)) * 3; z = Math.cos(j + (ticksLived/50d) + Math.PI/4) * (j%(Math.PI/2d)) * 3; - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); //Sound player.getWorld().playSound(player.getLocation(), Sound.STEP_WOOL, 2f, 1f + (float)((j%(Math.PI/2d))/(Math.PI/2))); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/BullsCharge.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/BullsCharge.java index 3845764e4..e74fee18b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/BullsCharge.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/BullsCharge.java @@ -18,7 +18,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -129,7 +131,8 @@ public class BullsCharge extends SkillActive { if (player.hasPotionEffect(PotionEffectType.SPEED)) UtilParticle.PlayParticle(ParticleType.CRIT, player.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 3); + (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java index 94c55cc50..1ad84ca2b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/Fortitude.java @@ -15,8 +15,10 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -107,7 +109,8 @@ public class Fortitude extends Skill UtilPlayer.health(entry.getKey(), toHeal); //Effect - UtilParticle.PlayParticle(ParticleType.HEART, entry.getKey().getEyeLocation(), 0, 0.2f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, entry.getKey().getEyeLocation(), 0, 0.2f, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); //Finished if (entry.getValue() <= 0) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HoldPosition.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HoldPosition.java index 274a9f4e0..c6456547f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HoldPosition.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/HoldPosition.java @@ -15,7 +15,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.core.updater.UpdateType; @@ -114,7 +116,8 @@ public class HoldPosition extends SkillActive continue; UtilParticle.PlayParticle(ParticleType.MOB_SPELL, player.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 3 + getLevel(player)); + (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 3 + getLevel(player), + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/ShieldSmash.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/ShieldSmash.java index 4ad7c9264..74c32eca4 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/ShieldSmash.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Knight/ShieldSmash.java @@ -14,7 +14,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -66,8 +68,10 @@ public class ShieldSmash extends SkillActive loc.add(0, 0.8, 0); //Particle - UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0, 0, 0, 0.05f, 6); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0, 0, 0, 0.05f, 6, + ViewDist.LONG, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); boolean hit = false; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java index 954680e46..dcd433766 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java @@ -26,6 +26,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -267,7 +268,8 @@ public class ArcticArmor extends Skill for (Entity ent : _active) { UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, ent.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, 3); + (float)(Math.random() - 0.5), 0.2f + (float)Math.random(), (float)(Math.random() - 0.5), 0, 3, + ViewDist.NORMAL, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBondsData.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBondsData.java index a2a54c0fa..c1afd55b2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBondsData.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/LifeBondsData.java @@ -4,7 +4,9 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -34,7 +36,8 @@ public class LifeBondsData } _loc.add(UtilAlg.getTrajectory(_loc, _target.getLocation().add(0, 0.8, 0)).multiply(0.9)); - UtilParticle.PlayParticle(ParticleType.HEART, _loc, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, _loc, 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); return false; } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/StaticLazer.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/StaticLazer.java index 4d3250ef9..7765eb633 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/StaticLazer.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/StaticLazer.java @@ -11,7 +11,9 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillChargeSword; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -93,13 +95,15 @@ public class StaticLazer extends SkillChargeSword curRange += 0.2; //Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } //Destination Location target = player.getLocation().add(player.getLocation().getDirection().multiply(curRange)); - UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); //Firework UtilFirework.playFirework(player.getLocation().add(player.getLocation().getDirection().multiply(Math.max(0, curRange - 0.6))), Type.BURST, Color.WHITE, false, false); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Agility.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Agility.java index aff5b5bc0..c02bd39f6 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Agility.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Agility.java @@ -16,11 +16,13 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -148,7 +150,8 @@ public class Agility extends SkillActive { if (player.isSprinting()) UtilParticle.PlayParticle(ParticleType.SPELL, player.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 4); + (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 4, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java index 2fda02997..3df193e1f 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Barrage.java @@ -9,7 +9,9 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillChargeBow; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -81,7 +83,8 @@ public class Barrage extends SkillChargeBow _arrows.add(arrow); cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); - UtilParticle.PlayParticle(ParticleType.CRIT, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CRIT, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Disengage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Disengage.java index a5e872bcb..327bfa27a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Disengage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Disengage.java @@ -21,8 +21,10 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -126,7 +128,8 @@ public class Disengage extends SkillActive //Effect damagee.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_METAL, 0.5f, 1.6f); - UtilParticle.PlayParticle(ParticleType.ANGRY_VILLAGER, damager.getEyeLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.ANGRY_VILLAGER, damager.getEyeLocation(), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); //Inform UtilPlayer.message(damagee, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + ".")); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java index 293025f4d..b265a710d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/ExplosiveShot.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Iterator; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -24,10 +25,12 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -232,7 +235,8 @@ public class ExplosiveShot extends SkillActive UtilPlayer.message((Player)cur, F.main(GetClassType().name(), F.name(player.getName()) +" hit you with " + F.skill(GetName(level)) + ".")); } - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); loc.getWorld().playSound(loc, Sound.EXPLODE, 2f, 0.75f); } @@ -243,7 +247,8 @@ public class ExplosiveShot extends SkillActive return; for (Entity ent : _arrows) - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } @Override diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HealingShot.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HealingShot.java index 571880344..43178e1bc 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HealingShot.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HealingShot.java @@ -28,7 +28,9 @@ import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -170,7 +172,9 @@ public class HealingShot extends SkillActive "You hit " + F.name(UtilEnt.getName(damagee)) +" with " + F.skill(GetName(level)) + ".")); //Particles - UtilParticle.PlayParticle(ParticleType.HEART, damagee.getLocation(), (float)(Math.random() - 0.5), (float)(Math.random() + 0.5), (float)(Math.random() - 0.5), 2f, 12); + UtilParticle.PlayParticle(ParticleType.HEART, damagee.getLocation(), + (float)(Math.random() - 0.5), (float)(Math.random() + 0.5), (float)(Math.random() - 0.5), 2f, 12, + ViewDist.MAX, UtilServer.getPlayers()); //Remove projectile.remove(); @@ -184,7 +188,8 @@ public class HealingShot extends SkillActive for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.HEART, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java index 9848193ed..429d86e16 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java @@ -15,7 +15,9 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -110,7 +112,8 @@ public class HeavyArrows extends Skill for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.CRIT, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CRIT, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/IncendiaryShot.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/IncendiaryShot.java index 4b2206cd6..91bb49867 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/IncendiaryShot.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/IncendiaryShot.java @@ -20,10 +20,12 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -146,7 +148,8 @@ public class IncendiaryShot extends SkillActive for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.FLAME, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/NapalmShot.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/NapalmShot.java index 9f2fb7378..90f4d217d 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/NapalmShot.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/NapalmShot.java @@ -22,11 +22,13 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.SkillActive; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -147,7 +149,8 @@ public class NapalmShot extends SkillActive for (Entity ent : _arrows) { - UtilParticle.PlayParticle(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Overcharge.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Overcharge.java index 88412d922..c2895fc66 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Overcharge.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Overcharge.java @@ -7,7 +7,9 @@ import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.minecraft.game.classcombat.Skill.SkillChargeBow; @@ -93,7 +95,8 @@ public class Overcharge extends SkillChargeBow for (Entity ent : _arrows.keySet()) { - UtilParticle.PlayParticle(ParticleType.RED_DUST, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.RED_DUST, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java index fa39af241..97ce042c5 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/VitalitySpores.java @@ -9,8 +9,10 @@ import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -46,7 +48,8 @@ public class VitalitySpores extends Skill //Factory.Condition().Factory().Regen(GetName(), cur, cur, 3.9 + 2*level, 0, false, true, true); UtilPlayer.health(cur, 1); - UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation().add(UtilAlg.getBehind(cur.getLocation().getDirection().multiply(0.5))), 0, 0.2f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, cur.getEyeLocation().add(UtilAlg.getBehind(cur.getLocation().getDirection().multiply(0.5))), 0, 0.2f, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsFury.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsFury.java index c501014b5..87f98a7f8 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsFury.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/WolfsFury.java @@ -18,11 +18,13 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.classcombat.Skill.SkillActive; @@ -197,7 +199,8 @@ public class WolfsFury extends SkillActive for (Player player : _active.keySet()) { UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 4); + (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 4, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java index b8d2f31ab..520e9597a 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityExplosive.java @@ -28,8 +28,10 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.classcombat.item.ItemFactory; import mineplex.minecraft.game.classcombat.item.ItemUsable; @@ -139,7 +141,8 @@ public class ProximityExplosive extends ItemUsable //Effect ent.getWorld().playSound(ent.getLocation(), Sound.NOTE_PLING, 0.5f, 0.5f); ent.getWorld().playSound(ent.getLocation(), Sound.EXPLODE, 4f, 0.8f); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0, 0.5f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0, 0.5f, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java index 33da5e43d..07d787b27 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/item/Throwable/ProximityZapper.java @@ -24,7 +24,9 @@ import mineplex.core.updater.UpdateType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.minecraft.game.classcombat.item.ItemFactory; @@ -132,7 +134,8 @@ public class ProximityZapper extends ItemUsable //Effect ent.getWorld().playSound(ent.getLocation(), Sound.NOTE_PLING, 0.5f, 0.5f); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation(), 0, 0.5f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation(), 0, 0.5f, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } @EventHandler diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index e7b460fe3..9b008c6b1 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -91,6 +91,10 @@ public class CustomDamageEvent extends Event implements Cancellable _damageMult.add(new DamageChange(source, reason, mod, useAttackName)); } + public void AddMod(String source, double mod) + { + AddMod(source, new String(), mod, false); + } public void AddMod(String source, String reason, double mod, boolean useAttackName) { 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/Mineplex.Queue.Core/.project b/Plugins/Mineplex.Queue.Core/.project new file mode 100644 index 000000000..669fb734b --- /dev/null +++ b/Plugins/Mineplex.Queue.Core/.project @@ -0,0 +1,17 @@ + + + Mineplex.Queue.Core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Plugins/Mineplex.Queuer/src/mineplex/queuer/Queuer.java b/Plugins/Mineplex.Queuer/src/mineplex/queuer/Queuer.java index 331d025a2..09fee8b15 100644 --- a/Plugins/Mineplex.Queuer/src/mineplex/queuer/Queuer.java +++ b/Plugins/Mineplex.Queuer/src/mineplex/queuer/Queuer.java @@ -9,208 +9,55 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.Set; +import java.util.UUID; import mineplex.serverdata.Region; +import mineplex.serverdata.commands.ServerTransfer; +import mineplex.serverdata.commands.TransferCommand; +import mineplex.serverdata.data.DedicatedServer; +import mineplex.serverdata.data.ServerGroup; +import mineplex.serverdata.servers.ConnectionData; +import mineplex.serverdata.servers.ServerManager; +import mineplex.serverdata.servers.ServerRepository; +import mineplex.serverprocesses.GenericRunnable; +import mineplex.serverprocesses.ProcessManager; +import mineplex.serverprocesses.ProcessRunner; public class Queuer { + public static final int MIN_QUEUE_WAIT = 0; // The number of seconds required in queue before creating a new match for a party. + private static QueueRepository _repo; + private static ServerRepository _serverRepository; + private static Set _pendingMatches; // Set of all matches awaiting players + private static int _matchId = 0; + private static int _matchesMade = 0; + private static int _updates = 0; + private static int _partyId = 0; + private static int _serverId = 0; public static void main (String args[]) { Region region = (!new File("eu.dat").exists()) ? Region.US : Region.EU; - + _serverRepository = ServerManager.getServerRepository(region); _repo = new QueueRepository(region); - - HashMap playerVarianceMap = new HashMap(); - HashMap playerPrepMatchMap = new HashMap(); - Set matches = new HashSet(); - - QueuePartySorter partySorter = new QueuePartySorter(); - - int matchId = 1; + _pendingMatches = new HashSet(); while (true) - { - int matchesMade = 0; - matchId %= 1500; + { + _updates++; + updateQueuer(); + ProcessManager.getInstance().updateProcesses(); - List assignedMatchIdChecked = new ArrayList(); - Map queueParties = _repo.getMappedQueueParties(); - - int matchPlayerCount = 2; - - System.out.println("Checking " + queueParties.size() + " queues..."); - for (QueueParty queueParty : queueParties.values()) - { - int partyId = queueParty.getId(); - int variance = playerVarianceMap.containsKey(partyId) ? playerVarianceMap.get(partyId) : 0; - variance += 25; - playerVarianceMap.put(partyId, variance); - - if (queueParty.hasAssignedMatch()) - { - for (Match match : matches) - { - if (Math.abs(match.getAverageElo() - queueParty.getAverageElo()) <= variance) - { - if (playerPrepMatchMap.containsKey(partyId)) - { - if (playerPrepMatchMap.get(partyId) == match) - break; - - playerPrepMatchMap.get(partyId).quitQueueParty(queueParty); - } - - match.joinQueueParty(queueParty); - playerPrepMatchMap.put(partyId, match); - - log("Found prep match for '" + queueParty.getId() + "'"); - break; - } - } - - if (!playerPrepMatchMap.containsKey(partyId)) - { - Match match = new Match(matchId++, queueParty.getAverageElo(), queueParty); - - playerPrepMatchMap.put(partyId, match); - matches.add(match); - } - } - else if (!assignedMatchIdChecked.contains(queueParty.getAssignedMatch())) - { - int assignedMatchId = queueParty.getAssignedMatch(); - log("Checking if match '" + assignedMatchId + "' is ready."); - //List matchStatuses = _repo.getMatchStatuses(queueRecord.AssignedMatch); - Collection joinedParties = _repo.getJoinedQueueParties(assignedMatchId); - boolean matchReady = true; - boolean matchDeny = false; - - for (QueueParty joinedParty : joinedParties) - { - String partyState = joinedParty.getState(); - if (partyState.equalsIgnoreCase("Deny")) - { - matchDeny = true; - matchReady = false; - break; - } - else if (!partyState.equalsIgnoreCase("Ready")) - { - matchReady = false; - } - } - - if (matchReady) - { - _repo.startMatch(assignedMatchId); - _repo.deleteAssignedParties(assignedMatchId); - - System.out.println("Starting match '" + assignedMatchId + "'"); - } - else if (matchDeny) - { - _repo.deleteMatch(assignedMatchId); - } - - assignedMatchIdChecked.add(assignedMatchId); - } - } - - System.out.println("Checking " + matches.size() + " matches..."); - - // Check for and kick off invites for ready matches - for (Iterator matchIterator = matches.iterator(); matchIterator.hasNext();) - { - Match match = matchIterator.next(); - - // Don't give me crap about not using iterator...can't cuz of stupid thing. - Set partiesToRemove = new HashSet(); - - for (QueueParty queueParty : match.getParties()) - { - if (!queueParties.containsKey(queueParty.getId())) - { - log("Removing matchStatus : " + queueParty.getId()); - partiesToRemove.add(queueParty); - - if (match.isWaitingForInvites()) - { - _repo.deleteMatch(match.getId()); - match.setWaitingForInvites(false); - } - } - } - - for (QueueParty party : partiesToRemove) - { - match.quitQueueParty(party); - } - - if (match.isWaitingForInvites()) - { - if ((match.getWaitDuration()) > 15000) - { - for (QueueParty queueParty : match.getParties()) - { - if (!queueParty.getState().equalsIgnoreCase("Ready")) - { - _repo.deleteQueueParty(queueParty.getId()); - } - } - - _repo.deleteMatch(match.getId()); - match.setWaitingForInvites(false); - } - - continue; - } - - if (match.getPlayerCount() >= matchPlayerCount) - { - List partyList = new ArrayList(match.getParties()); - Collections.sort(partyList, partySorter); - - int playerCount = 0; - for (QueueParty party : partyList) - { - if (playerCount + party.getPlayerCount() > matchPlayerCount) - { - match.quitQueueParty(party); - playerPrepMatchMap.remove(party.getId()); - log("Oops hit player cap, can't fit you in this match."); - continue; - } - - playerCount += party.getPlayerCount(); - } - - if (playerCount == matchPlayerCount) - { - log("Sent match invites for '" + match.getId() + "'"); - - for (QueueParty party : match.getParties()) - { - playerPrepMatchMap.remove(party.getId()); - _repo.assignMatch(party, match); - } - - match.setWaitingForInvites(true); - matchesMade++; - } - } - else if (match.getPlayerCount() == 0) - { - matchIterator.remove(); - } - } + log("Total pending matches after update: " + _pendingMatches.size()); + log("Total queued parties after update: " + _repo.getQueueParties().size()); try { - if (matchesMade > 0) - System.out.println("Made " + matchesMade + " matches."); + if (_matchesMade > 0) + System.out.println("Made " + _matchesMade + " matches."); Thread.sleep(1000); } @@ -222,6 +69,305 @@ public class Queuer } + + /** + * Tick & update the Queuer as a whole, making one whole pass through all queued players and pending matches to + * assign matches to parties and start matches. + */ + private static void updateQueuer() + { + // Update the status of each queue party, searching for best matchings and assigning matches to parties. + for (QueueParty queueParty : _repo.getQueueParties()) + { + updateParty(queueParty); + } + + // Update all matches, and remove pending matches if they are finished. + Iterator iterator = _pendingMatches.iterator(); + while (iterator.hasNext()) + { + Match match = iterator.next(); + boolean matchFinished = updateMatch(match); + + // Remove match if it is completed/finished + if (matchFinished) iterator.remove(); + } + } + + /** + * Update the status of a {@link QueueParty} by attempting to locate the best resulting + * {@code Match} available, or creating a new one if required. + * @param queueParty - the queue party to be updated for matchmaking purposes. + */ + private static void updateParty(QueueParty queueParty) + { + int queueDuration = (int) queueParty.getQueueDuration() / 1000; // Queue duration in seconds + Match bestMatch = getBestMatch(queueParty); + + if (queueParty.hasAssignedMatch()) + { + // TODO: If player has been waiting too long in current game and there is a better match, join that! + } + else + { + if (bestMatch != null) // Assign party into best match! + { + bestMatch.joinQueueParty(queueParty); + _repo.assignMatch(queueParty, bestMatch); + } + else if (queueDuration >= MIN_QUEUE_WAIT) // Create a new match for others to join! + { + Match match = new Match(_matchId++, queueParty.getServerGroup(), queueParty); + _pendingMatches.add(match); + _repo.assignMatch(queueParty, match); + } + } + } + + /** + * Update a {@link Match} by verifying it's player statuses, sending out invites + * and managing a Match from creation to deletion. + * @param match - the match to be updated. + * @return true, if the match is no longer required (successful or otherwise) and should be removed, false otherwise. + */ + private static boolean updateMatch(Match match) + { + // Remove queued parties that have left queue/match + // Don't give me crap about not using iterator...can't cuz of stupid thing. + Set partiesToRemove = new HashSet(); + for (QueueParty queueParty : match.getParties()) + { + int partyId = queueParty.getId(); + if (!_repo.queuePartyExists(partyId)) + { + log("Removing matchStatus : " + queueParty.getId()); + partiesToRemove.add(queueParty); + + if (match.isWaitingForInvites()) + { + _repo.deleteMatch(match.getId()); + match.setWaitingForInvites(false); + } + } + } + for (QueueParty party : partiesToRemove) + { + match.quitQueueParty(party); + } + + // If match took too long to find players, or is empty, quit match. + if (match.getPlayerCount() == 0) + { + return true; // Match is empty, remove from pending matches. + } + + // If match sent invites and is waiting for too long (15 seconds), kick players who didn't + // accept and keep looking + // Otherwise if everyone accepted, start game! + if (match.isWaitingForInvites()) + { + boolean matchReady = true; + for (QueueParty party : _repo.getJoinedQueueParties(match.getId())) + { + if (!party.isReady()) + { + matchReady = false; + } + } + + if (!matchReady && match.getWaitDuration() > 500) + { + matchReady = true; + } + + if (match.isReady()) // Invites accepted, MinecraftServer started, and players transferred. + { + return true; + } + else if (matchReady) // Players accepted invites, start match! + { + startMatch(match); + return false; + } + else if (match.getWaitDuration() > 15000) + { + for (QueueParty queueParty : match.getParties()) + { + if (!queueParty.isReady()) + { + _repo.deleteQueueParty(queueParty.getId()); + } + } + + _repo.deleteMatch(match.getId()); + match.setWaitingForInvites(false); + } + + return false; + } + + // Match has filled up, send out invites! + if (match.getOpenSlots() == 0) + { + for (QueueParty party : match.getParties()) + { + _repo.sendInvite(party); + } + + match.setWaitingForInvites(true); + } + + return false; + } + + /** + * @param queueParty - the party for whom a match is being searched. + * @return the best matching {@link Match} for the {@code queueParty}, if an acceptable {@link Match} + * could be found, null otherwise. + */ + private static Match getBestMatch(QueueParty queueParty) + { + Match best = null; + int minEloDelta = 0; + int variance = getSearchVariance(queueParty); + + for (Match match : _pendingMatches) + { + if (match.getOpenSlots() >= queueParty.getPlayerCount()) + { + int eloDelta = getEloDelta(queueParty, match); + if (eloDelta <= variance && (eloDelta < minEloDelta || best == null)) + { + best = match; + minEloDelta = eloDelta; + } + } + } + + return best; + } + + /** + * @param r1 + * @param r2 + * @return the ELO point delta (difference) between two {@link Ranked} objects. + */ + private static int getEloDelta(Ranked r1, Ranked r2) + { + return Math.abs(r1.getElo() - r2.getElo()); + } + + public static boolean startMatch(Match match) + { + ServerGroup group = match.getServerGroup(); + DedicatedServer bestServer = getBestDedicatedServer(group); + startServer(bestServer, group, match); + return true; + } + + /** + * Transfer all players queue'd into a {@link Match} to one server. + * @param match - the match whose queue'd players are to be transferred + * @param serverName - the name of the server to transfer the players to + */ + public static void transferPlayers(Match match, String serverName) + { + // Transfer players to the server + for (QueueParty queueParty : _repo.getJoinedQueueParties(match.getId())) + { + for (String playerName : queueParty.getPlayers()) + { + // Execute a transfer command + ServerTransfer serverTransfer = new ServerTransfer(playerName, serverName); + TransferCommand transferCommand = new TransferCommand(serverTransfer); + transferCommand.publish(); + } + } + + // Server transfers sent out, match has started! + _matchesMade++; + + // Delete queue parties for players who've been matched + for (QueueParty queueParty : match.getParties()) + { + if (!queueParty.isReady()) + { + _repo.deleteQueueParty(queueParty.getId()); + } + } + match.setReady(true); // Ready to be deleted/removed + } + + /** + * @return newly generated unique server id. + */ + public static int generateServerId() + { + return _serverId++; + } + + private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final Match match) + { + String cmd = "/home/mineplex/easyRemoteStartServerCustom.sh"; + final String groupPrefix = serverGroup.getPrefix(); + final String serverName = serverSpace.getName(); + final String serverAddress = serverSpace.getPublicAddress(); + final int serverId = generateServerId(); + + ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverAddress, serverSpace.getPrivateAddress(), (serverGroup.getPortSection() + serverId) + "", serverGroup.getRequiredRam() + "", serverGroup.getWorldZip(), serverGroup.getPlugin(), serverGroup.getConfigPath(), serverGroup.getName(), serverGroup.getPrefix() + "-" + serverId, serverSpace.isUsRegion() ? "true" : "false", serverGroup.getAddNoCheat() + "" }); + pr.start(new GenericRunnable() + { + public void run(Boolean error) + { + if (!error) + { + // Successfully started server, now transfer players + transferPlayers(match, serverName); + } + else + { + // TODO: Error in starting server for ELO match, try again or disband queued match? + log("[" + serverName + ":" + serverAddress + " Free Resources; CPU " + serverSpace.getAvailableCpu() + " RAM " + serverSpace.getAvailableRam() + "MB] Errored " + serverName + "(" + groupPrefix+ "-" + serverId + ")"); + } + + } + }); + + ProcessManager.getInstance().addProcess(pr); + serverSpace.incrementServerCount(serverGroup); + } + + private static DedicatedServer getBestDedicatedServer(ServerGroup serverGroup) + { + Collection dedicatedServers = _serverRepository.getDedicatedServers(); + DedicatedServer bestServer = null; + + for (DedicatedServer serverData : dedicatedServers) + { + if (serverData.getAvailableRam() > serverGroup.getRequiredRam() + && serverData.getAvailableCpu() > serverGroup.getRequiredCpu()) + { + if (bestServer == null || serverData.getServerCount(serverGroup) < bestServer.getServerCount(serverGroup)) + { + bestServer = serverData; + } + } + } + + return bestServer; + } + + /** + * @param party - the party whose ELO search variance is being fetched. + * @return the variance in ELO search parameters for {@code party}. + * I.E: Queuer searches for potential matches in [party.elo - variance, party.elo + variance] ELO range. + */ + private static int getSearchVariance(QueueParty party) + { + int seconds = (int) party.getQueueDuration() / 1000; // Duration of queue in seconds + + return seconds * 10; // 5 ELO variance for every second in queue + } private static void log(String message) { diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java index b848f99cd..8c0af1c99 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/Utility.java @@ -41,6 +41,8 @@ public class Utility */ public static T deserialize(String serializedData, Class type) { + if (serializedData == null) return null; + return _gson.fromJson(serializedData, type); } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/serialization/RuntimeTypeAdapterFactory.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/serialization/RuntimeTypeAdapterFactory.java new file mode 100644 index 000000000..5a6238618 --- /dev/null +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/serialization/RuntimeTypeAdapterFactory.java @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package mineplex.serverdata.serialization; + +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.internal.Streams; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + + +/** + * Adapts values whose runtime type may differ from their declaration type. This + * is necessary when a field's type is not the same type that GSON should create + * when deserializing that field. For example, consider these types: + *
   {@code
+ *   abstract class Shape {
+ *     int x;
+ *     int y;
+ *   }
+ *   class Circle extends Shape {
+ *     int radius;
+ *   }
+ *   class Rectangle extends Shape {
+ *     int width;
+ *     int height;
+ *   }
+ *   class Diamond extends Shape {
+ *     int width;
+ *     int height;
+ *   }
+ *   class Drawing {
+ *     Shape bottomShape;
+ *     Shape topShape;
+ *   }
+ * }
+ *

Without additional type information, the serialized JSON is ambiguous. Is + * the bottom shape in this drawing a rectangle or a diamond?

   {@code
+ *   {
+ *     "bottomShape": {
+ *       "width": 10,
+ *       "height": 5,
+ *       "x": 0,
+ *       "y": 0
+ *     },
+ *     "topShape": {
+ *       "radius": 2,
+ *       "x": 4,
+ *       "y": 1
+ *     }
+ *   }}
+ * This class addresses this problem by adding type information to the + * serialized JSON and honoring that type information when the JSON is + * deserialized:
   {@code
+ *   {
+ *     "bottomShape": {
+ *       "type": "Diamond",
+ *       "width": 10,
+ *       "height": 5,
+ *       "x": 0,
+ *       "y": 0
+ *     },
+ *     "topShape": {
+ *       "type": "Circle",
+ *       "radius": 2,
+ *       "x": 4,
+ *       "y": 1
+ *     }
+ *   }}
+ * Both the type field name ({@code "type"}) and the type labels ({@code + * "Rectangle"}) are configurable. + * + *

Registering Types

+ * Create a {@code RuntimeTypeAdapter} by passing the base type and type field + * name to the {@link #of} factory method. If you don't supply an explicit type + * field name, {@code "type"} will be used.
   {@code
+ *   RuntimeTypeAdapter shapeAdapter
+ *       = RuntimeTypeAdapter.of(Shape.class, "type");
+ * }
+ * Next register all of your subtypes. Every subtype must be explicitly + * registered. This protects your application from injection attacks. If you + * don't supply an explicit type label, the type's simple name will be used. + *
   {@code
+ *   shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
+ *   shapeAdapter.registerSubtype(Circle.class, "Circle");
+ *   shapeAdapter.registerSubtype(Diamond.class, "Diamond");
+ * }
+ * Finally, register the type adapter in your application's GSON builder: + *
   {@code
+ *   Gson gson = new GsonBuilder()
+ *       .registerTypeAdapter(Shape.class, shapeAdapter)
+ *       .create();
+ * }
+ * Like {@code GsonBuilder}, this API supports chaining:
   {@code
+ *   RuntimeTypeAdapter shapeAdapter = RuntimeTypeAdapterFactory.of(Shape.class)
+ *       .registerSubtype(Rectangle.class)
+ *       .registerSubtype(Circle.class)
+ *       .registerSubtype(Diamond.class);
+ * }
+ */ +public final class RuntimeTypeAdapterFactory implements TypeAdapterFactory { + private final Class baseType; + private final String typeFieldName; + private final Map> labelToSubtype = new LinkedHashMap>(); + private final Map, String> subtypeToLabel = new LinkedHashMap, String>(); + + private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName) { + if (typeFieldName == null || baseType == null) { + throw new NullPointerException(); + } + this.baseType = baseType; + this.typeFieldName = typeFieldName; + } + + /** + * Creates a new runtime type adapter using for {@code baseType} using {@code + * typeFieldName} as the type field name. Type field names are case sensitive. + */ + public static RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) { + return new RuntimeTypeAdapterFactory(baseType, typeFieldName); + } + + /** + * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as + * the type field name. + */ + public static RuntimeTypeAdapterFactory of(Class baseType) { + return new RuntimeTypeAdapterFactory(baseType, "type"); + } + + /** + * Registers {@code type} identified by {@code label}. Labels are case + * sensitive. + * + * @throws IllegalArgumentException if either {@code type} or {@code label} + * have already been registered on this type adapter. + */ + public RuntimeTypeAdapterFactory registerSubtype(Class type, String label) { + if (type == null || label == null) { + throw new NullPointerException(); + } + if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) { + throw new IllegalArgumentException("types and labels must be unique"); + } + labelToSubtype.put(label, type); + subtypeToLabel.put(type, label); + return this; + } + + /** + * Registers {@code type} identified by its {@link Class#getSimpleName simple + * name}. Labels are case sensitive. + * + * @throws IllegalArgumentException if either {@code type} or its simple name + * have already been registered on this type adapter. + */ + public RuntimeTypeAdapterFactory registerSubtype(Class type) { + return registerSubtype(type, type.getSimpleName()); + } + + public TypeAdapter create(Gson gson, TypeToken type) { + if (type.getRawType() != baseType) { + return null; + } + + final Map> labelToDelegate + = new LinkedHashMap>(); + final Map, TypeAdapter> subtypeToDelegate + = new LinkedHashMap, TypeAdapter>(); + for (Map.Entry> entry : labelToSubtype.entrySet()) { + TypeAdapter delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue())); + labelToDelegate.put(entry.getKey(), delegate); + subtypeToDelegate.put(entry.getValue(), delegate); + } + + return new TypeAdapter() { + @Override public R read(JsonReader in) throws IOException { + JsonElement jsonElement = Streams.parse(in); + JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName); + if (labelJsonElement == null) { + throw new JsonParseException("cannot deserialize " + baseType + + " because it does not define a field named " + typeFieldName); + } + String label = labelJsonElement.getAsString(); + @SuppressWarnings("unchecked") // registration requires that subtype extends T + TypeAdapter delegate = (TypeAdapter) labelToDelegate.get(label); + if (delegate == null) { + throw new JsonParseException("cannot deserialize " + baseType + " subtype named " + + label + "; did you forget to register a subtype?"); + } + return delegate.fromJsonTree(jsonElement); + } + + @Override public void write(JsonWriter out, R value) throws IOException { + if(value!=null) { + Class srcType = value.getClass(); + String label = subtypeToLabel.get(srcType); + @SuppressWarnings("unchecked") // registration requires that subtype extends T + TypeAdapter delegate = (TypeAdapter) subtypeToDelegate.get(srcType); + if (delegate == null) { + throw new JsonParseException("cannot serialize " + srcType.getName() + + "; did you forget to register a subtype?"); + } + JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); + if (jsonObject.has(typeFieldName)) { + throw new JsonParseException("cannot serialize " + srcType.getName() + + " because it already defines a field named " + typeFieldName); + } + JsonObject clone = new JsonObject(); + clone.add(typeFieldName, new JsonPrimitive(label)); + for (Map.Entry e : jsonObject.entrySet()) { + clone.add(e.getKey(), e.getValue()); + } + Streams.write(clone, out); + }else{ + out.nullValue(); + } + } + }; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 889dd4ef4..d54b23935 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -29,13 +29,15 @@ import mineplex.serverdata.data.ServerGroup; import mineplex.serverdata.servers.DedicatedServerSorter; import mineplex.serverdata.servers.ServerManager; import mineplex.serverdata.servers.ServerRepository; +import mineplex.serverprocesses.GenericRunnable; +import mineplex.serverprocesses.ProcessManager; +import mineplex.serverprocesses.ProcessRunner; public class ServerMonitor { private static ServerRepository _repository = null; private static StatusHistoryRepository _historyRepository = null; private static int _count = 0; - private static HashSet _processes = new HashSet(); private static HashMap _badServers = new HashMap(); private static Collection _serverStatuses = null; private static Collection _serverGroups = null; @@ -54,18 +56,6 @@ public class ServerMonitor public static void main (String args[]) { - /* - MinecraftPingReply data = null; - try - { - data = new MinecraftPing().getPing(new MinecraftPingOptions().setHostname("127.0.0.1").setPort(25565)); - } - catch (IOException e2) - { - e2.printStackTrace(); - } - System.out.println(data.getDescription() + " " + data.getPlayers().getOnline()); - */ _region = !new File("eu.dat").exists() ? Region.US : Region.EU; _debug = new File("debug.dat").exists(); _repository = ServerManager.getServerRepository(_region); // Fetches and connects to server repo @@ -286,55 +276,7 @@ public class ServerMonitor } } - int processWaits = 0; - - while (_processes.size() > 0) - { - for (Iterator iterator = _processes.iterator(); iterator.hasNext();) - { - ProcessRunner pr = iterator.next(); - - try - { - pr.join(100); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - - if (pr.isDone()) - iterator.remove(); - } - - if (_processes.size() > 0) - { - try - { - log("Sleeping while processes run..."); - Thread.sleep(6000); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - } - - if (processWaits >= 10) - { - log("Killing stale processes."); - - for (Iterator iterator = _processes.iterator(); iterator.hasNext();) - { - iterator.next().abort(); - iterator.remove(); - } - } - - processWaits++; - } - - processWaits = 0; + ProcessManager.getInstance().updateProcesses(); try { @@ -571,7 +513,9 @@ public class ServerMonitor if (!pr.isDone()) - _processes.add(pr); + { + ProcessManager.getInstance().addProcess(pr); + } } private static boolean isServerOffline(DedicatedServer serverData) @@ -672,7 +616,9 @@ public class ServerMonitor serverSpace.incrementServerCount(serverGroup); if (!pr.isDone()) - _processes.add(pr); + { + ProcessManager.getInstance().addProcess(pr); + } } private static void log(String message) diff --git a/Plugins/Mineplex.ServerProcesses/.project b/Plugins/Mineplex.ServerProcesses/.project new file mode 100644 index 000000000..66b31cde0 --- /dev/null +++ b/Plugins/Mineplex.ServerProcesses/.project @@ -0,0 +1,17 @@ + + + Mineplex.ServerProcesses + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index ae9ca9b08..a3b81be8e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -12,6 +12,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; +import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.UtilServer; @@ -113,7 +114,8 @@ public class Arcade extends JavaPlugin IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager); + Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); BlockRestore blockRestore = new BlockRestore(this); @@ -129,7 +131,7 @@ public class Arcade extends JavaPlugin cosmeticManager.setInterfaceSlot(7); //Arcade Manager - _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress); + _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress); new MemoryFix(this); new CustomTagFix(this, packetHandler); 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..8c69eddb5 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; @@ -37,13 +42,17 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ChildJsonMessage; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; 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 +64,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 +84,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; @@ -109,7 +124,6 @@ import nautilus.game.arcade.managers.GameSpectatorManager; import nautilus.game.arcade.managers.GameStatManager; import nautilus.game.arcade.managers.GameTournamentManager; import nautilus.game.arcade.managers.GameWorldManager; -import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; import nautilus.game.arcade.shop.ArcadeShop; @@ -169,6 +183,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(); @@ -184,7 +203,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, - DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, + DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat, Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler, CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress) { @@ -215,8 +234,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _clientManager = clientManager; _serverStatusManager = serverStatusManager; - _chat = new Chat(plugin, _clientManager, preferences, _serverStatusManager.getCurrentServerName()); - + _chat = chat; _creature = creature; _damageManager = damageManager; @@ -301,6 +319,90 @@ 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()); + + UtilPlayer.message(player, " "); + JsonMessage message = new JsonMessage("") + .color("gold") + .bold() + .extra("You need to accept the resource pack!\n" + + "Click me for instructions on how to fix this!") + + .click(ClickEvent.OPEN_URL, + + "http://mineplex.com/forums/m/11929946/viewthread/21554536-wizards-resource-pack-help"); + + message.sendToPlayer(player); + UtilPlayer.message(player, " "); + + returnHubNoResPack(player); + } + 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(), true); + } + 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 +1327,130 @@ 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(), 20000)) + { + 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(); + + if (_resourcePackUsers.containsKey(player.getName()) && _resourcePackUsers.get(player.getName())) + { + 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) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f); + GetPortal().sendPlayerToServer(player, "Lobby"); + } + + private void returnHubNoResPack(Player player, String message) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cGold + C.Bold + message); + UtilPlayer.message(player, " "); + + returnHubNoResPack(player); + } + + @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(), false); + 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(), false); + player.setResourcePack(_resourcePackUrl); + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index 4ff89e234..2320c9083 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -10,6 +10,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.bridge.Bridge; +import nautilus.game.arcade.game.games.build.Build; import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.game.games.champions.ChampionsDominate; import nautilus.game.arcade.game.games.champions.ChampionsTDM; @@ -68,6 +69,7 @@ public class GameFactory if (gameType == GameType.Barbarians) return new Barbarians(_manager); else if (gameType == GameType.BaconBrawl) return new BaconBrawl(_manager); else if (gameType == GameType.Bridge) return new Bridge(_manager); + else if (gameType == GameType.Build) return new Build(_manager); else if (gameType == GameType.CastleSiege) return new CastleSiege(_manager); else if (gameType == GameType.Christmas) return new Christmas(_manager); else if (gameType == GameType.DeathTag) return new DeathTag(_manager); 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 95f90b871..3a514a456 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -9,9 +9,9 @@ public enum GameType 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), @@ -26,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), - 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), + MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CLASSICS, 25, "http://chivebox.com/file/c/assets.zip", false), + MineWare("MineWare", Material.PAPER, (byte)0, GameCategory.ARCADE, 26), 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), @@ -39,22 +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, "http://chivebox.com/file/c/ResWizards.zip", 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; @@ -62,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; } @@ -70,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; @@ -79,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..318e93d47 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 @@ -255,6 +255,8 @@ public abstract class Game implements Listener public boolean CanAddStats = true; public boolean CanGiveLoot = true; + public boolean VersionRequire1_8 = false; + public ArrayList GemBoosters = new ArrayList(); private final Set> _statTrackers = new HashSet<>(); @@ -316,6 +318,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/baconbrawl/kits/KitMamaPig.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java index 4852415a5..ab258e925 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/baconbrawl/kits/KitMamaPig.java @@ -32,7 +32,7 @@ public class KitMamaPig extends Kit new String[] { - "Maba & Baby Piggles fight together!" + "Mama & Baby Piggles fight together!" }, new Perk[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java new file mode 100644 index 000000000..db8d93e7b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -0,0 +1,1274 @@ +package nautilus.game.arcade.game.games.build; + +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Boat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Minecart; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.ThrownPotion; +import org.bukkit.entity.minecart.CommandMinecart; +import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.entity.minecart.HopperMinecart; +import org.bukkit.entity.minecart.PoweredMinecart; +import org.bukkit.entity.minecart.RideableMinecart; +import org.bukkit.entity.minecart.SpawnerMinecart; +import org.bukkit.entity.minecart.StorageMinecart; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.vehicle.VehicleCreateEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.explosion.ExplosionEvent; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.build.gui.MobShop; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; +import nautilus.game.arcade.game.games.build.kits.KitBuilder; +import nautilus.game.arcade.kit.Kit; + +public class Build extends SoloGame +{ + private NautHashMap _data = new NautHashMap(); + + private ArrayList> _scoreboardPlaces = new ArrayList>(); + + private int _buildGameState = 0; + private long _buildStateTime = 0; + private long _buildTime = 300000; + private long _voteTime = 12000; + private long _viewTime = 16000; + private BuildData _viewData = null; + + private int _countdownTimerState = 0; + + private String[] _words; + + private String _word = "?"; + + private OptionsShop _optionsShop; + private MobShop _mobShop; + private ItemStack _shopItem; + + private String[] _hintText = new String[] + { + "Click Creatures to change their settings!", + "Set the Time/Weather in the Options Menu!", + "Vote based upon Effort, Creativity and Quality!", + "Create Particles in the Options Menu!", + "Vote fairly for other players! It's more fun!", + + }; + + private int _hintIndex = 0; + private long _hintTimer = 0; + private ChatColor _hintColor = ChatColor.YELLOW; + private ChatColor _firstHintColor = ChatColor.YELLOW; + + public Build(ArcadeManager manager) + { + super(manager, GameType.Build, + + new Kit[] + { + new KitBuilder(manager), + }, + + new String[] + { + "Be creative and build something", + "based on the build theme!" + }); + + this.StrictAntiHack = true; + this.Damage = false; + this.HungerSet = 20; + this.HealthSet = 20; + + this.BlockBreak = true; + this.BlockPlace = true; + + this.ItemDrop = true; + this.ItemPickup = true; + + this.InventoryClick = true; + + this.WorldTimeSet = 6000; + + this.PrepareFreeze = false; + + this.CreatureAllow = true; + + this.WorldFireSpread = true; + + _words = new String[] + { + "Rollercoaster", "Archery Range", "Pokemon", "Pirates", "Vikings", "Dinosaur", "Dragon", "Toilet", "Farm", "Tree House", "Burger", "Cat", "Truck", "Bicycle", "Soda", "Music Instrument", "Statue", "Cannon", "Catapult", "Sailing Boat", "Grim Reaper", "Star Wars", "Elephant", "Penguin", "Ninja", "Pot of Gold", "Shrek", "Fruit", "Breakfast", "Toaster", "Robot", "Camping", "Rocket", "Aliens", "Shipwreck", "Cannibals", "Flying Creature", "Beach Creature", "Sea Creature", "Spongebob", "Car", "Pot Plant", "Weapons", "Christmas", "King", "Queen", "Angel", "Demon", "Halloween", "Tank", "Aeroplane" + + }; + + _mobShop = new MobShop(getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); + _optionsShop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); + _shopItem = ItemStackFactory.Instance.CreateStack(Material.DIAMOND, (byte) 0, 1, C.cGreen + "Options"); + } + + @EventHandler + public void prepare(PlayerPrepareTeleportEvent event) + { + event.GetPlayer().setGameMode(GameMode.CREATIVE); + event.GetPlayer().setFlying(true); + event.GetPlayer().setFlySpeed(0.04f); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + { + if (GetPlayers(true).size() > GetTeamList().get(0).GetSpawns().size()) + { + SetState(GameState.End); + Announce(C.Bold + "Too Many Players..."); + return; + } + } + + else if (event.GetState() == GameState.Live) + { + for (Player player : GetPlayers(true)) + { + Location spawn = UtilAlg.findClosest(player.getLocation(), this.GetTeamList().get(0).GetSpawns()); + + _data.put(player, new BuildData(player, spawn, WorldData.GetDataLocs("YELLOW"))); + + player.setFlySpeed(0.1f); + } + + _word = _words[UtilMath.r(_words.length)]; + + UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5); + + this.WorldTimeSet = -1; + } + } + + @EventHandler + public void stateChange(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + //Game + if (_buildGameState == 0) + { + if (_countdownTimerState == 0 && UtilTime.elapsed(GetStateTime(), 60000)) + { + UtilTextMiddle.display(null, C.cYellow + "4 Minutes Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 1 && UtilTime.elapsed(GetStateTime(), 120000)) + { + UtilTextMiddle.display(null, C.cYellow + "3 Minutes Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 2 && UtilTime.elapsed(GetStateTime(), 180000)) + { + UtilTextMiddle.display(null, C.cYellow + "2 Minutes Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 3 && UtilTime.elapsed(GetStateTime(), 240000)) + { + UtilTextMiddle.display(null, C.cYellow + "1 Minute Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 4 && UtilTime.elapsed(GetStateTime(), 270000)) + { + UtilTextMiddle.display(null, C.cYellow + "30 Seconds Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 5 && UtilTime.elapsed(GetStateTime(), 285000)) + { + UtilTextMiddle.display(null, C.cYellow + "15 Seconds Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 6 && UtilTime.elapsed(GetStateTime(), 295000)) + { + UtilTextMiddle.display(null, C.cYellow + "5 Seconds Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 7 && UtilTime.elapsed(GetStateTime(), 296000)) + { + UtilTextMiddle.display(null, C.cYellow + "4 Seconds Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 8 && UtilTime.elapsed(GetStateTime(), 297000)) + { + UtilTextMiddle.display(null, C.cYellow + "3 Seconds Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 9 && UtilTime.elapsed(GetStateTime(), 298000)) + { + UtilTextMiddle.display(null, C.cYellow + "2 Seconds Remaining", 0, 60, 5); + _countdownTimerState++; + } + else if (_countdownTimerState == 10 && UtilTime.elapsed(GetStateTime(), 299000)) + { + UtilTextMiddle.display(null, C.cYellow + "1 Second Remaining", 0, 60, 5); + _countdownTimerState++; + } + + if (System.currentTimeMillis() - GetStateTime() > _buildTime) + { + _buildGameState++; + _buildStateTime = System.currentTimeMillis(); + + //Flags + this.BlockBreak = false; + this.BlockPlace = false; + + this.ItemDrop = false; + this.ItemPickup = false; + + this.InventoryClick = false; + + UtilTextMiddle.display(null, C.cYellow + "TIME IS UP!", 0, 60, 5); + + for (Player player : GetPlayers(true)) + { + player.getInventory().clear(8); + player.closeInventory(); + } + } + } + //Pause + else if (_buildGameState == 1) + { + if (UtilTime.elapsed(_buildStateTime, 5000)) + { + _buildGameState++; + _buildStateTime = System.currentTimeMillis(); + } + } + //Review Phase + else if (_buildGameState == 2) + { + //End Vote Time + if (_viewData != null && (UtilTime.elapsed(_buildStateTime, _voteTime))) + //_viewData.Score.size() == GetPlayers(true).size() - 1)) //All votes cast + { + for (Player player : GetPlayers(true)) + UtilInv.Clear(player); + + //Verdict + if (!_viewData.Judged) + { + BuildQuality quality = BuildQuality.getQuality(_viewData.getScore()); + + if (quality == BuildQuality.Failure) + { + Manager.GetExplosion().BlockExplosion(_viewData.Blocks, _viewData.Spawn, false); + + //Effects + _viewData.Spawn.getWorld().playSound(_viewData.Spawn, Sound.EXPLODE, 3f, 1f); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, _viewData.Spawn, 4f, 4f, 4f, 0, 10, + ViewDist.MAX, UtilServer.getPlayers()); + } + + //Announce Builder + UtilTextMiddle.display(quality.getText(), "Built by: " + C.Bold + _viewData.Player.getName(), 0, 80, 5); + } + + _viewData.Judged = true; + } + + //Start Vote + if (UtilTime.elapsed(_buildStateTime, _viewTime) || _viewData == null) + { + _viewData = null; + + //Get Next View Data + for (BuildData data : _data.values()) + { + if (!data.Judged) + { + _viewData = data; + break; + } + } + + //All Builds are Viewed + if (_viewData == null) + { + //Wait a little longer after voting, give time for EXPLODES + if (UtilTime.elapsed(_buildStateTime, _voteTime)) + { + _buildGameState++; + _buildStateTime = System.currentTimeMillis(); + } + } + //Start Viewing + else + { + teleportPlayers(_viewData); + + //Give Items + for (Player player : GetPlayers(true)) + { + UtilInv.Clear(player); + + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)14, 1, C.Bold + "+0 " + C.cRed + C.Bold + "MY EYES ARE BLEEDING!")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)1, 1, C.Bold + "+1 " + C.cGold + C.Bold + "MEH...")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)4, 1, C.Bold + "+2 " + C.cYellow + C.Bold + "It's okay...")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)5, 1, C.Bold + "+3 " + C.cGreen + C.Bold + "Good")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)3, 1, C.Bold + "+4 " + C.cAqua + C.Bold + "Amazing")); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(160, (byte)10, 1, C.Bold + "+5 " + C.cPurple + C.Bold + "WOW! EVERYTHING IS AWESOME!")); + + UtilTextMiddle.display(null, C.cYellow + "Click to Vote", 0, 60, 5, player); + } + + + _buildStateTime = System.currentTimeMillis(); + } + } + } + //Pause + else if (_buildGameState == 3) + { + if (UtilTime.elapsed(_buildStateTime, 5000)) + { + _buildGameState++; + _buildStateTime = System.currentTimeMillis(); + } + } + else if (_buildGameState == 4) + { + ArrayList places = new ArrayList(); + + //Calculate Places + boolean first = true; + while (!_data.isEmpty()) + { + Player bestPlayer = null; + double bestScore = 0; + + for (Player player : _data.keySet()) + { + double score = _data.get(player).getScore(); + + if (bestPlayer == null || score > bestScore) + { + bestPlayer = player; + bestScore = score; + } + } + + AddGems(bestPlayer, bestScore, "Build Votes", false, false); + + + BuildData data = _data.remove(bestPlayer); + + //Teleport to winner + if (first) + { + teleportPlayers(data); + first = false; + } + + //Only count if they got above TERRIBLE score + if (BuildQuality.getQuality(bestScore) != BuildQuality.Failure) + places.add(bestPlayer); + + _scoreboardPlaces.add(new AbstractMap.SimpleEntry(bestPlayer, bestScore)); + } + + writeScoreboard(); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + public boolean isBuildTime() + { + return _buildStateTime == 0; + } + + private void teleportPlayers(BuildData data) + { + //Teleport + for (int i=0 ; i Math.max(data.CornerA.getBlockY(), data.CornerB.getBlockY()) + 3 && + UtilMath.offset(data.Spawn, event.getFrom()) < UtilMath.offset(data.Spawn, event.getTo())) + { + //Inform + if (Recharge.Instance.use(event.getPlayer(), "Boundary Check", 1000, false, false)) + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot leave your designated area!")); + + //Stop + event.setTo(event.getFrom()); + + //Velocity + event.getPlayer().setVelocity(UtilAlg.getTrajectory(event.getTo(), data.Spawn)); + } + } + + public boolean inBuildArea(BuildData data, Block block) + { + if (!data.inBuildArea(block)) + { + UtilPlayer.message(data.Player, F.main("Game", "You can only build in your designated area!")); + return false; + } + + return true; + } + + @EventHandler + public void voteRegister(PlayerInteractEvent event) + { + if (!IsLive()) + return; + + if (_buildGameState != 2) + return; + + if (_viewData == null) + return; + + if (!IsAlive(event.getPlayer())) + return; + + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.STAINED_GLASS_PANE)) + return; + + if (!UtilEvent.isAction(event, ActionType.R) && !UtilEvent.isAction(event, ActionType.L)) + return; + + if (event.getPlayer().equals(_viewData.Player)) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot vote on your own creation!")); + return; + } + + if (!UtilTime.elapsed(_buildStateTime, 1500)) + return; + + switch (event.getPlayer().getItemInHand().getData().getData()) + { + case 14: + _viewData.addScore(event.getPlayer(), 0); + UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); + break; + case 1: + _viewData.addScore(event.getPlayer(), 1); + UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); + break; + case 4: + _viewData.addScore(event.getPlayer(), 2); + UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); + break; + case 5: + _viewData.addScore(event.getPlayer(), 3); + UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); + break; + case 3: + _viewData.addScore(event.getPlayer(), 4); + UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); + break; + case 10: + _viewData.addScore(event.getPlayer(), 5); + UtilTextMiddle.display(null, event.getPlayer().getItemInHand().getItemMeta().getDisplayName(), 0, 40, 5, event.getPlayer()); + break; + default: + break; + } + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _data.remove(event.getPlayer()); + + for (BuildData data : _data.values()) + data.removeScore(event.getPlayer()); + } + + @EventHandler + public void cleanTNT(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + for (Entity ent : this.WorldData.World.getEntities()) + { + if (ent instanceof TNTPrimed) + { + ent.remove(); + } + } + } + + @EventHandler + public void potionThrow(ProjectileLaunchEvent event) + { + if (event.getEntity() instanceof ThrownPotion) + event.getEntity().remove(); + } + + @EventHandler + public void bowShoot(EntityShootBowEvent event) + { + event.getProjectile().remove(); + } + + @EventHandler + public void blockFromTo(BlockFromToEvent event) + { + for (BuildData data : _data.values()) + if (data.inBuildArea(event.getToBlock())) + return; + + event.setCancelled(true); + } + + @EventHandler + public void pistonExtend(BlockPistonExtendEvent event) + { + for (BuildData data : _data.values()) + for (Block block : event.getBlocks()) + if (!data.inBuildArea(block)) + { + event.setCancelled(true); + return; + } + } + + @EventHandler + public void pistonRetract(BlockPistonRetractEvent event) + { + for (BuildData data : _data.values()) + if (!data.inBuildArea(event.getBlock())) + { + event.setCancelled(true); + return; + } + } + + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void itemClean(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + for (BuildData data : _data.values()) + { + data.clean(); + } + + for (Entity ent : this.WorldData.World.getEntities()) + { + if (!(ent instanceof Item)) + continue; + + boolean isPlacedItem = false; + for (BuildData data : _data.values()) + { + if (data.Items.contains(ent)) + { + isPlacedItem = true; + break; + } + } + + if (!isPlacedItem) + ent.remove(); + } + } + + @EventHandler + public void itemDrop(PlayerDropItemEvent event) + { + if (_buildGameState != 0) + return; + + BuildData data = _data.get(event.getPlayer()); + + if (data == null) + { + event.setCancelled(true); + return; + } + + data.addItem(event.getItemDrop()); + } + + @EventHandler + public void itemPickup(PlayerPickupItemEvent event) + { + if (_buildGameState != 0) + return; + + event.setCancelled(true); + + BuildData data = _data.get(event.getPlayer()); + + if (data == null) + return; + + if (data.Player.equals(event.getPlayer())) + { + event.getItem().remove(); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getItem().getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); + } + } + + @EventHandler + public void itemExpire(ItemDespawnEvent event) + { + for (BuildData data : _data.values()) + { + if (data.Items.contains(event.getEntity())) + { + event.setCancelled(true); + return; + } + } + } + + @EventHandler + public void dataClean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (BuildData data : _data.values()) + { + data.clean(); + } + } + + @EventHandler + public void entSpawn(CreatureSpawnEvent event) + { + if (event.getSpawnReason() != SpawnReason.SPAWNER_EGG) + { + event.setCancelled(true); + return; + } + + Player bestPlayer = null; + double bestDist = 0; + + for (Player player : GetPlayers(true)) + { + double dist = UtilMath.offset(event.getLocation(), player.getLocation()); + + if (bestPlayer == null || dist < bestDist) + { + bestPlayer = player; + bestDist = dist; + } + } + + if (bestPlayer == null) + { + event.setCancelled(true); + return; + } + + + BuildData data = _data.get(bestPlayer); + + if (data == null) + { + event.setCancelled(true); + return; + } + + //Not in area + if (!inBuildArea(data, event.getLocation().getBlock())) + { + event.setCancelled(true); + } + + //Maxed + else if (!data.addEntity(event.getEntity())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void entKill(CustomDamageEvent event) + { + if (event.GetDamagerPlayer(false) == null) + return; + + BuildData data = _data.get(event.GetDamagerPlayer(false)); + + if (data == null) + return; + + data.removeEntity(event.GetDamageeEntity()); + } + + @EventHandler + public void vehicleSpawn(VehicleCreateEvent event) + { + if (event.getVehicle() instanceof Boat || + event.getVehicle() instanceof Minecart || + event.getVehicle() instanceof ExplosiveMinecart || + event.getVehicle() instanceof HopperMinecart || + event.getVehicle() instanceof CommandMinecart || + event.getVehicle() instanceof StorageMinecart || + event.getVehicle() instanceof SpawnerMinecart || + event.getVehicle() instanceof PoweredMinecart || + event.getVehicle() instanceof RideableMinecart || + event.getVehicle() instanceof Painting || + event.getVehicle() instanceof ItemFrame) + { + Player bestPlayer = null; + double bestDist = 0; + + for (Player player : GetPlayers(true)) + { + double dist = UtilMath.offset(event.getVehicle().getLocation(), player.getLocation()); + + if (bestPlayer == null || dist < bestDist) + { + bestPlayer = player; + bestDist = dist; + } + } + + if (bestPlayer == null) + { + event.getVehicle().remove(); + return; + } + + + BuildData data = _data.get(bestPlayer); + + if (data == null) + { + event.getVehicle().remove(); + return; + } + + //Not in area + if (!inBuildArea(data, event.getVehicle().getLocation().getBlock())) + { + event.getVehicle().remove(); + } + + //Maxed + else if (!data.addEntity(event.getVehicle())) + { + event.getVehicle().remove(); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void vehicleDamage(VehicleDamageEvent event) + { + if (_buildGameState != 0 || event.getAttacker() == null || !(event.getAttacker() instanceof Player)) + { + event.setCancelled(true); + return; + } + + Player player = (Player)event.getAttacker(); + + BuildData data = _data.get(player); + + if (data == null) + { + event.setCancelled(true); + return; + } + + data.removeEntity(event.getVehicle()); + } + + @EventHandler + public void fireAllow(BlockIgniteEvent event) + { + if (event.getCause() != IgniteCause.FLINT_AND_STEEL && event.getCause() != IgniteCause.FIREBALL) + event.setCancelled(true); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + writeScoreboard(); + } + + public void writeScoreboard() + { + //Wipe Last + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Build Theme"); + Scoreboard.Write(_word); + + + Scoreboard.WriteBlank(); + + if (_buildGameState == 0) + { + Scoreboard.Write(C.cYellow + C.Bold + "Build Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _buildTime - (System.currentTimeMillis() - this.GetStateTime())), 1)); + } + else if (_buildGameState == 2) + { + Scoreboard.Write(C.cYellow + C.Bold + "Vote Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, _voteTime - (System.currentTimeMillis() - _buildStateTime)), 1)); + +// if (_viewData != null) +// { +// Scoreboard.WriteBlank(); +// Scoreboard.Write(C.cYellow + C.Bold + "Votes " + ChatColor.RESET + _viewData.Score.size() + " / " + (GetPlayers(true).size()-1)); +// Scoreboard.Write(C.cYellow + C.Bold + "Avg " + ChatColor.RESET + UtilMath.trim(2, _viewData.getScore()) + ""); +// Scoreboard.Write(C.cYellow + C.Bold + "Rating " + ChatColor.RESET + BuildQuality.getQuality(_viewData.getScore()) + ""); +// Scoreboard.WriteBlank(); +// +// for (Player player : _viewData.Score.keySet()) +// { +// Scoreboard.Write("+" + _viewData.Score.get(player) + " " + player.getName()); +// } +// } + } + else if (_buildGameState == 4) + { + for (Entry score : _scoreboardPlaces) + { + int percent = (int)(score.getValue() * 20); + + Scoreboard.Write(BuildQuality.getQuality(score.getValue()).getColor() + percent + "% " + ChatColor.RESET + score.getKey().getName()); + } + } + + + Scoreboard.Draw(); + } + + @EventHandler + public void disableInteraction(PlayerInteractEvent event) + { + if (_buildGameState != 0 && IsLive()) + event.setCancelled(true); + } + + @EventHandler + public void openShop(PlayerInteractEvent event) + { + if (IsAlive(event.getPlayer()) && _shopItem.equals(event.getPlayer().getItemInHand())) + _optionsShop.attemptShopOpen(event.getPlayer()); + } + + @EventHandler + public void giveItemStart(GameStateChangeEvent event) + { + if (event.GetGame() == this && event.GetState() == GameState.Live) + { + for (Player player : GetPlayers(true)) + player.getInventory().setItem(8, _shopItem); + } + } + + @EventHandler + public void giveItem(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (IsLive() && _buildGameState == 0) + for (Player player : GetPlayers(true)) + player.getInventory().setItem(8, _shopItem); + } + + @EventHandler + public void stopShopItemMove(InventoryClickEvent event) + { + if (event.getClickedInventory() != null && _shopItem.equals(event.getClickedInventory().getItem(event.getSlot()))) + event.setCancelled(true); + } + + @EventHandler + public void stopShopItemDrop(PlayerDropItemEvent event) + { + if (_shopItem.equals(event.getItemDrop().getItemStack())) + event.setCancelled(true); + } + + @EventHandler + public void placeParticles(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + ItemStack itemInHand = event.getPlayer().getItemInHand(); + + if (itemInHand != null && + itemInHand.getItemMeta() != null && + itemInHand.getItemMeta().getDisplayName() != null && + itemInHand.getItemMeta().getDisplayName().startsWith(ChatColor.GREEN + "Place ")) + { + ParticleType particleType = ParticleType.getFromFriendlyName(itemInHand.getItemMeta().getDisplayName().substring(8)); + + if (particleType != null) + { + BuildData data = _data.get(event.getPlayer()); + + if (data != null) + { + data.addParticles(particleType); + } + + event.setCancelled(true); + } + else + { + System.out.println("Place particles error! This shouldn't happen!"); + } + } + } + + @EventHandler + public void playParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (_viewData != null) + { + _viewData.playParticles(true); + } + else + { + for (BuildData data : _data.values()) + { + data.playParticles(false); + } + } + } + + @EventHandler + public void setWeather(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (_viewData != null) + { + _viewData.playWeather(true); + } + else + { + for (BuildData data : _data.values()) + { + data.playWeather(false); + } + } + } + + @EventHandler + public void clickInventory(InventoryClickEvent event) + { + if (event.getWhoClicked() instanceof Player) + { + Player player = ((Player) event.getWhoClicked()); + + if (IsLive() && IsAlive(player)) + { + BuildData buildData = _data.get(player); + if (buildData != null) + buildData.ClickedInventory = true; + } + } + } + + @EventHandler + public void showHints(UpdateEvent event) + { + if (!IsLive()) + return; + + if (_buildGameState != 0) + return; + + if (event.getType() != UpdateType.FAST) + return; + + //Hints + if (UtilTime.elapsed(_hintTimer, 8000)) + { + if (_hintColor == ChatColor.AQUA) + _hintColor = ChatColor.GREEN; + else + _hintColor = ChatColor.AQUA; + + _hintIndex = (_hintIndex + 1)%_hintText.length; + + _hintTimer = System.currentTimeMillis(); + } + + boolean showHint = !UtilTime.elapsed(_hintTimer, 1100); + + //Initial + for (Player player : GetPlayers(true)) + { + BuildData buildData = _data.get(player); + if (buildData != null && !buildData.ClickedInventory) + { + UtilTextBottom.display(_firstHintColor + "Open Inventory to get Blocks!", player); + } + else if (showHint) + { + UtilTextBottom.display(_hintColor + _hintText[_hintIndex], player); + } + } + + //Initial Flash + if (_firstHintColor == ChatColor.YELLOW) + _firstHintColor = ChatColor.GREEN; + else + _firstHintColor = ChatColor.YELLOW; + } + + @EventHandler(priority = EventPriority.LOWEST) + public void explode(ExplosionEvent event) + { + event.GetBlocks().clear(); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void explode(EntityExplodeEvent event) + { + event.blockList().clear(); + } + + @EventHandler + public void openMobGui(PlayerInteractEntityEvent event) + { + if (!IsLive() || !IsAlive(event.getPlayer())) return; + + Player player = event.getPlayer(); + BuildData buildData = _data.get(player); + + if (buildData != null) + { + for (Entity e : buildData.Entities) + { + if (e instanceof LivingEntity || e instanceof Minecart || e instanceof Boat) + { + if (e.equals(event.getRightClicked())) + { + _mobShop.attemptShopOpen(player, buildData, e); + event.setCancelled(true); + return; + } + } + } + } + } + + @Override + public Location GetSpectatorLocation() + { + if (GetPlayers(true).size() > 0) + return UtilAlg.Random(GetPlayers(true)).getLocation().add(0, 1, 0); + + return GetTeamList().get(0).GetSpawn(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java new file mode 100644 index 000000000..177277b8d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java @@ -0,0 +1,330 @@ +package nautilus.game.arcade.game.games.build; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.recharge.Recharge; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Ghast; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.meta.ItemMeta; +import net.minecraft.server.v1_7_R4.EntityLightning; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityWeather; + +public class BuildData +{ + public Player Player; + + public boolean Judged = false; + + public Location Spawn; + + public Location CornerA; + public Location CornerB; + + public HashSet Blocks = new HashSet(); + + public HashSet Entities = new HashSet(); + + public HashSet Items = new HashSet(); + + public NautHashMap Particles = new NautHashMap(); + + public int Time = 6000; + + // This is used to show the player to use their inventory to grab items + public boolean ClickedInventory = false; + + public WeatherType Weather = WeatherType.SUNNY; + + public NautHashMap Score = new NautHashMap(); + + public BuildData(Player player, Location spawn, ArrayList buildBorders) + { + Player = player; + Spawn = spawn; + + CornerA = UtilAlg.findClosest(spawn, buildBorders); + buildBorders.remove(CornerA); + CornerB = UtilAlg.findClosest(spawn, buildBorders); + buildBorders.remove(CornerB); + } + + public boolean addItem(Item item) + { + if (Items.size() >= 16) + { + UtilPlayer.message(Player, F.main("Game", "You cannot drop more than 16 Items!")); + item.remove(); + return false; + } + + Items.add(item); + + ItemMeta meta = item.getItemStack().getItemMeta(); + meta.setDisplayName(item.getUniqueId() + " NoStack"); + item.getItemStack().setItemMeta(meta); + return true; + } + + public boolean addParticles(ParticleType particleType) + { + if (Particles.size() >= 24) + { + UtilPlayer.message(Player, F.main("Game", "You cannot spawn more than 24 Particles!")); + return false; + } + + Particles.put(Player.getEyeLocation().add(Player.getLocation().getDirection()), particleType); + + UtilPlayer.message(Player, F.main("Game", "You placed " + particleType.getFriendlyName() + "!")); + + return true; + } + + public void resetParticles() + { + Particles.clear(); + + UtilPlayer.message(Player, F.main("Game", "You cleared your Particles!")); + } + + public boolean addEntity(Entity entity) + { + if (entity instanceof Ghast) + { + UtilPlayer.message(Player, F.main("Game", "You cannot spawn Ghasts!")); + + entity.remove(); + return false; + } + + if (Entities.size() >= 16) + { + UtilPlayer.message(Player, F.main("Game", "You cannot spawn more than 16 Entities!")); + + entity.remove(); + return false; + } + + if (entity instanceof LivingEntity) + { + ((LivingEntity)entity).setRemoveWhenFarAway(false); + ((LivingEntity)entity).setCustomName(UtilEnt.getName(entity)); + + } + + Entities.add(entity); + UtilEnt.Vegetate(entity, true); + UtilEnt.ghost(entity, true, false); + return true; + } + + public void removeEntity(Entity entity) + { + if (Entities.remove(entity)) + { + entity.remove(); + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, entity.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + + public void addBlock(Block block) + { + Blocks.add(block); + } + + public void addScore(Player player, int i) + { + Score.put(player, i); + } + + public void removeScore(Player player) + { + Score.remove(player); + } + + public double getScore() + { + if (Score.isEmpty()) + return -1; + + double score = 0; + + for (int i : Score.values()) + score += i; + + return score/(double)Score.size(); + } + + public boolean inBuildArea(Block block) + { + if (block.getX() < Math.min(CornerA.getBlockX(), CornerB.getBlockX())) + return false; + + if (block.getY() < Math.min(CornerA.getBlockY(), CornerB.getBlockY())) + return false; + + if (block.getZ() < Math.min(CornerA.getBlockZ(), CornerB.getBlockZ())) + return false; + + if (block.getX() > Math.max(CornerA.getBlockX(), CornerB.getBlockX())) + return false; + + if (block.getY() > Math.max(CornerA.getBlockY(), CornerB.getBlockY())) + return false; + + if (block.getZ() > Math.max(CornerA.getBlockZ(), CornerB.getBlockZ())) + return false; + + return true; + } + + public enum WeatherType + { + SUNNY, RAINING, STORMING; + } + + public void clean() + { + //Clean Ents + Iterator entIter = Entities.iterator(); + + while (entIter.hasNext()) + { + Entity ent = entIter.next(); + if (!ent.isValid() || !inBuildArea(ent.getLocation().getBlock())) + { + entIter.remove(); + ent.remove(); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + + } + + //Clean Items + Iterator itemIter = Items.iterator(); + + while (itemIter.hasNext()) + { + Entity ent = itemIter.next(); + if (!ent.isValid() || !inBuildArea(ent.getLocation().getBlock())) + { + itemIter.remove(); + ent.remove(); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, ent.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + public void playParticles(boolean all) + { + for (Location loc : Particles.keySet()) + { + int amount = 8; + + ParticleType type = Particles.get(loc); + + if (type == ParticleType.HUGE_EXPLOSION || + type == ParticleType.LARGE_EXPLODE || + type == ParticleType.NOTE) + amount = 1; + + if (all) + UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount, + ViewDist.LONGER, UtilServer.getPlayers()); + else + UtilParticle.PlayParticle(type, loc, 0.4f, 0.4f, 0.4f, 0, amount, + ViewDist.LONGER, Player); + } + } + + public void playWeather(boolean b) + { + org.bukkit.WeatherType type = org.bukkit.WeatherType.CLEAR; + if (Weather == WeatherType.STORMING || Weather == WeatherType.RAINING) + type = org.bukkit.WeatherType.DOWNFALL; + + if (b) + { + for (Player player : UtilServer.getPlayers()) + { + playWeather(player, type); + } + } + else + { + playWeather(Player, type); + } + } + + public void playWeather(Player player, org.bukkit.WeatherType type) + { + player.setPlayerWeather(type); + player.setPlayerTime(Time, false); + + if (Weather == WeatherType.STORMING) + { + if (Math.random() > 0.7) + player.playSound(player.getLocation(), Sound.AMBIENCE_THUNDER, 4f, 1f); + + //Strike Lightning Here + if (Math.random() > 0.9) + { + Location loc = UtilBlock.getHighest(player.getWorld(), + (int) (Spawn.getX() + Math.random() * 200 - 100), + (int) (Spawn.getX() + Math.random() * 200 - 100)).getLocation(); + + EntityLightning entity = new EntityLightning(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ(), true); + PacketPlayOutSpawnEntityWeather packet = new PacketPlayOutSpawnEntityWeather(entity); + UtilPlayer.sendPacket(player, packet); + } + } + } + + public void setGround(GroundData ground) + { + if (!Recharge.Instance.use(Player, "Change Ground", 2000, true, false)) + { + Player.playSound(Player.getLocation(), Sound.NOTE_BASS_GUITAR, 1f, 0.1f); + return; + } + + Material mat = ground.getMaterial(); + byte data = ground.getData(); + + if (mat == Material.LAVA_BUCKET) mat = Material.LAVA; + else if (mat == Material.WATER_BUCKET) mat = Material.WATER; + + int y = Math.min(CornerA.getBlockY(), CornerB.getBlockY()) - 1; + for (int x= Math.min(CornerA.getBlockX(), CornerB.getBlockX()) ; x <= Math.max(CornerA.getBlockX(), CornerB.getBlockX()) ; x++) + for (int z= Math.min(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z <= Math.max(CornerA.getBlockZ(), CornerB.getBlockZ()) ; z++) + { + MapUtil.QuickChangeBlockAt(Player.getWorld(), x, y, z, mat, data); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java new file mode 100644 index 000000000..78e1c1a42 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildQuality.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.game.games.build; + +import org.bukkit.ChatColor; + +import mineplex.core.common.util.C; + +public enum BuildQuality +{ + NoVotes(C.cGray + "No Votes"), + + Mindblowing(C.cAqua + "Mindblowing"), + Awesome(C.cGreen + "Awesome"), + Good(C.cYellow + "Good"), + Satisfactory(C.cGold + "Satisfactory"), + Failure(C.cRed + "FAILURE"); + + private String _text; + + BuildQuality(String text) + { + _text = text; + } + + public String getText() + { + return _text; + } + + public static BuildQuality getQuality(double avgScore) + { + if (avgScore < 0) return NoVotes; + if (avgScore <= 1) return Failure; + if (avgScore <= 2) return Satisfactory; + if (avgScore <= 3) return Good; + if (avgScore <= 4) return Awesome; + return Mindblowing; + } + + public String getColor() + { + return ChatColor.getLastColors(_text); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/GroundData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/GroundData.java new file mode 100644 index 000000000..ffaab207e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/GroundData.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.build; + +import org.bukkit.Material; + +public class GroundData +{ + public final Material _material; + public final byte _data; + + public GroundData(Material material) + { + this(material, (byte) 0); + } + + public GroundData(Material material, byte data) + { + _material = material; + _data = data; + } + + public byte getData() + { + return _data; + } + + public Material getMaterial() + { + return _material; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/MobShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/MobShop.java new file mode 100644 index 000000000..812e90336 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/MobShop.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.build.gui; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.page.MobPage; + +public class MobShop extends ShopBase +{ + public MobShop(ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Mob Options"); + } + + protected ShopPageBase> buildPagesFor(Player player, BuildData data, Entity entity) + { + return new MobPage(getPlugin(), this, getClientManager(), getDonationManager(), player, data, entity); + } + + public boolean attemptShopOpen(Player player, BuildData data, Entity entity) + { + if (!getOpenedShop().contains(player.getName())) + { + if (!canOpenShop(player)) + return false; + + getOpenedShop().add(player.getName()); + + openShopForPlayer(player); + if (!getPlayerPageMap().containsKey(player.getName())) + { + getPlayerPageMap().put(player.getName(), buildPagesFor(player, data, entity)); + } + + openPageForPlayer(player, getOpeningPageForPlayer(player)); + + return true; + } + + return false; + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java new file mode 100644 index 000000000..7c83eeb84 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.build.gui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.gui.page.OptionsPage; + +public class OptionsShop extends ShopBase +{ + private Build _game; + + public OptionsShop(Build game, ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Options"); + _game = game; + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new OptionsPage(_game, getPlugin(), this, getClientManager(), getDonationManager(), player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java new file mode 100644 index 000000000..bd4a56350 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/GroundPage.java @@ -0,0 +1,81 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import java.util.Arrays; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.GroundData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class GroundPage extends ShopPageBase +{ + private static GroundData[] GROUNDS = { + new GroundData(Material.STONE), new GroundData(Material.GRASS), new GroundData(Material.DIRT), + new GroundData(Material.SAND), new GroundData(Material.WATER_BUCKET), new GroundData(Material.LAVA_BUCKET), + new GroundData(Material.WOOD), new GroundData(Material.COBBLESTONE), new GroundData(Material.NETHERRACK), + new GroundData(Material.SMOOTH_BRICK), new GroundData(Material.ENDER_STONE), new GroundData(Material.MYCEL), + new GroundData(Material.STAINED_CLAY, (byte) 0), new GroundData(Material.STAINED_CLAY, (byte) 15), + new GroundData(Material.STAINED_CLAY, (byte) 4), new GroundData(Material.STAINED_CLAY, (byte) 3), + new GroundData(Material.STAINED_CLAY, (byte) 5), new GroundData(Material.STAINED_CLAY, (byte) 6), + new GroundData(Material.QUARTZ_BLOCK)}; + + private Build _game; + + public GroundPage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Change Ground", player, 9 * 4); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + int index = 0; + for (final GroundData data : GROUNDS) + { + ShopItem shopItem = new ShopItem(data.getMaterial(), data.getData(), ItemStackFactory.Instance.GetName(data.getMaterial(), data.getData(), true), null, 0, false, false); + addButton(index, shopItem, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.setGround(data); + } + }); + index++; + } + + addButton((9 * 3) + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java new file mode 100644 index 000000000..8c3c0c3ab --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/MobPage.java @@ -0,0 +1,175 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; +import org.bukkit.entity.Ageable; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.meta.SkullMeta; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilSkull; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.MobShop; + +public class MobPage extends ShopPageBase +{ + private BuildData _buildData; + private Entity _entity; + + + public MobPage(ArcadeManager plugin, MobShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, BuildData buildData, Entity entity) + { + super(plugin, shop, clientManager, donationManager, "Mob Options", player, 9); + + _buildData = buildData; + _entity = entity; + buildPage(); + } + + @Override + protected void buildPage() + { +// byte entityData = UtilSkull.getSkullData(_entity); + + // Add Skull delete button + final String entityName = _entity.getType().getName(); +// ShopItem head = new ShopItem(Material.SKULL_ITEM, entityData, entityName, new String[] {C.cGray + "Right Click to Delete Entity" }, 0, false, false); +// if (UtilSkull.isPlayerHead(entityData)) +// { +// SkullMeta meta = ((SkullMeta) head.getItemMeta()); +// meta.setOwner(UtilSkull.getPlayerHeadName(_entity)); +// head.setItemMeta(meta); +// } + +// addButton(4, head, new IButton() +// { +// @Override +// public void onClick(Player player, ClickType clickType) +// { +// if (clickType == ClickType.RIGHT) +// { +// _buildData.removeEntity(_entity); +// UtilPlayer.message(player, F.main("Game", "Entity Deleted")); +// player.closeInventory(); +// } +// } +// }); + + + int buttonSlot = 1; + if (_entity instanceof Ageable) + { + final Ageable ageable = ((Ageable) _entity); + ShopItem item = new ShopItem(Material.BLAZE_ROD, "Make " + (ageable.isAdult() ? "Baby" : "Adult"), null, 0, false, false); + + addButton(buttonSlot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (ageable.isAdult()) + ageable.setBaby(); + else + ageable.setAdult(); + + UtilPlayer.message(player, F.main("Game", entityName + " is now a " + (ageable.isAdult() ? "Adult" : "Baby"))); + buildPage(); + } + }); + + buttonSlot+= 2; + } + + if (_entity instanceof LivingEntity) + { + final LivingEntity livingEntity = ((LivingEntity) _entity); + final boolean ghost = ((CraftLivingEntity) livingEntity).getHandle().ghost; + + ShopItem item = new ShopItem(Material.FEATHER, (ghost ? "Allow " : "Disable ") + "Pushing " + entityName, null, 0, false, false); + addButton(buttonSlot, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + ((CraftLivingEntity) livingEntity).getHandle().ghost = !ghost; + UtilPlayer.message(player, F.main("Game", "Pushing " + (ghost ? "Enabled" : "Disabled") + " for " + entityName)); + buildPage(); + } + }); + + + buttonSlot += 2; + } + + if (_entity instanceof Slime) + { + final Slime slime = ((Slime) _entity); + + ShopItem decreaseSize = new ShopItem(Material.CLAY_BALL, "Decrease Size", null, 0, false, false); + + ShopItem increaseSize = new ShopItem(Material.CLAY, "Increase Size", null, 0, false, false); + + addButton(buttonSlot, decreaseSize, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (slime.getSize() <= 1) + { + UtilPlayer.message(player, F.main("Game", "Slime is already smallest size")); + } + else + { + slime.setSize(slime.getSize() - 1); + } + } + }); + + buttonSlot += 2; + + addButton(buttonSlot, increaseSize, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (slime.getSize() >= 10) + { + UtilPlayer.message(player, F.main("Game", "Slime is already largest size")); + } + else + { + slime.setSize(slime.getSize() + 1); + } + } + }); + } + + ShopItem deleteButton = new ShopItem(Material.TNT, "Delete " + entityName, null, 0, false); + addButton(8, deleteButton, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (clickType == ClickType.RIGHT) + { + _buildData.removeEntity(_entity); + UtilPlayer.message(player, F.main("Game", "Entity Deleted")); + player.closeInventory(); + } + } + }); + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsPage.java new file mode 100644 index 000000000..fa4eeacb9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsPage.java @@ -0,0 +1,98 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class OptionsPage extends ShopPageBase +{ + private Build _game; + + public OptionsPage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Options", player, 9); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + + ShopItem ground = new ShopItem(Material.GRASS, "Change Ground", 0, false); + final ShopItem flightSpeed = new ShopItem(Material.FEATHER, "Flight Speed", new String[] {C.cWhite + "Left-Click to Increase Speed", C.cWhite + "Shift Left-Click to Decrease Speed" } , 0, false); + ShopItem particles = new ShopItem(Material.NETHER_STAR, "Particles", 0, false); + ShopItem weather = new ShopItem(Material.SAPLING, "Weather", 0, false); + ShopItem time = new ShopItem(Material.WATCH, "Time of Day", 0, false); + + addButton(0, ground, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new GroundPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + + final int maxLevel = 8; + final float minLevel = 0.1F; + final float perLevel = (1F - minLevel) / (maxLevel - 1); + flightSpeed.setAmount((int)((getPlayer().getFlySpeed() - minLevel) / perLevel) + 1); + addButton(2, flightSpeed, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + if (clickType == ClickType.SHIFT_LEFT) + { + int newLevel = Math.max(1, flightSpeed.getAmount() - 1); + player.setFlySpeed(minLevel + ((newLevel - 1) * perLevel)); + } + else if (clickType == ClickType.LEFT) + { + int newLevel = Math.min(maxLevel, flightSpeed.getAmount() + 1); + player.setFlySpeed(minLevel + ((newLevel - 1) * perLevel)); + } + + buildPage(); + } + }); + + addButton(4, particles, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new ParticlesPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + + addButton(6, weather, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new WeatherPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + + addButton(8, time, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new TimePage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java new file mode 100644 index 000000000..c670ed4d5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java @@ -0,0 +1,86 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import java.util.Arrays; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class ParticlesPage extends ShopPageBase +{ + private Build _game; + + public ParticlesPage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Add Particles", player); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + int index = 0; + for (final UtilParticle.ParticleType particleType : UtilParticle.ParticleType.values()) + { + if (particleType.hasFriendlyData()) + { + ShopItem shopItem = new ShopItem(particleType.getMaterial(), particleType.getData(), particleType.getFriendlyName(), null, 0, false, false); + addButton(index, shopItem, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + String[] lore = { ChatColor.GRAY + "Right click to place" }; + ItemStack itemStack = ItemStackFactory.Instance.CreateStack(particleType.getMaterial(), particleType.getData(), 1, ChatColor.GREEN + "Place " + particleType.getFriendlyName(), Arrays.asList(lore)); + player.getInventory().addItem(itemStack); + } + }); + + index++; + } + } + + ShopItem clearButton = new ShopItem(Material.TNT, "Clear Particles", null, 0, false); + addButton(53, clearButton, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.resetParticles(); + } + }); + + addButton((9 * 5) + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java new file mode 100644 index 000000000..f80cac336 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class TimePage extends ShopPageBase +{ + private Build _game; + + public TimePage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Set Time", player, 18); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + for (int i = 0; i < 9; i++) + { + final int ticks = 3000 * i; + boolean am = (ticks >= 0 && ticks < 6000) || (ticks >= 18000); + int time = (6 + (ticks / 1000)) % 12; + if (time == 0) time = 12; + + Material material = buildData.Time == ticks ? Material.WATCH : Material.INK_SACK; + byte data = (byte) (buildData.Time == ticks ? 0 : 8); + ShopItem item = new ShopItem(material, data, time + (am ? "am" : "pm"), null, 0, false, false); + addButton(i, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Time = ticks; + buildPage(); + } + }); + } + + addButton(9 + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java new file mode 100644 index 000000000..7c2ef6376 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class WeatherPage extends ShopPageBase +{ + private Build _game; + + public WeatherPage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Set Weather", player, 18); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + int sunnySlot = 2; + int rainingSlot = 4; + int stormingSlot = 6; + + ShopItem sunny = new ShopItem(Material.DOUBLE_PLANT, "Sunny", 1, false); + ShopItem raining = new ShopItem(Material.WATER_BUCKET, "Raining", 1, false); + ShopItem storming = new ShopItem(Material.GOLD_NUGGET, "Storming", 1, false); + + addButton(sunnySlot, sunny, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Weather = BuildData.WeatherType.SUNNY; + buildPage(); + } + }); + + addButton(rainingSlot, raining, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Weather = BuildData.WeatherType.RAINING; + buildPage(); + } + }); + + addButton(stormingSlot, storming, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Weather = BuildData.WeatherType.STORMING; + buildPage(); + } + }); + + switch (buildData.Weather) + { + case RAINING: + addGlow(rainingSlot); + break; + case STORMING: + addGlow(stormingSlot); + break; + default: + addGlow(sunnySlot); + } + + addButton(9 + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/kits/KitBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/kits/KitBuilder.java new file mode 100644 index 000000000..a00f1e7f8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/kits/KitBuilder.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.build.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitBuilder extends Kit +{ + public KitBuilder(ArcadeManager manager) + { + super(manager, "Builder", KitAvailability.Free, + + new String[] + { + "Can I build it!? Yes I can!" + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.WOOD)); + + } + + @Override + public void GiveItems(Player player) + { + + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index 0713e43d4..74f919373 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -48,6 +48,7 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -880,7 +881,8 @@ public class CastleSiege extends TeamGame if (event.getClickedBlock() == null || event.getClickedBlock().getTypeId() != 85) return; - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, (byte)0, 1000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java index 67fe0adf5..1397465e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/content/PumpkinKing.java @@ -7,7 +7,9 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.games.christmas.ChristmasAudio; import nautilus.game.arcade.game.games.christmas.parts.Part5; @@ -129,8 +131,10 @@ public class PumpkinKing public void Die() { - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ent.getLocation(), 0, 1, 0, 0, 1); - UtilParticle.PlayParticle(ParticleType.LAVA, _ent.getLocation(), 0.25f, 1, 0.25f, 0, 50); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ent.getLocation(), 0, 1, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LAVA, _ent.getLocation(), 0.25f, 1, 0.25f, 0, 50, + ViewDist.LONGER, UtilServer.getPlayers()); _ent.getWorld().playSound(_ent.getLocation(), Sound.ENDERDRAGON_DEATH, 4f, 0.5f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part1.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part1.java index cb1ec9741..c37047bce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part1.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/christmas/parts/Part1.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -100,7 +101,8 @@ public class Part1 extends Part event.setCancelled(true); event.getEntity().getWorld().playSound(event.getLocation(), Sound.EXPLODE, 4f, 1f); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } @EventHandler(priority = EventPriority.LOWEST) @@ -109,7 +111,8 @@ public class Part1 extends Part event.setCancelled(true); event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 4f, 1f); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } private void UpdateSkeleton() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index ef6d9d7ab..1b5bd2003 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -112,7 +112,7 @@ public class Draw extends SoloGame _words = new String[] { - "Bird", "Volcano", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", + "Bird", "Volcano", "Sloth", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", }; _tools = new HashSet(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java index 91df8eb87..61ba6ca2c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/Gravity.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; @@ -28,6 +29,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.util.C; @@ -39,9 +41,12 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -92,7 +97,7 @@ public class Gravity extends SoloGame _help = new String[] { - "Push DROP to launch yourself off platforms.", + "Drop Item to launch yourself off platforms.", "You automatically grab onto nearby platforms.", "Hold Block to use your Jetpack", "Your Experience Bar is your Jetpack Fuel", @@ -110,6 +115,8 @@ public class Gravity extends SoloGame this.CompassEnabled = true; this.WorldBoundaryKill = false; + + this.VersionRequire1_8 = true; } @Override @@ -132,12 +139,59 @@ public class Gravity extends SoloGame @EventHandler public void AnnounceBoost(GameStateChangeEvent event) { - if (event.GetState() != GameState.Live) - return; - - Announce(C.Bold + C.cPurple + "Press " + C.Bold + C.cWhite + "DROP WEAPON" + C.Bold + C.cPurple + " to boost yourself off platforms!"); + if (event.GetState() == GameState.Prepare) + { + UtilTextMiddle.display(null, C.cGreen + "Drop Weapon" + C.cWhite + " to boost off Platforms", 0, 120, 0); + + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + UtilTextMiddle.display(null, C.cGreen + "Hold Block" + C.cWhite + " to use Jetpack", 0, 80, 5); + } + }, 120); + } + } + @EventHandler + public void cleanObjects(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //Objects + Iterator oIter = _objects.iterator(); + + while (oIter.hasNext()) + { + GravityObject o = oIter.next(); + + if (o instanceof GravityPlayer) + continue; + + if (!isInsideMap(o.Base.getLocation())) + { + o.remove(); + } + } + + //Projectiles + Iterator arrowIter = _arrows.keySet().iterator(); + + while (arrowIter.hasNext()) + { + Arrow arrow = arrowIter.next(); + + if (!isInsideMap(arrow.getLocation())) + { + arrow.remove(); + arrowIter.remove(); + } + } + } + @EventHandler public void ClearObjects(GameStateChangeEvent event) { @@ -153,11 +207,14 @@ public class Gravity extends SoloGame @EventHandler public void KickOff(PlayerDropItemEvent event) { + event.setCancelled(true); + + if (!IsLive()) + return; + for (GravityObject object : _objects) if (object instanceof GravityPlayer) ((GravityPlayer)object).KickOff(event.getPlayer()); - - event.setCancelled(true); } @EventHandler @@ -542,8 +599,8 @@ public class Gravity extends SoloGame else { arrow.setVelocity(_arrows.get(arrow)); - UtilParticle.PlayParticle(ParticleType.FLAME, arrow.getLocation(), 0, 0, 0, 0, 1); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); arrow.getWorld().playSound(arrow.getLocation(), Sound.FIZZ, 0.3f, 0.5f); } } @@ -552,6 +609,9 @@ public class Gravity extends SoloGame @EventHandler public void BowHit(ProjectileHitEvent event) { + if (!IsLive()) + return; + BowExplode(event.getEntity()); } @@ -609,7 +669,8 @@ public class Gravity extends SoloGame } //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, proj.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, proj.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); proj.getWorld().playSound(proj.getLocation(), Sound.EXPLODE, 0.6f, 1.5f); //Remove @@ -651,7 +712,8 @@ public class Gravity extends SoloGame { if (UtilMath.offset(player.getLocation(), _powerup) < 3) { - UtilPlayer.message(player, F.main("Game", "You collected " + F.skill("Jetpack Fuel") + "!")); + UtilTextMiddle.display(null, C.cGreen + "Collected Jetpack Fuel", 0, 80, 5, player); + player.setExp(Math.min(0.9999f, player.getExp() + 0.25f)); player.getWorld().playSound(player.getLocation(), Sound.DRINK, 1f, 0.5f); @@ -662,5 +724,5 @@ public class Gravity extends SoloGame break; } } - } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/GravityObject.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/GravityObject.java index 7efef6c4e..34c83e330 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/GravityObject.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/GravityObject.java @@ -3,10 +3,13 @@ package nautilus.game.arcade.game.games.gravity; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBat; import nautilus.game.arcade.game.games.gravity.objects.*; +import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -31,7 +34,7 @@ public abstract class GravityObject public GravityObject(Gravity host, Entity ent, double mass, double size, Vector vel) { - Host = host; + Host = host; Ent = ent; Mass = mass; @@ -57,6 +60,7 @@ public abstract class GravityObject UtilEnt.Vegetate(Base, true); //UtilEnt.ghost(Base, true, true); + Host.Manager.GetCondition().Factory().Invisible(null, Base, null, 9999, 1, false, false, false); } public boolean IsPlayer() @@ -86,15 +90,18 @@ public abstract class GravityObject { if (this instanceof GravityPlayer) { - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, Ent.getLocation().subtract(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, Ent.getLocation().subtract(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } else if (this instanceof GravityBomb) { - UtilParticle.PlayParticle(ParticleType.FLAME, Ent.getLocation().add(0, -0.1, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, Ent.getLocation().add(0, -0.1, 0), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } else if (this instanceof GravityHook) { - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, Ent.getLocation().add(0, 0.1, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, Ent.getLocation().add(0, 0.1, 0), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } @@ -214,4 +221,12 @@ public abstract class GravityObject Bat.setSitting(!moving); //Host.Manager.GetDisguise().updateDisguise(Bat); } + + public void remove() + { + if (Base.getPassenger() != null) + Base.getPassenger().remove(); + + Base.remove(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityBomb.java index de2f0adfb..ee9204abf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityBomb.java @@ -6,8 +6,10 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import nautilus.game.arcade.game.games.gravity.Gravity; import nautilus.game.arcade.game.games.gravity.GravityObject; @@ -172,7 +174,8 @@ public class GravityBomb extends GravityObject public void CustomCollide(GravityObject other) { - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); Ent.getWorld().playSound(Ent.getLocation(), Sound.EXPLODE, 0.3f, 1f); Ent.remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityDebris.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityDebris.java index 8dc9dbc26..68cd2a333 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityDebris.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityDebris.java @@ -1,7 +1,9 @@ package nautilus.game.arcade.game.games.gravity.objects; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import nautilus.game.arcade.game.games.gravity.Gravity; import nautilus.game.arcade.game.games.gravity.GravityObject; @@ -15,13 +17,15 @@ public class GravityDebris extends GravityObject super(host, ent, mass, 2, vel); CollideDelay = System.currentTimeMillis() + 500; + SetMovingBat(true); } @Override public void CustomCollide(GravityObject other) { Ent.remove(); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, Ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, Ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } public boolean CanCollide(GravityObject other) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityPlayer.java index 7ff622d36..7a391955e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/objects/GravityPlayer.java @@ -3,12 +3,16 @@ package nautilus.game.arcade.game.games.gravity.objects; import java.util.Collection; import java.util.HashSet; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.gravity.Gravity; import nautilus.game.arcade.game.games.gravity.GravityObject; @@ -39,7 +43,7 @@ public class GravityPlayer extends GravityObject } public boolean NearBlock() - { + { return !NearBlockList().isEmpty(); } @@ -76,7 +80,7 @@ public class GravityPlayer extends GravityObject public void AutoGrab() { - UtilPlayer.message(this.Ent, "Bat: " + Base.getLocation().getY()); + //UtilPlayer.message(this.Ent, "Bat: " + Base.getLocation().getY()); if (Vel.length() == 0) return; @@ -88,7 +92,7 @@ public class GravityPlayer extends GravityObject return; Vel.multiply(0); - Base.setVelocity(new Vector(0,0,0)); + Base.setVelocity(new Vector(0,0.1,0)); GrabDelay = System.currentTimeMillis(); @@ -109,6 +113,20 @@ public class GravityPlayer extends GravityObject if (!Ent.equals(player)) return; + boolean nearBlock = false; + for (Block block : UtilBlock.getSurrounding(Base.getLocation().getBlock(), true)) + { + if (block.getType() != Material.AIR) + { + nearBlock = true; + break; + } + } + + //Requires near block OR batsit + if (!Bat.isSitting() && !nearBlock) + return; + GrabDelay = System.currentTimeMillis(); AddVelocity(player.getLocation().getDirection().multiply(0.5), 0.5); @@ -138,11 +156,14 @@ public class GravityPlayer extends GravityObject if (player.getExp() <= 0) { if (Recharge.Instance.use(player, "Fuel", 1000, false, false)) - UtilPlayer.message(Ent, F.main("Skill", "You have no more " + F.skill("Jetpack Fuel") + ".")); + { + UtilTextMiddle.display(C.cRed + "Jetpack Empty", "Collect Fuel at Gold Blocks with Fireworks", 0, 80, 5, (Player)Ent); + } + return; } - player.setExp((float) Math.max(0, player.getExp()-0.004)); + player.setExp((float) Math.max(0, player.getExp()-0.005)); AddVelocity(player.getLocation().getDirection().multiply(0.025), 0.5); @@ -150,7 +171,8 @@ public class GravityPlayer extends GravityObject Ent.getWorld().playSound(Ent.getLocation(), Sound.GHAST_FIREBALL, 0.3f, 2f); //Effect - UtilParticle.PlayParticle(ParticleType.FLAME, Ent.getLocation().add(0, 0.5, 0), 0.1f, 0.1f, 0.1f, 0, 2); + UtilParticle.PlayParticle(ParticleType.FLAME, Ent.getLocation().add(0, 0.5, 0), 0.1f, 0.1f, 0.1f, 0, 2, + ViewDist.MAX, UtilServer.getPlayers()); } public void Oxygen() @@ -168,7 +190,11 @@ public class GravityPlayer extends GravityObject //Restore if (near) { - UtilPlayer.message(Ent, F.main("Game", "Restoring Oxygen...")); + if (Base.getHealth() < 58) + UtilTextMiddle.display(null, "Refilling Oxygen...", 0, 60, 5, (Player)Ent); + else + UtilTextMiddle.display(null, C.cGreen + "Oxygen Full", 0, 60, 5, (Player)Ent); + Ent.getWorld().playSound(Ent.getLocation(), Sound.CAT_HISS, 0.2f, 0.5f); Base.setHealth(Math.min(60, Base.getHealth() + 10)); @@ -186,8 +212,7 @@ public class GravityPlayer extends GravityObject DamageCause.CUSTOM, 2, false, true, false, "Oxygen Depleted", "Oxygen Depleted"); - UtilPlayer.message(Ent, F.main("Game", "You are suffocating!")); - UtilPlayer.message(Ent, F.main("Game", "Get more Oxygen from the Emerald Blocks!")); + UtilTextMiddle.display(C.cRed + "Suffocating", "Refill Oxygen at Emerald Blocks", 0, 60, 5, (Player)Ent); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java index bdd1fc7b7..5ee19efdd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween/creatures/PumpkinKing.java @@ -11,7 +11,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; - import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -20,6 +19,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -257,7 +257,8 @@ public class PumpkinKing extends CreatureBase if (GetState() >= 4) { //Particles - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, GetEntity().getLocation().add(0, 1.5, 0), 0.2f, 0.4f, 0.2f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, GetEntity().getLocation().add(0, 1.5, 0), 0.2f, 0.4f, 0.2f, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } @@ -404,7 +405,8 @@ public class PumpkinKing extends CreatureBase { Skeleton minion = _minions.get(i); - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, minion.getEyeLocation(), 0.1f, 0.1f, 0.1f, 0, 1); + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, minion.getEyeLocation(), 0.1f, 0.1f, 0.1f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); minion.setTarget(null); @@ -465,7 +467,8 @@ public class PumpkinKing extends CreatureBase { final Skeleton minion = _minions.get(i); - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, minion.getEyeLocation(), 0.1f, 0.1f, 0.1f, 0, 1); + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, minion.getEyeLocation(), 0.1f, 0.1f, 0.1f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); LivingEntity target = _minionTargets.get(minion); if (target == null) @@ -657,7 +660,8 @@ public class PumpkinKing extends CreatureBase { Entity shield = _shields.get(i); - UtilParticle.PlayParticle(ParticleType.FLAME, shield.getLocation(), 0.1f, 0.1f, 0.1f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, shield.getLocation(), 0.1f, 0.1f, 0.1f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); double lead = i * ((2d * Math.PI)/_shields.size()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index 31c333ead..28bc955d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -58,6 +58,7 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; @@ -917,7 +918,8 @@ public class HideSeek extends TeamGame this.AddGems(player, 0.25, "Meows", true, true); - UtilParticle.PlayParticle(ParticleType.NOTE, player.getLocation().add(0, 0.75, 0), 0.4f, 0.4f, 0.4f, 0, 6); + UtilParticle.PlayParticle(ParticleType.NOTE, player.getLocation().add(0, 0.75, 0), 0.4f, 0.4f, 0.4f, 0, 6, + ViewDist.MAX, UtilServer.getPlayers()); Bukkit.getPluginManager().callEvent(new MeowEvent(event.getPlayer())); } @@ -1524,7 +1526,8 @@ public class HideSeek extends TeamGame public void InfestStart(LivingEntity ent) { - UtilParticle.PlayParticle(ParticleType.SLIME, ent.getLocation().add(0, 0.6, 0), 0.3f, 0.3f, 0.3f, 0, 24); + UtilParticle.PlayParticle(ParticleType.SLIME, ent.getLocation().add(0, 0.6, 0), 0.3f, 0.3f, 0.3f, 0, 24, + ViewDist.MAX, UtilServer.getPlayers()); ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java index 8a05509f2..c4f5a47ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -74,6 +74,7 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.itemstack.ItemStackFactory; @@ -259,6 +260,8 @@ public class MineStrike extends TeamGame this.InventoryClick = true; this.JoinInProgress = true; + + this.VersionRequire1_8 = true; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); @@ -966,7 +969,8 @@ public class MineStrike extends TeamGame //Particle if (bullet != null && bullet.Shooter != null) - UtilParticle.PlayParticle(bullet.Shooter, ParticleType.FIREWORKS_SPARK, event.getEntity().getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getEntity().getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, bullet.Shooter); //Hit Block Sound event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); @@ -1049,7 +1053,8 @@ public class MineStrike extends TeamGame //Particle if (bullet != null && bullet.Shooter != null) - UtilParticle.PlayParticle(bullet.Shooter, ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, bullet.Shooter); //Hit Block Sound arrow.getWorld().playSound(arrow.getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); @@ -1063,7 +1068,8 @@ public class MineStrike extends TeamGame { loc.add(UtilAlg.getTrajectory(loc, arrow.getLocation()).multiply(1)); - UtilParticle.PlayParticle(ParticleType.CRIT, loc, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CRIT, loc, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } //Block Particle @@ -1459,7 +1465,8 @@ public class MineStrike extends TeamGame { Entity grenadeItem = grenadeIterator.next(); - UtilParticle.PlayParticle(ParticleType.CRIT, grenadeItem.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CRIT, grenadeItem.getLocation(), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); //Expired if (!grenadeItem.isValid() || grenadeItem.getTicksLived() > 400) @@ -1763,7 +1770,8 @@ public class MineStrike extends TeamGame if (_bombItem == null) return; - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, _bombItem.getLocation().add(0.0, 0.2, 0.0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, _bombItem.getLocation().add(0.0, 0.2, 0.0), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } public int getScore(GameTeam team) @@ -2701,40 +2709,7 @@ public class MineStrike extends TeamGame other.playSound(player.getLocation(), radio.getSound(), 1.5f, 1f); } } - - @EventHandler - public void joinMessage(PlayerJoinEvent event) - { - if (!UtilPlayer.is1_8(event.getPlayer())) - returnToHub(event.getPlayer()); - - else - UtilTextMiddle.display(C.cGold + C.Bold + "MineStrike", "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer()); - } - @EventHandler - public void outdatedVersion(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Player player : UtilServer.getPlayers()) - { - if (!UtilPlayer.is1_8(player)) - returnToHub(player); - } - } - - public void returnToHub(Player player) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cGold + C.Bold + "Mine-Strike 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 debug(PlayerCommandPreprocessEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java index a37485eed..65dee38f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java @@ -1,8 +1,10 @@ package nautilus.game.arcade.game.games.minestrike.data; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import org.bukkit.Material; import org.bukkit.Sound; @@ -53,7 +55,8 @@ public class Bomb if (UtilTime.elapsed(LastBeep, beepDuration)) { Block.getWorld().playSound(Block.getLocation(), Sound.ANVIL_BREAK, volume, 1f); - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); LastBeep = System.currentTimeMillis(); } @@ -63,7 +66,8 @@ public class Bomb clean(); //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Block.getLocation(), 10f, 10f, 10f, 0, 30); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Block.getLocation(), 10f, 10f, 10f, 0, 30, + ViewDist.MAX, UtilServer.getPlayers()); for (int i=0 ; i<3 ; i++) Block.getWorld().playSound(Block.getLocation(), Sound.ANVIL_LAND, 20f, (float)(Math.random() * 0.5 + 0.5)); @@ -87,7 +91,8 @@ public class Bomb clean(); //Effect - UtilParticle.PlayParticle(ParticleType.CLOUD, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CLOUD, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } public void clean() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java index 2b85418c7..a94e0ee44 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FireGrenadeBase.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.Radio; @@ -54,7 +55,8 @@ public abstract class FireGrenadeBase extends Grenade loc.getWorld().playSound(loc, Sound.IRONGOLEM_THROW, 1f, 1f); //Particle - UtilParticle.PlayParticle(ParticleType.LAVA, loc.add(0, 0.2, 0), 0.3f, 0f, 0.3f, 0, 30); + UtilParticle.PlayParticle(ParticleType.LAVA, loc.add(0, 0.2, 0), 0.3f, 0f, 0.3f, 0, 30, + ViewDist.LONG, UtilServer.getPlayers()); //Fire Blocks final HashMap blocks = UtilBlock.getInRadius(loc, 3.5d); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java index 1bcd4e483..cf422687b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java @@ -5,7 +5,9 @@ import java.util.HashMap; import java.util.List; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.MineStrike; @@ -36,7 +38,8 @@ public class HighExplosive extends Grenade if (ent.getTicksLived() > 40) { UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, - ent.getLocation(), 0, 0, 0, 0, 1); + ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); ent.getWorld().playSound(ent.getLocation(), Sound.EXPLODE, 3f, 0.8f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java index 0537384b8..1857f7a30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java @@ -1,7 +1,9 @@ package nautilus.game.arcade.game.games.minestrike.items.grenades; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.Radio; @@ -29,7 +31,8 @@ public class Smoke extends Grenade { if (ent.getTicksLived() > 60) { - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0.3f, 0.3f, 0.3f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0.3f, 0.3f, 0.3f, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); ent.getWorld().playSound(ent.getLocation(), Sound.FIZZ, 0.1f, 0.1f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java index cc2111290..0a70ee22a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.game.games.minestrike.items.guns; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; - import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; @@ -12,6 +11,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; @@ -131,7 +131,8 @@ public class Gun extends StrikeItem Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.2)); loc.add(UtilAlg.getRight(player.getLocation().getDirection()).multiply(0.5)); loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.3)); - UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); game.registerBullet(fireBullet(player, game)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java index e71a46c68..579843cc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java @@ -1,7 +1,9 @@ package nautilus.game.arcade.game.games.minestrike.items.guns; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; @@ -45,7 +47,8 @@ public class Shotgun extends Gun //Effect soundFire(player.getLocation()); - UtilParticle.PlayParticle(ParticleType.CLOUD, player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.5)), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.CLOUD, player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.5)), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); for (int i=0 ; i<_pellets ; i++) game.registerBullet(fireBullet(player, game)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java index 90dfa2574..cbabc5f8f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSheep.java @@ -66,7 +66,7 @@ public class KitSheep extends SmashKit { ChatColor.RESET + "Charge up static electricity in your", ChatColor.RESET + "wooly coat, and then unleash it upon", - ChatColor.RESET + "enemies in a devestating laser beam!", + ChatColor.RESET + "enemies in a devastating laser beam!", })); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java index e1b22e1b2..2d319f847 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/kits/KitSlime.java @@ -15,7 +15,9 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.itemstack.ItemStackFactory; @@ -190,7 +192,8 @@ public class KitSlime extends SmashKit DamageCause.CUSTOM, 8, true, false, false, player.getName(), GetName()); - UtilParticle.PlayParticle(ParticleType.SLIME, other.getLocation().add(0, 0.6, 0), 1f, 1f, 1f, 0, 20); + UtilParticle.PlayParticle(ParticleType.SLIME, other.getLocation().add(0, 0.6, 0), 1f, 1f, 1f, 0, 20, + ViewDist.LONG, UtilServer.getPlayers()); player.getWorld().playSound(other.getLocation(), Sound.SLIME_ATTACK, 3f, 1f); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java index 699c3ae15..25e4cb3f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snake/Snake.java @@ -26,9 +26,9 @@ import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; + import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_7_R4.Navigation; - import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -37,8 +37,10 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.recharge.Recharge; @@ -349,7 +351,8 @@ public class Snake extends SoloGame if (UtilMath.offset(_tail.get(player).get(0), tail) < 1.2) { - UtilParticle.PlayParticle(ParticleType.EXPLODE, tail.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.EXPLODE, tail.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); KillPlayer(player, other, null); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java index 73d1b3702..474567032 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.sneakyassassins; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.*; import mineplex.core.recharge.Recharge; import mineplex.core.updater.*; @@ -305,7 +306,8 @@ public class SneakyAssassins extends SoloGame event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.VILLAGER_YES, 1f, 1f); - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, event.getRightClicked().getLocation().add(0, 1, 0), 0.3f, 0.5f, 0.3f, 0, 10); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, event.getRightClicked().getLocation().add(0, 1, 0), 0.3f, 0.5f, 0.3f, 0, 10, + ViewDist.NORMAL, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java index 6d03c3644..f491bfa88 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/npc/NpcManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.sneakyassassins.npc; import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.*; import mineplex.core.updater.event.*; import mineplex.minecraft.game.core.condition.Condition.ConditionType; @@ -83,7 +84,8 @@ public class NpcManager implements Listener { LivingEntity npc = UtilAlg.Random(npcs); - UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, npc.getLocation(), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, npc.getLocation(), 0f, 0f, 0f, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); npc.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/powerups/PowerUpItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/powerups/PowerUpItem.java index 83ead7777..70cce7b1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/powerups/PowerUpItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/powerups/PowerUpItem.java @@ -2,8 +2,10 @@ package nautilus.game.arcade.game.games.sneakyassassins.powerups; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.*; import mineplex.core.updater.event.*; + import org.bukkit.*; import org.bukkit.block.*; import org.bukkit.entity.*; @@ -149,6 +151,7 @@ public class PowerUpItem float z = (float) (Math.cos(getNPC().getTicksLived()/4d) * 1f); float y = (float) (Math.cos(getNPC().getTicksLived()/7d) * 1f + 1f); - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, getNPC().getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, getNPC().getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } } 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..c7ca00602 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 @@ -74,6 +74,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -242,6 +243,8 @@ public class SurvivalGames extends SoloGame PlaySoundGameStart = false; PrepareTime = 15000; + + VersionRequire1_8 = true; BlockBreakAllow.add(Material.WEB.getId()); // Web BlockPlaceAllow.add(Material.WEB.getId()); @@ -1102,13 +1105,6 @@ public class SurvivalGames extends SoloGame event.setCancelled(true); } - @EventHandler - public void joinMessage(PlayerJoinEvent event) - { - if (!UtilPlayer.is1_8(event.getPlayer())) - returnToHub(event.getPlayer()); - } - @EventHandler public void onGameEnd(GameStateChangeEvent event) { @@ -1165,13 +1161,6 @@ public class SurvivalGames extends SoloGame return; } - for (Player player : Bukkit.getOnlinePlayers()) - { - if (!UtilPlayer.is1_8(player)) - { - returnToHub(player); - } - } if (!IsLive()) { @@ -1332,16 +1321,6 @@ public class SurvivalGames extends SoloGame } } - @EventHandler - public void outdatedVersion(GameStateChangeEvent event) - { - for (Player player : UtilServer.getPlayers()) - { - if (!UtilPlayer.is1_8(player)) - returnToHub(player); - } - } - @EventHandler public void outsideBorder(UpdateEvent event) { @@ -1471,7 +1450,8 @@ public class SurvivalGames extends SoloGame eFireball.dirY = traj.getY() * 0.1; eFireball.dirZ = traj.getZ() * 0.1; - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, spawn, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, spawn, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); player.getWorld().playSound(attackSource, Sound.GHAST_FIREBALL, 2f, 2f); } } @@ -1680,16 +1660,6 @@ public class SurvivalGames extends SoloGame } - public void returnToHub(Player player) - { - UtilPlayer.message(player, " "); - UtilPlayer.message(player, C.cGold + C.Bold + "SurvivalGames 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"); - } - @Override @EventHandler public void ScoreboardUpdate(UpdateEvent event) @@ -1844,129 +1814,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 @@ -2102,7 +2072,8 @@ public class SurvivalGames extends SoloGame continue; } - UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1); + UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java index 969e404b4..f37c1564b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java @@ -54,6 +54,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -1176,7 +1177,8 @@ public class SurvivalGamesTeams extends TeamGame continue; } - UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1); + UtilParticle.PlayParticle(ParticleType.SPELL, block.getLocation().add(0.5, 0.5, 0.5), 0.3f, 0.3f, 0.3f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index ea663bbe2..603f1c2bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -60,6 +60,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -339,7 +340,8 @@ public class UHC extends TeamGame if (UtilMath.offset(player.getLocation(), newLoc) > 16) continue; - UtilParticle.PlayParticle(player, ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1, + ViewDist.NORMAL, player); if (_borderSize > 16) player.playSound(newLoc, Sound.FIZZ, 0.1f, 0.1f); @@ -365,7 +367,8 @@ public class UHC extends TeamGame if (UtilMath.offset(player.getLocation(), newLoc) > 16) continue; - UtilParticle.PlayParticle(player, ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, newLoc, 0.5f, 0.5f, 0.5f, 0, 1, + ViewDist.NORMAL, player); if (_borderSize > 16) player.playSound(newLoc, Sound.FIZZ, 0.1f, 0.1f); @@ -391,7 +394,8 @@ public class UHC extends TeamGame if (!UtilBlock.airFoliage(block)) continue; - UtilParticle.PlayParticle(player, ParticleType.LAVA, block.getLocation().add(0.5, 0.5, 0.5), 0.5f, 0.5f, 0.5f, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, block.getLocation().add(0.5, 0.5, 0.5), 0.5f, 0.5f, 0.5f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } 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..c72976da6 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) + 1", + "", "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()); } @@ -697,7 +727,7 @@ public enum SpellType // ❤ + _spellCooldown - _cooldownChangePerLevel) - * (this == SpellType.Heal ? 1 : wizard.getCooldownModifier()))); + * (this == Heal || this == RainbowRoad ? 1 : wizard.getCooldownModifier()))); } public ItemStack getSpellItem() @@ -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..7fccee6e7 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 @@ -18,95 +18,91 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; -public class WizardSpellMenu extends MiniPlugin +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..1998bcfa6 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,35 +1,42 @@ 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; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.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; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.explosion.CustomExplosion; import nautilus.game.arcade.ArcadeManager; @@ -45,6 +52,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 +67,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 +78,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 +95,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 +108,1910 @@ 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; + VersionRequire1_8 = 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 onWandHit(CustomDamageEvent event) + { + // Damager is ENTITY + if (event.GetDamagerEntity(true) != null) + { + if (event.GetReason() == null) + { + if (event.GetDamagerPlayer(false) != null) + { + Player damager = event.GetDamagerPlayer(false); + + if (damager.getInventory().getHeldItemSlot() < 5) + { + Wizard wizard = getWizard(damager); + + String reason = damager.getInventory().getHeldItemSlot() < wizard.getWandsOwned() ? "Wand" : "Fist"; + + event.AddMod(reason, reason, 0, 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.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 = 24; + 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) + { + 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()); + } + } - 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()); + for (ItemStack item : inv.getArmorContents()) + { + if (item != null && item.getType() != Material.AIR) + { + items.add(item.clone()); + } + } - Iterator itel = event.getDrops().iterator(); + ItemStack cursorItem = player.getItemOnCursor(); - while (itel.hasNext()) - { - ItemStack item = itel.next(); + if (cursorItem != null && cursorItem.getType() != Material.AIR) + items.add(cursorItem.clone()); - if (item.getType() == Material.BLAZE_ROD || item.getType() == Material.STAINED_GLASS_PANE) - { - itel.remove(); - } - } - } + return items; + } - _wizards.remove(event.getEntity().getName()); - } + private void dropSpells(Player player) + { + HashSet spells = new HashSet(); + ArrayList itemsToDrop = new ArrayList(); - @EventHandler - public void onDropItem(ItemSpawnEvent event) - { - ItemStack item = event.getEntity().getItemStack(); + Wizard wizard = getWizard(player); - 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(( + for (int i = 0; i < 5; i++) + { + SpellType type = wizard.getSpell(i); - (getGameLiveTime() == 0 ? System.currentTimeMillis() : getGameLiveTime()) + 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)); + } + } - + (10 * 60 * 1000)) - System.currentTimeMillis(), 1, TimeUnit.MINUTES); + private void fillWithLoot(Block block) + { + BlockState state = block.getState(); - 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" : "")); + if (state instanceof InventoryHolder) + { + InventoryHolder holder = (InventoryHolder) state; + Inventory inv = holder.getInventory(); + boolean containsSpell = false; - GetScoreboard().Draw(); - } + for (int i = 0; i < 5 || !containsSpell; i++) + { + + ItemStack item = _chestLoot.getLoot(); + + SpellType spellType = getSpell(item); + + // 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); + } + } + } + + 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(ParticleType.HEART, + ((LivingEntity) event.getEntity()).getEyeLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, (Player) event.getDamager()); + } + } + } + } + + @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.getSlot() >= 5 ? 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 == Material.BUCKET || 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; + } + } + } + } + } + + + @Override + public void ParseData() + { + CreateChestCraftEnchant(); + _endGameEvent = UtilMath.r(2); + + System.out.print("Endgame event: " + (_endGameEvent == 0 ? "Meteors" : "Lightning")); + } + + @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.getBlock().getType() == Material.AIR) + { + location.add(0, -1, 0); + } + + if (location.getBlockY() > 0 && location.getBlock().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() 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, + ViewDist.MAX, UtilServer.getPlayers()); + + 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..2e240ffa0 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.Gem, 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..d672537cf 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.Gem, 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..b76498022 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.Achievement, 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.WIZARDS_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..2b4ae19f6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellAnvilDrop.java @@ -0,0 +1,141 @@ +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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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, + ViewDist.LONG, UtilServer.getPlayers()); + + 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..847c840be 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,72 @@ 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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; 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, + ViewDist.LONG, UtilServer.getPlayers()); + } + + // 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..94181f076 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellIceShards.java @@ -0,0 +1,156 @@ +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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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, + ViewDist.LONG, UtilServer.getPlayers()); + 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, + ViewDist.LONG, UtilServer.getPlayers()); + } + + _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..854ffb045 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,17 @@ 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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; @@ -12,74 +21,150 @@ 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()); + if (effectedBlocks.isEmpty()) + { + return; + } - block.setDropItem(false); + Collections.shuffle(effectedBlocks); - effectedBlock.setType(Material.AIR); - } - } - } - } + new BukkitRunnable() + { + int timesRan; + Iterator bItel; - for (Player player : Bukkit.getOnlinePlayers()) - { - player.playSound(player == p ? p.getLocation() : centerBlock.getLocation(), Sound.ENDERDRAGON_GROWL, 1.5F, 1.5F); - } + public void run() + { + if (effectedBlocks.size() > 0) + { + 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); + } - charge(p); - } - } + if (timesRan % 3 == 0) + { + for (int a = 0; a < Math.ceil(effectedBlocks.size() / 3D); a++) + { + if (bItel == null || !bItel.hasNext()) + { + bItel = effectedBlocks.iterator(); + } + + 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, + ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + } + + 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..51dd9e9cf 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,19 @@ 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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; 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 +23,132 @@ 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, + ViewDist.LONG, UtilServer.getPlayers()); + + 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, + 2 + (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..cccbbdcfd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellManaBolt.java @@ -0,0 +1,217 @@ +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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.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, + ViewDist.LONG, UtilServer.getPlayers()); + } + + 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, + ViewDist.LONG, UtilServer.getPlayers()); + } + + 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..01fbc81ec --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellNapalm.java @@ -0,0 +1,271 @@ +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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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, + ViewDist.LONG, UtilServer.getPlayers()); + } + + 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..06d20eb1b --- /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() + ((14 + UtilMath.r(7)) * 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..5aa7748c2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellSpectralArrow.java @@ -0,0 +1,106 @@ +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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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, + ViewDist.MAX, UtilServer.getPlayers()); + } + + 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..cdfbe7b97 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,10 +2,13 @@ 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; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -29,137 +32,138 @@ 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, + ViewDist.LONG, UtilServer.getPlayers()); + 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..7f6e91210 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,132 @@ 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.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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, + ViewDist.LONG, UtilServer.getPlayers()); + } + + 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, + ViewDist.LONG, UtilServer.getPlayers()); + + 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..96b6f0af8 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,191 @@ 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.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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), + ViewDist.LONG, UtilServer.getPlayers()); + } + } + 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/PerkBatForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatForm.java index 4b550b3c6..e5a3216e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatForm.java @@ -22,8 +22,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseWitch; import mineplex.core.recharge.Recharge; @@ -167,7 +169,8 @@ public class PerkBatForm extends SmashPerk data.Location.add(data.Direction.clone().multiply(0.75)); //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Location, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); data.Location.getWorld().playSound(data.Location, Sound.FIZZ, 1f, 2f); } } @@ -175,7 +178,8 @@ public class PerkBatForm extends SmashPerk private void explode(SonicBoomData data) { //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Location, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Location, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); data.Location.getWorld().playSound(data.Location, Sound.EXPLODE, 1f, 1.5f); //Damage diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java index fbb37a302..b0366e539 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBatWave.java @@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; @@ -188,7 +189,8 @@ public class PerkBatWave extends SmashPerk //Effect bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f); - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); bat.remove(); @@ -232,7 +234,8 @@ public class PerkBatWave extends SmashPerk for (Bat bat : _bats.get(player)) { if (bat.isValid()) - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3, + ViewDist.LONG, UtilServer.getPlayers()); bat.remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBladeVortex.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBladeVortex.java index 32cfe31cc..66292d9d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBladeVortex.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBladeVortex.java @@ -21,8 +21,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.kit.Perk; @@ -102,12 +104,14 @@ public class PerkBladeVortex extends Perk double x = Math.sin(j + (ticksLived/50d)) * (j%(Math.PI/2d)) * 3; double z = Math.cos(j + (ticksLived/50d)) * (j%(Math.PI/2d)) * 3; - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); x = Math.sin(j + (ticksLived/50d) + Math.PI/4) * (j%(Math.PI/2d)) * 3; z = Math.cos(j + (ticksLived/50d) + Math.PI/4) * (j%(Math.PI/2d)) * 3; - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(x, 1, z), 0f, 0f, 0f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); //Sound player.getWorld().playSound(player.getLocation(), Sound.STEP_WOOL, 2f, 1f + (float)((j%(Math.PI/2d))/(Math.PI/2))); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBullsCharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBullsCharge.java index d42fa4b71..45fb0049d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBullsCharge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBullsCharge.java @@ -18,7 +18,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -121,7 +123,8 @@ public class PerkBullsCharge extends Perk if (player.hasPotionEffect(PotionEffectType.SPEED)) UtilParticle.PlayParticle(ParticleType.CRIT, player.getLocation(), - (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 2); + (float)(Math.random() - 0.5), 0.2f + (float)(Math.random() * 1), (float)(Math.random() - 0.5), 0, 2, + ViewDist.LONG, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java index 8934cae7e..5b34be0b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkChickenRocket.java @@ -27,8 +27,10 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -184,7 +186,8 @@ public class PerkChickenRocket extends SmashPerk } //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Chicken.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Chicken.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); data.Chicken.getWorld().playSound(data.Chicken.getLocation(), Sound.EXPLODE, 2f, 1.2f); //Firework diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java index b500a7c39..4e1c99624 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperExplode.java @@ -23,7 +23,9 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseCreeper; import mineplex.core.recharge.Recharge; @@ -127,13 +129,15 @@ public class PerkCreeperExplode extends SmashPerk if (!isSuper) { //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); } else { //Particles - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 5f, 5f, 5f, 0, 20); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 5f, 5f, 5f, 0, 20, + ViewDist.MAX, UtilServer.getPlayers()); //Sound for (int i=0 ; i<4 ; i++) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java index 7fc965819..e5dc574de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCreeperSulphurBomb.java @@ -18,7 +18,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; @@ -116,7 +118,8 @@ public class PerkCreeperSulphurBomb extends SmashPerk implements IThrown public void Explode(ProjectileUser data) { - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.GetThrown().getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.GetThrown().getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); data.GetThrown().getWorld().playSound(data.GetThrown().getLocation(), Sound.EXPLODE, 1f, 1.5f); data.GetThrown().remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java index d8f23c155..d8ea85b93 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeadlyBones.java @@ -17,7 +17,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -74,7 +76,8 @@ public class PerkDeadlyBones extends SmashPerk continue; //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, item.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, item.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); item.getWorld().playSound(item.getLocation(), Sound.EXPLODE, 0.8f, 1.4f); Player player = _active.get(item); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java index 15bab2b60..4ceaaee33 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDeathsGrasp.java @@ -25,8 +25,10 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -179,8 +181,10 @@ public class PerkDeathsGrasp extends Perk event.AddMult(GetName(), GetName() + " Combo", 2, true); - UtilParticle.PlayParticle(ParticleType.RED_DUST, event.GetDamageeEntity().getLocation(), 0.5f, 0.5f, 0.5f, 0, 20); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.RED_DUST, event.GetDamageeEntity().getLocation(), 0.5f, 0.5f, 0.5f, 0, 20, + ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); damager.getWorld().playSound(damager.getLocation(), Sound.ZOMBIE_HURT, 1f, 2f); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java index 93fbdc12e..f56226073 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDestructor.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.*; import mineplex.core.recharge.*; import mineplex.core.updater.*; @@ -151,7 +152,8 @@ public class PerkDestructor extends Perk } } - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getTo(), 0f, 0f, 0f, 0f, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getTo(), 0f, 0f, 0f, 0f, 1, + ViewDist.MAX, UtilServer.getPlayers()); event.getTo().getWorld().playSound(event.getTo(), Sound.EXPLODE, 1f, 0.5f); event.getTo().getWorld().playSound(event.getTo(), Sound.FIREWORK_TWINKLE, 2f, 0.5f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java index 4f8c1f86b..4d0a133e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEndermanDragon.java @@ -18,7 +18,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -136,7 +138,8 @@ public class PerkEndermanDragon extends SmashPerk { EnderDragon dragon = _dragons.get(player); - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, dragon.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, dragon.getLocation(), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); for (Player other : Manager.GetGame().GetPlayers(true)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEvade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEvade.java index 79d5401a3..2aee1af11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEvade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkEvade.java @@ -22,8 +22,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -135,7 +137,8 @@ public class PerkEvade extends Perk //Effect UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, damagee.getLocation(), - (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10); + (float)(Math.random() - 0.5), (float)(Math.random() * 1.4), (float)(Math.random() - 0.5), 0, 10, + ViewDist.NORMAL, UtilServer.getPlayers()); //Action damagee.teleport(target); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplode.java index d054f503d..f561a62ee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkExplode.java @@ -18,7 +18,9 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.kit.Perk; @@ -83,7 +85,8 @@ public class PerkExplode extends Perk } //Effect - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java index d5ff6f514..fd0222205 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameDash.java @@ -17,8 +17,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -127,7 +129,8 @@ public class PerkFlameDash extends Perk data.Player.getWorld().playSound(data.Player.getLocation(), Sound.FIZZ, 0.6f, 1.2f); //Particles - UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 3); + UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 3, + ViewDist.LONGER, UtilServer.getPlayers()); } //End else @@ -157,8 +160,10 @@ public class PerkFlameDash extends Perk data.Player.getWorld().playSound(data.Player.getLocation(), Sound.EXPLODE, 1f, 1.2f); //Particles - UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation(), 0.1f, 0.1f, 0.1f, 0.3f, 100); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, data.Player.getLocation(), 0.1f, 0.1f, 0.1f, 0.3f, 100, + ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, data.Player.getLocation().add(0, 0.4, 0), 0.2f, 0.2f, 0.2f, 0f, 1, + ViewDist.MAX, UtilServer.getPlayers()); dataIterator.remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java index e3baf43d6..5c17248c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlameSlam.java @@ -23,8 +23,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -101,7 +103,8 @@ public class PerkFlameSlam extends Perk player.setVelocity(vel.multiply(0.8)); //Particle - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 5); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 5, + ViewDist.LONGER, UtilServer.getPlayers()); for (Entity other : player.getWorld().getEntities()) { @@ -160,8 +163,10 @@ public class PerkFlameSlam extends Perk DamageCause.CUSTOM, 24, true, true, false, damager.getName(), GetName()); - UtilParticle.PlayParticle(ParticleType.LAVA, damagee.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 30); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, damagee.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, damagee.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 30, + ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, damagee.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); damager.getWorld().playSound(damagee.getLocation(), Sound.EXPLODE, 1f, 1f); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlash.java index 6de0c5225..72ca1f21a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFlash.java @@ -22,7 +22,9 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.kit.Perk; @@ -136,7 +138,8 @@ public class PerkFlash extends Perk curRange += 0.2; // Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); } // Modify Range diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java index 6c1176f42..8339b3b3c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorseKick.java @@ -18,7 +18,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; @@ -152,7 +154,8 @@ public class PerkHorseKick extends SmashPerk loc.add(player.getLocation().getDirection().setY(0).normalize().multiply(1.5)); loc.add(0, 0.8, 0); - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc, 0.3f, 0.3f, 0.3f, 0, 2); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc, 0.3f, 0.3f, 0.3f, 0, 2, + ViewDist.LONG, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java index 5570c57d9..5e67dbcec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkInfernalHorror.java @@ -12,7 +12,9 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -144,10 +146,12 @@ public class PerkInfernalHorror extends SmashPerk Manager.GetCondition().Factory().Speed(GetName(), player, player, 0.9, 1, false, false, false); //Particles - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); if (Math.random() > 0.9) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java index 12bc8c2bf..e1cf6acf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLazer.java @@ -24,7 +24,9 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.recharge.Recharge; @@ -168,13 +170,15 @@ public class PerkLazer extends Perk curRange += 0.2; //Smoke Trail - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } //Destination Location target = player.getLocation().add(player.getLocation().getDirection().multiply(curRange)); - UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.EXPLODE, target, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); //Firework UtilFirework.playFirework(player.getLocation().add(player.getLocation().getDirection().multiply(Math.max(0, curRange - 0.6))), Type.BURST, Color.YELLOW, false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java index 256ddd79f..0d1c147f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBlast.java @@ -21,7 +21,9 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -150,6 +152,7 @@ public class PerkMagmaBlast extends Perk } //Particles - UtilParticle.PlayParticle(ParticleType.LAVA, proj.getLocation(), 0.1f, 0.1f, 0.1f, 0.1f, 50); + UtilParticle.PlayParticle(ParticleType.LAVA, proj.getLocation(), 0.1f, 0.1f, 0.1f, 0.1f, 50, + ViewDist.LONG, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java index a15af4b4e..0b8edda31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagmaBoost.java @@ -12,12 +12,12 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseMagmaCube; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import nautilus.game.arcade.kit.Perk; public class PerkMagmaBoost extends Perk @@ -128,13 +128,17 @@ public class PerkMagmaBoost extends Perk size += _kills.get(player); if (size == 0 && event.getType() == UpdateType.SEC) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); else if (size == 1 && event.getType() == UpdateType.FAST) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); else if (size == 2 && event.getType() == UpdateType.FASTER) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); else if (size == 3 && event.getType() == UpdateType.FASTEST) - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation().add(0,0.4,0), 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0.15f + 0.15f * size, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java index 39a8dd93c..80813cbf7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkOvercharge.java @@ -21,6 +21,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -187,7 +188,8 @@ public class PerkOvercharge extends SmashPerk if (arrow.isDead() || !arrow.isValid() || arrow.isOnGround() || arrow.getTicksLived() > 120) arrowIterator.remove(); else - UtilParticle.PlayParticle(ParticleType.RED_DUST, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.RED_DUST, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java index 72a756cc7..c4d4511c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBomb.java @@ -23,7 +23,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePigZombie; import mineplex.core.recharge.Recharge; @@ -149,7 +151,8 @@ public class PerkPigBaconBomb extends SmashPerk public void PigExplode(Iterator pigIterator, Pig pig, Player owner) { //Effect - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, pig.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, pig.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); //Sound pig.getWorld().playSound(pig.getLocation(), Sound.EXPLODE, 0.6f, 2f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java index c9ffc78d5..934899998 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPigBaconBounce.java @@ -23,8 +23,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePigZombie; import mineplex.core.itemstack.ItemStackFactory; @@ -164,7 +166,8 @@ public class PerkPigBaconBounce extends SmashPerk implements IThrown if (event.getItem().getItemStack().getType() == Material.GRILLED_PORK) { UtilPlayer.health(event.getPlayer(), 1); - UtilParticle.PlayParticle(ParticleType.HEART, event.getPlayer().getLocation().add(0, 0.5, 0), 0.2f, 0.2f, 0.2f, 0, 4); + UtilParticle.PlayParticle(ParticleType.HEART, event.getPlayer().getLocation().add(0, 0.5, 0), 0.2f, 0.2f, 0.2f, 0, 4, + ViewDist.LONG, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRewind.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRewind.java index 76bae73ac..4a1f12568 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRewind.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRewind.java @@ -19,7 +19,9 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -82,7 +84,8 @@ public class PerkRewind extends Perk while (UtilMath.offset(current, target) > 0.5) { - UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, current, 0, 1f, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, current, 0, 1f, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); current = current.add(UtilAlg.getTrajectory(current, target).multiply(0.1)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java index 20ce38db4..8e7ee1331 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSheepHoming.java @@ -13,7 +13,9 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -87,7 +89,8 @@ public class PerkSheepHoming extends SmashPerk data.Shooter.getName(), GetName()); } - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Sheep.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Sheep.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); data.Sheep.getWorld().playSound(data.Sheep.getLocation(), Sound.EXPLODE, 2f, 1f); data.Sheep.remove(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java index 376276d17..a0f5a5529 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSlimeRocket.java @@ -22,8 +22,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; @@ -31,7 +33,6 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import nautilus.game.arcade.kit.SmashPerk; public class PerkSlimeRocket extends SmashPerk implements IThrown @@ -155,7 +156,8 @@ public class PerkSlimeRocket extends SmashPerk implements IThrown //Effect player.getWorld().playSound(player.getLocation(), Sound.SLIME_WALK, 0.5f, (float)(0.5 + 1.5*(elapsed/3d))); UtilParticle.PlayParticle(ParticleType.SLIME, player.getLocation().add(0, 1, 0), - (float)(elapsed/6d), (float)(elapsed/6d), (float)(elapsed/6d), 0, (int)(elapsed * 5)); + (float)(elapsed/6d), (float)(elapsed/6d), (float)(elapsed/6d), 0, (int)(elapsed * 5), + ViewDist.LONGER, UtilServer.getPlayers()); } } //Release diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmokebomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmokebomb.java index 7845b2ae7..cabf76c7d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmokebomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSmokebomb.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.minecraft.game.core.condition.Condition; @@ -114,7 +115,8 @@ public class PerkSmokebomb extends Perk //Effects player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 2f, 0.5f); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0f, 0f, 0f, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } @EventHandler(priority = EventPriority.HIGH) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java index 182864956..8a52c396c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSnowTurret.java @@ -24,7 +24,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -78,7 +80,8 @@ public class PerkSnowTurret extends SmashPerk if (snowman.getTicksLived() > 400) { - UtilParticle.PlayParticle(ParticleType.SNOWBALL_POOF, snowman.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12); + UtilParticle.PlayParticle(ParticleType.SNOWBALL_POOF, snowman.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, + ViewDist.LONG, UtilServer.getPlayers()); turretIter.remove(); snowman.remove(); continue; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java index 32670cacb..7f72477ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpidersNest.java @@ -13,7 +13,9 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.SmashPerk; @@ -106,9 +108,11 @@ public class PerkSpidersNest extends SmashPerk damager.setMaxHealth(Math.min(60, damager.getMaxHealth() + diff)); damager.setHealth(damager.getHealth() + diff); - UtilParticle.PlayParticle(ParticleType.HEART, damager.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HEART, damager.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.RED_DUST, damagee.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12); + UtilParticle.PlayParticle(ParticleType.RED_DUST, damagee.getLocation().add(0, 1, 0), 0.4f, 0.4f, 0.4f, 0, 12, + ViewDist.LONG, UtilServer.getPlayers()); if (event.GetCause() == DamageCause.ENTITY_ATTACK) damager.getWorld().playSound(damager.getLocation(), Sound.SPIDER_IDLE, 1.5f, 1f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java index 137d49ba3..fd5f576e7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStormSquid.java @@ -20,7 +20,9 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -70,8 +72,10 @@ public class PerkStormSquid extends SmashPerk return; //Warning - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(0, 0.5, 0), 1f, 1f, 1f, 0.1f, 40); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc.clone().add(0, 0.5, 0), 1f, 1f, 1f, 0.1f, 40, + ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java index f53110ffa..c4eff1e87 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkTNTArrow.java @@ -29,6 +29,7 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -227,7 +228,8 @@ public class PerkTNTArrow extends Perk UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + ".")); } - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, loc, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); loc.getWorld().playSound(loc, Sound.EXPLODE, 2f, 0.75f); } @@ -238,6 +240,7 @@ public class PerkTNTArrow extends Perk return; for (Entity ent : _arrows) - UtilParticle.PlayParticle(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, ent.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java index e664f1d21..d6d70875b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitchPotion.java @@ -20,7 +20,9 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -142,7 +144,8 @@ public class PerkWitchPotion extends SmashPerk continue; } - UtilParticle.PlayParticle(ParticleType.MOB_SPELL, proj.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.MOB_SPELL, proj.getLocation(), 0, 0, 0, 0, 1, + ViewDist.LONGER, UtilServer.getPlayers()); //Super if (!(proj.getShooter() instanceof Player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrowBlind.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrowBlind.java index 0349b6fb5..9569bcad6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrowBlind.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrowBlind.java @@ -12,7 +12,9 @@ import org.bukkit.event.entity.EntityShootBowEvent; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -75,7 +77,8 @@ public class PerkWitherArrowBlind extends Perk Manager.GetCondition().Factory().Blind(GetName(), event.GetDamageeEntity(), null, 4, 0, false, false, false); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); event.SetCancelled("Smoke Arrow"); } @@ -105,7 +108,8 @@ public class PerkWitherArrowBlind extends Perk if (hit) { - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); arrowIterator.remove(); arrow.remove(); continue; @@ -122,7 +126,8 @@ public class PerkWitherArrowBlind extends Perk //Particle else { - UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrows.java index bf21b8aff..07249f73d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherArrows.java @@ -10,10 +10,11 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - import nautilus.game.arcade.kit.Perk; public class PerkWitherArrows extends Perk @@ -81,11 +82,13 @@ public class PerkWitherArrows extends Perk arrow.remove(); arrowIter.remove(); - UtilParticle.PlayParticle(ParticleType.LAVA, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.LAVA, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } else if (arrow.getTicksLived() > 1) { - UtilParticle.PlayParticle(ParticleType.FLAME, arrow.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.FLAME, arrow.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java index e8e02149d..06a5c5b47 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherAttack.java @@ -32,8 +32,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -96,7 +98,8 @@ public class PerkWitherAttack extends Perk WitherSkull skull = (WitherSkull)event.getEntity(); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); explode(skull); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java index f718319c9..f03f12567 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWitherSkull.java @@ -27,7 +27,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -143,7 +145,8 @@ public class PerkWitherSkull extends SmashPerk WitherSkull skull = (WitherSkull)event.getEntity(); - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, skull.getLocation(), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); explode(skull, event.getLocation(), (LivingEntity)skull.getShooter()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java index 0c97eb42b..8615521fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolBomb.java @@ -25,8 +25,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.itemstack.ItemStackFactory; @@ -199,7 +201,8 @@ public class PerkWoolBomb extends Perk implements IThrown data.restore(); //Explode - UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, data.Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); data.Block.getWorld().playSound(data.Block.getLocation(), Sound.EXPLODE, 3f, 0.8f); //Damage diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java index fdac5e907..76b51ee71 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWoolCloud.java @@ -21,8 +21,10 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.recharge.Recharge; @@ -95,7 +97,8 @@ public class PerkWoolCloud extends Perk { Player player = playerIterator.next(); - UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 4); + UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 4, + ViewDist.LONGER, UtilServer.getPlayers()); if (!UtilTime.elapsed(_active.get(player), 200)) continue; @@ -112,8 +115,10 @@ public class PerkWoolCloud extends Perk DamageCause.CUSTOM, 8, true, false, false, player.getName(), GetName()); - UtilParticle.PlayParticle(ParticleType.EXPLODE, other.getLocation(), 0f, 0f, 0f, 0, 1); - UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 10); + UtilParticle.PlayParticle(ParticleType.EXPLODE, other.getLocation(), 0f, 0f, 0f, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.LAVA, player.getLocation(), 0.2f, 0.2f, 0.2f, 0, 10, + ViewDist.MAX, UtilServer.getPlayers()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWraith.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWraith.java index 79c9ea98d..a1f76deda 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWraith.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkWraith.java @@ -15,8 +15,10 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.kit.Perk; @@ -99,7 +101,8 @@ public class PerkWraith extends Perk _steps.put(loc, System.currentTimeMillis()); - UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1); + UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); } } 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())) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 7a7c00480..483462e20 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -53,6 +53,7 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -97,6 +98,12 @@ public class GameFlagManager implements Listener if (damagee != null && Manager.isSpectator(damagee)) { event.SetCancelled("Damagee Spectator"); + + if (damagee.getFireTicks() > 0) + { + damagee.setFireTicks(0); + } + return; } @@ -1121,4 +1128,64 @@ public class GameFlagManager implements Listener event.setCancelled(true); } } + + @EventHandler + public void versionUpdateCheck(UpdateEvent event) + { + if (Manager.GetGame() == null) + return; + + if (!Manager.GetGame().VersionRequire1_8) + return; + + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (!UtilPlayer.is1_8(player)) + versionKick(player); + } + } + + @EventHandler + public void versionJoinCheck(PlayerJoinEvent event) + { + if (Manager.GetGame() == null) + return; + + if (!Manager.GetGame().VersionRequire1_8) + return; + + if (!UtilPlayer.is1_8(event.getPlayer())) + versionKick(event.getPlayer()); + } + + public void versionKick(Player player) + { + if (Manager.GetGame() == null) + return; + + if (Manager.GetGame().GetType().getResourcePackUrl() == null) + return; + + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cGold + C.Bold + Manager.GetGame().GetType().GetName() + " 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 resourceInform(PlayerJoinEvent event) + { + if (Manager.GetGame() == null) + return; + + if (Manager.GetGame().GetType().getResourcePackUrl() == null) + return; + + UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer()); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 46c4b86b6..bd55ff74b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -30,7 +30,7 @@ public class GameGemManager implements Listener { ArcadeManager Manager; - boolean DoubleGem = true; + boolean DoubleGem = false; public GameGemManager(ArcadeManager manager) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index d2a8b950c..0c28bab88 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -159,7 +159,7 @@ public class GamePlayerManager implements Listener @EventHandler public void DisallowCreativeClick(InventoryClickEvent event) { - if (Manager.GetGame() == null || !Manager.GetGame().InProgress() || Manager.GetGameHostManager().isEventServer()) + if (Manager.GetGame() == null || !Manager.GetGame().InProgress() || Manager.GetGameHostManager().isEventServer() || Manager.GetGame().GetType() == GameType.Build) return; if ((event.getInventory().getType() == InventoryType.CREATIVE || event.getInventory().getType() == InventoryType.PLAYER) && !event.getWhoClicked().isOp()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index f2bba323b..a53b9aa5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.itemstack.ItemStackFactory; @@ -128,7 +129,8 @@ public class HolidayManager implements Listener if (type == HolidayType.Halloween) { - UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4); + UtilParticle.PlayParticle(ParticleType.FLAME, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0.06f, 4, + ViewDist.LONG, UtilServer.getPlayers()); if (Math.random() > 0.90) { if (block.getType() == Material.PUMPKIN) @@ -143,7 +145,8 @@ public class HolidayManager implements Listener } else if (type == HolidayType.Easter) { - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, block.getLocation().add(0.5, 0.2, 0.5), 0.3f, 0.2f, 0.3f, 0, 1); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, block.getLocation().add(0.5, 0.2, 0.5), 0.3f, 0.2f, 0.3f, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); if (Math.random() > 0.90) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java index a598d8459..400e46a4a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/MiscManager.java @@ -9,6 +9,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import org.bukkit.Material; @@ -51,7 +52,7 @@ public class MiscManager implements Listener //BoneMeal if (event.getPlayer().getItemInHand().getType() == Material.INK_SACK && event.getPlayer().getItemInHand().getData().getData() == (byte)15) { - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && Manager.GetGame().GetType() != GameType.UHC) + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && Manager.GetGame().GetType() != GameType.UHC && Manager.GetGame().GetType() != GameType.Build) event.setCancelled(true); } else if (Manager.GetGame().GetState() != GameState.Live) @@ -134,4 +135,10 @@ public class MiscManager implements Listener event.setCancelled(true); } } + + @EventHandler + public void disableAchievementGUI(GameStateChangeEvent event) + { + Manager.GetAchievement().setShopEnabled(event.GetState() != GameState.Prepare && event.GetState() != GameState.Live); + } }