Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/battle-royale

This commit is contained in:
Sam 2017-06-23 14:18:51 +01:00
commit 2facabbe2d
106 changed files with 1587 additions and 1072 deletions

View File

@ -0,0 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-parent</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>mineplex-core-common-base</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
public enum Rank public enum Rank
{ {
@ -122,7 +122,7 @@ public enum Rank
if (inform) if (inform)
{ {
UtilPlayer.message(player, C.mHead + "Permissions> " + UtilPlayerBase.message(player, C.mHead + "Permissions> " +
C.mBody + "This requires Permission Rank [" + C.mBody + "This requires Permission Rank [" +
C.mHead + rank.Name.toUpperCase() + C.mHead + rank.Name.toUpperCase() +
C.mBody + "]."); C.mBody + "].");

View File

@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang.Validate;
import java.util.Set; import java.util.Set;

View File

@ -0,0 +1,38 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
public class UtilBlockBase
{
public static ArrayList<Block> getSurrounding(Block block, boolean diagonals)
{
ArrayList<Block> blocks = new ArrayList<Block>();
if (diagonals)
{
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++)
for (int y = 1; y >= -1; y--)
{
if (x == 0 && y == 0 && z == 0) continue;
blocks.add(block.getRelative(x, y, z));
}
}
else
{
blocks.add(block.getRelative(BlockFace.UP));
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.WEST));
blocks.add(block.getRelative(BlockFace.DOWN));
}
return blocks;
}
}

View File

@ -0,0 +1,97 @@
package mineplex.core.common.util;
import java.util.LinkedList;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import mineplex.core.common.events.PlayerMessageEvent;
import org.bukkit.Bukkit;
public class UtilPlayerBase
{
public static void message(Entity client, LinkedList<String> messageList)
{
message(client, messageList, false);
}
public static void message(Entity client, String message)
{
message(client, message, false);
}
public static void message(Entity client, LinkedList<String> messageList, boolean wiki)
{
for (String curMessage : messageList)
{
message(client, curMessage, wiki);
}
}
public static void message(Entity client, String message, boolean wiki)
{
if (client == null)
return;
if (!(client instanceof Player))
return;
/*
if (wiki)
message = UtilWiki.link(message);
*/
PlayerMessageEvent event = new PlayerMessageEvent((Player) client, message);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
((Player) client).sendMessage(message);
}
public static Player searchOnline(Player caller, String player, boolean inform)
{
LinkedList<Player> matchList = new LinkedList<Player>();
for (Player cur : Bukkit.getOnlinePlayers())
{
if (cur.getName().equalsIgnoreCase(player))
return cur;
if (cur.getName().toLowerCase().contains(player.toLowerCase()))
matchList.add(cur);
}
// No / Non-Unique
if (matchList.size() != 1)
{
if (!inform)
return null;
// Inform
message(caller,
F.main("Online Player Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem
+ player + C.mBody + "]."));
if (matchList.size() > 0)
{
String matchString = "";
for (Player cur : matchList)
matchString += F.elem(cur.getName()) + ", ";
if (matchString.length() > 1)
matchString = matchString.substring(0, matchString.length() - 2);
message(caller,
F.main("Online Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
}
return matchList.get(0);
}
}

View File

@ -6,8 +6,6 @@ import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Calendar; import java.util.Calendar;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class UtilTime public class UtilTime
{ {
public static final ZoneId CENTRAL_ZONE = ZoneId.of("America/Chicago"); // This means "CST" public static final ZoneId CENTRAL_ZONE = ZoneId.of("America/Chicago"); // This means "CST"
@ -54,15 +52,6 @@ public class UtilTime
} }
} }
/**
*
* @return Returns the current global server tick. Is reset on server restart. Starts out negative. Counts upwards.
*/
public static int getServerTick()
{
return MinecraftServer.currentTick;
}
/** /**
* Converts a {@link Timestamp} to a {@link LocalDateTime}. * Converts a {@link Timestamp} to a {@link LocalDateTime}.
* This method will only work for timestamp's stored using {@link #CENTRAL_ZONE}, if stored using * This method will only work for timestamp's stored using {@link #CENTRAL_ZONE}, if stored using

View File

@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -10,19 +11,16 @@ import org.bukkit.World.Environment;
import org.bukkit.WorldBorder; import org.bukkit.WorldBorder;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilWorld public class UtilWorld
{ {
public static World getWorld(String world) public static World getWorld(String world)
{ {
return UtilServer.getServer().getWorld(world); return Bukkit.getServer().getWorld(world);
} }
public static boolean areChunksEqual(Location first, Location second) public static boolean areChunksEqual(Location first, Location second)
@ -100,7 +98,7 @@ public class UtilWorld
try try
{ {
for (World cur : UtilServer.getServer().getWorlds()) for (World cur : Bukkit.getServer().getWorlds())
{ {
if (cur.getName().equalsIgnoreCase(parts[0])) if (cur.getName().equalsIgnoreCase(parts[0]))
{ {
@ -154,7 +152,7 @@ public class UtilWorld
try try
{ {
for (World cur : UtilServer.getServer().getWorlds()) for (World cur : Bukkit.getServer().getWorlds())
{ {
if (cur.getName().equalsIgnoreCase(tokens[0])) if (cur.getName().equalsIgnoreCase(tokens[0]))
{ {
@ -188,7 +186,7 @@ public class UtilWorld
public static World getWorldType(Environment env) public static World getWorldType(Environment env)
{ {
for (World cur : UtilServer.getServer().getWorlds()) for (World cur : Bukkit.getServer().getWorlds())
if (cur.getEnvironment() == env) if (cur.getEnvironment() == env)
return cur; return cur;
@ -305,16 +303,4 @@ public class UtilWorld
return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ; return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ;
} }
public static double distanceSquared(Entity a, Entity b)
{
if (a.getWorld() != b.getWorld())
throw new IllegalArgumentException("Different worlds: " + a.getWorld().getName() + " and " + b.getWorld().getName());
net.minecraft.server.v1_8_R3.Entity entityA = ((CraftEntity) a).getHandle();
net.minecraft.server.v1_8_R3.Entity entityB = ((CraftEntity) b).getHandle();
double dx = entityA.locX - entityB.locX;
double dy = entityA.locY - entityB.locY;
double dz = entityA.locZ - entityB.locZ;
return (dx * dx) + (dy * dy) + (dz * dz);
}
} }

View File

@ -20,6 +20,11 @@
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core-common-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.mineplex</groupId> <groupId>com.mineplex</groupId>
<artifactId>mineplex-serverdata</artifactId> <artifactId>mineplex-serverdata</artifactId>

View File

@ -0,0 +1,79 @@
package mineplex.core.common.geom;
import javax.annotation.Nonnull;
import java.util.Comparator;
import org.bukkit.Location;
public class Point2D implements Comparable<Point2D>
{
private static final Comparator<Point2D> COMPARE_BY_Y_THEN_X =
Comparator.comparingDouble(Point2D::getY).thenComparingDouble(Point2D::getX);
private final double _x;
private final double _y;
private Point2D(double x, double y)
{
_x = x;
_y = y;
}
public static Point2D of(double x, double y)
{
return new Point2D(x, y);
}
public static Point2D of(Location location)
{
return new Point2D(location.getX(), location.getZ());
}
public double getX()
{
return _x;
}
public double getY()
{
return _y;
}
public Comparator<Point2D> polarOrder()
{
return (p2, p3) ->
{
double dx1 = p2._x - _x;
double dy1 = p2._y - _y;
double dx2 = p3._x - _x;
double dy2 = p3._y - _y;
if (dy1 >= 0 && dy2 < 0) return -1; // p2 above; p3 below
else if (dy2 >= 0 && dy1 < 0) return 1; // p2 below; p3 above
else if (dy1 == 0 && dy2 == 0) { // 3-collinear and horizontal
if (dx1 >= 0 && dx2 < 0) return -1; // p2 right; p3 left
else if (dx2 >= 0 && dx1 < 0) return 1; // p2 left ; p3 right
else return 0; // all the same point
}
else return -ccw(Point2D.this, p2, p3); // both above or below
};
}
public static int ccw(Point2D a, Point2D b, Point2D c) {
double area2 = (b._x-a._x)*(c._y-a._y) - (b._y-a._y)*(c._x-a._x);
if (area2 < 0) return -1;
else if (area2 > 0) return 1;
else return 0;
}
@Override
public int compareTo(@Nonnull Point2D that)
{
return COMPARE_BY_Y_THEN_X.compare(this, that);
}
@Override
public String toString()
{
return "Point2D{_x=" + _x + ",_y=" + _y + "}";
}
}

View File

@ -0,0 +1,68 @@
package mineplex.core.common.geom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Stack;
public class Polygon2D
{
private final List<Point2D> _points;
private Polygon2D(List<Point2D> points)
{
_points = points;
// Ensure points[points.size-1] = points[0]
if (!_points.get(0).equals(points.get(_points.size()-1)))
{
_points.add(points.get(0));
}
}
public boolean contains(Point2D point)
{
boolean result = false;
for (int i = 0, j = _points.size() - 1; i < _points.size(); j = i++)
{
if ((_points.get(i).getY() > point.getY()) != (_points.get(j).getY() > point.getY()) &&
(point.getX() < (_points.get(j).getX() - _points.get(i).getX()) * (point.getY() - _points.get(i).getY()) / (_points.get(j).getY() - _points.get(i).getY()) + _points.get(i).getX()))
{
result = !result;
}
}
return result;
}
public static Polygon2D fromUnorderedPoints(List<Point2D> points)
{
Stack<Point2D> hull = new Stack<>();
Collections.sort(points);
points.subList(1, points.size()).sort(points.get(0).polarOrder());
hull.push(points.get(0));
hull.push(points.get(1));
// find first extreme point (not collinear with first and second elements)
int extreme;
for (extreme = 2; extreme < points.size(); extreme++)
if (Point2D.ccw(points.get(0), points.get(1), points.get(extreme)) != 0) break;
for (int i = extreme; i < points.size(); i++)
{
Point2D top = hull.pop();
while (Point2D.ccw(hull.peek(), top, points.get(i)) <= 0) {
top = hull.pop();
}
hull.push(top);
hull.push(points.get(i));
}
return new Polygon2D(new ArrayList<>(hull));
}
public static Polygon2D fromPoints(List<Point2D> points)
{
return new Polygon2D(new ArrayList<>(points));
}
}

View File

@ -615,30 +615,7 @@ public class UtilBlock
public static ArrayList<Block> getSurrounding(Block block, boolean diagonals) public static ArrayList<Block> getSurrounding(Block block, boolean diagonals)
{ {
ArrayList<Block> blocks = new ArrayList<Block>(); return UtilBlockBase.getSurrounding(block, diagonals);
if (diagonals)
{
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++)
for (int y = 1; y >= -1; y--)
{
if (x == 0 && y == 0 && z == 0) continue;
blocks.add(block.getRelative(x, y, z));
}
}
else
{
blocks.add(block.getRelative(BlockFace.UP));
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.WEST));
blocks.add(block.getRelative(BlockFace.DOWN));
}
return blocks;
} }
public static boolean isVisible(Block block) public static boolean isVisible(Block block)

View File

@ -348,42 +348,22 @@ public class UtilPlayer
public static void message(Entity client, LinkedList<String> messageList) public static void message(Entity client, LinkedList<String> messageList)
{ {
message(client, messageList, false); UtilPlayerBase.message(client, messageList);
} }
public static void message(Entity client, String message) public static void message(Entity client, String message)
{ {
message(client, message, false); UtilPlayerBase.message(client, message);
} }
public static void message(Entity client, LinkedList<String> messageList, boolean wiki) public static void message(Entity client, LinkedList<String> messageList, boolean wiki)
{ {
for (String curMessage : messageList) UtilPlayerBase.message(client, messageList, wiki);
{
message(client, curMessage, wiki);
}
} }
public static void message(Entity client, String message, boolean wiki) public static void message(Entity client, String message, boolean wiki)
{ {
if (client == null) UtilPlayerBase.message(client, message, wiki);
return;
if (!(client instanceof Player))
return;
/*
if (wiki)
message = UtilWiki.link(message);
*/
PlayerMessageEvent event = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message));
if (event.isCancelled())
return;
((Player) client).sendMessage(message);
} }
public static Player searchExact(String name) public static Player searchExact(String name)
@ -454,44 +434,7 @@ public class UtilPlayer
public static Player searchOnline(Player caller, String player, boolean inform) public static Player searchOnline(Player caller, String player, boolean inform)
{ {
LinkedList<Player> matchList = new LinkedList<Player>(); return UtilPlayerBase.searchOnline(caller, player, inform);
for (Player cur : UtilServer.getPlayers())
{
if (cur.getName().equalsIgnoreCase(player))
return cur;
if (cur.getName().toLowerCase().contains(player.toLowerCase()))
matchList.add(cur);
}
// No / Non-Unique
if (matchList.size() != 1)
{
if (!inform)
return null;
// Inform
message(caller,
F.main("Online Player Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem
+ player + C.mBody + "]."));
if (matchList.size() > 0)
{
String matchString = "";
for (Player cur : matchList)
matchString += F.elem(cur.getName()) + ", ";
if (matchString.length() > 1)
matchString = matchString.substring(0, matchString.length() - 2);
message(caller,
F.main("Online Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
}
return matchList.get(0);
} }
public static void searchOffline(List<String> matches, final Callback<String> callback, final Player caller, public static void searchOffline(List<String> matches, final Callback<String> callback, final Player caller,

View File

@ -78,39 +78,39 @@ public class AntiHackGuardian implements Listener
{ {
UtilServer.RegisterEvents(this); UtilServer.RegisterEvents(this);
this.MAX_DISTANCE_X = maxX; MAX_DISTANCE_X = maxX;
this.MIN_DISTANCE_X = minX; MIN_DISTANCE_X = minX;
this.MAX_DISTANCE_Y = maxY; MAX_DISTANCE_Y = maxY;
this.MIN_DISTANCE_Y = minY; MIN_DISTANCE_Y = minY;
this.MAX_DISTANCE_Z = maxZ; MAX_DISTANCE_Z = maxZ;
this.MIN_DISTANCE_Z = minZ; MIN_DISTANCE_Z = minZ;
this.CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0); CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0);
this.CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0); CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0);
this.CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0);
//debug("Spawning ArmorStand at " + center + ""); //debug("Spawning ArmorStand at " + center + "");
CoreClientManager clientManager = Managers.get(CoreClientManager.class); CoreClientManager clientManager = Managers.get(CoreClientManager.class);
DisguiseManager disguiseManager = Managers.get(DisguiseManager.class); DisguiseManager disguiseManager = Managers.get(DisguiseManager.class);
this._center = center; _center = center;
this._center.getChunk().load(); _center.getChunk().load();
this._armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) this._center.getWorld()).getHandle(), this._center.getX(), this._center.getY(), this._center.getZ()).getBukkitEntity(); _armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) _center.getWorld()).getHandle(), _center.getX(), _center.getY(), _center.getZ()).getBukkitEntity();
this._armorStand.setGravity(false); _armorStand.setGravity(false);
this._armorStand.setVisible(false); _armorStand.setVisible(false);
this._armorStand.setRemoveWhenFarAway(false); _armorStand.setRemoveWhenFarAway(false);
this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); _nmsEntity = ((CraftArmorStand) _armorStand).getHandle();
this._nmsEntity.maxNoDamageTicks = 86400; _nmsEntity.maxNoDamageTicks = 86400;
this._nmsEntity.noDamageTicks = 86400; _nmsEntity.noDamageTicks = 86400;
this._entityUUID = this._armorStand.getUniqueId(); _entityUUID = _armorStand.getUniqueId();
this._disguise = new DisguiseGuardian(this._armorStand); _disguise = new DisguiseGuardian(_armorStand);
this._disguise.setHideIfNotDisguised(true); _disguise.setHideIfNotDisguised(true);
disguiseManager.disguise(this._disguise, player -> disguiseManager.disguise(_disguise, player ->
{ {
if (!hideForStaff) return true; if (!hideForStaff) return true;
@ -141,17 +141,17 @@ public class AntiHackGuardian implements Listener
@EventHandler @EventHandler
public void onLoad(ChunkAddEntityEvent event) public void onLoad(ChunkAddEntityEvent event)
{ {
if (event.getEntity().getUniqueId().equals(this._entityUUID)) if (event.getEntity().getUniqueId().equals(_entityUUID))
{ {
this._armorStand = (ArmorStand) event.getEntity(); _armorStand = (ArmorStand) event.getEntity();
this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); _nmsEntity = ((CraftArmorStand) _armorStand).getHandle();
} }
} }
@EventHandler @EventHandler
public void onStack(StackerEvent event) public void onStack(StackerEvent event)
{ {
if (event.getEntity().getUniqueId().equals(this._entityUUID)) if (event.getEntity().getUniqueId().equals(_entityUUID))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -159,27 +159,27 @@ public class AntiHackGuardian implements Listener
public void tick() public void tick()
{ {
if (this._nmsEntity.dead || !this._nmsEntity.valid) if (_nmsEntity.dead || !_nmsEntity.valid)
{ {
//debug("Skipping because " + this._armorStand.isDead() + " " + this._armorStand.isValid()); //debug("Skipping because " + _armorStand.isDead() + " " + _armorStand.isValid());
return; return;
} }
if (this._target == null) if (_target == null)
{ {
regularTick(); regularTick();
} }
else else
{ {
this._stalkTime++; _stalkTime++;
targetTick(); targetTick();
} }
//debug("Ticking " + this._armorStand + " " + this._armorStand.isDead() + " " + this._armorStand.getLocation() + " " + this._ticksUntilReset); //debug("Ticking " + _armorStand + " " + _armorStand.isDead() + " " + _armorStand.getLocation() + " " + _ticksUntilReset);
} }
private void regularTick() private void regularTick()
{ {
if (this._ticksUntilReset <= 0) if (_ticksUntilReset <= 0)
{ {
reset(); reset();
} }
@ -187,8 +187,8 @@ public class AntiHackGuardian implements Listener
//debug("===== Begin Calculations ====="); //debug("===== Begin Calculations =====");
//debug("Target: " + this._targetX + " " + this._targetY + " " + this._targetZ); //debug("Target: " + _targetX + " " + _targetY + " " + _targetZ);
//debug("Start: " + this._armorStand.getLocation()); //debug("Start: " + _armorStand.getLocation());
double deltaX = _targetX - _nmsEntity.locX; double deltaX = _targetX - _nmsEntity.locX;
double deltaY = _targetY - _nmsEntity.locY; double deltaY = _targetY - _nmsEntity.locY;
double deltaZ = _targetZ - _nmsEntity.locZ; double deltaZ = _targetZ - _nmsEntity.locZ;
@ -210,28 +210,28 @@ public class AntiHackGuardian implements Listener
_nmsEntity.locY += dy; _nmsEntity.locY += dy;
_nmsEntity.locZ += dz; _nmsEntity.locZ += dz;
//debug("Dest: " + this._nmsEntity.locX + " " + this._nmsEntity.locY + " " + this._nmsEntity.locZ); //debug("Dest: " + _nmsEntity.locX + " " + _nmsEntity.locY + " " + _nmsEntity.locZ);
//debug("===== End Calculations ====="); //debug("===== End Calculations =====");
// Only send look update every second // Only send look update every second
if (this._nmsEntity.ticksLived % 20 == 0) if (_nmsEntity.ticksLived % 20 == 0)
{ {
UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ);
} }
this._ticksUntilReset--; _ticksUntilReset--;
} }
private void targetTick() private void targetTick()
{ {
//debug("===== Stalking " + this._target.getName() + " ====="); //debug("===== Stalking " + _target.getName() + " =====");
EntityPlayer entityPlayer = ((CraftPlayer) this._target).getHandle(); EntityPlayer entityPlayer = ((CraftPlayer) _target).getHandle();
Vector direction = this._target.getLocation().getDirection().normalize().multiply(-6); Vector direction = _target.getLocation().getDirection().normalize().multiply(-6);
this._nmsEntity.locX = entityPlayer.locX + direction.getX(); _nmsEntity.locX = entityPlayer.locX + direction.getX();
this._nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); _nmsEntity.locZ = entityPlayer.locZ + direction.getZ();
this._nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0); _nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0);
UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ); UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, entityPlayer.locX, entityPlayer.locY, entityPlayer.locZ);
} }
@ -261,7 +261,7 @@ public class AntiHackGuardian implements Listener
cy = MAGICAL_FUNCTION.apply(cy) * (y > CENTER_Y ? -(MAX_DISTANCE_Y - CENTER_Y) : (CENTER_Y - MIN_DISTANCE_Y)); cy = MAGICAL_FUNCTION.apply(cy) * (y > CENTER_Y ? -(MAX_DISTANCE_Y - CENTER_Y) : (CENTER_Y - MIN_DISTANCE_Y));
cz = MAGICAL_FUNCTION.apply(cz) * (z > CENTER_Z ? -(MAX_DISTANCE_Z - CENTER_Z) : (CENTER_Z - MIN_DISTANCE_Z)); cz = MAGICAL_FUNCTION.apply(cz) * (z > CENTER_Z ? -(MAX_DISTANCE_Z - CENTER_Z) : (CENTER_Z - MIN_DISTANCE_Z));
//debug("Start: " + this._armorStand.getLocation()); //debug("Start: " + _armorStand.getLocation());
//debug("Changes: " + cx + " " + cy + " " + cz); //debug("Changes: " + cx + " " + cy + " " + cz);
int ex = nextInt(8, 12); int ex = nextInt(8, 12);
@ -285,18 +285,18 @@ public class AntiHackGuardian implements Listener
//debug("Deltas: " + dx + " " + dy + " " + dz); //debug("Deltas: " + dx + " " + dy + " " + dz);
this._targetX = x + dx; _targetX = x + dx;
this._targetY = y + dy; _targetY = y + dy;
this._targetZ = z + dz; _targetZ = z + dz;
//debug("End: " + this._targetX + " " + this._targetY + " " + this._targetZ); //debug("End: " + _targetX + " " + _targetY + " " + _targetZ);
// If we can't find a good position, just go to the center // If we can't find a good position, just go to the center
if (!locCheck()) if (!locCheck())
{ {
this._targetX = CENTER_X; _targetX = CENTER_X;
this._targetY = CENTER_Y; _targetY = CENTER_Y;
this._targetZ = CENTER_Z; _targetZ = CENTER_Z;
dx = (int) (CENTER_X - x); dx = (int) (CENTER_X - x);
dy = (int) (CENTER_Y - y); dy = (int) (CENTER_Y - y);
@ -305,46 +305,46 @@ public class AntiHackGuardian implements Listener
double maxDelta = Math.max(Math.max(Math.abs(dx), Math.abs(dy)), Math.abs(dz)); double maxDelta = Math.max(Math.max(Math.abs(dx), Math.abs(dy)), Math.abs(dz));
this._ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); _ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK);
// Send look update for new target // Send look update for new target
UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ);
//debug("Ticks: " + this._ticksUntilReset); //debug("Ticks: " + _ticksUntilReset);
//debug("======= END RESET ======"); //debug("======= END RESET ======");
} }
public void target(Player player) public void target(Player player)
{ {
this._target = player; _target = player;
} }
public boolean isTargeting() public boolean isTargeting()
{ {
return this._target != null; return _target != null;
} }
public int getTargetingTime() public int getTargetingTime()
{ {
return this._stalkTime; return _stalkTime;
} }
public void stopTargeting() public void stopTargeting()
{ {
this._target = null; _target = null;
this._stalkTime = 0; _stalkTime = 0;
reset(); reset();
} }
public void shoot(Player player) public void shoot(Player player)
{ {
this._disguise.setTarget(player == null ? 0 : player.getEntityId()); _disguise.setTarget(player == null ? 0 : player.getEntityId());
Managers.get(DisguiseManager.class).updateDisguise(this._disguise); Managers.get(DisguiseManager.class).updateDisguise(_disguise);
} }
public Player getTarget() public Player getTarget()
{ {
return this._target; return _target;
} }
private boolean locCheck() private boolean locCheck()
@ -376,31 +376,31 @@ public class AntiHackGuardian implements Listener
public void remove() public void remove()
{ {
this._target = null; _target = null;
UtilServer.Unregister(this); UtilServer.Unregister(this);
Managers.get(DisguiseManager.class).undisguise(this._disguise); Managers.get(DisguiseManager.class).undisguise(_disguise);
this._armorStand.remove(); _armorStand.remove();
this._nmsEntity = null; _nmsEntity = null;
this._armorStand = null; _armorStand = null;
this._center = null; _center = null;
} }
public ArmorStand getEntity() public ArmorStand getEntity()
{ {
return this._armorStand; return _armorStand;
} }
public void moveDelta(double dx, double dy, double dz) public void moveDelta(double dx, double dy, double dz)
{ {
this._nmsEntity.locX += dx; _nmsEntity.locX += dx;
this._nmsEntity.locY += dy; _nmsEntity.locY += dy;
this._nmsEntity.locZ += dz; _nmsEntity.locZ += dz;
} }
public void move(double x, double y, double z) public void move(double x, double y, double z)
{ {
this._nmsEntity.locX = x; _nmsEntity.locX = x;
this._nmsEntity.locY = y; _nmsEntity.locY = y;
this._nmsEntity.locZ = z; _nmsEntity.locZ = z;
} }
} }

