Merge pull request #15 in MIN/mineplex from Wizards to master

* commit 'fbafeca1503c782aedf328c9561352595bcf2a46': (27 commits)
  Wizards: Remove block burn flag true
  Wizards: Re-sorted spells
  Wizards: Temporary resource pack
  ResourcePackCode: Fixed the return to hub sender displaying the wrong message. Bad downloads are now sent back to hub.
  Wizards: Current progress
  ResourcePack: Add constructors to GameType for resource pack urls, sorted the enum's by name
  Wizards: Latest changes by Chiss
  Wizards: Added new food Cheese, removed other foods and raised spawn chance of remaining
  Wizards: Changed spell icons for resource pack
  Wizards: Spell levels are now viewable on items in chest as item amount
  Wizards: More changes as per demand.
  Wizards Napalm: Make glazed blocks more common, raise damage
  CustomExplosion: Fixed loop, added max damage
  UtilBlock: Added a method that may or may not tell you the blocks destroyed in an explosion
  Wizards: Balancing
  UtilParticle: Added lore for future reference on colored particles.
  UtilShapes: Fixed getting BlockFace's being bugged and weird sometimes, added another method to get diagonal faces between two diagonals
  CustomExplosion: Added option to limit falling blocks that spawn, removed 'Reason' to prevent CustomDamageEvent from using a mod instead of initialDamage (wtf?)
  Wizards changes
  IcePathData: Compare Material instead of integers
  ...
This commit is contained in:
libraryaddict 2015-04-30 22:45:53 -05:00
commit ec5d25b04b
65 changed files with 6352 additions and 4661 deletions

View File

@ -4,11 +4,16 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; 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.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class UtilBlock public class UtilBlock
@ -304,7 +309,13 @@ public class UtilBlock
return blockList; return blockList;
} }
public static HashMap<Block, Double> getInRadius(Block block, double dR) public static HashMap<Block, Double> getInRadius(Block block, double dR)
{
return getInRadius(block, dR, false);
}
public static HashMap<Block, Double> getInRadius(Block block, double dR, boolean hollow)
{ {
HashMap<Block, Double> blockList = new HashMap<Block, Double>(); HashMap<Block, Double> blockList = new HashMap<Block, Double>();
int iR = (int)dR + 1; int iR = (int)dR + 1;
@ -317,8 +328,10 @@ public class UtilBlock
double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation()); double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation());
if (offset <= dR) if (offset <= dR && !(hollow && offset < dR - 1))
blockList.put(curBlock, 1 - (offset/dR)); {
blockList.put(curBlock, 1 - (offset / dR));
}
} }
return blockList; return blockList;
@ -369,6 +382,74 @@ public class UtilBlock
return block.getRelative(BlockFace.UP); 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<Block> getExplosionBlocks(Location location, float strength, boolean damageBlocksEqually)
{
ArrayList<Block> toExplode = new ArrayList<Block>();
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<Block> getSurrounding(Block block, boolean diagonals) public static ArrayList<Block> getSurrounding(Block block, boolean diagonals)
{ {
ArrayList<Block> blocks = new ArrayList<Block>(); ArrayList<Block> blocks = new ArrayList<Block>();

View File

@ -5,115 +5,213 @@ import java.lang.reflect.Field;
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles; import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class UtilParticle public class UtilParticle
{ {
public enum ParticleType public enum ParticleType
{ {
HUGE_EXPLOSION("hugeexplosion"), ANGRY_VILLAGER("angryVillager"),
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; BLOCK_CRACK("blockcrack_1_0")
{
@Override
public String getParticle(Material type, int data)
{
return "blockcrack_" + type.getId() + "_" + data;
}
},
ParticleType(String particleName) BLOCK_DUST("blockdust_1_0")
{ {
this.particleName = particleName; @Override
} public String getParticle(Material type, int data)
{
return "blockdust_" + type.getId() + "_" + data;
}
},
BUBBLE("bubble"),
CLOUD("cloud"),
CRIT("crit"),
DEPTH_SUSPEND("depthSuspend"),
DRIP_LAVA("dripLava"),
DRIP_WATER("dripWater"),
DROPLET("droplet"),
ENCHANTMENT_TABLE("enchantmenttable"),
EXPLODE("explode"),
FIREWORKS_SPARK("fireworksSpark"),
FLAME("flame"),
FOOTSTEP("footstep"),
HAPPY_VILLAGER("happyVillager"),
HEART("heart"),
HUGE_EXPLOSION("hugeexplosion"),
ICON_CRACK("iconcrack_1_0")
{
@Override
public String getParticle(Material type, int data)
{
return "iconcrack_" + type.getId() + "_" + data;
}
},
INSTANT_SPELL("instantSpell"),
LARGE_EXPLODE("largeexplode"),
LARGE_SMOKE("largesmoke"),
LAVA("lava"),
MAGIC_CRIT("magicCrit"),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
*/
MOB_SPELL("mobSpell"),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
*/
MOB_SPELL_AMBIENT("mobSpellAmbient"),
NOTE("note"),
PORTAL("portal"),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz. Offset y if 0 will default to 1, counter by making it 0.0001
*/
RED_DUST("reddust"),
SLIME("slime"),
SNOW_SHOVEL("snowshovel"),
SNOWBALL_POOF("snowballpoof"),
SPELL("spell"),
SPLASH("splash"),
SUSPEND("suspended"),
TOWN_AURA("townaura"),
WITCH_MAGIC("witchMagic");
public String particleName;
ParticleType(String particleName)
{
this.particleName = particleName;
}
public String getParticle(Material type, int data)
{
return particleName;
}
} }
public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY,
{ float offsetZ, float speed, int count)
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles();
for (Field field : packet.getClass().getDeclaredFields())
{
try
{
field.setAccessible(true);
String fieldName = field.getName();
switch (fieldName)
{
case "a":
field.set(packet, 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)
{ {
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles();
for (Field field : packet.getClass().getDeclaredFields())
{
try
{
field.setAccessible(true);
String fieldName = field.getName();
switch (fieldName)
{
case "a":
field.set(packet, particleName); // Particle name
break;
case "b":
field.setFloat(packet, (float) location.getX()); // Block X
break;
case "c":
field.setFloat(packet, (float) location.getY()); // Block Y
break;
case "d":
field.setFloat(packet, (float) location.getZ()); // Block Z
break;
case "e":
field.setFloat(packet, offsetX); // Random X Offset
break;
case "f":
field.setFloat(packet, offsetY); // Random Y Offset
break;
case "g":
field.setFloat(packet, offsetZ); // Random Z Offset
break;
case "h":
field.setFloat(packet, speed); // Speed/data of particles
break;
case "i":
field.setInt(packet, count); // Amount of particles
break;
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
return packet;
}
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count)
{
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count);
}
public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY,
float offsetZ, float speed, int count)
{
PlayParticle(player, type.particleName, location, offsetX, offsetY, offsetZ, speed, count);
}
public static void PlayParticle(Player player, String particleName, Location location, float offsetX, float offsetY,
float offsetZ, float speed, int count)
{
PacketPlayOutWorldParticles packet = getPacket(particleName, location, offsetX, offsetY, offsetZ, speed, count);
UtilPlayer.sendPacket(player, packet);
}
public static void PlayParticle(String particleName, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count)
{
PacketPlayOutWorldParticles packet = getPacket(particleName, location, offsetX, offsetY, offsetZ, speed, count);
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
//Dont send to players who cannot see it! // Dont send to players who cannot see it!
if (type != ParticleType.FIREWORKS_SPARK && if (!particleName.equals(ParticleType.FIREWORKS_SPARK.particleName)
type != ParticleType.LARGE_EXPLODE && && !particleName.equals(ParticleType.LARGE_EXPLODE.particleName)
type != ParticleType.HUGE_EXPLOSION) && !particleName.equals(ParticleType.HUGE_EXPLOSION.particleName))
{ {
if (UtilMath.offset(player.getLocation(), location) > 24) if (UtilMath.offset(player.getLocation(), location) > 24)
{ {
@ -121,7 +219,7 @@ public class UtilParticle
} }
} }
PlayParticle(player, type, location, offsetX, offsetY, offsetZ, speed, count); UtilPlayer.sendPacket(player, packet);
} }
} }
} }

View File

@ -9,181 +9,237 @@ import org.bukkit.util.Vector;
public class UtilShapes public class UtilShapes
{ {
private final static BlockFace[] diagonalFaces = private final static BlockFace[] diagonalFaces =
{ {
BlockFace.SOUTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_EAST, BlockFace.SOUTH_EAST BlockFace.SOUTH_WEST, BlockFace.NORTH_WEST, BlockFace.NORTH_EAST, BlockFace.SOUTH_EAST
}; };
private final static BlockFace[] radial = private final static BlockFace[] radial =
{ {
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
}; };
private final static BlockFace[] squareFaces = private final static BlockFace[] squareFaces =
{ {
BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST BlockFace.SOUTH, BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST
}; };
public static ArrayList<Location> getCircle(Location loc, double radius, boolean hollow) public static ArrayList<Location> getCircle(Location loc, double radius, boolean hollow)
{ {
return getCircleBlocks(loc, radius, 0, hollow, false); return getCircleBlocks(loc, radius, 0, hollow, false);
} }
public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow) public static ArrayList<Location> getSphereBlocks(Location loc, double radius, double height, boolean hollow)
{ {
return getCircleBlocks(loc, radius, height, hollow, true); return getCircleBlocks(loc, radius, height, hollow, true);
} }
private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere) private static ArrayList<Location> getCircleBlocks(Location loc, double radius, double height, boolean hollow, boolean sphere)
{ {
ArrayList<Location> circleblocks = new ArrayList<Location>(); ArrayList<Location> circleblocks = new ArrayList<Location>();
double cx = loc.getBlockX(); double cx = loc.getBlockX();
double cy = loc.getBlockY(); double cy = loc.getBlockY();
double cz = loc.getBlockZ(); double cz = loc.getBlockZ();
for (double y = (sphere ? cy - radius : cy); y < (sphere ? cy + radius : cy + height + 1); y++) 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 x = cx - radius; x <= cx + radius; x++)
{ {
for (double z = cz - radius; z <= cz + radius; z++) 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); 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))) if (dist < radius * radius && !(hollow && dist < (radius - 1) * (radius - 1)))
{ {
Location l = new Location(loc.getWorld(), x, y, z); Location l = new Location(loc.getWorld(), x, y, z);
circleblocks.add(l); circleblocks.add(l);
} }
} }
} }
} }
return circleblocks; return circleblocks;
} }
/** /**
* Gets the block at the exact corners, will return a diagonal. * Gets the block at the exact corners, will return a diagonal.
* *
* @Yeah ik this code sucks. * @Yeah ik this code sucks.
*/ */
public static BlockFace[] getCornerBlockFaces(Block b, BlockFace facing) public static BlockFace[] getCornerBlockFaces(Block b, BlockFace facing)
{ {
BlockFace left = null; BlockFace left = null;
BlockFace right = null; BlockFace right = null;
for (int i = 0; i < radial.length; i++) for (int i = 0; i < radial.length; i++)
{ {
if (radial[i] == facing) if (radial[i] == facing)
{ {
int high = i + 2; int high = i + 2;
if (high >= radial.length) if (high >= radial.length)
high = high - radial.length; high = high - radial.length;
int low = i - 2; int low = i - 2;
if (low < 0) if (low < 0)
low = radial.length + low; low = radial.length + low;
left = radial[low]; left = radial[low];
right = radial[high]; right = radial[high];
return new BlockFace[] return new BlockFace[]
{ {
left, right left, right
}; };
} }
} }
return null; return null;
} }
public static Block[] getCornerBlocks(Block b, BlockFace facing) public static Block[] getCornerBlocks(Block b, BlockFace facing)
{ {
BlockFace[] faces = getSideBlockFaces(b, facing); BlockFace[] faces = getSideBlockFaces(facing);
return new Block[] return new Block[]
{ {
b.getRelative(faces[0]), b.getRelative(faces[1]) b.getRelative(faces[0]), b.getRelative(faces[1])
}; };
} }
public static BlockFace getFacing(float yaw) public static BlockFace getFacing(float yaw)
{ {
return radial[Math.round(yaw / 45f) & 0x7]; return radial[Math.round(yaw / 45f) & 0x7];
} }
public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint, public static ArrayList<Location> getLinesDistancedPoints(Location startingPoint, Location endingPoint,
double distanceBetweenParticles) double distanceBetweenParticles)
{ {
return getLinesLimitedPoints(startingPoint, endingPoint, return getLinesLimitedPoints(startingPoint, endingPoint,
(int) Math.ceil(startingPoint.distance(endingPoint) / distanceBetweenParticles)); (int) Math.ceil(startingPoint.distance(endingPoint) / distanceBetweenParticles));
} }
public static ArrayList<Location> getLinesLimitedPoints(Location startingPoint, Location endingPoint, int amountOfPoints) public static ArrayList<Location> getLinesLimitedPoints(Location startingPoint, Location endingPoint, int amountOfPoints)
{ {
startingPoint = startingPoint.clone(); startingPoint = startingPoint.clone();
Vector vector = endingPoint.toVector().subtract(startingPoint.toVector()); Vector vector = endingPoint.toVector().subtract(startingPoint.toVector());
vector.normalize(); vector.normalize();
vector.multiply(startingPoint.distance(endingPoint) / (amountOfPoints + 1D)); vector.multiply(startingPoint.distance(endingPoint) / (amountOfPoints + 1D));
ArrayList<Location> locs = new ArrayList<Location>(); ArrayList<Location> locs = new ArrayList<Location>();
for (int i = 0; i < amountOfPoints; i++) for (int i = 0; i < amountOfPoints; i++)
{ {
locs.add(startingPoint.add(vector).clone()); locs.add(startingPoint.add(vector).clone());
} }
return locs; return locs;
} }
public static ArrayList<Location> getPointsInCircle(Location center, int pointsAmount, double circleRadius) public static ArrayList<Location> getPointsInCircle(Location center, int pointsAmount, double circleRadius)
{ {
ArrayList<Location> locs = new ArrayList<Location>(); ArrayList<Location> locs = new ArrayList<Location>();
for (int i = 0; i < pointsAmount; i++) for (int i = 0; i < pointsAmount; i++)
{ {
double angle = ((2 * Math.PI) / pointsAmount) * i; double angle = ((2 * Math.PI) / pointsAmount) * i;
double x = circleRadius * Math.cos(angle); double x = circleRadius * Math.cos(angle);
double z = circleRadius * Math.sin(angle); double z = circleRadius * Math.sin(angle);
Location loc = center.clone().add(x, 0, z); Location loc = center.clone().add(x, 0, z);
locs.add(loc); locs.add(loc);
} }
return locs; return locs;
} }
public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius) public static ArrayList<Location> getDistancedCircle(Location center, double pointsDistance, double circleRadius)
{ {
return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius); return getPointsInCircle(center, (int) ((circleRadius * Math.PI * 2) / pointsDistance), circleRadius);
} }
/** /**
* Returns a north/west/east/south block, never a diagonal. * Returns a north/west/east/south block, never a diagonal.
*/ */
public static BlockFace[] getSideBlockFaces(Block b, BlockFace facing) public static BlockFace[] getSideBlockFaces(BlockFace facing)
{ {
BlockFace left = null; return getSideBlockFaces(facing, true);
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;
}
public static Block[] getSideBlocks(Block b, BlockFace facing) public static BlockFace[] getSideBlockFaces(BlockFace facing, boolean allowDiagonal)
{ {
BlockFace[] faces = getSideBlockFaces(b, facing);
return new Block[] int[][] facesXZ;
{ allowDiagonal = !allowDiagonal && (facing.getModX() != 0 && facing.getModZ() != 0);
b.getRelative(faces[0]), b.getRelative(faces[1])
}; 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<Block> getDiagonalBlocks(Block block, BlockFace facing, int blockWidth)
{
ArrayList<Block> blocks = new ArrayList<Block>();
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])
};
}
} }

View File

