Merge remote-tracking branch 'origin/clans_custom_gear' into clans/world-events

Conflicts:
	Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java
This commit is contained in:
Shaun Bennett 2015-06-02 20:45:53 -05:00
commit d8acb0aae6
302 changed files with 14261 additions and 5426 deletions

View File

@ -17,7 +17,7 @@
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.4.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
</root>
</artifact>
</component>

View File

@ -4,7 +4,7 @@
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="compileArcade" description="Arcade Compilation">
<target name="compileArcade1" description="Arcade Compilation Step 1">
<javac srcdir="../Mineplex.Core.Common/src" destdir="../Mineplex.Core.Common/bin" classpathref="classpath"/>
<jar jarfile="../bin/Mineplex.Core.Common.jar">
<fileset dir="../Mineplex.Core.Common/bin">
@ -12,6 +12,32 @@
</fileset>
</jar>
<copy file="../bin/Mineplex.Core.Common.jar" todir="../Libraries"/>
</target>
<target name="compileArcade2" description="Arcade Compilation Step 2">
<path id="classpathCommon">
<fileset dir="../Libraries" includes="**/*.jar"/>
</path>
<javac srcdir="../Mineplex.ServerData/src" destdir="../Mineplex.ServerData/bin" classpathref="classpathCommon"/>
<jar jarfile="../bin/Mineplex.ServerData.jar">
<fileset dir="../Mineplex.ServerData/bin">
<include name="**/*.class"/>
</fileset>
</jar>
<copy file="../bin/Mineplex.ServerData.jar" todir="../Libraries"/>
</target>
<target name="compileArcade3" description="Arcade Compilation Step 3">
<path id="classpathCommon">
<fileset dir="../Libraries" includes="**/*.jar"/>
</path>
<javac srcdir="../Mineplex.Database/src" destdir="../Mineplex.Database/bin" classpathref="classpathCommon"/>
<jar jarfile="../bin/Mineplex.Database.jar">
<fileset dir="../Mineplex.Database/bin">
<include name="**/*.class"/>
</fileset>
</jar>
<copy file="../bin/Mineplex.Database.jar" todir="../Libraries"/>
</target>
<target name="compileArcade4" description="Arcade Compilation Step 4">
<path id="classpathCommon">
<fileset dir="../Libraries" includes="**/*.jar"/>
</path>
@ -22,13 +48,15 @@
</fileset>
</jar>
<copy file="../bin/Mineplex.Core.jar" todir="../Libraries"/>
</target>
<target name="compileArcade" description="Arcade Compilation Step #">
</target>
<target name="compileArcade5" description="Arcade Compilation Step 5">
<path id="classpathCommon">
<fileset dir="../Libraries" includes="**/*.jar"/>
</path>
<javac srcdir="../Mineplex.Minecraft.Game.Core/src" destdir="../Mineplex.Minecraft.Game.Core/bin" classpathref="classpathCommon"/>
<javac srcdir="../Mineplex.Minecraft.Game.ClassCombat/src" destdir="../Mineplex.Minecraft.Game.ClassCombat/bin" classpathref="classpathCommon"/>
<javac srcdir="../Mineplex.Database/src" destdir="../Mineplex.Database/bin" classpathref="classpathCommon"/>
<javac srcdir="../Mineplex.ServerData/src" destdir="../Mineplex.ServerData/bin" classpathref="classpathCommon"/>
<javac srcdir="../Nautilus.Game.Arcade/src" destdir="../Nautilus.Game.Arcade/bin" classpathref="classpathCommon"/>
</target>
<target name ="Arcade" description="Arcade">

View File

@ -0,0 +1,179 @@
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
import java.util.HashMap;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
import net.minecraft.server.v1_7_R4.PacketListener;
import net.minecraft.server.v1_7_R4.PacketPlayOutListener;
public class PacketPlayOutWorldParticles extends Packet {
private String a;
private float b;
private float c;
private float d;
private float e;
private float f;
private float g;
private float h;
private int i;
private boolean _displayFar;
public PacketPlayOutWorldParticles() {
}
public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i) {
this(s, f, f1, f2, f3, f4, f5, f6, i, false);
}
public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i, boolean displayFar) {
this.a = s;
this.b = f;
this.c = f1;
this.d = f2;
this.e = f3;
this.f = f4;
this.g = f5;
this.h = f6;
this.i = i;
_displayFar = displayFar;
}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
this.a = packetdataserializer.c(64);
this.b = packetdataserializer.readFloat();
this.c = packetdataserializer.readFloat();
this.d = packetdataserializer.readFloat();
this.e = packetdataserializer.readFloat();
this.f = packetdataserializer.readFloat();
this.g = packetdataserializer.readFloat();
this.h = packetdataserializer.readFloat();
this.i = packetdataserializer.readInt();
}
public void b(PacketDataSerializer packetdataserializer) throws IOException {
String[] parts = this.a.split("_");
PacketPlayOutWorldParticles.Particle particle = PacketPlayOutWorldParticles.Particle.find(parts[0]);
if(particle == null) {
particle = PacketPlayOutWorldParticles.Particle.CRIT;
}
if(packetdataserializer.version < 17) {
packetdataserializer.a(this.a);
} else {
packetdataserializer.writeInt(particle.ordinal());
packetdataserializer.writeBoolean(_displayFar);
}
packetdataserializer.writeFloat(this.b);
packetdataserializer.writeFloat(this.c);
packetdataserializer.writeFloat(this.d);
packetdataserializer.writeFloat(this.e);
packetdataserializer.writeFloat(this.f);
packetdataserializer.writeFloat(this.g);
packetdataserializer.writeFloat(this.h);
packetdataserializer.writeInt(this.i);
if(packetdataserializer.version >= 17) {
for(int i = 0; i < particle.extra; ++i) {
int toWrite = 0;
if(parts.length - 1 > i) {
try {
toWrite = Integer.parseInt(parts[i + 1]);
if(particle.extra == 1 && parts.length == 3) {
++i;
toWrite |= Integer.parseInt(parts[i + 1]) << 12;
}
} catch (NumberFormatException var7) {
;
}
}
packetdataserializer.b(toWrite);
}
}
}
public void a(PacketPlayOutListener packetplayoutlistener) {
packetplayoutlistener.a(this);
}
public void handle(PacketListener packetlistener) {
this.a((PacketPlayOutListener)packetlistener);
}
private static enum Particle {
EXPLOSION_NORMAL("explode"),
EXPLOSION_LARGE("largeexplode"),
EXPLOSION_HUGE("hugeexplosion"),
FIREWORKS_SPARK("fireworksSpark"),
WATER_BUBBLE("bubble"),
WATER_SPLASH("splash"),
WATER_WAKE("wake"),
SUSPENDED("suspended"),
SUSPENDED_DEPTH("depthsuspend"),
CRIT("crit"),
CRIT_MAGIC("magicCrit"),
SMOKE_NORMAL("smoke"),
SMOKE_LARGE("largesmoke"),
SPELL("spell"),
SPELL_INSTANT("instantSpell"),
SPELL_MOB("mobSpell"),
SPELL_MOB_AMBIENT("mobSpellAmbient"),
SPELL_WITCH("witchMagic"),
DRIP_WATER("dripWater"),
DRIP_LAVA("dripLava"),
VILLAGER_ANGRY("angryVillager"),
VILLAGER_HAPPY("happyVillager"),
TOWN_AURA("townaura"),
NOTE("note"),
PORTAL("portal"),
ENCHANTMENT_TABLE("enchantmenttable"),
FLAME("flame"),
LAVA("lava"),
FOOTSTEP("footstep"),
CLOUD("cloud"),
REDSTONE("reddust"),
SNOWBALL("snowballpoof"),
SNOW_SHOVEL("snowshovel"),
SLIME("slime"),
HEART("heart"),
BARRIER("barrier"),
ICON_CRACK("iconcrack", 2),
BLOCK_CRACK("blockcrack", 1),
BLOCK_DUST("blockdust", 1),
WATER_DROP("droplet"),
ITEM_TAKE("take"),
MOB_APPEARANCE("mobappearance");
public final String name;
public final int extra;
private static final HashMap<String, PacketPlayOutWorldParticles.Particle> particleMap;
private Particle(String name) {
this(name, 0);
}
private Particle(String name, int extra) {
this.name = name;
this.extra = extra;
}
public static PacketPlayOutWorldParticles.Particle find(String part) {
return (PacketPlayOutWorldParticles.Particle)particleMap.get(part);
}
static {
particleMap = new HashMap();
PacketPlayOutWorldParticles.Particle[] var0 = values();
int var1 = var0.length;
for(int var2 = 0; var2 < var1; ++var2) {
PacketPlayOutWorldParticles.Particle particle = var0[var2];
particleMap.put(particle.name, particle);
}
}
}
}

Binary file not shown.

View File