View File

@ -41,13 +41,13 @@ public class GuardianManager extends MiniPlugin
{ {
super("GuardianManager"); super("GuardianManager");
this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> _plugin.getServer().getScheduler().runTaskTimer(_plugin, () ->
{ {
for (AntiHackGuardian guardian : this._guardians) for (AntiHackGuardian guardian : _guardians)
{ {
if (guardian.getTarget() != null && !guardian.getTarget().isOnline()) if (guardian.getTarget() != null && !guardian.getTarget().isOnline())
{ {
this._stalking.remove(guardian.getTarget().getUniqueId()); _stalking.remove(guardian.getTarget().getUniqueId());
guardian.stopTargeting(); guardian.stopTargeting();
} }
else if (guardian.getTargetingTime() > MIN_STALK_TIME) else if (guardian.getTargetingTime() > MIN_STALK_TIME)
@ -55,7 +55,7 @@ public class GuardianManager extends MiniPlugin
double threshold = STALK_END_PROBABILITY_EQUATION.apply(guardian.getTargetingTime() - MIN_STALK_TIME); double threshold = STALK_END_PROBABILITY_EQUATION.apply(guardian.getTargetingTime() - MIN_STALK_TIME);
if (Math.random() <= threshold) if (Math.random() <= threshold)
{ {
this._stalking.remove(guardian.getTarget().getUniqueId()); _stalking.remove(guardian.getTarget().getUniqueId());
_stalkingCooldown.put(guardian.getTarget().getUniqueId(), true); _stalkingCooldown.put(guardian.getTarget().getUniqueId(), true);
guardian.stopTargeting(); guardian.stopTargeting();
} }
@ -64,7 +64,7 @@ public class GuardianManager extends MiniPlugin
} }
}, 0L, 1L); }, 0L, 1L);
this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> _plugin.getServer().getScheduler().runTaskTimer(_plugin, () ->
{ {
if (_stalking.size() >= MAX_STALKED_PLAYERS) if (_stalking.size() >= MAX_STALKED_PLAYERS)
{ {
@ -124,6 +124,6 @@ public class GuardianManager extends MiniPlugin
public void registerGuardian(AntiHackGuardian guardian) public void registerGuardian(AntiHackGuardian guardian)
{ {
this._guardians.add(guardian); _guardians.add(guardian);
} }
} }

View File

@ -55,7 +55,7 @@ public class BetaWhitelist extends MiniPlugin
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
Rank rank = _clientManager.Get(player).GetRank(true); Rank rank = _clientManager.Get(player).GetRank(true);
if (rank.has(Rank.TITAN) // If this player is Titan+ if (rank.has(Rank.ULTRA) // If this player is Ultra+
|| _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber, || _powerPlayClubRepository.getCachedData(player).isSubscribed() // a PPC subscriber,
|| EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted,
{ {

View File

@ -10,10 +10,11 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ArrowEffectGadget; import mineplex.core.gadget.types.ArrowEffectGadget;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class ArrowTrailCandyCane extends ArrowEffectGadget public class ArrowTrailCandyCane extends ArrowEffectGadget
{ {
@ -29,7 +30,7 @@ public class ArrowTrailCandyCane extends ArrowEffectGadget
public void doTrail(Arrow arrow) public void doTrail(Arrow arrow)
{ {
int data = 15; int data = 15;
int tick = Math.abs(UtilTime.getServerTick()%3); int tick = Math.abs(MinecraftServer.currentTick%3);
if(tick == 1) data = 1; if(tick == 1) data = 1;
if(tick == 2) data = 2; if(tick == 2) data = 2;
Location loc = arrow.getLocation(); Location loc = arrow.getLocation();

View File

@ -104,7 +104,8 @@ public enum GameDisplay
AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false),
MOBA("Heroes of GWEN", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), MOBA("Heroes of GWEN", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, true),
MOBATraining("Heroes of GWEN Training", Material.PRISMARINE, (byte)0, GameCategory.CLASSICS, 70, false),
GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false),

View File

@ -6,7 +6,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
@ -19,7 +18,6 @@ import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.AntiHack;
import mineplex.core.antihack.guardians.AntiHackGuardian;
import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.antihack.guardians.GuardianManager;
import mineplex.core.aprilfools.AprilFoolsManager; import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
@ -161,81 +159,6 @@ public class Clans extends JavaPlugin
new EternalGiveawayManager(this, _clientManager, serverStatusManager); new EternalGiveawayManager(this, _clientManager, serverStatusManager);
{
// West Shop
int maxX = -385;
int minX = -462;
int maxY = 100;
int minY = 90;
int maxZ = 46;
int minZ = -30;
Location spawn = new Location(Bukkit.getWorld("world"), -422, 95, 8);
for (int i = 0; i < 10; i++)
{
guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ));
}
}
{
// East Shop
int maxX = 385;
int minX = -463;
int maxY = 100;
int minY = 90;
int maxZ = 31;
int minZ = -46;
Location spawn = new Location(Bukkit.getWorld("world"), 424, 95, -8);
for (int i = 0; i < 10; i++)
{
guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ));
}
}
{
// North Spawn
int maxX = 25;
int minX = -8;
int maxY = 215;
int minY = 205;
int maxZ = -376;
int minZ = -410;
Location spawn = new Location(Bukkit.getWorld("world"), 9, 210, -393);
for (int i = 0; i < 10; i++)
{
guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ));
}
}
{
// South Spawn
int maxX = 25;
int minX = -8;
int maxY = 215;
int minY = 205;
int maxZ = 407;
int minZ = 373;
Location spawn = new Location(Bukkit.getWorld("world"), 8, 210, 390);
for (int i = 0; i < 10; i++)
{
guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ));
}
}
{
// Fields
int maxX = 50;
int minX = -60;
int maxY = 110;
int minY = 100;
int maxZ = 70;
int minZ = -70;
Location spawn = new Location(Bukkit.getWorld("world"), 0, 100, 0);
for (int i = 0; i < 40; i++)
{
guardianManager.registerGuardian(new AntiHackGuardian(spawn.clone(), maxX, minX, maxY, minY, maxZ, minZ));
}
}
BlockRestore blockRestore = require(BlockRestore.class); BlockRestore blockRestore = require(BlockRestore.class);
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);