@ -25,7 +25,6 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -303,6 +302,11 @@ public class Explosion extends MiniPlugin
} }
public void BlockExplosion(Collection<Block> blockSet, Location mid, boolean onlyAbove) public void BlockExplosion(Collection<Block> blockSet, Location mid, boolean onlyAbove)
{
BlockExplosion(blockSet, mid, onlyAbove, true);
}
public void BlockExplosion(Collection<Block> blockSet, Location mid, boolean onlyAbove, boolean removeBlock)
{ {
if (blockSet.isEmpty()) if (blockSet.isEmpty())
return; return;
@ -320,7 +324,10 @@ public class Explosion extends MiniPlugin
blocks.put(cur, new AbstractMap.SimpleEntry<Integer, Byte>(cur.getTypeId(), cur.getData())); blocks.put(cur, new AbstractMap.SimpleEntry<Integer, Byte>(cur.getTypeId(), cur.getData()));
cur.setType(Material.AIR); if (removeBlock)
{
cur.setType(Material.AIR);
}
} }
//DELAY //DELAY

View File

@ -4,37 +4,32 @@ import java.util.ArrayList;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
public class ChestLoot public class ChestLoot
{ {
private int _totalLoot;
private ArrayList<RandomItem> _randomItems = new ArrayList<RandomItem>(); private ArrayList<RandomItem> _randomItems = new ArrayList<RandomItem>();
private int _totalLoot;
private boolean _unbreakableLoot; private boolean _unbreakableLoot;
public ChestLoot(boolean unbreakableLoot)
{
_unbreakableLoot = unbreakableLoot;
}
public ChestLoot() public ChestLoot()
{ {
this(false); this(false);
} }
public ChestLoot(boolean unbreakableLoot)
{
_unbreakableLoot = unbreakableLoot;
}
public void cloneLoot(ChestLoot loot) public void cloneLoot(ChestLoot loot)
{ {
_totalLoot += loot._totalLoot; _totalLoot += loot._totalLoot;
_randomItems.addAll(loot._randomItems); _randomItems.addAll(loot._randomItems);
} }
public void registerLoot(RandomItem item)
{
_totalLoot += item.getAmount();
_randomItems.add(item);
}
public ItemStack getLoot() public ItemStack getLoot()
{ {
int no = UtilMath.r(_totalLoot); int no = UtilMath.r(_totalLoot);
@ -60,4 +55,30 @@ public class ChestLoot
return null; 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);
}
} }

View File

@ -11,6 +11,11 @@ public class RandomItem
private ItemStack _item; private ItemStack _item;
private int _min, _max; 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) public RandomItem(ItemStack item, int amount, int minStackSize, int maxStackSize)
{ {
_amount = amount; _amount = amount;
@ -19,9 +24,9 @@ public class RandomItem
_max = maxStackSize; _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) public RandomItem(Material material, int amount, int minStackSize, int maxStackSize)
@ -32,9 +37,9 @@ public class RandomItem
_max = maxStackSize; _max = maxStackSize;
} }
public RandomItem(Material material, int amount) public int getAmount()
{ {
this(material, amount, 1, 1); return _amount;
} }
public ItemStack getItemStack() public ItemStack getItemStack()
@ -43,9 +48,4 @@ public class RandomItem
return _item; return _item;
} }
public int getAmount()
{
return _amount;
}
} }

View File

@ -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");
}
}
}
}
}

View File

@ -0,0 +1,9 @@
package mineplex.core.resourcepack;
import org.bukkit.entity.Player;
public interface ResUnloadCheck
{
public boolean canSendUnload(Player player);
}

View File

@ -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;
}
}

View File

@ -36,6 +36,8 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish; import mineplex.core.punish.Punish;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.resourcepack.ResUnloadCheck;
import mineplex.core.resourcepack.ResPackManager;
import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.spawn.Spawn; import mineplex.core.spawn.Spawn;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
@ -127,6 +129,13 @@ public class Hub extends JavaPlugin implements IRelation
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
new CustomTagFix(this, packetHandler); new CustomTagFix(this, packetHandler);
new TablistFix(this); new TablistFix(this);
new ResPackManager(new ResUnloadCheck()
{
public boolean canSendUnload(Player player)
{
return true;
}
});
//new Replay(this, packetHandler); //new Replay(this, packetHandler);
new PersonalServerManager(this, clientManager); new PersonalServerManager(this, clientManager);

View File

@ -1,6 +1,8 @@
package mineplex.minecraft.game.core.explosion; package mineplex.minecraft.game.core.explosion;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -45,8 +47,15 @@ public class CustomExplosion extends Explosion
private boolean _createFire; private boolean _createFire;
private boolean _ignoreRate = true; private boolean _ignoreRate = true;
private float _blockExplosionSize; 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); super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize);
@ -54,6 +63,25 @@ public class CustomExplosion extends Explosion
_manager = manager; _manager = manager;
_damageReason = deathCause; _damageReason = deathCause;
_blockExplosionSize = explosionSize; _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) public CustomExplosion setBlockExplosionSize(float explosionSize)
@ -70,6 +98,20 @@ public class CustomExplosion extends Explosion
return this; 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) public CustomExplosion setDamageBlocks(boolean damageBlocks)
{ {
b = damageBlocks; b = damageBlocks;
@ -204,9 +246,21 @@ public class CustomExplosion extends Explosion
d0 /= d8; d0 /= d8;
d1 /= d8; d1 /= d8;
d2 /= 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 d9 = this._world.a(vec3d, entity.boundingBox);
double d10 = (1.0D - d7) * d9; 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) if (entity.getBukkitEntity() instanceof LivingEntity)
{ {
@ -282,6 +336,27 @@ public class CustomExplosion extends Explosion
return; return;
} }
if (_fallingBlockExplosion)
{
Collection<org.bukkit.block.Block> blocks = event.GetBlocks();
if (blocks.size() > _maxFallingBlocks)
{
blocks = new ArrayList<org.bukkit.block.Block>(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(); Iterator iterator = this.blocks.iterator();
while (iterator.hasNext()) while (iterator.hasNext())

View File

@ -3,12 +3,15 @@ package nautilus.game.arcade;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -30,6 +33,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.base.Objects;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
@ -39,11 +44,12 @@ import mineplex.core.chat.Chat;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; 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.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature; import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
@ -55,12 +61,19 @@ import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.movement.Movement; import mineplex.core.movement.Movement;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler; 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.party.PartyManager;
import mineplex.core.pet.PetManager; import mineplex.core.pet.PetManager;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; 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.RewardRarity;
import mineplex.core.reward.rewards.PetReward; import mineplex.core.reward.rewards.PetReward;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
@ -68,7 +81,6 @@ import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport; import mineplex.core.teleport.Teleport;
import mineplex.core.timing.TimingManager; import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Class.ClassManager;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
@ -169,6 +181,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private PacketHandler _packetHandler; private PacketHandler _packetHandler;
private IPacketHandler _resourcePacketHandler;
private String _resourcePackUrl;
private boolean _resourcePackRequired;
private NautHashMap<String, EnumResourcePackStatus> _resourcePackUsers = new NautHashMap<String, EnumResourcePackStatus>();
private NautHashMap<String, Long> _resourcePackNoResponse = new NautHashMap<String, Long>();
// Observers // Observers
private HashSet<Player> _specList = new HashSet<Player>(); private HashSet<Player> _specList = new HashSet<Player>();
@ -301,6 +318,76 @@ public class ArcadeManager extends MiniPlugin implements IRelation
} }
}, 80L); }, 80L);
} }
_resourcePacketHandler = new IPacketHandler()
{
@Override
public void handle(PacketInfo packetInfo)
{
if (_resourcePackUrl != null && packetInfo.getPacket() instanceof PacketPlayResourcePackStatus)
{
final Player player = packetInfo.getPlayer();
final EnumResourcePackStatus response = ((PacketPlayResourcePackStatus) packetInfo.getPacket())
.getResourcePackStatus();
Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
{
@Override
public void run()
{
if (_resourcePackRequired)
{
if (response == EnumResourcePackStatus.ACCEPTED)
{
_resourcePackNoResponse.remove(player.getName());
}
else if (response == EnumResourcePackStatus.DECLINED)
{
_resourcePackNoResponse.remove(player.getName());
returnHubNoResPack(player, "Failed to download resource pack!");
}
else if (response == EnumResourcePackStatus.FAILED_DOWNLOAD)
{
_resourcePackNoResponse.remove(player.getName());
returnHubNoResPack(player, "Failed to download resource pack!");
return;
}
}
if (response == EnumResourcePackStatus.ACCEPTED || response == EnumResourcePackStatus.LOADED)
{
_resourcePackUsers.put(player.getName(), response);
}
else
{
_resourcePackUsers.remove(player.getName());
}
}
});
}
}
};
new ResPackManager(new ResUnloadCheck()
{
public boolean canSendUnload(Player player)
{
if (_resourcePackUsers.containsKey(player.getName()))
{
return false;
}
return true;
}
});
getPacketHandler().addPacketHandler(_resourcePacketHandler);
} }
@Override @Override
@ -1225,4 +1312,129 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return UtilPlayer.isSpectator((Player)player); return UtilPlayer.isSpectator((Player)player);
return false; return false;
} }
@EventHandler
public void onSecond(UpdateEvent event)
{
Iterator<Entry<String, Long>> itel = _resourcePackNoResponse.entrySet().iterator();
while (itel.hasNext())
{
Entry<String, Long> entry = itel.next();
if (UtilTime.elapsed(entry.getValue(), 10000))
{
Player player = Bukkit.getPlayerExact(entry.getKey());
if (player != null)
{
// Send it again, enforce it!
_resourcePackNoResponse.put(player.getName(), System.currentTimeMillis());
player.setResourcePack(_resourcePackUrl);
}
else
{
itel.remove();
}
}
}
}
@EventHandler
public void ResourcePackQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
EnumResourcePackStatus status = _resourcePackUsers.get(player.getName());
if (status == EnumResourcePackStatus.ACCEPTED || status == EnumResourcePackStatus.LOADED)
{
new RedisUnloadResPack(player.getName()).publish();
_resourcePackUsers.remove(player.getName());
}
}
@EventHandler
public void outdatedVersion(GameStateChangeEvent event)
{
if (!_resourcePackRequired)
return;
for (Player player : UtilServer.getPlayers())
{
if (!UtilPlayer.is1_8(player))
returnHubNoResPack(player, "You need to be using 1.8 to play " + GetGame().GetName() + "!");
}
}
private void returnHubNoResPack(Player player, String message)
{
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cGold + C.Bold + message);
UtilPlayer.message(player, " ");
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
GetPortal().sendPlayerToServer(player, "Lobby");
}
@EventHandler
public void ResourcePackJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (!UtilPlayer.is1_8(player) && _resourcePackRequired)
{
returnHubNoResPack(player, "You need to be using 1.8 to play " + GetGame().GetName() + "!");
return;
}
if (_resourcePackUrl != null)
{
if (_resourcePackRequired)
{
_resourcePackNoResponse.put(player.getName(), System.currentTimeMillis());
}
_resourcePackUsers.put(player.getName(), null);
player.setResourcePack(_resourcePackUrl);
}
}
public void setResourcePack(String resourcePack, boolean forceResourcePack)
{
if (!Objects.equal(resourcePack, _resourcePackUrl) || forceResourcePack != _resourcePackRequired)
{
_resourcePackNoResponse.clear();
_resourcePackUsers.clear();
_resourcePackUrl = resourcePack == null || resourcePack.isEmpty() ? null : resourcePack;
_resourcePackRequired = forceResourcePack;
if (_resourcePackUrl == null || _resourcePackUrl.isEmpty())
{
_resourcePackRequired = false;
for (Player player : Bukkit.getOnlinePlayers())
{
player.setResourcePack("http://www.chivebox.com/file/c/empty.zip");
}
}
else
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (_resourcePackRequired)
{
_resourcePackNoResponse.put(player.getName(), System.currentTimeMillis());
}
_resourcePackUsers.put(player.getName(), null);
player.setResourcePack(_resourcePackUrl);
}
}
}
}
} }

View File

@ -8,11 +8,10 @@ public enum GameType
BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1), BaconBrawl("Bacon Brawl", Material.PORK, (byte)0, GameCategory.ARCADE, 1),
Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.ARCADE, 2), Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.ARCADE, 2),
Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3),
CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4), 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), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6),
ChampionsMOBA("Champions MOBA", "Champions", Material.SKULL_ITEM, (byte)0, GameCategory.CHAMPIONS, 7), 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), Christmas("Christmas Chaos", Material.SNOW_BALL, (byte)0, GameCategory.CLASSICS, 8),
DeathTag("Death Tag", Material.SKULL_ITEM, (byte)0, GameCategory.ARCADE, 9), DeathTag("Death Tag", Material.SKULL_ITEM, (byte)0, GameCategory.ARCADE, 9),
DragonEscape("Dragon Escape", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 10), DragonEscape("Dragon Escape", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 10),
@ -27,12 +26,10 @@ public enum GameType
Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19), Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19),
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
Horse("Horseback", Material.IRON_BARDING, (byte)0, GameCategory.ARCADE, 21), 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), Micro("Micro Battle", Material.LAVA_BUCKET, (byte)0, GameCategory.ARCADE, 24),
MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27),
MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CLASSICS, 25), MineStrike("MineStrike", Material.TNT, (byte)0, GameCategory.CLASSICS, 25),
MineWare("MineWare", Material.PAPER, (byte)0, GameCategory.ARCADE, 26), MineWare("MineWare", Material.PAPER, (byte)0, GameCategory.ARCADE, 26),
MilkCow("Milk the Cow", Material.MILK_BUCKET, (byte)0, GameCategory.ARCADE, 27),
Paintball("Super Paintball", Material.ENDER_PEARL, (byte)0, GameCategory.ARCADE, 28), Paintball("Super Paintball", Material.ENDER_PEARL, (byte)0, GameCategory.ARCADE, 28),
Quiver("One in the Quiver", Material.ARROW, (byte)0, GameCategory.ARCADE, 29), 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), QuiverTeams("One in the Quiver Teams", Material.ARROW, (byte)0, GameCategory.ARCADE, 30),
@ -40,22 +37,23 @@ public enum GameType
SearchAndDestroy("Search and Destroy", Material.TNT, (byte)0, GameCategory.SURVIVAL, 32), SearchAndDestroy("Search and Destroy", Material.TNT, (byte)0, GameCategory.SURVIVAL, 32),
Sheep("Sheep Quest", Material.WOOL, (byte)4, GameCategory.ARCADE, 33), Sheep("Sheep Quest", Material.WOOL, (byte)4, GameCategory.ARCADE, 33),
Smash("Super Smash Mobs", Material.SKULL_ITEM, (byte)4, GameCategory.CLASSICS, 34), 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), 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), Snake("Snake", Material.WOOL, (byte)0, GameCategory.ARCADE, 37),
SneakyAssassins("Sneaky Assassins", Material.INK_SACK, (byte)0, GameCategory.ARCADE, 38), SneakyAssassins("Sneaky Assassins", Material.INK_SACK, (byte)0, GameCategory.ARCADE, 38),
SnowFight("Snow Fight", Material.SNOW_BALL, (byte)0, GameCategory.ARCADE, 39), SnowFight("Snow Fight", Material.SNOW_BALL, (byte)0, GameCategory.ARCADE, 39),
Spleef("Super Spleef", Material.IRON_SPADE, (byte)0, GameCategory.ARCADE, 40), Spleef("Super Spleef", Material.IRON_SPADE, (byte)0, GameCategory.ARCADE, 40),
SpleefTeams("Super Spleef Teams", Material.IRON_SPADE, (byte)0, GameCategory.ARCADE, 41), 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), 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), Tug("Tug of Wool", Material.WHEAT, (byte)0, GameCategory.ARCADE, 44),
TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45), TurfWars("Turf Wars", Material.STAINED_CLAY, (byte)14, GameCategory.ARCADE, 45),
UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46), UHC("Ultra Hardcore", Material.GOLDEN_APPLE, (byte)0, GameCategory.SURVIVAL, 46),
WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47), WitherAssault("Wither Assault", Material.SKULL_ITEM, (byte)1, GameCategory.ARCADE, 47),
Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48), Wizards("Wizards", Material.BLAZE_ROD, (byte)0, GameCategory.SURVIVAL, 48, "https://www.dropbox.com/s/qrtc9c91ktvmf3q/WizPack.zip?dl=1", true),
ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49), ZombieSurvival("Zombie Survival", Material.SKULL_ITEM, (byte)2, GameCategory.SURVIVAL, 49),
Build("Master Builders", Material.BRICK, (byte)0, GameCategory.CLASSICS, 50), Build("Master Builders", Material.BRICK, (byte)0, GameCategory.CLASSICS, 50),
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
@ -65,6 +63,8 @@ public enum GameType
Material _mat; Material _mat;
byte _data; byte _data;
GameCategory _gameCategory; GameCategory _gameCategory;
boolean _enforceResourcePack;
String _resourcePack;
private int _gameId; // Unique identifying id for this gamemode (used for statistics) private int _gameId; // Unique identifying id for this gamemode (used for statistics)
public int getGameId() { return _gameId; } public int getGameId() { return _gameId; }
@ -74,7 +74,17 @@ public enum GameType
this(name, name, mat, data, gameCategory, gameId); 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) 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; _name = name;
_lobbyName = lobbyName; _lobbyName = lobbyName;
@ -82,6 +92,18 @@ public enum GameType
_data = data; _data = data;
_gameCategory = gameCategory; _gameCategory = gameCategory;
_gameId = gameId; _gameId = gameId;
_resourcePack = resourcePackUrl;
_enforceResourcePack = enforceResourcePack;
}
public boolean isEnforceResourcePack()
{
return _enforceResourcePack;
}
public String getResourcePackUrl()
{
return _resourcePack;
} }
public String GetName() public String GetName()