@ -1,5 +1,6 @@
package mineplex.bungee.motd;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@ -53,22 +54,12 @@ public class MotdManager implements Listener, Runnable
public void run()
{
// Add in default MOTD listing to database
/*
if (!_repository.elementExists("MainMotd"))
{
_repository.removeElement("MainMotd");
List<String> lines = new ArrayList<String>();
lines.add(" §a§lDouble Gems for 1.8 Players!");
lines.add(" §e§lChampions Update §a§lBalance Patch");
lines.add(" §6§lSpecial Egg Baskets!");
lines.add(" §e§lBunny Morph §a§lLimited Time!");
lines.add(" §d§lHero Sale §a§l33% Off");
lines.add(" §a§lDouble Gems for 1.8 Players!");
lines.add(" §d§lMaster Builders§f - §d§lWizards§f - §d§lGravity");
//lines.add(" §d§lRank Sale §a§l40% Off");
updateMainMotd(" §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r", lines);
}
*/
GlobalMotd motd = _repository.getElement("MainMotd");

View File

@ -4,11 +4,16 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import net.minecraft.server.v1_7_R4.Blocks;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.WorldServer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.inventory.ItemStack;
public class UtilBlock
@ -304,7 +309,13 @@ public class UtilBlock
return blockList;
}
public static HashMap<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>();
int iR = (int)dR + 1;
@ -317,8 +328,10 @@ public class UtilBlock
double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation());
if (offset <= dR)
blockList.put(curBlock, 1 - (offset/dR));
if (offset <= dR && !(hollow && offset < dR - 1))
{
blockList.put(curBlock, 1 - (offset / dR));
}
}
return blockList;
@ -369,6 +382,74 @@ public class UtilBlock
return block.getRelative(BlockFace.UP);
}
/**
*
* @param location of explosion
* @param strength of explosion
* @param damageBlocksEqually - Treat all blocks as durability of dirt
* @param ensureDestruction - Ensure that the closest blocks are destroyed at least
* @return
*/
public static ArrayList<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)
{
ArrayList<Block> blocks = new ArrayList<Block>();

View File

@ -2,126 +2,230 @@ package mineplex.core.common.util;
import java.lang.reflect.Field;
import mineplex.core.common.util.UtilParticle.ViewDist;
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class UtilParticle
{
public enum ParticleType
public enum ViewDist
{
HUGE_EXPLOSION("hugeexplosion"),
LARGE_EXPLODE("largeexplode"),
FIREWORKS_SPARK("fireworksSpark"),
BUBBLE("bubble"),
SUSPEND("suspended"),
DEPTH_SUSPEND("depthSuspend"),
TOWN_AURA("townaura"),
CRIT("crit"),
MAGIC_CRIT("magicCrit"),
MOB_SPELL("mobSpell"),
MOB_SPELL_AMBIENT("mobSpellAmbient"),
SPELL("spell"),
INSTANT_SPELL("instantSpell"),
WITCH_MAGIC("witchMagic"),
NOTE("note"),
PORTAL("portal"),
ENCHANTMENT_TABLE("enchantmenttable"),
EXPLODE("explode"),
FLAME("flame"),
LAVA("lava"),
FOOTSTEP("footstep"),
SPLASH("splash"),
LARGE_SMOKE("largesmoke"),
CLOUD("cloud"),
RED_DUST("reddust"),
SNOWBALL_POOF("snowballpoof"),
DRIP_WATER("dripWater"),
DRIP_LAVA("dripLava"),
DROPLET("droplet"),
SNOW_SHOVEL("snowshovel"),
SLIME("slime"),
HEART("heart"),
ANGRY_VILLAGER("angryVillager"),
HAPPY_VILLAGER("happyVillager");
SHORT(8),
NORMAL(24),
LONG(48),
LONGER(96),
MAX(256);
public String particleName;
private int _dist;
ParticleType(String particleName)
{
this.particleName = particleName;
}
ViewDist(int dist)
{
_dist = dist;
}
public int getDist()
{
return _dist;
}
}
public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count)
{
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles();
for (Field field : packet.getClass().getDeclaredFields())
{
try
{
field.setAccessible(true);
String fieldName = field.getName();
switch (fieldName)
{
case "a":
field.set(packet, type.particleName); //Particle name
break;
case "b":
field.setFloat(packet, (float)location.getX()); //Block X
break;
case "c":
field.setFloat(packet, (float)location.getY()); //Block Y
break;
case "d":
field.setFloat(packet, (float)location.getZ()); //Block Z
break;
case "e":
field.setFloat(packet, offsetX); //Random X Offset
break;
case "f":
field.setFloat(packet, offsetY); //Random Y Offset
break;
case "g":
field.setFloat(packet, offsetZ); //Random Z Offset
break;
case "h":
field.setFloat(packet, speed); //Speed/data of particles
break;
case "i":
field.setInt(packet, count); //Amount of particles
break;
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
return;
}
}
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count)
public enum ParticleType
{
for (Player player : UtilServer.getPlayers())
ANGRY_VILLAGER("angryVillager", "Lightning Cloud", Material.INK_SACK, (byte) 11),
BLOCK_CRACK("blockcrack_1_0")
{
//Dont send to players who cannot see it!
if (type != ParticleType.FIREWORKS_SPARK &&
type != ParticleType.LARGE_EXPLODE &&
type != ParticleType.HUGE_EXPLOSION)
@Override
public String getParticle(Material type, int data)
{
if (UtilMath.offset(player.getLocation(), location) > 24)
{
continue;
}
return "blockcrack_" + type.getId() + "_" + data;
}
},
BLOCK_DUST("blockdust_1_0")
{
@Override
public String getParticle(Material type, int data)
{
return "blockdust_" + type.getId() + "_" + data;
}
},
BUBBLE("bubble"),
CLOUD("cloud", "White Smoke", Material.INK_SACK, (byte) 7),
CRIT("crit", "Brown Magic", Material.INK_SACK, (byte) 14),
DEPTH_SUSPEND("depthSuspend"),
DRIP_LAVA("dripLava", "Lava Drip", Material.LAVA_BUCKET, (byte) 0),
DRIP_WATER("dripWater", "Water Drop", Material.WATER_BUCKET, (byte) 0),
DROPLET("droplet", "Water Splash", Material.INK_SACK, (byte) 4),
ENCHANTMENT_TABLE("enchantmenttable", "Enchantment Words", Material.BOOK, (byte) 0),
EXPLODE("explode", "Big White Smoke", Material.INK_SACK, (byte) 15),
FIREWORKS_SPARK("fireworksSpark", "White Sparkle", Material.GHAST_TEAR, (byte) 0),
FLAME("flame", "Flame", Material.BLAZE_POWDER, (byte) 0),
FOOTSTEP("footstep", "Foot Step", Material.LEATHER_BOOTS, (byte) 0),
HAPPY_VILLAGER("happyVillager", "Emerald Sparkle", Material.EMERALD, (byte) 0),
HEART("heart", "Love Heart", Material.APPLE, (byte) 0),
HUGE_EXPLOSION("hugeexplosion", "Huge Explosion", Material.TNT, (byte) 0),
ICON_CRACK("iconcrack_1_0")
{
@Override
public String getParticle(Material type, int data)
{
return "iconcrack_" + type.getId() + "_" + data;
}
},
INSTANT_SPELL("instantSpell"),
LARGE_EXPLODE("largeexplode", "Explosion", Material.FIREBALL, (byte) 0),
LARGE_SMOKE("largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0),
LAVA("lava", "Lava Debris", Material.LAVA, (byte) 0),
MAGIC_CRIT("magicCrit", "Teal Magic", Material.INK_SACK, (byte) 6),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
*/
MOB_SPELL("mobSpell", "Black Swirls", Material.getMaterial(2263), (byte) 0),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
*/
MOB_SPELL_AMBIENT("mobSpellAmbient", "Transparent Black Swirls", Material.getMaterial(2266), (byte) 0),
NOTE("note", "Musical Note", Material.JUKEBOX, (byte) 0),
PORTAL("portal", "Portal Effect", Material.INK_SACK, (byte) 5),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz. Offset y if 0 will default to 1, counter by making it 0.0001
*/
RED_DUST("reddust", "Red Smoke", Material.INK_SACK, (byte) 1),
SLIME("slime", "Slime Particles", Material.SLIME_BALL, (byte) 0),
SNOW_SHOVEL("snowshovel", "Snow Puffs", Material.SNOW_BALL, (byte) 0),
SNOWBALL_POOF("snowballpoof"),
SPELL("spell", "White Swirls", Material.getMaterial(2264), (byte) 0),
SPLASH("splash"),
SUSPEND("suspended"),
TOWN_AURA("townaura", "Black Specks", Material.COAL, (byte) 0),
WITCH_MAGIC("witchMagic", "Purple Magic", Material.INK_SACK, (byte) 13);
public String particleName;
private boolean _friendlyData;
private String _friendlyName;
private Material _material;
private byte _data;
ParticleType(String particleName)
{
this.particleName = particleName;
_friendlyData = false;
}
ParticleType(String particleName, String friendlyName, Material material, byte data)
{
this.particleName = particleName;
_friendlyData = true;
_friendlyName = friendlyName;
_material = material;
_data = data;
}
public String getParticle(Material type, int data)
{
return particleName;
}
public boolean hasFriendlyData()
{
return _friendlyData;
}
public String getFriendlyName()
{
if (_friendlyName == null)
{
return toString();
}
PlayParticle(player, type, location, offsetX, offsetY, offsetZ, speed, count);
return _friendlyName;
}
public Material getMaterial()
{
return _material;
}
public byte getData()
{
return _data;
}
public static ParticleType getFromFriendlyName(String name)
{
for (ParticleType type : values())
{
if (type.hasFriendlyData() && type.getFriendlyName().equals(name))
return type;
}
return null;
}
}
private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY,
float offsetZ, float speed, int count, boolean displayFar)
{
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, displayFar);
return packet;
}
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
{
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, players);
}
public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
{
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
for (Player player : players)
{
//Out of range for player
if (UtilMath.offset(player.getLocation(), location) > dist.getDist())
continue;
UtilPlayer.sendPacket(player, packet);
}
}
}

View File

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

@ -0,0 +1,82 @@
package mineplex.core.common.util;
import org.bukkit.entity.*;
public class UtilSkull
{
public static byte getSkullData(Entity entity)
{
if (entity instanceof Skeleton)
{
Skeleton sk = ((Skeleton) entity);
if (sk.getSkeletonType() == Skeleton.SkeletonType.WITHER)
return 1;
else return 0;
}
else if (entity instanceof Zombie || entity instanceof Giant)
{
return 2;
}
else if (entity instanceof Creeper)
{
return 4;
}
else
return 3;
}
public static boolean isPlayerHead(byte data)
{
return data == 3;
}
public static String getPlayerHeadName(Entity entity)
{
String name = "MHF_Alex";
// order is important for some of these
if (entity instanceof Blaze)
name = "MHF_Blaze";
else if (entity instanceof CaveSpider)
name = "MHF_CaveSpider";
else if (entity instanceof Spider)
name = "MHF_Spider";
else if (entity instanceof Chicken)
name = "MHF_Chicken";
else if (entity instanceof MushroomCow)
name = "MHF_MushroomCow";
else if (entity instanceof Cow)
name = "MHF_Cow";
else if (entity instanceof Creeper)
name = "MHF_Creeper";
else if (entity instanceof Enderman)
name = "MHF_Enderman";
else if (entity instanceof Ghast)
name = "MHF_Ghast";
else if (entity instanceof Golem)
name = "MHF_Golem";
else if (entity instanceof PigZombie)
name = "MHF_PigZombie";
else if (entity instanceof MagmaCube)
name = "MHF_LavaSlime";
else if (entity instanceof Slime)
name = "MHF_Slime";
else if (entity instanceof Ocelot)
name = "MHF_Ocelot";
else if (entity instanceof PigZombie)
name = "MHF_PigZombie";
else if (entity instanceof Pig)
name = "MHF_Pig";
else if (entity instanceof Sheep)
name = "MHF_Pig";
else if (entity instanceof Squid)
name = "MHF_Squid";
else if (entity instanceof HumanEntity)
name = "MHF_Steve";
else if (entity instanceof Villager)
name = "MHF_Villager";
return name;
}
}

View File

@ -46,7 +46,7 @@ public class UtilTextBottom
amount = 1 - amount;
//Generate Bar
int bars = 52;
int bars = 24;
String progressBar = C.cGreen + "";
boolean colorChange = false;
for (int i=0 ; i<bars ; i++)
@ -57,7 +57,7 @@ public class UtilTextBottom
colorChange = true;
}
progressBar += "|";
progressBar += "";
}
//Send to Player

View File

@ -84,13 +84,20 @@ public enum Achievement
new int[]{1},
AchievementCategory.SURVIVAL_GAMES),
//Survival Games
//UHC
UHC_WINS("Ultimate Winner", 600,
new String[]{"Ultra Hardcore.Wins"},
new String[]{"Win 10 games of Ultra Hardcore"},
new int[]{10},
AchievementCategory.UHC),
//UHC
WIZARDS_WINS("Supreme Wizard", 600,
new String[]{"Wizards.Wins"},
new String[]{"Win 50 games of Wizards"},
new int[]{10},
AchievementCategory.WIZARDS),
//Smash Mobs
SMASH_MOBS_WINS("SO SUPER!", 600,
new String[]{"Super Smash Mobs.Wins"},

View File

@ -34,6 +34,16 @@ public enum AchievementCategory
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.IRON_SWORD, 0, GameCategory.SURVIVAL, "Horseman Kit"),
UHC("Ultra Hardcore", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
WIZARDS("Wizards", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
MINE_STRIKE("MineStrike", null,
new String[] {"Wins", "Losses", "Kills", "Deaths", "GemsEarned"},
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
@ -66,10 +76,7 @@ public enum AchievementCategory
new String[] {"Wins", "Losses", "Kills", "Deaths", "Gems Earned"},
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"),
UHC("Ultra Hardcore", null,
new String[] { "Wins", "Losses", "Kills", "Deaths", "GemsEarned" },
new String[] { "Wins", "Losses", "Kills", "Deaths", "Gems Earned" },
Material.GOLD_INGOT, 0, GameCategory.SURVIVAL, "Extra Class Skills"),
//Arcade
DRAGONS("Dragons", null,

View File

@ -35,6 +35,8 @@ public class AchievementManager extends MiniPlugin
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
private boolean _shopEnabled = true;
public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager)
{
super("Achievement Manager", statsManager.getPlugin());
@ -177,6 +179,9 @@ public class AchievementManager extends MiniPlugin
@EventHandler
public void openShop(PlayerInteractEvent event)
{
if (!_shopEnabled)
return;
if (event.hasItem() && event.getItem().getType() == Material.SKULL_ITEM)
{
event.setCancelled(true);
@ -217,4 +222,9 @@ public class AchievementManager extends MiniPlugin
return Achievement.getExperienceString(level) + " " + ChatColor.RESET;
}
public void setShopEnabled(boolean var)
{
_shopEnabled = var;
}
}

View File

@ -207,82 +207,59 @@ public class Chat extends MiniPlugin
if (event.isAsynchronous())
{
final Player player = event.getPlayer();
//final String plyrname = player.toString();
final String plyrname = player.getUniqueId().toString();
final String msg = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim();
//final String filtertype = "chat";
final String filtertype = "moderate";
final String dname = player.getPlayerListName();
String filteredMessage = getFilteredMessage(event.getPlayer(), event.getMessage());
JSONObject message = buildJsonChatObject(filtertype, dname, plyrname, msg, _serverName, 1);
String response = getResponseFromCleanSpeak(message, filtertype);
if (response == null)
for (Player onlinePlayer : event.getRecipients())
{
System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak.");
return;
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
}
/* TESTING OUTPUT - POSSIBLY USEFUL
System.out.println(message);
System.out.println(response);
System.out.println(JSONValue.parse(response));
//NullPointerException occasionally happening, JSONValue.parse(String) returns null randomly, why?
event.setCancelled(true);
}
}
for (Object o : ((JSONObject)JSONValue.parse(response)).values())
{
System.out.println(o.toString());
}
*/
public String getFilteredMessage(Player player, String originalMessage)
{
final String playerName = player.getUniqueId().toString();
originalMessage = originalMessage.replaceAll("[^\\x00-\\x7F]", "").trim();
final String filterType = "moderate";
final String displayName = player.getPlayerListName();
String filteredMsg = "";
JSONObject message = buildJsonChatObject(filterType, displayName, playerName, originalMessage, _serverName, 1);
String response = getResponseFromCleanSpeak(message, filterType);
filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString();
if (filteredMsg.contains("parts"))
{
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("parts").toString();
filteredMsg = filteredMsg.replace('[', ' ').replace(']', ' ').trim();
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("replacement").toString();
if (response == null)
{
System.out.println("[ERROR] Unable to filter chat message...thanks a lot CleanSpeak.");
return originalMessage;
}
for (Player onlinePlayer : event.getRecipients())
{
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMsg));
}
/* TESTING OUTPUT - POSSIBLY USEFUL
System.out.println(message);
System.out.println(response);
System.out.println(JSONValue.parse(response));
//NullPointerException occasionally happening, JSONValue.parse(String) returns null randomly, why?
event.setCancelled(true);
}
for (Object o : ((JSONObject)JSONValue.parse(response)).values())
{
System.out.println(o.toString());
}
*/
/*
int risk = Integer.parseInt(((JSONObject) JSONValue.parse(response)).get("risk").toString());
String filteredMsg = "";
if (risk >= 5)
{
String filteredMessage = event.getMessage().replaceAll("[^\\x00-\\x7F]", "").trim();
filteredMsg = ((JSONObject) JSONValue.parse(response)).get("content").toString();
if (filteredMsg.contains("parts"))
{
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("parts").toString();
filteredMsg = filteredMsg.replace('[', ' ').replace(']', ' ').trim();
filteredMsg = ((JSONObject) JSONValue.parse(filteredMsg)).get("replacement").toString();
if (parseHashes(response) == null)
event.setMessage(ChatColor.RED + msg);
else
{
JSONArray hashindex = parseHashes(response);
String newmessage = hasher(hashindex, msg);
String badmessage = (new StringBuilder().append(newmessage)).toString();
if (newmessage.contains("*"))
{
filteredMessage = badmessage;
}
}
for (Player onlinePlayer : event.getRecipients())
{
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
}
event.setCancelled(true);
}
*/
return filteredMsg;
}
else
{
return originalMessage;
}
}

View File

@ -154,13 +154,20 @@ public class CosmeticManager extends MiniPlugin
_gadgetManager.setActiveItemSlot(i-1);
}
public void setActive(boolean b)
public void setActive(boolean showInterface)
{
_showInterface = b;
_showInterface = showInterface;
if (!b)
if (!showInterface)
{
for (Player player : UtilServer.getPlayers())
player.getOpenInventory().close();
{
if (player.getOpenInventory().getTopInventory().getHolder() != player)
{
player.closeInventory();
}
}
}
}
public void disableItemsForGame()

View File

@ -40,9 +40,10 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
@Override
public void addCommands()
{
addCommand(new GemCommand(this));
addCommand(new CoinCommand(this));
addCommand(new GoldCommand(this));
// TODO: Re-add commands? Where are command implementations, seen as missing at the moment.
//addCommand(new GemCommand(this));
//addCommand(new CoinCommand(this));
//addCommand(new GoldCommand(this));
}
@EventHandler

View File

@ -145,7 +145,8 @@ public class Donor
public void addGold(int amount)
{
_gold += amount;
_gold = Math.max(0, _gold + amount);
}
public List<CoinTransactionToken> getCoinTransactions()

View File

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

View File

@ -21,6 +21,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.recharge.Recharge;
@ -117,7 +118,8 @@ public class ItemBatGun extends ItemGadget
//Effect
bat.getWorld().playSound(bat.getLocation(), Sound.BAT_HURT, 1f, 1f);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3,
ViewDist.NORMAL, UtilServer.getPlayers());
bat.remove();
@ -138,7 +140,8 @@ public class ItemBatGun extends ItemGadget
for (Bat bat : _bats.get(player))
{
if (bat.isValid())
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, bat.getLocation(), 0, 0, 0, 0, 3,
ViewDist.NORMAL, UtilServer.getPlayers());
bat.remove();
}