View File

@ -377,7 +377,7 @@ public class ClansGame extends MiniPlugin
@EventHandler @EventHandler
public void respawn(PlayerRespawnEvent event) public void respawn(PlayerRespawnEvent event)
{ {
_clans.getItemMapManager().setMap(event.getPlayer()); //_clans.getItemMapManager().setMap(event.getPlayer());
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)

View File

@ -221,7 +221,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private ProjectileManager _projectileManager; private ProjectileManager _projectileManager;
private WorldEventManager _worldEvent; private WorldEventManager _worldEvent;
private Chat _chat; private Chat _chat;
private ItemMapManager _itemMapManager; // private ItemMapManager _itemMapManager;
private DisguiseManager _disguiseManager; private DisguiseManager _disguiseManager;
private NpcManager _npcManager; private NpcManager _npcManager;
private Explosion _explosion; private Explosion _explosion;
@ -305,7 +305,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_clanGame = new ClansGame(plugin, this); _clanGame = new ClansGame(plugin, this);
_clanUtility = new ClansUtility(this); _clanUtility = new ClansUtility(this);
_tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager); _tutorial = new TutorialManager(plugin, clientManager, donationManager, chat, hologramManager, this, _npcManager, _taskManager);
_itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent); // _itemMapManager = new ItemMapManager(this, _tutorial, _worldEvent);
new TntGeneratorManager(plugin, this); new TntGeneratorManager(plugin, this);
new SupplyDropManager(plugin, this); new SupplyDropManager(plugin, this);
@ -492,7 +492,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
addCommand(new ClansChatCommand(this)); addCommand(new ClansChatCommand(this));
addCommand(new ClansAllyChatCommand(this)); addCommand(new ClansAllyChatCommand(this));
addCommand(new ClanManagementCommand(this)); addCommand(new ClanManagementCommand(this));
addCommand(new MapCommand(this)); // addCommand(new MapCommand(this));
addCommand(new SpeedCommand(this)); addCommand(new SpeedCommand(this));
} }
@ -563,10 +563,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
return _inventoryManager; return _inventoryManager;
} }
public ItemMapManager getItemMapManager() // public ItemMapManager getItemMapManager()
{ // {
return _itemMapManager; // return _itemMapManager;
} // }
public Explosion getExplosion() public Explosion getExplosion()
{ {
@ -1273,10 +1273,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
online++; online++;
} }
if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp()) if (online >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && rank != Rank.YOUTUBE && rank != Rank.YOUTUBE_SMALL && !event.getPlayer().isWhitelisted() && !event.getPlayer().isOp())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon"); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This Clans server is full! Try again soon");
event.setKickMessage("This Clans server is full! Try again soon");
} }
else else
{ {

View File

@ -987,18 +987,18 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanUtility().unclaimAll(caller); Plugin.getClanUtility().unclaimAll(caller);
} }
public void map(Player caller, String[] args) // public void map(Player caller, String[] args)
{ // {
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "map"); // ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "map");
UtilServer.getServer().getPluginManager().callEvent(event); // UtilServer.getServer().getPluginManager().callEvent(event);
//
if (event.isCancelled()) // if (event.isCancelled())
{ // {
return; // return;
} // }
//
Plugin.getItemMapManager().setMap(caller); // Plugin.getItemMapManager().setMap(caller);
} // }
public void home(final Player caller, String[] args) public void home(final Player caller, String[] args)
{ {

View File

@ -33,6 +33,6 @@ public class MapCommand extends CommandBase<ClansManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
Plugin.getItemMapManager().setMap(caller); //Plugin.getItemMapManager().setMap(caller);
} }
} }