View File

@ -317,6 +317,8 @@ public abstract class Game implements Listener
); );
} }
Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack());
System.out.println("Loading " + GetName() + "..."); System.out.println("Loading " + GetName() + "...");
} }

View File

@ -1844,129 +1844,129 @@ public class SurvivalGames extends SoloGame
private void setupLoot() private void setupLoot()
{ {
// Food // Food
_baseLoot.registerLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3)); _baseLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 3));
_baseLoot.registerLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.CARROT_ITEM, 30, 1, 3)); _baseLoot.addLoot(new RandomItem(Material.CARROT_ITEM, 30, 1, 3));
_baseLoot.registerLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1)); _baseLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1));
_baseLoot.registerLoot(new RandomItem(Material.WHEAT, 30, 1, 6)); _baseLoot.addLoot(new RandomItem(Material.WHEAT, 30, 1, 6));
_baseLoot.registerLoot(new RandomItem(Material.APPLE, 30, 1, 4)); _baseLoot.addLoot(new RandomItem(Material.APPLE, 30, 1, 4));
_baseLoot.registerLoot(new RandomItem(Material.PORK, 30, 1, 4)); _baseLoot.addLoot(new RandomItem(Material.PORK, 30, 1, 4));
_baseLoot.registerLoot(new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6)); _baseLoot.addLoot(new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6));
// Weapons // Weapons
_baseLoot.registerLoot(new RandomItem(Material.WOOD_AXE, 80)); _baseLoot.addLoot(new RandomItem(Material.WOOD_AXE, 80));
_baseLoot.registerLoot(new RandomItem(Material.WOOD_SWORD, 70)); _baseLoot.addLoot(new RandomItem(Material.WOOD_SWORD, 70));
_baseLoot.registerLoot(new RandomItem(Material.STONE_AXE, 60)); _baseLoot.addLoot(new RandomItem(Material.STONE_AXE, 60));
_baseLoot.registerLoot(new RandomItem(Material.STONE_SWORD, 30)); _baseLoot.addLoot(new RandomItem(Material.STONE_SWORD, 30));
// Leather armor // Leather armor
_baseLoot.registerLoot(new RandomItem(Material.LEATHER_BOOTS, 30)); _baseLoot.addLoot(new RandomItem(Material.LEATHER_BOOTS, 30));
_baseLoot.registerLoot(new RandomItem(Material.LEATHER_CHESTPLATE, 30)); _baseLoot.addLoot(new RandomItem(Material.LEATHER_CHESTPLATE, 30));
_baseLoot.registerLoot(new RandomItem(Material.LEATHER_HELMET, 30)); _baseLoot.addLoot(new RandomItem(Material.LEATHER_HELMET, 30));
_baseLoot.registerLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30)); _baseLoot.addLoot(new RandomItem(Material.LEATHER_LEGGINGS, 30));
// Gold armor // Gold armor
_baseLoot.registerLoot(new RandomItem(Material.GOLD_BOOTS, 25)); _baseLoot.addLoot(new RandomItem(Material.GOLD_BOOTS, 25));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25)); _baseLoot.addLoot(new RandomItem(Material.GOLD_CHESTPLATE, 25));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_HELMET, 25)); _baseLoot.addLoot(new RandomItem(Material.GOLD_HELMET, 25));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_LEGGINGS, 25)); _baseLoot.addLoot(new RandomItem(Material.GOLD_LEGGINGS, 25));
// Chain armor // Chain armor
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20)); _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_BOOTS, 20));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20)); _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_CHESTPLATE, 20));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20)); _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_HELMET, 20));
_baseLoot.registerLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20)); _baseLoot.addLoot(new RandomItem(Material.CHAINMAIL_LEGGINGS, 20));
// Throwable // Throwable
_baseLoot.registerLoot(new RandomItem(Material.FISHING_ROD, 30)); _baseLoot.addLoot(new RandomItem(Material.FISHING_ROD, 30));
_baseLoot.registerLoot(new RandomItem(Material.BOW, 20)); _baseLoot.addLoot(new RandomItem(Material.BOW, 20));
_baseLoot.registerLoot(new RandomItem(Material.ARROW, 20, 1, 3)); _baseLoot.addLoot(new RandomItem(Material.ARROW, 20, 1, 3));
_baseLoot.registerLoot(new RandomItem(Material.SNOW_BALL, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.SNOW_BALL, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.EGG, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.EGG, 30, 1, 2));
// Misc // Misc
_baseLoot.registerLoot(new RandomItem(Material.EXP_BOTTLE, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.EXP_BOTTLE, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.COMPASS, 20)); _baseLoot.addLoot(new RandomItem(Material.COMPASS, 20));
_baseLoot.registerLoot(new RandomItem(Material.STICK, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.STICK, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.BOAT, 15)); _baseLoot.addLoot(new RandomItem(Material.BOAT, 15));
_baseLoot.registerLoot(new RandomItem(Material.FLINT, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.FLINT, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.FEATHER, 30, 1, 2)); _baseLoot.addLoot(new RandomItem(Material.FEATHER, 30, 1, 2));
_baseLoot.registerLoot(new RandomItem(Material.GOLD_INGOT, 20)); _baseLoot.addLoot(new RandomItem(Material.GOLD_INGOT, 20));
_baseLoot.registerLoot(new RandomItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT")), 15)); _baseLoot.addLoot(new RandomItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwing TNT")), 15));
_spawnLoot.registerLoot(new RandomItem(Material.MUSHROOM_SOUP, 15)); _spawnLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 15));
_spawnLoot.cloneLoot(_baseLoot); _spawnLoot.cloneLoot(_baseLoot);
// Food // Food
_spawnLoot.registerLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5)); _spawnLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 30, 1, 5));
_spawnLoot.registerLoot(new RandomItem(Material.CAKE, 30)); _spawnLoot.addLoot(new RandomItem(Material.CAKE, 30));
_spawnLoot.registerLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1)); _spawnLoot.addLoot(new RandomItem(Material.MUSHROOM_SOUP, 30, 1, 1));
_spawnLoot.registerLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3)); _spawnLoot.addLoot(new RandomItem(Material.COOKED_BEEF, 30, 1, 3));
_spawnLoot.registerLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3)); _spawnLoot.addLoot(new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3));
_spawnLoot.registerLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6)); _spawnLoot.addLoot(new RandomItem(Material.COOKED_FISH, 30, 1, 6));
_spawnLoot.registerLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3)); _spawnLoot.addLoot(new RandomItem(Material.GRILLED_PORK, 30, 1, 3));
_spawnLoot.registerLoot(new RandomItem(Material.COOKIE, 30)); _spawnLoot.addLoot(new RandomItem(Material.COOKIE, 30));
_spawnLoot.registerLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3)); _spawnLoot.addLoot(new RandomItem(Material.PUMPKIN_PIE, 30, 1, 3));
_spawnLoot.registerLoot(new RandomItem(Material.APPLE, 30, 2, 6)); _spawnLoot.addLoot(new RandomItem(Material.APPLE, 30, 2, 6));
// Loot for chests in spawn // Loot for chests in spawn
// Weaponry and ores // Weaponry and ores
_spawnLoot.registerLoot(new RandomItem(Material.STONE_SWORD, 30)); _spawnLoot.addLoot(new RandomItem(Material.STONE_SWORD, 30));
_spawnLoot.registerLoot(new RandomItem(Material.IRON_AXE, 30)); _spawnLoot.addLoot(new RandomItem(Material.IRON_AXE, 30));
_spawnLoot.registerLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2)); _spawnLoot.addLoot(new RandomItem(Material.IRON_INGOT, 30, 1, 2));
_spawnLoot.registerLoot(new RandomItem(Material.DIAMOND, 30)); _spawnLoot.addLoot(new RandomItem(Material.DIAMOND, 30));
// Iron gear // Iron gear
_spawnLoot.registerLoot(new RandomItem(Material.IRON_BOOTS, 30)); _spawnLoot.addLoot(new RandomItem(Material.IRON_BOOTS, 30));
_spawnLoot.registerLoot(new RandomItem(Material.IRON_CHESTPLATE, 30)); _spawnLoot.addLoot(new RandomItem(Material.IRON_CHESTPLATE, 30));
_spawnLoot.registerLoot(new RandomItem(Material.IRON_HELMET, 30)); _spawnLoot.addLoot(new RandomItem(Material.IRON_HELMET, 30));
_spawnLoot.registerLoot(new RandomItem(Material.IRON_LEGGINGS, 30)); _spawnLoot.addLoot(new RandomItem(Material.IRON_LEGGINGS, 30));
// Supply crate loot // Supply crate loot
// Diamond gear // Diamond gear
_crateLoot.registerLoot(new RandomItem(Material.DIAMOND_HELMET, 10)); _crateLoot.addLoot(new RandomItem(Material.DIAMOND_HELMET, 10));
_crateLoot.registerLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6)); _crateLoot.addLoot(new RandomItem(Material.DIAMOND_CHESTPLATE, 6));
_crateLoot.registerLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8)); _crateLoot.addLoot(new RandomItem(Material.DIAMOND_LEGGINGS, 8));
_crateLoot.registerLoot(new RandomItem(Material.DIAMOND_BOOTS, 10)); _crateLoot.addLoot(new RandomItem(Material.DIAMOND_BOOTS, 10));
// Iron gear // Iron gear
_crateLoot.registerLoot(new RandomItem(Material.IRON_HELMET, 30)); _crateLoot.addLoot(new RandomItem(Material.IRON_HELMET, 30));
_crateLoot.registerLoot(new RandomItem(Material.IRON_CHESTPLATE, 24)); _crateLoot.addLoot(new RandomItem(Material.IRON_CHESTPLATE, 24));
_crateLoot.registerLoot(new RandomItem(Material.IRON_LEGGINGS, 27)); _crateLoot.addLoot(new RandomItem(Material.IRON_LEGGINGS, 27));
_crateLoot.registerLoot(new RandomItem(Material.IRON_BOOTS, 30)); _crateLoot.addLoot(new RandomItem(Material.IRON_BOOTS, 30));
// Weapons // Weapons
_crateLoot.registerLoot(new RandomItem(Material.IRON_SWORD, 24)); _crateLoot.addLoot(new RandomItem(Material.IRON_SWORD, 24));
_crateLoot.registerLoot(new RandomItem(Material.DIAMOND_SWORD, 8)); _crateLoot.addLoot(new RandomItem(Material.DIAMOND_SWORD, 8));
_crateLoot.registerLoot(new RandomItem(Material.DIAMOND_AXE, 16)); _crateLoot.addLoot(new RandomItem(Material.DIAMOND_AXE, 16));
// Cooked furnace // Cooked furnace
_cookedFurnace.registerLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2)); _cookedFurnace.addLoot(new RandomItem(Material.COOKED_BEEF, 3, 1, 2));
_cookedFurnace.registerLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2)); _cookedFurnace.addLoot(new RandomItem(Material.COOKED_CHICKEN, 3, 1, 2));
_cookedFurnace.registerLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2)); _cookedFurnace.addLoot(new RandomItem(Material.COOKED_FISH, 3, 1, 2));
_cookedFurnace.registerLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2)); _cookedFurnace.addLoot(new RandomItem(Material.GRILLED_PORK, 3, 1, 2));
_cookedFurnace.registerLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1)); _cookedFurnace.addLoot(new RandomItem(Material.BAKED_POTATO, 3, 1, 1));
_cookedFurnace.registerLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1)); _cookedFurnace.addLoot(new RandomItem(Material.PUMPKIN_PIE, 3, 1, 1));
_cookedFurnace.registerLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1)); _cookedFurnace.addLoot(new RandomItem(Material.IRON_INGOT, 1, 1, 1));
// Raw furnace // Raw furnace
_rawFurnace.registerLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3)); _rawFurnace.addLoot(new RandomItem(Material.RAW_BEEF, 1, 1, 3));
_rawFurnace.registerLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3)); _rawFurnace.addLoot(new RandomItem(Material.RAW_CHICKEN, 1, 1, 3));
_rawFurnace.registerLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3)); _rawFurnace.addLoot(new RandomItem(Material.RAW_FISH, 1, 1, 3));
_rawFurnace.registerLoot(new RandomItem(Material.PORK, 1, 1, 3)); _rawFurnace.addLoot(new RandomItem(Material.PORK, 1, 1, 3));
_rawFurnace.registerLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3)); _rawFurnace.addLoot(new RandomItem(Material.POTATO_ITEM, 1, 1, 3));
// Deathmatch Loot // Deathmatch Loot
_deathMatchLoot.registerLoot(new RandomItem(Material.PUMPKIN_PIE, 4)); _deathMatchLoot.addLoot(new RandomItem(Material.PUMPKIN_PIE, 4));
_deathMatchLoot.registerLoot(new RandomItem(Material.BAKED_POTATO, 4)); _deathMatchLoot.addLoot(new RandomItem(Material.BAKED_POTATO, 4));
_deathMatchLoot.registerLoot(new RandomItem(Material.CAKE, 4)); _deathMatchLoot.addLoot(new RandomItem(Material.CAKE, 4));
_deathMatchLoot.registerLoot(new RandomItem(Material.APPLE, 4)); _deathMatchLoot.addLoot(new RandomItem(Material.APPLE, 4));
_deathMatchLoot.registerLoot(new RandomItem(Material.CARROT_ITEM, 4)); _deathMatchLoot.addLoot(new RandomItem(Material.CARROT_ITEM, 4));
_deathMatchLoot.registerLoot(new RandomItem(Material.WOOD_SWORD, 3)); _deathMatchLoot.addLoot(new RandomItem(Material.WOOD_SWORD, 3));
_deathMatchLoot.registerLoot(new RandomItem(Material.WOOD_AXE, 3)); _deathMatchLoot.addLoot(new RandomItem(Material.WOOD_AXE, 3));
_deathMatchLoot.registerLoot(new RandomItem(Material.STONE_AXE, 3)); _deathMatchLoot.addLoot(new RandomItem(Material.STONE_AXE, 3));
_deathMatchLoot.registerLoot(new RandomItem(Material.STONE_SWORD, 1)); _deathMatchLoot.addLoot(new RandomItem(Material.STONE_SWORD, 1));
} }
@EventHandler @EventHandler

View File