View File

@ -11,7 +11,9 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.disguises.DisguiseBlaze;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget;
@ -65,8 +67,12 @@ public class MorphBlaze extends MorphGadget
player.eject();
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.2f, (float)(Math.random()));
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0f, 3);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 1, 0), 0.1f, 0.1f, 0.1f, 0f, 1);
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0f, 3,
ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 1, 0),
0.1f, 0.1f, 0.1f, 0f, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
UtilAction.velocity(player, 0.8, 0.1, 1, true);
}
}

View File

@ -31,6 +31,7 @@ import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilServer;
@ -239,7 +240,8 @@ public class MorphBunny extends MorphGadget
}
else
{
UtilParticle.PlayParticle(ParticleType.SPELL, egg.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1);
UtilParticle.PlayParticle(ParticleType.SPELL, egg.getLocation().add(0, 0.1, 0), 0.1f, 0.1f, 0.1f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}

View File

@ -17,7 +17,9 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseCreeper;
import mineplex.core.updater.UpdateType;
@ -98,7 +100,8 @@ public class MorphCreeper extends MorphGadget
continue;
//Explode
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0.5f, 0, 0, 1);
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, player.getLocation(), 0, 0.5f, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1f, 0.8f);
player.playEffect(EntityEffect.HURT);

View File

@ -23,8 +23,10 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.recharge.Recharge;
@ -115,7 +117,8 @@ public class MorphWither extends MorphGadget
WitherSkull skull = (WitherSkull)event.getEntity();
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, skull.getLocation(), 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, skull.getLocation(), 0, 0, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
skull.getWorld().playSound(skull.getLocation(), Sound.EXPLODE, 2f, 1f);
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getLocation(), 6);

View File

@ -15,7 +15,9 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
import mineplex.core.blood.BloodEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -53,7 +55,8 @@ public class ParticleBlizzard extends ParticleGadget
if (Manager.isMoving(player))
{
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
@ -68,11 +71,13 @@ public class ParticleBlizzard extends ParticleGadget
double x = Math.sin(r + (i * (Math.PI/4))) * (r%(Math.PI * 4)) * 0.4;
double z = Math.cos(r + (i * (Math.PI/4))) * (r%(Math.PI * 4)) * 0.4;
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(x, scale * 3, z), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(x, scale * 3, z), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
if (scale > 0.95 && Recharge.Instance.use(player, GetName(), 1000, false, false))
{
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, scale * 3.5, 0), 0f, 0f, 0f, 0.2f, 60);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, player.getLocation().add(0, scale * 3.5, 0), 0f, 0f, 0f, 0.2f, 60,
ViewDist.NORMAL, UtilServer.getPlayers());
player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 1f, 1.5f);
}
}
@ -88,7 +93,8 @@ public class ParticleBlizzard extends ParticleGadget
if (!event.getPlayer().isFlying())
if (IsActive(event.getPlayer()))
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getPlayer().getLocation(), 0f, 0f, 0f, 0.6f, 100);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getPlayer().getLocation(), 0f, 0f, 0f, 0.6f, 100,
ViewDist.NORMAL, UtilServer.getPlayers());
}
@EventHandler
@ -115,7 +121,8 @@ public class ParticleBlizzard extends ParticleGadget
if (!_arrows.remove(event.getEntity()))
return;
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getEntity().getLocation(), 0f, 0f, 0f, 0.4f, 12);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, event.getEntity().getLocation(), 0f, 0f, 0f, 0.4f, 12,
ViewDist.NORMAL, UtilServer.getPlayers());
}
@EventHandler
@ -134,7 +141,8 @@ public class ParticleBlizzard extends ParticleGadget
}
else
{
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, arrow.getLocation(), 0f, 0f, 0f, 0f, 1);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, arrow.getLocation(), 0f, 0f, 0f, 0f, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}

View File

@ -7,7 +7,9 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -41,11 +43,13 @@ public class ParticleEnchant extends ParticleGadget
if (Manager.isMoving(player))
{
UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4);
UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1.4, 0), 0f, 0f, 0f, 1, 4);
UtilParticle.PlayParticle(ParticleType.ENCHANTMENT_TABLE, player.getLocation().add(0, 1.4, 0), 0f, 0f, 0f, 1, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}

View File

@ -3,7 +3,9 @@ package mineplex.core.gadget.gadgets;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import org.bukkit.Location;
import org.bukkit.Sound;
@ -72,8 +74,10 @@ public class ParticleFairyData
Fairy.add(Direction.clone().multiply(Speed));
//Particle
UtilParticle.PlayParticle(ParticleType.FLAME, Fairy, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(ParticleType.LAVA, Fairy, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(ParticleType.FLAME, Fairy, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.LAVA, Fairy, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
//Sound
Fairy.getWorld().playSound(Fairy, Sound.CAT_PURREOW, 0.1f, 3f);

View File

@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -42,7 +44,8 @@ public class ParticleFireRings extends ParticleGadget
if (Manager.isMoving(player))
{
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1f, 0), 0.2f, 0.2f, 0.2f, 0, 1);
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(0, 1f, 0), 0.2f, 0.2f, 0.2f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
@ -55,7 +58,8 @@ public class ParticleFireRings extends ParticleGadget
float y = (float) (Math.sin(player.getTicksLived()/5d + lead) + 1f);
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
for (int i=0 ; i < 1 ; i++)
@ -67,7 +71,8 @@ public class ParticleFireRings extends ParticleGadget
float y = (float) (Math.sin(player.getTicksLived()/5d + lead) + 1f);
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.FLAME, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
//Sound

View File

@ -18,8 +18,10 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -90,9 +92,11 @@ public class ParticleFoot extends ParticleGadget
_steps.put(loc, System.currentTimeMillis());
UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.FOOTSTEP, loc, 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc.clone().add(0, 0.1, 0), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.LARGE_SMOKE, loc.clone().add(0, 0.1, 0), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}

View File

@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -44,7 +46,8 @@ public class ParticleGreen extends ParticleGadget
float z = (float) (Math.cos(player.getTicksLived()/7d) * 1f);
float y = (float) (Math.cos(player.getTicksLived()/17d) * 1f + 1f);
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, player.getLocation().add(x, y, z), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
// if (Manager.isMoving(player))
// {

View File

@ -19,6 +19,7 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -79,9 +80,11 @@ public class ParticleHeart extends ParticleGadget {
}
if (Manager.isMoving(player))
UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
else
UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1);
UtilParticle.PlayParticle(ParticleType.HEART, player.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
@ -96,7 +99,8 @@ public class ParticleHeart extends ParticleGadget {
entry.getValue().add(UtilAlg.getTrajectory(entry.getValue(), entry.getKey().getEyeLocation()).multiply(0.6));
UtilParticle.PlayParticle(ParticleType.HEART, entry.getValue(), 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(ParticleType.HEART, entry.getValue(), 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
if (UtilMath.offset(entry.getValue(), entry.getKey().getEyeLocation()) < 0.6)
heartIterator.remove();

View File

@ -8,7 +8,9 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -42,7 +44,8 @@ public class ParticleHelix extends ParticleGadget
if (Manager.isMoving(player))
{
UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4);
UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
@ -59,7 +62,8 @@ public class ParticleHelix extends ParticleGadget
float y = 0.15f * height;
UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(x * (1d - height/22d), y, z * (1d - height/22d)), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(ParticleType.RED_DUST, player.getLocation().add(x * (1d - height/22d), y, z * (1d - height/22d)), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -43,17 +44,21 @@ public class ParticleRain extends ParticleGadget
if (Manager.isMoving(player))
{
UtilParticle.PlayParticle(ParticleType.SPLASH, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4);
UtilParticle.PlayParticle(ParticleType.SPLASH, player.getLocation().add(0, 1, 0), 0.2f, 0.2f, 0.2f, 0, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
UtilParticle.PlayParticle(player, ParticleType.EXPLODE, player.getLocation().add(0, 3.5, 0), 0.6f, 0f, 0.6f, 0, 8);
UtilParticle.PlayParticle(ParticleType.EXPLODE, player.getLocation().add(0, 3.5, 0), 0.6f, 0f, 0.6f, 0, 8,
ViewDist.NORMAL, player);
for (Player other : UtilServer.getPlayers())
if (!player.equals(other))
UtilParticle.PlayParticle(other, ParticleType.CLOUD, player.getLocation().add(0, 3.5, 0), 0.6f, 0.1f, 0.6f, 0, 8);
UtilParticle.PlayParticle(ParticleType.CLOUD, player.getLocation().add(0, 3.5, 0), 0.6f, 0.1f, 0.6f, 0, 8,
ViewDist.NORMAL, other);
UtilParticle.PlayParticle(ParticleType.DRIP_WATER, player.getLocation().add(0, 3.5, 0), 0.4f, 0.1f, 0.4f, 0, 2);
UtilParticle.PlayParticle(ParticleType.DRIP_WATER, player.getLocation().add(0, 3.5, 0), 0.4f, 0.1f, 0.4f, 0, 2,
ViewDist.NORMAL, UtilServer.getPlayers());
//Sound
player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.1f, 1f);

View File

@ -1,7 +1,9 @@
package mineplex.core.gadget.gadgets;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -29,7 +31,8 @@ public class SongData
return true;
}
UtilParticle.PlayParticle(ParticleType.NOTE, Block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2);
UtilParticle.PlayParticle(ParticleType.NOTE, Block.getLocation().add(0.5, 1, 0.5), 0.5f, 0.5f, 0.5f, 0f, 2,
ViewDist.NORMAL, UtilServer.getPlayers());
return false;
}

View File

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

View File

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

View File

@ -13,6 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.Chat;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -46,11 +47,12 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
private HashMap<UUID, BukkitRunnable> _messageTimeouts = new HashMap<UUID, BukkitRunnable>();
private PreferencesManager _preferences;
private Punish _punish;
private Chat _chat;
private LinkedList<String> _randomMessage;
private String _serverName;
public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences,
IgnoreManager ignoreManager, Punish punish, FriendManager friendManager)
IgnoreManager ignoreManager, Punish punish, FriendManager friendManager, Chat chat)
{
super("Message", plugin);
@ -59,6 +61,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
_ignoreManager = ignoreManager;
_punish = punish;
_friendsManager = friendManager;
_chat = chat;
_serverName = getPlugin().getConfig().getString("serverstatus.name");
MessageHandler messageHandler = new MessageHandler(this);
@ -181,6 +184,8 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
return;
}
message = _chat.getFilteredMessage(from, message);
// Inform
UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message);
@ -278,6 +283,9 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
_randomMessage.add("i like pie.");
_randomMessage.add("Do you play Clash of Clans?");
_randomMessage.add("Mmm...Steak!");
_randomMessage.add("Poop! Poop everywhere!");
_randomMessage.add("I'm so forgetful. Like I was going to say somethin...wait what were we talking about?");
_randomMessage.add("Mmm...Steak!");
}
public CoreClientManager GetClientManager()

