Merge branch 'update/hub-makeover' into develop
This commit is contained in:
commit
169feb1efb
@ -7,7 +7,7 @@
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-parent</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<relativePath>../plugin.xml</relativePath>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>ClansQueue-Common</name>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.mineplex.clansqueue.common;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class SortableLinkedList<T extends Comparable<T>> extends LinkedList<T>
|
||||
@ -8,6 +9,6 @@ public class SortableLinkedList<T extends Comparable<T>> extends LinkedList<T>
|
||||
|
||||
public void sort()
|
||||
{
|
||||
sort((t1, t2) -> t1.compareTo(t2));
|
||||
sort(Comparator.naturalOrder());
|
||||
}
|
||||
}
|
@ -8,69 +8,62 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
|
||||
/**
|
||||
* A simple 3D vector stored shape
|
||||
* A simple 3D vector stored shape
|
||||
*/
|
||||
|
||||
public class Shape
|
||||
{
|
||||
|
||||
|
||||
protected final static double DEFAULT_DENSITY = 1;
|
||||
|
||||
|
||||
protected HashSet<Vector> _points = new HashSet<>();
|
||||
|
||||
public Shape(){}
|
||||
|
||||
|
||||
public Shape(Collection<Vector> points){
|
||||
this._points.addAll(points);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate this shape along the X-axis
|
||||
* @param radians Radians to rotate the shape
|
||||
*/
|
||||
public void rotateOnXAxis(double radians)
|
||||
{
|
||||
for(Vector v : _points)
|
||||
for(Vector v : _points)
|
||||
{
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
v.setY(y * Math.cos(radians) - z * Math.sin(radians));
|
||||
v.setZ(y * Math.sin(radians) + z * Math.cos(radians));
|
||||
UtilAlg.rotateAroundXAxis(v, radians);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate this shape along the Y-axis
|
||||
* @param radians Radians to rotate the shape
|
||||
*/
|
||||
public void rotateOnYAxis(double radians)
|
||||
{
|
||||
for(Vector v : _points)
|
||||
for(Vector v : _points)
|
||||
{
|
||||
double x = v.getX();
|
||||
double z = v.getZ();
|
||||
v.setX(x * Math.cos(radians) - z * Math.sin(radians));
|
||||
v.setZ(x * Math.sin(radians) + z * Math.cos(radians));
|
||||
UtilAlg.rotateAroundYAxis(v, radians);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate this shape along the Z-axis
|
||||
* @param radians Radians to rotate the shape
|
||||
*/
|
||||
public void rotateOnZAxis(double radians)
|
||||
{
|
||||
for(Vector v : _points)
|
||||
for(Vector v : _points)
|
||||
{
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
v.setX(x * Math.cos(radians) - y * Math.sin(radians));
|
||||
v.setY(x * Math.sin(radians) + y * Math.cos(radians));
|
||||
}
|
||||
|
||||
UtilAlg.rotateAroundZAxis(v, radians);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Offsets all the points based on the given vector
|
||||
* @param v
|
||||
@ -79,26 +72,26 @@ public class Shape
|
||||
{
|
||||
for(Vector p : _points) p.add(v);
|
||||
}
|
||||
|
||||
|
||||
public void addPoint(Vector v)
|
||||
{
|
||||
_points.add(v);
|
||||
}
|
||||
|
||||
|
||||
public boolean removePoint(Vector v)
|
||||
{
|
||||
return _points.remove(v);
|
||||
}
|
||||
|
||||
|
||||
public Set<Vector> getPoints()
|
||||
{
|
||||
return new HashSet<>(_points);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Multiply all the points by m.
|
||||
* If m > 1 then the shape will become larger.
|
||||
* If m < 1 then the shape will become smaller.
|
||||
* Multiply all the points by m.
|
||||
* If m > 1 then the shape will become larger.
|
||||
* If m < 1 then the shape will become smaller.
|
||||
* If m = 1 then the shape will stay the same.
|
||||
* If m < 0 then the shape will become inverted.
|
||||
* @param m
|
||||
@ -107,7 +100,7 @@ public class Shape
|
||||
{
|
||||
for(Vector v : _points) v.multiply(m);
|
||||
}
|
||||
|
||||
|
||||
public Shape clone() {
|
||||
List<Vector> list = new ArrayList<>();
|
||||
for(Vector p : _points)
|
||||
@ -116,12 +109,12 @@ public class Shape
|
||||
}
|
||||
return new Shape(list);
|
||||
}
|
||||
|
||||
|
||||
public Vector getMidPoint()
|
||||
{
|
||||
return getMaxAABBCorner().subtract(getMinAABBCorner()).multiply(0.5);
|
||||
}
|
||||
|
||||
|
||||
public Vector getMaxAABBCorner()
|
||||
{
|
||||
Vector max = null;
|
||||
@ -138,7 +131,7 @@ public class Shape
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
public Vector getMinAABBCorner()
|
||||
{
|
||||
Vector min = null;
|
||||
@ -155,7 +148,7 @@ public class Shape
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the closest length which will be a factor of the provided length, but not longer then max
|
||||
* E.g. You want to split a length of 9 into even peaces, but the peaces should not be longer than the max 5, then this will
|
||||
@ -164,12 +157,12 @@ public class Shape
|
||||
* @param max The max distance of the returned length
|
||||
* @return The closest to length to be a factor of the provided length which is <= max
|
||||
*/
|
||||
|
||||
|
||||
public static double getRoundFactor(double length, double max)
|
||||
{
|
||||
return length/Math.ceil(length/max);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the closest RoundFactor length applied to a vector, using the vector as the max length. The returned vector is a cloned
|
||||
* parallel vector to the provided length
|
||||
@ -177,13 +170,13 @@ public class Shape
|
||||
* @param maxLength The max length of the new returned vector
|
||||
* @return Returns a parallel vector to the given length vector which is also a factor of the provided vector, but not longer
|
||||
* then maxLength
|
||||
*
|
||||
*
|
||||
* @see #getRoundFactor(double, double)
|
||||
*/
|
||||
public static Vector getVectorFactor(Vector length, double maxLength)
|
||||
{
|
||||
return length.clone().multiply(getRoundFactor(length.length(), maxLength));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -175,14 +175,13 @@ public class SkinData
|
||||
return "_" + _nameCount;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* Creates a {@link SkinData} from a given {@link GameProfile}.
|
||||
* Will return null if the GameProfile does not have any texture data
|
||||
*
|
||||
* @param input The GameProfile to get textures from
|
||||
* @param requireSecure Whether the SkinData should be signed
|
||||
* @param useDefaultSkins Whether to subsitute an Alex or Steve skin if no textures are present
|
||||
* @param useDefaultSkins Whether to substitute an Alex or Steve skin if no textures are present
|
||||
*
|
||||
* @return The SkinData, or null if no textures are present
|
||||
*/
|
||||
|
@ -1,8 +1,16 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.TrigMath;
|
||||
@ -14,6 +22,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilAlg
|
||||
{
|
||||
|
||||
public static TreeSet<String> sortKey(Set<String> toSort)
|
||||
{
|
||||
return sortSet(toSort, null);
|
||||
@ -21,28 +30,27 @@ public class UtilAlg
|
||||
|
||||
public static <T> TreeSet<T> sortSet(Collection<T> toSort, Comparator<T> comparator)
|
||||
{
|
||||
TreeSet<T> sortedSet = new TreeSet<T>(comparator);
|
||||
for (T cur : toSort)
|
||||
sortedSet.add(cur);
|
||||
TreeSet<T> sortedSet = new TreeSet<>(comparator);
|
||||
sortedSet.addAll(toSort);
|
||||
|
||||
return sortedSet;
|
||||
}
|
||||
|
||||
|
||||
public static Location getMidpoint(Location a, Location b)
|
||||
{
|
||||
return a.clone().add(b.clone().subtract(a.clone()).multiply(0.5));
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTrajectory(Entity from, Entity to)
|
||||
{
|
||||
return getTrajectory(from.getLocation().toVector(), to.getLocation().toVector());
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTrajectory(Location from, Location to)
|
||||
{
|
||||
return getTrajectory(from.toVector(), to.toVector());
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTrajectory(Vector from, Vector to)
|
||||
{
|
||||
return to.clone().subtract(from).normalize();
|
||||
@ -56,34 +64,34 @@ public class UtilAlg
|
||||
|
||||
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
return new double[] { dx / len, dy / len, dz / len};
|
||||
return new double[]{dx / len, dy / len, dz / len};
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTrajectory2d(Entity from, Entity to)
|
||||
{
|
||||
return getTrajectory2d(from.getLocation().toVector(), to.getLocation().toVector());
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTrajectory2d(Location from, Location to)
|
||||
{
|
||||
return getTrajectory2d(from.toVector(), to.toVector());
|
||||
}
|
||||
|
||||
|
||||
public static Vector getTrajectory2d(Vector from, Vector to)
|
||||
{
|
||||
return to.clone().subtract(from).setY(0).normalize();
|
||||
}
|
||||
|
||||
public static boolean HasSight(Location from, Player to)
|
||||
public static boolean HasSight(Location from, Player to)
|
||||
{
|
||||
return HasSight(from, to.getLocation()) || HasSight(from, to.getEyeLocation());
|
||||
}
|
||||
|
||||
public static boolean HasSight(Location from, Location to)
|
||||
public static boolean HasSight(Location from, Location to)
|
||||
{
|
||||
//Clone Location
|
||||
Location cur = new Location(from.getWorld(), from.getX(), from.getY(), from.getZ());
|
||||
|
||||
Location cur = new Location(from.getWorld(), from.getX(), from.getY(), from.getZ());
|
||||
|
||||
double rate = 0.1;
|
||||
Vector vec = getTrajectory(from, to).multiply(0.1);
|
||||
|
||||
@ -97,7 +105,7 @@ public class UtilAlg
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static float GetPitch(Vector vec)
|
||||
{
|
||||
return GetPitch(vec.getX(), vec.getY(), vec.getZ());
|
||||
@ -110,11 +118,11 @@ public class UtilAlg
|
||||
|
||||
public static float GetPitch(double x, double y, double z)
|
||||
{
|
||||
double xz = Math.sqrt((x*x) + (z*z));
|
||||
double xz = Math.sqrt((x * x) + (z * z));
|
||||
|
||||
double pitch = Math.toDegrees(TrigMath.atan(xz/y));
|
||||
if (y <= 0) pitch += 90;
|
||||
else pitch -= 90;
|
||||
double pitch = Math.toDegrees(TrigMath.atan(xz / y));
|
||||
if (y <= 0) pitch += 90;
|
||||
else pitch -= 90;
|
||||
|
||||
//Fix for two vectors at same Y giving 180
|
||||
if (pitch == 180)
|
||||
@ -122,7 +130,7 @@ public class UtilAlg
|
||||
|
||||
return (float) pitch;
|
||||
}
|
||||
|
||||
|
||||
public static float GetYaw(Vector vec)
|
||||
{
|
||||
return GetYaw(vec.getX(), vec.getY(), vec.getZ());
|
||||
@ -135,40 +143,35 @@ public class UtilAlg
|
||||
|
||||
public static float GetYaw(double x, double y, double z)
|
||||
{
|
||||
double yaw = Math.toDegrees(TrigMath.atan((-x)/z));
|
||||
if (z < 0) yaw += 180;
|
||||
|
||||
double yaw = Math.toDegrees(TrigMath.atan((-x) / z));
|
||||
if (z < 0) yaw += 180;
|
||||
|
||||
return (float) yaw;
|
||||
}
|
||||
|
||||
|
||||
public static Vector Normalize(Vector vec)
|
||||
{
|
||||
if (vec.length() > 0)
|
||||
vec.normalize();
|
||||
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
public static Vector Clone(Vector vec)
|
||||
{
|
||||
return new Vector(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
|
||||
public static <T> T Random(Set<T> set)
|
||||
public static <T> T Random(Set<T> set)
|
||||
{
|
||||
List<T> list = new ArrayList<T>();
|
||||
|
||||
|
||||
list.addAll(set);
|
||||
|
||||
|
||||
return Random(list);
|
||||
}
|
||||
|
||||
|
||||
public static <T> T Random(List<T> list)
|
||||
|
||||
|
||||
public static <T> T Random(List<T> list)
|
||||
{
|
||||
if (list.isEmpty())
|
||||
return null;
|
||||
|
||||
|
||||
return list.get(UtilMath.r(list.size()));
|
||||
}
|
||||
|
||||
@ -215,69 +218,69 @@ public class UtilAlg
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB)
|
||||
public static boolean inBoundingBox(Location loc, Location cornerA, Location cornerB)
|
||||
{
|
||||
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
|
||||
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
|
||||
|
||||
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
|
||||
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
|
||||
|
||||
if (cornerA.getY() != cornerB.getY())
|
||||
{
|
||||
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
|
||||
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
|
||||
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
|
||||
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
|
||||
}
|
||||
|
||||
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
|
||||
|
||||
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean inBoundingBox(Location loc, Vector cornerA, Vector cornerB)
|
||||
{
|
||||
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
|
||||
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
|
||||
|
||||
if (loc.getX() <= Math.min(cornerA.getX(), cornerB.getX())) return false;
|
||||
if (loc.getX() >= Math.max(cornerA.getX(), cornerB.getX())) return false;
|
||||
|
||||
if (cornerA.getY() != cornerB.getY())
|
||||
{
|
||||
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
|
||||
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
|
||||
if (loc.getY() <= Math.min(cornerA.getY(), cornerB.getY())) return false;
|
||||
if (loc.getY() >= Math.max(cornerA.getY(), cornerB.getY())) return false;
|
||||
}
|
||||
|
||||
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
|
||||
|
||||
if (loc.getZ() <= Math.min(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
if (loc.getZ() >= Math.max(cornerA.getZ(), cornerB.getZ())) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static Vector cross(Vector a, Vector b)
|
||||
{
|
||||
double x = a.getY()*b.getZ() - a.getZ()*b.getY();
|
||||
double y = a.getZ()*b.getX() - a.getX()*b.getZ();
|
||||
double z = a.getX()*b.getY() - a.getY()*b.getX();
|
||||
|
||||
return new Vector(x,y,z).normalize();
|
||||
double x = a.getY() * b.getZ() - a.getZ() * b.getY();
|
||||
double y = a.getZ() * b.getX() - a.getX() * b.getZ();
|
||||
double z = a.getX() * b.getY() - a.getY() * b.getX();
|
||||
|
||||
return new Vector(x, y, z).normalize();
|
||||
}
|
||||
|
||||
|
||||
public static Vector getRight(Vector vec)
|
||||
{
|
||||
return cross(vec.clone().normalize(), new Vector(0,1,0));
|
||||
return cross(vec.clone().normalize(), new Vector(0, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
public static Vector getLeft(Vector vec)
|
||||
{
|
||||
return getRight(vec).multiply(-1);
|
||||
}
|
||||
|
||||
|
||||
public static Vector getBehind(Vector vec)
|
||||
{
|
||||
return vec.clone().multiply(-1);
|
||||
}
|
||||
|
||||
|
||||
public static Vector getUp(Vector vec)
|
||||
{
|
||||
return getDown(vec).multiply(-1);
|
||||
}
|
||||
|
||||
|
||||
public static Vector getDown(Vector vec)
|
||||
{
|
||||
return cross(vec, getRight(vec));
|
||||
@ -287,37 +290,37 @@ public class UtilAlg
|
||||
{
|
||||
if (locs.isEmpty())
|
||||
return null;
|
||||
|
||||
Vector vec = new Vector(0,0,0);
|
||||
|
||||
Vector vec = new Vector(0, 0, 0);
|
||||
double amount = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
vec.add(loc.toVector());
|
||||
amount++;
|
||||
}
|
||||
|
||||
vec.multiply(1d/amount);
|
||||
|
||||
|
||||
vec.multiply(1d / amount);
|
||||
|
||||
return vec.toLocation(locs.get(0).getWorld());
|
||||
}
|
||||
|
||||
|
||||
public static Location getAverageBlockLocation(List<Block> locs)
|
||||
{
|
||||
if (locs.isEmpty())
|
||||
return null;
|
||||
|
||||
Vector vec = new Vector(0,0,0);
|
||||
|
||||
Vector vec = new Vector(0, 0, 0);
|
||||
double amount = 0;
|
||||
|
||||
|
||||
for (Block loc : locs)
|
||||
{
|
||||
vec.add(loc.getLocation().toVector());
|
||||
amount++;
|
||||
}
|
||||
|
||||
vec.multiply(1d/amount);
|
||||
|
||||
|
||||
vec.multiply(1d / amount);
|
||||
|
||||
return vec.toLocation(locs.get(0).getWorld());
|
||||
}
|
||||
|
||||
@ -325,217 +328,217 @@ public class UtilAlg
|
||||
{
|
||||
if (locs.isEmpty())
|
||||
return null;
|
||||
|
||||
Vector vec = new Vector(0,0,0);
|
||||
|
||||
Vector vec = new Vector(0, 0, 0);
|
||||
double amount = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
vec.add(UtilAlg.getTrajectory(loc, source));
|
||||
amount++;
|
||||
}
|
||||
|
||||
vec.multiply(1d/amount);
|
||||
|
||||
|
||||
vec.multiply(1d / amount);
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
public static Entity findClosest(Entity mid, ArrayList<Entity> locs)
|
||||
{
|
||||
Entity bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
|
||||
for (Entity loc : locs)
|
||||
{
|
||||
double dist = UtilMath.offset(mid, loc);
|
||||
|
||||
|
||||
if (bestLoc == null || dist < bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location findClosest(Location mid, ArrayList<Location> locs)
|
||||
public static Location findClosest(Location mid, List<Location> locs)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double dist = UtilMath.offset(mid, loc);
|
||||
|
||||
|
||||
if (bestLoc == null || dist < bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location findFurthest(Location mid, ArrayList<Location> locs)
|
||||
|
||||
public static Location findFurthest(Location mid, List<Location> locs)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double dist = UtilMath.offset(mid, loc);
|
||||
|
||||
|
||||
if (bestLoc == null || dist > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isInPyramid(Vector a, Vector b, double angleLimit)
|
||||
{
|
||||
return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit);
|
||||
}
|
||||
|
||||
public static boolean isTargetInPlayerPyramid(Player player, Player target, double angleLimit)
|
||||
|
||||
public static boolean isTargetInPlayerPyramid(Player player, Player target, double angleLimit)
|
||||
{
|
||||
return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) ||
|
||||
isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit);
|
||||
}
|
||||
|
||||
public static Location getLocationAwayFromPlayers(ArrayList<Location> locs, ArrayList<Player> players)
|
||||
public static Location getLocationAwayFromPlayers(ArrayList<Location> locs, ArrayList<Player> players)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double closest = -1;
|
||||
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
//Different Worlds
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
|
||||
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||
|
||||
|
||||
if (closest == -1 || dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (closest == -1)
|
||||
continue;
|
||||
|
||||
|
||||
if (bestLoc == null || closest > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = closest;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationAwayFromOtherLocations(ArrayList<Location> locs, ArrayList<Location> players)
|
||||
|
||||
public static Location getLocationAwayFromOtherLocations(ArrayList<Location> locs, ArrayList<Location> players)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double closest = -1;
|
||||
|
||||
|
||||
for (Location player : players)
|
||||
{
|
||||
//Different Worlds
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
|
||||
double dist = UtilMath.offsetSquared(player, loc);
|
||||
|
||||
|
||||
if (closest == -1 || dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (closest == -1)
|
||||
continue;
|
||||
|
||||
|
||||
if (bestLoc == null || closest > bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = closest;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||
|
||||
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
double closest = -1;
|
||||
|
||||
|
||||
boolean valid = true;
|
||||
|
||||
|
||||
//Dont spawn on other players
|
||||
for (Player player : dontOverlap)
|
||||
{
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
|
||||
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||
|
||||
|
||||
if (dist < 0.8)
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!valid)
|
||||
continue;
|
||||
|
||||
|
||||
//Find closest player
|
||||
for (Player player : players)
|
||||
{
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
|
||||
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||
|
||||
|
||||
if (closest == -1 || dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (closest == -1)
|
||||
continue;
|
||||
|
||||
|
||||
if (bestLoc == null || closest < bestDist)
|
||||
{
|
||||
bestLoc = loc;
|
||||
bestDist = closest;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
|
||||
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, Entity entity)
|
||||
{
|
||||
if (entity instanceof LivingEntity)
|
||||
@ -584,47 +587,47 @@ public class UtilAlg
|
||||
double vz = vh * dirz;
|
||||
return new Vector(vx, vy, vz);
|
||||
}
|
||||
|
||||
|
||||
public static Location getNearestCornerLocation(Location near, Block block)
|
||||
{
|
||||
ArrayList<Location> corners = new ArrayList<Location>();
|
||||
|
||||
|
||||
corners.add(block.getLocation().clone());
|
||||
corners.add(block.getLocation().clone().add(.999, 0, 0));
|
||||
corners.add(block.getLocation().clone().add(.999, 0, .999));
|
||||
corners.add(block.getLocation().clone().add(0, 0, .999));
|
||||
|
||||
|
||||
corners.add(block.getLocation().clone().add(0, .999, 0));
|
||||
corners.add(block.getLocation().clone().add(.999, .999, 0));
|
||||
corners.add(block.getLocation().clone().add(.999, .999, .999));
|
||||
corners.add(block.getLocation().clone().add(0, .999, .999));
|
||||
|
||||
|
||||
return UtilAlg.findClosest(near, corners);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSimilar(Location a, Location b)
|
||||
{
|
||||
return a.getWorld() == b.getWorld() && a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ();
|
||||
}
|
||||
|
||||
public static int randomMidpoint(int min, int max)
|
||||
public static int randomMidpoint(int min, int max)
|
||||
{
|
||||
int variance = max - min;
|
||||
|
||||
|
||||
int value = UtilMath.r(variance);
|
||||
|
||||
|
||||
value += min;
|
||||
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static EulerAngle vectorToEuler(Vector vector)
|
||||
{
|
||||
//JUST MAKE SURE THE ARMOR STAND ISNT ROTATED.
|
||||
|
||||
|
||||
return new EulerAngle(
|
||||
Math.toRadians(UtilAlg.GetPitch(vector)),
|
||||
Math.toRadians(UtilAlg.GetPitch(vector)),
|
||||
Math.toRadians(UtilAlg.GetYaw(vector)),
|
||||
0);
|
||||
}
|
||||
@ -638,12 +641,12 @@ public class UtilAlg
|
||||
{
|
||||
double x = location.getX();
|
||||
double z = location.getZ();
|
||||
|
||||
|
||||
double rad = Math.toRadians(yaw);
|
||||
|
||||
|
||||
x = reverse ? (x + strength * Math.sin(rad)) : (x - strength * Math.sin(rad));
|
||||
z = reverse ? (z - strength * Math.cos(rad)) : (z + strength * Math.cos(rad));
|
||||
|
||||
|
||||
return new Location(location.getWorld(), x, location.getY(), z, location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
@ -658,7 +661,8 @@ public class UtilAlg
|
||||
|
||||
/**
|
||||
* Gets a random location, with specific radius
|
||||
* @param center The center location
|
||||
*
|
||||
* @param center The center location
|
||||
* @param radiusX The X radius
|
||||
* @param radiusY The Y radius
|
||||
* @param radiusZ The Z radius
|
||||
@ -670,12 +674,40 @@ public class UtilAlg
|
||||
double x = minX + (UtilMath.random.nextDouble() * 2 * radiusX);
|
||||
double y = minY + (UtilMath.random.nextDouble() * 2 * radiusY);
|
||||
double z = minZ + (UtilMath.random.nextDouble() * 2 * radiusZ);
|
||||
Location newLocation = center.clone().add((radiusX == 0) ? 0 : x, (radiusY == 0) ? 0 : y, (radiusZ == 0) ? 0 : z);
|
||||
return newLocation;
|
||||
return center.clone().add((radiusX == 0) ? 0 : x, (radiusY == 0) ? 0 : y, (radiusZ == 0) ? 0 : z);
|
||||
}
|
||||
|
||||
public static Location getRandomLocation(Location center, double radius)
|
||||
{
|
||||
return getRandomLocation(center, radius, radius, radius);
|
||||
}
|
||||
|
||||
public static Vector rotateAroundXAxis(Vector vec, double angle)
|
||||
{
|
||||
double y = vec.getY(), z = vec.getZ(), sin = Math.sin(angle), cos = Math.cos(angle);
|
||||
return vec.setY(y * cos - z * sin).setZ(y * sin + z * cos);
|
||||
}
|
||||
|
||||
public static Vector rotateAroundYAxis(Vector vec, double angle)
|
||||
{
|
||||
double x = vec.getX(), z = vec.getZ(), sin = Math.sin(angle), cos = Math.cos(angle);
|
||||
return vec.setX(x * cos - z * sin).setZ(x * sin + z * cos);
|
||||
}
|
||||
|
||||
public static Vector rotateAroundZAxis(Vector vec, double angle)
|
||||
{
|
||||
double x = vec.getX(), y = vec.getY(), sin = Math.sin(angle), cos = Math.cos(angle);
|
||||
return vec.setX(x * cos - y * sin).setZ(x * sin + y * cos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the yaw of a location to face the nearest location in the lookAt collection.
|
||||
*
|
||||
* @param location The location to adjust the yaw of
|
||||
* @param lookAt The list of locations to look at
|
||||
*/
|
||||
public static void lookAtNearest(Location location, List<Location> lookAt)
|
||||
{
|
||||
location.setYaw(GetYaw(getTrajectory(location, findClosest(location, lookAt))));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -98,7 +99,7 @@ public class UtilBlock
|
||||
/**
|
||||
* All horizontal diections [north, east, south, west]
|
||||
*/
|
||||
public static HashSet<BlockFace> horizontals = new HashSet<>();
|
||||
public static List<BlockFace> horizontals = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST);
|
||||
|
||||
private static MultiBlockUpdaterAgent _quickChangeRecorder;
|
||||
|
||||
@ -325,11 +326,6 @@ public class UtilBlock
|
||||
blockUseSet.add((byte) Material.JUNGLE_DOOR.getId());
|
||||
blockUseSet.add((byte) Material.ACACIA_DOOR.getId());
|
||||
blockUseSet.add((byte) Material.DARK_OAK_DOOR.getId());
|
||||
|
||||
horizontals.add(BlockFace.NORTH);
|
||||
horizontals.add(BlockFace.EAST);
|
||||
horizontals.add(BlockFace.SOUTH);
|
||||
horizontals.add(BlockFace.WEST);
|
||||
}
|
||||
|
||||
public static boolean solid(Block block)
|
||||
@ -1740,5 +1736,10 @@ public class UtilBlock
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public static BlockFace getFace(float yaw)
|
||||
{
|
||||
return horizontals.get(Math.round(yaw / 90F) & 0x3);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,8 +43,6 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -54,8 +52,8 @@ public class UtilEnt
|
||||
public static final String FLAG_ENTITY_COMPONENT = "component";
|
||||
|
||||
//Custom Entity Names
|
||||
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();
|
||||
private static HashMap<String, EntityType> creatureMap = new HashMap<String, EntityType>();
|
||||
private static HashMap<Entity, String> _nameMap = new HashMap<>();
|
||||
private static HashMap<String, EntityType> creatureMap = new HashMap<>();
|
||||
|
||||
private static Field _goalSelector;
|
||||
private static Field _targetSelector;
|
||||
@ -293,19 +291,7 @@ public class UtilEnt
|
||||
creature.setVegetated(true);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SecurityException e)
|
||||
catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -574,7 +560,7 @@ public class UtilEnt
|
||||
|
||||
public static HashMap<LivingEntity, Double> getInRadius(Location loc, double dR)
|
||||
{
|
||||
HashMap<LivingEntity, Double> ents = new HashMap<LivingEntity, Double>();
|
||||
HashMap<LivingEntity, Double> ents = new HashMap<>();
|
||||
|
||||
for (Entity cur : loc.getWorld().getEntities())
|
||||
{
|
||||
@ -588,7 +574,7 @@ public class UtilEnt
|
||||
|
||||
if (offset < dR)
|
||||
{
|
||||
ents.put(ent, Double.valueOf(1 - (offset/dR)));
|
||||
ents.put(ent, 1 - (offset / dR));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -597,8 +583,7 @@ public class UtilEnt
|
||||
|
||||
if (offset < dR)
|
||||
{
|
||||
ents.put(ent, Double.valueOf(1 - (offset/dR)));
|
||||
continue;
|
||||
ents.put(ent, 1 - (offset / dR));
|
||||
}
|
||||
}
|
||||
|
||||
@ -619,8 +604,7 @@ public class UtilEnt
|
||||
|
||||
if (offset < dR)
|
||||
{
|
||||
ents.put(cur, Double.valueOf(1 - (offset/dR)));
|
||||
continue;
|
||||
ents.put(cur, 1 - (offset / dR));
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,10 +617,7 @@ public class UtilEnt
|
||||
{
|
||||
if (disguise == EntityType.SQUID)
|
||||
{
|
||||
if (UtilMath.offset(loc, ent.getLocation().add(0, 0.4, 0)) < 0.6 * mult)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return UtilMath.offset(loc, ent.getLocation().add(0, 0.4, 0)) < 0.6 * mult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,7 +833,7 @@ public class UtilEnt
|
||||
ec.fakePitch = pitch;
|
||||
ec.fakeYaw = yaw;
|
||||
|
||||
EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.getWorld()).tracker.trackedEntities.get(ec.getId());
|
||||
EntityTrackerEntry entry = ((WorldServer) ec.getWorld()).tracker.trackedEntities.get(ec.getId());
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
@ -1000,11 +981,6 @@ public class UtilEnt
|
||||
return .51 * ((double) size);
|
||||
}
|
||||
|
||||
public static boolean inWater(LivingEntity ent)
|
||||
{
|
||||
return ent.getLocation().getBlock().getTypeId() == 8 || ent.getLocation().getBlock().getTypeId() == 9;
|
||||
}
|
||||
|
||||
public static void setBoundingBox(Entity ent, double width, double height)
|
||||
{
|
||||
((CraftEntity)ent).getHandle().setSize((float) width, (float)height);
|
||||
@ -1042,12 +1018,6 @@ public class UtilEnt
|
||||
entity.removeMetadata(key, UtilServer.getPlugin());
|
||||
}
|
||||
|
||||
public static void SetItemInHand(LivingEntity entity, ItemStack item)
|
||||
{
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
equipment.setItemInHand(item);
|
||||
}
|
||||
|
||||
public static byte getEntityEggData(EntityType type)
|
||||
{
|
||||
switch (type)
|
||||
@ -1084,4 +1054,9 @@ public class UtilEnt
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInWater(Entity entity)
|
||||
{
|
||||
return ((CraftEntity) entity).getHandle().inWater;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -513,7 +513,11 @@ public class UtilPlayer
|
||||
|
||||
public static Player getClosest(Location loc, double maxDist, Collection<Player> ignore)
|
||||
{
|
||||
maxDist *= maxDist;
|
||||
if (maxDist > 0)
|
||||
{
|
||||
maxDist *= maxDist;
|
||||
}
|
||||
|
||||
Player best = null;
|
||||
double bestDist = 0;
|
||||
|
||||
@ -552,7 +556,10 @@ public class UtilPlayer
|
||||
|
||||
public static Player getClosest(Location loc, double maxDist, Entity... ignore)
|
||||
{
|
||||
maxDist *= maxDist;
|
||||
if (maxDist > 0)
|
||||
{
|
||||
maxDist *= maxDist;
|
||||
}
|
||||
|
||||
Player best = null;
|
||||
double bestDist = 0;
|
||||
@ -719,10 +726,7 @@ public class UtilPlayer
|
||||
public static void clearInventory(Player player)
|
||||
{
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setHelmet(null);
|
||||
player.getInventory().setChestplate(null);
|
||||
player.getInventory().setLeggings(null);
|
||||
player.getInventory().setBoots(null);
|
||||
player.getInventory().setArmorContents(null);
|
||||
}
|
||||
|
||||
public static void clearPotionEffects(Player player)
|
||||
|
@ -5,13 +5,15 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WeightSet<T>
|
||||
{
|
||||
private static Random random = new Random();
|
||||
|
||||
private static Random RANDOM = new Random();
|
||||
|
||||
private Set<Weight<T>> _weights = new HashSet<>();
|
||||
private final Set<Weight<T>> _weights = new HashSet<>();
|
||||
|
||||
private volatile transient Set<T> _keyset;
|
||||
|
||||
@ -23,10 +25,7 @@ public class WeightSet<T>
|
||||
@SafeVarargs
|
||||
public WeightSet(Weight<T>... weights)
|
||||
{
|
||||
for (Weight<T> weight : weights)
|
||||
{
|
||||
_weights.add(weight);
|
||||
}
|
||||
Collections.addAll(_weights, weights);
|
||||
computeKeyset();
|
||||
}
|
||||
|
||||
@ -35,7 +34,7 @@ public class WeightSet<T>
|
||||
{
|
||||
for (T element : elements)
|
||||
{
|
||||
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
|
||||
_weights.add(new Weight<>(1, element)); // Constant weight of 1 means all elements are equally likely
|
||||
}
|
||||
computeKeyset();
|
||||
}
|
||||
@ -44,11 +43,17 @@ public class WeightSet<T>
|
||||
{
|
||||
for (T element : elements)
|
||||
{
|
||||
_weights.add(new Weight<T>(1, element)); // Constant weight of 1 means all elements are equally likely
|
||||
_weights.add(new Weight<>(1, element)); // Constant weight of 1 means all elements are equally likely
|
||||
}
|
||||
computeKeyset();
|
||||
}
|
||||
|
||||
public WeightSet(WeightSet<T> weightSet)
|
||||
{
|
||||
_weights.addAll(weightSet._weights);
|
||||
computeKeyset();
|
||||
}
|
||||
|
||||
public Weight<T> add(int weight, T element)
|
||||
{
|
||||
Weight<T> w = new Weight<>(weight, element);
|
||||
@ -58,9 +63,18 @@ public class WeightSet<T>
|
||||
return w;
|
||||
}
|
||||
|
||||
public void remove(Weight<T> weight)
|
||||
public boolean remove(Weight<T> weight)
|
||||
{
|
||||
_weights.remove(weight);
|
||||
boolean remove = _weights.remove(weight);
|
||||
computeKeyset();
|
||||
return remove;
|
||||
}
|
||||
|
||||
public boolean removeIf(Predicate<Weight<T>> filter)
|
||||
{
|
||||
boolean remove = _weights.removeIf(filter);
|
||||
computeKeyset();
|
||||
return remove;
|
||||
}
|
||||
|
||||
private int getTotalWeight()
|
||||
@ -78,7 +92,7 @@ public class WeightSet<T>
|
||||
public T generateRandom()
|
||||
{
|
||||
int totalWeight = getTotalWeight();
|
||||
int roll = random.nextInt(totalWeight);
|
||||
int roll = RANDOM.nextInt(totalWeight);
|
||||
|
||||
for (Weight<T> weight : _weights)
|
||||
{
|
||||
|
@ -8,11 +8,18 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
public abstract class MiniDbClientPlugin<DataType extends Object> extends MiniClientPlugin<DataType> implements ILoginProcessor
|
||||
{
|
||||
|
||||
protected CoreClientManager ClientManager = null;
|
||||
|
||||
|
||||
public MiniDbClientPlugin(String moduleName)
|
||||
{
|
||||
this(moduleName, UtilServer.getPlugin(), Managers.require(CoreClientManager.class));
|
||||
}
|
||||
|
||||
public MiniDbClientPlugin(String moduleName, JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super(moduleName, plugin);
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.achievement.leveling.LevelingManager;
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
public enum Achievement
|
||||
@ -71,6 +72,16 @@ public enum Achievement
|
||||
new int[]{300},
|
||||
AchievementCategory.HOLIDAY),
|
||||
|
||||
GLOBAL_PUMPKIN_SMASHER_2017("2017 Pumpkin Smasher", 0,
|
||||
new String[]{"Global.Halloween Pumpkins 2017"},
|
||||
new String[]{"Smash 200 Flaming Pumpkins,",
|
||||
"during Halloween 2017!"},
|
||||
new int[][]{ new int[]{0,0,8000}},
|
||||
new int[]{2000},
|
||||
"",
|
||||
new String[0],
|
||||
AchievementCategory.HOLIDAY),
|
||||
|
||||
//Bridges
|
||||
BRIDGES_WINS("Bridge Champion", 600,
|
||||
new String[]{"The Bridges.Wins"},
|
||||
@ -1404,7 +1415,7 @@ public enum Achievement
|
||||
|
||||
private static int[] getExperienceLevels()
|
||||
{
|
||||
int[] levels = new int[100];
|
||||
int[] levels = new int[LevelingManager.getMaxLevel()];
|
||||
|
||||
int expReq = 0;
|
||||
|
||||
@ -1443,7 +1454,12 @@ public enum Achievement
|
||||
expReq += 5000;
|
||||
levels[i] = expReq;
|
||||
}
|
||||
|
||||
|
||||
// for (int i=100 ; i<levels.length ; i++)
|
||||
// {
|
||||
// levels[i] = expReq;
|
||||
// }
|
||||
|
||||
return levels;
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ public enum AchievementCategory
|
||||
{
|
||||
GLOBAL("Global", null,
|
||||
new StatDisplay[] { StatDisplay.GEMS_EARNED, null, new StatDisplay("Games Played", "GamesPlayed"), StatDisplay.TIME_IN_GAME, null,
|
||||
new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") },
|
||||
new StatDisplay("Daily Rewards", "DailyReward"), new StatDisplay("Times Voted", "DailyVote"), null, new StatDisplay("Chests Opened", "Treasure.Old", "Treasure.Ancient", "Treasure.Mythical") },
|
||||
Material.EMERALD, 0, GameCategory.GLOBAL, "None", false, -1),
|
||||
|
||||
|
||||
HOLIDAY("Holiday Achievements", null,
|
||||
new StatDisplay[] {},
|
||||
Material.CAKE, 0, GameCategory.HOLIDAY, "None", false, -1),
|
||||
@ -46,34 +46,34 @@ public enum AchievementCategory
|
||||
|
||||
UHC("Ultra Hardcore", null,
|
||||
new StatDisplay[] {
|
||||
new StatDisplay(C.Bold + "Solo Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCSolo, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSolo, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCSolo, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSolo, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSolo, "GemsEarned"),
|
||||
null,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Teams Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHC, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHC, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHC, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHC, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHC, "GemsEarned") },
|
||||
new StatDisplay(C.Bold + "Solo Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCSolo, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSolo, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCSolo, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSolo, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSolo, "GemsEarned"),
|
||||
null,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Teams Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHC, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHC, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHC, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHC, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHC, "GemsEarned") },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSolo.getGameId(), GameDisplay.UHC.getGameId()),
|
||||
|
||||
UHC_SPEED("Ultra Hardcore Speed", null,
|
||||
new StatDisplay[] {
|
||||
new StatDisplay(C.Bold + "Solo Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCSoloSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSoloSpeed, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCSoloSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSoloSpeed, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSoloSpeed, "GemsEarned"),
|
||||
null,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Teams Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCTeamsSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCTeamsSpeed, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCTeamsSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCTeamsSpeed, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCTeamsSpeed, "GemsEarned") },
|
||||
new StatDisplay(C.Bold + "Solo Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCSoloSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCSoloSpeed, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCSoloSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCSoloSpeed, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCSoloSpeed, "GemsEarned"),
|
||||
null,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Teams Stats", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.UHCTeamsSpeed, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.UHCTeamsSpeed, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.UHCTeamsSpeed, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.UHCTeamsSpeed, "Deaths"),
|
||||
StatDisplay.fromGame("Gems Earned", GameDisplay.UHCTeamsSpeed, "GemsEarned") },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.UHC, "None", false, GameDisplay.UHCSoloSpeed.getGameId(), GameDisplay.UHCTeamsSpeed.getGameId()),
|
||||
|
||||
/*MC_LEAGUE("MC League", null,
|
||||
@ -83,36 +83,36 @@ public enum AchievementCategory
|
||||
WIZARDS("Wizards", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()),
|
||||
|
||||
|
||||
CASTLE_ASSAULT("Castle Assault", new String[] {"Castle Assault", "Castle Assault TDM"},
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.CROWNS_EARNED },
|
||||
Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleAssault.getGameId(), GameDisplay.CastleAssaultTDM.getGameId()),
|
||||
|
||||
|
||||
CASTLE_SIEGE("Castle Siege", null,
|
||||
new StatDisplay[]
|
||||
{
|
||||
StatDisplay.WINS,
|
||||
StatDisplay.GAMES_PLAYED,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Total", true),
|
||||
StatDisplay.KILLS,
|
||||
new StatDisplay("Assists", "Defender Assists", "Undead Assists"),
|
||||
StatDisplay.DEATHS,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Defenders", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Kills", GameDisplay.CastleSiege, "Defenders Kills"),
|
||||
StatDisplay.fromGame("Assists", GameDisplay.CastleSiege, "Defenders Assists"),
|
||||
StatDisplay.fromGame("Deaths", GameDisplay.CastleSiege, "Defenders Deaths"),
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Undead", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Kills", GameDisplay.CastleSiege, "Undead Kills"),
|
||||
StatDisplay.fromGame("Assists", GameDisplay.CastleSiege, "Undead Assists"),
|
||||
StatDisplay.fromGame("Deaths", GameDisplay.CastleSiege, "Undead Deaths"),
|
||||
null,
|
||||
StatDisplay.GEMS_EARNED,
|
||||
},
|
||||
{
|
||||
StatDisplay.WINS,
|
||||
StatDisplay.GAMES_PLAYED,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Total", true),
|
||||
StatDisplay.KILLS,
|
||||
new StatDisplay("Assists", "Defender Assists", "Undead Assists"),
|
||||
StatDisplay.DEATHS,
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Defenders", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Kills", GameDisplay.CastleSiege, "Defenders Kills"),
|
||||
StatDisplay.fromGame("Assists", GameDisplay.CastleSiege, "Defenders Assists"),
|
||||
StatDisplay.fromGame("Deaths", GameDisplay.CastleSiege, "Defenders Deaths"),
|
||||
null,
|
||||
new StatDisplay(C.Bold + "Undead", true),
|
||||
null,
|
||||
StatDisplay.fromGame("Kills", GameDisplay.CastleSiege, "Undead Kills"),
|
||||
StatDisplay.fromGame("Assists", GameDisplay.CastleSiege, "Undead Assists"),
|
||||
StatDisplay.fromGame("Deaths", GameDisplay.CastleSiege, "Undead Deaths"),
|
||||
null,
|
||||
StatDisplay.GEMS_EARNED,
|
||||
},
|
||||
Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, "Undead Summoner & Castle Paladin Kit", false, GameDisplay.CastleSiege.getGameId()),
|
||||
|
||||
BAWK_BAWK_BATTLES("Bawk Bawk Battles", null,
|
||||
@ -146,72 +146,72 @@ public enum AchievementCategory
|
||||
MASTER_BUILDERS("Master Builders", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
||||
Material.WOOD, 0, GameCategory.CLASSICS, "None", false, GameDisplay.Build.getGameId()),
|
||||
|
||||
|
||||
//Arcade
|
||||
DRAGONS("Dragons", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
||||
Material.ENDER_STONE, 0, GameCategory.ARCADE, null, false, GameDisplay.Dragons.getGameId()),
|
||||
|
||||
|
||||
DRAGON_ESCAPE("Dragon Escape", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
|
||||
Material.DRAGON_EGG, 0, GameCategory.ARCADE, "Digger Kit", false, GameDisplay.DragonEscape.getGameId()),
|
||||
|
||||
|
||||
SHEEP_QUEST("Sheep Quest", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.WOOL, 0, GameCategory.ARCADE, null, false, GameDisplay.Sheep.getGameId()),
|
||||
|
||||
|
||||
SNEAKY_ASSASSINS("Sneaky Assassins", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.INK_SACK, 0, GameCategory.ARCADE, "Briber Kit", false, GameDisplay.SneakyAssassins.getGameId()),
|
||||
|
||||
|
||||
ONE_IN_THE_QUIVER("One in the Quiver", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.BOW, 0, GameCategory.ARCADE, "Ninja Kit", false, GameDisplay.Quiver.getGameId()),
|
||||
|
||||
|
||||
SUPER_PAINTBALL("Super Paintball", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.ENDER_PEARL, 0, GameCategory.ARCADE, "Sniper Kit", false, GameDisplay.Paintball.getGameId()),
|
||||
|
||||
|
||||
TURF_WARS("Turf Wars", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.HARD_CLAY, 14, GameCategory.ARCADE, null, false, GameDisplay.TurfWars.getGameId()),
|
||||
|
||||
|
||||
RUNNER("Runner", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.LEATHER_BOOTS, 0, GameCategory.ARCADE, null, false, GameDisplay.Runner.getGameId()),
|
||||
|
||||
|
||||
SPLEEF("Super Spleef", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.IRON_SPADE, 0, GameCategory.ARCADE, null, false, GameDisplay.Spleef.getGameId()),
|
||||
|
||||
|
||||
DEATH_TAG("Death Tag", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.SKULL_ITEM, 0, GameCategory.ARCADE, null, false, GameDisplay.DeathTag.getGameId()),
|
||||
|
||||
|
||||
SNAKE("Snake", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.WOOL, 4, GameCategory.ARCADE, "Reversal Snake Kit", false, GameDisplay.Snake.getGameId()),
|
||||
|
||||
|
||||
BACON_BRAWL("Bacon Brawl", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.PORK, 0, GameCategory.ARCADE, null, false, GameDisplay.BaconBrawl.getGameId()),
|
||||
|
||||
|
||||
MICRO_BATTLE("Micro Battle", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.LAVA_BUCKET, 0, GameCategory.ARCADE, null, false, GameDisplay.Micro.getGameId()),
|
||||
|
||||
|
||||
BOMB_LOBBERS("Bomb Lobbers", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.FIREBALL, 0, GameCategory.ARCADE, "Waller Kit", false, GameDisplay.Lobbers.getGameId()),
|
||||
|
||||
|
||||
EVOLUTION("Evolution", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
|
||||
Material.MONSTER_EGG, 55 /* slime */, GameCategory.ARCADE, "Harvester Kit", false, GameDisplay.Evolution.getGameId()),
|
||||
|
||||
|
||||
MONSTER_MAZE("Monster Maze", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED},
|
||||
Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM", false, GameDisplay.MonsterMaze.getGameId()),
|
||||
|
||||
|
||||
GLADIATORS("Gladiators", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.IRON_SWORD, 0, GameCategory.ARCADE, null, false, GameDisplay.Gladiators.getGameId()),
|
||||
@ -223,13 +223,13 @@ public enum AchievementCategory
|
||||
SPEED_BUILDERS("Speed Builders", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},
|
||||
Material.QUARTZ_BLOCK, 0, GameCategory.CLASSICS, null, false, GameDisplay.SpeedBuilders.getGameId()),
|
||||
|
||||
|
||||
/*ONE_IN_THE_QUIVER_PAYLOAD("One in the Quiver Payload", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED},
|
||||
Material.EXPLOSIVE_MINECART, 0, GameCategory.CLASSICS, "Sky Warrior Kit", false, GameDisplay.QuiverPayload.getGameId()),*/
|
||||
|
||||
SKYFALL("Skyfall", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, null, new StatDisplay("Booster Rings", "Rings"),
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, null, new StatDisplay("Booster Rings", "Rings"),
|
||||
null, null, new StatDisplay(C.Bold + "Team Stats", true), null,
|
||||
StatDisplay.fromGame("Wins", GameDisplay.SkyfallTeams, "Wins"), StatDisplay.fromGame("Games Played", GameDisplay.SkyfallTeams, "Wins", "Losses"),
|
||||
StatDisplay.fromGame("Kills", GameDisplay.SkyfallTeams, "Kills"), StatDisplay.fromGame("Deaths", GameDisplay.SkyfallTeams, "Deaths"),
|
||||
@ -253,11 +253,11 @@ public enum AchievementCategory
|
||||
private String _kitReward;
|
||||
public boolean DisplayDivision;
|
||||
public int[] GameId;
|
||||
|
||||
|
||||
AchievementCategory(String name, String[] statsToPull, StatDisplay[] statDisplays, Material icon, int iconData, GameCategory gameCategory, String kitReward, boolean displayDivision, int... gameId)
|
||||
{
|
||||
_name = name;
|
||||
|
||||
|
||||
if (statsToPull != null)
|
||||
_statsToPull = statsToPull;
|
||||
else
|
||||
@ -267,7 +267,7 @@ public enum AchievementCategory
|
||||
_iconData = (byte)iconData;
|
||||
_gameCategory = gameCategory;
|
||||
_kitReward = kitReward;
|
||||
|
||||
|
||||
GameId = gameId;
|
||||
DisplayDivision = displayDivision;
|
||||
}
|
||||
@ -276,7 +276,7 @@ public enum AchievementCategory
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
public String getReward()
|
||||
{
|
||||
return _kitReward;
|
||||
@ -291,7 +291,7 @@ public enum AchievementCategory
|
||||
{
|
||||
return _statsToPull;
|
||||
}
|
||||
|
||||
|
||||
public StatDisplay[] getStatsToDisplay()
|
||||
{
|
||||
return _statDisplays;
|
||||
@ -351,7 +351,7 @@ public enum AchievementCategory
|
||||
for (String statName : _statDisplays[i].getStats())
|
||||
{
|
||||
if(_statDisplays[i].isDivideStats())
|
||||
{
|
||||
{
|
||||
if(statNumber == 0)
|
||||
{
|
||||
statNumber = targetStats.getStat(statToPull + "." + statName);
|
||||
@ -370,7 +370,7 @@ public enum AchievementCategory
|
||||
}
|
||||
|
||||
String statString = C.cWhite + Math.round(statNumber);
|
||||
|
||||
|
||||
// doubles
|
||||
// Special display for Words per Minute
|
||||
if (displayName.equalsIgnoreCase("Words Per Minute"))
|
||||
@ -382,14 +382,14 @@ public enum AchievementCategory
|
||||
lore.add(C.cYellow + displayName + ": " + statString);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ints
|
||||
// Need to display special for time
|
||||
if (displayName.equalsIgnoreCase("Time In Game"))
|
||||
statString = C.cWhite + UtilTime.convertString(Math.round(statNumber) * 1000L, 0, UtilTime.TimeUnit.FIT);
|
||||
|
||||
|
||||
|
||||
lore.add(C.cYellow + displayName + ": " + statString);
|
||||
}
|
||||
}
|
||||
@ -398,4 +398,4 @@ public enum AchievementCategory
|
||||
{
|
||||
GLOBAL, HOLIDAY, SURVIVAL, CLASSICS, CHAMPIONS, ARCADE, UHC
|
||||
}
|
||||
}
|
||||
}
|
@ -8,10 +8,12 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.achievement.command.StatsCommand;
|
||||
import mineplex.core.achievement.leveling.LevelingManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
@ -33,18 +35,14 @@ public class AchievementManager extends MiniPlugin
|
||||
STATS_COMMAND,
|
||||
}
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private IncognitoManager _incognitoManager;
|
||||
private StatsManager _statsManager;
|
||||
private EloManager _eloManager;
|
||||
private final CoreClientManager _clientManager;
|
||||
private final IncognitoManager _incognitoManager;
|
||||
private final StatsManager _statsManager;
|
||||
private final EloManager _eloManager;
|
||||
|
||||
private AchievementShop _shop;
|
||||
private int _interfaceSlot = 7;
|
||||
private boolean _giveInterfaceItem = false;
|
||||
private final AchievementShop _shop;
|
||||
|
||||
private NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<String, NautHashMap<Achievement, AchievementLog>>();
|
||||
|
||||
private boolean _shopEnabled = true;
|
||||
private final NautHashMap<String, NautHashMap<Achievement, AchievementLog>> _log = new NautHashMap<>();
|
||||
|
||||
public AchievementManager(StatsManager statsManager, CoreClientManager clientManager, DonationManager donationManager, IncognitoManager incognitoManager, EloManager eloManager)
|
||||
{
|
||||
@ -55,10 +53,12 @@ public class AchievementManager extends MiniPlugin
|
||||
_eloManager = eloManager;
|
||||
_clientManager = clientManager;
|
||||
_shop = new AchievementShop(this, _statsManager, clientManager, donationManager, "Achievement");
|
||||
|
||||
|
||||
//new LevelingManager(this);
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionGroup.MOD.setPermission(Perm.SEE_FULL_STATS, true, true);
|
||||
@ -108,7 +108,7 @@ public class AchievementManager extends MiniPlugin
|
||||
if (stat.equalsIgnoreCase(event.getStatName()))
|
||||
{
|
||||
if (!_log.containsKey(player.getName()))
|
||||
_log.put(player.getName(), new NautHashMap<Achievement, AchievementLog>());
|
||||
_log.put(player.getName(), new NautHashMap<>());
|
||||
|
||||
//Record that achievement has leveled up
|
||||
if (type.getLevelData(event.getValueAfter()).getLevel() > type.getLevelData(event.getValueBefore()).getLevel())
|
||||
@ -184,62 +184,56 @@ public class AchievementManager extends MiniPlugin
|
||||
return _log.remove(player.getName());
|
||||
}
|
||||
|
||||
public void setGiveInterfaceItem(boolean giveInterfaceItem)
|
||||
{
|
||||
_giveInterfaceItem = giveInterfaceItem;
|
||||
}
|
||||
|
||||
/*@EventHandler
|
||||
public void openShop(PlayerInteractEvent event)
|
||||
{
|
||||
if (!_shopEnabled)
|
||||
return;
|
||||
|
||||
if (event.hasItem() && event.getItem().getType() == Material.SKULL_ITEM)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
openShop(event.getPlayer());
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean hasCategory(Player player, Achievement[] required)
|
||||
{
|
||||
if (required == null || required.length == 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
for (Achievement cur : required)
|
||||
{
|
||||
if (get(player, cur).getLevel() < cur.getMaxLevel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public int getMineplexLevelNumber(Player sender)
|
||||
{
|
||||
return getMineplexLevelNumber(sender, true);
|
||||
}
|
||||
|
||||
public int getMineplexLevelNumber(Player sender, boolean fakeLevels)
|
||||
{
|
||||
CoreClient client = _clientManager.Get(sender);
|
||||
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
|
||||
|
||||
if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_50))
|
||||
if (client.hasPermission(Perm.FAKE_LEVEL_50))
|
||||
{
|
||||
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
} else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_30))
|
||||
}
|
||||
else if (client.hasPermission(Perm.FAKE_LEVEL_30))
|
||||
{
|
||||
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
|
||||
} else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_15))
|
||||
}
|
||||
else if (client.hasPermission(Perm.FAKE_LEVEL_15))
|
||||
{
|
||||
level = Math.max(level, 15);
|
||||
} else if (_clientManager.Get(sender).hasPermission(Perm.FAKE_LEVEL_5))
|
||||
}
|
||||
else if (client.hasPermission(Perm.FAKE_LEVEL_5))
|
||||
{
|
||||
level = Math.max(level, 5);
|
||||
}
|
||||
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
public String getMineplexLevel(Player sender)
|
||||
{
|
||||
{
|
||||
return Achievement.getExperienceString(getMineplexLevelNumber(sender)) + " " + ChatColor.RESET;
|
||||
}
|
||||
|
||||
@ -248,11 +242,6 @@ public class AchievementManager extends MiniPlugin
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public void setShopEnabled(boolean var)
|
||||
{
|
||||
_shopEnabled = var;
|
||||
}
|
||||
|
||||
public IncognitoManager getIncognito()
|
||||
{
|
||||
return _incognitoManager;
|
||||
|
@ -0,0 +1,248 @@
|
||||
package mineplex.core.achievement.leveling;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.achievement.Achievement;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.leveling.rewards.LevelChestReward;
|
||||
import mineplex.core.achievement.leveling.rewards.LevelCurrencyReward;
|
||||
import mineplex.core.achievement.leveling.rewards.LevelReward;
|
||||
import mineplex.core.achievement.leveling.ui.LevelRewardShop;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.treasure.types.TreasureType;
|
||||
|
||||
public class LevelingManager extends MiniDbClientPlugin<List<Integer>>
|
||||
{
|
||||
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
|
||||
VIEW_LEVEL_MENU
|
||||
|
||||
}
|
||||
|
||||
// That is a big old number
|
||||
private static final int MAX_LEVEL = 100;
|
||||
public static int getMaxLevel()
|
||||
{
|
||||
return MAX_LEVEL;
|
||||
}
|
||||
|
||||
private final AchievementManager _achievement;
|
||||
private final LevelingRepository _repository;
|
||||
private final LevelRewardShop _shop;
|
||||
|
||||
private final List<Entry<Integer, LevelReward>> _rewards;
|
||||
|
||||
public LevelingManager(AchievementManager achievementManager)
|
||||
{
|
||||
super("Level Rewards");
|
||||
|
||||
_achievement = achievementManager;
|
||||
_repository = new LevelingRepository();
|
||||
_shop = new LevelRewardShop(this, ClientManager, require(DonationManager.class));
|
||||
|
||||
_rewards = new ArrayList<>(120);
|
||||
|
||||
populateRewards();
|
||||
generatePermissions();
|
||||
|
||||
addCommand(new CommandBase<LevelingManager>(this, Perm.VIEW_LEVEL_MENU,"level")
|
||||
{
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
_shop.attemptShopOpen(caller);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionGroup.PLAYER.setPermission(Perm.VIEW_LEVEL_MENU, true, true);
|
||||
}
|
||||
|
||||
private void populateRewards()
|
||||
{
|
||||
addCurrencyReward(1, GlobalCurrency.GEM, 100);
|
||||
addCurrencyReward(2, GlobalCurrency.GEM, 200);
|
||||
addChestReward(3, TreasureType.OLD, 1);
|
||||
addCurrencyReward(4, GlobalCurrency.GEM, 250);
|
||||
addCurrencyReward(5, GlobalCurrency.GEM, 250);
|
||||
addChestReward(6, TreasureType.OLD, 2);
|
||||
addCurrencyReward(7, GlobalCurrency.GEM, 250);
|
||||
addCurrencyReward(8, GlobalCurrency.GEM, 250);
|
||||
addCurrencyReward(9, GlobalCurrency.GEM, 500);
|
||||
addChestReward(10, TreasureType.OLD, 2);
|
||||
}
|
||||
|
||||
private void addCurrencyReward(int level, GlobalCurrency type, int amount)
|
||||
{
|
||||
_rewards.add(new SimpleEntry<>(level, new LevelCurrencyReward(type, amount)));
|
||||
}
|
||||
|
||||
private void addChestReward(int level, TreasureType type, int amount)
|
||||
{
|
||||
_rewards.add(new SimpleEntry<>(level, new LevelChestReward(type, amount)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
List<Integer> levels = new ArrayList<>(50);
|
||||
|
||||
try
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
levels.add(resultSet.getInt("level"));
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Set(uuid, levels);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Integer> addPlayer(UUID uuid)
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT level FROM accountLevelReward WHERE accountId=" + accountId + ";";
|
||||
}
|
||||
|
||||
public int getLevel(Player player)
|
||||
{
|
||||
return _achievement.getMineplexLevelNumber(player, false);
|
||||
}
|
||||
|
||||
public int getFirstUnclaimedLevel(Player player)
|
||||
{
|
||||
List<Integer> claimed = Get(player);
|
||||
|
||||
for (Entry<Integer, LevelReward> entry : _rewards)
|
||||
{
|
||||
int level = entry.getKey();
|
||||
|
||||
if (!claimed.contains(level))
|
||||
{
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public List<LevelReward> getLevelRewards(int level)
|
||||
{
|
||||
List<LevelReward> rewards = new ArrayList<>();
|
||||
|
||||
for (Entry<Integer, LevelReward> entry : _rewards)
|
||||
{
|
||||
int rewardLevel = entry.getKey();
|
||||
|
||||
if (level == rewardLevel)
|
||||
{
|
||||
rewards.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return rewards;
|
||||
}
|
||||
|
||||
public List<Entry<Integer, LevelReward>> getLevelRewards()
|
||||
{
|
||||
return _rewards;
|
||||
}
|
||||
|
||||
public ItemStack getLevelItem(Player player, List<LevelReward> rewards, int level)
|
||||
{
|
||||
boolean claimed = hasClaimed(player, level);
|
||||
boolean canClaim = canClaim(player, level);
|
||||
boolean exclusive = level > 100;
|
||||
|
||||
Material material;
|
||||
byte data = 0;
|
||||
String title = "Level " + Achievement.getExperienceString(level);
|
||||
String bottomLine;
|
||||
ItemBuilder builder = new ItemBuilder(Material.AIR);
|
||||
|
||||
// Already claimed
|
||||
if (claimed)
|
||||
{
|
||||
material = Material.INK_SACK;
|
||||
data = 8;
|
||||
title = C.cRed + title;
|
||||
bottomLine = C.cRed + "You have already claimed this reward.";
|
||||
}
|
||||
// Hasn't claimed and could claim
|
||||
else if (canClaim)
|
||||
{
|
||||
material = exclusive ? Material.DIAMOND_BLOCK : Material.EMERALD_BLOCK;
|
||||
title = C.cGreen + title;
|
||||
bottomLine = C.cGreen + "Click to claim this reward!";
|
||||
builder.setGlow(true);
|
||||
}
|
||||
// Hasn't claimed and can't claim
|
||||
else
|
||||
{
|
||||
material = exclusive ? Material.OBSIDIAN : Material.REDSTONE_BLOCK;
|
||||
title = C.cRed + title;
|
||||
bottomLine = C.cRed + "You aren't a high enough level to claim this reward.";
|
||||
}
|
||||
|
||||
builder.setType(material);
|
||||
builder.setData(data);
|
||||
builder.setTitle(title);
|
||||
builder.addLore("");
|
||||
|
||||
for (LevelReward reward : rewards)
|
||||
{
|
||||
builder.addLore(" " + reward.getDescription());
|
||||
}
|
||||
|
||||
builder.addLore("", bottomLine);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public void claim(Player player, int level)
|
||||
{
|
||||
Get(player).add(level);
|
||||
_repository.claimReward(ClientManager.Get(player), level);
|
||||
}
|
||||
|
||||
public boolean hasClaimed(Player player, int level)
|
||||
{
|
||||
return Get(player).contains(level);
|
||||
}
|
||||
|
||||
public boolean canClaim(Player player, int level)
|
||||
{
|
||||
return getLevel(player) >= level;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package mineplex.core.achievement.leveling;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
|
||||
public class LevelingRepository extends RepositoryBase
|
||||
{
|
||||
|
||||
private static final String CLAIM_REWARD = "INSERT INTO accountLevelReward VALUES (?,?);";
|
||||
|
||||
LevelingRepository()
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
}
|
||||
|
||||
public void claimReward(CoreClient client, int level)
|
||||
{
|
||||
int accountId = client.getAccountId();
|
||||
|
||||
executeInsert(CLAIM_REWARD, null,
|
||||
new ColumnInt("accountId", accountId),
|
||||
new ColumnInt("level", level)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.core.achievement.leveling.rewards;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.treasure.types.TreasureType;
|
||||
|
||||
public class LevelChestReward implements LevelReward
|
||||
{
|
||||
|
||||
private final TreasureType _chest;
|
||||
private final int _amount;
|
||||
|
||||
public LevelChestReward(TreasureType chest, int amount)
|
||||
{
|
||||
_chest = chest;
|
||||
_amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void claim(Player player)
|
||||
{
|
||||
INVENTORY.addItemToInventory(null, player, _chest.getItemName(), _amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return C.cWhite + "- " + _amount + " " + _chest.getName();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.core.achievement.leveling.rewards;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LevelCurrencyReward implements LevelReward
|
||||
{
|
||||
|
||||
private final GlobalCurrency _type;
|
||||
private final int _amount;
|
||||
|
||||
public LevelCurrencyReward(GlobalCurrency type, int amount)
|
||||
{
|
||||
_type = type;
|
||||
_amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void claim(Player player)
|
||||
{
|
||||
DONATION.rewardCurrencyUntilSuccess(_type, player, "Level Reward", _amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription()
|
||||
{
|
||||
return C.cWhite + "- " + F.currency(_type, _amount);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package mineplex.core.achievement.leveling.rewards;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface LevelReward
|
||||
{
|
||||
|
||||
DonationManager DONATION = Managers.require(DonationManager.class);
|
||||
InventoryManager INVENTORY = Managers.require(InventoryManager.class);
|
||||
|
||||
void claim(Player player);
|
||||
|
||||
String getDescription();
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package mineplex.core.achievement.leveling.ui;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.leveling.LevelingManager;
|
||||
import mineplex.core.achievement.leveling.ui.page.LevelRewardMainPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LevelRewardShop extends ShopBase<LevelingManager>
|
||||
{
|
||||
|
||||
public LevelRewardShop(LevelingManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Level Reward");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<LevelingManager, ? extends ShopBase<LevelingManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return new LevelRewardMainPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package mineplex.core.achievement.leveling.ui.button;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import mineplex.core.achievement.leveling.LevelingManager;
|
||||
import mineplex.core.achievement.leveling.rewards.LevelReward;
|
||||
import mineplex.core.achievement.leveling.ui.LevelRewardShop;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class LevelRewardButton implements IButton
|
||||
{
|
||||
|
||||
private LevelingManager _plugin;
|
||||
private ShopPageBase<LevelingManager, LevelRewardShop> _menu;
|
||||
private final List<LevelReward> _rewards;
|
||||
private final int _level;
|
||||
|
||||
public LevelRewardButton(ShopPageBase<LevelingManager, LevelRewardShop> menu, List<LevelReward> rewards, int level)
|
||||
{
|
||||
_plugin = menu.getPlugin();
|
||||
_menu = menu;
|
||||
_rewards = rewards;
|
||||
_level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (_plugin.hasClaimed(player, _level) || !_plugin.canClaim(player, _level) || !Recharge.Instance.use(player, "Claim Level Reward", 250, true, false))
|
||||
{
|
||||
_menu.playDenySound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Give the player the reward
|
||||
_rewards.forEach(reward -> reward.claim(player));
|
||||
_plugin.claim(player, _level);
|
||||
|
||||
// Give some feedback
|
||||
_menu.playAcceptSound(player);
|
||||
player.sendMessage(F.main(_plugin.getName(), "You claimed rewards for level " + F.elem(_level) + ":"));
|
||||
_rewards.forEach(reward -> player.sendMessage(F.main(_plugin.getName(), reward.getDescription())));
|
||||
|
||||
// Rebuild the menu
|
||||
_menu.refresh();
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package mineplex.core.achievement.leveling.ui.page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.account.repository.token.Rank;
|
||||
import mineplex.core.achievement.leveling.LevelingManager;
|
||||
import mineplex.core.achievement.leveling.rewards.LevelReward;
|
||||
import mineplex.core.achievement.leveling.ui.LevelRewardShop;
|
||||
import mineplex.core.achievement.leveling.ui.button.LevelRewardButton;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class LevelRewardMainPage extends ShopPageBase<LevelingManager, LevelRewardShop>
|
||||
{
|
||||
|
||||
private static final int VIEW_ALL_INDEX = 22;
|
||||
private static final ItemStack VIEW_ALL = new ItemBuilder(Material.BOOK)
|
||||
.setTitle(C.cGreen + "View All Rewards")
|
||||
.addLore("Click to view all rewards.")
|
||||
.build();
|
||||
private static final ItemStack MAX_LEVEL = new ItemBuilder(Material.FIREWORK)
|
||||
.setTitle(C.cPurpleB + "Congratulations!")
|
||||
.addLore(
|
||||
"You have achieved the maximum level",
|
||||
"possible on Mineplex! From all of us",
|
||||
"here at Mineplex, we thank you for",
|
||||
"dedicating so much time to the server.",
|
||||
"",
|
||||
"Unless you're an " + PermissionGroup.ADMIN.getDisplay(true, true, true, false) + C.mBody + " in which case",
|
||||
"you cheated " + C.cPurple + "<3" + C.cGray + "."
|
||||
)
|
||||
.build();
|
||||
|
||||
public LevelRewardMainPage(LevelingManager plugin, LevelRewardShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "Level Rewards", player, 3 * 9);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int current = _plugin.getFirstUnclaimedLevel(_player);
|
||||
int previousA = getPreviousLevel(current);
|
||||
int previousB = getPreviousLevel(previousA);
|
||||
int nextA = getNextLevel(current);
|
||||
int nextB = getNextLevel(nextA);
|
||||
|
||||
List<LevelReward> previousARewards = _plugin.getLevelRewards(previousA);
|
||||
List<LevelReward> previousBRewards = _plugin.getLevelRewards(previousB);
|
||||
List<LevelReward> currentRewards = _plugin.getLevelRewards(current);
|
||||
List<LevelReward> nextARewards = _plugin.getLevelRewards(nextA);
|
||||
List<LevelReward> nextBRewards = _plugin.getLevelRewards(nextB);
|
||||
|
||||
// Order of display
|
||||
// previousB -> previousA -> current -> nextA -> nextB
|
||||
|
||||
addButton(11, previousB, previousBRewards);
|
||||
addButton(12, previousA, previousARewards);
|
||||
addButton(13, current, currentRewards);
|
||||
addButton(14, nextA, nextARewards);
|
||||
addButton(15, nextB, nextBRewards);
|
||||
|
||||
addButton(VIEW_ALL_INDEX, VIEW_ALL, new ViewAllRewardsButton());
|
||||
|
||||
// Claimed all the rewards
|
||||
if (current == -1)
|
||||
{
|
||||
addButtonNoAction(13, MAX_LEVEL);
|
||||
|
||||
for (int i = 0; i < getSize(); i++)
|
||||
{
|
||||
if (i == 13 || i == VIEW_ALL_INDEX)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
addButtonNoAction(i, new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) UtilMath.r(15))
|
||||
.setTitle(C.cBlack)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addButton(int slot, int level, List<LevelReward> rewards)
|
||||
{
|
||||
if (level < 0 || rewards.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addButton(slot, _plugin.getLevelItem(_player, rewards, level), new LevelRewardButton(this, rewards, level));
|
||||
}
|
||||
|
||||
private int getPreviousLevel(int level)
|
||||
{
|
||||
int previous = 0;
|
||||
|
||||
for (Entry<Integer, LevelReward> entry : _plugin.getLevelRewards())
|
||||
{
|
||||
int currentLevel = entry.getKey();
|
||||
|
||||
if (currentLevel == level)
|
||||
{
|
||||
return previous;
|
||||
}
|
||||
|
||||
previous = currentLevel;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int getNextLevel(int level)
|
||||
{
|
||||
boolean foundSearch = false;
|
||||
|
||||
for (Entry<Integer, LevelReward> entry : _plugin.getLevelRewards())
|
||||
{
|
||||
int currentLevel = entry.getKey();
|
||||
|
||||
if (currentLevel == level)
|
||||
{
|
||||
foundSearch = true;
|
||||
}
|
||||
else if (foundSearch)
|
||||
{
|
||||
return currentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private class ViewAllRewardsButton implements IButton
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_shop.openPageForPlayer(player, new LevelRewardViewAllPage(getPlugin(), getShop(), LevelRewardMainPage.this, getClientManager(), getDonationManager(), player, 1));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package mineplex.core.achievement.leveling.ui.page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.leveling.LevelingManager;
|
||||
import mineplex.core.achievement.leveling.rewards.LevelReward;
|
||||
import mineplex.core.achievement.leveling.ui.LevelRewardShop;
|
||||
import mineplex.core.achievement.leveling.ui.button.LevelRewardButton;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class LevelRewardViewAllPage extends ShopPageBase<LevelingManager, LevelRewardShop>
|
||||
{
|
||||
|
||||
private static final int DISPLAY_SIZE = 45;
|
||||
private static final ItemStack UNKNOWN_REWARD = new ItemBuilder(Material.OBSIDIAN)
|
||||
.setTitle(C.cRed + "???")
|
||||
.addLore("", C.cRed + "You aren't a high enough level to claim this reward.")
|
||||
.build();
|
||||
private static final ItemStack GO_BACK = new ItemBuilder(Material.BED)
|
||||
.setTitle(C.cGreen + "Click to go back.")
|
||||
.build();
|
||||
|
||||
private final ShopPageBase<LevelingManager, LevelRewardShop> _menu;
|
||||
private int _startingLevel;
|
||||
|
||||
LevelRewardViewAllPage(LevelingManager plugin, LevelRewardShop shop, ShopPageBase<LevelingManager, LevelRewardShop> menu, CoreClientManager clientManager, DonationManager donationManager, Player player, int startingLevel)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, "All Level Rewards", player);
|
||||
|
||||
_menu = menu;
|
||||
_startingLevel = startingLevel;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
int level = _startingLevel;
|
||||
int playerLevel = _plugin.getLevel(_player);
|
||||
boolean lastPage = false;
|
||||
|
||||
// No i++ ?! look down
|
||||
for (int i = 0; i < DISPLAY_SIZE; )
|
||||
{
|
||||
if (level >= LevelingManager.getMaxLevel())
|
||||
{
|
||||
lastPage = true;
|
||||
break;
|
||||
}
|
||||
|
||||
List<LevelReward> rewards = _plugin.getLevelRewards(level);
|
||||
|
||||
// No reward for that level
|
||||
if (rewards.isEmpty())
|
||||
{
|
||||
level++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack itemStack;
|
||||
|
||||
if (level > 100 && playerLevel < level)
|
||||
{
|
||||
itemStack = UNKNOWN_REWARD;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack = _plugin.getLevelItem(_player, rewards, level);
|
||||
}
|
||||
|
||||
addButton(i++, itemStack, new LevelRewardButton(this, rewards, level));
|
||||
level++;
|
||||
}
|
||||
|
||||
// Not the first page
|
||||
if (_startingLevel > 1)
|
||||
{
|
||||
addButton(46, getChangePageItem(true), new LevelRewardChangePageButton(_startingLevel - DISPLAY_SIZE));
|
||||
}
|
||||
// Not the last page
|
||||
else if (!lastPage)
|
||||
{
|
||||
addButton(53, getChangePageItem(false), new LevelRewardChangePageButton(_startingLevel + DISPLAY_SIZE));
|
||||
}
|
||||
|
||||
addButton(49, GO_BACK, new GoBackButton());
|
||||
}
|
||||
|
||||
private ItemStack getChangePageItem(boolean previous)
|
||||
{
|
||||
return new ItemBuilder(Material.ARROW)
|
||||
.setTitle(previous ? "Previous Page" : "Next Page")
|
||||
.build();
|
||||
}
|
||||
|
||||
private class LevelRewardChangePageButton implements IButton
|
||||
{
|
||||
|
||||
private int _newStartingIndex;
|
||||
|
||||
LevelRewardChangePageButton(int newStartingIndex)
|
||||
{
|
||||
_newStartingIndex = newStartingIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
// Update the starting index and rebuild the page
|
||||
_startingLevel = _newStartingIndex;
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private class GoBackButton implements IButton
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
_shop.openPageForPlayer(player, _menu);
|
||||
}
|
||||
}
|
||||
}
|
@ -236,7 +236,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
String itemName = C.Bold + _category.getFriendlyName() + " Stats";
|
||||
List<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
_category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _targetName, _targetStats);
|
||||
//_category.addStats(getClientManager(), _statsManager, lore, getPlayer(), _targetName, _targetStats);
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
@ -1,163 +0,0 @@
|
||||
package mineplex.core.arena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Region
|
||||
{
|
||||
private String _name;
|
||||
private transient Vector _pointOne;
|
||||
private transient Vector _pointTwo;
|
||||
|
||||
private List<String> _owners;
|
||||
|
||||
private Boolean _blockPassage = false;
|
||||
private Boolean _blockChange = true;
|
||||
|
||||
private int _priority;
|
||||
|
||||
private int _minX;
|
||||
private int _minY;
|
||||
private int _minZ;
|
||||
|
||||
private int _maxX;
|
||||
private int _maxY;
|
||||
private int _maxZ;
|
||||
|
||||
public Region(String name, Vector pointOne, Vector pointTwo)
|
||||
{
|
||||
_name = name;
|
||||
_pointOne = pointOne;
|
||||
_pointTwo = pointTwo;
|
||||
_priority = 0;
|
||||
_owners = new ArrayList<String>();
|
||||
|
||||
UpdateMinMax();
|
||||
}
|
||||
|
||||
public Vector GetMaximumPoint()
|
||||
{
|
||||
return new Vector(_maxX, _maxY, _maxZ);
|
||||
}
|
||||
|
||||
public void AdjustRegion(Vector vector)
|
||||
{
|
||||
_minX += vector.getBlockX();
|
||||
_minY += vector.getBlockY();
|
||||
_minZ += vector.getBlockZ();
|
||||
|
||||
_maxX += vector.getBlockX();
|
||||
_maxY += vector.getBlockY();
|
||||
_maxZ += vector.getBlockZ();
|
||||
}
|
||||
|
||||
public Vector GetMinimumPoint()
|
||||
{
|
||||
return new Vector(_minX, _minY, _minZ);
|
||||
}
|
||||
|
||||
public Vector GetMidPoint()
|
||||
{
|
||||
return new Vector((_maxX - _minX)/2 + _minX, (_maxY - _minY)/2 + _minY, (_maxZ - _minZ)/2 + _minZ);
|
||||
}
|
||||
|
||||
public void SetPriority(int priority)
|
||||
{
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
public int GetPriority()
|
||||
{
|
||||
return _priority;
|
||||
}
|
||||
|
||||
public Boolean Contains(Vector v)
|
||||
{
|
||||
return v.getBlockX() >= _minX && v.getBlockX() <= _maxX
|
||||
&& v.getBlockY() >= _minY && v.getBlockY() <= _maxY
|
||||
&& v.getBlockZ() >= _minZ && v.getBlockZ() <= _maxZ;
|
||||
}
|
||||
|
||||
public void AddOwner(String name)
|
||||
{
|
||||
if (!_owners.contains(name.toLowerCase()))
|
||||
{
|
||||
_owners.add(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveOwner(String name)
|
||||
{
|
||||
_owners.remove(name.toLowerCase());
|
||||
}
|
||||
|
||||
public void SetOwners(List<String> owners)
|
||||
{
|
||||
_owners = owners;
|
||||
|
||||
for (String ownerName : _owners)
|
||||
{
|
||||
ownerName = ownerName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEnter(Boolean canEnter)
|
||||
{
|
||||
_blockPassage = !canEnter;
|
||||
}
|
||||
|
||||
public void SetChangeBlocks(Boolean canChangeBlocks)
|
||||
{
|
||||
_blockChange = !canChangeBlocks;
|
||||
}
|
||||
|
||||
public Boolean CanEnter(String playerName)
|
||||
{
|
||||
if (_blockPassage)
|
||||
{
|
||||
if (!_owners.contains(playerName.toLowerCase()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean CanChangeBlocks(String playerName)
|
||||
{
|
||||
if (_blockChange)
|
||||
{
|
||||
if (!_owners.contains(playerName.toLowerCase()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
private void UpdateMinMax()
|
||||
{
|
||||
_minX = Math.min(_pointOne.getBlockX(), _pointTwo.getBlockX());
|
||||
_minY = Math.min(_pointOne.getBlockY(), _pointTwo.getBlockY());
|
||||
_minZ = Math.min(_pointOne.getBlockZ(), _pointTwo.getBlockZ());
|
||||
|
||||
_maxX = Math.max(_pointOne.getBlockX(), _pointTwo.getBlockX());
|
||||
_maxY = Math.max(_pointOne.getBlockY(), _pointTwo.getBlockY());
|
||||
_maxZ = Math.max(_pointOne.getBlockZ(), _pointTwo.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Maximum point: " + GetMaximumPoint() + " Minimum point: " + GetMinimumPoint();
|
||||
}
|
||||
}
|
@ -57,9 +57,6 @@ import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
@ -76,10 +73,10 @@ import mineplex.core.playwire.PlayWireManager;
|
||||
import mineplex.core.poll.PollManager;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import mineplex.core.treasure.reward.TreasureRewardManager;
|
||||
import mineplex.core.treasure.types.TreasureType;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
@ -91,7 +88,7 @@ import mineplex.serverdata.database.DBPool;
|
||||
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
|
||||
{
|
||||
public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
|
||||
|
||||
|
||||
private static long timeOffSet = 0;
|
||||
|
||||
public enum Perm implements Permission
|
||||
@ -108,7 +105,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
POWER_PLAY_COMMAND,
|
||||
TICKET_COMMAND,
|
||||
}
|
||||
|
||||
|
||||
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
|
||||
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
|
||||
private final Map<UUID, Pair<String, Integer>> _homeServerMap = new ConcurrentHashMap<>();
|
||||
@ -116,29 +113,29 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private long _explode;
|
||||
private boolean _canVote;
|
||||
private boolean _animationRunning;
|
||||
|
||||
|
||||
public final boolean ClansBonus;
|
||||
|
||||
public static long getSqlTime()
|
||||
{
|
||||
return getSqlTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
public static long getSqlTime(long currentTime)
|
||||
{
|
||||
return currentTime + timeOffSet;
|
||||
}
|
||||
|
||||
|
||||
public static long getLocalTime()
|
||||
{
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public static long getLocalTime(long sqlTime)
|
||||
{
|
||||
return sqlTime - timeOffSet;
|
||||
}
|
||||
|
||||
|
||||
public void updateOffSet()
|
||||
{
|
||||
_repository.getTimeOffset(data -> timeOffSet = data);
|
||||
@ -151,7 +148,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private PollManager _pollManager;
|
||||
private NpcManager _npcManager;
|
||||
private HologramManager _hologramManager;
|
||||
private RewardManager _rewardManager;
|
||||
private TreasureRewardManager _rewardManager;
|
||||
private StatsManager _statsManager;
|
||||
private FacebookManager _facebookManager;
|
||||
private YoutubeManager _youtubeManager;
|
||||
@ -163,11 +160,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private Location _carlLocation;
|
||||
private AnimationCarl _animation;
|
||||
private int _visualTick;
|
||||
|
||||
|
||||
private ArrayList<String> _voteList;
|
||||
|
||||
|
||||
private String _creeperName;
|
||||
|
||||
|
||||
/**
|
||||
* THIS SHOULD ONLY BE USED FOR VOTIFIER!
|
||||
*/
|
||||
@ -183,9 +180,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
System.out.print("VOTIFIER: ");
|
||||
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
|
||||
|
||||
|
||||
ClansBonus = _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub");
|
||||
|
||||
|
||||
_voteList = new ArrayList<>();
|
||||
if (ClansBonus)
|
||||
{
|
||||
@ -198,11 +195,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_voteList.add("http://vote1.mineplex.com");
|
||||
_voteList.add("http://vote2.mineplex.com");
|
||||
}
|
||||
|
||||
|
||||
_creeperName = "Carl";
|
||||
|
||||
updateOffSet();
|
||||
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
@ -223,7 +220,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
System.out.print("GM NULL");
|
||||
}
|
||||
|
||||
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, gadgetManager, statsManager);
|
||||
_rewardManager = require(TreasureRewardManager.class);
|
||||
|
||||
_pollManager = pollManager;
|
||||
_statsManager = statsManager;
|
||||
@ -233,9 +230,9 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_playWireManager = playWireManager;
|
||||
|
||||
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager);
|
||||
|
||||
|
||||
ClansBonus = _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub");
|
||||
|
||||
|
||||
_voteList = new ArrayList<>();
|
||||
if (ClansBonus)
|
||||
{
|
||||
@ -264,8 +261,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_carlNpc.setLocation(carlLocation);
|
||||
}
|
||||
_enabled = true;
|
||||
_animation = new AnimationCarl(_carlNpc.getEntity());
|
||||
_animation.setRunning(false);
|
||||
// _animation = new AnimationCarl(_carlNpc.getEntity());
|
||||
// _animation.setRunning(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -274,11 +271,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
|
||||
clientManager.addStoredProcedureLoginProcessor(this);
|
||||
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, new VoteHandler(this));
|
||||
|
||||
|
||||
updateOffSet();
|
||||
|
||||
|
||||
if (ClansBonus)
|
||||
{
|
||||
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor()
|
||||
@ -306,10 +303,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionGroup.ULTRA.setPermission(Perm.MONTHLY_BONUS, true, true);
|
||||
@ -343,12 +340,12 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return;
|
||||
updateOffSet();
|
||||
}
|
||||
|
||||
|
||||
public String getCreeperName()
|
||||
{
|
||||
return _creeperName;
|
||||
}
|
||||
|
||||
|
||||
public Pair<String, Integer> getClansHomeServer(Player player)
|
||||
{
|
||||
if (ClansBonus)
|
||||
@ -360,7 +357,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return Pair.create("No Server", -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleVote(final Player player, final int rewardReceived, final boolean clans)
|
||||
{
|
||||
final int accountId = _clientManager.getAccountId(player);
|
||||
@ -373,7 +370,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
data.setHologram(oldData.getHologram());
|
||||
}
|
||||
Set(player, data);
|
||||
|
||||
|
||||
if (clans)
|
||||
{
|
||||
_statsManager.incrementStat(player, "Global.ClansDailyVote", 1);
|
||||
@ -390,52 +387,52 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void fireCreeper(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
|
||||
if(_pendingExplosions.isEmpty())
|
||||
return;
|
||||
|
||||
if (_animationRunning)
|
||||
return;
|
||||
|
||||
|
||||
if (!_canVote)
|
||||
return;
|
||||
|
||||
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
_animationRunning = true;
|
||||
_explode = System.currentTimeMillis();
|
||||
_animation.setTicks(0);
|
||||
//_animation.setTicks(0);
|
||||
_canVote = false;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void creeperAnimation(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
_animation.itemClean();
|
||||
|
||||
|
||||
//_animation.itemClean();
|
||||
|
||||
if (_canVote)
|
||||
return;
|
||||
|
||||
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (!_animationRunning)
|
||||
return;
|
||||
|
||||
|
||||
Entity creeper = _carlNpc.getEntity();
|
||||
|
||||
|
||||
double elapsed = (System.currentTimeMillis() - _explode)/1000d;
|
||||
|
||||
|
||||
//Not Detonated
|
||||
if (elapsed < 1)
|
||||
{
|
||||
@ -443,21 +440,21 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
creeper.getWorld().playSound(creeper.getLocation(), Sound.CREEPER_HISS, (float)(0.5 + elapsed), (float)(0.5 + elapsed));
|
||||
|
||||
IncreaseSize(creeper);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!_animation.isRunning())
|
||||
{
|
||||
//Effect
|
||||
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
|
||||
creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f);
|
||||
_animation.setType(_pendingExplosions.get(0));
|
||||
_animation.setPlayer(_pendingExplosionsPlayers.get(0));
|
||||
_animation.setRunning(true);
|
||||
}
|
||||
|
||||
if(!_animation.isDone())
|
||||
return;
|
||||
// if(!_animation.isRunning())
|
||||
// {
|
||||
// //Effect
|
||||
// UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
|
||||
// creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f);
|
||||
// _animation.setType(_pendingExplosions.get(0));
|
||||
// _animation.setPlayer(_pendingExplosionsPlayers.get(0));
|
||||
// _animation.setRunning(true);
|
||||
// }
|
||||
//
|
||||
// if(!_animation.isDone())
|
||||
// return;
|
||||
|
||||
_animationRunning = false;
|
||||
DecreaseSize(creeper);
|
||||
@ -465,22 +462,22 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_pendingExplosionsPlayers.remove(0);
|
||||
_canVote = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateAnimation(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if(!_animation.isRunning())
|
||||
return;
|
||||
|
||||
_animation.run();
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void updateAnimation(UpdateEvent event)
|
||||
// {
|
||||
// if(event.getType() != UpdateType.TICK)
|
||||
// return;
|
||||
//
|
||||
// if (!_enabled)
|
||||
// return;
|
||||
//
|
||||
// if(!_animation.isRunning())
|
||||
// return;
|
||||
//
|
||||
// _animation.run();
|
||||
// }
|
||||
|
||||
public void DecreaseSize(Entity player)
|
||||
{
|
||||
if (!_enabled)
|
||||
@ -488,7 +485,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) -1, EntityCreeper.META_FUSE_STATE, -1);
|
||||
}
|
||||
|
||||
|
||||
public void IncreaseSize(Entity player)
|
||||
{
|
||||
if (!_enabled)
|
||||
@ -539,21 +536,21 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
public long nextDailyBonus(Player player)
|
||||
{
|
||||
Timestamp timestamp = ClansBonus ? Get(player).getClansDailyTime() : Get(player).getDailyTime();
|
||||
|
||||
|
||||
if (timestamp == null)
|
||||
return 0;
|
||||
|
||||
|
||||
long lastBonus = timestamp.getTime();
|
||||
|
||||
|
||||
return getLocalTime(lastBonus + TIME_BETWEEN_BONUSES);
|
||||
}
|
||||
|
||||
|
||||
// RANK BONUS
|
||||
public void attemptRankBonus(final Player player, final Callback<Boolean> result)
|
||||
{
|
||||
if (timeTillRankBonus(player) > 0)
|
||||
result.run(false);
|
||||
|
||||
|
||||
getRepository().attemptRankBonus(player, aBoolean ->
|
||||
{
|
||||
if (aBoolean)
|
||||
@ -594,22 +591,22 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public long timeTillRankBonus(Player player)
|
||||
{
|
||||
return nextRankBonus(player) - getLocalTime();
|
||||
}
|
||||
|
||||
|
||||
// This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
|
||||
public long nextRankBonus(Player player)
|
||||
{
|
||||
Date date = Get(player).getRankTime();
|
||||
|
||||
|
||||
if (date == null)
|
||||
return 0;
|
||||
|
||||
|
||||
long lastBonus = date.getTime();
|
||||
|
||||
|
||||
return getNextRankBonusTime(getLocalTime(lastBonus));
|
||||
}
|
||||
|
||||
@ -627,7 +624,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateVoteStreak(BonusRecord client)
|
||||
{
|
||||
if (client.getVoteStreak() > 0 && client.getVotetime() != null)
|
||||
@ -651,7 +648,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (data.getDailyStreak() > data.getMaxDailyStreak())
|
||||
data.setMaxDailyStreak(data.getDailyStreak());
|
||||
}
|
||||
|
||||
|
||||
public void incrementVoteStreak(BonusRecord client)
|
||||
{
|
||||
client.setVoteStreak(client.getVoteStreak() + 1);
|
||||
@ -673,21 +670,21 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime;
|
||||
return maxTime - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public static long getNextRankBonusTime(long time)
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeZone(TIMEZONE);
|
||||
calendar.setTimeInMillis(time);
|
||||
|
||||
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
|
||||
calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
||||
|
||||
|
||||
return calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
@ -700,7 +697,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (streak >= 40) multiplier += (1 * (streak - 40));
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
|
||||
public int getVoteMultiplier(int streak)
|
||||
{
|
||||
int multiplier = Math.min(100, 5 * streak);
|
||||
@ -729,13 +726,13 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
public BonusAmount getClansDailyBonusAmount(Player player)
|
||||
{
|
||||
BonusAmount amount = new BonusAmount();
|
||||
|
||||
|
||||
int serverId = getClansHomeServer(player).getRight();
|
||||
|
||||
|
||||
if (serverId != -1)
|
||||
{
|
||||
amount.setGold(serverId, 500);
|
||||
@ -743,7 +740,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
public BonusAmount getVoteBonusAmount(Player player)
|
||||
{
|
||||
return getVoteBonusAmount(Get(player).getVoteStreak());
|
||||
@ -757,25 +754,25 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
amount.setTickets(1);
|
||||
amount.setGems(400);
|
||||
amount.setBonusGems((int) (mult * 400));
|
||||
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
public BonusAmount getClansVoteBonusAmount(Player player)
|
||||
{
|
||||
return getClansVoteBonusAmount(getClansHomeServer(player).getRight());
|
||||
}
|
||||
|
||||
|
||||
public BonusAmount getClansVoteBonusAmount(int serverId)
|
||||
{
|
||||
BonusAmount amount = new BonusAmount();
|
||||
|
||||
|
||||
if (serverId != -1)
|
||||
{
|
||||
amount.setTickets(1);
|
||||
amount.setGold(serverId, 1000);
|
||||
}
|
||||
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@ -804,8 +801,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//VOTE
|
||||
public long timeTillVoteBonus(Player player)
|
||||
{
|
||||
@ -921,10 +918,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(experience + " Experience")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static long getNextVoteTime(long time)
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeZone(TIMEZONE);
|
||||
calendar.setTimeInMillis(time);
|
||||
|
||||
@ -1009,7 +1006,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
BonusClientData client = Get(player);
|
||||
|
||||
int availableRewards = 0;
|
||||
|
||||
|
||||
if (canVote(player)) availableRewards++;
|
||||
if (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) availableRewards++;
|
||||
if (_youtubeManager.canYoutube(player)) availableRewards++;
|
||||
@ -1025,10 +1022,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (client.getHologram() == null)
|
||||
{
|
||||
double yAdd = 2.3;
|
||||
if(!UtilPlayer.is1_9(player))
|
||||
{
|
||||
yAdd = 2.45;
|
||||
}
|
||||
if(!UtilPlayer.is1_9(player))
|
||||
{
|
||||
yAdd = 2.45;
|
||||
}
|
||||
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
|
||||
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
|
||||
hologram.addPlayer(player);
|
||||
@ -1089,7 +1086,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
_visualTick++;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected BonusClientData addPlayer(UUID uuid)
|
||||
{
|
||||
@ -1106,11 +1103,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public RewardManager getRewardManager()
|
||||
{
|
||||
return _rewardManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void UnloadPlayer(final ClientUnloadEvent event)
|
||||
@ -1133,7 +1125,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_pendingExplosions.add(obj);
|
||||
_pendingExplosionsPlayers.add(player);
|
||||
}
|
||||
|
||||
|
||||
public PollManager getPollManager()
|
||||
{
|
||||
return _pollManager;
|
||||
@ -1154,7 +1146,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
runSyncLater(() -> _showCarl.put(event.getPlayer().getName(), true), 200);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void Quit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -1162,31 +1154,31 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
// Removes from allow command map
|
||||
UtilPlayer.removeAllowedCommands(event.getPlayer());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void carlUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
|
||||
{
|
||||
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.Get(player).hasPermission(Perm.MONTHLY_BONUS) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
|
||||
{
|
||||
if (_showCarl.containsKey(player.getName()))
|
||||
{
|
||||
if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub"))
|
||||
{
|
||||
UtilPlayer.message(player, C.cDGreen + C.Bold + _creeperName + " the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
|
||||
{
|
||||
if (_pollManager.hasPoll(player) || canVote(player) || _youtubeManager.canYoutube(player) || (_playWireManager.Get(player) != null && _playWireManager.Get(player).getAccountId() != -1 && _playWireManager.canRedeemTickets(_playWireManager.Get(player))) || (canRank(player) && _clientManager.Get(player).hasPermission(Perm.MONTHLY_BONUS) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
|
||||
{
|
||||
if (_showCarl.containsKey(player.getName()))
|
||||
{
|
||||
if (_plugin.getClass().getSimpleName().equalsIgnoreCase("Hub") || _plugin.getClass().getSimpleName().equalsIgnoreCase("ClansHub"))
|
||||
{
|
||||
UtilPlayer.message(player, C.cDGreen + C.Bold + _creeperName + " the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getVoteLink()
|
||||
{
|
||||
long sqlTime = getSqlTime();
|
||||
@ -1259,7 +1251,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
_carlLocation = carlLocation;
|
||||
}
|
||||
|
||||
|
||||
public Npc getCarl()
|
||||
{
|
||||
return _carlNpc;
|
||||
|
@ -10,8 +10,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
@ -24,291 +22,291 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AnimationCarl extends Animation
|
||||
public class AnimationCarl
|
||||
{
|
||||
private boolean _isDone;
|
||||
private Block _creeper;
|
||||
private Object _type;
|
||||
private Player _player;
|
||||
|
||||
private HashSet<Item> _items = new HashSet<Item>();
|
||||
|
||||
public AnimationCarl(Entity creeper)
|
||||
{
|
||||
_creeper = creeper.getLocation().getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if(_type instanceof String)
|
||||
{
|
||||
if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL"))
|
||||
{
|
||||
for (int i = 50; i < 60; i++)
|
||||
{
|
||||
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
|
||||
_items.add(gem);
|
||||
_items.add(shard);
|
||||
|
||||
Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d));
|
||||
UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false);
|
||||
UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false);
|
||||
|
||||
}
|
||||
}
|
||||
if(((String) _type).contentEquals("RANK"))
|
||||
{
|
||||
for (int i = 50; i < 60; i++)
|
||||
{
|
||||
Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
|
||||
_items.add(shard);
|
||||
|
||||
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
|
||||
}
|
||||
}
|
||||
if(!((String) _type).contentEquals("DAILY") && !((String) _type).contentEquals("RANK") && !((String) _type).contentEquals("POLL"))
|
||||
{
|
||||
|
||||
Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
|
||||
_items.add(paper);
|
||||
|
||||
Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d));
|
||||
UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false);
|
||||
|
||||
for (int i = 50; i < 60; i++)
|
||||
{
|
||||
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
_items.add(gem);
|
||||
|
||||
Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d));
|
||||
UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false);
|
||||
|
||||
}
|
||||
}
|
||||
finish();
|
||||
}
|
||||
if(_type instanceof Reward)
|
||||
{
|
||||
if(getTicks() == 0)
|
||||
{
|
||||
RewardData rewardData = ((Reward)_type).getFakeRewardData(_player);
|
||||
ItemStack itemStack = rewardData.getDisplayItem();
|
||||
Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack);
|
||||
_items.add(item);
|
||||
|
||||
Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
|
||||
|
||||
UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
|
||||
}
|
||||
|
||||
if(((Reward)_type).getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
RareAnimation();
|
||||
}
|
||||
else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY)
|
||||
{
|
||||
LegendAnimation();
|
||||
}
|
||||
else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL)
|
||||
{
|
||||
MythicalAnimation();
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
if (_type instanceof PowerPlayAnimation)
|
||||
{
|
||||
for (int i = 50; i < 65; i++)
|
||||
{
|
||||
// Gem amplifier
|
||||
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
_items.add(gem);
|
||||
|
||||
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
UtilAction.velocity(gem, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
|
||||
// Omega chest
|
||||
Item omega = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), SkinData.OMEGA_CHEST.getSkull());
|
||||
_items.add(omega);
|
||||
|
||||
vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
UtilAction.velocity(omega, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
|
||||
// Monthly items
|
||||
PowerPlayAnimation powerPlayAnimation = (PowerPlayAnimation) _type;
|
||||
for (ItemStack itemStack : powerPlayAnimation.getAnimationItems())
|
||||
{
|
||||
Item monthly = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), itemStack);
|
||||
_items.add(monthly);
|
||||
|
||||
vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
UtilAction.velocity(monthly, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
}
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinish() {
|
||||
_isDone = true;
|
||||
_player = null;
|
||||
setTicks(0);
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return _isDone;
|
||||
}
|
||||
|
||||
public void setDone(boolean b)
|
||||
{
|
||||
_isDone = b;
|
||||
}
|
||||
|
||||
public void setType(Object type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public void LegendAnimation()
|
||||
{
|
||||
if (getTicks() < 1)
|
||||
{
|
||||
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
|
||||
}
|
||||
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
|
||||
}
|
||||
else if (getTicks() < 35)
|
||||
{
|
||||
double radius = 2 - (getTicks() / 10D * 2);
|
||||
int particleAmount = 20 - (getTicks() * 2);
|
||||
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||
{
|
||||
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void MythicalAnimation()
|
||||
{
|
||||
if (getTicks() < 30)
|
||||
{
|
||||
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
|
||||
}
|
||||
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
|
||||
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
|
||||
}
|
||||
else if (getTicks() < 40)
|
||||
{
|
||||
UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
|
||||
new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
|
||||
|
||||
//Particle Spiral Up
|
||||
double radius = getTicks() / 20D;
|
||||
int particleAmount = getTicks() / 2;
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
|
||||
Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
|
||||
ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
for(double e = 0.1 ; e < 3 ; e += 0.5)
|
||||
{
|
||||
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void RareAnimation()
|
||||
{
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false);
|
||||
}
|
||||
_creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F);
|
||||
}
|
||||
else if (getTicks() >= 60)
|
||||
{
|
||||
finish();
|
||||
}
|
||||
|
||||
else if (getTicks() < 35)
|
||||
{
|
||||
double radius = 2 - (getTicks() / 10D * 2);
|
||||
int particleAmount = 20 - (getTicks() * 2);
|
||||
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
for (int i = 0; i < particleAmount; i++)
|
||||
{
|
||||
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||
{
|
||||
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void itemClean()
|
||||
{
|
||||
Iterator<Item> itemIterator = _items.iterator();
|
||||
|
||||
while (itemIterator.hasNext())
|
||||
{
|
||||
Item item = itemIterator.next();
|
||||
|
||||
if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60)
|
||||
{
|
||||
item.remove();
|
||||
itemIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
// private boolean _isDone;
|
||||
// private Block _creeper;
|
||||
// private Object _type;
|
||||
// private Player _player;
|
||||
//
|
||||
// private HashSet<Item> _items = new HashSet<Item>();
|
||||
//
|
||||
// public AnimationCarl(Entity creeper)
|
||||
// {
|
||||
// _creeper = creeper.getLocation().getBlock();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void tick()
|
||||
// {
|
||||
// if(_type instanceof String)
|
||||
// {
|
||||
// if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL"))
|
||||
// {
|
||||
// for (int i = 50; i < 60; i++)
|
||||
// {
|
||||
// Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
// Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
|
||||
// _items.add(gem);
|
||||
// _items.add(shard);
|
||||
//
|
||||
// Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d));
|
||||
// UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false);
|
||||
// UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if(((String) _type).contentEquals("RANK"))
|
||||
// {
|
||||
// for (int i = 50; i < 60; i++)
|
||||
// {
|
||||
// Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
|
||||
// _items.add(shard);
|
||||
//
|
||||
// Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
// UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if(!((String) _type).contentEquals("DAILY") && !((String) _type).contentEquals("RANK") && !((String) _type).contentEquals("POLL"))
|
||||
// {
|
||||
//
|
||||
// Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
|
||||
// _items.add(paper);
|
||||
//
|
||||
// Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d));
|
||||
// UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false);
|
||||
//
|
||||
// for (int i = 50; i < 60; i++)
|
||||
// {
|
||||
// Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
// _items.add(gem);
|
||||
//
|
||||
// Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d));
|
||||
// UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// finish();
|
||||
// }
|
||||
// if(_type instanceof Reward)
|
||||
// {
|
||||
// if(getTicks() == 0)
|
||||
// {
|
||||
// RewardData rewardData = ((Reward)_type).getFakeRewardData(_player);
|
||||
// ItemStack itemStack = rewardData.getDisplayItem();
|
||||
// Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack);
|
||||
// _items.add(item);
|
||||
//
|
||||
// Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
|
||||
//
|
||||
// UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
|
||||
// }
|
||||
//
|
||||
// if(((Reward)_type).getRarity() == RewardRarity.RARE)
|
||||
// {
|
||||
// RareAnimation();
|
||||
// }
|
||||
// else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY)
|
||||
// {
|
||||
// LegendAnimation();
|
||||
// }
|
||||
// else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL)
|
||||
// {
|
||||
// MythicalAnimation();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
// if (_type instanceof PowerPlayAnimation)
|
||||
// {
|
||||
// for (int i = 50; i < 65; i++)
|
||||
// {
|
||||
// // Gem amplifier
|
||||
// Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
|
||||
// _items.add(gem);
|
||||
//
|
||||
// Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
// UtilAction.velocity(gem, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
//
|
||||
// // Omega chest
|
||||
// Item omega = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), SkinData.OMEGA_CHEST.getSkull());
|
||||
// _items.add(omega);
|
||||
//
|
||||
// vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
// UtilAction.velocity(omega, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
//
|
||||
// // Monthly items
|
||||
// PowerPlayAnimation powerPlayAnimation = (PowerPlayAnimation) _type;
|
||||
// for (ItemStack itemStack : powerPlayAnimation.getAnimationItems())
|
||||
// {
|
||||
// Item monthly = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), itemStack);
|
||||
// _items.add(monthly);
|
||||
//
|
||||
// vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
|
||||
// UtilAction.velocity(monthly, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
|
||||
// }
|
||||
// }
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onFinish() {
|
||||
// _isDone = true;
|
||||
// _player = null;
|
||||
// setTicks(0);
|
||||
// }
|
||||
//
|
||||
// public boolean isDone()
|
||||
// {
|
||||
// return _isDone;
|
||||
// }
|
||||
//
|
||||
// public void setDone(boolean b)
|
||||
// {
|
||||
// _isDone = b;
|
||||
// }
|
||||
//
|
||||
// public void setType(Object type)
|
||||
// {
|
||||
// _type = type;
|
||||
// }
|
||||
//
|
||||
// public void setPlayer(Player player)
|
||||
// {
|
||||
// _player = player;
|
||||
// }
|
||||
//
|
||||
// public void LegendAnimation()
|
||||
// {
|
||||
// if (getTicks() < 1)
|
||||
// {
|
||||
// UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
|
||||
// }
|
||||
//
|
||||
// if (getTicks() == 1)
|
||||
// {
|
||||
// _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
|
||||
// }
|
||||
// else if (getTicks() < 35)
|
||||
// {
|
||||
// double radius = 2 - (getTicks() / 10D * 2);
|
||||
// int particleAmount = 20 - (getTicks() * 2);
|
||||
// Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
// for (int i = 0; i < particleAmount; i++)
|
||||
// {
|
||||
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||
// {
|
||||
// Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
// UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void MythicalAnimation()
|
||||
// {
|
||||
// if (getTicks() < 30)
|
||||
// {
|
||||
// UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
|
||||
// }
|
||||
//
|
||||
// if (getTicks() == 1)
|
||||
// {
|
||||
// _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
|
||||
// _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
|
||||
// }
|
||||
// else if (getTicks() < 40)
|
||||
// {
|
||||
// UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
|
||||
// new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
|
||||
//
|
||||
// //Particle Spiral Up
|
||||
// double radius = getTicks() / 20D;
|
||||
// int particleAmount = getTicks() / 2;
|
||||
// for (int i = 0; i < particleAmount; i++)
|
||||
// {
|
||||
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
//
|
||||
// Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff);
|
||||
// UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
|
||||
// ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
// }
|
||||
//
|
||||
// Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
// for (int i = 0; i < particleAmount; i++)
|
||||
// {
|
||||
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// for(double e = 0.1 ; e < 3 ; e += 0.5)
|
||||
// {
|
||||
// Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
// UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// finish();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void RareAnimation()
|
||||
// {
|
||||
// if (getTicks() == 1)
|
||||
// {
|
||||
// for(int i = 0; i < 3; i++)
|
||||
// {
|
||||
// UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false);
|
||||
// }
|
||||
// _creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F);
|
||||
// }
|
||||
// else if (getTicks() >= 60)
|
||||
// {
|
||||
// finish();
|
||||
// }
|
||||
//
|
||||
// else if (getTicks() < 35)
|
||||
// {
|
||||
// double radius = 2 - (getTicks() / 10D * 2);
|
||||
// int particleAmount = 20 - (getTicks() * 2);
|
||||
// Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
|
||||
// for (int i = 0; i < particleAmount; i++)
|
||||
// {
|
||||
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
|
||||
// for(double e = 0.1 ; e < 3 ; e += 0.6)
|
||||
// {
|
||||
// Location location = _centerLocation.clone().add(xDiff, e, zDiff);
|
||||
// UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void itemClean()
|
||||
// {
|
||||
// Iterator<Item> itemIterator = _items.iterator();
|
||||
//
|
||||
// while (itemIterator.hasNext())
|
||||
// {
|
||||
// Item item = itemIterator.next();
|
||||
//
|
||||
// if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60)
|
||||
// {
|
||||
// item.remove();
|
||||
// itemIterator.remove();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
@ -21,7 +21,7 @@ public class AnimationCommand extends CommandBase<BonusManager>{
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
caller = Bukkit.getPlayer(args[0]);
|
||||
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SPINNER_FILLER, true));
|
||||
//plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SPINNER_FILLER, true));
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
|
@ -2,9 +2,11 @@ package mineplex.core.bonuses.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.BonusGui;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.treasure.reward.TreasureRewardManager;
|
||||
|
||||
public class GuiCommand extends CommandBase<BonusManager>
|
||||
{
|
||||
@ -16,6 +18,6 @@ public class GuiCommand extends CommandBase<BonusManager>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new BonusGui(Plugin.getPlugin(), caller, Plugin, Plugin.getRewardManager(), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager(), Plugin.getPlayWireManager()).openInventory();
|
||||
new BonusGui(Plugin.getPlugin(), caller, Plugin, Managers.require(TreasureRewardManager.class), Plugin.getFacebookManager(), Plugin.getYoutubeManager(), Plugin.getThankManager(), Plugin.getPlayWireManager()).openInventory();
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@ import mineplex.core.bonuses.gui.buttons.VoteButton;
|
||||
import mineplex.core.bonuses.gui.buttons.YoutubeButton;
|
||||
import mineplex.core.facebook.FacebookManager;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.treasure.reward.TreasureRewardManager;
|
||||
import mineplex.core.playwire.PlayWireManager;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.youtube.YoutubeManager;
|
||||
|
||||
@ -38,7 +38,7 @@ public class BonusGui extends SimpleGui
|
||||
|
||||
private static final int INV_SIZE = 54;
|
||||
|
||||
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager, PlayWireManager playWireManager)
|
||||
public BonusGui(Plugin plugin, Player player, BonusManager manager, TreasureRewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager, PlayWireManager playWireManager)
|
||||
{
|
||||
super(plugin, player, player.getName() + "'s Bonuses", INV_SIZE);
|
||||
|
||||
|
@ -2,25 +2,6 @@ package mineplex.core.bonuses.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gui.DisplayItem;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardPool.Type;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.RewardType;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.buttons.RewardButton;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -32,20 +13,37 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.bonuses.gui.buttons.RewardButton;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gui.DisplayItem;
|
||||
import mineplex.core.gui.SimpleGui;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
import mineplex.core.treasure.reward.TreasureRewardManager;
|
||||
import mineplex.core.treasure.types.CarlTreasure;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class SpinGui extends SimpleGui
|
||||
{
|
||||
|
||||
private static final int HOPPER_SLOT = 4;
|
||||
private static final int CARL_SLOT = 22;
|
||||
private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ };
|
||||
private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/};
|
||||
private static final CarlTreasure TREASURE = new CarlTreasure();
|
||||
|
||||
private int _tickCount;
|
||||
private RewardData _rewardData;
|
||||
private Reward _reward;
|
||||
private BonusManager _manager;
|
||||
private int _currentRewardIndex;
|
||||
private int _ticksThisSwap;
|
||||
private int _ticksPerSwap;
|
||||
private int _swapCount;
|
||||
private Reward[] _rewards;
|
||||
private boolean _stopped;
|
||||
private boolean _rewarded;
|
||||
@ -54,94 +52,85 @@ public class SpinGui extends SimpleGui
|
||||
private float _pitch;
|
||||
private int _stopSpinnerAt;
|
||||
|
||||
public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager)
|
||||
public SpinGui(Plugin plugin, Player player, TreasureRewardManager rewardManager, BonusManager manager)
|
||||
{
|
||||
super(plugin, player, "Carl's Spinner", 27);
|
||||
|
||||
|
||||
_manager = manager;
|
||||
|
||||
ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false);
|
||||
ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[]{ChatColor.RESET + "Good Luck!"}, 1, false, false);
|
||||
|
||||
setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER)));
|
||||
//setItem(CARL_SLOT, new DisplayItem(carlItem));
|
||||
|
||||
|
||||
|
||||
_ticks = new ArrayList<>();
|
||||
_frame = 0;
|
||||
_pitch = 1;
|
||||
|
||||
|
||||
|
||||
|
||||
_ticksPerSwap = 1;
|
||||
|
||||
for (int i=0 ; i<40 ; i++)
|
||||
for (int i = 0; i < 40; i++)
|
||||
_ticks.add(1);
|
||||
|
||||
for (int i=0 ; i<20 ; i++)
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
_ticks.add(2);
|
||||
|
||||
for (int i=0 ; i<10 ; i++)
|
||||
for (int i = 0; i < 10; i++)
|
||||
_ticks.add(4);
|
||||
|
||||
for (int i=0 ; i<4 ; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
_ticks.add(6);
|
||||
|
||||
for (int i=0 ; i<3 ; i++)
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
_ticks.add(8);
|
||||
|
||||
|
||||
if (Math.random() > 0.5)
|
||||
{
|
||||
_ticks.add(12);
|
||||
_ticks.add(12);
|
||||
}
|
||||
|
||||
|
||||
_stopSpinnerAt = _ticks.size();
|
||||
|
||||
|
||||
//Create Rewards
|
||||
_rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still.
|
||||
for (int i = 0; i < _stopSpinnerAt+10 ; i++)
|
||||
_rewards = new Reward[_stopSpinnerAt + 10]; //Adding 10, so theres items to the right still.
|
||||
for (int i = 0; i < _stopSpinnerAt + 10; i++)
|
||||
{
|
||||
if (i != _stopSpinnerAt + 4)
|
||||
{
|
||||
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_FILLER, true);
|
||||
_rewards[i] = TREASURE.nextReward(player, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_REAL, true);
|
||||
_rewards[i] = TREASURE.nextReward(player, false);
|
||||
_reward = _rewards[i];
|
||||
}
|
||||
}
|
||||
|
||||
_reward.giveReward(RewardType.SPINNER_REAL, getPlayer(), new Callback<RewardData>()
|
||||
{
|
||||
@Override
|
||||
public void run(RewardData data)
|
||||
{
|
||||
_rewardData = data;
|
||||
}
|
||||
});
|
||||
|
||||
_reward.giveReward(player, data -> _rewardData = data);
|
||||
}
|
||||
|
||||
private void tick()
|
||||
{
|
||||
|
||||
if(_stopped)
|
||||
|
||||
if (_stopped)
|
||||
return;
|
||||
|
||||
|
||||
_ticksThisSwap++;
|
||||
|
||||
// Swap
|
||||
if (_ticksThisSwap >= _ticksPerSwap)
|
||||
{
|
||||
_ticksThisSwap = 0;
|
||||
_swapCount++;
|
||||
|
||||
if(_pitch == 1)
|
||||
_pitch = (float) 1.5;
|
||||
else if(_pitch == 1.5)
|
||||
_pitch = 2;
|
||||
else if(_pitch == 2)
|
||||
_pitch = 1;
|
||||
|
||||
if (_pitch == 1)
|
||||
_pitch = (float) 1.5;
|
||||
else if (_pitch == 1.5)
|
||||
_pitch = 2;
|
||||
else if (_pitch == 2)
|
||||
_pitch = 1;
|
||||
|
||||
getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch);
|
||||
|
||||
_currentRewardIndex++;
|
||||
@ -150,12 +139,10 @@ public class SpinGui extends SimpleGui
|
||||
|
||||
// Slow
|
||||
_ticksPerSwap = _ticks.get(_currentRewardIndex - 1);
|
||||
|
||||
if(_currentRewardIndex == _stopSpinnerAt)
|
||||
|
||||
if (_currentRewardIndex == _stopSpinnerAt)
|
||||
_stopped = true;
|
||||
}
|
||||
|
||||
_tickCount++;
|
||||
}
|
||||
|
||||
public void updateGui()
|
||||
@ -189,18 +176,18 @@ public class SpinGui extends SimpleGui
|
||||
tick();
|
||||
checkIfDone();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void close(InventoryCloseEvent event)
|
||||
{
|
||||
if(_rewarded)
|
||||
if (_rewarded)
|
||||
return;
|
||||
|
||||
if(event.getPlayer() != getPlayer())
|
||||
|
||||
if (event.getPlayer() != getPlayer())
|
||||
return;
|
||||
|
||||
|
||||
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||
|
||||
|
||||
if (_reward.getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
@ -218,51 +205,51 @@ public class SpinGui extends SimpleGui
|
||||
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void Glass(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if(!_stopped)
|
||||
if (!_stopped)
|
||||
return;
|
||||
|
||||
if(!_rewarded)
|
||||
|
||||
if (!_rewarded)
|
||||
return;
|
||||
|
||||
if(_frame == 0)
|
||||
|
||||
if (_frame == 0)
|
||||
{
|
||||
setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
_frame++;
|
||||
}
|
||||
else if(_frame < 5)
|
||||
else if (_frame < 5)
|
||||
{
|
||||
setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
|
||||
|
||||
setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
|
||||
|
||||
setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
|
||||
_frame++;
|
||||
}
|
||||
if(_frame == 6)
|
||||
if (_frame == 6)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkIfDone()
|
||||
{
|
||||
if(!_stopped)
|
||||
if (!_stopped)
|
||||
return;
|
||||
|
||||
if(_rewarded)
|
||||
|
||||
if (_rewarded)
|
||||
return;
|
||||
|
||||
|
||||
_manager.addPendingExplosion(getPlayer(), _reward);
|
||||
if (_reward.getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
@ -283,7 +270,7 @@ public class SpinGui extends SimpleGui
|
||||
ItemStack item = getInventory().getItem(13);
|
||||
getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName()));
|
||||
_rewarded = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gui.GuiItem;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.treasure.reward.TreasureRewardManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
@ -21,9 +21,9 @@ public class CarlSpinButton implements GuiItem
|
||||
private Plugin _plugin;
|
||||
private Player _player;
|
||||
private BonusManager _bonusManager;
|
||||
private RewardManager _rewardManager;
|
||||
private TreasureRewardManager _rewardManager;
|
||||
|
||||
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager)
|
||||
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, TreasureRewardManager rewardManager)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_player = player;
|
||||
|
@ -33,9 +33,9 @@ import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
|
||||
public class CosmeticManager extends MiniPlugin
|
||||
|
@ -238,6 +238,11 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
itemLore.add(C.cBlue + "Found in Thankful Treasure");
|
||||
break;
|
||||
|
||||
case CostConstants.FOUND_IN_TRICK_OR_TREAT:
|
||||
itemLore.add(C.cBlack);
|
||||
itemLore.add(C.cBlue + "Found in Trick or Treat Treasure");
|
||||
break;
|
||||
|
||||
// Ranks
|
||||
case CostConstants.UNLOCKED_WITH_ULTRA:
|
||||
itemLore.add(C.cBlack);
|
||||
|
@ -2,13 +2,10 @@ package mineplex.core.customdata;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 17/12/15
|
||||
*/
|
||||
public class CorePlayer extends MineplexPlayer
|
||||
{
|
||||
public CorePlayer(Player player, CustomDataManager customDataManager)
|
||||
|
||||
CorePlayer(Player player, CustomDataManager customDataManager)
|
||||
{
|
||||
super(player, customDataManager);
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package mineplex.core.customdata;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class CustomData
|
||||
{
|
||||
private int _id;
|
||||
private String _key;
|
||||
|
||||
private final int _id;
|
||||
private final String _key;
|
||||
|
||||
public CustomData(int id, String key)
|
||||
{
|
||||
@ -24,4 +21,5 @@ public class CustomData
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,32 +8,33 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniDbClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.customdata.repository.CustomDataRepository;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
{
|
||||
private CustomDataRepository _repository;
|
||||
|
||||
public CustomDataManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
private final CustomDataRepository _repository;
|
||||
|
||||
private CustomDataManager()
|
||||
{
|
||||
super("Custom Data Manager", plugin, clientManager);
|
||||
super("Custom Data");
|
||||
|
||||
_repository = new CustomDataRepository(plugin, clientManager, this);
|
||||
_repository = new CustomDataRepository(ClientManager, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
PlayerCustomData data = new PlayerCustomData(_repository);
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
data.setData(_repository.getKey(resultSet.getInt("customDataId")), resultSet.getInt("data"));
|
||||
}
|
||||
|
||||
Set(uuid, data);
|
||||
}
|
||||
|
||||
@ -49,15 +50,16 @@ public class CustomDataManager extends MiniDbClientPlugin<PlayerCustomData>
|
||||
return new PlayerCustomData(_repository);
|
||||
}
|
||||
|
||||
public void saveAsync(Player player)
|
||||
void saveAsync(Player player)
|
||||
{
|
||||
final int accountId = getClientManager().getAccountId(player);
|
||||
final String name = player.getName();
|
||||
|
||||
if (accountId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
runAsync(() -> _repository.saveData(name, player.getUniqueId(), accountId));
|
||||
runAsync(() -> _repository.saveData(player.getUniqueId(), accountId));
|
||||
}
|
||||
|
||||
public CorePlayer getCorePlayer(Player player)
|
||||
|
@ -2,14 +2,11 @@ package mineplex.core.customdata;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public abstract class MineplexPlayer
|
||||
{
|
||||
private Player _player;
|
||||
private CustomDataManager _customDataManager;
|
||||
|
||||
private final Player _player;
|
||||
private final CustomDataManager _customDataManager;
|
||||
|
||||
public MineplexPlayer(Player player, CustomDataManager customDataManager)
|
||||
{
|
||||
@ -31,7 +28,10 @@ public abstract class MineplexPlayer
|
||||
{
|
||||
key = getKeyPrefix() + key;
|
||||
_customDataManager.Get(getPlayer()).setData(key, data);
|
||||
if (save) _customDataManager.saveAsync(_player);
|
||||
if (save)
|
||||
{
|
||||
_customDataManager.saveAsync(_player);
|
||||
}
|
||||
}
|
||||
|
||||
public int get(String key)
|
||||
|
@ -1,25 +1,23 @@
|
||||
package mineplex.core.customdata;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mineplex.core.customdata.repository.CustomDataRepository;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class PlayerCustomData
|
||||
{
|
||||
private HashMap<CustomData, Integer> _data;
|
||||
private CustomDataRepository _repository;
|
||||
|
||||
public PlayerCustomData(CustomDataRepository repository)
|
||||
private final Map<CustomData, Integer> _data;
|
||||
private final CustomDataRepository _repository;
|
||||
|
||||
PlayerCustomData(CustomDataRepository repository)
|
||||
{
|
||||
_data = new HashMap<>();
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public HashMap<CustomData, Integer> getDataMap()
|
||||
public Map<CustomData, Integer> getDataMap()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
@ -37,24 +35,20 @@ public class PlayerCustomData
|
||||
return;
|
||||
}
|
||||
|
||||
_repository.getClientManager().getScheduler().runTaskAsynchronously(
|
||||
_repository.getClientManager().getPlugin(),
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.registerKey(key); // Make sure it's in the DB.
|
||||
_repository.getCustomDataManager().runAsync(() ->
|
||||
{
|
||||
_repository.registerKey(key); // Make sure it's in the DB.
|
||||
|
||||
setData(_repository.getKey(key), amount); // Input
|
||||
}
|
||||
});
|
||||
setData(_repository.getKey(key), amount); // Input
|
||||
});
|
||||
}
|
||||
|
||||
public int getData(String key)
|
||||
{
|
||||
if (_data.containsKey(_repository.getKey(key)))
|
||||
{
|
||||
return _data.get(_repository.getKey(key));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,46 +1,40 @@
|
||||
package mineplex.core.customdata.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.customdata.CustomData;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.customdata.PlayerCustomData;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class CustomDataRepository extends RepositoryBase
|
||||
{
|
||||
|
||||
private static final String SELECT_KEYS = "SELECT id, name FROM customData;";
|
||||
private static final String INSERT_KEY = "INSERT INTO customData (name) VALUES (?);";
|
||||
private static final String UPDATE_DATA = "UPDATE accountCustomData SET data = ? WHERE accountId = ? AND customDataId = ?;";
|
||||
private static final String INSERT_DATA = "INSERT INTO accountCustomData (accountId, customDataId, data) VALUES (?, ?, ?);";
|
||||
|
||||
private ArrayList<CustomData> _dataKeys;
|
||||
private final CoreClientManager _clientManager;
|
||||
private final CustomDataManager _customDataManager;
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private CustomDataManager _customDataManager;
|
||||
private final List<CustomData> _dataKeys;
|
||||
|
||||
public CustomDataRepository(JavaPlugin plugin, CoreClientManager clientManager, CustomDataManager customDataManager)
|
||||
public CustomDataRepository(CoreClientManager clientManager, CustomDataManager customDataManager)
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
|
||||
_clientManager = clientManager;
|
||||
_customDataManager = customDataManager;
|
||||
|
||||
_dataKeys = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,22 +45,18 @@ public class CustomDataRepository extends RepositoryBase
|
||||
|
||||
private void downloadDataKeys()
|
||||
{
|
||||
_dataKeys = new ArrayList<>();
|
||||
|
||||
executeQuery(SELECT_KEYS, new ResultSetCallable()
|
||||
executeQuery(SELECT_KEYS, resultSet ->
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
_dataKeys.clear();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
_dataKeys.add(new CustomData(resultSet.getInt("id"), resultSet.getString("name")));
|
||||
}
|
||||
_dataKeys.add(new CustomData(resultSet.getInt("id"), resultSet.getString("name")));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveData(String name, UUID uuid, int accountId)
|
||||
public void saveData(UUID uuid, int accountId)
|
||||
{
|
||||
PlayerCustomData data = _customDataManager.Get(uuid);
|
||||
|
||||
@ -92,22 +82,23 @@ public class CustomDataRepository extends RepositoryBase
|
||||
public void registerKey(String key)
|
||||
{
|
||||
if (doesKeyExist(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
executeUpdate(INSERT_KEY, new ColumnVarChar("name", 100, key));
|
||||
downloadDataKeys();
|
||||
}
|
||||
|
||||
public ArrayList<CustomData> getDataKeys()
|
||||
{
|
||||
return _dataKeys;
|
||||
}
|
||||
|
||||
public boolean doesKeyExist(String key)
|
||||
{
|
||||
for (CustomData cur : _dataKeys)
|
||||
{
|
||||
if (cur.getKey().equals(key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -115,8 +106,12 @@ public class CustomDataRepository extends RepositoryBase
|
||||
public CustomData getKey(int id)
|
||||
{
|
||||
for (CustomData cur : _dataKeys)
|
||||
{
|
||||
if (cur.getId() == id)
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -124,8 +119,12 @@ public class CustomDataRepository extends RepositoryBase
|
||||
public CustomData getKey(String key)
|
||||
{
|
||||
for (CustomData cur : _dataKeys)
|
||||
{
|
||||
if (cur.getKey().equals(key))
|
||||
{
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -134,4 +133,9 @@ public class CustomDataRepository extends RepositoryBase
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public CustomDataManager getCustomDataManager()
|
||||
{
|
||||
return _customDataManager;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.facebook.command.FacebookCommand;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
|
||||
public class FacebookManager extends MiniDbClientPlugin<FacebookClient>
|
||||
{
|
||||
@ -85,7 +84,7 @@ public class FacebookManager extends MiniDbClientPlugin<FacebookClient>
|
||||
boolean completed = _repository.activateCode(code, accountId);
|
||||
if (completed)
|
||||
{
|
||||
_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10);
|
||||
//_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10);
|
||||
message(player, "Thanks! You earned " + F.elem("10 Ancient Chests"));
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
|
||||
//_donationManager.RewardCoinsLater(getName(), player, 20000);
|
||||
|
@ -7,7 +7,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -25,6 +24,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
@ -75,6 +75,7 @@ import mineplex.core.gadget.gadgets.death.DeathEmerald;
|
||||
import mineplex.core.gadget.gadgets.death.DeathEnchant;
|
||||
import mineplex.core.gadget.gadgets.death.DeathFreedom;
|
||||
import mineplex.core.gadget.gadgets.death.DeathFrostLord;
|
||||
import mineplex.core.gadget.gadgets.death.DeathHalloween;
|
||||
import mineplex.core.gadget.gadgets.death.DeathMapleLeaf;
|
||||
import mineplex.core.gadget.gadgets.death.DeathMusic;
|
||||
import mineplex.core.gadget.gadgets.death.DeathPinataBurst;
|
||||
@ -113,6 +114,7 @@ import mineplex.core.gadget.gadgets.hat.HatItem;
|
||||
import mineplex.core.gadget.gadgets.hat.HatType;
|
||||
import mineplex.core.gadget.gadgets.item.ItemBatGun;
|
||||
import mineplex.core.gadget.gadgets.item.ItemBow;
|
||||
import mineplex.core.gadget.gadgets.item.ItemCandy;
|
||||
import mineplex.core.gadget.gadgets.item.ItemCoal;
|
||||
import mineplex.core.gadget.gadgets.item.ItemCoinBomb;
|
||||
import mineplex.core.gadget.gadgets.item.ItemDuelingSword;
|
||||
@ -128,6 +130,7 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush;
|
||||
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
|
||||
import mineplex.core.gadget.gadgets.item.ItemSnowball;
|
||||
import mineplex.core.gadget.gadgets.item.ItemTNT;
|
||||
import mineplex.core.gadget.gadgets.kitselector.HalloweenKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.RainCloudKitSelector;
|
||||
import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector;
|
||||
@ -166,7 +169,6 @@ import mineplex.core.gadget.gadgets.morph.MorphVillager;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphWitch;
|
||||
import mineplex.core.gadget.gadgets.morph.MorphWither;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.SoulManager;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.SwimManager;
|
||||
import mineplex.core.gadget.gadgets.morph.moba.MorphAnath;
|
||||
import mineplex.core.gadget.gadgets.morph.moba.MorphBardolf;
|
||||
import mineplex.core.gadget.gadgets.morph.moba.MorphBiff;
|
||||
@ -186,6 +188,7 @@ import mineplex.core.gadget.gadgets.mount.types.MountFrost;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountLoveTrain;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountMule;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountNightmareSteed;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountPumpkin;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountSlime;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountSpider;
|
||||
import mineplex.core.gadget.gadgets.mount.types.MountStPatricksHorse;
|
||||
@ -225,6 +228,7 @@ import mineplex.core.gadget.gadgets.particle.ParticleHeart;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleMusic;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticlePartyTime;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleHalloween;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleRain;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleTitan;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
|
||||
@ -244,6 +248,7 @@ import mineplex.core.gadget.gadgets.particle.king.ParticleKing;
|
||||
import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo;
|
||||
import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt;
|
||||
import mineplex.core.gadget.gadgets.taunts.EternalTaunt;
|
||||
import mineplex.core.gadget.gadgets.taunts.InfernalTaunt;
|
||||
import mineplex.core.gadget.gadgets.taunts.RainbowTaunt;
|
||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
|
||||
import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
|
||||
@ -269,6 +274,7 @@ import mineplex.core.gadget.set.SetCupidsLove;
|
||||
import mineplex.core.gadget.set.SetEmerald;
|
||||
import mineplex.core.gadget.set.SetFreedom;
|
||||
import mineplex.core.gadget.set.SetFrostLord;
|
||||
import mineplex.core.gadget.set.SetHalloween;
|
||||
import mineplex.core.gadget.set.SetHowlingWinds;
|
||||
import mineplex.core.gadget.set.SetMusic;
|
||||
import mineplex.core.gadget.set.SetParty;
|
||||
@ -310,8 +316,8 @@ import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.pet.custom.CustomPet;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.treasure.TreasureManager;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class GadgetManager extends MiniPlugin
|
||||
{
|
||||
|
||||
@ -350,7 +356,6 @@ public class GadgetManager extends MiniPlugin
|
||||
private final OutfitWindUpSuitBoosterManager _boosterManager;
|
||||
private final IncognitoManager _incognitoManager;
|
||||
private final GameCosmeticManager _gameCosmeticManager;
|
||||
private TreasureManager _treasureManager;
|
||||
private SoulManager _soulManager;
|
||||
private CastleManager _castleManager;
|
||||
|
||||
@ -361,7 +366,7 @@ public class GadgetManager extends MiniPlugin
|
||||
private final Map<Player, Long> _lastMove = new HashMap<>();
|
||||
private final Map<Player, Map<GadgetType, Gadget>> _playerActiveGadgetMap = new HashMap<>();
|
||||
|
||||
private final HashSet<GadgetSet> _sets = new HashSet<>();
|
||||
private final Set<GadgetSet> _sets = new HashSet<>();
|
||||
|
||||
private UserGadgetPersistence _userGadgetPersistence;
|
||||
|
||||
@ -369,32 +374,30 @@ public class GadgetManager extends MiniPlugin
|
||||
private int _activeItemSlot = 3;
|
||||
private boolean _gadgetsEnabled = true;
|
||||
|
||||
private Set<Entity> _gadgetCollideWhitelist = new HashSet<>();
|
||||
private final Set<Entity> _gadgetCollideWhitelist = new HashSet<>();
|
||||
private final Set<Player> _swimmingPlayers = new HashSet<>();
|
||||
|
||||
public GadgetManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
|
||||
PetManager petManager, PreferencesManager preferencesManager, DisguiseManager disguiseManager,
|
||||
BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager,
|
||||
PacketHandler packetHandler, HologramManager hologramManager, IncognitoManager incognitoManager, CastleManager castleManager)
|
||||
private GadgetManager()
|
||||
{
|
||||
super("Gadget");
|
||||
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_petManager = petManager;
|
||||
_preferencesManager = preferencesManager;
|
||||
_disguiseManager = disguiseManager;
|
||||
_blockRestore = blockRestore;
|
||||
_projectileManager = projectileManager;
|
||||
_achievementManager = achievementManager;
|
||||
_packetManager = packetHandler;
|
||||
_hologramManager = hologramManager;
|
||||
_clientManager = require(CoreClientManager.class);
|
||||
_donationManager = require(DonationManager.class);
|
||||
_inventoryManager = require(InventoryManager.class);
|
||||
_petManager = require(PetManager.class);
|
||||
_preferencesManager = require(PreferencesManager.class);
|
||||
_disguiseManager = require(DisguiseManager.class);
|
||||
_blockRestore = require(BlockRestore.class);
|
||||
_projectileManager = require(ProjectileManager.class);
|
||||
_achievementManager = require(AchievementManager.class);
|
||||
_packetManager = require(PacketHandler.class);
|
||||
_hologramManager = require(HologramManager.class);
|
||||
_userGadgetPersistence = new UserGadgetPersistence(this);
|
||||
_boosterManager = new OutfitWindUpSuitBoosterManager(this);
|
||||
_incognitoManager = incognitoManager;
|
||||
_incognitoManager = require(IncognitoManager.class);
|
||||
_gameCosmeticManager = require(GameCosmeticManager.class);
|
||||
_soulManager = new SoulManager();
|
||||
_castleManager = castleManager;
|
||||
_castleManager = require(CastleManager.class);
|
||||
|
||||
createGadgets();
|
||||
createSets();
|
||||
@ -466,6 +469,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addSet(new SetFreedom(this));
|
||||
addSet(new SetSpring(this));
|
||||
addSet(new SetCanadian(this));
|
||||
addSet(new SetHalloween(this));
|
||||
}
|
||||
|
||||
private void createGadgets()
|
||||
@ -492,6 +496,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new ItemBow(this));
|
||||
addGadget(new ItemLovePotion(this));
|
||||
addGadget(new ItemFlowerGift(this));
|
||||
addGadget(new ItemCandy(this));
|
||||
|
||||
// Costume
|
||||
addGadget(new OutfitRaveSuitHelmet(this));
|
||||
@ -587,6 +592,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new MountCake(this));
|
||||
addGadget(new MountLoveTrain(this));
|
||||
addGadget(new MountStPatricksHorse(this));
|
||||
addGadget(new MountPumpkin(this));
|
||||
|
||||
// Particles
|
||||
addGadget(new ParticleFoot(this));
|
||||
@ -624,7 +630,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new ParticleAuraNiceness(this));
|
||||
addGadget(new ParticleCanadian(this));
|
||||
|
||||
//addGadget(new ParticlePulse(this));
|
||||
addGadget(new ParticleHalloween(this));
|
||||
|
||||
|
||||
// Arrow Trails
|
||||
@ -660,6 +666,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new DeathPresentDanger(this));
|
||||
addGadget(new DeathSpring(this));
|
||||
addGadget(new DeathMapleLeaf(this));
|
||||
addGadget(new DeathHalloween(this));
|
||||
|
||||
// Double Jump
|
||||
addGadget(new DoubleJumpFrostLord(this));
|
||||
@ -730,6 +737,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new EternalTaunt(this));
|
||||
addGadget(new BlowAKissTaunt(this));
|
||||
addGadget(new RainbowTaunt(this));
|
||||
addGadget(new InfernalTaunt(this));
|
||||
|
||||
// Flags
|
||||
addGadget(new FlagGadget(this, FlagType.CANADA));
|
||||
@ -742,6 +750,7 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new RainbowDanceKitSelector(this));
|
||||
addGadget(new RainCloudKitSelector(this));
|
||||
addGadget(new ShimmeringRingKitSelector(this));
|
||||
addGadget(new HalloweenKitSelector(this));
|
||||
|
||||
for (SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values())
|
||||
{
|
||||
@ -1510,44 +1519,13 @@ public class GadgetManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void checkPlayerSwim(PlayerMoveEvent event)
|
||||
{
|
||||
Material material = event.getPlayer().getLocation().getBlock().getType();
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
if (material == Material.WATER || material == Material.STATIONARY_WATER)
|
||||
{
|
||||
if (!SwimManager.isSwimming(uuid))
|
||||
{
|
||||
SwimManager.addPlayer(uuid);
|
||||
SwimManager.removePlayerLava(uuid);
|
||||
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), true, false));
|
||||
}
|
||||
}
|
||||
else if (material == Material.LAVA || material == Material.STATIONARY_LAVA)
|
||||
{
|
||||
if (!SwimManager.isInLava(uuid))
|
||||
{
|
||||
SwimManager.addPlayerLava(uuid);
|
||||
SwimManager.removePlayer(uuid);
|
||||
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), true, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SwimManager.isSwimming(uuid) || SwimManager.isInLava(uuid))
|
||||
{
|
||||
SwimManager.removeLavaAndWater(uuid);
|
||||
Bukkit.getPluginManager().callEvent(new PlayerToggleSwimEvent(event.getPlayer(), false, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
boolean inWater = UtilEnt.isInWater(player);
|
||||
|
||||
public void setTreasureManager(TreasureManager treasureManager)
|
||||
{
|
||||
_treasureManager = treasureManager;
|
||||
}
|
||||
|
||||
public TreasureManager getTreasureManager()
|
||||
{
|
||||
return _treasureManager;
|
||||
if (inWater && _swimmingPlayers.add(player) || !inWater && _swimmingPlayers.remove(player))
|
||||
{
|
||||
UtilServer.CallEvent(new PlayerToggleSwimEvent(player, inWater));
|
||||
}
|
||||
}
|
||||
|
||||
public SoulManager getSoulManager()
|
||||
@ -1555,11 +1533,6 @@ public class GadgetManager extends MiniPlugin
|
||||
return _soulManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles taunt commands
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onTauntCommand(TauntCommandEvent event)
|
||||
{
|
||||
|
@ -10,9 +10,9 @@ public class PlayerToggleSwimEvent extends Event
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private boolean _swimming, _lava;
|
||||
private boolean _swimming;
|
||||
|
||||
public PlayerToggleSwimEvent(Player player, boolean swimming, boolean lava)
|
||||
public PlayerToggleSwimEvent(Player player, boolean swimming)
|
||||
{
|
||||
_player = player;
|
||||
_swimming = swimming;
|
||||
@ -28,11 +28,6 @@ public class PlayerToggleSwimEvent extends Event
|
||||
return _swimming;
|
||||
}
|
||||
|
||||
public boolean isInLava()
|
||||
{
|
||||
return _lava;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
|
@ -58,7 +58,7 @@ public class ArrowTrailFreedom extends ArrowEffectGadget
|
||||
@Override
|
||||
public void doHitEffect(Arrow arrow)
|
||||
{
|
||||
BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(arrow.getLocation(), Manager.getPlugin(), _color);
|
||||
BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(arrow.getLocation(), _color);
|
||||
babyFireworkEffect.start();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
package mineplex.core.gadget.gadgets.death;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.blood.BloodEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
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.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.DeathEffectGadget;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
|
||||
public class DeathHalloween extends DeathEffectGadget
|
||||
{
|
||||
|
||||
public DeathHalloween(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Spooky Death",
|
||||
UtilText.splitLineToArray(C.cGray + "Explode in a flurry of fright.", LineFormat.LORE),
|
||||
CostConstants.FOUND_IN_TRICK_OR_TREAT, Material.PUMPKIN, (byte) 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlood(Player player, BloodEvent event)
|
||||
{
|
||||
event.setItem(Material.PUMPKIN, (byte) 0);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 1.1, 0), 0.4F, 0.4F, 0.4F, 0.1F, 30, ViewDist.LONG);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,7 +2,7 @@ package mineplex.core.gadget.gadgets.gamemodifiers.moba.emblems;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public enum EmblemType
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ import mineplex.core.disguise.disguises.DisguiseSnowman;
|
||||
import mineplex.core.disguise.disguises.DisguiseSpider;
|
||||
import mineplex.core.disguise.disguises.DisguiseWitch;
|
||||
import mineplex.core.disguise.disguises.DisguiseZombie;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public enum ShopMorphType
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ import mineplex.core.gadget.types.GameModifierGadget;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public class HeroSkinGadget extends GameModifierGadget
|
||||
{
|
||||
|
@ -1,8 +1,7 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.moba.skins;
|
||||
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public class HeroSkinGadgetData
|
||||
{
|
||||
|
@ -0,0 +1,55 @@
|
||||
package mineplex.core.gadget.gadgets.item;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.Ammo;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
|
||||
public class ItemCandy extends ItemGadget
|
||||
{
|
||||
|
||||
private static final PotionEffectType[] POTION_EFFECTS = {
|
||||
PotionEffectType.SPEED,
|
||||
PotionEffectType.JUMP,
|
||||
};
|
||||
|
||||
public ItemCandy(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Halloween Candy",
|
||||
UtilText.splitLineToArray(C.cWhite + "Get some serious sugar rush", LineFormat.LORE),
|
||||
CostConstants.FOUND_IN_TRICK_OR_TREAT, Material.COOKIE, (byte) 0, 2000, new Ammo("Halloween Candy", "1 Halloween Candy", Material.COOKIE, (byte) 0, new String[]
|
||||
{
|
||||
}
|
||||
, CostConstants.FOUND_IN_TRICK_OR_TREAT, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ActivateCustom(Player player)
|
||||
{
|
||||
player.sendMessage(F.main(Manager.getName(), "Sugar Rush!!!"));
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
||||
|
||||
PotionEffectType effectType = UtilMath.randomElement(POTION_EFFECTS);
|
||||
|
||||
if (effectType == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.removePotionEffect(effectType);
|
||||
player.addPotionEffect(new PotionEffect(effectType, 10 * 20, 5 + UtilMath.r(5)));
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package mineplex.core.gadget.gadgets.item;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -34,8 +33,8 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.pet.PetType;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.rewards.PetReward;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
public class ItemCoal extends ItemGadget
|
||||
{
|
||||
@ -132,13 +131,10 @@ public class ItemCoal extends ItemGadget
|
||||
Recharge.Instance.use(player, getName(), 30000, true, true);
|
||||
|
||||
PetReward reward = new PetReward(
|
||||
Manager.getPetManager(),
|
||||
Manager.getInventoryManager(),
|
||||
Manager.getDonationManager(),
|
||||
"Coal Apparition", "Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0);
|
||||
"Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.LEGENDARY, 0);
|
||||
|
||||
if (reward.canGiveReward(player))
|
||||
reward.giveReward(null, player, new Callback<RewardData>()
|
||||
reward.giveReward(player, new Callback<RewardData>()
|
||||
{
|
||||
@Override
|
||||
public void run(RewardData data)
|
||||
|
@ -0,0 +1,46 @@
|
||||
package mineplex.core.gadget.gadgets.kitselector;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
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.UtilText;
|
||||
import mineplex.core.common.util.particles.ColoredParticle;
|
||||
import mineplex.core.common.util.particles.DustSpellColor;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.KitSelectorGadget;
|
||||
|
||||
public class HalloweenKitSelector extends KitSelectorGadget
|
||||
{
|
||||
|
||||
private static final DustSpellColor COLOR_A = new DustSpellColor(Color.ORANGE);
|
||||
private static final DustSpellColor COLOR_B = new DustSpellColor(Color.BLACK);
|
||||
|
||||
public HalloweenKitSelector(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Haunted Kit", UtilText.splitLinesToArray(new String[]{C.cGray + "Are you scared?"}, LineFormat.LORE),
|
||||
0, Material.PUMPKIN, (byte) 0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void playParticle(Entity entity, Player playTo)
|
||||
{
|
||||
Location location = entity.getLocation().add(0, 1.1, 0);
|
||||
|
||||
new ColoredParticle(ParticleType.RED_DUST, COLOR_A, UtilAlg.getRandomLocation(location, 1))
|
||||
.display(ViewDist.NORMAL, playTo);
|
||||
new ColoredParticle(ParticleType.RED_DUST, COLOR_B, UtilAlg.getRandomLocation(location, 1))
|
||||
.display(ViewDist.NORMAL, playTo);
|
||||
}
|
||||
|
||||
}
|
@ -38,7 +38,8 @@ public class SingleParticleKitSelector extends KitSelectorGadget
|
||||
EMBER("Ember", UtilText.splitLinesToArray(new String[]{C.cGray + "I'd like my kit well done."}, LineFormat.LORE),
|
||||
0, Material.COAL, (byte) 0, UtilParticle.ParticleType.SMOKE, 3),
|
||||
LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "I think I LIKE this kit, if you know what I mean."}, LineFormat.LORE),
|
||||
0, Material.POTION, (byte) 8233, UtilParticle.ParticleType.HEART);
|
||||
0, Material.POTION, (byte) 8233, UtilParticle.ParticleType.HEART),
|
||||
;
|
||||
|
||||
private String _name;
|
||||
private String[] _lore;
|
||||
|
@ -24,7 +24,6 @@ import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.disguise.disguises.DisguiseSquid;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.SwimManager;
|
||||
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.gadget.types.OutfitGadget;
|
||||
@ -57,7 +56,6 @@ public class MorphSquid extends MorphGadget implements IThrown
|
||||
applyArmor(player, message);
|
||||
DisguiseSquid disguiseSquid = new DisguiseSquid(player);
|
||||
UtilMorph.disguise(player, disguiseSquid, Manager);
|
||||
onToggleSwim(new PlayerToggleSwimEvent(player, SwimManager.isSwimming(player.getUniqueId()), SwimManager.isInLava(player.getUniqueId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -92,7 +90,9 @@ public class MorphSquid extends MorphGadget implements IThrown
|
||||
public void onToggleSwim(PlayerToggleSwimEvent event)
|
||||
{
|
||||
if (!isActive(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isSwimming())
|
||||
{
|
||||
|
@ -102,23 +102,23 @@ public class MorphWitch extends MorphGadget
|
||||
return;
|
||||
}
|
||||
|
||||
// Checks if player is opening a treasure chest/close to a treasure area
|
||||
if (Manager.getTreasureManager() != null)
|
||||
{
|
||||
if (Manager.getTreasureManager().isOpening(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
|
||||
return;
|
||||
}
|
||||
for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
|
||||
{
|
||||
if (blockLocation.distanceSquared(cauldronLocation) <= 25)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// // Checks if player is opening a treasure chest/close to a treasure area
|
||||
// if (Manager.getTreasureManager() != null)
|
||||
// {
|
||||
// if (Manager.getTreasureManager().isOpening(event.getPlayer()))
|
||||
// {
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
|
||||
// return;
|
||||
// }
|
||||
// for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
|
||||
// {
|
||||
// if (blockLocation.distanceSquared(cauldronLocation) <= 25)
|
||||
// {
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Checks if the player is close to a cactus
|
||||
for (int x = -3; x < 3; x++)
|
||||
|
@ -41,7 +41,7 @@ public class WitchEffectManager
|
||||
bat.setCustomNameVisible(true);
|
||||
_bat = bat;
|
||||
|
||||
_witchParticleEffect = new WitchParticleEffect(_location, UtilServer.getPlugin());
|
||||
_witchParticleEffect = new WitchParticleEffect(_location);
|
||||
_witchParticleEffect.start();
|
||||
}
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
package mineplex.core.gadget.gadgets.morph.managers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SwimManager
|
||||
{
|
||||
|
||||
private static List<UUID> _swimming = new ArrayList<>();
|
||||
private static List<UUID> _lava = new ArrayList<>();
|
||||
|
||||
public static void addPlayer(UUID uuid)
|
||||
{
|
||||
_swimming.add(uuid);
|
||||
}
|
||||
|
||||
public static void removePlayer(UUID uuid)
|
||||
{
|
||||
if (_swimming.contains(uuid))
|
||||
{
|
||||
_swimming.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addPlayerLava(UUID uuid)
|
||||
{
|
||||
_lava.add(uuid);
|
||||
}
|
||||
|
||||
public static void removePlayerLava(UUID uuid)
|
||||
{
|
||||
if (_lava.contains(uuid))
|
||||
{
|
||||
_lava.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeLavaAndWater(UUID uuid)
|
||||
{
|
||||
removePlayerLava(uuid);
|
||||
removePlayer(uuid);
|
||||
}
|
||||
|
||||
public static boolean isSwimming(UUID uuid)
|
||||
{
|
||||
return _swimming.contains(uuid);
|
||||
}
|
||||
|
||||
public static boolean isInLava(UUID uuid)
|
||||
{
|
||||
return _lava.contains(uuid);
|
||||
}
|
||||
|
||||
}
|
@ -183,7 +183,7 @@ public class MorphAnath extends MorphGadget
|
||||
|
||||
Block block = player.getLocation().getBlock();
|
||||
|
||||
while (!UtilBlock.solid(block))
|
||||
while (!UtilBlock.solid(block) && block.getLocation().getBlockY() > 10)
|
||||
{
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
@ -57,12 +57,6 @@ public class MountBabyReindeer extends HorseMount
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldRide(Player player, SingleEntityMountData<Horse> data, boolean head)
|
||||
{
|
||||
return data.ownsMount(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fly(UpdateEvent event)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public class MountFreedomHorse extends HorseMount
|
||||
|
||||
data.getEntity().getInventory().setArmor(new ItemStack(Material.DIAMOND_BARDING));
|
||||
|
||||
FreedomTrailEffect effect = new FreedomTrailEffect(horse, Manager.getPlugin());
|
||||
FreedomTrailEffect effect = new FreedomTrailEffect(horse);
|
||||
effect.start();
|
||||
_trailMap.put(data, effect);
|
||||
|
||||
|
@ -0,0 +1,119 @@
|
||||
package mineplex.core.gadget.gadgets.mount.types;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
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.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.mount.Mount;
|
||||
import mineplex.core.gadget.gadgets.mount.SingleEntityMountData;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class MountPumpkin extends Mount<SingleEntityMountData>
|
||||
{
|
||||
|
||||
private static final ItemStack HELMET = new ItemStack(Material.JACK_O_LANTERN);
|
||||
|
||||
public MountPumpkin(GadgetManager manager)
|
||||
{
|
||||
super(manager,
|
||||
"Pumpkin Mount",
|
||||
UtilText.splitLinesToArray(new String[]
|
||||
{
|
||||
C.cGray + "One of the Pumpkin King's flying minions.",
|
||||
"",
|
||||
C.cBlue + "Earned by defeating the Pumpkin King",
|
||||
C.cBlue + "in the 2017 Halloween Horror Event."
|
||||
}, LineFormat.LORE),
|
||||
CostConstants.NO_LORE,
|
||||
Material.JACK_O_LANTERN,
|
||||
(byte) 0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleEntityMountData spawnMount(Player player)
|
||||
{
|
||||
ArmorStand stand = player.getWorld().spawn(player.getLocation(), ArmorStand.class);
|
||||
|
||||
stand.setCustomName(player.getName() + "'s Pumpkin Mount");
|
||||
stand.setGravity(false);
|
||||
stand.setVisible(false);
|
||||
stand.setHelmet(HELMET);
|
||||
stand.setPassenger(player);
|
||||
stand.getWorld().playSound(stand.getLocation(), Sound.FIZZ, 1, 0.8F);
|
||||
|
||||
return new SingleEntityMountData<>(player, stand);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateLocation(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Player> toRemove = new HashSet<>();
|
||||
|
||||
for (Player player : getActiveMounts().keySet())
|
||||
{
|
||||
SingleEntityMountData data = getActiveMounts().get(player);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
toRemove.add(player);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!data.getEntity().isValid() || data.getEntity().getPassenger() == null)
|
||||
{
|
||||
data.getEntity().remove();
|
||||
toRemove.add(player);
|
||||
continue;
|
||||
}
|
||||
|
||||
Location playerLocation = player.getLocation();
|
||||
Location location = data.getEntity().getLocation().add(playerLocation.getDirection());
|
||||
((CraftEntity) data.getEntity()).getHandle().setPositionRotation(location.getX(), location.getY(), location.getZ(), playerLocation.getYaw(), playerLocation.getPitch());
|
||||
}
|
||||
|
||||
for (Player player : toRemove)
|
||||
{
|
||||
disable(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateParticles(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : getActiveMounts().keySet())
|
||||
{
|
||||
Entity entity = getActiveMounts().get(player).getEntity();
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1.4, 0), 0.2F, 0.2F, 0.2F, 0.05F, 4, ViewDist.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
@ -111,7 +111,7 @@ public class MountSpider extends HorseMount
|
||||
Player player = entry.getKey();
|
||||
Horse horse = entry.getValue().getEntity();
|
||||
|
||||
if (!horse.getPassenger().equals(player))
|
||||
if (horse.getPassenger() == null || !horse.getPassenger().equals(player))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class MountStPatricksHorse extends HorseMount
|
||||
SingleEntityMountData<Horse> data = super.spawnMount(player);
|
||||
Horse horse = data.getEntity();
|
||||
|
||||
RainbowTrailEffect effect = new RainbowTrailEffect(horse, Manager.getPlugin(), _items);
|
||||
RainbowTrailEffect effect = new RainbowTrailEffect(horse, _items);
|
||||
effect.start();
|
||||
_trailMap.put(data, effect);
|
||||
|
||||
|
@ -9,7 +9,6 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -126,29 +125,29 @@ public class OutfitFreezeSuit extends OutfitGadget
|
||||
|
||||
Map<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation(), RANGE);
|
||||
|
||||
boolean setBlocks = true, forceBreak = false;
|
||||
//boolean setBlocks = true, forceBreak = false;
|
||||
|
||||
for (Block block : blocks.keySet())
|
||||
{
|
||||
if (Manager.getTreasureManager() != null)
|
||||
{
|
||||
if (Manager.getTreasureManager().isOpening(player))
|
||||
{
|
||||
forceBreak= true;
|
||||
}
|
||||
for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
|
||||
{
|
||||
if (blockLocation.distanceSquared(block.getLocation()) <= 25)
|
||||
{
|
||||
setBlocks = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (forceBreak)
|
||||
break;
|
||||
|
||||
if (!setBlocks)
|
||||
continue;
|
||||
// if (Manager.getTreasureManager() != null)
|
||||
// {
|
||||
// if (Manager.getTreasureManager().isOpening(player))
|
||||
// {
|
||||
// forceBreak= true;
|
||||
// }
|
||||
// for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
|
||||
// {
|
||||
// if (blockLocation.distanceSquared(block.getLocation()) <= 25)
|
||||
// {
|
||||
// setBlocks = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (forceBreak)
|
||||
// break;
|
||||
//
|
||||
// if (!setBlocks)
|
||||
// continue;
|
||||
|
||||
Manager.getBlockRestore().snow(block, (byte) 1, (byte) 1, (int) (DURATION * (1 + blocks.get(block))), 250, 0);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class ParticleChristmasTree extends ParticleGadget
|
||||
{
|
||||
if (!_effects.containsKey(player.getUniqueId()))
|
||||
{
|
||||
ChristmasTreeEffect christmasTreeEffect = new ChristmasTreeEffect(Manager.getPlugin(), player, Manager);
|
||||
ChristmasTreeEffect christmasTreeEffect = new ChristmasTreeEffect(player, Manager);
|
||||
christmasTreeEffect.start();
|
||||
_effects.put(player.getUniqueId(), christmasTreeEffect);
|
||||
}
|
||||
|
@ -18,10 +18,11 @@ import mineplex.core.common.util.particles.ColoredParticle;
|
||||
import mineplex.core.common.util.particles.DustSpellColor;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class ParticlePulse extends ParticleGadget
|
||||
public class ParticleHalloween extends ParticleGadget
|
||||
{
|
||||
|
||||
private static final int ARRAY_SIZE = 300;
|
||||
@ -36,11 +37,11 @@ public class ParticlePulse extends ParticleGadget
|
||||
private int[] _nextIndexes;
|
||||
private int _index, _inIndex;
|
||||
|
||||
public ParticlePulse(GadgetManager manager)
|
||||
public ParticleHalloween(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Lotus", UtilText
|
||||
.splitLineToArray(C.cGray + "I need healing. Mada mada", LineFormat.LORE), -2,
|
||||
Material.INK_SACK, (byte) 10);
|
||||
super(manager, "Halloween Aura", UtilText
|
||||
.splitLineToArray(C.cGray + "Scary Skeletons", LineFormat.LORE), CostConstants.FOUND_IN_TRICK_OR_TREAT,
|
||||
Material.PUMPKIN, (byte) 0);
|
||||
|
||||
_nextIndexes = new int[INDEXES_PER_ITERATION];
|
||||
_x = new ArrayList<>(ARRAY_SIZE);
|
||||
@ -82,7 +83,7 @@ public class ParticlePulse extends ParticleGadget
|
||||
public void playParticle(Player player, UpdateEvent event)
|
||||
{
|
||||
Location location = player.getLocation().add(0, 0.3, 0);
|
||||
DustSpellColor color = new DustSpellColor(_index < _inIndex ? Color.MAGENTA : Color.CYAN);
|
||||
DustSpellColor color = new DustSpellColor(_index < _inIndex ? Color.BLACK : Color.ORANGE);
|
||||
|
||||
if (Manager.isMoving(player))
|
||||
{
|
@ -1,8 +1,5 @@
|
||||
package mineplex.core.gadget.gadgets.particle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -13,7 +10,6 @@ import mineplex.core.common.util.LineFormat;
|
||||
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.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
@ -43,10 +39,6 @@ public class ParticleRain extends ParticleGadget
|
||||
{
|
||||
Location loc = player.getLocation().add(0, 3.5, 0);
|
||||
UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0.6f, 0f, 0.6f, 0, 8, ViewDist.NORMAL, player);
|
||||
|
||||
List<Player> others = new ArrayList<Player>();
|
||||
others.addAll(UtilServer.getPlayersCollection());
|
||||
others.remove(player);
|
||||
UtilParticle.PlayParticle(ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 8, ViewDist.NORMAL);
|
||||
|
||||
UtilParticle.playParticleFor(player, ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, ViewDist.NORMAL);
|
||||
|
@ -38,7 +38,7 @@ public class ParticleFreedom extends ParticleGadget
|
||||
@Override
|
||||
public void startEffect(Player player)
|
||||
{
|
||||
_effects.put(player.getUniqueId(), new FreedomFireworkEffect(player, Manager.getPlugin(), true));
|
||||
_effects.put(player.getUniqueId(), new FreedomFireworkEffect(player, true));
|
||||
_effects.get(player.getUniqueId()).start();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class ParticleSpringHalo extends ParticleGadget
|
||||
super.enableCustom(player, message);
|
||||
Manager.removeGadgetType(player, GadgetType.MORPH, this);
|
||||
Manager.removeOutfit(player, OutfitGadget.ArmorSlot.HELMET);
|
||||
ColoredCircleEffect circleEffect = new ColoredCircleEffect(Manager.getPlugin(), player, 0.7d, false);
|
||||
ColoredCircleEffect circleEffect = new ColoredCircleEffect(player, 0.7d, false);
|
||||
RGBData colorA = UtilColor.hexToRgb(0x5a92ed);
|
||||
RGBData colorB = UtilColor.hexToRgb(0xdb5aed);
|
||||
RGBData colorC = UtilColor.hexToRgb(0xd2cdf2);
|
||||
|
@ -46,7 +46,7 @@ public class BlowAKissTaunt extends TauntGadget
|
||||
ignore.add(Material.AIR);
|
||||
Location loc = player.getTargetBlock(ignore, 64).getLocation().add(0.5, 0.5, 0.5);
|
||||
|
||||
BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc, this);
|
||||
BlowAKissEffect blowAKissEffect = new BlowAKissEffect(player, loc);
|
||||
blowAKissEffect.start();
|
||||
|
||||
return true;
|
||||
|
@ -11,11 +11,11 @@ import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -99,6 +99,7 @@ public class EternalTaunt extends TauntGadget
|
||||
|
||||
Item clock = player.getWorld().dropItem(player.getLocation().add(0.5, 1.5, 0.5),
|
||||
ItemStackFactory.Instance.CreateStack(Material.WATCH, (byte) 0, 1, " " + i));
|
||||
clock.setPickupDelay(Integer.MAX_VALUE);
|
||||
|
||||
enableArcadeSpawnEvent = new EnableArcadeSpawnEvent(false);
|
||||
Bukkit.getPluginManager().callEvent(enableArcadeSpawnEvent);
|
||||
@ -128,15 +129,16 @@ public class EternalTaunt extends TauntGadget
|
||||
@Override
|
||||
public void onFinish(Player player)
|
||||
{
|
||||
if (_disguises.containsKey(player.getUniqueId()))
|
||||
DisguiseBase disguise = _disguises.remove(player.getUniqueId());
|
||||
|
||||
if (disguise != null)
|
||||
{
|
||||
Manager.getDisguiseManager().undisguise(_disguises.remove(player.getUniqueId()));
|
||||
Manager.getDisguiseManager().undisguise(disguise);
|
||||
}
|
||||
|
||||
if (_clocks.containsKey(player.getUniqueId()))
|
||||
{
|
||||
_clocks.get(player.getUniqueId()).forEach(c -> c.remove());
|
||||
_clocks.get(player.getUniqueId()).clear();
|
||||
_clocks.get(player.getUniqueId()).forEach(Entity::remove);
|
||||
_clocks.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
@ -149,19 +151,4 @@ public class EternalTaunt extends TauntGadget
|
||||
Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClockPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
for (List<Item> clocks : _clocks.values())
|
||||
{
|
||||
for (Item item : clocks)
|
||||
{
|
||||
if (event.getItem().equals(item))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package mineplex.core.gadget.gadgets.taunts;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseSkeleton;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.TauntGadget;
|
||||
import mineplex.core.gadget.util.CostConstants;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.particleeffects.TextEffect;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
|
||||
public class InfernalTaunt extends TauntGadget
|
||||
{
|
||||
|
||||
private static final int COOLDOWN = 60000;
|
||||
private static final int PVP_COOLDOWN = 10000;
|
||||
|
||||
private final Map<UUID, DisguiseBase> _disguises = new HashMap<>();
|
||||
|
||||
public InfernalTaunt(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Infernal Taunt", new String[]
|
||||
{
|
||||
C.cGray + "Shows everyone your name in",
|
||||
C.cGray + "burning text!",
|
||||
"",
|
||||
C.cWhite + "Use /taunt in game to use this taunt.",
|
||||
C.cRed + "Cannot be used while in PvP!"
|
||||
}, CostConstants.FOUND_IN_TRICK_OR_TREAT, Material.SKULL_ITEM, (byte) 1);
|
||||
|
||||
setCanPlayWithPvp(false);
|
||||
setPvpCooldown(PVP_COOLDOWN);
|
||||
setShouldPlay(true);
|
||||
setEventType(UpdateType.FASTER);
|
||||
addDisabledGames(GameDisplay.Smash, GameDisplay.SmashTeams, GameDisplay.SmashDomination, GameDisplay.SmashTraining);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStart(Player player)
|
||||
{
|
||||
if (!Recharge.Instance.use(player, getName(), COOLDOWN, true, false, "Cosmetics"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
player.getWorld().strikeLightningEffect(player.getLocation());
|
||||
Bukkit.broadcastMessage(F.main("Taunt", F.name(player.getName()) + " unleashed the " + F.name("Infernal Horror") + "!"));
|
||||
|
||||
if (!Manager.getDisguiseManager().isDisguised(player))
|
||||
{
|
||||
DisguiseSkeleton disguiseSkeleton = new DisguiseSkeleton(player);
|
||||
disguiseSkeleton.setName(player.getName());
|
||||
disguiseSkeleton.setCustomNameVisible(true);
|
||||
disguiseSkeleton.showArmor();
|
||||
disguiseSkeleton.SetSkeletonType(SkeletonType.WITHER);
|
||||
Manager.getDisguiseManager().disguise(disguiseSkeleton);
|
||||
_disguises.put(player.getUniqueId(), disguiseSkeleton);
|
||||
}
|
||||
|
||||
new TextEffect(40, player.getName(), player.getLocation().add(0, 5, 0), false, false, ParticleType.FLAME)
|
||||
.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlay(Player player)
|
||||
{
|
||||
if (getPlayerTicks(player) >= 40)
|
||||
{
|
||||
finish(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(Player player)
|
||||
{
|
||||
DisguiseBase disguise = _disguises.remove(player.getUniqueId());
|
||||
|
||||
if (disguise != null)
|
||||
{
|
||||
Manager.getDisguiseManager().undisguise(disguise);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ public class RainbowTaunt extends TauntGadget
|
||||
Location start = player.getLocation().clone().add(sideA.multiply(4).toLocation(player.getWorld()));
|
||||
Location end = player.getLocation().clone().add(sideB.multiply(4).toLocation(player.getWorld()));
|
||||
|
||||
RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start, Manager.getPlugin());
|
||||
RainbowTauntEffect rainbowTauntEffect = new RainbowTauntEffect(start);
|
||||
rainbowTauntEffect.setTargetLocation(new EffectLocation(end));
|
||||
rainbowTauntEffect.start();
|
||||
|
||||
|
@ -182,11 +182,11 @@ public class WinEffectHalloween extends WinEffectGadget
|
||||
BabyFireworkEffect babyFireworkEffect;
|
||||
if (i %2 == 0)
|
||||
{
|
||||
babyFireworkEffect = new BabyFireworkEffect((randomLoc) ? randLocation : entityLocation, Manager.getPlugin(), color);
|
||||
babyFireworkEffect = new BabyFireworkEffect((randomLoc) ? randLocation : entityLocation, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
babyFireworkEffect = new BabyFireworkEffect((randomLoc) ? randLocation : entityLocation, Manager.getPlugin(), Color.ORANGE, Color.BLACK);
|
||||
babyFireworkEffect = new BabyFireworkEffect((randomLoc) ? randLocation : entityLocation, Color.ORANGE, Color.BLACK);
|
||||
}
|
||||
// Starts without the firework trail
|
||||
babyFireworkEffect.setCount(6);
|
||||
|
@ -0,0 +1,22 @@
|
||||
package mineplex.core.gadget.set;
|
||||
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween;
|
||||
import mineplex.core.gadget.gadgets.death.DeathHalloween;
|
||||
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween;
|
||||
import mineplex.core.gadget.gadgets.particle.ParticleHalloween;
|
||||
import mineplex.core.gadget.types.GadgetSet;
|
||||
|
||||
public class SetHalloween extends GadgetSet
|
||||
{
|
||||
|
||||
public SetHalloween(GadgetManager manager)
|
||||
{
|
||||
super(manager, "Spooky", "Increased chance of spawning Flaming Pumpkins in game (During Halloween)",
|
||||
manager.getGadget(ArrowTrailHalloween.class),
|
||||
manager.getGadget(DeathHalloween.class),
|
||||
manager.getGadget(DoubleJumpHalloween.class),
|
||||
manager.getGadget(ParticleHalloween.class)
|
||||
);
|
||||
}
|
||||
}
|
@ -84,27 +84,27 @@ public abstract class TauntGadget extends Gadget
|
||||
|
||||
public abstract void onFinish(Player player);
|
||||
|
||||
public void setCanPlayWithPvp(boolean canPlayWithPvp)
|
||||
protected void setCanPlayWithPvp(boolean canPlayWithPvp)
|
||||
{
|
||||
_canPlayWithPvp = canPlayWithPvp;
|
||||
}
|
||||
|
||||
public void setPvpCooldown(long pvpCooldown)
|
||||
protected void setPvpCooldown(long pvpCooldown)
|
||||
{
|
||||
_pvpCooldown = pvpCooldown;
|
||||
}
|
||||
|
||||
public void setShouldPlay(boolean shouldPlay)
|
||||
protected void setShouldPlay(boolean shouldPlay)
|
||||
{
|
||||
_shouldPlay = shouldPlay;
|
||||
}
|
||||
|
||||
public void setEventType(UpdateType updateType)
|
||||
protected void setEventType(UpdateType updateType)
|
||||
{
|
||||
_updateType = updateType;
|
||||
}
|
||||
|
||||
public void addDisabledGames(GameDisplay... disabledGames)
|
||||
protected void addDisabledGames(GameDisplay... disabledGames)
|
||||
{
|
||||
_disabledGames.addAll(Arrays.asList(disabledGames));
|
||||
}
|
||||
@ -124,9 +124,9 @@ public abstract class TauntGadget extends Gadget
|
||||
return _pvpCooldown;
|
||||
}
|
||||
|
||||
public int getPlayerTicks(Player player)
|
||||
protected int getPlayerTicks(Player player)
|
||||
{
|
||||
return (_ticksPerPlayer.containsKey(player.getUniqueId())) ? _ticksPerPlayer.get(player.getUniqueId()) : -1;
|
||||
return _ticksPerPlayer.getOrDefault(player.getUniqueId(), -1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -71,6 +71,10 @@ public class CostConstants
|
||||
* Found in Thankful Treasure
|
||||
*/
|
||||
public static final int FOUND_IN_THANKFUL_CHESTS = -21;
|
||||
/**
|
||||
* Found in Trick or Treat Treasure
|
||||
*/
|
||||
public static final int FOUND_IN_TRICK_OR_TREAT = -22;
|
||||
/**
|
||||
* Unlocked with Ultra Rank
|
||||
*/
|
||||
|
@ -1,96 +0,0 @@
|
||||
package mineplex.core.globalpacket;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.globalpacket.command.GlobalPacketCommand;
|
||||
import mineplex.core.globalpacket.listeners.GlobalGiveCoins;
|
||||
import mineplex.core.globalpacket.listeners.GlobalGiveGems;
|
||||
import mineplex.core.globalpacket.listeners.GlobalGiveItem;
|
||||
import mineplex.core.globalpacket.redis.GlobalPacketHandler;
|
||||
import mineplex.core.globalpacket.redis.GlobalPacketMessage;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class GlobalPacketManager extends MiniPlugin
|
||||
{
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
GLOBAL_PACKET_COMMAND,
|
||||
}
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private ServerStatusManager _statusManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private DonationManager _donationManager;
|
||||
private RewardManager _rewardManager;
|
||||
|
||||
public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager, DonationManager donationManager, PetManager petManager, StatsManager statsManager, RewardManager rewardmanager)
|
||||
{
|
||||
super("Global Packet Manager", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_statusManager = statusManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_donationManager = donationManager;
|
||||
_rewardManager = rewardmanager;
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("GlobalPacketMessage", GlobalPacketMessage.class, new GlobalPacketHandler(statusManager));
|
||||
|
||||
getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager, _rewardManager), getPlugin());
|
||||
getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin());
|
||||
getPluginManager().registerEvents(new GlobalGiveCoins(donationManager, clientManager), getPlugin());
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
|
||||
PermissionGroup.ADMIN.setPermission(Perm.GLOBAL_PACKET_COMMAND, true, true);
|
||||
}
|
||||
|
||||
public void callGlobalCommand(Player caller, String[] args)
|
||||
{
|
||||
String callerName = null;
|
||||
UUID callerUUID = null;
|
||||
List<String> callerRanks = null;
|
||||
|
||||
if (caller != null)
|
||||
{
|
||||
callerName = caller.getName();
|
||||
callerUUID = caller.getUniqueId();
|
||||
callerRanks = _clientManager.Get(caller).getAdditionalGroups().stream().map(PermissionGroup::name).collect(Collectors.toList());
|
||||
callerRanks.add(_clientManager.Get(caller).getPrimaryGroup().name());
|
||||
|
||||
UtilPlayer.message(caller, F.main("Global", "Sending Global Command with Arguments;"));
|
||||
UtilPlayer.message(caller, F.main("Global", F.elem(Arrays.toString(args))));
|
||||
UtilPlayer.message(caller, F.main("Global", "Please be patient for a response."));
|
||||
}
|
||||
|
||||
GlobalPacketMessage message = new GlobalPacketMessage(callerName, callerUUID, callerRanks, _statusManager.getCurrentServerName(), args);
|
||||
message.publish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new GlobalPacketCommand(this));
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package mineplex.core.globalpacket.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.globalpacket.GlobalPacketManager;
|
||||
|
||||
public class GlobalPacketCommand extends CommandBase<GlobalPacketManager>
|
||||
{
|
||||
public GlobalPacketCommand(GlobalPacketManager plugin)
|
||||
{
|
||||
super(plugin, GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND, "global", "globalpacket");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Global", "Please call the global command with at least 1 argument"));
|
||||
UtilPlayer.message(caller, F.main("Global", "For help please see /global google doc"));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.callGlobalCommand(caller, args);
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package mineplex.core.globalpacket.event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class GlobalPacketEvent extends Event
|
||||
{
|
||||
private Player _caller;
|
||||
private String _callerName;
|
||||
private UUID _callerUUID;
|
||||
private List<String> _callerGroups;
|
||||
private String _sourceServer;
|
||||
private String[] _parts;
|
||||
|
||||
public GlobalPacketEvent(Player caller, String callerName, UUID callerUUID, List<String> callerGroups, String sourceServer, String[] parts)
|
||||
{
|
||||
_caller = caller;
|
||||
_callerName = callerName;
|
||||
_callerUUID = callerUUID;
|
||||
_callerGroups = callerGroups;
|
||||
_sourceServer = sourceServer;
|
||||
_parts = parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player that executed this global command.
|
||||
* This player will be NULL when called on the servers that aren't _sourceServer
|
||||
*/
|
||||
public Player getCaller()
|
||||
{
|
||||
return _caller;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player name of the player that called the command
|
||||
*/
|
||||
public String getCallerName()
|
||||
{
|
||||
return _callerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The UUID of the player that called the command
|
||||
*/
|
||||
public UUID getCallerUUID()
|
||||
{
|
||||
return _callerUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rank of the player that called this global command
|
||||
*/
|
||||
public List<String> getCallerGroups()
|
||||
{
|
||||
return _callerGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* The server name that this global command came from
|
||||
*/
|
||||
public String getSourceServer()
|
||||
{
|
||||
return _sourceServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unprocessed parts of this command
|
||||
*/
|
||||
public String[] getParts()
|
||||
{
|
||||
return _parts;
|
||||
}
|
||||
|
||||
// Bukkit event stuff
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
public static HandlerList getHandlerList() { return handlers; }
|
||||
public HandlerList getHandlers() { return handlers; }
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package mineplex.core.globalpacket.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.globalpacket.GlobalPacketManager;
|
||||
import mineplex.core.globalpacket.event.GlobalPacketEvent;
|
||||
|
||||
public class GlobalGiveCoins implements Listener
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
public GlobalGiveCoins(DonationManager donationManager, CoreClientManager coreClientManager)
|
||||
{
|
||||
_donationManager = donationManager;
|
||||
_clientManager = coreClientManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveCoins(final GlobalPacketEvent e)
|
||||
{
|
||||
boolean allowed = false;
|
||||
for (String id : e.getCallerGroups())
|
||||
{
|
||||
if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND))
|
||||
{
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getParts() == null || e.getParts().length < 1)
|
||||
return;
|
||||
|
||||
if (!e.getParts()[0].equalsIgnoreCase("givecoins"))
|
||||
return;
|
||||
|
||||
if (e.getParts().length != 2)
|
||||
{
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givecoins <amount>"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = 1;
|
||||
try
|
||||
{
|
||||
amount = Integer.parseInt(e.getParts()[1]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// No number
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final int fAmount = amount;
|
||||
for (final Player p : UtilServer.getPlayers())
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, p, "Global Coins", amount, response ->
|
||||
{
|
||||
if (response)
|
||||
{
|
||||
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Coins") + "."));
|
||||
UtilTextMiddle.display(C.cYellow + fAmount + " Coins", C.cGold + "received from " + e.getCallerName() + "!", p);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package mineplex.core.globalpacket.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.globalpacket.GlobalPacketManager;
|
||||
import mineplex.core.globalpacket.event.GlobalPacketEvent;
|
||||
|
||||
public class GlobalGiveGems implements Listener
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
|
||||
public GlobalGiveGems(DonationManager donationManager)
|
||||
{
|
||||
_donationManager = donationManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveGems(final GlobalPacketEvent e)
|
||||
{
|
||||
boolean allowed = false;
|
||||
for (String id : e.getCallerGroups())
|
||||
{
|
||||
if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND))
|
||||
{
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getParts() == null || e.getParts().length < 1)
|
||||
return;
|
||||
|
||||
if (!e.getParts()[0].equalsIgnoreCase("givegems"))
|
||||
return;
|
||||
|
||||
if (e.getParts().length != 2)
|
||||
{
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givegems <amount>"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = 1;
|
||||
try
|
||||
{
|
||||
amount = Integer.parseInt(e.getParts()[1]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// No number
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final int fAmount = amount;
|
||||
for (final Player p : UtilServer.getPlayers())
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.GEM, p, "Global Gems", amount, success ->
|
||||
{
|
||||
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Gems") + "."));
|
||||
UtilTextMiddle.display(C.cYellow + fAmount + " Gems", C.cGold + "received from " + e.getCallerName() + "!", p);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
package mineplex.core.globalpacket.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.globalpacket.GlobalPacketManager;
|
||||
import mineplex.core.globalpacket.event.GlobalPacketEvent;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardType;
|
||||
|
||||
public class GlobalGiveItem implements Listener
|
||||
{
|
||||
private InventoryManager _inventoryManager;
|
||||
private RewardManager _rewardManager;
|
||||
|
||||
public GlobalGiveItem(InventoryManager inventoryManager, RewardManager rewardManager)
|
||||
{
|
||||
_inventoryManager = inventoryManager;
|
||||
_rewardManager = rewardManager;
|
||||
}
|
||||
|
||||
public enum GlobalItem
|
||||
{
|
||||
OLD_CHEST("Old Chest"),
|
||||
ANCIENT_CHEST("Ancient Chest"),
|
||||
MYTHICAL_CHEST("Mythical Chest"),
|
||||
|
||||
GAME_LOOT("Game Loot");
|
||||
|
||||
private String _invName;
|
||||
|
||||
GlobalItem(String invName)
|
||||
{
|
||||
_invName = invName;
|
||||
}
|
||||
|
||||
public String getInvName()
|
||||
{
|
||||
return _invName;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveItem(final GlobalPacketEvent e)
|
||||
{
|
||||
boolean allowed = false;
|
||||
for (String id : e.getCallerGroups())
|
||||
{
|
||||
if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND))
|
||||
{
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getParts() == null || e.getParts().length < 1)
|
||||
return;
|
||||
|
||||
if (!e.getParts()[0].equalsIgnoreCase("giveitem"))
|
||||
return;
|
||||
|
||||
if (e.getParts().length != 3)
|
||||
{
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "/global giveitem <item> <amount>"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalItem item = null;
|
||||
|
||||
try
|
||||
{
|
||||
item = GlobalItem.valueOf(e.getParts()[1]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Wrong item
|
||||
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "That GlobalItem type can't be found. Types:"));
|
||||
|
||||
String list = "";
|
||||
for (GlobalItem i : GlobalItem.values())
|
||||
{
|
||||
list += i.toString() + " ";
|
||||
}
|
||||
|
||||
UtilPlayer.message(e.getCaller(), C.cYellow + list);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = 1; // Default, shouldn't happen anyway.
|
||||
|
||||
try
|
||||
{
|
||||
amount = Integer.parseInt(e.getParts()[2]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Not a number
|
||||
|
||||
if (e.getCaller() != null)
|
||||
{
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(e.getParts()[2]) + "] is not a valid number."));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.toString().contains("CHEST"))
|
||||
{
|
||||
for (final Player p : UtilServer.getPlayers())
|
||||
{
|
||||
final int fAmount = amount;
|
||||
final GlobalItem fItem = item;
|
||||
_inventoryManager.addItemToInventory(data ->
|
||||
{
|
||||
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " " + fItem.getInvName() + "(s)") + " from " + F.name(e.getCallerName()) + "."));
|
||||
UtilTextMiddle.display(C.cYellow + fAmount + " " + fItem.getInvName() + "(s)", C.cGold + "received from " + e.getCallerName() + "!", p);
|
||||
}, p, item.getInvName(), amount);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (item.toString().equalsIgnoreCase("GAME_LOOT"))
|
||||
{
|
||||
for (final Player p : UtilServer.getPlayers())
|
||||
{
|
||||
Reward reward = _rewardManager.nextReward(p, null, false, RewardType.GAME_LOOT, true);
|
||||
reward.giveReward(RewardType.GAME_LOOT, p, data ->
|
||||
{
|
||||
UtilPlayer.message(p, F.main("Global", "You received " + F.elem("Game Loot") + " from " + F.name(e.getCallerName()) + "."));
|
||||
UtilPlayer.message(p, F.main("Global", "You won " + F.elem(data.getFriendlyName()) + "!"));
|
||||
UtilTextMiddle.display(C.cYellow + data.getFriendlyName(), C.cGold + "received from " + e.getCallerName() + "!", p);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package mineplex.core.globalpacket.redis;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.globalpacket.event.GlobalPacketEvent;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class GlobalPacketHandler implements CommandCallback
|
||||
{
|
||||
private ServerStatusManager _serverStatus;
|
||||
|
||||
public GlobalPacketHandler(ServerStatusManager serverStatus)
|
||||
{
|
||||
_serverStatus = serverStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
if (command instanceof GlobalPacketMessage)
|
||||
{
|
||||
GlobalPacketMessage packetMessage = ((GlobalPacketMessage) command);
|
||||
|
||||
Player caller = null;
|
||||
if (packetMessage.getSourceServer() != null && packetMessage.getSourceServer().equals(_serverStatus.getCurrentServerName()))
|
||||
{
|
||||
caller = UtilPlayer.searchExact(packetMessage.getCallerUUID());
|
||||
}
|
||||
|
||||
GlobalPacketEvent event = new GlobalPacketEvent(caller, packetMessage.getCallerName(), packetMessage.getCallerUUID(),
|
||||
packetMessage.getCallerGroups(), packetMessage.getSourceServer(), packetMessage.getParts());
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package mineplex.core.globalpacket.redis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class GlobalPacketMessage extends ServerCommand
|
||||
{
|
||||
private String _callerName;
|
||||
private UUID _callerUUID;
|
||||
private List<String> _callerGroups;
|
||||
private String _sourceServer;
|
||||
private String[] _parts;
|
||||
|
||||
public GlobalPacketMessage(String callerName, UUID callerUUID, List<String> callerGroups, String sourceServer, String[] parts)
|
||||
{
|
||||
_callerName = callerName;
|
||||
_callerUUID = callerUUID;
|
||||
_callerGroups = callerGroups;
|
||||
_sourceServer = sourceServer;
|
||||
_parts = parts;
|
||||
}
|
||||
|
||||
public String getCallerName()
|
||||
{
|
||||
return _callerName;
|
||||
}
|
||||
|
||||
public UUID getCallerUUID()
|
||||
{
|
||||
return _callerUUID;
|
||||
}
|
||||
|
||||
public List<String> getCallerGroups()
|
||||
{
|
||||
return _callerGroups;
|
||||
}
|
||||
|
||||
public String getSourceServer()
|
||||
{
|
||||
return _sourceServer;
|
||||
}
|
||||
|
||||
public String[] getParts()
|
||||
{
|
||||
return _parts;
|
||||
}
|
||||
}
|
@ -366,7 +366,7 @@ public class Hologram {
|
||||
if (_hideBoundingBox)
|
||||
{
|
||||
DataWatcher watcher = packet.l;
|
||||
packet.d = (int) ((getLocation().getY() + ((double) textRow * 0.285)) * 32);
|
||||
packet.d = (int) ((getLocation().getY() + ((double) textRow * 0.31)) * 32);
|
||||
watcher.a(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16);
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ public class Hologram {
|
||||
packet.a = entityId;
|
||||
packet.b = 30;
|
||||
packet.c = (int) (getLocation().getX() * 32);
|
||||
packet.d = (int) ((getLocation().getY() - 2.1 + ((double) textRow * 0.285)) * 32);
|
||||
packet.d = (int) ((getLocation().getY() - 2.1 + ((double) textRow * 0.31)) * 32);
|
||||
packet.e = (int) (getLocation().getZ() * 32);
|
||||
packet.l = watcher;
|
||||
packet.uuid = UUID.randomUUID();
|
||||
@ -537,7 +537,7 @@ public class Hologram {
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
|
||||
teleportPacket.a = entityId;
|
||||
teleportPacket.b = x;
|
||||
teleportPacket.c = (int) Math.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.285)) * 32);
|
||||
teleportPacket.c = (int) Math.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.31)) * 32);
|
||||
teleportPacket.d = z;
|
||||
|
||||
packets1_9[i] = teleportPacket;
|
||||
|
@ -1,12 +1,15 @@
|
||||
package mineplex.core.imagemap;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.imagemap.objects.PlayerMapBoard;
|
||||
import mineplex.core.imagemap.objects.PlayerMapImage;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -18,15 +21,14 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.imagemap.objects.MapImage;
|
||||
import mineplex.core.imagemap.objects.PlayerMapBoard;
|
||||
import mineplex.core.imagemap.objects.PlayerMapImage;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class ImageMapManager extends MiniPlugin
|
||||
@ -60,7 +62,13 @@ public class ImageMapManager extends MiniPlugin
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
runSyncLater(() -> _boards.forEach(board -> board.onPlayerJoin(player)), 40);
|
||||
runSyncLater(() -> _boards.forEach(board ->
|
||||
{
|
||||
if (board.isHandleJoin())
|
||||
{
|
||||
board.onPlayerJoin(player);
|
||||
}
|
||||
}), 40);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -82,7 +90,39 @@ public class ImageMapManager extends MiniPlugin
|
||||
_boards.forEach(PlayerMapBoard::onRefresh);
|
||||
}
|
||||
|
||||
public MapImage createBoard(Location topLeft, BlockFace direction, int width, int height, String image)
|
||||
{
|
||||
BufferedImage bufferedImage = getImage(new File(IMAGE_DIR + File.separator + image));
|
||||
return createBoard(topLeft, direction, width, height, bufferedImage);
|
||||
}
|
||||
|
||||
public MapImage createBoard(Location topLeft, BlockFace direction, int width, int height, File image)
|
||||
{
|
||||
BufferedImage bufferedImage = getImage(image);
|
||||
return createBoard(topLeft, direction, width, height, bufferedImage);
|
||||
}
|
||||
|
||||
public MapImage createBoard(Location topLeft, BlockFace direction, int width, int height, URL image)
|
||||
{
|
||||
BufferedImage bufferedImage = getImage(image);
|
||||
return createBoard(topLeft, direction, width, height, bufferedImage);
|
||||
}
|
||||
|
||||
public MapImage createBoard(Location topLeft, BlockFace direction, int width, int height, BufferedImage image)
|
||||
{
|
||||
List<ItemFrame> itemFrames = createItemFrames(topLeft, direction, width, height);
|
||||
MapImage mapImage = new MapImage(image, itemFrames, width, height);
|
||||
mapImage.create();
|
||||
|
||||
return mapImage;
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, String... images)
|
||||
{
|
||||
return createPlayerBoard(topLeft, direction, width, height, true, images);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, boolean handleJoin, String... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
@ -91,22 +131,15 @@ public class ImageMapManager extends MiniPlugin
|
||||
bufferedImages[i] = getImage(new File(IMAGE_DIR + File.separator + images[i]));
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, bufferedImages);
|
||||
return createPlayerBoard(topLeft, direction, width, height, handleJoin, bufferedImages);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, File... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
for (int i = 0; i < images.length; i++)
|
||||
{
|
||||
bufferedImages[i] = getImage(images[i]);
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, bufferedImages);
|
||||
return createPlayerBoard(topLeft, direction, width, height, true, images);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, URL... images)
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, boolean handleJoin, File... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
@ -115,10 +148,27 @@ public class ImageMapManager extends MiniPlugin
|
||||
bufferedImages[i] = getImage(images[i]);
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, bufferedImages);
|
||||
return createPlayerBoard(topLeft, direction, width, height, handleJoin, bufferedImages);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, BufferedImage... images)
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, URL... images)
|
||||
{
|
||||
return createPlayerBoard(topLeft, direction, width, height, true, images);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, boolean handleJoin, URL... images)
|
||||
{
|
||||
BufferedImage[] bufferedImages = new BufferedImage[images.length];
|
||||
|
||||
for (int i = 0; i < images.length; i++)
|
||||
{
|
||||
bufferedImages[i] = getImage(images[i]);
|
||||
}
|
||||
|
||||
return createPlayerBoard(topLeft, direction, width, height, handleJoin, bufferedImages);
|
||||
}
|
||||
|
||||
public PlayerMapBoard createPlayerBoard(Location topLeft, BlockFace direction, int width, int height, boolean handleJoin, BufferedImage... images)
|
||||
{
|
||||
List<ItemFrame> itemFrames = createItemFrames(topLeft, direction, width, height);
|
||||
List<PlayerMapImage> mapImageList = new ArrayList<>();
|
||||
@ -131,9 +181,12 @@ public class ImageMapManager extends MiniPlugin
|
||||
mapImageList.add(mapImage);
|
||||
}
|
||||
|
||||
PlayerMapBoard board = new PlayerMapBoard(topLeft, mapImageList);
|
||||
PlayerMapBoard board = new PlayerMapBoard(topLeft, mapImageList, handleJoin);
|
||||
|
||||
runSyncLater(() -> Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin), 50);
|
||||
if (handleJoin)
|
||||
{
|
||||
runSyncLater(() -> Bukkit.getOnlinePlayers().forEach(board::onPlayerJoin), 50);
|
||||
}
|
||||
|
||||
_boards.add(board);
|
||||
return board;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package mineplex.core.imagemap.objects;
|
||||
|
||||
import mineplex.core.imagemap.ImageMapRenderer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -8,20 +11,21 @@ import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import mineplex.core.imagemap.ImageMapRenderer;
|
||||
|
||||
public class MapImage
|
||||
{
|
||||
|
||||
protected final BufferedImage _image;
|
||||
private final BufferedImage _image;
|
||||
protected final List<ItemFrame> _itemFrames;
|
||||
protected final List<MapView> _mapViews;
|
||||
protected final int _width, _height;
|
||||
|
||||
public MapImage(BufferedImage image, List<ItemFrame> itemFrames, int width, int height)
|
||||
{
|
||||
_image = image;
|
||||
_itemFrames = itemFrames;
|
||||
_mapViews = new ArrayList<>(itemFrames.size());
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
@ -50,6 +54,7 @@ public class MapImage
|
||||
|
||||
map.addRenderer(new ImageMapRenderer(_image, x, y));
|
||||
item.setDurability(map.getId());
|
||||
_mapViews.add(map);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -18,12 +18,14 @@ public class PlayerMapBoard
|
||||
private final Location _location;
|
||||
private final List<PlayerMapImage> _images;
|
||||
private final Map<Player, Integer> _viewers;
|
||||
private final boolean _handleJoin;
|
||||
|
||||
public PlayerMapBoard(Location location, List<PlayerMapImage> images)
|
||||
public PlayerMapBoard(Location location, List<PlayerMapImage> images, boolean handleJoin)
|
||||
{
|
||||
_location = location;
|
||||
_images = images;
|
||||
_viewers = new HashMap<>();
|
||||
_handleJoin = handleJoin;
|
||||
}
|
||||
|
||||
public void goTo(Player player, boolean next)
|
||||
@ -45,8 +47,13 @@ public class PlayerMapBoard
|
||||
}
|
||||
|
||||
int newIndex = next ? index + 1 : index - 1;
|
||||
_viewers.put(player, newIndex);
|
||||
_images.get(newIndex).addViewer(player, true);
|
||||
goTo(player, newIndex);
|
||||
}
|
||||
|
||||
public void goTo(Player player, int index)
|
||||
{
|
||||
_viewers.put(player, index);
|
||||
_images.get(index).addViewer(player, true);
|
||||
}
|
||||
|
||||
public void onPlayerJoin(Player player)
|
||||
@ -87,4 +94,8 @@ public class PlayerMapBoard
|
||||
return _location;
|
||||
}
|
||||
|
||||
public boolean isHandleJoin()
|
||||
{
|
||||
return _handleJoin;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package mineplex.core.imagemap.objects;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.imagemap.CustomItemFrames;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mineplex.core.imagemap.CustomItemFrames;
|
||||
|
||||
public class PlayerMapImage extends MapImage
|
||||
{
|
||||
@ -48,14 +48,16 @@ public class PlayerMapImage extends MapImage
|
||||
{
|
||||
if (sendMap)
|
||||
{
|
||||
//FIXME
|
||||
int slot = 8;
|
||||
for (ItemStack itemStack : _itemMaps)
|
||||
{
|
||||
player.getInventory().setItem(slot++, itemStack);
|
||||
}
|
||||
// //FIXME
|
||||
// int slot = 8;
|
||||
// for (ItemStack itemStack : _itemMaps)
|
||||
// {
|
||||
// player.getInventory().setItem(slot++, itemStack);
|
||||
// }
|
||||
//
|
||||
// UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5);
|
||||
|
||||
UtilServer.runSyncLater(() -> player.getInventory().removeItem(_itemMaps.toArray(new ItemStack[0])), 5);
|
||||
_mapViews.forEach(player::sendMap);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _itemMaps.size(); i++)
|
||||
|
171
Plugins/Mineplex.Core/src/mineplex/core/newnpc/NPC.java
Normal file
171
Plugins/Mineplex.Core/src/mineplex/core/newnpc/NPC.java
Normal file
@ -0,0 +1,171 @@
|
||||
package mineplex.core.newnpc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.utils.UtilVariant;
|
||||
import mineplex.serverdata.database.column.Column;
|
||||
import mineplex.serverdata.database.column.ColumnByte;
|
||||
import mineplex.serverdata.database.column.ColumnDouble;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class NPC
|
||||
{
|
||||
|
||||
private final HologramManager HOLOGRAM_MANAGER = Managers.require(HologramManager.class);
|
||||
|
||||
private int _id;
|
||||
protected EntityType _entityType;
|
||||
protected String _name;
|
||||
protected Location _spawn;
|
||||
private Material _inHand;
|
||||
private byte _inHandData;
|
||||
private Material _helmet;
|
||||
private Material _chestplate;
|
||||
private Material _leggings;
|
||||
private Material _boots;
|
||||
private String _metadata;
|
||||
|
||||
private LivingEntity _entity;
|
||||
private Hologram _nameTag;
|
||||
|
||||
public NPC(int id, EntityType entityType, String name, Location spawn, Material inHand, byte inHandData, Material helmet, Material chestplate, Material leggings, Material boots, String metadata)
|
||||
{
|
||||
_id = id;
|
||||
_entityType = entityType;
|
||||
_name = name;
|
||||
_spawn = spawn;
|
||||
_inHand = inHand;
|
||||
_inHandData = inHandData;
|
||||
_helmet = helmet;
|
||||
_chestplate = chestplate;
|
||||
_leggings = leggings;
|
||||
_boots = boots;
|
||||
_metadata = metadata;
|
||||
}
|
||||
|
||||
public LivingEntity spawnEntity()
|
||||
{
|
||||
_spawn.getChunk().load(true);
|
||||
LivingEntity entity;
|
||||
|
||||
//TODO remove this terrible hack
|
||||
if (_name.contains("Halloween"))
|
||||
{
|
||||
entity = UtilVariant.spawnWitherSkeleton(_spawn);
|
||||
}
|
||||
else
|
||||
{
|
||||
entity = (LivingEntity) _spawn.getWorld().spawnEntity(_spawn, _entityType);
|
||||
}
|
||||
|
||||
boolean nullName = _name.equals("NULL");
|
||||
|
||||
entity.setCanPickupItems(false);
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
entity.setCustomName(nullName ? null : ChatColor.translateAlternateColorCodes('&', _name));
|
||||
entity.setCustomNameVisible(!nullName);
|
||||
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
|
||||
if (_inHand != null)
|
||||
{
|
||||
equipment.setItemInHand(ItemStackFactory.Instance.CreateStack(_inHand, _inHandData));
|
||||
}
|
||||
if (_helmet != null)
|
||||
{
|
||||
equipment.setHelmet(ItemStackFactory.Instance.CreateStack(_helmet));
|
||||
}
|
||||
if (_chestplate != null)
|
||||
{
|
||||
equipment.setChestplate(ItemStackFactory.Instance.CreateStack(_chestplate));
|
||||
}
|
||||
if (_leggings != null)
|
||||
{
|
||||
equipment.setLeggings(ItemStackFactory.Instance.CreateStack(_leggings));
|
||||
}
|
||||
if (_boots != null)
|
||||
{
|
||||
equipment.setBoots(ItemStackFactory.Instance.CreateStack(_boots));
|
||||
}
|
||||
|
||||
UtilEnt.vegetate(entity);
|
||||
UtilEnt.setFakeHead(entity, true);
|
||||
UtilEnt.CreatureLook(entity, _spawn.getPitch(), _spawn.getYaw());
|
||||
UtilEnt.ghost(entity, true, false);
|
||||
UtilEnt.silence(entity, true);
|
||||
|
||||
_entity = entity;
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Hologram getNameTag()
|
||||
{
|
||||
if (_nameTag == null)
|
||||
{
|
||||
_nameTag = new Hologram(HOLOGRAM_MANAGER, _entity.getLocation().add(0, UtilEnt.getHeight(_entity), 0), true, _entity.getCustomName())
|
||||
.start();
|
||||
|
||||
_entity.setCustomNameVisible(false);
|
||||
_entity.setCustomName(null);
|
||||
}
|
||||
|
||||
return _nameTag;
|
||||
}
|
||||
|
||||
void setId(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getMetadata()
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
public LivingEntity getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
|
||||
public List<Column<?>> toDatabaseQuery()
|
||||
{
|
||||
return Arrays.asList(
|
||||
new ColumnVarChar("entity_type", 32, _entityType.name()),
|
||||
new ColumnVarChar("name", 32, _name),
|
||||
new ColumnVarChar("world", 32, _spawn.getWorld().getName()),
|
||||
new ColumnDouble("x", _spawn.getBlockX() + 0.5),
|
||||
new ColumnDouble("y", _spawn.getY()),
|
||||
new ColumnDouble("z", _spawn.getBlockZ() + 0.5),
|
||||
new ColumnInt("yaw", (int) _spawn.getYaw()),
|
||||
new ColumnInt("pitch", (int) _spawn.getPitch()),
|
||||
new ColumnVarChar("in_hand", 32, _inHand == null ? "NULL" : _inHand.name()),
|
||||
new ColumnByte("in_hand_data", _inHandData),
|
||||
new ColumnVarChar("helmet", 32, _helmet == null ? "NULL" : _helmet.name()),
|
||||
new ColumnVarChar("chestplate", 32, _chestplate == null ? "NULL" : _chestplate.name()),
|
||||
new ColumnVarChar("leggings", 32, _leggings == null ? "NULL" : _leggings.name()),
|
||||
new ColumnVarChar("boots", 32, _boots == null ? "NULL" : _boots.name()),
|
||||
new ColumnVarChar("metadata", 32, _metadata),
|
||||
new ColumnVarChar("skinValue", 400, "NULL"),
|
||||
new ColumnVarChar("skinSignature", 700, "NULL")
|
||||
);
|
||||
}
|
||||
}
|
115
Plugins/Mineplex.Core/src/mineplex/core/newnpc/NPCBuilder.java
Normal file
115
Plugins/Mineplex.Core/src/mineplex/core/newnpc/NPCBuilder.java
Normal file
@ -0,0 +1,115 @@
|
||||
package mineplex.core.newnpc;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.utils.UtilGameProfile;
|
||||
|
||||
public class NPCBuilder
|
||||
{
|
||||
|
||||
private EntityType _type;
|
||||
private String _name;
|
||||
private String _metadata;
|
||||
private boolean _useSkin;
|
||||
|
||||
public void build(Player player, NewNPCManager manager)
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
Material inHand = inventory.getItemInHand() == null ? null : inventory.getItemInHand().getType();
|
||||
byte inHandData = inventory.getItemInHand() == null ? 0 : inventory.getItemInHand().getData().getData();
|
||||
Material helmet = inventory.getHelmet() == null ? null : inventory.getHelmet().getType();
|
||||
Material chestplate = inventory.getChestplate() == null ? null : inventory.getChestplate().getType();
|
||||
Material leggings = inventory.getLeggings() == null ? null : inventory.getLeggings().getType();
|
||||
Material boots = inventory.getBoots() == null ? null : inventory.getBoots().getType();
|
||||
|
||||
NPC npc;
|
||||
|
||||
if (_type == EntityType.PLAYER)
|
||||
{
|
||||
SkinData data;
|
||||
|
||||
if (_useSkin)
|
||||
{
|
||||
data = SkinData.constructFromGameProfile(UtilGameProfile.getGameProfile(player), true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = SkinData.STEVE;
|
||||
}
|
||||
|
||||
npc = new PlayerNPC(
|
||||
-1,
|
||||
_name,
|
||||
location,
|
||||
inHand,
|
||||
inHandData,
|
||||
helmet,
|
||||
chestplate,
|
||||
leggings,
|
||||
boots,
|
||||
_metadata,
|
||||
data.getProperty().getValue(),
|
||||
data.getProperty().getSignature()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc = new NPC(
|
||||
-1,
|
||||
_type,
|
||||
_name,
|
||||
location,
|
||||
inHand,
|
||||
inHandData,
|
||||
helmet,
|
||||
chestplate,
|
||||
leggings,
|
||||
boots,
|
||||
_metadata
|
||||
);
|
||||
}
|
||||
|
||||
manager.addNPC(npc);
|
||||
}
|
||||
|
||||
public void setType(EntityType type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public EntityType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void setMetadata(String metadata)
|
||||
{
|
||||
_metadata = metadata;
|
||||
}
|
||||
|
||||
public String getMetadata()
|
||||
{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
public void setUseSkin(boolean useSkin)
|
||||
{
|
||||
_useSkin = useSkin;
|
||||
}
|
||||
}
|
@ -0,0 +1,510 @@
|
||||
package mineplex.core.newnpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
|
||||
import mineplex.core.newnpc.command.NPCCommand;
|
||||
import mineplex.core.newnpc.command.NPCDeleteCommand;
|
||||
import mineplex.core.newnpc.command.NPCMoveCommand;
|
||||
import mineplex.core.newnpc.event.NPCInteractEvent;
|
||||
import mineplex.core.newnpc.event.NPCRefreshEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
/**
|
||||
* NPCManager is a new version of the previous NpcManager to improve usability and more general purpose.
|
||||
* <br>
|
||||
* NPCs are saved in the table <b>newNPCs</b> in the <b>accounts</b> database.
|
||||
* <br>
|
||||
* Details on how to create NPCs can be found in the {@link NPC} and {@link PlayerNPC} classes.
|
||||
*/
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class NewNPCManager extends MiniPlugin
|
||||
{
|
||||
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
NPC_COMMAND,
|
||||
BUILD_NPC_COMMAND,
|
||||
CLEAR_NPC_COMMAND,
|
||||
DELETE_NPC_COMMAND,
|
||||
REFRESH_NPC_COMMAND,
|
||||
MOVE_NPC_COMMAND
|
||||
}
|
||||
|
||||
private final Creature _creature;
|
||||
|
||||
private final NewNPCRepository _repository;
|
||||
|
||||
private final List<NPC> _npcs;
|
||||
private final Map<Player, NPCBuilder> _builders;
|
||||
private final Map<Player, Location> _teleportMap;
|
||||
|
||||
private NewNPCManager()
|
||||
{
|
||||
super("NPC");
|
||||
|
||||
_creature = require(Creature.class);
|
||||
_repository = new NewNPCRepository();
|
||||
_npcs = new ArrayList<>();
|
||||
_builders = new HashMap<>();
|
||||
_teleportMap = new HashMap<>();
|
||||
|
||||
// Loading NPCs on the main thread makes sure that _npcs is populated before anything tries to spawn NPCs.
|
||||
loadNPCs();
|
||||
// Any NPC with the metadata DUMMY will always be spawned regardless, useful for testing designs
|
||||
spawnNPCs("DUMMY", npc ->
|
||||
{
|
||||
if (npc instanceof PlayerNPC)
|
||||
{
|
||||
npc.getNameTag();
|
||||
}
|
||||
});
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionGroup.ADMIN.setPermission(Perm.NPC_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.BUILD_NPC_COMMAND, true, true);
|
||||
PermissionGroup.DEV.setPermission(Perm.CLEAR_NPC_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.DELETE_NPC_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.REFRESH_NPC_COMMAND, true, true);
|
||||
PermissionGroup.ADMIN.setPermission(Perm.MOVE_NPC_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new NPCCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads synchronously all NPCs from the database and populates the {@link #_npcs} list if the npc was not already
|
||||
* contained within the collection. Thus this method can be called more than once during runtime. Though it is
|
||||
* recommended that if the caller is not calling this during startup then this should not be called from the main
|
||||
* thread.
|
||||
*/
|
||||
private void loadNPCs()
|
||||
{
|
||||
_repository.getNPCs(npcs ->
|
||||
{
|
||||
npcs.forEach(npc ->
|
||||
{
|
||||
if (_npcs.contains(npc))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_npcs.add(npc);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns all NPCs that have the metadata specified.
|
||||
*
|
||||
* @param metadata The metadata that must equal the NPC's metadata.
|
||||
* @param after A callback consumer for each npc.
|
||||
*/
|
||||
public void spawnNPCs(String metadata, Consumer<NPC> after)
|
||||
{
|
||||
_creature.SetForce(true);
|
||||
|
||||
List<NPC> npcs = getUnloadedNPCs(metadata);
|
||||
|
||||
npcs.forEach(npc ->
|
||||
{
|
||||
npc.spawnEntity();
|
||||
|
||||
if (after != null)
|
||||
{
|
||||
after.accept(npc);
|
||||
}
|
||||
});
|
||||
|
||||
_creature.SetForce(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #loadNPCs()} then the {@link NPCRefreshEvent}
|
||||
*/
|
||||
public void refreshNPCS()
|
||||
{
|
||||
loadNPCs();
|
||||
|
||||
UtilServer.CallEvent(new NPCRefreshEvent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an NPC's entity and removes it from the database.
|
||||
*
|
||||
* @param npc The NPC you want to delete.
|
||||
*/
|
||||
public void deleteNPC(NPC npc)
|
||||
{
|
||||
runAsync(() -> _repository.deleteNPC(npc));
|
||||
|
||||
if (npc.getEntity() != null)
|
||||
{
|
||||
npc.getEntity().remove();
|
||||
}
|
||||
|
||||
_npcs.remove(npc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes every NPC.
|
||||
*
|
||||
* @param deleteFromDB If true, all NPC's are deleted from the database. If false this action is only temporary.
|
||||
*/
|
||||
public void clearNPCS(boolean deleteFromDB)
|
||||
{
|
||||
if (deleteFromDB)
|
||||
{
|
||||
runAsync(_repository::clearNPCs);
|
||||
}
|
||||
|
||||
_npcs.forEach(npc ->
|
||||
{
|
||||
if (npc.getEntity() != null)
|
||||
{
|
||||
npc.getEntity().remove();
|
||||
}
|
||||
});
|
||||
|
||||
_npcs.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param npc The NPC you want to spawn.
|
||||
* @see #addNPC(NPC, boolean)
|
||||
*/
|
||||
public void addNPC(NPC npc)
|
||||
{
|
||||
addNPC(npc, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds and spawns an NPC.
|
||||
*
|
||||
* @param npc The NPC you want to spawn.
|
||||
* @param saveToDB If true the NPC will be saved to the database.
|
||||
*/
|
||||
public void addNPC(NPC npc, boolean saveToDB)
|
||||
{
|
||||
_creature.SetForce(true);
|
||||
|
||||
_npcs.add(npc);
|
||||
npc.spawnEntity();
|
||||
|
||||
if (saveToDB)
|
||||
{
|
||||
runAsync(() -> _repository.insertNPCIfNotExists(npc));
|
||||
}
|
||||
|
||||
_creature.SetForce(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by {@link NPCMoveCommand}. Has no other purpose.
|
||||
*/
|
||||
public void setPlayerTeleport(Player player)
|
||||
{
|
||||
_teleportMap.put(player, player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports an NPC to a location and saves that in the database for future reference.
|
||||
*
|
||||
* @param npc The NPC you want to move.
|
||||
* @param location The Location you want to move the NPC to.
|
||||
*/
|
||||
public void teleport(NPC npc, Location location)
|
||||
{
|
||||
// If there isn't an entity or the location to go is null, then don't teleport.
|
||||
if (npc.getEntity() == null || location == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
npc.getEntity().teleport(location);
|
||||
runAsync(() -> _repository.teleportNPC(npc, location));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by {@link mineplex.core.newnpc.command.NPCBuildCommand}. Has no other purpose.
|
||||
*/
|
||||
public void createBuilder(Player player)
|
||||
{
|
||||
_builders.put(player, new NPCBuilder());
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "Hello " + F.name(player.getName()) + "! It seems you would like to create a new NPC. Hold or wear any items that you want your NPC to have."));
|
||||
player.sendMessage(F.main("Step 1", "Type in chat the Entity Type of your NPC."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up NPC creation maps, if the player quits.
|
||||
*/
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
_builders.remove(player);
|
||||
_teleportMap.remove(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles {@link NPCBuilder} data input.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void chat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
NPCBuilder builder = _builders.get(player);
|
||||
|
||||
if (builder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (builder.getType() == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
builder.setType(EntityType.valueOf(event.getMessage().toUpperCase()));
|
||||
player.sendMessage(F.main(_moduleName, "Set the entity type to " + F.name(builder.getType().toString()) + "!"));
|
||||
|
||||
player.sendMessage(F.main("Step 2", "Now type in chat the name of your NPC. Using " + F.elem("&") + " as colour codes"));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "That isn't a valid entity type"));
|
||||
player.sendMessage(F.main(_moduleName, "Valid Entity Types: " + UtilText.listToString(Arrays.asList(EntityType.values()), true)));
|
||||
}
|
||||
}
|
||||
else if (builder.getName() == null)
|
||||
{
|
||||
if (event.getMessage().length() > 32)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "The maximum length for NPC name's is 32 characters."));
|
||||
return;
|
||||
}
|
||||
|
||||
builder.setName(event.getMessage());
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "Set the name to " + F.name(ChatColor.translateAlternateColorCodes('&', builder.getName())) + "!"));
|
||||
|
||||
player.sendMessage(F.main("Step 3", "Now type in chat the metadata of your NPC. If you don't want to set any metadata, type " + F.elem("null") + "."));
|
||||
}
|
||||
else if (builder.getMetadata() == null)
|
||||
{
|
||||
String uppercase = event.getMessage().toUpperCase();
|
||||
|
||||
if (uppercase.equals("NULL"))
|
||||
{
|
||||
event.setMessage(uppercase);
|
||||
}
|
||||
|
||||
builder.setMetadata(event.getMessage());
|
||||
|
||||
if (builder.getType() == EntityType.PLAYER)
|
||||
{
|
||||
player.sendMessage(F.main("Step 4", "Now type in chat " + F.elem("Yes") + " if you would like your NPC to use your Minecraft Skin. If not, then say anything else"));
|
||||
}
|
||||
else
|
||||
{
|
||||
buildNPC(player, builder);
|
||||
}
|
||||
}
|
||||
else if (builder.getType() == EntityType.PLAYER)
|
||||
{
|
||||
if (event.getMessage().toUpperCase().equals("YES"))
|
||||
{
|
||||
builder.setUseSkin(true);
|
||||
player.sendMessage(F.main(_moduleName, "Set your NPC to use your Minecraft Skin!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "Set your NPC to not use your Minecraft Skin. You (or someone else) can always change it in the database."));
|
||||
}
|
||||
|
||||
buildNPC(player, builder);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildNPC(Player player, NPCBuilder builder)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "Creating your NPC..."));
|
||||
runSync(() -> builder.build(player, this));
|
||||
player.sendMessage(F.main(_moduleName, "Created your NPC!"));
|
||||
_builders.remove(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles {@link NPCDeleteCommand} and {@link NPCMoveCommand} data input.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void npcInteract(NPCInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
NPC npc = event.getNpc();
|
||||
|
||||
if (!Recharge.Instance.usable(player, NPCDeleteCommand.RECHARGE_KEY))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
deleteNPC(npc);
|
||||
player.sendMessage(F.main(_moduleName, "Deleted " + F.name(npc.getEntity().getCustomName()) + " (" + F.elem(npc.getId()) + ")."));
|
||||
Recharge.Instance.recharge(player, NPCDeleteCommand.RECHARGE_KEY);
|
||||
}
|
||||
else if (!Recharge.Instance.usable(player, NPCMoveCommand.RECHARGE_KEY))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
teleport(npc, _teleportMap.remove(player));
|
||||
player.sendMessage(F.main(_moduleName, "Moved " + F.name(npc.getEntity().getCustomName()) + " (" + F.elem(npc.getId()) + ")."));
|
||||
Recharge.Instance.recharge(player, NPCMoveCommand.RECHARGE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents chunk unloading when there is an NPC in it.
|
||||
*/
|
||||
@EventHandler
|
||||
public void chunkUnload(ChunkUnloadEvent event)
|
||||
{
|
||||
for (Entity entity : event.getChunk().getEntities())
|
||||
{
|
||||
if (isNPC(entity))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
A collection of listeners that make sure NPCs don't die.
|
||||
*/
|
||||
|
||||
@EventHandler
|
||||
public void entityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (isNPC(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void entityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (isNPC(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void entityDamage(EntityDamageByEntityEvent event)
|
||||
{
|
||||
NPC npc = getNPC(event.getEntity());
|
||||
|
||||
if (event.getDamager() instanceof Player && npc != null)
|
||||
{
|
||||
callInteractEvent((Player) event.getDamager(), npc, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void entityInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
NPC npc = getNPC(event.getRightClicked());
|
||||
|
||||
if (npc != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
callInteractEvent(event.getPlayer(), npc, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void callInteractEvent(Player player, NPC npc, boolean leftClick)
|
||||
{
|
||||
UtilServer.CallEvent(new NPCInteractEvent(player, npc, leftClick));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void creatureKill(CreatureKillEntitiesEvent event)
|
||||
{
|
||||
event.GetEntities().removeIf(this::isNPC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param metadata The metadata you wish to find all the NPCs of.
|
||||
* @return A list of {@link NPC} that are unloaded (have no entity attached to them) and that have the metadata which
|
||||
* starts with that specified.
|
||||
*/
|
||||
private List<NPC> getUnloadedNPCs(String metadata)
|
||||
{
|
||||
return _npcs.stream()
|
||||
.filter(npc -> npc.getMetadata().startsWith(metadata) && npc.getEntity() == null)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity The entity you want to get it's NPC of.
|
||||
* @return The {@link NPC} representation of that entity or null if the entity is not an NPC.
|
||||
*/
|
||||
public NPC getNPC(Entity entity)
|
||||
{
|
||||
for (NPC npc : _npcs)
|
||||
{
|
||||
if (npc.getEntity() != null && npc.getEntity().equals(entity))
|
||||
{
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity The entity you want to check.
|
||||
* @return true if the entity is a {@link NPC}.
|
||||
*/
|
||||
private boolean isNPC(Entity entity)
|
||||
{
|
||||
return getNPC(entity) != null;
|
||||
}
|
||||
}
|
@ -0,0 +1,203 @@
|
||||
package mineplex.core.newnpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.Column;
|
||||
import mineplex.serverdata.database.column.ColumnDouble;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
/**
|
||||
* A repository class that provides an interface for getting and saving NPCs.
|
||||
*/
|
||||
class NewNPCRepository extends RepositoryBase
|
||||
{
|
||||
|
||||
/**
|
||||
* A SQL statement that returns all entries form the table.
|
||||
*/
|
||||
private static final String GET_NPCS = "SELECT * FROM newNPCs;";
|
||||
/**
|
||||
* A SQL statement that inserts an entry and returns the id field generated.
|
||||
*/
|
||||
private static final String INSERT_NPC = "INSERT INTO newNPCs (entity_type, name, world, x, y, z, yaw, pitch, in_hand, in_hand_data, helmet, chestplate, leggings, boots, metadata, skinValue, skinSignature) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
||||
/**
|
||||
* A SQL statement that deletes an entry with a specific id field.
|
||||
*/
|
||||
private static final String DELETE_NPC = "DELETE FROM newNPCs WHERE id=?;";
|
||||
/**
|
||||
* A SQL statement that removes all entries from the table.
|
||||
*/
|
||||
private static final String CLEAR_NPCS = "DELETE FROM newNPCs;";
|
||||
/**
|
||||
* A SQL statement that adjusts the location properties of an entry with a specific id field.
|
||||
*/
|
||||
private static final String MOVE_NPC = "UPDATE newNPCs SET world=?, x=?, y=?, z=?, yaw=?, pitch=? WHERE id=?";
|
||||
|
||||
NewNPCRepository()
|
||||
{
|
||||
super(DBPool.getAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL query:
|
||||
* <p>
|
||||
* {@value GET_NPCS}
|
||||
* </p>
|
||||
* The values return are parsed into an instance of {@link NPC} or one of it's subclasses such as {@link PlayerNPC}
|
||||
* if appropriate.
|
||||
*
|
||||
* @param response The consumer callback that supplies the list of NPCs.
|
||||
*/
|
||||
void getNPCs(Consumer<List<NPC>> response)
|
||||
{
|
||||
executeQuery(GET_NPCS, resultSet ->
|
||||
{
|
||||
List<NPC> npcs = new ArrayList<>();
|
||||
|
||||
// While there are more entries
|
||||
while (resultSet.next())
|
||||
{
|
||||
int id = resultSet.getInt("id");
|
||||
EntityType entityType = EntityType.valueOf(resultSet.getString("entity_type"));
|
||||
String name = resultSet.getString("name");
|
||||
String worldName = resultSet.getString("world");
|
||||
double x = resultSet.getDouble("x");
|
||||
double y = resultSet.getDouble("y");
|
||||
double z = resultSet.getDouble("z");
|
||||
int yaw = resultSet.getInt("yaw");
|
||||
int pitch = resultSet.getInt("pitch");
|
||||
Material inHand = parseMaterial(resultSet.getString("in_hand"));
|
||||
byte inHandData = resultSet.getByte("in_hand_data");
|
||||
Material helmet = parseMaterial(resultSet.getString("helmet"));
|
||||
Material chestplate = parseMaterial(resultSet.getString("chestplate"));
|
||||
Material leggings = parseMaterial(resultSet.getString("leggings"));
|
||||
Material boots = parseMaterial(resultSet.getString("boots"));
|
||||
String metadata = resultSet.getString("metadata");
|
||||
String skinValue = resultSet.getString("skinValue");
|
||||
String skinSignature = resultSet.getString("skinSignature");
|
||||
|
||||
NPC npc;
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
|
||||
// If the world is not loaded on the server then don't add it to the list
|
||||
if (world == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the entity type is of player then the NPC must be specified as a PlayerNPC
|
||||
if (entityType == EntityType.PLAYER)
|
||||
{
|
||||
npc = new PlayerNPC(id, name, new Location(world, x, y, z, yaw, pitch), inHand, inHandData, helmet, chestplate, leggings, boots, metadata, skinValue, skinSignature);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc = new NPC(id, entityType, name, new Location(world, x, y, z, yaw, pitch), inHand, inHandData, helmet, chestplate, leggings, boots, metadata);
|
||||
}
|
||||
|
||||
npcs.add(npc);
|
||||
}
|
||||
|
||||
response.accept(npcs);
|
||||
});
|
||||
}
|
||||
|
||||
// Simply calls Material.valueOf, if invalid null
|
||||
private Material parseMaterial(String material)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Material.valueOf(material);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL insert:
|
||||
* <p>
|
||||
* {@value INSERT_NPC}
|
||||
* </p>
|
||||
* If the NPC does not have an id of -1, the insert will not be run.
|
||||
*
|
||||
* @param npc The NPC you want to insert into the database.
|
||||
*/
|
||||
void insertNPCIfNotExists(NPC npc)
|
||||
{
|
||||
// If the id isn't -1 then it has already been inserted
|
||||
if (npc.getId() != -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Column<?>[] columns = npc.toDatabaseQuery().toArray(new Column[0]);
|
||||
executeInsert(INSERT_NPC, resultSet ->
|
||||
{
|
||||
// If successful
|
||||
if (resultSet.next())
|
||||
{
|
||||
// Set the NPC's id with that generated by the database
|
||||
npc.setId(resultSet.getInt(1));
|
||||
}
|
||||
}, columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL insert:
|
||||
* <p>
|
||||
* {@value DELETE_NPC}
|
||||
* </p>
|
||||
*
|
||||
* @param npc The NPC you want to delete.
|
||||
*/
|
||||
void deleteNPC(NPC npc)
|
||||
{
|
||||
executeUpdate(DELETE_NPC, new ColumnInt("id", npc.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL insert:
|
||||
* <p>
|
||||
* {@value CLEAR_NPCS}
|
||||
* </p>
|
||||
*/
|
||||
void clearNPCs()
|
||||
{
|
||||
executeUpdate(CLEAR_NPCS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL insert:
|
||||
* <p>
|
||||
* {@value MOVE_NPC}
|
||||
* </p>
|
||||
*
|
||||
* @param npc The NPC you want to teleport.
|
||||
* @param location The Location that you want to the npc to teleport to.
|
||||
*/
|
||||
void teleportNPC(NPC npc, Location location)
|
||||
{
|
||||
executeUpdate(MOVE_NPC,
|
||||
new ColumnVarChar("world", 32, location.getWorld().getName()),
|
||||
new ColumnDouble("x", location.getBlockX() + 0.5),
|
||||
new ColumnDouble("y", location.getY()),
|
||||
new ColumnDouble("z", location.getBlockZ() + 0.5),
|
||||
new ColumnInt("yaw", (int) location.getYaw()),
|
||||
new ColumnInt("pitch", (int) location.getPitch()),
|
||||
new ColumnInt("id", npc.getId())
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package mineplex.core.newnpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.serverdata.database.column.Column;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class PlayerNPC extends NPC
|
||||
{
|
||||
|
||||
private static final DisguiseManager MANAGER = Managers.require(DisguiseManager.class);
|
||||
|
||||
private final SkinData _skinData;
|
||||
|
||||
private DisguisePlayer _disguise;
|
||||
|
||||
public PlayerNPC(int id, String name, Location spawn, Material inHand, byte inHandData, Material helmet, Material chestplate, Material leggings, Material boots, String metadata, String skinValue, String skinSignature)
|
||||
{
|
||||
super(id, EntityType.ARMOR_STAND, name, spawn, inHand, inHandData, helmet, chestplate, leggings, boots, metadata);
|
||||
|
||||
_skinData = new SkinData(skinValue, skinSignature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity spawnEntity()
|
||||
{
|
||||
LivingEntity entity = super.spawnEntity();
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), SkinData.getUnusedSkullName());
|
||||
profile.getProperties().clear();
|
||||
profile.getProperties().put("textures", _skinData.getProperty());
|
||||
|
||||
DisguisePlayer player = new DisguisePlayer(entity, profile);
|
||||
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
player.setHeldItem(equipment.getItemInHand());
|
||||
player.setHelmet(equipment.getHelmet());
|
||||
player.setChestplate(equipment.getChestplate());
|
||||
player.setLeggings(equipment.getLeggings());
|
||||
player.setBoots(equipment.getBoots());
|
||||
|
||||
_disguise = player;
|
||||
|
||||
// Ensure the entity is loaded before disguising
|
||||
MANAGER.runSyncLater(() -> MANAGER.disguise(player), 20);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hologram getNameTag()
|
||||
{
|
||||
if (!_disguise.hasHologram())
|
||||
{
|
||||
_disguise.getHologram().setText(getEntity().getCustomName());
|
||||
}
|
||||
|
||||
return _disguise.getHologram();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Column<?>> toDatabaseQuery()
|
||||
{
|
||||
List<Column<?>> columns = new ArrayList<>(super.toDatabaseQuery());
|
||||
|
||||
columns.set(0, new ColumnVarChar("entity_type", 32, EntityType.PLAYER.name()));
|
||||
columns.set(15, new ColumnVarChar("skinValue", 400, _skinData.getProperty().getValue()));
|
||||
columns.set(16, new ColumnVarChar("skinSignature", 700, _skinData.getProperty().getSignature()));
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
public DisguisePlayer getDisguise()
|
||||
{
|
||||
return _disguise;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package mineplex.core.newnpc.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.NewNPCManager.Perm;
|
||||
|
||||
public class NPCBuildCommand extends CommandBase<NewNPCManager>
|
||||
{
|
||||
|
||||
NPCBuildCommand(NewNPCManager plugin)
|
||||
{
|
||||
super(plugin, Perm.BUILD_NPC_COMMAND, "builder");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.createBuilder(caller);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package mineplex.core.newnpc.command;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.NewNPCManager.Perm;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class NPCClearCommand extends CommandBase<NewNPCManager>
|
||||
{
|
||||
|
||||
private static final String RECHARGE_KEY = "Clear NPCS";
|
||||
|
||||
NPCClearCommand(NewNPCManager plugin)
|
||||
{
|
||||
super(plugin, Perm.CLEAR_NPC_COMMAND, "clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (Recharge.Instance.usable(caller, RECHARGE_KEY))
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Are you really sure you want to delete ALL NPCs? This will remove every one off every server."));
|
||||
caller.sendMessage(F.main(Plugin.getName(), "If you are sure then run " + F.elem("/npc clear") + " again within " + F.time("10 seconds")) + ".");
|
||||
Recharge.Instance.useForce(caller, RECHARGE_KEY, TimeUnit.SECONDS.toMillis(10));
|
||||
return;
|
||||
}
|
||||
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Deleting all NPCs..."));
|
||||
Plugin.clearNPCS(true);
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Deleted all NPCs."));
|
||||
Recharge.Instance.recharge(caller, RECHARGE_KEY);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package mineplex.core.newnpc.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.NewNPCManager.Perm;
|
||||
|
||||
public class NPCCommand extends MultiCommandBase<NewNPCManager>
|
||||
{
|
||||
|
||||
public NPCCommand(NewNPCManager plugin)
|
||||
{
|
||||
super(plugin, Perm.NPC_COMMAND, "newnpc");
|
||||
|
||||
AddCommand(new NPCBuildCommand(plugin));
|
||||
AddCommand(new NPCDeleteCommand(plugin));
|
||||
AddCommand(new NPCClearCommand(plugin));
|
||||
AddCommand(new NPCRefreshCommand(plugin));
|
||||
AddCommand(new NPCMoveCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Command List:"));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " builder", "Creates a new NPC using the builder.", ChatColor.DARK_RED));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " delete", "Deletes an NPC.", ChatColor.DARK_RED));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " clear", "Removes all NPCs permanently.", ChatColor.DARK_RED));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " refresh", "Reloads all NPCs.", ChatColor.DARK_RED));
|
||||
caller.sendMessage(F.help("/" + _aliasUsed + " move", "Moves an NPC.", ChatColor.DARK_RED));
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package mineplex.core.newnpc.command;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.NewNPCManager.Perm;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class NPCDeleteCommand extends CommandBase<NewNPCManager>
|
||||
{
|
||||
|
||||
public static final String RECHARGE_KEY = "Delete NPC";
|
||||
|
||||
NPCDeleteCommand(NewNPCManager plugin)
|
||||
{
|
||||
super(plugin, Perm.DELETE_NPC_COMMAND, "delete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Punch the NPC you wish to remove. You will have " + F.time("10 seconds") + " to do so."));
|
||||
Recharge.Instance.useForce(caller, RECHARGE_KEY, TimeUnit.SECONDS.toMillis(10));
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package mineplex.core.newnpc.command;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.NewNPCManager.Perm;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class NPCMoveCommand extends CommandBase<NewNPCManager>
|
||||
{
|
||||
|
||||
public static final String RECHARGE_KEY = "Move NPC";
|
||||
|
||||
NPCMoveCommand(NewNPCManager plugin)
|
||||
{
|
||||
super(plugin, Perm.DELETE_NPC_COMMAND, "move");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Punch the NPC you wish to move to this location. You will have " + F.time("30 seconds") + " to do so."));
|
||||
Plugin.setPlayerTeleport(caller);
|
||||
Recharge.Instance.useForce(caller, RECHARGE_KEY, TimeUnit.SECONDS.toMillis(30));
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.newnpc.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.newnpc.NewNPCManager;
|
||||
import mineplex.core.newnpc.NewNPCManager.Perm;
|
||||
|
||||
public class NPCRefreshCommand extends CommandBase<NewNPCManager>
|
||||
{
|
||||
|
||||
NPCRefreshCommand(NewNPCManager plugin)
|
||||
{
|
||||
super(plugin, Perm.REFRESH_NPC_COMMAND, "refresh");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Refreshing NPCs..."));
|
||||
Plugin.runAsync(() -> Plugin.refreshNPCS());
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Refreshed NPCs"));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user