@ -10,31 +10,46 @@ import org.bukkit.event.inventory.ClickType;
public class SpellButton implements IButton public class SpellButton implements IButton
{ {
private SpellType _spell; private SpellType _spell;
private SpellMenuPage _spellPage; private SpellMenuPage _spellPage;
public SpellButton(SpellMenuPage spellPage, SpellType spell) public SpellButton(SpellMenuPage spellPage, SpellType spell)
{ {
_spell = spell; _spell = spell;
_spellPage = spellPage; _spellPage = spellPage;
} }
@Override @Override
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
Wizard wizard = _spellPage.getWizards().getWizard(player); Wizard wizard = _spellPage.getWizards().getWizard(player);
if (wizard != null) if (player.getInventory().getHeldItemSlot() >= wizard.getWandsOwned())
{ {
wizard.setSpell(player.getInventory().getHeldItemSlot(), _spell); 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); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 1);
_spellPage.getWizards().changeWandsTitles(player); }
} 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();
}
}
} }

View File

@ -1,7 +1,6 @@
package nautilus.game.arcade.game.games.wizards; package nautilus.game.arcade.game.games.wizards;
import java.util.ArrayList; import java.util.ArrayList;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
@ -15,94 +14,113 @@ import org.bukkit.entity.Player;
public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenuShop> public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenuShop>
{ {
private Wizards _wizard; private Wizards _wizard;
public SpellMenuPage(WizardSpellMenu plugin, WizardSpellMenuShop shop, CoreClientManager clientManager, public SpellMenuPage(WizardSpellMenu plugin, WizardSpellMenuShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player, Wizards wizard) DonationManager donationManager, Player player, Wizards wizard)
{ {
super(plugin, shop, clientManager, donationManager, "Spell Menu", player); super(plugin, shop, clientManager, donationManager, "Spell Menu", player);
_wizard = wizard; _wizard = wizard;
buildPage(); buildPage();
} }
@Override @Override
protected void buildPage() protected void buildPage()
{ {
Wizard wizard = getWizards().getWizard(getPlayer()); Wizard wizard = getWizards().getWizard(getPlayer());
ArrayList<Integer> usedNumbers = new ArrayList<Integer>(); ArrayList<Integer> usedNumbers = new ArrayList<Integer>();
for (SpellElement ele : SpellElement.values()) for (SpellElement ele : SpellElement.values())
{ {
addItem(ele.getSlot(), new ShopItem(ele.getIcon(), ele.name(), ele.name(), 1, true, true)); addItem(ele.getSlot(), new ShopItem(ele.getIcon(), ele.name(), ele.name(), 1, true, true));
for (int i = ele.getFirstSlot(); i <= ele.getSecondSlot(); i++) for (int i = ele.getFirstSlot(); i <= ele.getSecondSlot(); i++)
{ {
usedNumbers.add(i); usedNumbers.add(i);
} }
} }
for (int i = 0; i < 54; i++) for (int i = 0; i < 54; i++)
{ {
SpellType spell = null; SpellType spell = null;
for (SpellType spells : SpellType.values())
{
if (spells.getSlot() == i)
{
spell = spells;
break;
}
}
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) int spellLevel = wizard == null ? 1 : wizard.getSpellLevel(spell);
{
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("");
for (String lore : spell.getDesc()) if (spellLevel > 0)
{ {
builder.addLore(C.cGray + lore, 35); ItemBuilder builder = new ItemBuilder(spell.getSpellItem());
}
if (wizard == null) builder.setTitle(spell.getElement().getColor() + C.Bold + spell.getSpellName());
{
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));
}
}
}
public Wizards getWizards() builder.setAmount(spellLevel);
{
return _wizard;
}
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;
}
} }

View File

@ -1,60 +1,25 @@
package nautilus.game.arcade.game.games.wizards; 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.C;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.wizards.spells.SpellBridge; import nautilus.game.arcade.game.games.wizards.spells.*;
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 org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public enum SpellType // public enum SpellType //
{ {
AnvilDrop(SpellElement.ATTACK, // Spell element
Bridge(SpellElement.MISC, // Spell element WandElement.EARTH, // Wand element
"Bridge", // Spell name "Anvil Drop", // Spell name
new ItemStack(Material.FENCE), // Spell icon new ItemStack(Material.NETHER_BRICK_ITEM), // Spell icon
SpellBridge.class, // Spell class SpellAnvilDrop.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
3, // Spell max level 3, // Spell max level
40, // Mana cost 40, // Mana cost
15, // Spell cooldown 15, // Spell cooldown
@ -62,53 +27,18 @@ public enum SpellType // ❤
-4, // Cooldown change per level -4, // Cooldown change per level
10, // Item amount in loot 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 "This also includes the caster!"),
"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!"),
Fireball(SpellElement.ATTACK, // Spell element Fireball(SpellElement.ATTACK, // Spell element
WandElement.FIRE, // Wand element
"Fireball", // Spell name "Fireball", // Spell name
new ItemStack(Material.FIREBALL), // Spell icon new ItemStack(Material.COAL), // Spell icon
SpellFireball.class, // Spell class SpellFireball.class, // Spell class
3, // Spell max level 3, // Spell max level
30, // Mana cost 30, // Mana cost
@ -117,7 +47,7 @@ public enum SpellType // ❤
-2, // Cooldown change per level -2, // Cooldown change per level
10, // Item amount in loot 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!"), "Summon a blazing fireball!"),
Flash(SpellElement.SUPPORT, // Spell element Flash(SpellElement.SUPPORT, // Spell element
WandElement.LIFE, // Wand element
"Flash", // Spell name "Flash", // Spell name
new ItemStack(Material.REDSTONE_TORCH_ON), // Spell icon new ItemStack(Material.GOLD_NUGGET), // Spell icon
SpellFlash.class, // Spell class SpellFlash.class, // Spell class
3, // Spell max level 3, // Spell max level
50, // Mana cost 20, // Mana cost
50, // Spell cooldown 50, // Spell cooldown
0, // Mana cost change per level 0, // Mana cost change per level
-5, // Cooldown change per level -5, // Cooldown change per level
3, // Item amount in loot 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!"), "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 Heal(SpellElement.SUPPORT, // Spell element
WandElement.LIFE, // Wand element
"Heal", // Spell name "Heal", // Spell name
new ItemStack(Material.POTION, 1, (short) 8261), // Spell icon new ItemStack(Material.QUARTZ), // Spell icon
SpellHeal.class, // Spell class SpellHeal.class, // Spell class
5, // Spell max level 5, // Spell max level
50, // Mana cost 50, // Mana cost
@ -153,7 +125,7 @@ public enum SpellType // ❤
-1, // Cooldown change per level -1, // Cooldown change per level
5, // Item amount in loot 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!"), "Use this! Heal yourself up!"),
HealingRune(SpellElement.RUNES, // Spell element IcePrison(SpellElement.MISC, // Spell element
"Rune of Healing", // Spell name WandElement.ICE, // Wand element
new ItemStack(Material.POTION, 1, (short) 8197), // Spell icon "Ice Prison", // Spell name
SpellHealingRune.class, // Spell class new ItemStack(Material.EYE_OF_ENDER), // Spell icon
SpellIcePrison.class, // Spell class
3, // Spell max level 3, // Spell max level
60, // Mana cost 25, // Mana cost
30, // Spell cooldown 20, // Spell cooldown
0, // Mana cost change per level 2, // Mana cost change per level
-5, // Cooldown change per level 0, // Cooldown change per level
3, // Item amount in loot 3, // Item amount in loot
C.cGold + C.Bold + "Size: " + C.Bold + C.cWhite + "(Spell Level x 0.5) + 2", C.cYellow + C.Bold + "Size: " + C.Bold + C.cWhite + "Spell Level + 3",
C.cGold + C.Bold + "Lasts for: " + C.Bold + C.cWhite + "(Spell Level x 3) + 5 seconds",
"", "",
"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 Implode(SpellElement.MISC, // Spell element
WandElement.EARTH, // Wand element
"Implode", // Spell name "Implode", // Spell name
new ItemStack(Material.TNT), // Spell icon new ItemStack(Material.GLOWSTONE_DUST), // Spell icon
SpellImplode.class, // Spell class SpellImplode.class, // Spell class
3, // Spell max level 3, // Spell max level
50, // Mana cost 50, // Mana cost
@ -193,11 +191,11 @@ public enum SpellType // ❤
-3, // Cooldown change per level -3, // Cooldown change per level
3, // Item amount in loot 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"), "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 LightningStrike(SpellElement.ATTACK, // Spell element
WandElement.AIR, // Wand element
"Lightning Strike", // Spell name "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 SpellLightningStrike.class, // Spell class
3, // Spell max level 3, // Spell max level
50, // Mana cost 50, // Mana cost
@ -277,16 +215,21 @@ public enum SpellType // ❤
0, // Cooldown change per level 0, // Cooldown change per level
10, // Item amount in loot 10, // Item amount in loot
C.cYellow + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level x 2) + 2",
"", "",
"Summon a mighty lightning strike", "Summon a mighty lightning strike",
"to hit the target you point out!"), "to hit the target you point out!",
MagicMissile(SpellElement.ATTACK, // Spell element "The lightning also contains fire!"),
"Magic Missile", // Spell name
new ItemStack(Material.STICK), // Spell icon ManaBolt(SpellElement.ATTACK, // Spell element
SpellMagicMissile.class, // Spell class WandElement.AIR, // Wand element
"Mana Bolt", // Spell name
new ItemStack(Material.MELON_SEEDS), // Spell icon
SpellManaBolt.class, // Spell class
3, // Spell max level 3, // Spell max level
15, // Mana cost 15, // Mana cost
5, // Spell cooldown 5, // Spell cooldown
@ -294,19 +237,41 @@ public enum SpellType // ❤
0, // Cooldown change per level 0, // Cooldown change per level
15, // Item amount in loot 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 RainbowBeam(SpellElement.ATTACK, // Spell element
WandElement.FIRE, // Wand element
"Rainbow Beam", // Spell name "Rainbow Beam", // Spell name
new ItemStack(Material.EMERALD), // Spell icon new ItemStack(Material.INK_SACK, 1, (short) 10), // Spell icon
SpellRainbowBeam.class, // Spell class SpellRainbowBeam.class, // Spell class
5, // Spell max level 5, // Spell max level
5, // Mana cost 5, // Mana cost
@ -315,99 +280,117 @@ public enum SpellType // ❤
1, // Cooldown change per level 1, // Cooldown change per level
10, // Item amount in loot 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 "budget the damage will decrease after",
"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
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", RainbowRoad(SpellElement.MISC, // Spell element
WandElement.AIR, // Wand element
"", "Rainbow Road", // Spell name
new ItemStack(Material.SADDLE), // Spell icon
"Creates an targeted earthquake", SpellRainbowRoad.class, // Spell class
3, // Spell max level
"in the direction you point", 10, // Mana cost
20, // Spell cooldown
"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
0, // Mana cost change per level 0, // Mana cost change per level
0, // Cooldown change per level 0, // Cooldown change per level
3, // Item amount in loot 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"), "Gain a speed potion effect to outrun your enemies"),
Spiderman(SpellElement.MISC, // Spell element SummonWolves(SpellElement.MISC, // Spell element
"Spiderman", // Spell name WandElement.LIFE, // Wand element
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
"Summon Wolves", // Spell name "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 SpellSummonWolves.class, // Spell class
3, // Spell max level 3, // Spell max level
80, // Mana cost 80, // Mana cost
@ -416,7 +399,7 @@ public enum SpellType // ❤
0, // Cooldown change per level 0, // Cooldown change per level
8, // Item amount in loot 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"), "They will fight for you and after 30 seconds, will disappear"),
TeleportRune(SpellElement.RUNES, // Spell element TrapRune(SpellElement.MISC, // Spell element
"Teleport Rune", // Spell name WandElement.DEATH, // Wand element
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
"Trap Rune", // Spell name "Trap Rune", // Spell name
new ItemStack(Material.TRAP_DOOR), // Spell icon new ItemStack(Material.SHEARS), // Spell icon
SpellTrapRune.class, // Spell class SpellTrapRune.class, // Spell class
3, // Spell max level 3, // Spell max level
50, // Mana cost 25, // Mana cost
30, // Spell cooldown 30, // Spell cooldown
0, // Mana cost change per level 0, // Mana cost change per level
-5, // Cooldown change per level -5, // Cooldown change per level
3, // Item amount in loot 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!"), "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 WizardsCompass(SpellElement.MISC, // Spell element
WandElement.LIFE, // Wand element
"Wizard's Compass", // Spell name "Wizard's Compass", // Spell name
new ItemStack(Material.COMPASS), // Spell icon new ItemStack(Material.SUGAR), // Spell icon
SpellWizardsCompass.class, // Spell class SpellWizardsCompass.class, // Spell class
1, // Spell max level 1, // Spell max level
5, // Mana cost 5, // Mana cost
@ -489,19 +469,16 @@ public enum SpellType // ❤
public enum SpellElement 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), .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", C.cGray + "Misc spells that don't fit in",
"These spells generally effect the world itself").build(), C.cGray), "These spells generally effect the world itself").build(), C.cGray),
RUNES(3, 3, 3, new ItemBuilder(Material.NETHER_STAR).setTitle(C.cGold + "Rune Spells") SUPPORT(4, 4, 4, new ItemBuilder(Material.INK_SACK, 1, (short) 14).setTitle(C.cDGreen + "Support 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")
.addLore(C.cGray + "Spells of assistance").build(), C.cDGreen); .addLore(C.cGray + "Spells of assistance").build(), C.cDGreen);
private String _chatColor; 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 static
{ {
for (SpellType spell : values()) ArrayList<SpellType> spells = new ArrayList<SpellType>(Arrays.asList(SpellType.values()));
{
spell._slot = 9 + spell.getElement().getFirstSlot();
for (SpellType spell2 : values()) Collections.sort(spells, new Comparator<SpellType>()
{
@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) if (spell != spell2 && spell.getElement() == spell2.getElement() && spell._slot <= spell2._slot)
{ {
@ -610,10 +633,13 @@ public enum SpellType // ❤
private int _spellCost; private int _spellCost;
private String _spellName; private String _spellName;
private SpellElement _type; private SpellElement _type;
private WandElement _wandElement;
private SpellType(SpellElement type, String spellName, ItemStack spellItem, Class<? extends Spell> spell, int maxLevel, private SpellType(SpellElement type, WandElement wandElement, String spellName, ItemStack spellItem,
int spellCost, int spellCooldown, int manaChangePerLevel, int cooldownChangePerLevel, int itemAmount, String... desc) Class<? extends Spell> spell, int maxLevel, int spellCost, int spellCooldown, int manaChangePerLevel,
int cooldownChangePerLevel, int itemAmount, String... desc)
{ {
_wandElement = wandElement;
_maxLevel = maxLevel; _maxLevel = maxLevel;
_item = spellItem; _item = spellItem;
_desc = desc; _desc = desc;
@ -627,6 +653,16 @@ public enum SpellType // ❤
_itemAmount = itemAmount; _itemAmount = itemAmount;
} }
public int getBaseCooldown()
{
return _spellCooldown;
}
public int getBaseManaCost()
{
return _spellCost;
}
public String[] getDesc() public String[] getDesc()
{ {
return _desc; return _desc;
@ -642,16 +678,6 @@ public enum SpellType // ❤
return _itemAmount; return _itemAmount;
} }
public int getBaseManaCost()
{
return _spellCost;
}
public int getBaseCooldown()
{
return _spellCooldown;
}
public int getManaCost(Wizard wizard) public int getManaCost(Wizard wizard)
{ {
return Math.max(0, return Math.max(0,
@ -677,7 +703,11 @@ public enum SpellType // ❤
public ItemStack getSpellBook(Wizards wizards) 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()); .build());
} }
@ -710,10 +740,17 @@ public enum SpellType // ❤
return _spellName; return _spellName;
} }
public WandElement getWandType()
{
return _wandElement;
}
public ItemStack makeSpell(Wizards wizards, ItemStack item) public ItemStack makeSpell(Wizards wizards, ItemStack item)
{ {
ItemBuilder builder = new ItemBuilder(item); ItemBuilder builder = new ItemBuilder(item);
builder.setTitle(C.cDBlue + C.Bold + "Spell: " + _type._chatColor + getSpellName() + wizards.buildTime()); builder.setTitle(C.cDBlue + C.Bold + "Spell: " + _type._chatColor + getSpellName() + wizards.buildTime());
return builder.build(); return builder.build();
} }
} }

View File

@ -1,106 +1,141 @@
package nautilus.game.arcade.game.games.wizards; package nautilus.game.arcade.game.games.wizards;
import java.util.Set;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
public class Wizard public class Wizard
{ {
private NautHashMap<SpellType, Long> _cooldowns = new NautHashMap<SpellType, Long>(); private NautHashMap<SpellType, Long> _cooldowns = new NautHashMap<SpellType, Long>();
private NautHashMap<SpellType, Integer> _knownSpells = new NautHashMap<SpellType, Integer>(); private NautHashMap<SpellType, Integer> _knownSpells = new NautHashMap<SpellType, Integer>();
private SpellType[] _assignedWands = new SpellType[5]; private SpellType[] _assignedWands = new SpellType[5];
private float _mana; private float _mana;
private float _manaPerTick = 2.5F / 20F; private float _manaPerTick = 2.5F / 20F;
private float _maxMana; private float _maxMana;
private int _soulStars; private int _soulStars;
private float _cooldownModifier = 1; private float _cooldownModifier = 1;
private int _wandsOwned;
public float getCooldownModifier() public void setWandsOwned(int wandsOwned)
{ {
return _cooldownModifier; _wandsOwned = wandsOwned;
} }
public void decreaseCooldown() public int getWandsOwned()
{ {
_cooldownModifier -= 0.1; return _wandsOwned;
} }
public void addSoulStar() public float getCooldownModifier()
{ {
_soulStars++; return _cooldownModifier;
} }
public Wizard(float maxMana) public void decreaseCooldown()
{ {
learnSpell(SpellType.MagicMissile); _cooldownModifier -= 0.1;
learnSpell(SpellType.WizardsCompass); }
_maxMana = maxMana;
}
public SpellType getSpell(int slot) public void addSoulStar()
{ {
return _assignedWands[slot]; _soulStars++;
} }
public void setSpell(int slot, SpellType spell) public Wizard(float maxMana)
{ {
_assignedWands[slot] = spell; learnSpell(SpellType.ManaBolt);
} learnSpell(SpellType.WizardsCompass);
public long getCooldown(SpellType type) _maxMana = maxMana;
{ }
if (_cooldowns.containsKey(type) && _cooldowns.get(type) >= System.currentTimeMillis())
{
return _cooldowns.get(type);
}
return 0; public SpellType getSpell(int slot)
} {
return _assignedWands[slot];
}
public float getMana() public void setSpell(int slot, SpellType spell)
{ {
return _mana; _assignedWands[slot] = spell;
} }
public float getManaPerTick() public long getCooldown(SpellType type)
{ {
return _manaPerTick + ((_soulStars * 0.1F) / 20); if (_cooldowns.containsKey(type) && _cooldowns.get(type) >= System.currentTimeMillis())
} {
return _cooldowns.get(type);
}
public float getMaxMana() return 0;
{ }
return _maxMana;
}
public int getSpellLevel(SpellType type) public float getMana()
{ {
if (_knownSpells.containsKey(type)) return _mana;
{ }
return _knownSpells.get(type);
}
return 0;
}
public void learnSpell(SpellType type) public float getManaPerTick()
{ {
_knownSpells.put(type, getSpellLevel(type) + 1); return _manaPerTick + ((_soulStars * 0.2F) / 20);
} }
public void setMana(float newMana) public float getMaxMana()
{ {
_mana = newMana; return _maxMana;
} }
public void setUsedSpell(SpellType spell) public int getSpellLevel(SpellType type)
{ {
int cooldown = spell.getSpellCooldown(this); if (_knownSpells.containsKey(type))
if (cooldown > 0) {
{ return _knownSpells.get(type);
_cooldowns.put(spell, System.currentTimeMillis() + (1000L * cooldown)); }
} return 0;
} }
public void setManaPerTick(float manaPerTick) public void learnSpell(SpellType type)
{ {
_manaPerTick = manaPerTick; _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<SpellType, Long> getCooldowns()
{
return _cooldowns;
}
public void setManaPerTick(float manaPerTick)
{
_manaPerTick = manaPerTick;
}
public Set<SpellType> getKnownSpells()
{
return _knownSpells.keySet();
}
} }

View File

@ -20,93 +20,89 @@ import org.bukkit.plugin.java.JavaPlugin;
public class WizardSpellMenu extends MiniPlugin public class WizardSpellMenu extends MiniPlugin
{ {
private Wizards _wizards; private Wizards _wizards;
private WizardSpellMenuShop _wizardShop; private WizardSpellMenuShop _wizardShop;
private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells") 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(); .addLore(C.cGray + "Right click with this to view the spells").build();
public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards) public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards)
{ {
super("Wizard Spell Menu", plugin); super("Wizard Spell Menu", plugin);
_wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager() _wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager()
.GetDonation(), wizards); .GetDonation(), wizards);
_wizards = wizards; _wizards = wizards;
} }
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent event) 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) @EventHandler
{ public void onDeath(final PlayerDeathEvent event)
event.getPlayer().getInventory().addItem(_wizardSpells); {
} Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
} {
public void run()
{
if (_wizards.IsLive())
{
event.getEntity().getInventory().setItem(0, _wizardSpells);
}
}
});
}
@EventHandler @EventHandler
public void onDeath(final PlayerDeathEvent event) public void onJoin(GameStateChangeEvent event)
{ {
Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() if (event.GetState() == GameState.Recruit)
{ {
public void run() for (Player player : Bukkit.getOnlinePlayers())
{ {
if (_wizards.IsLive()) player.getInventory().setItem(0, _wizardSpells);
{ }
event.getEntity().getInventory().addItem(_wizardSpells); }
} }
}
});
}
@EventHandler @EventHandler
public void onJoin(GameStateChangeEvent event) 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) ItemStack item = event.getItem();
{
for (Player player : Bukkit.getOnlinePlayers())
{
player.getInventory().addItem(_wizardSpells);
}
}
}
@EventHandler if (item != null && item.isSimilar(_wizardSpells))
public void onInteract(PlayerInteractEvent event) {
{
if (event.getAction() != Action.PHYSICAL && (!_wizards.IsLive() || !_wizards.IsAlive(event.getPlayer())))
{
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 (p.getInventory().getHeldItemSlot() < _wizards.getWizard(p).getWandsOwned())
} {
} if (event.getAction().name().contains("RIGHT"))
{
if (_wizards.IsLive() && _wizards.IsAlive(event.getPlayer())) if (p.getInventory().getHeldItemSlot() < 5)
{ {
if (event.getClickedBlock() == null || !(event.getClickedBlock().getState() instanceof InventoryHolder))
ItemStack item = event.getItem(); {
if (item != null && item.getType() == Material.BLAZE_ROD) _wizardShop.attemptShopOpen(p);
{ }
}
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);
}
}
}
}
}
}
} }