View File

@ -469,13 +469,13 @@ public class NetherManager extends MiniPlugin
} }
} }
UtilServer.getPlayersCollection() // UtilServer.getPlayersCollection()
.stream() // .stream()
.filter(player -> isInNether(player)) // .filter(player -> isInNether(player))
.forEach(player -> // .forEach(player ->
{ // {
ClansManager.getInstance().getItemMapManager().removeMap(player); // ClansManager.getInstance().getItemMapManager().removeMap(player);
}); // });
} }
} }

View File

@ -157,17 +157,17 @@ public class RaidManager extends MiniPlugin
@EventHandler @EventHandler
public void update(UpdateEvent event) public void update(UpdateEvent event)
{ {
if (event.getType() == UpdateType.TICK) // if (event.getType() == UpdateType.TICK)
{ // {
UtilServer.getPlayersCollection() // UtilServer.getPlayersCollection()
.stream() // .stream()
.filter(player -> isInRaid(player.getLocation())) // .filter(player -> isInRaid(player.getLocation()))
.forEach(player -> // .forEach(player ->
{ // {
ClansManager.getInstance().getItemMapManager().removeMap(player); // ClansManager.getInstance().getItemMapManager().removeMap(player);
}); // });
return; // return;
} // }
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
{ {
return; return;

View File

@ -128,7 +128,7 @@ public class ClansMainTutorial extends Tutorial
player.teleport(Spawn.getNorthSpawn()); player.teleport(Spawn.getNorthSpawn());
UtilInv.Clear(player); UtilInv.Clear(player);
ClansManager.getInstance().getItemMapManager().setMap(player); // ClansManager.getInstance().getItemMapManager().setMap(player);
}, 20 * 10L); }, 20 * 10L);
player.setWalkSpeed(0.2F); player.setWalkSpeed(0.2F);

View File