View File

@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.mount.DragonData;
@ -42,17 +43,11 @@ public class MountDragon extends DragonMount
if (event.getType() == UpdateType.TICK)
{
for (DragonData data : GetActive().values())
for (Player player : UtilServer.getPlayers())
{
try
{
UtilParticle.PlayParticle(player, ParticleType.WITCH_MAGIC, data.Dragon.getLocation().add(0, 1, 0), 1f, 1f, 1f, 0f, 20);
}
catch (Exception e)
{
e.printStackTrace();
}
}
{
UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, data.Dragon.getLocation().add(0, 1, 0),
1f, 1f, 1f, 0f, 20,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}

View File

@ -9,7 +9,9 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
@ -37,7 +39,9 @@ public class MountFrost extends HorseMount
{
if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0.1f, 4);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
// @EventHandler

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType;
@ -38,11 +39,15 @@ public class MountUndead extends HorseMount
{
if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 2);
UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 2,
ViewDist.NORMAL, UtilServer.getPlayers());
if (event.getType() == UpdateType.FAST)
for (Horse horse : GetActive().values())
UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), 0.25f, 0.25f, 0.25f, 0, 1);
UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}

View File

@ -6,7 +6,9 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseSquid;
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
@ -93,7 +95,8 @@ public class ProjectileUser
_thrown.getWorld().playEffect(_thrown.getLocation(), _effect, _effectData);
if (_particle != null)
UtilParticle.PlayParticle(_particle, _thrown.getLocation(), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(_particle, _thrown.getLocation(), 0f, 0f, 0f, 0, 1,
ViewDist.LONG, UtilServer.getPlayers());
}

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

@ -50,7 +50,7 @@ public class ServerConfiguration extends MiniPlugin
_plugin.getServer().setWhitelist(_serverGroup.getWhitelist());
((CraftServer)_plugin.getServer()).getServer().setPvP(_serverGroup.getPvp());
((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
//((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
}
@EventHandler

View File

@ -13,12 +13,14 @@ import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.hologram.HologramManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
@ -133,7 +135,8 @@ public class Treasure
if (_treasureType == TreasureType.OLD)
{
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4);
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (_treasureType == TreasureType.ANCIENT)
{
@ -141,11 +144,13 @@ public class Treasure
double xDif = 0.7 * Math.sin(Math.PI * (_tickCount / 5.0));
double zDif = 0.7 * Math.cos(Math.PI * (_tickCount / 5.0));
float red = 0.1F + (float)( 0.4 * (1 + Math.cos(Math.PI * (_tickCount / 20.0))));
UtilParticle.PlayParticle(type, block.getLocation().add(0.5 + xDif, 0.5 + yDif, 0.5 + zDif), red, 0.2F, 0.2F, 1F, 0);
UtilParticle.PlayParticle(type, block.getLocation().add(0.5 + xDif, 0.5 + yDif, 0.5 + zDif), red, 0.2F, 0.2F, 1F, 0,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0);
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
@ -327,7 +332,8 @@ public class Treasure
if (block.getType().equals(Material.CHEST))
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10);
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10,
ViewDist.NORMAL, UtilServer.getPlayers());
// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F);
}
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());

View File

@ -12,10 +12,11 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.MathHelper;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
@ -82,7 +83,8 @@ public class ChestSpawnAnimation extends Animation
//Play Particels
if (getTreasure().getTreasureType() == TreasureType.OLD)
{
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.ANCIENT)
{
@ -93,7 +95,8 @@ public class ChestSpawnAnimation extends Animation
newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale));
newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale));
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL)
{
@ -107,7 +110,8 @@ public class ChestSpawnAnimation extends Animation
float x = (float) (Math.sin(getTicks()/4D + lead));
float z = (float) (Math.cos(getTicks()/4D + lead));
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
@ -122,7 +126,8 @@ public class ChestSpawnAnimation extends Animation
if (particleType != null)
{
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50);
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{

View File

@ -11,6 +11,8 @@ import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
@ -55,7 +57,8 @@ public class LootLegendaryAnimation extends Animation
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, 0, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
else if (getTicks() < 40)

View File

@ -8,6 +8,8 @@ import org.bukkit.FireworkEffect.Type;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
@ -52,7 +54,8 @@ public class LootRareAnimation extends Animation
Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
//Particle Spiral Up
@ -64,7 +67,8 @@ public class LootRareAnimation extends Animation
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, -1.3, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}

View File

@ -9,6 +9,8 @@ import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
@ -42,7 +44,8 @@ public class LootUncommonAnimation extends Animation
}
else if (getTicks() % 2 == 0)
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}

View File

@ -5,6 +5,8 @@ import java.util.ArrayList;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
@ -54,7 +56,8 @@ public class ParticleAnimation extends Animation
{
Vector position = PATH.get(pathPosition);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
pathPosition = (pathPosition + 1) % PATH.size();
}

View File

@ -8,5 +8,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.ClassCombat"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Minecraft.Game.Core"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,11 +1,13 @@
package mineplex.game.clans;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import mineplex.core.account.CoreClientManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.donation.DonationManager;
import mineplex.core.explosion.Explosion;
@ -16,6 +18,7 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Punish;
@ -28,6 +31,7 @@ import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.shop.building.BuildingShop;
import mineplex.game.clans.shop.pvp.PvpShop;
@ -66,7 +70,10 @@ public class Clans extends JavaPlugin
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
new Spawn(this, serverStatusManager.getCurrentServerName());
// TODO: Add spawn locations to a configuration file of some sort?
Spawn spawn = new Spawn(this, serverStatusManager.getCurrentServerName());
Teleport teleport = new Teleport(this);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
@ -79,7 +86,8 @@ public class Clans extends JavaPlugin
BlockRestore blockRestore = new BlockRestore(this);
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal));
Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
new MemoryFix(this);
new Explosion(this, blockRestore);
@ -92,6 +100,10 @@ public class Clans extends JavaPlugin
new BuildingShop(clans, _clientManager, _donationManager);
new PvpShop(clans, _clientManager, _donationManager);
// Enable custom-gear related managers
PacketHandler packetHandler = new PacketHandler(this);
GearManager customGear = new GearManager(this, packetHandler);
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.clans;
import org.bukkit.ChatColor;
import org.bukkit.Color;
public class ChunkData
{
private int _x;
public int getX() { return _x; }
private int _z;
public int getZ() { return _z; }
private ChatColor _color;
public ChatColor getColor() { return _color; }
private String _clanName;
public String getClanName() { return _clanName; }
public ChunkData(int x, int z, ChatColor color, String clanName)
{
_x = x;
_z = z;
_color = color;
_clanName = clanName;
}
}

View File

@ -32,7 +32,7 @@ public class ClanEnergyManager extends MiniPlugin implements Runnable
for (final ClanInfo clanInfo : _clansManager.getClanMap().values())
{
if (clanInfo.isAdmin())
if (clanInfo.isAdmin() || true) // TODO: Remove || true and implement ability to purchase Energy
continue;
int energyPerMinute = clanInfo.getEnergyCostPerMinute();

View File

@ -4,3 +4,4 @@ public enum ClanRole
{
NONE, RECRUIT, MEMBER, ADMIN, LEADER
}

View File

@ -3,6 +3,7 @@ package mineplex.game.clans.clans;
import java.util.HashSet;
import java.util.TimeZone;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -10,6 +11,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
@ -44,6 +46,7 @@ import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.fields.Field;
import mineplex.game.clans.gameplay.Gameplay;
import mineplex.game.clans.spawn.Spawn;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
@ -60,6 +63,9 @@ import mineplex.minecraft.game.core.mechanics.Weapon;
public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelation
{
public static final int FIELD_RADIUS = 128;
public static final int CLAIMABLE_RADIUS = 800;
public static final int WORLD_RADIUS = 1200;
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
private String _serverName;
@ -92,6 +98,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
// Spawn area
public String[] denyClan = new String[] {
"neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home"};
@ -103,6 +111,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_clientManager = clientManager;
_combatManager = new CombatManager(plugin);
_blockRestore = blockRestore;
_teleport = teleport;
@ -115,12 +124,14 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
Energy energy = new Energy(plugin);
PacketHandler packetHandler = new PacketHandler(plugin);
new CustomTagFix(plugin, packetHandler);
// TODO: Re-enable customtagfix with NCP update?
//new CustomTagFix(plugin, packetHandler);
DisguiseManager disguiseManager = new DisguiseManager(plugin, packetHandler);
_condition = new SkillConditionManager(plugin);
Creature creature = new Creature(plugin);
new Field(plugin, creature, _condition, energy, serverName);
new Spawn(plugin);
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager);
@ -186,6 +197,23 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
return _clanMemberMap;
}
public static boolean isClaimable(Location location)
{
int x = Math.abs(location.getBlockX());
int z = Math.abs(location.getBlockZ());
return (x > FIELD_RADIUS || z > FIELD_RADIUS)
&& (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS);
}
public static boolean isFields(Location location)
{
int x = Math.abs(location.getBlockX());
int z = Math.abs(location.getBlockZ());
return x <= FIELD_RADIUS && z <= FIELD_RADIUS;
}
public ClanInfo getClan(Player player)
{
return _clanMemberMap.get(player.getName());

View File

@ -1,11 +1,15 @@
package mineplex.game.clans.clans;
import java.awt.Color;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
@ -34,6 +38,48 @@ public class ClansUtility
SAFE
}
/**
*
* @param location
* @param radius
* @return a 2D array of {@link ClanTerritory} with uniform dimension of ({@code radius} * 2 + 1). The region represented by
* the array of territories is centered on {@code location} chunk with a given chunk {@code radius}.
*/
public List<ChunkData> getTerritory(Location location, int radius, ClanInfo surveyorClan)
{
World world = location.getWorld();
Chunk chunk = location.getChunk();
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
int width = radius*2 + 1;
List<ChunkData> chunks = new ArrayList<ChunkData>();
for (int x = 0; x < width; x++)
{
for (int z = 0; z < width; z++)
{
int territoryX = chunkX - radius + x;
int territoryZ = chunkZ - radius + z;
ClanTerritory territory = getClaim(world.getChunkAt(territoryX, territoryZ));
if (territory != null)
{
ClanInfo clan = getOwner(territory);
String clanName = territory.Owner;
ClanRelation relationship = rel(surveyorClan, clan);
ChatColor color = relChatColor(relationship, false);
ChunkData data = new ChunkData(territoryX, territoryZ, color, clanName);
chunks.add(data);
}
}
}
return chunks;
}
public ClanInfo searchClanPlayer(Player caller, String name, boolean inform)
{
//CLAN
@ -198,10 +244,15 @@ public class ClansUtility
return clan.getHome().getChunk().equals(chunk);
}
public ClanTerritory getClaim(Chunk chunk)
{
String chunkTag = UtilWorld.chunkToStr(chunk);
return Clans.getClaimMap().get(chunkTag);
}
public ClanTerritory getClaim(Location loc)
{
String chunk = UtilWorld.chunkToStr(loc.getChunk());
return Clans.getClaimMap().get(chunk);
return getClaim(loc.getChunk());
}
public ClanTerritory getClaim(String chunk)
@ -486,8 +537,9 @@ public class ClansUtility
return true;
}
public boolean isBorderlands(Location loc)
{
return (Math.abs(loc.getX()) > 400 || Math.abs(loc.getZ()) > 400);
return Math.abs(loc.getBlockX()) > ClansManager.CLAIMABLE_RADIUS || Math.abs(loc.getBlockZ()) > ClansManager.CLAIMABLE_RADIUS;
}
}

View File