View File

@ -10,26 +10,26 @@ import org.bukkit.entity.Player;
public class WizardSpellMenuShop extends ShopBase<WizardSpellMenu> public class WizardSpellMenuShop extends ShopBase<WizardSpellMenu>
{ {
private Wizards _wizards; private Wizards _wizards;
public WizardSpellMenuShop(WizardSpellMenu plugin, CoreClientManager clientManager, DonationManager donationManager, public WizardSpellMenuShop(WizardSpellMenu plugin, CoreClientManager clientManager, DonationManager donationManager,
Wizards wizard, CurrencyType... currencyTypes) Wizards wizard, CurrencyType... currencyTypes)
{ {
super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes); super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes);
_wizards = wizard; _wizards = wizard;
} }
@Override @Override
protected ShopPageBase<WizardSpellMenu, ? extends ShopBase<WizardSpellMenu>> buildPagesFor(Player player) protected ShopPageBase<WizardSpellMenu, ? extends ShopBase<WizardSpellMenu>> buildPagesFor(Player player)
{ {
return new SpellMenuPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _wizards); return new SpellMenuPage(getPlugin(), this, getClientManager(), getDonationManager(), player, _wizards);
} }
public void update() public void update()
{ {
for (ShopPageBase<WizardSpellMenu, ? extends ShopBase<WizardSpellMenu>> shopPage : getPlayerPageMap().values()) for (ShopPageBase<WizardSpellMenu, ? extends ShopBase<WizardSpellMenu>> shopPage : getPlayerPageMap().values())
{ {
shopPage.refresh(); shopPage.refresh();
} }
} }
} }

View File

@ -1,7 +1,5 @@
package nautilus.game.arcade.game.games.wizards.kit; 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.ArcadeManager;
import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.wizards.Wizards;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
@ -15,35 +13,17 @@ import org.bukkit.inventory.ItemStack;
public class KitMage extends Kit public class KitMage extends Kit
{ {
public KitMage(ArcadeManager manager) public KitMage(ArcadeManager manager)
{ {
super(manager, "Mage", KitAvailability.Free, new String[] super(manager, "Mage", KitAvailability.Free, new String[]
{ {
"Start with two extra spells" "Start with two extra spells"
}, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD));
} }
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
for (int i = 0; i < 5; i++) ((Wizards) this.Manager.GetGame()).setupWizard(player);
{ }
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());
}
}
}
} }

View File

@ -1,7 +1,5 @@
package nautilus.game.arcade.game.games.wizards.kit; 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.ArcadeManager;
import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.wizards.Wizards;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
@ -15,35 +13,17 @@ import org.bukkit.inventory.ItemStack;
public class KitMystic extends Kit public class KitMystic extends Kit
{ {
public KitMystic(ArcadeManager manager) public KitMystic(ArcadeManager manager)
{ {
super(manager, "Mystic", KitAvailability.Free, new String[] super(manager, "Mystic", KitAvailability.Free, new String[]
{ {
"Mana regeneration increased by 10%" "Mana regeneration increased by 10%"
}, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); }, new Perk[0], EntityType.WITCH, new ItemStack(Material.WOOD_HOE));
} }
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
for (int i = 0; i < 5; i++) ((Wizards) this.Manager.GetGame()).setupWizard(player);
{ }
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());
}
}
}
} }

View File

@ -1,7 +1,5 @@
package nautilus.game.arcade.game.games.wizards.kit; 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.ArcadeManager;
import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.wizards.Wizards;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
@ -15,35 +13,17 @@ import org.bukkit.inventory.ItemStack;
public class KitSorcerer extends Kit public class KitSorcerer extends Kit
{ {
public KitSorcerer(ArcadeManager manager) public KitSorcerer(ArcadeManager manager)
{ {
super(manager, "Sorcerer", KitAvailability.Free, new String[] super(manager, "Sorcerer", KitAvailability.Free, new String[]
{ {
"Start out with an extra wand" "Start out with an extra wand"
}, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); }, new Perk[0], EntityType.WITCH, new ItemStack(Material.STONE_HOE));
} }
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
for (int i = 0; i < 5; i++) ((Wizards) this.Manager.GetGame()).setupWizard(player);
{ }
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());
}
}
}
} }

View File

@ -1,8 +1,6 @@
package nautilus.game.arcade.game.games.wizards.kit; package nautilus.game.arcade.game.games.wizards.kit;
import mineplex.core.achievement.Achievement; 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.ArcadeManager;
import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.wizards.Wizards;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
@ -16,40 +14,22 @@ import org.bukkit.inventory.ItemStack;
public class KitWitchDoctor extends Kit public class KitWitchDoctor extends Kit
{ {
public KitWitchDoctor(ArcadeManager manager) public KitWitchDoctor(ArcadeManager manager)
{ {
super(manager, "Witch Doctor", KitAvailability.Free, new String[] super(manager, "Witch Doctor", KitAvailability.Free, new String[]
{ {
"Max mana increased to 150" "Max mana increased to 150"
}, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); }, new Perk[0], EntityType.WITCH, new ItemStack(Material.IRON_HOE));
this.setAchievementRequirements(new Achievement[] this.setAchievementRequirements(new Achievement[]
{ {
Achievement.BACON_BRAWL_WINS Achievement.BACON_BRAWL_WINS
}); });
} }
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
for (int i = 0; i < 5; i++) ((Wizards) this.Manager.GetGame()).setupWizard(player);
{ }
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());
}
}
}
} }

View File

@ -0,0 +1,138 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.minecraft.game.core.explosion.CustomExplosion;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.metadata.FixedMetadataValue;
public class SpellAnvilDrop extends Spell implements SpellClick
{
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
@Override
public void castSpell(Player player)
{
ArrayList<Player> players = new ArrayList<Player>();
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<FallingBlock> newFallingBlocks = new ArrayList<FallingBlock>();
for (Player p : players)
{
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, p.getLocation(), 0, 0, 0, 0, 1);
Location loc = p.getLocation().clone().add(0, 15 + (getSpellLevel(player) * 3), 0);
int lowered = 0;
while (lowered < 5 && loc.getBlock().getType() != Material.AIR)
{
lowered++;
loc = loc.add(0, -1, 0);
}
if (loc.getBlock().getType() == Material.AIR)
{
FallingBlock anvil = p.getWorld().spawnFallingBlock(loc.getBlock().getLocation().add(0.5, 0.5, 0.5),
Material.ANVIL, (byte) 0);
anvil.setMetadata("SpellLevel", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(),
getSpellLevel(player)));
anvil.setMetadata("Wizard", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), player));
anvil.getWorld().playSound(anvil.getLocation(), Sound.ANVIL_USE, 1.9F, 0);
newFallingBlocks.add(anvil);
}
}
if (!newFallingBlocks.isEmpty())
{
_fallingBlocks.addAll(newFallingBlocks);
charge(player);
}
}
private void handleAnvil(Entity entity)
{
_fallingBlocks.remove(entity);
int spellLevel = entity.getMetadata("SpellLevel").get(0).asInt();
CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), Wizards.getArcadeManager()
.GetExplosion(), entity.getLocation(), 1 + (spellLevel / 2F), "Anvil Drop");
explosion.setPlayer((Player) entity.getMetadata("Wizard").get(0).value(), true);
explosion.setFallingBlockExplosion(true);
explosion.setDropItems(false);
explosion.setMaxDamage(6 + (spellLevel * 4));
explosion.explode();
entity.remove();
}
@EventHandler
public void onDrop(ItemSpawnEvent event)
{
Iterator<FallingBlock> 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);
}
}
}

View File

@ -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<Block, Long> _wallExpires = new HashMap<Block, Long>();
@EventHandler
public void onUpdate(UpdateEvent event)
{
Iterator<Entry<Block, Long>> itel = _wallExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> 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);
}
}

View File

@ -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);
}
}
}
}
}

View File

@ -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<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
@Override
public void castSpell(Player player)
{
ArrayList<Player> players = new ArrayList<Player>();
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<FallingBlock> newFallingBlocks = new ArrayList<FallingBlock>();
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<FallingBlock> 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);
}
}
}

View File

@ -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<ExplosiveRune> _explosiveRunes = new ArrayList<ExplosiveRune>();
@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<Block> 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<ExplosiveRune> 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));
}
}

View File

@ -18,49 +18,53 @@ import org.bukkit.util.Vector;
public class SpellFireball extends Spell implements SpellClick public class SpellFireball extends Spell implements SpellClick
{ {
@EventHandler @EventHandler
public void onHit(ProjectileHitEvent event) public void onHit(ProjectileHitEvent event)
{ {
Projectile projectile = event.getEntity(); Projectile projectile = event.getEntity();
if (projectile.hasMetadata("FireballSpell"))
{
projectile.remove();
CustomExplosion explosion = new CustomExplosion(Wizards.getArcadeManager().GetDamage(), projectile.getLocation(), if (projectile.hasMetadata("FireballSpell"))
projectile.getMetadata("FireballYield").get(0).asFloat(), "Fireball"); {
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 explosion.setDropItems(false);
public void castSpell(Player p)
{
org.bukkit.entity.Fireball fireball = (org.bukkit.entity.Fireball) p.getWorld().spawnEntity(p.getEyeLocation(),
EntityType.FIREBALL);
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. explosion.explode();
EntityFireball eFireball = ((CraftFireball) fireball).getHandle(); }
eFireball.dirX = vector.getX(); }
eFireball.dirY = vector.getY();
eFireball.dirZ = vector.getZ();
fireball.setBounce(false); @Override
fireball.setShooter(p); public void castSpell(Player p)
fireball.setYield(0); {
fireball.setMetadata("FireballSpell", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), p)); org.bukkit.entity.Fireball fireball = (org.bukkit.entity.Fireball) p.getWorld().spawnEntity(p.getEyeLocation(),
fireball.setMetadata("FireballYield", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), EntityType.FIREBALL);
(getSpellLevel(p) * 0.25F) + 0.8F));
p.getWorld().playSound(p.getLocation(), Sound.BLAZE_BREATH, 0.5F, 5F); Vector vector = p.getEyeLocation().getDirection().normalize().multiply(0.14);
charge(p);
}
// 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);
}
} }