@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Location;
public class WorldManager extends MiniPlugin public class WorldManager extends MiniPlugin
{ {
@ -77,6 +78,9 @@ public class WorldManager extends MiniPlugin
{ {
List<Player> players = world.getPlayers(); List<Player> players = world.getPlayers();
Map<EntityType, Set<Entity>> entities = new HashMap<>(); Map<EntityType, Set<Entity>> entities = new HashMap<>();
// For optimization reasons reuse location objects
Location entityLocation = new Location(world, 0, 0, 0);
Location playerLocation = new Location(world, 0, 0, 0);
for (Entity entity : world.getEntities()) for (Entity entity : world.getEntities())
{ {
@ -104,11 +108,11 @@ public class WorldManager extends MiniPlugin
else if (CULL_LIMITS.containsKey(entityType)) else if (CULL_LIMITS.containsKey(entityType))
{ {
boolean cull = true; boolean cull = true;
entity.getLocation(entityLocation);
for (Player player : players) for (Player player : players)
{ {
// Using NMS because this is going to be called quite a few times player.getLocation(playerLocation);
// and each getLocation() call creates a new Location object if (playerLocation.distanceSquared(entityLocation) <= MIN_RANGE_SQUARED)
if (UtilWorld.distanceSquared(player, entity) <= MIN_RANGE_SQUARED)
{ {
cull = false; cull = false;
break; break;

View File

@ -14,9 +14,13 @@
<artifactId>mineplex-mapparser</artifactId> <artifactId>mineplex-mapparser</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>mineplex-core-common</artifactId> <artifactId>mineplex-core-common-base</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -23,9 +24,8 @@ import com.google.common.collect.Sets;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlockBase;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.command.AddLoreCommand; import mineplex.mapparser.command.AddLoreCommand;
import mineplex.mapparser.command.AddSplashTextCommand; import mineplex.mapparser.command.AddSplashTextCommand;
import mineplex.mapparser.command.AdminCommand; import mineplex.mapparser.command.AdminCommand;
@ -144,7 +144,7 @@ public class MapParser extends JavaPlugin
public void sendValidGameTypes(Player player) public void sendValidGameTypes(Player player)
{ {
UtilPlayer.message(player, F.main("Parser", "Valid Game Types;")); UtilPlayerBase.message(player, F.main("Parser", "Valid Game Types;"));
String gameTypes = ""; String gameTypes = "";
@ -256,7 +256,7 @@ public class MapParser extends JavaPlugin
public void announce(String msg) public void announce(String msg)
{ {
for (Player player : UtilServer.getPlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
player.sendMessage(C.cGold + msg); player.sendMessage(C.cGold + msg);
} }
@ -390,7 +390,7 @@ public class MapParser extends JavaPlugin
if (!blocks.add(current)) if (!blocks.add(current))
return blocks; return blocks;
for (Block other : UtilBlock.getSurrounding(current, true)) for (Block other : UtilBlockBase.getSurrounding(current, true))
{ {
if (current.getType() != Material.LOG && current.getType() != Material.LEAVES) if (current.getType() != Material.LOG && current.getType() != Material.LEAVES)
continue; continue;

View File

@ -1,6 +1,5 @@
package mineplex.mapparser; package mineplex.mapparser;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.ZipUtil; import mineplex.core.common.util.ZipUtil;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -24,7 +23,7 @@ public class WorldManager
public World prepMapParse(World world) public World prepMapParse(World world)
{ {
//Unload World //Unload World
MapUtil.UnloadWorld(Host, world, true); Host.getServer().unloadWorld(world, true);
//Delete Non-Map Files //Delete Non-Map Files
String[] folders = new File(world.getName()).list(); String[] folders = new File(world.getName()).list();
@ -69,7 +68,7 @@ public class WorldManager
public void finalizeParsedWorld(World world) public void finalizeParsedWorld(World world)
{ {
MapUtil.UnloadWorld(Host, world, true); Host.getServer().unloadWorld(world, true);
ArrayList<String> fileList = new ArrayList<String>(); ArrayList<String> fileList = new ArrayList<String>();
ArrayList<String> dirList = new ArrayList<String>(); ArrayList<String> dirList = new ArrayList<String>();

View File

@ -4,7 +4,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapData; import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
@ -42,7 +42,7 @@ public class AdminCommand extends BaseCommand
return true; return true;
} }
Player other = UtilPlayer.searchOnline(player, args[0], true); Player other = UtilPlayerBase.searchOnline(player, args[0], true);
if (player != null) if (player != null)
{ {

View File

@ -6,7 +6,7 @@ import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
/** /**
@ -59,6 +59,6 @@ public abstract class BaseCommand
protected void message(Player player, String message) protected void message(Player player, String message)
{ {
UtilPlayer.message(player, F.main("Parser", message)); UtilPlayerBase.message(player, F.main("Parser", message));
} }
} }

View File

@ -7,7 +7,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType; import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -73,7 +72,7 @@ public class CopyCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation()); other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for copy..."); message(other, "Unloading world for copy...");
} }
MapUtil.UnloadWorld(getPlugin(), world, true); getPlugin().getServer().unloadWorld(world, true);
} }
File source = new File(worldName); File source = new File(worldName);

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType; import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -66,7 +65,7 @@ public class DeleteCommand extends BaseCommand
//Unload World //Unload World
//Things break if this isn't set to true for saving the world //Things break if this isn't set to true for saving the world
MapUtil.UnloadWorld(getPlugin(), world, true); getPlugin().getServer().unloadWorld(world, true);
} }
//Delete //Delete

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType; import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData; import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
@ -69,7 +68,7 @@ public class GameTypeCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation()); other.teleport(getPlugin().getSpawnLocation());
message(player, "Unloading world for rename..."); message(player, "Unloading world for rename...");
} }
MapUtil.UnloadWorld(getPlugin(), world, true); getPlugin().getServer().unloadWorld(world, true);
File typeFolder = new File("map/" + type.GetName()); File typeFolder = new File("map/" + type.GetName());
if (!typeFolder.exists()) if (!typeFolder.exists())

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.GameType; import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
@ -28,7 +28,7 @@ public class ListCommand extends BaseCommand
{ {
if (args.length == 0) if (args.length == 0)
{ {
UtilPlayer.message(player, F.main("Parser", "Listing Maps;")); UtilPlayerBase.message(player, F.main("Parser", "Listing Maps;"));
boolean colorSwitch = false; boolean colorSwitch = false;
@ -60,7 +60,7 @@ public class ListCommand extends BaseCommand
} }
} }
UtilPlayer.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName()))); UtilPlayerBase.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName())));
listMaps(player, gameType, false); listMaps(player, gameType, false);
} }

View File

@ -1,7 +1,7 @@
package mineplex.mapparser.command; package mineplex.mapparser.command;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.GameType; import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData; import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
@ -32,7 +32,7 @@ public class MapCommand extends BaseCommand
{ {
if (args.length < 1) if (args.length < 1)
{ {
//UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName> [GameType]"))); //UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName> [GameType]")));
return false; return false;
} }
@ -50,7 +50,7 @@ public class MapCommand extends BaseCommand
{ {
message(player, "Found more than one possible match:"); message(player, "Found more than one possible match:");
for (String s : possibleMaps) for (String s : possibleMaps)
UtilPlayer.message(player, s); UtilPlayerBase.message(player, s);
return true; return true;
} }
@ -126,9 +126,9 @@ public class MapCommand extends BaseCommand
MapData data = getPlugin().getData(worldName); MapData data = getPlugin().getData(worldName);
UtilPlayer.message(player, F.value("Map Name", data.MapName)); UtilPlayerBase.message(player, F.value("Map Name", data.MapName));
UtilPlayer.message(player, F.value("Author", data.MapCreator)); UtilPlayerBase.message(player, F.value("Author", data.MapCreator));
UtilPlayer.message(player, F.value("Game Type", data.MapGameType.GetName())); UtilPlayerBase.message(player, F.value("Game Type", data.MapGameType.GetName()));
return true; return true;
} }
} }

View File

@ -2,7 +2,6 @@ package mineplex.mapparser.command;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,14 +37,14 @@ public class PMCommand extends BaseCommand
{ {
builder.append(s).append(" "); builder.append(s).append(" ");
} }
for (Player ops : UtilServer.getPlayers()) for (Player ops : getPlugin().getServer().getOnlinePlayers())
{ {
if (!ops.isOp()) if (!ops.isOp())
{ {
continue; continue;
} }
ops.sendMessage(F.main("Message", builder.toString().trim())); ops.sendMessage(F.main("Message", builder.toString().trim()));
ops.playSound(ops.getLocation(), Sound.NOTE_PLING, 1.0f, 1.0f); ops.playSound(ops.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f);
} }
return true; return true;

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.MapData; import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
@ -56,7 +55,7 @@ public class RenameCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation()); other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for rename..."); message(other, "Unloading world for rename...");
} }
MapUtil.UnloadWorld(getPlugin(), world, true); getPlugin().getServer().unloadWorld(world, true);
message(player, "World unloaded!"); message(player, "World unloaded!");

View File

@ -6,8 +6,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
/** /**
@ -37,7 +36,7 @@ public class SaveCommand extends BaseCommand
{ {
message(player, "More than one map found:"); message(player, "More than one map found:");
for (String s : possibleMaps) for (String s : possibleMaps)
UtilPlayer.message(player, s); UtilPlayerBase.message(player, s);
return true; return true;
} }
@ -63,7 +62,7 @@ public class SaveCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation()); other.teleport(getPlugin().getSpawnLocation());
//Unload World //Unload World
MapUtil.UnloadWorld(getPlugin(), world, true); getPlugin().getServer().unloadWorld(world, true);
} }
else else
{ {

View File

@ -3,8 +3,6 @@ package mineplex.mapparser.command;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
/** /**

View File

@ -2,7 +2,7 @@ package mineplex.mapparser.module.modules;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
import mineplex.mapparser.command.BaseCommand; import mineplex.mapparser.command.BaseCommand;
import mineplex.mapparser.module.Module; import mineplex.mapparser.module.Module;
@ -38,7 +38,7 @@ public class CommandModule extends Module
if (getPlugin().getCurParse() != null) if (getPlugin().getCurParse() != null)
{ {
UtilPlayer.message(player, F.main("Parser", "Cannot use commands during Map Parse!")); UtilPlayerBase.message(player, F.main("Parser", "Cannot use commands during Map Parse!"));
return; return;
} }
if (event.getMessage().toLowerCase().startsWith("/help")) if (event.getMessage().toLowerCase().startsWith("/help"))
@ -83,8 +83,8 @@ public class CommandModule extends Module
if (!baseCommand.execute(player, commandLabel, args)) if (!baseCommand.execute(player, commandLabel, args))
{ {
UtilPlayer.message(player, F.main("Parser", "Invalid Input.")); UtilPlayerBase.message(player, F.main("Parser", "Invalid Input."));
UtilPlayer.message(player, F.elem(baseCommand.getUsage())); UtilPlayerBase.message(player, F.elem(baseCommand.getUsage()));
} }
} }

View File

@ -27,9 +27,7 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilPlayerBase;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.BackupTask; import mineplex.mapparser.BackupTask;
import mineplex.mapparser.MapData; import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser; import mineplex.mapparser.MapParser;
@ -135,7 +133,7 @@ public class EventModule extends Module
if (world.getPlayers().isEmpty()) if (world.getPlayers().isEmpty())
{ {
getPlugin().announce("Saving & Closing World: " + F.elem(world.getName())); getPlugin().announce("Saving & Closing World: " + F.elem(world.getName()));
MapUtil.UnloadWorld(getPlugin(), world, true); getPlugin().getServer().unloadWorld(world, true);
_updated.remove(world); _updated.remove(world);
getPlugin()._mapsBeingZipped.add(world.getName()); getPlugin()._mapsBeingZipped.add(world.getName());
System.out.println("Starting backup of " + world); System.out.println("Starting backup of " + world);
@ -164,7 +162,7 @@ public class EventModule extends Module
String grayName = C.cBlue + event.getPlayer().getName(); String grayName = C.cBlue + event.getPlayer().getName();
String grayWorld = C.cBlue + C.Bold + event.getPlayer().getWorld().getName(); String grayWorld = C.cBlue + C.Bold + event.getPlayer().getWorld().getName();
for (Player player : UtilServer.getPlayers()) for (Player player : getPlugin().getServer().getOnlinePlayers())
{ {
if (player.getWorld().equals(event.getPlayer().getWorld())) if (player.getWorld().equals(event.getPlayer().getWorld()))
{ {
@ -212,7 +210,7 @@ public class EventModule extends Module
event.setCancelled(true); event.setCancelled(true);
Player target = UtilPlayer.searchOnline(player, tokens[1], true); Player target = UtilPlayerBase.searchOnline(player, tokens[1], true);
if (target != null) if (target != null)
{ {
if (!target.getWorld().getName().equals("world")) if (!target.getWorld().getName().equals("world"))
@ -224,7 +222,7 @@ public class EventModule extends Module
return; return;
} }
} }
UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + ".")); UtilPlayerBase.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + "."));
player.teleport(target); player.teleport(target);
} }
} }
@ -246,7 +244,7 @@ public class EventModule extends Module
//Permission //Permission
if (!getPlugin().getData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer())) if (!getPlugin().getData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{ {
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map.")); UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -276,10 +274,10 @@ public class EventModule extends Module
player.setFlySpeed(speed); player.setFlySpeed(speed);
UtilPlayer.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + ".")); UtilPlayerBase.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + "."));
} catch (Exception e) } catch (Exception e)
{ {
UtilPlayer.message(player, F.main("Game", "Invalid Speed Input.")); UtilPlayerBase.message(player, F.main("Game", "Invalid Speed Input."));
} }
} }

View File

@ -63,6 +63,8 @@ import nautilus.game.arcade.game.games.minestrike.Minestrike;
import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike; import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaClassic;
import nautilus.game.arcade.game.games.moba.training.MobaTraining;
import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monsterleague.MonsterLeague;
import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare; import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
@ -232,7 +234,8 @@ public enum GameType
AlienInvasion(AlienInvasion.class, GameDisplay.AlienInvasion), AlienInvasion(AlienInvasion.class, GameDisplay.AlienInvasion),
MOBA(Moba.class, GameDisplay.MOBA), MOBA(MobaClassic.class, GameDisplay.MOBA),
MOBATraining(MobaTraining.class, GameDisplay.MOBATraining),
Event(EventGame.class, GameDisplay.Event, new GameType[]{ Event(EventGame.class, GameDisplay.Event, new GameType[]{
GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build,

View File

@ -14,7 +14,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Crypt public class Crypt
{ {
@ -42,10 +43,10 @@ public class Crypt
{ {
if(isDestroyed()) return false; if(isDestroyed()) return false;
Integer lastTime = _damageCooldown.get(mob); Integer lastTime = _damageCooldown.get(mob);
if(lastTime != null && lastTime > UtilTime.getServerTick()) return false; if(lastTime != null && lastTime > MinecraftServer.currentTick) return false;
_health -= damage; _health -= damage;
_damageCooldown.put(mob, UtilTime.getServerTick() + cooldown); _damageCooldown.put(mob, MinecraftServer.currentTick + cooldown);
updateState(damage); updateState(damage);

View File

@ -4,11 +4,9 @@ import mineplex.core.Managers;
import mineplex.core.beta.BetaWhitelist; import mineplex.core.beta.BetaWhitelist;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.Leaderboard;
@ -23,7 +21,6 @@ import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.BossManager;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain;
import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager;
@ -46,7 +43,6 @@ import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena;
import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.minion.MinionManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
import nautilus.game.arcade.game.games.moba.recall.Recall;
import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.shop.MobaShop;
import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager;
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
@ -55,13 +51,10 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -76,34 +69,30 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
public class Moba extends TeamGame public class Moba extends TeamGame
{ {
private static final String[] DESCRIPTION = {
"..."
};
private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1);
private final HeroKit[] _kits; private final HeroKit[] _kits;
private final Set<MobaPlayer> _playerData = new HashSet<>(); private final Set<MobaPlayer> _playerData = new HashSet<>();
private final Set<Listener> _listeners = new HashSet<>(); private final Set<Listener> _listeners = new HashSet<>();
private final MobaShop _shop; protected final MobaShop _shop;
private final GoldManager _goldManager; protected final GoldManager _goldManager;
private final BossManager _boss; protected final BossManager _boss;
private final TowerManager _tower; protected final BuffManager _buffs;
private final CapturePointManager _capturePoint; protected final ArrowKBManager _arrowKb;
private final ArrowKBManager _arrowKb; protected final TowerManager _tower;
private final BuffManager _buffs; protected final CapturePointManager _capturePoint;
protected final MinionManager _minion;
private BetaWhitelist _betaWhitelist; private BetaWhitelist _betaWhitelist;
public Moba(ArcadeManager manager) private int _inPlayers;
public Moba(ArcadeManager manager, GameType gameType, String[] description)
{ {
super(manager, GameType.MOBA, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); super(manager, gameType, new Kit[]{new KitPlayer(manager)}, description);
_kits = new HeroKit[]{ _kits = new HeroKit[]{
new HeroHattori(Manager), new HeroHattori(Manager),
@ -118,16 +107,7 @@ public class Moba extends TeamGame
}; };
AllowParticles = false; AllowParticles = false;
DontAllowOverfill = true;
PrepareAutoAnnounce = false;
PrepareFreeze = false;
PrepareTime = PREPARE_TIME;
DeathOut = false;
DeathSpectateSecs = 12;
HungerSet = 20;
DamageFall = false;
manager.getCosmeticManager().setHideParticles(true);
manager.GetCreature().SetDisableCustomDrops(true); manager.GetCreature().SetDisableCustomDrops(true);
// Instantiate managers // Instantiate managers
@ -135,34 +115,19 @@ public class Moba extends TeamGame
// Global managers // Global managers
_shop = registerManager(new MobaShop(this)); _shop = registerManager(new MobaShop(this));
_goldManager = registerManager(new GoldManager(this)); _goldManager = registerManager(new GoldManager(this));
_boss = registerManager(new BossManager(this));
_buffs = registerManager(new BuffManager());
_arrowKb = registerManager(new ArrowKBManager(this));
_minion = registerManager(new MinionManager(this));
registerManager(new HPManager(this)); registerManager(new HPManager(this));
registerManager(new MobaDamageManager(this)); registerManager(new MobaDamageManager(this));
registerManager(new MobaFountain(this)); registerManager(new MobaFountain(this));
registerManager(new Recall(this)); registerManager(new EnderPearlManager());
// Pregame managers
registerManager(new PrepareManager(this));
registerManager(new PrepareSelection(this));
// Bosses
_boss = registerManager(new BossManager(this));
// Structures // Structures
_tower = registerManager(new TowerManager(this)); _tower = registerManager(new TowerManager(this));
_capturePoint = registerManager(new CapturePointManager(this)); _capturePoint = registerManager(new CapturePointManager(this));
// Minions
registerManager(new MinionManager(this));
// Arrow Knockback
_arrowKb = registerManager(new ArrowKBManager(this));
// Ender Pearls
registerManager(new EnderPearlManager());
// Buffs
_buffs = registerManager(new BuffManager());
// Beta Message // Beta Message
registerManager(new BetaManager(this)); registerManager(new BetaManager(this));
@ -183,66 +148,6 @@ public class Moba extends TeamGame
.setGiveCompassToAlive(false) .setGiveCompassToAlive(false)
.register(this); .register(this);
new CustomScoreboardModule()
.setSidebar((player, scoreboard) ->
{
GameState state = GetState();
switch (state)
{
case Prepare:
writePrepare(player, scoreboard);
break;
case Live:
writeLive(player, scoreboard);
break;
}
})
.setPrefix((perspective, subject) ->
{
if (!IsAlive(subject))
{
return C.cGray;
}
GameTeam team = GetTeam(subject);
return team.GetColor().toString();
})
.setSuffix((perspective, subject) ->
{
GameState state = GetState();
GameTeam perspectiveTeam = GetTeam(perspective);
GameTeam subjectTeam = GetTeam(subject);
if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null)
{
return "";
}
MobaPlayer mobaPlayer = getMobaData(subject);
String suffix;
if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam))
{
suffix = C.cYellow + " Unknown";
}
else if (mobaPlayer.getKit() == null)
{
suffix = C.cYellow + " Selecting";
}
else
{
suffix = mobaPlayer.getRole().getChatColor() + " " + mobaPlayer.getKit().GetName();
}
return suffix + C.Reset;
})
.setUnderNameObjective(C.cRed + "")
.setUnderName((perspective, subject) ->
(int) (Math.ceil(subject.getHealth() / 2D)))
.register(this);
registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) registerDebugCommand(new DebugCommand("kit", Rank.ADMIN)
{ {
@Override @Override
@ -271,7 +176,7 @@ public class Moba extends TeamGame
}); });
} }
private <T extends Listener> T registerManager(T listener) protected <T extends Listener> T registerManager(T listener)
{ {
_listeners.add(listener); _listeners.add(listener);
return listener; return listener;
@ -330,97 +235,6 @@ public class Moba extends TeamGame
} }
} }
private void writePrepare(Player player, GameScoreboard scoreboard)
{
MobaPlayer mobaPlayer = getMobaData(player);
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Hero Selection");
scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis()));
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Hero");
scoreboard.write((mobaPlayer == null || mobaPlayer.getKit() == null) ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")");
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Players");
int kits = 0;
for (MobaPlayer otherMobaPlayer : _playerData)
{
if (otherMobaPlayer.getKit() != null)
{
kits++;
}
}
scoreboard.write(kits + "/" + GetPlayers(true).size());
scoreboard.writeNewLine();
}
private void writeLive(Player player, GameScoreboard scoreboard)
{
GameTeam team = GetTeam(player);
boolean alive = IsAlive(player);
scoreboard.writeNewLine();
// Towers
GameTeam red = GetTeam(ChatColor.RED);
GameTeam blue = GetTeam(ChatColor.AQUA);
String redTitle;
String blueTitle;
if (alive)
{
boolean playerRed = team.equals(red);
redTitle = playerRed ? "Your Team" : "Enemy Team";
blueTitle = playerRed ? "Enemy Team" : "Your Team";
}
else
{
redTitle = "Red Team";
blueTitle = "Blue Team";
}
scoreboard.write(red.GetColor() + C.Bold + redTitle);
scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red));
scoreboard.writeNewLine();
scoreboard.write(blue.GetColor() + C.Bold + blueTitle);
scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue));
scoreboard.writeNewLine();
scoreboard.write(C.cGreenB + "Beacons");
scoreboard.write(_capturePoint.getDisplayString());
scoreboard.writeNewLine();
// Gold
scoreboard.write(C.cGoldB + "Your Gold");
if (alive)
{
int gold = _goldManager.getGold(player);
scoreboard.write(String.valueOf(gold));
}
else
{
scoreboard.write("None");
}
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Time");
scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime()));
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void prepare(GameStateChangeEvent event) public void prepare(GameStateChangeEvent event)
{ {
@ -445,7 +259,7 @@ public class Moba extends TeamGame
{ {
Player player = event.GetPlayer(); Player player = event.GetPlayer();
if (GetPlayers(true).size() > 8) if (++_inPlayers > 8)
{ {
SetPlayerState(player, GameTeam.PlayerState.OUT); SetPlayerState(player, GameTeam.PlayerState.OUT);
Manager.addSpectator(player, true); Manager.addSpectator(player, true);
@ -453,68 +267,6 @@ public class Moba extends TeamGame
} }
} }
@Override
public void EndCheck()
{
if (!IsLive())
{
return;
}
// Only one team online check
List<GameTeam> teamsWithPlayers = new ArrayList<>(GetTeamList().size());
for (GameTeam team : GetTeamList())
{
if (team.GetPlayers(true).isEmpty())
{
continue;
}
teamsWithPlayers.add(team);
}
if (teamsWithPlayers.size() == 1)
{
AnnounceEnd(teamsWithPlayers.get(0));
SetState(GameState.End);
return;
}
// Wither Dead check
for (GameTeam team : GetTeamList())
{
WitherBoss boss = _boss.getWitherBoss(team);
LivingEntity entity = boss.getEntity();
// Dead Wither
if (entity == null || !entity.isValid() || entity.isDead())
{
// Get the other team
for (GameTeam otherTeam : GetTeamList())
{
for (Player player : otherTeam.GetPlayers(true))
{
AddGems(player, 10, "Participation", false, false);
}
if (team.equals(otherTeam))
{
continue;
}
for (Player player : otherTeam.GetPlayers(true))
{
AddGems(player, 20, "Winning", false, false);
}
AnnounceEnd(otherTeam);
SetState(GameState.End);
}
}
}
}
@Override @Override
public void RespawnPlayer(Player player) public void RespawnPlayer(Player player)
{ {
@ -529,6 +281,17 @@ public class Moba extends TeamGame
_listeners.forEach(UtilServer::Unregister); _listeners.forEach(UtilServer::Unregister);
_listeners.clear(); _listeners.clear();
_betaWhitelist.deregisterSelf(); _betaWhitelist.deregisterSelf();
// Undisguise all players
for (Player player : Bukkit.getOnlinePlayers())
{
DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);
if (disguise != null && disguise instanceof DisguisePlayer)
{
Manager.GetDisguise().undisguise(disguise);
}
}
} }
@Override @Override
@ -567,26 +330,6 @@ public class Moba extends TeamGame
} }
} }
// Undisguise everyone upon game end
@EventHandler
public void end(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End && event.GetState() != GameState.Dead)
{
return;
}
for (Player player : Bukkit.getOnlinePlayers())
{
DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player);
if (disguise != null && disguise instanceof DisguisePlayer)
{
Manager.GetDisguise().undisguise(disguise);
}
}
}
public Map<String, Location> getLocationStartsWith(String s) public Map<String, Location> getLocationStartsWith(String s)
{ {
Map<String, Location> map = new HashMap<>(); Map<String, Location> map = new HashMap<>();
@ -753,6 +496,11 @@ public class Moba extends TeamGame
return _goldManager; return _goldManager;
} }
public BuffManager getBuffManager()
{
return _buffs;
}
public TowerManager getTowerManager() public TowerManager getTowerManager()
{ {
return _tower; return _tower;
@ -772,9 +520,4 @@ public class Moba extends TeamGame
{ {
return _arrowKb; return _arrowKb;
} }
public BuffManager getBuffManager()
{
return _buffs;
}
} }

View File

@ -0,0 +1,263 @@
package nautilus.game.arcade.game.games.moba;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class MobaClassic extends Moba
{
private static final String[] DESCRIPTION = {
"Select your Role and Hero.",
"Kill the enemy Team!",
"Capture the Beacons to earn gold to spent in the shop!",
"Destroy the enemy's Towers and Wither!"
};
private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1);
public MobaClassic(ArcadeManager manager)
{
super(manager, GameType.MOBA, DESCRIPTION);
DontAllowOverfill = true;
PrepareAutoAnnounce = false;
PrepareFreeze = false;
PrepareTime = PREPARE_TIME;
DeathOut = false;
DeathSpectateSecs = 12;
HungerSet = 20;
DamageFall = false;
// Pregame managers
registerManager(new PrepareManager(this));
registerManager(new PrepareSelection(this));
new CustomScoreboardModule()
.setSidebar((player, scoreboard) ->
{
GameState state = GetState();
switch (state)
{
case Prepare:
writePrepare(player, scoreboard);
break;
case Live:
writeLive(player, scoreboard);
break;
}
})
.setPrefix((perspective, subject) ->
{
if (!IsAlive(subject))
{
return C.cGray;
}
GameTeam team = GetTeam(subject);
return team.GetColor().toString();
})
.setSuffix((perspective, subject) ->
{
GameState state = GetState();
GameTeam perspectiveTeam = GetTeam(perspective);
GameTeam subjectTeam = GetTeam(subject);
if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null)
{
return "";
}
MobaPlayer mobaPlayer = getMobaData(subject);
String suffix;
if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam))
{
suffix = C.cYellow + " Unknown";
}
else if (mobaPlayer.getKit() == null)
{
suffix = C.cYellow + " Selecting";
}
else
{
suffix = mobaPlayer.getRole().getChatColor() + " [" + mobaPlayer.getKit().GetName() + "]";
}
return suffix + C.Reset;
})
.setUnderNameObjective(C.cRed + "")
.setUnderName((perspective, subject) ->
(int) (Math.ceil(subject.getHealth() / 2D)))
.register(this);
}
private void writePrepare(Player player, GameScoreboard scoreboard)
{
MobaPlayer mobaPlayer = getMobaData(player);
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Hero Selection");
scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis()));
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Hero");
scoreboard.write((mobaPlayer == null || mobaPlayer.getKit() == null) ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")");
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Players");
int kits = 0;
for (MobaPlayer otherMobaPlayer : getMobaData())
{
if (otherMobaPlayer.getKit() != null)
{
kits++;
}
}
scoreboard.write(kits + "/" + GetPlayers(true).size());
scoreboard.writeNewLine();
}
private void writeLive(Player player, GameScoreboard scoreboard)
{
GameTeam team = GetTeam(player);
boolean alive = IsAlive(player);
scoreboard.writeNewLine();
// Towers
GameTeam red = GetTeam(ChatColor.RED);
GameTeam blue = GetTeam(ChatColor.AQUA);
String redTitle;
String blueTitle;
if (alive)
{
boolean playerRed = team.equals(red);
redTitle = playerRed ? "Your Team" : "Enemy Team";
blueTitle = playerRed ? "Enemy Team" : "Your Team";
}
else
{
redTitle = "Red Team";
blueTitle = "Blue Team";
}
scoreboard.write(red.GetColor() + C.Bold + redTitle);
scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red));
scoreboard.writeNewLine();
scoreboard.write(blue.GetColor() + C.Bold + blueTitle);
scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue));
scoreboard.writeNewLine();
scoreboard.write(C.cGreenB + "Beacons");
scoreboard.write(_capturePoint.getDisplayString());
scoreboard.writeNewLine();
// Gold
scoreboard.write(C.cGoldB + "Your Gold");
if (alive)
{
int gold = _goldManager.getGold(player);
scoreboard.write(String.valueOf(gold));
}
else
{
scoreboard.write("None");
}
scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Time");
scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime()));
}
@Override
public void EndCheck()
{
if (!IsLive())
{
return;
}
// Only one team online check
List<GameTeam> teamsWithPlayers = new ArrayList<>(GetTeamList().size());
for (GameTeam team : GetTeamList())
{
if (team.GetPlayers(true).isEmpty())
{
continue;
}
teamsWithPlayers.add(team);
}
if (teamsWithPlayers.size() == 1)
{
AnnounceEnd(teamsWithPlayers.get(0));
SetState(GameState.End);
return;
}
// Wither Dead check
for (GameTeam team : GetTeamList())
{
WitherBoss boss = _boss.getWitherBoss(team);
LivingEntity entity = boss.getEntity();
// Dead Wither
if (entity == null || !entity.isValid() || entity.isDead())
{
// Get the other team
for (GameTeam otherTeam : GetTeamList())
{
for (Player player : otherTeam.GetPlayers(true))
{
AddGems(player, 10, "Participation", false, false);
}
if (team.equals(otherTeam))
{
continue;
}
for (Player player : otherTeam.GetPlayers(true))
{
AddGems(player, 20, "Winning", false, false);
}
AnnounceEnd(otherTeam);
SetState(GameState.End);
}
}
}
}
}

View File

@ -32,6 +32,7 @@ public class MobaPlayer
public void setKit(HeroKit kit) public void setKit(HeroKit kit)
{ {
_role = kit.getRole();
_kit = kit; _kit = kit;
} }

View File

@ -6,7 +6,7 @@ import org.bukkit.Color;
public enum MobaRole public enum MobaRole
{ {
ASSASSIN("Assassin", Color.GRAY, ChatColor.DARK_GRAY), ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY),
HUNTER("Hunter", Color.LIME, ChatColor.GREEN), HUNTER("Hunter", Color.LIME, ChatColor.GREEN),
MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE),
WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD),

View File

@ -1,14 +1,19 @@
package nautilus.game.arcade.game.games.moba.ai; package nautilus.game.arcade.game.games.moba.ai;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import mineplex.core.common.geom.Point2D;
import mineplex.core.common.geom.Polygon2D;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod;
import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import java.util.List;
public class MobaAI public class MobaAI
{ {
@ -16,7 +21,7 @@ public class MobaAI
private final GameTeam _owner; private final GameTeam _owner;
private final float _speedTarget; private final float _speedTarget;
private final float _speedHome; private final float _speedHome;
private final List<Location> _boundaries; private final Polygon2D _boundaries;
private LivingEntity _entity; private LivingEntity _entity;
private LivingEntity _target; private LivingEntity _target;
@ -32,7 +37,12 @@ public class MobaAI
_entity = entity; _entity = entity;
_home = home; _home = home;
_aiMethod = aiMethod; _aiMethod = aiMethod;
_boundaries = host.WorldData.GetDataLocs(getBoundaryKey());
List<Point2D> boundaryPoints = host.WorldData.GetDataLocs(getBoundaryKey()).stream()
.map(Point2D::of)
.collect(Collectors.toList());
_boundaries = Polygon2D.fromUnorderedPoints(boundaryPoints);
} }
public void updateTarget() public void updateTarget()
@ -80,7 +90,7 @@ public class MobaAI
return _target; return _target;
} }
public List<Location> getBoundaries() public Polygon2D getBoundaries()
{ {
return _boundaries; return _boundaries;
} }

View File

@ -24,6 +24,8 @@ public class BossManager implements Listener
private Map<GameTeam, WitherBoss> _teamBosses; private Map<GameTeam, WitherBoss> _teamBosses;
private PumpkinBoss _pumpkinBoss; private PumpkinBoss _pumpkinBoss;
private boolean _dummyBosses;
public BossManager(Moba host) public BossManager(Moba host)
{ {
_host = host; _host = host;
@ -32,6 +34,11 @@ public class BossManager implements Listener
private void spawnBosses() private void spawnBosses()
{ {
if (_dummyBosses)
{
return;
}
_host.CreatureAllowOverride = true; _host.CreatureAllowOverride = true;
WorldData worldData = _host.WorldData; WorldData worldData = _host.WorldData;
@ -72,7 +79,11 @@ public class BossManager implements Listener
} }
_teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup());
_pumpkinBoss.cleanup();
if (_pumpkinBoss != null)
{
_pumpkinBoss.cleanup();
}
} }
public String getWitherDisplayString(GameTeam team) public String getWitherDisplayString(GameTeam team)
@ -96,4 +107,9 @@ public class BossManager implements Listener
return bosses; return bosses;
} }
public void setDummyBosses(boolean dummyBosses)
{
_dummyBosses = dummyBosses;
}
} }

View File

@ -5,22 +5,16 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.MobaAI;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
public abstract class MobaBoss implements Listener public abstract class MobaBoss implements Listener
{ {
@ -85,7 +79,7 @@ public abstract class MobaBoss implements Listener
@EventHandler @EventHandler
public void updateMovement(UpdateEvent event) public void updateMovement(UpdateEvent event)
{ {
if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) if (event.getType() != UpdateType.TICK || !_host.IsLive())
{ {
return; return;
} }

View File

@ -44,7 +44,7 @@ public class WitherBoss extends MobaBoss
private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod();
private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30);
private GameTeam _team; private final GameTeam _team;
private MobaAI _ai; private MobaAI _ai;
private DisguiseWither _disguise; private DisguiseWither _disguise;
private boolean _damageable; private boolean _damageable;

View File

@ -1,39 +0,0 @@
package nautilus.game.arcade.game.games.moba.buff.buffs;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.Buff;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BuffCripple extends Buff<Player>
{
private static final ItemStack ITEM = new ItemBuilder(Material.IRON_INGOT)
.setTitle(C.cGray + "Crippled")
.build();
public static ItemStack getItemRepresentation()
{
return ITEM;
}
public BuffCripple(Moba host, Player entity, long duration)
{
super(host, entity, duration);
}
@Override
public void onApply()
{
UtilTextMiddle.display("", C.cRed + "Crippled", 10, 20, 10, _entity);
}
@Override
public void onExpire()
{
}
}

View File

@ -43,14 +43,7 @@ public class MobaDamageManager implements Listener
return; return;
} }
if (damageeTeam.equals(damagerTeam)) _host.getScoreboardModule().refreshAsSubject(damagee);
{
event.SetCancelled("Team Damage");
}
else
{
_host.getScoreboardModule().refreshAsSubject(damagee);
}
} }
@EventHandler @EventHandler

View File

@ -67,20 +67,6 @@ public class GoldManager implements Listener
}); });
} }
@EventHandler
public void prepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
for (Player player : _host.GetPlayers(true))
{
_playerGold.put(player, 0);
}
}
@EventHandler @EventHandler
public void playerQuit(PlayerQuitEvent event) public void playerQuit(PlayerQuitEvent event)
{ {
@ -146,7 +132,7 @@ public class GoldManager implements Listener
public int getGold(Player player) public int getGold(Player player)
{ {
return _playerGold.get(player); return _playerGold.getOrDefault(player, 0);
} }
public void addGold(Player player, int amount) public void addGold(Player player, int amount)
@ -156,6 +142,7 @@ public class GoldManager implements Listener
public void addGold(Player player, int amount, String reason) public void addGold(Player player, int amount, String reason)
{ {
_playerGold.putIfAbsent(player, 0);
_playerGold.put(player, _playerGold.get(player) + amount); _playerGold.put(player, _playerGold.get(player) + amount);
_host.getArcadeManager().GetStatsManager().incrementStat(player, _host.GetName() + ".GoldEarned", amount); _host.getArcadeManager().GetStatsManager().incrementStat(player, _host.GetName() + ".GoldEarned", amount);
@ -168,12 +155,13 @@ public class GoldManager implements Listener
public void removeGold(Player player, int amount) public void removeGold(Player player, int amount)
{ {
_playerGold.putIfAbsent(player, 0);
_playerGold.put(player, _playerGold.get(player) - amount); _playerGold.put(player, _playerGold.get(player) - amount);
} }
public boolean hasGold(Player player, int amount) public boolean hasGold(Player player, int amount)
{ {
return _playerGold.get(player) >= amount; return _playerGold.getOrDefault(player, 0) >= amount;
} }
} }

View File

@ -3,7 +3,6 @@ package nautilus.game.arcade.game.games.moba.kit;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import mineplex.core.common.skin.SkinData; import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -41,14 +40,10 @@ public class HeroKit extends Kit
private int _maxAmmo; private int _maxAmmo;
private SkinData _skin; private SkinData _skin;
private static final int RECALL_SLOT = 8; private static final int SHOP_SLOT = 8;
private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED)
.setTitle(C.cGreenB + "Recall to your Base")
.addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.")
.build();
private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT)
.setTitle(C.cGold + "Open Gold Upgrades") .setTitle(C.cGold + "Open Gold Upgrades")
.addLore("Click to open the Gold Upgrades", "shop while you are respawning.") .addLore("Click to open the Gold Upgrades Shop")
.build(); .build();
private boolean _visible = true; private boolean _visible = true;
@ -173,8 +168,7 @@ public class HeroKit extends Kit
// Give standard items // Give standard items
inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(AMMO_SLOT, _ammo);
//inventory.setItem(RECALL_SLOT, RECALL_ITEM); inventory.setItem(SHOP_SLOT, SHOP_ITEM);
inventory.setItem(RECALL_SLOT, SHOP_ITEM);
Moba game = (Moba) Manager.GetGame(); Moba game = (Moba) Manager.GetGame();
List<MobaItem> items = game.getShop().getOwnedItems(player); List<MobaItem> items = game.getShop().getOwnedItems(player);
@ -268,6 +262,11 @@ public class HeroKit extends Kit
Manager.GetDisguise().disguise(disguise); Manager.GetDisguise().disguise(disguise);
} }
public SkinData getSkinData()
{
return _skin;
}
public boolean isVisible() public boolean isVisible()
{ {
return _visible; return _visible;

View File

@ -14,7 +14,6 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple;
import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
@ -108,13 +107,13 @@ public class HeroSkill extends Perk
_item = new ItemBuilder(_item) _item = new ItemBuilder(_item)
.setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName())
.addLore(GetDesc()) .setLore(GetDesc())
.setUnbreakable(true) .setUnbreakable(true)
.build(); .build();
_cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8)
.setTitle(C.cRed + GetName()) .setTitle(C.cRed + GetName())
.addLore(GetDesc()) .setLore(GetDesc())
.setUnbreakable(true) .setUnbreakable(true)
.build(); .build();
} }
@ -280,13 +279,6 @@ public class HeroSkill extends Perk
boolean done = UtilTime.elapsed(start, cooldown); boolean done = UtilTime.elapsed(start, cooldown);
// If the player is crippled say they are
if (moba.getBuffManager().hasBuff(player, BuffCripple.class))
{
player.getInventory().setItem(_slot, BuffCripple.getItemRepresentation());
continue;
}
if (done) if (done)
{ {
_lastSkill.remove(player.getUniqueId()); _lastSkill.remove(player.getUniqueId());
@ -359,7 +351,12 @@ public class HeroSkill extends Perk
protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager)
{ {
if (!(damager instanceof Player)) if (damagee.equals(damager))
{
return true;
}
if (!(damager instanceof Player) || Manager.GetGame().DamageTeamSelf)
{ {
return false; return false;
} }

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.moba.kit.anath; package nautilus.game.arcade.game.games.moba.kit.anath;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaConstants;
@ -37,7 +38,7 @@ public class SkillFireProjectile extends HeroSkill
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!_kit.useAmmo(player, 1)) if (!Recharge.Instance.use(player, GetName(), 500, false, true) || !_kit.useAmmo(player, 1))
{ {
return; return;
} }

View File

@ -89,6 +89,12 @@ public class SkillFullMoon extends HeroSkill
kit.disguise(player); kit.disguise(player);
player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease());
ItemStack itemStack = player.getInventory().getItem(1);
if (itemStack != null)
{
itemStack.setAmount(1);
}
for (Wolf wolf : data.getWolves()) for (Wolf wolf : data.getWolves())
{ {
wolf.setHealth(0); wolf.setHealth(0);

View File

@ -20,7 +20,9 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.*; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
public class DashSkill extends HeroSkill public class DashSkill extends HeroSkill
@ -127,10 +129,12 @@ public class DashSkill extends HeroSkill
return; return;
} }
for (Entry<Player, Long> entry : _startTime.entrySet()) Iterator<Player> iterator = _startTime.keySet().iterator();
while (iterator.hasNext())
{ {
Player player = entry.getKey(); Player player = iterator.next();
long start = entry.getValue(); long start = _startTime.get(player);
if (UtilTime.elapsed(start, _velocityTime)) if (UtilTime.elapsed(start, _velocityTime))
{ {
@ -138,7 +142,8 @@ public class DashSkill extends HeroSkill
{ {
UtilAction.zeroVelocity(player); UtilAction.zeroVelocity(player);
} }
_startTime.remove(player);
iterator.remove();
postDash(player); postDash(player);
} }
else else

View File

@ -6,7 +6,6 @@ import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.game.games.moba.shop.MobaItem;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -33,7 +33,7 @@ public class SkillSnowball extends HeroSkill implements IThrown
{ {
super("Shuriken", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); super("Shuriken", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY);
setCooldown(1000); setCooldown(1500);
} }
@EventHandler @EventHandler

View File

@ -31,6 +31,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -81,6 +82,12 @@ public class SkillAOEHeal extends HeroSkill implements IThrown
Manager.GetProjectile().AddThrow(item, player, this, 1000, true, true, true, false, 1F); Manager.GetProjectile().AddThrow(item, player, this, 1000, true, true, true, false, 1F);
} }
@EventHandler
public void emptyBucket(PlayerBucketEmptyEvent event)
{
event.setCancelled(true);
}
@Override @Override
public void Collide(LivingEntity target, Block block, ProjectileUser data) public void Collide(LivingEntity target, Block block, ProjectileUser data)
{ {
@ -113,6 +120,13 @@ public class SkillAOEHeal extends HeroSkill implements IThrown
AOEHealData data = iterator.next(); AOEHealData data = iterator.next();
Player owner = data.Owner; Player owner = data.Owner;
GameTeam team = Manager.GetGame().GetTeam(owner); GameTeam team = Manager.GetGame().GetTeam(owner);
if (team == null)
{
iterator.remove();
continue;
}
DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? java.awt.Color.RED : java.awt.Color.CYAN); DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? java.awt.Color.RED : java.awt.Color.CYAN);
if (UtilTime.elapsed(data.Start, DURATION)) if (UtilTime.elapsed(data.Start, DURATION))

View File

@ -47,7 +47,7 @@ public class SkillAquaCannon extends HeroSkill
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!_kit.useAmmo(player, 1)) if (!Recharge.Instance.use(player, GetName(), 500, false, true) || !_kit.useAmmo(player, 1))
{ {
return; return;
} }

View File

@ -3,10 +3,6 @@ package nautilus.game.arcade.game.games.moba.kit.larissa;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple;
import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; import nautilus.game.arcade.game.games.moba.kit.common.DashSkill;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,7 +18,6 @@ public class SkillWaterDash extends DashSkill
"come into contact with." "come into contact with."
}; };
private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER);
private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3);
public SkillWaterDash(int slot) public SkillWaterDash(int slot)
{ {
@ -40,18 +35,6 @@ public class SkillWaterDash extends DashSkill
public void dashTick(Player player) public void dashTick(Player player)
{ {
UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 5, ViewDist.LONG); UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 5, ViewDist.LONG);
Moba moba = (Moba) Manager.GetGame();
BuffManager buffManager = moba.getBuffManager();
for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 2))
{
if (isTeamDamage(nearby, player) || buffManager.hasBuff(nearby, BuffCripple.class))
{
continue;
}
buffManager.apply(new BuffCripple(moba, nearby, CRIPPLE_DURATION));
}
} }
} }

View File

@ -148,10 +148,6 @@ public class SkillBombardment extends HeroSkill
data.Block.setType(Material.AIR); data.Block.setType(Material.AIR);
iterator.remove(); iterator.remove();
} }
else if (data.Block != null)
{
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.Block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.001F, 3, ViewDist.LONG);
}
} }
} }

View File

@ -127,7 +127,7 @@ public class SkillLightArrows extends HeroSkill
{ {
LineParticle lineParticle = iterator.next(); LineParticle lineParticle = iterator.next();
for (int i = 0; i < 4; i++) for (int i = 0; i < 6; i++)
{ {
if (!lineParticle.update()) if (!lineParticle.update())
{ {

View File

@ -4,11 +4,9 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
@ -17,9 +15,6 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent;
import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.PigZombie; import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
@ -36,7 +31,6 @@ import java.util.concurrent.TimeUnit;
public class MinionManager implements Listener public class MinionManager implements Listener
{ {
private static final int MINION_SPAWN_DELAY_TICKS = 40;
private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30); private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30);
private final Moba _host; private final Moba _host;
@ -51,6 +45,7 @@ public class MinionManager implements Listener
{ {
_host = host; _host = host;
_waves = new HashSet<>(); _waves = new HashSet<>();
_enabled = true;
host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER)
{ {
@ -67,12 +62,6 @@ public class MinionManager implements Listener
}); });
} }
@EventHandler
public void gameCountdownCommence(GamePrepareCountdownCommence event)
{
UtilServer.runSyncLater(() -> setEnabled(true), MINION_SPAWN_DELAY_TICKS);
}
@EventHandler @EventHandler
public void spawnMinions(UpdateEvent event) public void spawnMinions(UpdateEvent event)
{ {
@ -83,6 +72,11 @@ public class MinionManager implements Listener
_lastWave = System.currentTimeMillis(); _lastWave = System.currentTimeMillis();
if (_path == null)
{
preparePath();
}
for (GameTeam team : _host.GetTeamList()) for (GameTeam team : _host.GetTeamList())
{ {
List<Location> path = new ArrayList<>(_path); List<Location> path = new ArrayList<>(_path);
@ -131,14 +125,9 @@ public class MinionManager implements Listener
} }
} }
public void setEnabled(boolean enabled) public void disableMinions()
{ {
_enabled = enabled; _enabled = false;
if (enabled)
{
preparePath();
}
} }
public void unregisterWave(MinionWave wave) public void unregisterWave(MinionWave wave)

View File

@ -14,10 +14,8 @@ import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod;
import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.MobaBoss;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -27,15 +25,11 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.jooq.util.derby.sys.Sys;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
public class MinionWave implements Listener public class MinionWave implements Listener
{ {

View File

@ -112,8 +112,6 @@ public class PrepareSelection implements Listener, IPacketHandler
List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole()); List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole());
ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build();
UtilServer.runSyncLater(() -> UtilServer.runSyncLater(() ->
{ {
for (Location location : spawns.values()) for (Location location : spawns.values())
@ -126,10 +124,10 @@ public class PrepareSelection implements Listener, IPacketHandler
stand.setCustomNameVisible(true); stand.setCustomNameVisible(true);
stand.setCustomName(C.cGreenB + kit.GetName()); stand.setCustomName(C.cGreenB + kit.GetName());
stand.setArms(true); stand.setArms(true);
stand.setHelmet(head); stand.setHelmet(kit.getSkinData().getSkull());
// stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, kit.getRole()));
// stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, kit.getRole()));
// stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, kit.getRole()));
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 0.5F); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 0.5F);
UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 2, 0), 0.5F, 0.5F, 0.5F, 0.01F, 20, ViewDist.LONG, player); UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 2, 0), 0.5F, 0.5F, 0.5F, 0.01F, 20, ViewDist.LONG, player);

View File

@ -1,153 +0,0 @@
package nautilus.game.arcade.game.games.moba.recall;
import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class Recall implements Listener
{
private static final int RECALL_TIME = 5000;
private static final double PARTICLE_HEIGHT = 2.5;
private static final double PARTICLE_RADIUS = 1.5;
private final Moba _host;
private final Set<RecallSession> _sessions;
public Recall(Moba host)
{
_host = host;
_sessions = new HashSet<>();
}
@EventHandler
public void interactBed(PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
if (!UtilEvent.isAction(event, ActionType.R))
{
return;
}
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (itemStack == null || itemStack.getType() != Material.BED || getSession(player) != null)
{
return;
}
if (Recharge.Instance.use(player, "Recall", RECALL_TIME, false, true))
{
_sessions.add(new RecallSession(player));
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
{
return;
}
long now = System.currentTimeMillis();
for (Player player : _host.GetPlayers(true))
{
RecallSession session = getSession(player);
if (session == null)
{
continue;
}
if (UtilTime.elapsed(session.Start, RECALL_TIME))
{
_host.GetTeam(player).SpawnTeleport(player);
removeSession(player, null);
}
else if (UtilMath.offsetSquared(player.getLocation(), session.Location) > 4)
{
removeSession(player, "You moved!");
}
else
{
Location location = session.Location.clone();
double height = (double) (now - session.Start) / (double) RECALL_TIME;
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10)
{
double x = PARTICLE_RADIUS * Math.sin(theta);
double z = PARTICLE_RADIUS * Math.cos(theta);
for (double y = 0.25; y < height * PARTICLE_HEIGHT; y += 0.5)
{
location.add(x, y, z);
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG);
location.subtract(x, y, z);
}
}
}
}
}
@EventHandler
public void damage(CustomDamageEvent event)
{
if (event.GetDamageePlayer() == null)
{
return;
}
removeSession(event.GetDamageePlayer(), "You took damage!");
}
private void removeSession(Player player, String reason)
{
boolean had = _sessions.removeIf(session -> session.Player.equals(player));
if (had && reason != null)
{
player.sendMessage(F.main("Game", reason + " You recall has been cancelled"));
}
}
private RecallSession getSession(Player player)
{
for (RecallSession session : _sessions)
{
if (session.Player.equals(player))
{
return session;
}
}
return null;
}
}

View File

@ -1,19 +0,0 @@
package nautilus.game.arcade.game.games.moba.recall;
import org.bukkit.Location;
import org.bukkit.entity.Player;
class RecallSession
{
public Player Player;
public long Start;
public Location Location;
public RecallSession(Player player)
{
Player = player;
Start = System.currentTimeMillis();
Location = player.getLocation();
}
}

View File

@ -27,6 +27,7 @@ import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop;
import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaConstants;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -131,7 +132,7 @@ public class MobaShop implements Listener
LivingEntity entity = entry.getKey(); LivingEntity entity = entry.getKey();
Location location = entry.getValue(); Location location = entry.getValue();
((CraftLivingEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); ((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ());
} }
} }
@ -222,7 +223,7 @@ public class MobaShop implements Listener
} }
} }
_host.GetKit(player).ApplyKit(player); _host.GetKit(player).GiveItems(player);
} }
public boolean ownsItem(Player player, MobaItem item) public boolean ownsItem(Player player, MobaItem item)
@ -251,6 +252,11 @@ public class MobaShop implements Listener
return null; return null;
} }
public void clearPurchases(Player player)
{
_upgrades.put(player, new ArrayList<>());
}
@EventHandler @EventHandler
public void playerDeath(PlayerDeathEvent event) public void playerDeath(PlayerDeathEvent event)
{ {
@ -322,6 +328,11 @@ public class MobaShop implements Listener
Player player = event.getPlayer(); Player player = event.getPlayer();
List<MobaItem> items = _upgrades.get(player); List<MobaItem> items = _upgrades.get(player);
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)
@ -342,6 +353,11 @@ public class MobaShop implements Listener
Player player = event.getPlayer(); Player player = event.getPlayer();
List<MobaItem> items = _upgrades.get(player); List<MobaItem> items = _upgrades.get(player);
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)
@ -374,6 +390,11 @@ public class MobaShop implements Listener
List<MobaItem> items = _upgrades.get(damager); List<MobaItem> items = _upgrades.get(damager);
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)
@ -409,6 +430,11 @@ public class MobaShop implements Listener
List<MobaItem> items = _upgrades.get(killer); List<MobaItem> items = _upgrades.get(killer);
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)
@ -429,6 +455,11 @@ public class MobaShop implements Listener
Player player = event.getPlayer(); Player player = event.getPlayer();
List<MobaItem> items = _upgrades.get(player); List<MobaItem> items = _upgrades.get(player);
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)
@ -453,6 +484,11 @@ public class MobaShop implements Listener
List<MobaItem> items = _upgrades.get(event.getSource()); List<MobaItem> items = _upgrades.get(event.getSource());
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)
@ -473,6 +509,11 @@ public class MobaShop implements Listener
Player player = event.GetPlayer(); Player player = event.GetPlayer();
List<MobaItem> items = _upgrades.get(player); List<MobaItem> items = _upgrades.get(player);
if (items == null)
{
return;
}
for (MobaItem item : items) for (MobaItem item : items)
{ {
if (item.getEffects() == null) if (item.getEffects() == null)

View File

@ -30,7 +30,7 @@ public class MobaAssassinShop extends MobaShopMenu
.build(), 1000), .build(), 1000),
new MobaItem(new ItemBuilder(Material.DIAMOND_SWORD) new MobaItem(new ItemBuilder(Material.DIAMOND_SWORD)
.setTitle(C.cDRedB + "Pumpkin King's Blade") .setTitle(C.cDRedB + "Pumpkin King's Blade")
.addEnchantment(Enchantment.DAMAGE_ALL, 3) .addEnchantment(Enchantment.DAMAGE_ALL, 2)
.build(), 1750) .build(), 1750)
), new ItemStack(Material.WOOD_SWORD)); ), new ItemStack(Material.WOOD_SWORD));

View File

@ -20,7 +20,7 @@ public class MobaBasicAttackDamageEffect extends MobaItemEffect
@Override @Override
protected void onDamage(CustomDamageEvent event) protected void onDamage(CustomDamageEvent event)
{ {
if (!event.GetReason().contains(MobaConstants.BASIC_ATTACK)) if (event.GetReason() == null || !event.GetReason().contains(MobaConstants.BASIC_ATTACK))
{ {
return; return;
} }

View File

@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;

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