@ -25,9 +25,13 @@ import mineplex.game.clans.clans.ClientClan;
public class ClansCommand extends CommandBase<ClansManager>
{
private ClansManager _manager;
public ClansCommand(ClansManager plugin)
{
super(plugin, Rank.ALL, "c", "clans", "f", "factions");
_manager = plugin;
}
@Override
@ -784,12 +788,9 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
if (caller.getLocation().getChunk().getX() < -24 ||
caller.getLocation().getChunk().getX() > 23 ||
caller.getLocation().getChunk().getZ() < -24 ||
caller.getLocation().getChunk().getZ() > 23)
if (!ClansManager.isClaimable(caller.getLocation()))
{
UtilPlayer.message(caller, F.main("Clans", "You cannot claim Territory this far away."));
UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!"));
return;
}

View File

@ -105,6 +105,7 @@ public class WarManager extends MiniPlugin
{
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer == null) return; // Wasn't killed by player
ClanInfo playerClan = _clansManager.getClan(player);
ClanInfo killerClan = _clansManager.getClan(killer);

View File

@ -0,0 +1,114 @@
package mineplex.game.clans.economy;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.core.MiniPlugin;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.creature.Creature;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.core.energy.Energy;
import mineplex.game.clans.Clans;
import mineplex.game.clans.fields.repository.FieldRepository;
import mineplex.game.clans.items.generation.WeightSet;
import mineplex.minecraft.game.core.condition.ConditionFactory;
import mineplex.minecraft.game.core.condition.ConditionManager;
public class GoldManager extends MiniPlugin
{
public static final double DEATH_TAX = 0.04d; // Percentage of gold lost on death
private static GoldManager _instance;
public static GoldManager getInstance() { return _instance; }
private DonationManager _donationManager;
public GoldManager(JavaPlugin plugin, DonationManager donationManager)
{
super("Clans Gold", plugin);
_instance = this;
_donationManager = donationManager;
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
Player player = event.getEntity();
Player killer = player.getKiller();
int gold = getGold(player);
int droppedGold = (int) (gold * DEATH_TAX);
if (droppedGold > 0)
{
deductGold(player, droppedGold);
notify(player, String.format("You dropped %d gold on your death!", droppedGold));
if (killer != null)
{
addGold(killer, droppedGold);
notify(killer, String.format("You looted %d gold off of %s's corpse!", droppedGold, player.getName()));
}
}
}
@EventHandler
public void playerCmd(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/gold"))
{
notify(event.getPlayer(), "Your Balance is " + C.cYellow + getGold(event.getPlayer()) + "g");
event.setCancelled(true);
}
}
public int getGold(Player player)
{
return getDonor(player).getGold();
}
public void addGold(Player player, int amount)
{
getDonor(player).addGold(amount);
}
public void deductGold(Player player, int amount)
{
addGold(player, -amount);
}
public void cashIn(Player player, GoldToken token)
{
int value = token.getGoldValue();
addGold(player, value);
notify(player, String.format("You have cashed in a gold token worth %dg!", value));
}
private Donor getDonor(Player player)
{
return _donationManager.Get(player.getName());
}
private void notify(Player player, String message)
{
UtilPlayer.message(player, F.main("Gold", message));
}
}

View File

@ -26,6 +26,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.energy.Energy;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.fields.commands.FieldBlockCommand;
import mineplex.game.clans.fields.commands.FieldOreCommand;
import mineplex.game.clans.fields.repository.FieldBlockToken;
@ -206,17 +207,19 @@ public class FieldBlock extends MiniPlugin
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void BlockBreak(BlockBreakEvent event)
{
if (event.isCancelled())
return;
if (ClansManager.isFields(event.getBlock().getLocation()))
{
event.setCancelled(true); // Cancel all block breaks in fields. Handle custom breaking for FieldBlocks and Ores.
FieldBlockData fieldBlock = getFieldBlock(event.getBlock());
if (fieldBlock == null) return;
fieldBlock.handleMined(event.getPlayer());
event.setCancelled(true);
FieldBlockData fieldBlock = getFieldBlock(event.getBlock());
if (fieldBlock != null)
{
fieldBlock.handleMined(event.getPlayer());
}
}
}
@EventHandler

View File

@ -0,0 +1,251 @@
package mineplex.game.clans.gameplay.safelog;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mineplex.core.MiniPlugin;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.items.commands.GearCommand;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class LoggingManager extends MiniPlugin
{
public static final double SAFE_LOG_RANGE = 32d;
public static final int LOGOUT_DURATION = 10000; // Duration of safe-log (in milliseconds)
public static final long REJOIN_TIME = 60000;
//Track Offline Players
private HashMap<String, LogoutData> _logouts;
public LoggingManager(JavaPlugin plugin)
{
super("Logout Manager", plugin);
_logouts = new HashMap<String, LogoutData>();
}
private Set<Player> getNearbyHostilePlayers(Location location, double radius)
{
Set<Player> nearbyPlayers = new HashSet<Player>();
for (Player player : location.getWorld().getPlayers())
{
double radiusSquared = radius * radius;
if (player.getLocation().distanceSquared(location) <= radiusSquared) // TODO: Check to see if they're in a clan?
{
nearbyPlayers.add(player);
}
}
return nearbyPlayers;
}
public void onPlayerQuit(Player player)
{
LogoutData logoutData = _logouts.remove(player);
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout() && !player.isDead();
if (!isSafeLog && getNearbyHostilePlayers(player.getLocation(), 32d).size() == 1) // No other players within 32 blocks
{
isSafeLog = true;
}
// TODO: Check to see if player was attacked or attacked another player within last 15 seconds and set isSafeLog=false...
if (!isSafeLog)
{
onCombatLog(player);
}
}
public void onPlayerJoin(Player player)
{
// TODO: Check to see if the player has a combat-log bot in place
// and if so, remove/un-use it as they have logged back in.
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
onPlayerQuit(event.getPlayer());
}
@EventHandler
public void onPlayerKicked(PlayerKickEvent event)
{
onPlayerQuit(event.getPlayer());
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
onPlayerJoin(event.getPlayer());
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
tick();
}
@Override
public void addCommands()
{
addCommand(new QuitCommand(this));
}
private LogoutData getLogoutData(Player player)
{
return _logouts.get(player.getName());
}
public LogoutData insertLogoutData(Player player, long duration)
{
LogoutData data = new LogoutData(player, duration);
_logouts.put(player.getName(), data);
return data;
}
public LogoutData insertLogoutData(Player player)
{
return insertLogoutData(player, LOGOUT_DURATION);
}
public boolean hasLogoutData(Player player)
{
return getLogoutData(player) != null;
}
/**
* Tick the internal logic of this manager and update it's state.
* Intended to be ticked/updated every in-game tick.
*/
private void tick()
{
for (String playerName : _logouts.keySet())
{
LogoutData data = _logouts.get(playerName);
if (data.isOnline())
{
double distance = data.getDistanceTravelled();
if (distance >= SAFE_LOG_RANGE)
{
cancelSafeLog(data.getPlayer());
}
else if (data.hasSafeLogout())
{
// TODO: Log out player safely.
}
}
else
{
_logouts.remove(playerName);
}
}
}
private void cancelSafeLog(Player player)
{
_logouts.remove(player.getName());
// TODO: Notify player that safe-log was cancelled
}
public void onCombatLog(Player player)
{
UtilInv.drop(player, true); // Drop player's inventory belongigs to ground
}
@EventHandler(ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (hasLogoutData(player))
{
cancelSafeLog(player);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamaged(EntityDamageByEntityEvent event)
{
Entity victim = event.getEntity();
if (victim instanceof Player)
{
Player player = (Player) victim;
if (hasLogoutData(player))
{
cancelSafeLog(player);
}
}
}
@EventHandler(ignoreCancelled = true)
public void onItemPickup(PlayerPickupItemEvent event)
{
if (hasLogoutData(event.getPlayer()))
{
event.setCancelled(true); // Prevent players that are safe-logging from picking up items.
}
}
}

View File

@ -0,0 +1,46 @@
package mineplex.game.clans.gameplay.safelog;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class LogoutData
{
private String _playerName;
public Player getPlayer() { return Bukkit.getPlayer(_playerName); }
private long _endTime;
public boolean hasSafeLogout() { return System.currentTimeMillis() >= _endTime; }
private long _startTime;
private Location _location;
public Location getLocation() { return _location; }
public LogoutData(Player player, long duration)
{
_startTime = System.currentTimeMillis();
_endTime = _startTime + duration;
_location = player.getLocation();
_playerName = player.getName();
}
public boolean isOnline()
{
Player player = getPlayer();
return player != null && player.isOnline();
}
public double getDistanceTravelled()
{
if (isOnline())
{
Player player = getPlayer();
return player.getLocation().distance(_location);
}
return -1d;
}
}

View File

@ -0,0 +1,62 @@
package mineplex.game.clans.gameplay.safelog;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInput;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.attributes.weapon.FlamingAttribute;
import mineplex.game.clans.items.attributes.weapon.FrostedAttribute;
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.game.clans.items.legendaries.WindBlade;
public class QuitCommand extends CommandBase<LoggingManager>
{
private LoggingManager _loggingManager;
public QuitCommand(LoggingManager plugin)
{
super(plugin, Rank.ALL, "quit", "log", "logout");
_loggingManager = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
if (_loggingManager.hasLogoutData(caller))
{
UtilPlayer.message(caller, F.main("SafeLog", "You are already safe-logging!"));
}
else
{
_loggingManager.insertLogoutData(caller);
UtilPlayer.message(caller, F.main("SafeLog", "Successfully initiated safe-log!"));
}
}
}

View File

@ -0,0 +1,226 @@
package mineplex.game.clans.items;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Material;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* Represents a customizable wrapper for an {@link ItemStack}, enabling the possession
* of special abilities, attributes, and triggers on item.
* @author MrTwiggy
*
*/
public class CustomItem
{
private ItemAttribute _superPrefix;
public void setSuperPrefix(ItemAttribute attribute) { _superPrefix = attribute; }
private ItemAttribute _prefix;
public void setPrefix(ItemAttribute attribute) { _prefix = attribute; }
private ItemAttribute _suffix;
public void setSuffix(ItemAttribute attribute) { _suffix = attribute; }
protected String _displayName;
private String _description;
private Material _material;
private String _uuid;
public String getUuid() { return _uuid; }
public CustomItem(String displayName, String description, Material material)
{
_displayName = displayName;
_description = description;
_material = material;
_uuid = UUID.randomUUID().toString();
}
public CustomItem(Material material)
{
this(prettifyName(material), null, material);
}
/**
* @return the name displayed to players for the item.
*/
public String getDisplayName()
{
// Concatenate attribute prefixes/suffixes to display name.
String display = _displayName;
if (_prefix != null)
{
display = _prefix.getDisplayName() + " " + display;
}
if (_superPrefix != null)
{
display = _superPrefix.getDisplayName() + " " + display;
}
if (_suffix != null)
{
display += " of " + _suffix.getDisplayName();
}
return display;
}
public String getDescription()
{
return _description;
}
public List<String> getLore()
{
String serialization = GearManager.getItemSerialization(this);
List<String> lore = new ArrayList<String>();
if (getDescription() != null)
{
lore.add(getDescription());
}
// Display attribute descriptions and stats in lore
for (ItemAttribute attribute : getAttributes())
{
String attributeLine = attribute.getDisplayName() + " - " + attribute.getDescription();
lore.add(attributeLine);
}
// Tack on serialized JSON encoded line for utility purposes. (Not seen by user)
List<String> serializedLines = new ArrayList<String>();
String[] seri = serialization.split("\n");
for (String line : seri)
{
serializedLines.add(line);
}
lore.addAll(serializedLines);
return lore;
}
public ItemStack toItemStack(int amount)
{
ItemStack item = new ItemStack(_material, amount);
update(item);
// TODO: Add non-descript enchantment for glowing efect?
return item;
}
public ItemStack toItemStack()
{
return toItemStack(1);
}
public void onInteract(PlayerInteractEvent event)
{
System.out.println("Triggered interact!");
for (ItemAttribute attribute : getAttributes())
{
attribute.onInteract(event);
}
}
public void onAttack(CustomDamageEvent event)
{
System.out.println("Triggered attack!");
for (ItemAttribute attribute : getAttributes())
{
attribute.onAttack(event);
}
}
public void onAttacked(CustomDamageEvent event)
{
System.out.println("Triggered damage!");
for (ItemAttribute attribute : getAttributes())
{
attribute.onAttacked(event);
}
}
/**
* @return the (possibly empty) set of {@link ItemAttribute}s attached to this item.
*/
public Set<ItemAttribute> getAttributes()
{
Set<ItemAttribute> attributes = new HashSet<ItemAttribute>();
if (_superPrefix != null) attributes.add(_superPrefix);
if (_prefix != null) attributes.add(_prefix);
if (_suffix != null) attributes.add(_suffix);
return attributes;
}
/**
* @param item - the item to check for a matching link
* @return true, if {@code item} matches this CustomItem via UUID, false otherwise.
*/
public boolean matches(CustomItem item)
{
return item.getUuid().equals(_uuid);
}
/**
* Update {@code item} with the proper meta properties suited for this
* {@link CustomItem}.
* @param item - the item whose meta properties are being updated to become a version of this updated custom item.
*/
public void update(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
String displayName = getDisplayName();
List<String> lore = getLore();
meta.setDisplayName(displayName);
meta.setLore(lore);
item.setItemMeta(meta);
}
public void addAttribute(ItemAttribute attribute)
{
if (_superPrefix == null)
{
_superPrefix = attribute;
}
else if (_prefix == null)
{
_prefix = attribute;
}
else if (_suffix == null)
{
_suffix = attribute;
}
}
public static String prettifyName(Material material)
{
String name = "";
String[] words = material.toString().split("_");
for (String word : words)
{
word = word.toLowerCase();
name += word.substring(0, 1).toUpperCase() + word.substring(1) + " ";
}
return name;
}
}

View File

@ -0,0 +1,379 @@
package mineplex.game.clans.items;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.UtilServer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.portal.TransferHandler;
import mineplex.core.portal.Commands.SendCommand;
import mineplex.core.portal.Commands.ServerCommand;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.attributes.weapon.*;
import mineplex.game.clans.items.attributes.armor.*;
import mineplex.game.clans.items.commands.GearCommand;
import mineplex.game.clans.items.generation.Weight;
import mineplex.game.clans.items.generation.WeightSet;
import mineplex.game.clans.items.legendaries.*;
import mineplex.game.clans.items.smelting.SmeltingListener;
import mineplex.serverdata.Region;
import mineplex.serverdata.Utility;
import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.commands.TransferCommand;
import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory;
import mineplex.serverdata.servers.ServerManager;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot;
import net.minecraft.util.com.google.common.collect.Sets;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* Manages creation and retrieval of associated {@link PlayerGear}s with online players, as well
* as offering methods for parsing and handling {@link CustomItem}s.
* @author MrTwiggy
*
*/
public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
{
private static final String ITEM_SERIALIZATION_TAG = "-JSON-";
private static Random random = new Random();
private static Gson _gson;
private static GearManager _instance; // Singleton instance
private Map<String, PlayerGear> _playerGears; // Mapping of player names (key) to cached gear set (value).
private WeightSet<Integer> _attributeWeights; // Weightings for randomly selecting number of attributes (1, 2, 3)
private WeightSet<ItemType> _typeWeights; // Weightings for randomly selecting item type (legendary/weapon/armour/bow)
// Legendary generation
private WeightSet<Class<? extends LegendaryItem>> _legendaryWeights;
// Weapon generation
private WeightSet<Material> _weaponTypes;
// Armour generation
private WeightSet<Material> _armourTypes;
// Attribute generation
private WeightSet<Class<? extends ItemAttribute>> _weaponAttributes;
private WeightSet<Class<? extends ItemAttribute>> _armourAttributes;
private WeightSet<Class<? extends ItemAttribute>> _bowAttributes;
public GearManager(JavaPlugin plugin, PacketHandler packetHandler)
{
super("CustomGear", plugin);
_instance = this;
_playerGears = new HashMap<String, PlayerGear>();
// TODO: Introduce configurable non-hardcoded values for generation weights?
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(10, ItemType.LEGENDARY),
new Weight<ItemType>(45, ItemType.ARMOUR),
new Weight<ItemType>(22, ItemType.WEAPON),
new Weight<ItemType>(0, ItemType.BOW));
// Weapon-based attributes
_weaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class,
JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class);
// Armour-based attributes
_armourAttributes = new WeightSet<Class<? extends ItemAttribute>>(SlantedAttribute.class, ReinforcedAttribute.class,
ProtectionAttribute.class, PaddedAttribute.class, LavaAttribute.class);
// Bow-based attributes
//_bowAttributes = new WeightSet<Class<? extends ItemAttribute>>(); // TODO: Add in bow-attributes
// Weapon material types
_weaponTypes = new WeightSet<Material>(Material.DIAMOND_SWORD, Material.GOLD_SWORD, Material.IRON_SWORD, Material.STONE_SWORD,
Material.DIAMOND_AXE, Material.GOLD_AXE, Material.IRON_AXE, Material.STONE_AXE);
// Armour material types
_armourTypes = new WeightSet<Material>(Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS,
Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS,
Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS);
// TODO: Initialize list of attributes and types
// Initialize various LegendaryItem types
_legendaryWeights = new WeightSet<Class<? extends LegendaryItem>>(AlligatorsTooth.class, WindBlade.class,
GiantsBroadsword.class, HyperBlade.class, MagneticBlade.class);
// TODO: Add rest of legendaries, find better way?
// Register listeners
UtilServer.getServer().getPluginManager().registerEvents(new ItemListener(), getPlugin());
UtilServer.getServer().getPluginManager().registerEvents(new SmeltingListener(), getPlugin());
// Initialize attribute types factory for JSON handling of polymorphism.
RuntimeTypeAdapterFactory<ItemAttribute> attributeFactory = RuntimeTypeAdapterFactory
.of(ItemAttribute.class);
for (Class<? extends ItemAttribute> attributeType : _armourAttributes.elements())
{
attributeFactory.registerSubtype(attributeType);
}
for (Class<? extends ItemAttribute> attributeType : _weaponAttributes.elements())
{
attributeFactory.registerSubtype(attributeType);
}
// Initialize legendary item type factory for JSON handling of polymorphism.
RuntimeTypeAdapterFactory<CustomItem> customItemType = RuntimeTypeAdapterFactory
.of(CustomItem.class);
customItemType.registerSubtype(CustomItem.class);
customItemType.registerSubtype(LegendaryItem.class);
for (Class<? extends CustomItem> itemType : _legendaryWeights.elements())
{
customItemType.registerSubtype(itemType);
}
// Build GSON instance off factories for future serialization of items.
_gson = new GsonBuilder()
.registerTypeAdapterFactory(attributeFactory)
.registerTypeAdapterFactory(customItemType)
.create();
packetHandler.addPacketHandler(this);
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 1l, 1l);
}
@Override
public void addCommands()
{
addCommand(new GearCommand(this));
}
/**
* Tick & update internal logic for {@link GearManager}. Called once per tick.
*/
@Override
public void run()
{
for (PlayerGear gear : _playerGears.values())
{
gear.update();
}
}
/**
* @param player - the player whose {@link PlayerGear} set is to be fetched.
* @return the cached or newly instantiated {@link PlayerGear} associated with {@code player}.
*/
public PlayerGear getPlayerGear(Player player)
{
String playerName = player.getName();
if (!_playerGears.containsKey(playerName))
{
PlayerGear gear = new PlayerGear(playerName);
_playerGears.put(playerName, gear);
}
return _playerGears.get(playerName);
}
public CustomItem generateItem()
{
int attributeCount = _attributeWeights.generateRandom();
ItemType itemType = _typeWeights.generateRandom();
System.out.println("Generating item of type " + itemType.toString() + " with attribute count of " + attributeCount);
CustomItem item = generateItem(itemType);
System.out.println("Generated item!");
if (itemType != ItemType.LEGENDARY) // Only non-legendaries have attributes
{
for (ItemAttribute attribute : generateAttributes(itemType, attributeCount))
{
item.addAttribute(attribute);
}
// Add up to attributeCount attributes
}
return item;
}
private CustomItem generateItem(ItemType itemType)
{
switch(itemType)
{
case LEGENDARY: // Legendary weapon
Class<? extends LegendaryItem> legendaryClass = _legendaryWeights.generateRandom();
System.out.println("Legendary: " + legendaryClass.getName());
return instantiate(legendaryClass);
case WEAPON: // Sword or axe
return new CustomItem(_weaponTypes.generateRandom());
case ARMOUR: // Helmet, chestplate, leggings, or boots
return new CustomItem(_armourTypes.generateRandom());
case BOW: // A bow
return new CustomItem(Material.BOW);
default:
return null;// Never reached, yet required for compilation purposes.
}
}
private Set<ItemAttribute> generateAttributes(ItemType type, int count)
{
Set<ItemAttribute> attributes = new HashSet<ItemAttribute>();
for (int i = 0; i < count; i++)
{
switch (type)
{
case ARMOUR:
attributes.add(instantiate(_armourAttributes.generateRandom()));
break;
case WEAPON:
attributes.add(instantiate(_weaponAttributes.generateRandom()));
break;
default:
break;
}
}
return attributes;
}
public void spawnItem(Location location)
{
CustomItem item = generateItem();
location.getWorld().dropItem(location, item.toItemStack());
}
public static CustomItem parseItem(ItemStack item)
{
String serialization = getItemSerialization(item);
if (serialization != null)
{
CustomItem customItem = deserialize(serialization);
return customItem;
}
return null; // No serialization found in item's lore, not a custom item!
}
public static boolean isCustomItem(ItemStack item)
{
return getItemSerialization(item) != null;
}
public static String getItemSerialization(CustomItem customItem)
{
String serialization = serialize(customItem);
return ITEM_SERIALIZATION_TAG + serialization;
}
/**
* @param type - the class-type of the object to be instantiated. (must have zero-argument constructor)
* @return a newly instantiated instance of {@code type} class-type. Instantied with zero argument constructor.
*/
private static <T> T instantiate(Class<T> type)
{
try
{
return type.newInstance();
}
catch (Exception e)
{
return null;
}
}
private static String getItemSerialization(ItemStack item)
{
if (item == null || item.getItemMeta() == null
|| item.getItemMeta().getLore() == null) return null;
ItemMeta meta = item.getItemMeta();
for (String lore : meta.getLore())
{
if (lore.startsWith(ITEM_SERIALIZATION_TAG)) // Found serialization lore-line
{
int tagLength = ITEM_SERIALIZATION_TAG.length();
String serialization = lore.substring(tagLength);
return serialization;
}
}
return null; // Unable to find any serialized lore lines, hence not a CustomItem.
}
public static String serialize(CustomItem customItem)
{
return _gson.toJson(customItem, CustomItem.class);
}
public static CustomItem deserialize(String serialization)
{
return _gson.fromJson(serialization, CustomItem.class);
}
/**
* @return singleton instance of {@link GearManager}.
*/
public static GearManager getInstane()
{
return _instance;
}
@Override
public void handle(PacketInfo packetInfo)
{
Packet packet = packetInfo.getPacket();
if (packet instanceof PacketPlayOutSetSlot)
{
System.out.println("Item slot packet!");
PacketPlayOutSetSlot slotPacket = (PacketPlayOutSetSlot) packet;
net.minecraft.server.v1_7_R4.ItemStack original = slotPacket.c;
CraftItemStack originalItem = CraftItemStack.asCraftMirror(original);
ItemMeta originalMeta = originalItem.getItemMeta();
if (originalMeta == null || originalMeta.getLore() == null) return; // No need to modify item packets with no lore
List<String> lore = new ArrayList<String>();
for (String line : originalMeta.getLore())
{
if (!line.startsWith(ITEM_SERIALIZATION_TAG)) // Remove serialization lines from out-going lore
{
lore.add(line);
}
}
net.minecraft.server.v1_7_R4.ItemStack newItem = CraftItemStack.asNMSCopy(originalItem);
CraftItemStack newCopy = CraftItemStack.asCraftMirror(newItem);
ItemMeta newMeta = newCopy.getItemMeta();
newMeta.setLore(lore);
newCopy.setItemMeta(newMeta);
slotPacket.c = newItem;
//CraftItemStack.setItemMeta(slotPacket.c, meta);
// TODO: Modify spigot build so that slotPacket's itemstack lore can be modified
// to 'hide' json-encoded lore from players.
}
}
}