View File

@ -1,48 +1,69 @@
package nautilus.game.arcade.game.games.wizards.spells; package nautilus.game.arcade.game.games.wizards.spells;
import java.util.List;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class SpellFlash extends Spell implements SpellClick public class SpellFlash extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player player) public void castSpell(Player player)
{ {
int maxTeleportDistance = 20 + (10 * getSpellLevel(player)); int maxRange = 20 + (10 * getSpellLevel(player));
List<Block> list = player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, maxTeleportDistance); double curRange = 0;
if (list.size() > 1 && list.get(1).getType() != Material.AIR) while (curRange <= maxRange)
{ {
Block b = list.get(0); Location newTarget = player.getEyeLocation().add(new Vector(0, 0.2, 0))
.add(player.getLocation().getDirection().multiply(curRange));
if (b.getLocation().distance(player.getLocation()) > 2) if (!UtilBlock.airFoliage(newTarget.getBlock())
{ || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))
break;
Location loc = b.getLocation().clone().add(0.5, 0.5, 0.5); // Progress Forwards
curRange += 0.2;
player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F); // Smoke Trail
player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9); UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, newTarget.clone().add(0, 0.5, 0), 0, 0, 0, 0, 1);
}
player.setFallDistance(0); // Modify Range
player.teleport(loc); curRange -= 0.4;
if (curRange < 0)
curRange = 0;
player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F); // Destination
player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9); Location loc = player.getEyeLocation().add(new Vector(0, 0.2, 0))
.add(player.getLocation().getDirection().multiply(curRange)).add(new Vector(0, 0.4, 0));
charge(player); 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);
}
}
} }

View File

@ -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<Block, Long> _wallExpires = new HashMap<Block, Long>();
@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<Entry<Block, Long>> itel = _wallExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> entry = itel.next();
if (entry.getValue() < System.currentTimeMillis())
{
itel.remove();
if (entry.getKey().getType() == Material.ICE)
{
entry.getKey().setType(Material.AIR);
}
}
}
}
}

View File

@ -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<Player, Double> 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);
}
});
}
}
}

View File

@ -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.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; 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.Effect;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class SpellHeal extends Spell implements SpellClick, SpellClickEntity public class SpellHeal extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player p) public void castSpell(Player p)
{ {
castSpell(p, p); if (p.getHealth() < p.getMaxHealth())
} {
double health = p.getHealth() + (3 + getSpellLevel(p));
@Override if (health > p.getMaxHealth())
public void castSpell(Player p, Entity target) health = p.getMaxHealth();
{
if (!(target instanceof LivingEntity))
return;
LivingEntity entity = (LivingEntity) target; p.setHealth(health);
if (entity.getHealth() < entity.getMaxHealth()) p.getWorld().spigot().playEffect(p.getEyeLocation(), Effect.HEART, 0, 0, 0.8F, 0.4F, 0.8F, 0, 6, 30);
{
double health = entity.getHealth() + (3 + getSpellLevel(p));
if (health > entity.getMaxHealth()) charge(p);
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);
}
}
} }

View File

@ -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<HealingRune> _healingRunes = new ArrayList<HealingRune>();
@EventHandler
public void onTick(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
Iterator<HealingRune> 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);
}
}

View File

@ -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<Block, Long> _prisonExpires = new HashMap<Block, Long>();
@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<Block, Double> 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<Entry<Block, Long>> itel = _prisonExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> 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);
}
}
}

View File

@ -0,0 +1,152 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.HashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class SpellIceShards extends Spell implements SpellClick, IThrown
{
private HashMap<Entity, Location> _lastParticles = new HashMap<Entity, Location>();
@Override
public void castSpell(final Player player)
{
shoot(player);
for (int i = 1; i <= getSpellLevel(player); i++)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable()
{
@Override
public void run()
{
shoot(player);
}
}, i * 5);
}
charge(player);
}
private void shoot(Player player)
{
if (Wizards.IsAlive(player))
{
// Boost
org.bukkit.entity.Item ent = player.getWorld().dropItem(
player.getEyeLocation(),
ItemStackFactory.Instance.CreateStack(Material.GHAST_TEAR, (byte) 0, 1, "Ice Shard " + player.getName() + " "
+ System.currentTimeMillis()));
UtilAction.velocity(ent, player.getLocation().getDirection(), 2, false, 0, 0.2, 10, false);
Wizards.getArcadeManager().GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 2f);
player.getWorld().playSound(player.getLocation(), Sound.CLICK, 1.2F, 0.8F);
_lastParticles.put(ent, ent.getLocation());
}
}
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
if (target != null && target instanceof Player)
{
// Damage Event
Wizards.getArcadeManager()
.GetDamage()
.NewDamageEvent(target, data.GetThrower(), null, DamageCause.PROJECTILE, 4 /*+ (timesHit * 2)*/, true, true,
false, "Ice Shard", "Ice Shard");
}
handleShard(data);
}
private void handleShard(ProjectileUser data)
{
data.GetThrown().remove();
Location loc = data.GetThrown().getLocation();
UtilParticle.PlayParticle(ParticleType.BLOCK_CRACK.getParticle(Material.PACKED_ICE, 0), loc, 0.3F, 0.3F, 0.3F, 0, 12);
loc.getWorld().playSound(loc, Sound.GLASS, 1.2F, 1);
for (int x = -1; x <= 1; x++)
{
for (int y = -1; y <= 1; y++)
{
for (int z = -1; z <= 1; z++)
{
Block block = loc.clone().add(x, y, z).getBlock();
if (block.getType() == Material.FIRE)
{
block.setType(Material.AIR);
}
}
}
}
_lastParticles.remove(data.GetThrown());
}
@EventHandler
public void onTick(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
for (Entity entity : _lastParticles.keySet())
{
for (Location loc : UtilShapes.getLinesDistancedPoints(_lastParticles.get(entity), entity.getLocation(), 0.3))
{
UtilParticle.PlayParticle(ParticleType.BLOCK_CRACK.getParticle(Material.PACKED_ICE, 0), loc, 0, 0, 0, 0, 1);
}
_lastParticles.put(entity, entity.getLocation());
}
}
@Override
public void Idle(ProjectileUser data)
{
handleShard(data);
}
@Override
public void Expire(ProjectileUser data)
{
handleShard(data);
}
}

View File

@ -1,8 +1,15 @@
package nautilus.game.arcade.game.games.wizards.spells; 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.List;
import java.util.Random;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
@ -12,74 +19,143 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.scheduler.BukkitRunnable;
public class SpellImplode extends Spell implements SpellClick public class SpellImplode extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player p) public void castSpell(final Player p)
{ {
List<Block> list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 50); List<Block> list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 50);
if (list.size() > 1) if (list.size() > 1)
{ {
BlockFace face = list.get(0).getFace(list.get(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<Block> effectedBlocks = new ArrayList<Block>();
int size = (int) (1.5F + (getSpellLevel(p) * 0.7F));
for (int i = 0; i < Math.min(maxDist, getSpellLevel(p) * 2); i++) for (int x = -size * 2; x <= size * 2; x++)
{ {
if (centerBlock.getRelative(face) != null) for (int y = -size * 2; y <= size * 2; y++)
{ {
centerBlock = centerBlock.getRelative(face); 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); if (effectedBlock.getType() == Material.AIR || effectedBlock.getType() == Material.BEDROCK
int size = (int) (1.5F + (getSpellLevel(p) * 0.7F)); || effectedBlocks.contains(effectedBlock))
{
continue;
}
for (int x = -size * 2; x <= size * 2; x++) if ((centerLocation.distance(effectedBlock.getLocation().add(0.5, 0.5, 0.5)) + Math.abs(y / 4D))
{
for (int y = -size; y <= size; y++)
{
for (int z = -size * 2; z <= size * 2; z++)
{
Block effectedBlock = centerBlock.getRelative(x, y, z);
if (effectedBlock.getLocation().distance(centerBlock.getLocation()) <= size * 2 <= ((size * 2) + UtilMath.random.nextFloat())
&& !(effectedBlock.getState() instanceof InventoryHolder))
{
if (effectedBlock.getType() == Material.BEDROCK) && !(effectedBlock.getState() instanceof InventoryHolder))
{ {
continue;
}
FallingBlock block = effectedBlock.getWorld().spawnFallingBlock(effectedBlock.getLocation(), effectedBlocks.add(effectedBlock);
effectedBlock.getType(), effectedBlock.getData()); }
}
}
}
block.setVelocity(centerLocation.toVector() Collections.shuffle(effectedBlocks);
.subtract(effectedBlock.getLocation().add(0.5, 0.5, 0.5).toVector()).normalize());
block.setDropItem(false); new BukkitRunnable()
{
int timesRan;
Iterator<Block> bItel;
effectedBlock.setType(Material.AIR); public void run()
} {
} {
} Block block = effectedBlocks.get(UtilMath.r(effectedBlocks.size()));
} block.getWorld().playSound(block.getLocation(),
new Random().nextBoolean() ? Sound.DIG_GRAVEL : Sound.DIG_GRASS, 2,
UtilMath.random.nextFloat() / 4);
}
for (Player player : Bukkit.getOnlinePlayers()) if (timesRan % 3 == 0)
{ {
player.playSound(player == p ? p.getLocation() : centerBlock.getLocation(), Sound.ENDERDRAGON_GROWL, 1.5F, 1.5F); for (int a = 0; a < Math.ceil(effectedBlocks.size() / 3D); a++)
} {
if (bItel == null || !bItel.hasNext())
{
bItel = effectedBlocks.iterator();
}
charge(p); Block block = bItel.next();
}
} if (block.getType() == Material.AIR)
{
continue;
}
for (int i = 0; i < 6; i++)
{
BlockFace face = BlockFace.values()[i];
Block b = block.getRelative(face);
if (UtilBlock.airFoliage(b))
{
UtilParticle.PlayParticle(
ParticleType.BLOCK_CRACK.getParticle(block.getType(), block.getData()),
block.getLocation().add(
0.5 + (face.getModX() * 0.6D),
0.5 + (face.getModY() * 0.6D),
0.5 + (face.getModZ() * 0.6D)),
face.getModX() / 2F, face.getModX() / 2F, face.getModX() / 2F, 0, 6);
}
}
}
}
if (effectedBlocks.isEmpty())
{
cancel();
}
else if (timesRan++ >= 20)
{
Iterator<Block> 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);
}
}
} }

View File

@ -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<Entry<ArrayList<Location>, Player>> _locations = new ArrayList<Entry<ArrayList<Location>, Player>>();
@Override
public void castSpell(Player player)
{
// Player p = UtilPlayer.getPlayerInSight(player, 10 * getSpellLevel(player), true);
Location l = null;
// if (p == null)
// {
List<Block> 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<Location> locs = UtilShapes.getLinesDistancedPoints(player.getLocation(), l, 1.5);
Iterator<Location> 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<Entry<ArrayList<Location>, Player>> itel = _locations.iterator();
while (itel.hasNext())
{
Entry<ArrayList<Location>, 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();
}
}

View File

@ -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);
}
}
}

View File

@ -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<LaunchRune> _launchRunes = new ArrayList<LaunchRune>();
@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<LaunchRune> 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));
}
}

View File

@ -1,12 +1,17 @@
package nautilus.game.arcade.game.games.wizards.spells; 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.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.LightningStrike; import org.bukkit.entity.LightningStrike;
@ -16,53 +21,131 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
public class SpellLightningStrike extends Spell implements SpellClick public class SpellLightningStrike extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player p) public void castSpell(final Player p)
{ {
List<Block> list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 150); double curRange = 0;
if (list.size() > 1)
{
Location loc = list.get(0).getLocation();
while (UtilBlock.solid(loc.getBlock().getRelative(BlockFace.UP))) while (curRange <= 150)
{ {
loc.add(0, 1, 0); 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 // Destination
public void onEntityDamage(EntityDamageByEntityEvent event) final Location loc = p.getLocation().add(p.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0)));
{
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")) while (UtilBlock.solid(loc.getBlock().getRelative(BlockFace.UP)))
{ {
lightning.setMetadata("IgnoreDamage", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), null)); loc.add(0, 1, 0);
}
Wizards.getArcadeManager() UtilParticle.PlayParticle(ParticleType.ANGRY_VILLAGER, loc.clone().add(0, 1.3, 0), 0.5F, 0.3F, 0.5F, 0, 7);
.GetDamage()
.NewDamageEvent((LivingEntity) event.getEntity(), Bukkit.getScheduler().scheduleSyncDelayedTask(Wizards.getArcadeManager().getPlugin(), new Runnable()
(Player) lightning.getMetadata("Damager").get(0).value(), null, DamageCause.LIGHTNING, {
event.getDamage(), false, true, false, "Lightning Strike", "Lightning Strike");
} @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<Block> toExplode = new ArrayList<Block>();
ArrayList<Block> toFire = new ArrayList<Block>();
for (int x = -1; x <= 1; x++)
{
for (int y = -1; y <= 1; y++)
{
for (int z = -1; z <= 1; z++)
{
if (x == 0 || (Math.abs(x) != Math.abs(z) || UtilMath.r(3) == 0))
{
Block block = b.getRelative(x, y, z);
if ((y == 0 || (x == 0 && z == 0)) && block.getType() != Material.AIR
&& block.getType() != Material.BEDROCK)
{
if (y == 0 || UtilMath.random.nextBoolean())
{
toExplode.add(block);
toFire.add(block);
}
}
else if (block.getType() == Material.AIR)
{
toFire.add(block);
}
}
}
}
}
Wizards.getArcadeManager().GetExplosion().BlockExplosion(toExplode, b.getLocation(), false);
for (Block block : toFire)
{
if (UtilMath.random.nextBoolean())
{
block.setType(Material.FIRE);
}
}
}
}, 20);
charge(p);
}
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent event)
{
if (event.getDamager() instanceof LightningStrike && event.getEntity() instanceof LivingEntity)
{
LightningStrike lightning = (LightningStrike) event.getDamager();
if (lightning.hasMetadata("Damager"))
{
event.setCancelled(true);
if (!lightning.hasMetadata("IgnoreDamage"))
{
lightning.setMetadata("IgnoreDamage", new FixedMetadataValue(Wizards.getArcadeManager().getPlugin(), null));
event.getEntity().setFireTicks(80);
Player player = (Player) lightning.getMetadata("Damager").get(0).value();
Wizards.getArcadeManager()
.GetDamage()
.NewDamageEvent((LivingEntity) event.getEntity(), player, null, DamageCause.LIGHTNING,
4 + (4 * getSpellLevel(player)), false, true, false, "Lightning Strike", "Lightning Strike");
}
}
}
}
} }

View File

@ -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);
}
}

View File

@ -0,0 +1,213 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.ArrayList;
import java.util.Random;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilShapes;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class SpellManaBolt extends Spell implements SpellClick
{
public void castSpell(final Player player)
{
final Location missileLocation = player.getEyeLocation();
final Location shotFrom = missileLocation.clone();
final Vector direction = missileLocation.getDirection().normalize().multiply(0.3);
final int maxRange = 20 + (10 * getSpellLevel(player));
final int maxDings = maxRange * 3;
final int damage = 4 + (getSpellLevel(player) * 2);
new BukkitRunnable()
{
private int dingsDone;
private Location previousLocation = missileLocation;
private void burst()
{
for (Entity cur : missileLocation.getWorld().getEntities())
{
if (cur == player || !(cur instanceof LivingEntity) || (cur instanceof Player && UtilPlayer.isSpectator(cur)))
continue;
LivingEntity entity = (LivingEntity) cur;
Location eLoc = entity.getLocation();
// If they are less than 0.5 blocks away
if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7)
{
// If it is in their body height
if (Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.5)) - missileLocation.getY()) <= entity
.getEyeHeight() / 2)
{
if (entity != player && (!(entity instanceof Player) || Wizards.IsAlive(entity)))
{
Wizards.Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.MAGIC, damage, true,
true, false, "Mana Bolt", "Mana Bolt");
}
}
}
}
playParticle(missileLocation, previousLocation);
for (int i = 0; i < 120; i++)
{
Vector vector = new Vector(new Random().nextFloat() - 0.5F, new Random().nextFloat() - 0.5F,
new Random().nextFloat() - 0.5F);
if (vector.length() >= 1)
{
i--;
continue;
}
Location loc = missileLocation.clone();
loc.add(vector.multiply(2));
UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, -1, 1, 1, 1, 0);
}
missileLocation.getWorld().playSound(missileLocation, Sound.BAT_TAKEOFF, 1.2F, 1);
cancel();
}
public void run()
{
if (dingsDone >= maxDings || !player.isOnline() || !Wizards.Manager.IsAlive(player))
{
burst();
}
else
{
for (int i = 0; i < 2; i++)
{
Player closestPlayer = null;
double dist = 0;
// This lot of code makes the magic missile change direction towards the closest player in its path
// Not entirely accurate, it doesn't go only for the people it can hit.
// This makes magic missile pretty cool in my opinion
for (Player closest : Wizards.GetPlayers(true))
{
Location loc = closest.getLocation();
if (closest != player)
{
double dist1 = loc.distance(shotFrom);
// If the player is a valid target
if (dist1 < maxRange + 10)
{
double dist2 = missileLocation.distance(loc);
// If the player is closer to the magic missile than the other dist
if (closestPlayer == null || dist2 < dist)
{
double dist3 = missileLocation.clone().add(direction).distance(loc);
if (dist3 < dist2)
{
// If the magic missile grows closer when it moves
closestPlayer = closest;
dist = dist2;
}
}
}
}
}
if (closestPlayer != null)
{
Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector()
.subtract(missileLocation.toVector());
direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.3);
}
missileLocation.add(direction);
for (Entity cur : missileLocation.getWorld().getEntities())
{
if (cur == player || !(cur instanceof LivingEntity)
|| (cur instanceof Player && UtilPlayer.isSpectator(cur)))
continue;
LivingEntity ent = (LivingEntity) cur;
Location eLoc = ent.getLocation();
// If they are less than 0.5 blocks away
if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7)
{
// If it is in their body height
if (Math.abs((eLoc.getY() + (ent.getEyeHeight() / 1.5)) - missileLocation.getY()) <= ent
.getEyeHeight() / 2)
{
burst();
return;
}
}
}
if (UtilBlock.solid(missileLocation.getBlock()))
{
burst();
return;
}
playParticle(missileLocation, previousLocation);
previousLocation = missileLocation.clone();
dingsDone++;
}
missileLocation.getWorld().playSound(missileLocation, Sound.ORB_PICKUP, 0.7F, 0);
}
}
}.runTaskTimer(Wizards.Manager.getPlugin(), 0, 0);
charge(player);
}
private void playParticle(Location start, Location end)
{
final ArrayList<Location> locations = UtilShapes.getLinesDistancedPoints(start, end, 0.1);
new BukkitRunnable()
{
int timesRan;
public void run()
{
for (Location loc : locations)
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, loc, -1, 1, 1, 1, 0);
}
if (timesRan++ > 1)
{
cancel();
}
}
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0);
}
}

View File

@ -0,0 +1,268 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class SpellNapalm extends Spell implements SpellClick
{
private HashMap<Material, Material> _glazedBlocks = new HashMap<Material, Material>();
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<Block> litOnFire = new ArrayList<Block>();
HashMap<Block, Double> tempIgnore = new HashMap<Block, Double>();
double blocksTravelled;
double size = 1;
double lastTick;
public void run()
{
Random r = new Random();
napalmLoc.add(vector);
if (!UtilBlock.airFoliage(napalmLoc.getBlock()))
{
cancel();
return;
}
for (int b = 0; b < size * 20; b++)
{
float x = r.nextFloat();
float y = r.nextFloat();
float z = r.nextFloat();
while (Math.sqrt((x * x) + (y * y) + (z * z)) >= 1)
{
x = r.nextFloat();
y = r.nextFloat();
z = r.nextFloat();
}
UtilParticle.PlayParticle(ParticleType.RED_DUST,
napalmLoc.clone().add(
(size * (x - 0.5)) / 5,
(size * (y - 0.5)) / 5,
(size * (z - 0.5)) / 5),
-0.3F,
0.35F + (r.nextFloat() / 8),
0.1F, 1, 0);
}
if (lastTick % 3 == 0)
{
for (Entity entity : napalmLoc.getWorld().getEntities())
{
if (!UtilPlayer.isSpectator(entity))
{
double heat = (size * 1.1) - entity.getLocation().distance(napalmLoc);
if (heat > 0)
{
if (lastTick % 10 == 0 && heat > 0.2)
{
if (entity instanceof LivingEntity)
{
Wizards.getArcadeManager()
.GetDamage()
.NewDamageEvent((LivingEntity) entity, player, null, DamageCause.FIRE,
heat / 1.5, false, true, true, "Napalm", "Napalm");
}
else
{
entity.remove();
continue;
}
}
if (entity instanceof LivingEntity && !UtilPlayer.isSpectator(entity)
&& entity.getFireTicks() < heat * 40)
{
entity.setFireTicks((int) (heat * 40));
}
}
}
}
int bSize = (int) Math.ceil(size * 0.75);
for (int y = -bSize; y <= bSize; y++)
{
if (napalmLoc.getBlockY() + y < 256 && napalmLoc.getBlockY() + y > 0)
{
for (int x = -bSize; x <= bSize; x++)
{
for (int z = -bSize; z <= bSize; z++)
{
Block block = napalmLoc.clone().add(x, y, z).getBlock();
if (litOnFire.contains(block))
{
continue;
}
if (UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), playerLoc) < 2.5)
{
continue;
}
double heat = bSize - UtilMath.offset(block.getLocation().add(0.5, 0.5, 0.5), napalmLoc);
if (tempIgnore.containsKey(block))
{
if (tempIgnore.remove(block) > heat)
{
litOnFire.add(block);
continue;
}
}
if (heat > 0)
{
if (block.getType() != Material.AIR)
{
float strength = net.minecraft.server.v1_7_R4.Block.getById(block.getTypeId()).a(
(net.minecraft.server.v1_7_R4.Entity) null) * 0.7F;
if (strength <= heat)
{
block.setType(Material.AIR);
block.getWorld().playSound(block.getLocation(), Sound.FIZZ, 1.3F,
0.6F + ((new Random().nextFloat() - 0.5F) / 3F));
}
else if (0.2 <= heat)
{
if (_glazedBlocks.containsKey(block.getType()))
{
block.setType(_glazedBlocks.get(block.getType()));
if (block.getType() == Material.STAINED_CLAY)
{
block.setData((byte) 8);
}
block.getWorld().playSound(block.getLocation(), Sound.FIZZ, 1.3F,
0.6F + ((new Random().nextFloat() - 0.5F) / 3F));
}
}
else if (strength * 2 > size)
{
tempIgnore.put(block, heat);
continue;
}
}
if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)
{
if (heat > 1)
{
block.setType(Material.AIR);
block.getWorld().playSound(block.getLocation(), Sound.FIZZ, 1.3F, 0);
litOnFire.add(block);
}
}
else if (block.getType() == Material.AIR)
{
if (UtilMath.random.nextBoolean())
{
for (int a = 0; a < 6; a++)
{
Block b = block.getRelative(BlockFace.values()[a]);
if (b.getType() != Material.AIR)
{
block.setType(Material.FIRE);
block.getWorld().playSound(block.getLocation(), Sound.DIG_WOOL, 1.3F,
0.6F + ((new Random().nextFloat() - 0.5F) / 3F));
break;
}
}
}
litOnFire.add(block);
}
}
}
}
}
}
size = Math.min(8, size + 0.06);
}
blocksTravelled += 0.15;
if (lastTick++ % 8 == 0)
{
napalmLoc.getWorld().playSound(napalmLoc, Sound.CAT_HISS, Math.min(0.8F + (float) (size * 0.09F), 1.8f), 0F);
}
if (blocksTravelled >= length)
{
cancel();
}
}
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 1);
charge(player);
}
}

View File

@ -17,47 +17,57 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class SpellRainbowBeam extends Spell implements SpellClick public class SpellRainbowBeam extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player p) public void castSpell(Player p)
{ {
Entity entityTarget = UtilPlayer.getEntityInSight(p, 20 * getSpellLevel(p), true, true, true, 1.9F); Entity entityTarget = UtilPlayer.getEntityInSight(p, 80, true, true, true, 1.9F);
if (!(entityTarget instanceof LivingEntity)) if (!(entityTarget instanceof LivingEntity))
{ {
entityTarget = null; entityTarget = null;
} }
Location loc; Location loc;
if (entityTarget != null) if (entityTarget != null)
{ {
loc = p.getEyeLocation().add( loc = p.getEyeLocation().add(
p.getEyeLocation().getDirection().normalize() p.getEyeLocation().getDirection().normalize()
.multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation()))); .multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation())));
// The above code makes the beam appear to hit them where you aimed. double damage = (getSpellLevel(p) * 2) + 4;
Wizards.getArcadeManager() double dist = loc.distance(p.getLocation()) - (80 * .2D);
.GetDamage()
.NewDamageEvent((LivingEntity) entityTarget, p, null, DamageCause.CUSTOM, (getSpellLevel(p) * 2) + 4F, true,
true, false, "Rainbow Beam", "Rainbow Beam");
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));
} damage = Math.max(1, damage);
else }
{
loc = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 20 * getSpellLevel(p)).get(0).getLocation()
.add(0.5, 0.5, 0.5);
}
for (Location l : UtilShapes.getLinesDistancedPoints(p.getEyeLocation().subtract(0, 0.1, 0), loc, 1)) // The above code makes the beam appear to hit them where you aimed.
{ Wizards.getArcadeManager()
l.getWorld().spigot().playEffect(l, Effect.POTION_SWIRL, 0, 0, 0, 0, 0, 500, 1, 30); .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);
}
} }

View File

@ -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<Block, Long> _wallExpires = new HashMap<Block, Long>();
@EventHandler
public void onUpdate(UpdateEvent event)
{
Iterator<Entry<Block, Long>> itel = _wallExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> 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<Block> bs = new ArrayList<Block>();
bs.add(block);
for (int i = 0; i < 2; i++)
{
bs.add(block.getRelative(faces[i]));
}
bs.addAll(UtilShapes.getDiagonalBlocks(block, face, 1));
boolean playSound = false;
for (Block b : bs)
{
if (!Wizards.isInsideMap(b.getLocation()))
{
continue;
}
if (!_wallExpires.containsKey(block) && UtilBlock.solid(b))
{
continue;
}
b.setType(Material.STAINED_GLASS);
b.setData((byte) _rainbow[colorProgress++ % _rainbow.length]);
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WOOL, b.getData());
_wallExpires.put(b, System.currentTimeMillis() + ((20 + UtilMath.r(10)) * 1000L));
playSound = true;
}
if (playSound)
{
block.getWorld().playSound(block.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1);
}
return colorProgress;
}
}

View File

@ -3,13 +3,17 @@ package nautilus.game.arcade.game.games.wizards.spells;
import java.util.ArrayList; import java.util.ArrayList;
import mineplex.core.common.util.UtilBlock; 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.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.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClickBlock;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.AnimalTamer;
@ -17,164 +21,332 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class SpellRumble extends Spell implements SpellClickBlock, SpellClick public class SpellRumble extends Spell implements SpellClickBlock, SpellClick
{ {
final private BlockFace[] _radial = final private BlockFace[] _radial =
{ {
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
}; };
public void castSpell(Player player) public void castSpell(Player player)
{ {
Block block = player.getLocation().add(0, -1, 0).getBlock(); Block block = player.getLocation().add(0, -1, 0).getBlock();
if (!UtilBlock.solid(block)) if (!UtilBlock.solid(block))
{ {
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
} }
castSpell(player, block); castSpell(player, block);
} }
@Override @EventHandler
public void castSpell(final Player player, final Block target) 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]; if (UtilBlock.solid(target))
final int spellLevel = getSpellLevel(player); {
final int damage = 4 + (spellLevel * 2);
final int maxDist = 10 * spellLevel;
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() playBlockEffect(target);
{
private Block _currentBlock = target;
private int _distTravelled = 0;
private ArrayList<Integer> _effected = new ArrayList<Integer>();
private ArrayList<Block> _previousBlocks = new ArrayList<Block>();
@Override new BukkitRunnable()
public void run() {
{ private Block _currentBlock = target;
if (!player.isOnline() || !Wizards.IsAlive(player)) private int _distTravelled = 0;
{ private ArrayList<Integer> _effected = new ArrayList<Integer>();
cancel(); private ArrayList<Block> _previousBlocks = new ArrayList<Block>();
return;
}
_currentBlock = _currentBlock.getRelative(moveDirection); private void endRun()
{
ArrayList<Block> bs = new ArrayList<Block>();
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))) for (int i = 1; i <= Math.min(4, Math.floor(_distTravelled / (8D - spellLevel))) + 1; i++)
{ {
cancel(); for (int a = 0; a < faces.length; a++)
return; {
} Block b = _currentBlock.getRelative(faces[a], i);
} if (UtilBlock.solid(b))
else if (!UtilBlock.solid(_currentBlock) && _currentBlock.getY() > 0) {
{ bs.add(b);
}
}
}
_currentBlock = _currentBlock.getRelative(BlockFace.DOWN); for (Block block : bs)
{
} ArrayList<Block> toExplode = new ArrayList<Block>();
if (!UtilBlock.solid(_currentBlock)) toExplode.add(block);
{
cancel();
return;
}
ArrayList<Block> bs = new ArrayList<Block>(); 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 (LivingEntity entity : block.getWorld().getEntitiesByClass(LivingEntity.class))
{ {
for (int a = 0; a < faces.length; a++) if (!UtilPlayer.isSpectator(entity))
{ {
Block b = _currentBlock.getRelative(faces[a], i); if (entity instanceof Tameable)
{
AnimalTamer tamer = ((Tameable) entity).getOwner();
if (UtilBlock.solid(b)) if (tamer != null && tamer == player)
{ {
bs.add(b); continue;
} }
} }
}
_previousBlocks.addAll(bs); double dist = 999;
for (Block b : _previousBlocks) for (Block b : toExplode)
{ {
for (Entity entity : b.getChunk().getEntities()) double currentDist = b.getLocation().add(0.5, 0.5, 0.5).distance(entity.getLocation());
{
if (entity instanceof LivingEntity && player != entity && !_effected.contains(entity.getEntityId()))
{
if (entity instanceof Tameable) if (dist > currentDist)
{ {
AnimalTamer tamer = ((Tameable) entity).getOwner(); dist = currentDist;
}
}
if (tamer != null && tamer == player) if (dist < 2)
{ {
continue; 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)) boolean found = false;
{
continue;
}
double height = loc.getY() - b.getY(); for (int y : new int[]
if (height >= 0 && height <= 2) {
{ 0, 1, -1, -2
Wizards.Manager.GetDamage().NewDamageEvent((LivingEntity) entity, player, null, })
DamageCause.CUSTOM, damage, false, true, false, "Rumble", "Rumble"); {
} 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) break;
{ }
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId(), 19); // 19 being particle view }
// distance
}
if (_distTravelled++ >= maxDist) if (!found)
{ {
cancel(); endRun();
} return;
} }
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 5, 1);
charge(player); ArrayList<Block> effectedBlocks = new ArrayList<Block>();
}
} 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<? extends Player> 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);*/
}
} }

View File