View File

@ -0,0 +1,95 @@
package mineplex.game.clans.items;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
/**
* Listens for item-related trigger events and accordingly triggers appropriate
* {@link PlayerGear} events for {@link CustomItem} abilities and attributes.
* @author MrTwiggy
*
*/
public class ItemListener implements Listener
{
/**
* Handle players shuffling CustomItems around by properly updating
* and managing their movement.
* @param event
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
// TODO: Update any custom-items that are selected/moved to save proper stats if they
// TODO: are active. (IE: PlayerGear possesses it as armor slot or weapon)
}
/**
* Handle updated CustomItem stats and lore upon player
* switching items.
* @param event
*/
@EventHandler
public void onItemHeldChanged(PlayerItemHeldEvent event)
{
Player player = event.getPlayer();
PlayerGear gear = getGear(player);
gear.onItemHeldChanged(event);
}
/**
* Handle the trigger of custom gear related effects and abilities.
* @param event
*/
@EventHandler
public void onPlayerAttack(CustomDamageEvent event)
{
Player damager = event.GetDamagerPlayer(true);
Player damagee = event.GetDamageePlayer();
// Trigger custom gear effects for attacker
if (damager != null)
{
PlayerGear attackerGear = getGear(damager);
attackerGear.onAttack(event);
}
// Trigger custom gear effects for defender
if (damagee != null)
{
PlayerGear defenderGear = getGear(damagee);
defenderGear.onAttacked(event);
}
}
/**
* Handle weapon ability activation of custom gear.
* @param event
*/
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
// Activate weapon interact abilities
PlayerGear playerGear = getGear(event.getPlayer());
playerGear.onInteract(event);
}
/**
* @param player - the player whose gear is to be fetched
* @return the {@link PlayerGear} associated with {@code player}.
*/
private PlayerGear getGear(Player player)
{
return GearManager.getInstane().getPlayerGear(player);
}
}

View File

@ -0,0 +1,18 @@
package mineplex.game.clans.items;
import com.google.common.collect.Sets;
import mineplex.game.clans.items.generation.WeightSet;
import mineplex.game.clans.items.legendaries.AlligatorsTooth;
import mineplex.game.clans.items.legendaries.WindBlade;
public enum ItemType
{
LEGENDARY,
ARMOUR,
WEAPON,
BOW;
}