@ -0,0 +1,103 @@
package nautilus.game.arcade.game.games.wizards.spells;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.metadata.FixedMetadataValue;
public class SpellSpectralArrow extends Spell implements SpellClick
{
private HashMap<Arrow, Location[]> _spectralArrows = new HashMap<Arrow, Location[]>();
@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<Entry<Arrow, Location[]>> itel = _spectralArrows.entrySet().iterator();
while (itel.hasNext())
{
Entry<Arrow, Location[]> entry = itel.next();
for (Location loc : UtilShapes.getLinesDistancedPoints(entry.getValue()[1], entry.getKey().getLocation(), 0.7D))
{
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, loc, 0, 0, 0, 0, 1);
}
entry.getValue()[1] = entry.getKey().getLocation();
}
}
@EventHandler
public void onSecond(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
Iterator<Arrow> 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);
}
}
}

View File

@ -7,14 +7,11 @@ import org.bukkit.entity.Player;
public class SpellSpeedBoost extends Spell implements SpellClick public class SpellSpeedBoost extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player p) public void castSpell(Player p)
{ {
int ticks = 30 * getSpellLevel(p) * 20; Wizards.getArcadeManager().GetCondition().Factory().Speed("Speed Boost", p, p, 20, getSpellLevel(p), false, false, false);
int potionLevel = getSpellLevel(p);
Wizards.getArcadeManager().GetCondition().Factory().Speed("Speed Boost", p, p, ticks, potionLevel, false, false, false); charge(p);
}
charge(p);
}
} }

View File

@ -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);
}
}
}

View File

@ -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<Block, Long> _wallExpires = new HashMap<Block, Long>();
@EventHandler
public void onUpdate(UpdateEvent event)
{
Iterator<Entry<Block, Long>> itel = _wallExpires.entrySet().iterator();
while (itel.hasNext())
{
Entry<Block, Long> 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);
}
}

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.wizards.spells;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Random;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
@ -29,137 +30,137 @@ import org.bukkit.event.EventHandler;
public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBlock public class SpellSummonWolves extends Spell implements SpellClick, SpellClickBlock
{ {
private HashMap<Wolf, Long> _summonedWolves = new HashMap<Wolf, Long>(); private HashMap<Wolf, Long> _summonedWolves = new HashMap<Wolf, Long>();
@Override @Override
public void castSpell(Player player, Block block) public void castSpell(Player player, Block block)
{ {
block = block.getRelative(BlockFace.UP); block = block.getRelative(BlockFace.UP);
if (!UtilBlock.airFoliage(block)) if (!UtilBlock.airFoliage(block))
{ {
block = player.getLocation().getBlock(); 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++) for (int i = 0; i < getSpellLevel(player); i++)
{ {
Wizards.CreatureAllowOverride = true; 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.setCollarColor(DyeColor.YELLOW);
wolf.setTamed(true); wolf.setTamed(true);
wolf.setOwner(player); wolf.setOwner(player);
wolf.setBreed(false); wolf.setBreed(false);
wolf.setCustomName(player.getDisplayName() + "'s Wolf"); wolf.setCustomName(player.getDisplayName() + "'s Wolf");
wolf.setRemoveWhenFarAway(false); wolf.setRemoveWhenFarAway(false);
wolf.setMaxHealth(2); wolf.setMaxHealth(0.5);
wolf.setHealth(2); wolf.setHealth(0.5);
// wolf.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 9001, 0));
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); UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, loc, 0.8F, 0, 0.8F, 0, 4);
player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.2F, 1); player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.2F, 1);
charge(player); charge(player);
} }
@EventHandler @EventHandler
public void onDamage(CustomDamageEvent event) public void onDamage(CustomDamageEvent event)
{ {
if (event.GetDamagerEntity(false) instanceof Wolf) if (event.GetDamagerEntity(false) instanceof Wolf)
{ {
Wolf wolf = (Wolf) event.GetDamagerEntity(false); Wolf wolf = (Wolf) event.GetDamagerEntity(false);
event.AddMult("Summoned Wolf", "Summoned Wolf", 0.3, true); event.AddMult("Summoned Wolf", "Summoned Wolf", 0.3, true);
AnimalTamer tamer = wolf.getOwner(); AnimalTamer tamer = wolf.getOwner();
if (tamer instanceof Player) if (tamer instanceof Player)
{ {
event.SetDamager((Player) tamer); event.SetDamager((Player) tamer);
event.setKnockbackOrigin(wolf.getLocation()); event.setKnockbackOrigin(wolf.getLocation());
} }
} }
} }
@EventHandler @EventHandler
public void onSecond(UpdateEvent event) public void onSecond(UpdateEvent event)
{ {
if (event.getType() == UpdateType.SEC) if (event.getType() == UpdateType.SEC)
{ {
Iterator<Wolf> itel = _summonedWolves.keySet().iterator(); Iterator<Wolf> itel = _summonedWolves.keySet().iterator();
while (itel.hasNext()) while (itel.hasNext())
{ {
Wolf wolf = itel.next(); Wolf wolf = itel.next();
AnimalTamer wolfOwner = wolf.getOwner(); AnimalTamer wolfOwner = wolf.getOwner();
if (!wolf.isValid() || _summonedWolves.get(wolf) < System.currentTimeMillis() || !(wolfOwner instanceof Player) if (!wolf.isValid() || _summonedWolves.get(wolf) < System.currentTimeMillis() || !(wolfOwner instanceof Player)
|| !Wizards.IsAlive((Entity) wolfOwner)) || !Wizards.IsAlive((Entity) wolfOwner))
{ {
if (wolf.isValid()) if (wolf.isValid())
{ {
wolf.getWorld().playEffect(wolf.getLocation(), Effect.EXPLOSION_HUGE, 0); wolf.getWorld().playEffect(wolf.getLocation(), Effect.EXPLOSION_HUGE, 0);
} }
wolf.remove(); wolf.remove();
itel.remove(); itel.remove();
} }
else else
{ {
if (wolf.getTarget() == null || !wolf.getTarget().isValid() || !Wizards.IsAlive(wolf.getTarget()) if (wolf.getTarget() == null || !wolf.getTarget().isValid() || !Wizards.IsAlive(wolf.getTarget())
|| wolf.getTarget().getLocation().distance(wolf.getLocation()) > 16) || wolf.getTarget().getLocation().distance(wolf.getLocation()) > 16)
{ {
double dist = 0; double dist = 0;
Player target = null; Player target = null;
for (Player player : Wizards.GetPlayers(true)) for (Player player : Wizards.GetPlayers(true))
{ {
if (!player.equals(wolfOwner)) if (!player.equals(wolfOwner))
{ {
double newDist = player.getLocation().distance(wolf.getLocation()); double newDist = player.getLocation().distance(wolf.getLocation());
if (newDist < 16 && (target == null || dist > newDist)) if (newDist < 16 && (target == null || dist > newDist))
{ {
dist = newDist; dist = newDist;
target = player; target = player;
} }
} }
} }
if (target != null) if (target != null)
{ {
wolf.setTarget(target); wolf.setTarget(target);
} }
else else
{ {
Location loc = ((Player) wolfOwner).getLocation(); Location loc = ((Player) wolfOwner).getLocation();
if (loc.distance(wolf.getLocation()) > 16) if (loc.distance(wolf.getLocation()) > 16)
{ {
wolf.teleport(loc); wolf.teleport(loc);
} }
} }
} }
} }
} }
} }
} }
@Override @Override
public void castSpell(Player player) public void castSpell(Player player)
{ {
castSpell(player, player.getLocation().getBlock().getRelative(BlockFace.DOWN)); castSpell(player, player.getLocation().getBlock().getRelative(BlockFace.DOWN));
} }
} }

View File

@ -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<TeleportRune> _teleportRunes = new ArrayList<TeleportRune>();
@EventHandler
public void onTick(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
Iterator<TeleportRune> 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");
}
}
}

View File

@ -6,19 +6,14 @@ import java.util.List;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock; 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.UpdateType;
import mineplex.core.updater.event.UpdateEvent; 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.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import nautilus.game.arcade.game.games.wizards.spells.subclasses.TrapRune; 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.Location;
import org.bukkit.Sound; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -26,179 +21,52 @@ import org.bukkit.event.EventHandler;
public class SpellTrapRune extends Spell implements SpellClick public class SpellTrapRune extends Spell implements SpellClick
{ {
private ArrayList<TrapRune> _runes = new ArrayList<TrapRune>(); private ArrayList<TrapRune> _runes = new ArrayList<TrapRune>();
@EventHandler @EventHandler
public void onTick(UpdateEvent event) public void onTick(UpdateEvent event)
{ {
if (event.getType() == UpdateType.TICK) if (event.getType() == UpdateType.TICK)
{ {
Iterator<TrapRune> itel = _runes.iterator(); Iterator<TrapRune> itel = _runes.iterator();
while (itel.hasNext()) while (itel.hasNext())
{ {
TrapRune rune = itel.next(); 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;
}
}
}
}
}
}
}
}
public void initialParticles(Location trapLocation, double trapSize) if (rune.onRuneTick())
{ {
for (Location loc : getBox(trapLocation, trapSize, 0.3)) itel.remove();
{ }
for (double y = 0; y < 1; y += 0.2) }
{ }
trapLocation.getWorld().spigot().playEffect(loc, Effect.FLAME, 0, 0, 0, 0, 0, 0, 1, 30); }
}
}
}
private ArrayList<Location> getBox(Location trapLocation, double trapSize, double spacing) @Override
{ public void castSpell(Player p)
ArrayList<Location> boxLocs = getBoxCorners(trapLocation, trapSize); {
ArrayList<Location> returns = new ArrayList<Location>(); List<Block> 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; if (loc.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR)
returns.addAll(UtilShapes.getLinesDistancedPoints(boxLocs.get(i), boxLocs.get(a), spacing)); {
returns.add(boxLocs.get(i)); return;
}
} TrapRune rune = new TrapRune(Wizards, p, loc, getSpellLevel(p));
return returns; if (!rune.isValid())
} {
p.sendMessage(C.cGreen + "Cannot draw rune on wall");
return;
}
private ArrayList<Location> getBoxCorners(Location center, double boxSize) rune.initialParticles();
{
ArrayList<Location> boxPoints = new ArrayList<Location>();
boxPoints.add(center.clone().add(-boxSize, 0, -boxSize)); _runes.add(rune);
boxPoints.add(center.clone().add(boxSize, 0, -boxSize)); charge(p);
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<Block> 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);
}
}
} }

View File

@ -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<Block, Integer> commonBlocks = new HashMap<Block, Integer>();
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<Block, Integer> 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);
}
}

View File

@ -1,62 +1,128 @@
package nautilus.game.arcade.game.games.wizards.spells; package nautilus.game.arcade.game.games.wizards.spells;
import mineplex.core.common.util.C; import java.util.ArrayList;
import mineplex.core.common.util.UtilShapes; import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget;
import nautilus.game.arcade.game.games.wizards.Spell; import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class SpellWizardsCompass extends Spell implements SpellClick public class SpellWizardsCompass extends Spell implements SpellClick
{ {
@Override @Override
public void castSpell(Player p) public void castSpell(Player p)
{ {
double dist = 9999; Location loc = p.getEyeLocation().subtract(0, 1, 0);
Player closestPlayer = null;
for (Player player : Wizards.GetPlayers(true)) final ArrayList<Integer[]> colors = new ArrayList<Integer[]>();
{
double newDist = player.getLocation().distance(p.getLocation());
if (newDist > 10 && (closestPlayer == null || newDist < dist)) for (int x = -1; x <= 1; x++)
{ {
closestPlayer = player; for (int y = -1; y <= 1; y++)
dist = newDist; {
} for (int z = -1; z <= 1; z++)
} {
colors.add(new Integer[]
{
x, y, z
});
}
}
}
if (closestPlayer != null) Collections.shuffle(colors);
{
int particlesPlayed = 0;
for (Location loc : UtilShapes.getLinesDistancedPoints( for (Player enemy : Wizards.GetPlayers(true))
p.getEyeLocation().subtract(p.getEyeLocation().getDirection().normalize().multiply(-0.3)).subtract(0, .5, 0), {
closestPlayer.getEyeLocation(), 0.3)) if (enemy == p)
{ {
continue;
}
if (particlesPlayed++ > 13) final double playerDist = Math.min(7, UtilMath.offset(enemy, p));
{
break;
}
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); hologram.setHologramTarget(HologramTarget.WHITELIST);
} hologram.addPlayer(p);
else
{
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<Location, Integer> locations = new HashMap<Location, Integer>();
public void run()
{
tick++;
Iterator<Entry<Location, Integer>> itel = locations.entrySet().iterator();
while (itel.hasNext())
{
Entry<Location, Integer> entry = itel.next();
if ((entry.getValue() + tick) % 3 == 0)
{
// Colored redstone dust
UtilParticle.PlayParticle(ParticleType.RED_DUST, entry.getKey(), ints[0], ints[1], ints[2], 1, 0);
}
if (entry.getValue() < tick)
{
itel.remove();
}
}
if (dist <= playerDist * 10)
{
for (int a = 0; a < 2; a++)
{
// Colored redstone dust
UtilParticle.PlayParticle(ParticleType.RED_DUST, location, ints[0], ints[1], ints[2], 1, 0);
locations.put(location.clone(), tick + 50);
location.add(traj);
dist++;
}
}
else if (locations.isEmpty())
{
hologram.stop();
cancel();
}
}
}.runTaskTimer(Wizards.getArcadeManager().getPlugin(), 0, 0);
}
p.playSound(p.getLocation(), Sound.ZOMBIE_UNFECT, 1.5F, 1);
charge(p);
}
} }

View File

@ -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);
}
}
}

View File

@ -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<Location> 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;
}
}

View File

@ -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<UUID, Long> _launchedEntities = new HashMap<UUID, Long>();
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;
}
}

View File

@ -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);
}
}

View File

@ -1,15 +1,188 @@
package nautilus.game.arcade.game.games.wizards.spells.subclasses; package nautilus.game.arcade.game.games.wizards.spells.subclasses;
import java.util.ArrayList;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.minecraft.game.core.explosion.CustomExplosion;
import nautilus.game.arcade.game.games.wizards.Wizards;
import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class TrapRune public class TrapRune
{ {
// TODO Methods and potentially move code into here
public Location RuneLocation; private Location _runeLocation;
public float RuneSize; private float _runeSize;
public Player RuneCaster; private Player _runeCaster;
public int TicksLived; private int _ticksLived;
private Wizards _wizards;
private int _spellLevel;
public boolean onRuneTick()
{
if (!_runeCaster.isOnline() || UtilPlayer.isSpectator(_runeCaster))
{
return true;
}
else if (_ticksLived++ > 2000)
{
return true;
}
else
{
if (_ticksLived <= 100)
{
if (_ticksLived % 15 == 0)
{
initialParticles();
}
if (_ticksLived == 100)
{
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, _runeLocation, 0, _runeSize / 4, 0, _runeSize / 4,
(int) (_runeSize * 10));
}
}
else
{
if (!isValid())
{
trapCard();
return true;
}
else
{
for (Player player : _wizards.GetPlayers(true))
{
if (isInTrap(player.getLocation()))
{
trapCard();
return true;
}
}
}
}
}
return false;
}
public TrapRune(Wizards wizards, Player player, Location location, int spellLevel)
{
_wizards = wizards;
_runeCaster = player;
_runeLocation = location;
_spellLevel = spellLevel;
_runeSize = Math.max(1, spellLevel * 0.8F);
}
public void initialParticles()
{
for (Location loc : getBox(0.3))
{
for (double y = 0; y < 1; y += 0.2)
{
_runeLocation.getWorld().spigot().playEffect(loc, Effect.SMALL_SMOKE, 0, 0, 0, 0, 0, 0, 1, 30);
}
}
}
public ArrayList<Location> getBox(double spacing)
{
ArrayList<Location> boxLocs = getBoxCorners();
ArrayList<Location> returns = new ArrayList<Location>();
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<Location> getBoxCorners()
{
ArrayList<Location> boxPoints = new ArrayList<Location>();
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);
}
}
}
} }

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -76,10 +77,10 @@ public class IcePathData
loc.add(dir.clone().multiply(0.2)); loc.add(dir.clone().multiply(0.2));
if (loc.getBlock().getTypeId() == 79) if (loc.getBlock().getType() == Material.ICE)
continue; 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())) if (!_blocks.contains(loc.getBlock()))
{ {