View File

@ -0,0 +1,225 @@
package mineplex.game.clans.items;
import java.util.HashSet;
import java.util.Set;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
/**
* PlayerGear caches and manages a players set of {@link CustomItem}s that
* they currently wield.
* @author MrTwiggy
*
*/
public class PlayerGear
{
private String _playerName; // Name of player who owns the gear
// Cached custom item information for player's gear
private CustomItem weapon;
private CustomItem helmet;
private CustomItem chestplate;
private CustomItem leggings;
private CustomItem boots;
/**
* Class constructor
* @param playerName
*/
public PlayerGear(String playerName)
{
_playerName = playerName;
}
/**
* Tick & update internal logic for the PlayerGear and required custom items that are
* equipped.
*/
public void update()
{
if (isOnline())
{
CustomItem item = getWeapon();
if (item != null && item instanceof LegendaryItem)
{
LegendaryItem legendary = (LegendaryItem) item;
legendary.update(getPlayer());
}
}
}
public boolean isOnline()
{
Player player = getPlayer();
return player != null && player.isOnline();
}
/**
* @return the {@link Player} that owns this gear set.
*/
public Player getPlayer()
{
return Bukkit.getPlayer(_playerName);
}
/**
* @return the {@link PlayerInventory} associated with the owner of this {@link PlayerGear}.
*/
public PlayerInventory getInventory()
{
return getPlayer().getInventory();
}
/**
* Trigger interact events for the set of equipped {@link CustomItem}s in gear set.
* @param event - the triggering interact event
*/
public void onInteract(PlayerInteractEvent event)
{
for (CustomItem item : getGear())
{
item.onInteract(event);
}
}
/**
* Trigger on-attack events for the set of equipped {@link CustomItem}s in gear set.
* @param event - the triggering on-attack event
*/
public void onAttack(CustomDamageEvent event)
{
for (CustomItem item : getGear())
{
item.onAttack(event);
}
}
/**
* Trigger attacked events for the set of equipped {@link CustomItem}s in gear set.
* @param event - the triggering attacked event
*/
public void onAttacked(CustomDamageEvent event)
{
for (CustomItem item : getGear())
{
item.onAttacked(event);
}
}
/**
* Update appropriate gear status and item lores.
* @param event - the triggering item held change event.
*/
public void onItemHeldChanged(PlayerItemHeldEvent event)
{
ItemStack item = getPlayer().getItemInHand();
CustomItem weapon = getWeapon();
if (weapon != null)
{
weapon.update(item); // Update held-item's stats.
}
}
public CustomItem getWeapon()
{
ItemStack weaponItem = getPlayer().getInventory().getItemInHand();
if (!itemsMatch(weapon, weaponItem))
{
weapon = parseItem(weaponItem);
}
return weapon;
}
public CustomItem getHelmet()
{
ItemStack helmetItem = getPlayer().getInventory().getHelmet();
if (!itemsMatch(helmet, helmetItem))
{
helmet = parseItem(helmetItem);
}
return helmet;
}
public CustomItem getChestplate()
{
ItemStack chestplateItem = getPlayer().getInventory().getChestplate();
if (!itemsMatch(chestplate, chestplateItem))
{
chestplate = parseItem(chestplateItem);
}
return chestplate;
}
public CustomItem getLeggings()
{
ItemStack leggingsItem = getPlayer().getInventory().getLeggings();
if (!itemsMatch(leggings, leggingsItem))
{
leggings = parseItem(leggingsItem);
}
return leggings;
}
public CustomItem getBoots()
{
ItemStack bootsItem = getPlayer().getInventory().getBoots();
if (!itemsMatch(boots, bootsItem))
{
boots = parseItem(bootsItem);
}
return boots;
}
/**
* @return set of currently equipped {@link CustomItem}s in the gear set.
*/
public Set<CustomItem> getGear()
{
Set<CustomItem> items = new HashSet<CustomItem>();
if (getWeapon() != null) items.add(getWeapon());
if (getHelmet() != null) items.add(getHelmet());
if (getChestplate() != null) items.add(getChestplate());
if (getLeggings() != null) items.add(getLeggings());
if (getBoots() != null) items.add(getBoots());
return items;
}
private boolean itemsMatch(CustomItem customItem, ItemStack item)
{
if (customItem == null || item == null) return false;
if (GearManager.isCustomItem(item))
{
CustomItem customItem2 = GearManager.parseItem(item);
return customItem2.matches(customItem);
}
return false;
}
private CustomItem parseItem(ItemStack item)
{
return GearManager.parseItem(item);
}
}

View File

@ -0,0 +1,53 @@
package mineplex.game.clans.items.attributes;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
/**
* Represents an attribute that can be attached to {@link CustomItem} to augment their abilities
* and special effects on trigger.
* @author MrTwiggy
*
*/
public abstract class ItemAttribute
{
/**
* @return the attribute name display to players.
*/
public abstract String getDisplayName();
/**
* @return a user-friendly description of this attribute, entailing it's effects
* and current associated values.
*/
public String getDescription() { return "???IMPLEMENT"; }
public void onInteract(PlayerInteractEvent event)
{
// Implementation left to subclasses.
}
public void onAttack(CustomDamageEvent event)
{
// Implementation left to subclasses.
}
public void onAttacked(CustomDamageEvent event)
{
// Implementation left to subclasses.
}
/**
* @param minValue - the minimum value for attribute value range
* @param maxValue - the maximum value for attribute value range
* @return newly instantiated {@link ValueDistribution} for attribute values in range [{@code minValue}. {@code maxValue}].
*/
public static ValueDistribution generateDistribution(double minValue, double maxValue)
{
return new ValueDistribution(minValue, maxValue);
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.items.attributes.armor;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class EscapeAttribute extends ItemAttribute
{
// TODO: Replace with your generators
private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount
private int _healPercent;
public EscapeAttribute()
{
_healPercent = healGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return ""; // TODO: Fill in name
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.items.attributes.armor;
import mineplex.game.clans.items.generation.ValueDistribution;
public abstract class FlatReductionAttribute extends ReductionAttribute
{
private double _reduction;
public double getFlatReduction() { return _reduction; }
public FlatReductionAttribute(ValueDistribution reductionGen, ReductionConfig config)
{
super(config);
_reduction = reductionGen.generateValue();
}
@Override
public double getDamageReduction(double originalDamage)
{
return _reduction;
}
}

View File

@ -0,0 +1,30 @@
package mineplex.game.clans.items.attributes.armor;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class LavaAttribute extends PercentReductionAttribute
{
private static ValueDistribution reductionGen = generateDistribution(0.2d, 1.0d); // Value generator for heal amount
private static ReductionConfig lavaConfig = new ReductionConfig(DamageCause.FIRE, DamageCause.LAVA, DamageCause.FIRE_TICK);
public LavaAttribute()
{
super(reductionGen, lavaConfig);
}
@Override
public String getDisplayName()
{
return "Lava Forged";
}
@Override
public String getDescription()
{
return String.format("Reduce fire-related damage by %.2f percent.", getReductionPercent());
}
}

View File

@ -0,0 +1,29 @@
package mineplex.game.clans.items.attributes.armor;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class PaddedAttribute extends FlatReductionAttribute
{
private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d);
private static ReductionConfig config = new ReductionConfig(DamageCause.FALL);
public PaddedAttribute()
{
super(reductionGen, config);
}
@Override
public String getDisplayName()
{
return "Padded";
}
@Override
public String getDescription()
{
return String.format("Reduce fall damage by %.2f half-hearts.", getFlatReduction());
}
}

View File

@ -0,0 +1,22 @@
package mineplex.game.clans.items.attributes.armor;
import mineplex.game.clans.items.generation.ValueDistribution;
public abstract class PercentReductionAttribute extends ReductionAttribute
{
private double _reductionPercent;
public double getReductionPercent() { return _reductionPercent; }
public PercentReductionAttribute(ValueDistribution reductionGen, ReductionConfig config)
{
super(config);
_reductionPercent = reductionGen.generateValue();
}
@Override
public double getDamageReduction(double originalDamage)
{
return originalDamage * _reductionPercent;
}
}

View File

@ -0,0 +1,31 @@
package mineplex.game.clans.items.attributes.armor;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
// A.K.A Conquering for Armor
public class ProtectionAttribute extends FlatReductionAttribute
{
private static ValueDistribution reductionGen = generateDistribution(1.0d, 4.0d);
private static ReductionConfig config = new ReductionConfig(EntityType.values());
public ProtectionAttribute()
{
super(reductionGen, config);
}
@Override
public String getDisplayName()
{
return "Protection";
}
@Override
public String getDescription()
{
return String.format("Reduce incoming attack damage by %.2f half-hearts.", getFlatReduction());
}
}

View File

@ -0,0 +1,45 @@
package mineplex.game.clans.items.attributes.armor;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public abstract class ReductionAttribute extends ItemAttribute
{
private ReductionConfig _config;
public ReductionAttribute(ReductionConfig config)
{
_config = config;
}
@Override
public void onAttacked(CustomDamageEvent event)
{
DamageCause cause = event.GetCause();
Entity attacker = event.GetDamagerEntity(true);
if (_config.reducesDamage(cause, attacker))
{
double damage = event.GetDamage();
double reduction = getDamageReduction(damage);
event.AddMod("Reduction Armor", reduction);
System.out.println("Reduced damage by " + reduction);
}
else
{
System.out.println("Armour doesn't reduce " + cause);
}
}
public abstract double getDamageReduction(double originalDamage);
}

View File

@ -0,0 +1,46 @@
package mineplex.game.clans.items.attributes.armor;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class ReductionConfig
{
private Set<EntityType> _reducedAttackers; // EntityTypes whose attacks are reduced by this attribute
private Set<DamageCause> _reducedCauses; // DamageCauses that are reduced by this attribute
public ReductionConfig()
{
_reducedAttackers = new HashSet<EntityType>();
_reducedCauses = new HashSet<DamageCause>();
}
public ReductionConfig(DamageCause... reducedCauses)
{
this();
for (DamageCause cause : reducedCauses)
{
_reducedCauses.add(cause);
}
}
public ReductionConfig(EntityType... reducedAttackers)
{
this();
for (EntityType attacker : reducedAttackers)
{
_reducedAttackers.add(attacker);
}
}
public boolean reducesDamage(DamageCause cause, Entity attacker)
{
return _reducedCauses.contains(cause) || (attacker != null && _reducedAttackers.contains(attacker.getType()));
}
}

View File

@ -0,0 +1,28 @@
package mineplex.game.clans.items.attributes.armor;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.generation.ValueDistribution;
public class ReinforcedAttribute extends FlatReductionAttribute
{
private static ValueDistribution reductionGen = generateDistribution(0.5d, 1.0d);
private static ReductionConfig config = new ReductionConfig(DamageCause.ENTITY_ATTACK);
public ReinforcedAttribute()
{
super(reductionGen, config);
}
@Override
public String getDisplayName()
{
return "Reinforced";
}
@Override
public String getDescription()
{
return String.format("Reduce incoming enemy attacks by %.2f half-hearts.", getFlatReduction());
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.items.attributes.armor;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class SeaAttribute extends ItemAttribute
{
// TODO: Replace with your generators
private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount
private int _healPercent;
public SeaAttribute()
{
_healPercent = healGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return ""; // TODO: Fill in name
}
}

View File

@ -0,0 +1,29 @@
package mineplex.game.clans.items.attributes.armor;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class SlantedAttribute extends FlatReductionAttribute
{
private static ValueDistribution reductionGen = generateDistribution(0.5d, 1.5d);
private static ReductionConfig config = new ReductionConfig(DamageCause.PROJECTILE);
public SlantedAttribute()
{
super(reductionGen, config);
}
@Override
public String getDisplayName()
{
return "Slanted";
}
@Override
public String getDescription()
{
return String.format("Reduce arrow damage by %.2f half-hearts.", getFlatReduction());
}
}

View File

@ -0,0 +1,42 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
/**
* Represents an attribute that triggers a special ability after a specified number
* of attacks with a weapon possessing the attribute.
* @author MrTwiggy
*
*/
public abstract class AttackAttribute extends ItemAttribute
{
private int _attackLimit;
public int getAttackLimit() { return _attackLimit; }
private int _attackCount;
public AttackAttribute(int attackLimit)
{
_attackLimit = attackLimit;
_attackCount = 0;
}
@Override
public void onAttack(CustomDamageEvent event)
{
_attackCount++;
System.out.println("Attack count " + _attackCount + " - " + _attackLimit);
if (_attackCount >= _attackLimit)
{
_attackCount = 0;
triggerAttack(event.GetDamagerEntity(true), event.GetDamageeEntity());
}
}
public abstract void triggerAttack(Entity attacker, Entity defender);
}

View File

@ -0,0 +1,35 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.generation.ValueDistribution;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class ConqueringAttribute extends DamageAttribute
{
private static ValueDistribution damageGen = generateDistribution(1.0d, 6.0d);
public ConqueringAttribute()
{
super(damageGen);
}
@Override
public String getDisplayName()
{
return "Conquering";
}
@Override
public String getDescription()
{
return String.format("Deal an extra %.2f hearts of damage to mobs.", getBonusDamage());
}
@Override
public boolean grantBonusDamage(Entity entity)
{
return !(entity instanceof Player); // TODO: Check to see if entity is mob and/or a boss!
}
}

View File

@ -0,0 +1,30 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public abstract class DamageAttribute extends ItemAttribute
{
private double _bonusDamage;
public double getBonusDamage() { return _bonusDamage; }
public DamageAttribute(ValueDistribution damageGen)
{
_bonusDamage = damageGen.generateValue();
}
@Override
public void onAttack(CustomDamageEvent event)
{
if (grantBonusDamage(event.GetDamageeEntity()))
{
event.AddMod("Damage Attribute", _bonusDamage);
}
}
public abstract boolean grantBonusDamage(Entity defender);
}

View File

@ -0,0 +1,38 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.generation.ValueDistribution;
import org.bukkit.entity.Entity;
public class FlamingAttribute extends AttackAttribute
{
private static ValueDistribution attackGen = generateDistribution(2, 4);
private static ValueDistribution fireGen = generateDistribution(60, 120);
private int _fireDuration;
public FlamingAttribute()
{
super(attackGen.generateIntValue());
_fireDuration = fireGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return "Flaming"; // TODO: Fill in name
}
@Override
public String getDescription()
{
return String.format("Enemies catch fire for %d ticks every %d attacks.", _fireDuration, getAttackLimit());
}
@Override
public void triggerAttack(Entity attacker, Entity defender)
{
defender.setFireTicks(_fireDuration);
}
}

View File

@ -0,0 +1,62 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
/**
* Frosted attribute to be added onto custom armour. Applies a slowing effect to players that
* attack the wearer of a Frosted {@link CustomItem}.
* @author MrTwiggy
*
*/
public class FrostedAttribute extends ItemAttribute
{
private static ValueDistribution amountGen = generateDistribution(0, 3); // Value generator for slow amount range
private static ValueDistribution durationGen = generateDistribution(20, 60); // Value generator for slow duration range
private int _slowAmount; // The slowness level/amplifier
private int _slowDuration; // The duration (in ticks) of slow effect
/**
* Class constructor
*/
public FrostedAttribute()
{
_slowAmount = amountGen.generateIntValue();
_slowDuration = durationGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return "Frosted";
}
@Override
public String getDescription()
{
return String.format("Apply slowness %d for %d ticks to enemies.", _slowAmount, _slowDuration);
}
@Override
public void onAttacked(CustomDamageEvent event)
{
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
{
damager.addPotionEffect(generateSlowEffect()); // Slow attacking player
}
}
private PotionEffect generateSlowEffect()
{
return new PotionEffect(PotionEffectType.SLOW, _slowDuration, _slowAmount);
}
}

View File

@ -0,0 +1,50 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.generation.ValueDistribution;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class HasteAttribute extends AttackAttribute
{
private static ValueDistribution attackGen = generateDistribution(2, 4);
private static ValueDistribution speedGen = generateDistribution(0, 2);
private static ValueDistribution durationGen = generateDistribution(60, 120);
private int _speedAmount;
private int _speedDuration;
public HasteAttribute()
{
super(attackGen.generateIntValue());
_speedAmount = speedGen.generateIntValue();
_speedDuration = durationGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return "Haste";
}
@Override
public String getDescription()
{
return String.format("Gain speed %d for %d ticks every %d attacks.", _speedAmount, _speedDuration, getAttackLimit());
}
@Override
public void triggerAttack(Entity attacker, Entity defender)
{
if (attacker instanceof Player)
{
Player player = (Player) attacker;
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, _speedDuration, _speedAmount));
}
}
}

View File

@ -0,0 +1,25 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class HeavyAttribute extends ItemAttribute
{
// TODO: Replace with your generators
private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount
private int _healPercent;
public HeavyAttribute()
{
_healPercent = healGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return ""; // TODO: Fill in name
}
}

View File

@ -0,0 +1,35 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.generation.ValueDistribution;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class JaggedAttribute extends AttackAttribute
{
private static ValueDistribution attackGen = generateDistribution(2, 4);
public JaggedAttribute()
{
super(attackGen.generateIntValue());
}
@Override
public String getDisplayName()
{
return "Jagged";
}
@Override
public String getDescription()
{
return String.format("Temporarily halt enemies every %d attacks.", getAttackLimit());
}
@Override
public void triggerAttack(Entity attacker, Entity defender)
{
defender.setVelocity(new Vector(0, 0, 0));
}
}

View File

@ -0,0 +1,34 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.generation.ValueDistribution;
import org.bukkit.entity.Entity;
public class SharpAttribute extends DamageAttribute
{
private static ValueDistribution damageGen = generateDistribution(0.5d, 1.5d);
public SharpAttribute()
{
super(damageGen);
}
@Override
public String getDisplayName()
{
return "Sharp";
}
@Override
public String getDescription()
{
return String.format("Deal an extra %.2f damage.", getBonusDamage());
}
@Override
public boolean grantBonusDamage(Entity defender)
{
return true;
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class SmashingAttribute extends ItemAttribute
{
// TODO: Replace with your generators
private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount
private int _healPercent;
public SmashingAttribute()
{
_healPercent = healGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return ""; // TODO: Fill in name
}
}

View File

@ -0,0 +1,24 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
public class SwiftAttribute extends ItemAttribute
{
// TODO: Replace with your generators
private static ValueDistribution healGen = generateDistribution(4, 12); // Value generator for heal amount
private int _healPercent;
public SwiftAttribute()
{
_healPercent = healGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return ""; // TODO: Fill in name
}
}

View File

@ -0,0 +1,47 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class VampiricAttribute extends ItemAttribute
{
private static ValueDistribution healGen = generateDistribution(4, 12);
private int _healPercent;
public VampiricAttribute()
{
_healPercent = healGen.generateIntValue();
}
@Override
public String getDisplayName()
{
return "Vampiric";
}
@Override
public String getDescription()
{
return String.format("Heal yourself for %d percentage of damage dealt to enemy players.", _healPercent);
}
@Override
public void onAttack(CustomDamageEvent event)
{
Player damager = event.GetDamagerPlayer(true);
double damage = event.GetDamage();
double healAmount = damage * (_healPercent / 100d);
heal(damager, healAmount);
}
private void heal(Player player, double healAmount)
{
player.setHealth(player.getHealth() + healAmount);
}
}

View File

@ -0,0 +1,66 @@
package mineplex.game.clans.items.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.Vector;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInput;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanRole;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.items.CustomItem;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.attributes.weapon.FlamingAttribute;
import mineplex.game.clans.items.attributes.weapon.FrostedAttribute;
import mineplex.game.clans.items.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.legendaries.LegendaryItem;
import mineplex.game.clans.items.legendaries.WindBlade;
public class GearCommand extends CommandBase<GearManager>
{
private GearManager _gearManager;
public GearCommand(GearManager plugin)
{
super(plugin, Rank.ALL, "gear", "custom-gear");
_gearManager = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, F.main("Gear", "Opening custom gear GUI!"));
if (args == null || args.length == 0)
{
Vector direction = caller.getLocation().getDirection().normalize();
_gearManager.spawnItem(caller.getEyeLocation().add(direction));
}
else
{
Vector direction = caller.getLocation().getDirection().normalize();
_gearManager.spawnItem(caller.getEyeLocation().add(direction));
}
}
}

View File

@ -0,0 +1,25 @@
package mineplex.game.clans.items.economy;
import org.bukkit.Material;
import mineplex.game.clans.items.CustomItem;;
public class GoldToken extends CustomItem
{
private int _goldValue;
public int getGoldValue() { return _goldValue; }
public GoldToken(int goldValue)
{
super("Gold Token", null, Material.GOLD_INGOT);
_goldValue = goldValue;
}
@Override
public String getDescription()
{
return String.format("A gold token worth %s gold coins.", _goldValue);
}
}

View File

@ -0,0 +1,56 @@
package mineplex.game.clans.items.generation;
import java.util.Random;
/**
* Handles the random generation of attribute values in specified value range
* and probability distribution.
* @author MrTwiggy
*
*/
public class ValueDistribution
{
private static Random random = new Random(); // Used for RNG of value generation
private double _min; // Minimum value range available for distribution
private double _max; // Maximum value range available for distribution
private double _lambdaScaler; // Scales exponential probability distribution to skew range values
/**
* Class constructor for distribution of range [min, max]
* @param min - the minimum value for generation range
* @param max - the maximum value for generation range
*/
public ValueDistribution(double min, double max)
{
_min = min;
_max = max;
}
/**
* @return randomly generated value conforming to the range and value distribution.
*/
public double generateValue()
{
double roll = random.nextDouble() * random.nextDouble();
double delta = getRange() * roll;
return _min + delta;
}
/**
* @return randomly generated distribution value, rounding to nearest integer.
*/
public int generateIntValue()
{
return (int) Math.round(generateValue());
}
/**
* @return the value range associated with this distribution.
*/
public double getRange()
{
return _max - _min;
}
}

View File

@ -0,0 +1,19 @@
package mineplex.game.clans.items.generation;
public class Weight<T>
{
private int _weight;
public int getWeight() { return _weight; }
private T _value;
public T getValue() { return _value; }
public Weight(int weight, T value)
{
_weight = weight;
_value = value;
}
}

View File

@ -0,0 +1,94 @@
package mineplex.game.clans.items.generation;
import java.util.Collection;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class WeightSet<T>
{
private static Random random = new Random();
private Set<Weight<T>> _weights;
private WeightSet()
{
_weights = new HashSet<Weight<T>>();
}
@SafeVarargs
public WeightSet(Weight<T>... weights)
{
this();
for (Weight<T> weight : weights)
{
_weights.add(weight);
}
}
@SafeVarargs
public WeightSet(T... elements)
{
this();
for (T element : elements)
{
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
}
}
public WeightSet(Collection<T> elements)
{
this();
for (T element : elements)
{
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
}
}
private int getTotalWeight()
{
int total = 0;
for (Weight<T> weight : _weights)
{
total += weight.getWeight();
}
return total;
}
public T generateRandom()
{
int totalWeight = getTotalWeight();
int roll = random.nextInt(totalWeight);
for (Weight<T> weight : _weights)
{
roll -= weight.getWeight();
if (roll <= 0)
{
return weight.getValue();
}
}
// Should never reach here.
return null;
}
public Set<T> elements()
{
Set<T> elements = new HashSet<T>();
for (Weight<T> weight : _weights)
{
elements.add(weight.getValue());
}
return elements;
}
}

View File

@ -0,0 +1,61 @@
package mineplex.game.clans.items.legendaries;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.game.clans.items.generation.ValueDistribution;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class AlligatorsTooth extends LegendaryItem
{
private static ValueDistribution boostGen = generateDistribution(0.6d, 1.2d);
private static ValueDistribution damageGen = generateDistribution(1.0d, 6.0d);
private double _damageBonus;
private double _swimSpeed;
public AlligatorsTooth()
{
super("Alligators Tooth", "Grants bonus damage in water and special ability to swim fast!", Material.RAW_FISH);
_damageBonus = damageGen.generateValue();
_swimSpeed = boostGen.generateValue();
}
@Override
public void update(Player wielder)
{
if (isHoldingRightClick() && isInWater(wielder))
{
propelPlayer(wielder);
}
}
@Override
public void onAttack(CustomDamageEvent event, Player wielder)
{
if (isInWater(wielder))
{
event.AddMod("Alligators Tooth", _damageBonus);
event.AddKnockback("Alligators Tooth", 0.5d);
}
super.onAttack(event);
}
private void propelPlayer(Player player)
{
Vector direction = player.getLocation().getDirection().normalize();
direction.multiply(_swimSpeed);
player.setVelocity(direction);
}
private boolean isInWater(Player player)
{
return player.getLocation().getBlock().isLiquid();
}
}

View File

@ -0,0 +1,54 @@
package mineplex.game.clans.items.legendaries;
import java.util.HashSet;
import java.util.Set;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class GiantsBroadsword extends LegendaryItem
{
public GiantsBroadsword()
{
super("Giants Broadsword", "Deal huge damage and block to gain defensive abilities!", Material.PAPER);
}
@Override
public void update(Player wielder)
{
if (isHoldingRightClick())
{
buffPlayer(wielder);
}
}
@Override
public void onAttack(CustomDamageEvent event, Player wielder)
{
double bonusDamage = 2.0d; // Too much?
event.AddMod("Giants Bonus", bonusDamage);
event.AddKnockback("Giants Sword", 0.5d);
}
private void buffPlayer(Player player)
{
player.addPotionEffects(generateBlockBuff());
}
private Set<PotionEffect> generateBlockBuff()
{
Set<PotionEffect> potions = new HashSet<PotionEffect>();
// Slow 5 and Regen 1 for 5 ticks
potions.add(new PotionEffect(PotionEffectType.SLOW, 4, 5));
potions.add(new PotionEffect(PotionEffectType.REGENERATION, 0, 5));
return potions;
}
}

Some files were not shown because too many files have changed in this diff Show More