Merge remote-tracking branch 'refs/remotes/origin/develop' into feature/staff-titles

This commit is contained in:
Sam 2017-06-30 14:22:52 +01:00
commit 041d0020bd
116 changed files with 1751 additions and 1202 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

@ -176,7 +176,7 @@ public class ClientArmorStand implements ArmorStand
@Override @Override
public Location getLocation() public Location getLocation()
{ {
return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ); return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ, _armorStand.yaw, _armorStand.pitch);
} }
@Override @Override
@ -240,6 +240,20 @@ public class ClientArmorStand implements ArmorStand
return false; return false;
} }
public boolean teleport(Location location, Player player)
{
double pX = _armorStand.locX;
double pY = _armorStand.locY;
double pZ = _armorStand.locZ;
float pYaw = _armorStand.yaw;
float pPitch = _armorStand.pitch;
_armorStand.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport(_armorStand));
_armorStand.setPositionRotation(pX, pY, pZ, pYaw, pPitch);
return false;
}
@Override @Override
public boolean teleport(Location loc) public boolean teleport(Location loc)
{ {

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

@ -1,104 +0,0 @@
package mineplex.core;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import sun.net.www.protocol.http.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
@ReflectivelyCreateMiniPlugin
public class TimingsFix extends MiniPlugin
{
private static final Gson GSON = new Gson();
private TimingsFix()
{
super("Timings Fix");
URL.setURLStreamHandlerFactory(protocol ->
{
if (protocol.equals("http"))
{
return new sun.net.www.protocol.http.Handler()
{
@Override
protected URLConnection openConnection(URL u) throws IOException
{
if (u.getHost().contains("paste.ubuntu.com"))
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
return new HttpURLConnection(u, null, this)
{
@Override
public OutputStream getOutputStream()
{
return baos;
}
@Override
public InputStream getInputStream()
{
return bais;
}
@Override
public String getHeaderField(String name)
{
if (name.equals("Location"))
{
try
{
String request = new String(baos.toByteArray(), StandardCharsets.UTF_8);
request = request.substring("poster=Spigot&syntax=text&content=".length());
request = URLDecoder.decode(request, "UTF-8");
URL url = new URL("https://timings.spigotmc.org/paste");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setInstanceFollowRedirects(false);
connection.getOutputStream().write(request.getBytes(StandardCharsets.UTF_8));
connection.getOutputStream().close();
JsonObject object = GSON.fromJson(new InputStreamReader(connection.getInputStream()), JsonObject.class);
return "http://paste.ubuntu.com/" + object.get("key").getAsString() + "/";
}
catch (Throwable e)
{
e.printStackTrace();
return "http://paste.ubuntu.com/0/";
}
}
return null;
}
};
}
return super.openConnection(u);
}
@Override
protected URLConnection openConnection(URL u, Proxy p) throws IOException
{
return super.openConnection(u, p);
}
};
}
return null;
});
}
}

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

@ -2,6 +2,15 @@ package mineplex.core.monitor;
import java.util.HashSet; import java.util.HashSet;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
@ -10,17 +19,6 @@ import mineplex.core.common.util.F;
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.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class LagMeter extends MiniPlugin public class LagMeter extends MiniPlugin
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
@ -31,12 +29,6 @@ public class LagMeter extends MiniPlugin
private long _lastAverage; private long _lastAverage;
private long _start; private long _start;
private long _lastTick = 0;
private boolean _timingsRunning;
private boolean _timingsPasted;
private long _timingsStarted;
private HashSet<Player> _monitoring = new HashSet<Player>(); private HashSet<Player> _monitoring = new HashSet<Player>();
public LagMeter(JavaPlugin plugin, CoreClientManager clientManager) public LagMeter(JavaPlugin plugin, CoreClientManager clientManager)
@ -98,24 +90,6 @@ public class LagMeter extends MiniPlugin
_lastRun = now; _lastRun = now;
_count++; _count++;
if (System.currentTimeMillis() - _start > 30000)
{
if (_timingsRunning)
{
if (System.currentTimeMillis() - _timingsStarted > 30000)
{
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings paste");
_timingsRunning = false;
}
}
else if (_ticksPerSecond < 10)
{
_timingsRunning = true;
_timingsStarted = System.currentTimeMillis();
getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(), "timings on");
}
}
} }
public double getTicksPerSecond() public double getTicksPerSecond()

View File

@ -1,12 +1,11 @@
package mineplex.game.clans; package mineplex.game.clans;
import static mineplex.core.Managers.require;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import net.minecraft.server.v1_8_R3.MinecraftServer;
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;
@ -15,11 +14,9 @@ import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix; import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix; import mineplex.core.FoodDupeFix;
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;
@ -77,7 +74,8 @@ import mineplex.game.clans.shop.mining.MiningShop;
import mineplex.game.clans.shop.pvp.PvpShop; import mineplex.game.clans.shop.pvp.PvpShop;
import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.spawn.travel.TravelShop;
import mineplex.game.clans.world.WorldManager; import mineplex.game.clans.world.WorldManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import static mineplex.core.Managers.require;
public class Clans extends JavaPlugin public class Clans extends JavaPlugin
{ {
@ -115,8 +113,6 @@ public class Clans extends JavaPlugin
_clientManager = new CoreClientManager(this); _clientManager = new CoreClientManager(this);
CommandCenter.Instance.setClientManager(_clientManager); CommandCenter.Instance.setClientManager(_clientManager);
require(TimingsFix.class);
ItemStackFactory.Initialize(this, false); ItemStackFactory.Initialize(this, false);
DelayedTask.Initialize(this); DelayedTask.Initialize(this);
@ -161,81 +157,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

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

@ -43,7 +43,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
@ -273,7 +272,6 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
// new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
require(PlayerDisguiseManager.class); require(PlayerDisguiseManager.class);
require(TimingsFix.class);
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
// new MailManager(_plugin, notificationManager); // new MailManager(_plugin, notificationManager);
new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager);

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

@ -1,10 +1,10 @@
package nautilus.game.arcade; package nautilus.game.arcade;
import static mineplex.core.Managers.require;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -16,7 +16,6 @@ import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix; import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix; import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix; import mineplex.core.PacketsInteractionFix;
import mineplex.core.TimingsFix;
import mineplex.core.TwitchIntegrationFix; import mineplex.core.TwitchIntegrationFix;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
@ -82,10 +81,11 @@ import mineplex.core.visibility.VisibilityManager;
import mineplex.core.website.WebsiteLinkManager; import mineplex.core.website.WebsiteLinkManager;
import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameServerConfig; import nautilus.game.arcade.game.GameServerConfig;
import net.minecraft.server.v1_8_R3.MinecraftServer; import static mineplex.core.Managers.require;
public class Arcade extends JavaPlugin public class Arcade extends JavaPlugin
{ {
@ -138,8 +138,6 @@ public class Arcade extends JavaPlugin
CommandCenter.Instance.setClientManager(_clientManager); CommandCenter.Instance.setClientManager(_clientManager);
require(ProfileCacheManager.class); require(ProfileCacheManager.class);
require(TimingsFix.class);
ItemStackFactory.Initialize(this, false); ItemStackFactory.Initialize(this, false);
Recharge.Initialize(this); Recharge.Initialize(this);

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;
@ -44,9 +41,7 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager;
import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa;
import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; 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.overtime.OvertimeManager;
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 +50,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 +68,31 @@ 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<>(); protected 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 OvertimeManager _overtimeManager;
private final CapturePointManager _capturePoint; protected final BuffManager _buffs;
private final ArrowKBManager _arrowKb; protected final ArrowKBManager _arrowKb;
private final BuffManager _buffs; protected final TowerManager _tower;
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,20 @@ 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));
_overtimeManager = registerManager(new OvertimeManager(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 +149,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 +177,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 +236,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 +260,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 +268,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 +282,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 +331,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 +497,16 @@ public class Moba extends TeamGame
return _goldManager; return _goldManager;
} }
public OvertimeManager getOvertimeManager()
{
return _overtimeManager;
}
public BuffManager getBuffManager()
{
return _buffs;
}
public TowerManager getTowerManager() public TowerManager getTowerManager()
{ {
return _tower; return _tower;
@ -773,8 +527,8 @@ public class Moba extends TeamGame
return _arrowKb; return _arrowKb;
} }
public BuffManager getBuffManager() public MinionManager getMinionManager()
{ {
return _buffs; return _minion;
} }
} }

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

@ -23,11 +23,11 @@ public class MobaAI
private final float _speedHome; private final float _speedHome;
private final Polygon2D _boundaries; private final Polygon2D _boundaries;
private LivingEntity _entity; protected LivingEntity _entity;
private LivingEntity _target; private LivingEntity _target;
private Location _home; private Location _home;
private MobaAIMethod _aiMethod; protected MobaAIMethod _aiMethod;
public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod)
{ {

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,8 +79,12 @@ public class BossManager implements Listener
} }
_teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup());
if (_pumpkinBoss != null)
{
_pumpkinBoss.cleanup(); _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

@ -40,12 +40,13 @@ public class WitherBoss extends MobaBoss
private static final String NAME = "Wither Boss"; private static final String NAME = "Wither Boss";
private static final float SPEED_TARGET = 4F; private static final float SPEED_TARGET = 4F;
private static final float SPEED_HOME = 6F; private static final float SPEED_HOME = 6F;
private static final int INITIAL_HEALTH = 125; private static final int INITIAL_HEALTH = 275;
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 MobaAI _aiOvertime;
private DisguiseWither _disguise; private DisguiseWither _disguise;
private boolean _damageable; private boolean _damageable;
private long _lastInform; private long _lastInform;
@ -65,11 +66,11 @@ public class WitherBoss extends MobaBoss
{ {
ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class);
// Reducing the wither's health to 10% gives a shield like effect.
stand.setMaxHealth(INITIAL_HEALTH); stand.setMaxHealth(INITIAL_HEALTH);
stand.setHealth(INITIAL_HEALTH * 0.1); stand.setHealth(INITIAL_HEALTH);
stand.setGravity(false); stand.setGravity(false);
MobaUtil.setTeamEntity(stand, _team);
UtilEnt.setBoundingBox(stand, 3, 5); UtilEnt.setBoundingBox(stand, 3, 5);
_disguise = new DisguiseWither(stand); _disguise = new DisguiseWither(stand);
@ -87,10 +88,31 @@ public class WitherBoss extends MobaBoss
{ {
_ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); _ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD);
} }
else if (_host.getOvertimeManager().isOvertime())
{
if (_aiOvertime == null)
{
_aiOvertime = new WitherBossOvertimeAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD);
}
return _aiOvertime;
}
return _ai; return _ai;
} }
@Override
@EventHandler
public void updateMovement(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK || !_host.IsLive())
{
return;
}
getAi().updateTarget();
}
@Override @Override
public String getName() public String getName()
{ {
@ -125,20 +147,6 @@ public class WitherBoss extends MobaBoss
return; return;
} }
// If not damageable
if (!_damageable)
{
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
{
damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!"));
damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F);
}
return;
}
LivingEntity damagee = event.GetDamageeEntity(); LivingEntity damagee = event.GetDamageeEntity();
Player damager = event.GetDamagerPlayer(true); Player damager = event.GetDamagerPlayer(true);
@ -152,6 +160,18 @@ public class WitherBoss extends MobaBoss
} }
} }
// If not damageable
if (!_damageable)
{
if (damager != null)
{
damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!"));
damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F);
}
return;
}
// Inform the team // Inform the team
if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME))
{ {
@ -191,11 +211,14 @@ public class WitherBoss extends MobaBoss
return; return;
} }
// Here we can remove the shield effect, as the wither is no longer invincible if (tower.isFirstTower())
if (!tower.isFirstTower())
{ {
_entity.setHealth(_entity.getHealth() - 50);
}
else
{
_entity.setHealth(_entity.getHealth() - 100);
_damageable = true; _damageable = true;
_entity.setHealth(INITIAL_HEALTH);
updateDisplay(); updateDisplay();
} }
} }
@ -218,7 +241,7 @@ public class WitherBoss extends MobaBoss
public double getHealthPercentage() public double getHealthPercentage()
{ {
return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1; return _entity.getHealth() / _entity.getMaxHealth();
} }
private void updateDisplay() private void updateDisplay()
@ -230,4 +253,9 @@ public class WitherBoss extends MobaBoss
{ {
return _team; return _team;
} }
public void setDamageable(boolean damageable)
{
_damageable = damageable;
}
} }

View File

@ -0,0 +1,55 @@
package nautilus.game.arcade.game.games.moba.boss.wither;
import mineplex.core.common.geom.Polygon2D;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.GameTeam;
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.goal.MobaAIMethod;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import java.util.List;
public class WitherBossOvertimeAI extends MobaAI
{
private List<Location> _path;
private Location _target;
private int _targetIndex;
public WitherBossOvertimeAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod)
{
super(host, owner, entity, home, speedTarget, speedHome, aiMethod);
_path = host.getMinionManager().getPath(owner.GetColor() == ChatColor.RED);
_path = _path.subList(0, (int) (_path.size() / 2D));
}
@Override
public void updateTarget()
{
if (_target == null)
{
_target = _path.get(0);
_targetIndex = 0;
}
double dist = UtilMath.offsetSquared(_target, _entity.getLocation());
if (dist < 16 && _targetIndex < _path.size() - 1)
{
_targetIndex++;
_target = _path.get(_targetIndex);
}
_aiMethod.updateMovement(_entity, _target, 2);
}
@Override
public Polygon2D getBoundaries()
{
return null;
}
}

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,15 +43,8 @@ public class MobaDamageManager implements Listener
return; return;
} }
if (damageeTeam.equals(damagerTeam))
{
event.SetCancelled("Team Damage");
}
else
{
_host.getScoreboardModule().refreshAsSubject(damagee); _host.getScoreboardModule().refreshAsSubject(damagee);
} }
}
@EventHandler @EventHandler
public void preventTeamFire(ConditionApplyEvent event) public void preventTeamFire(ConditionApplyEvent event)

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,24 +142,26 @@ 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);
if (amount > 20 && reason != null) if (amount > 20 && reason != null)
{ {
_host.AddGems(player, (double) amount / 2D, reason, true, true); _host.AddGems(player, (double) amount / 3D, reason, true, true);
player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + "."));
} }
} }
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;
@ -171,10 +166,12 @@ public class HeroKit extends Kit
{ {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
// This is important
inventory.clear();
// 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 +265,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

@ -6,15 +6,14 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
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.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,12 +107,14 @@ 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())
.setLore()
.addLore(GetDesc()) .addLore(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())
.setLore()
.addLore(GetDesc()) .addLore(GetDesc())
.setUnbreakable(true) .setUnbreakable(true)
.build(); .build();
@ -280,13 +281,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());
@ -322,12 +316,31 @@ public class HeroSkill extends Perk
public void useActiveSkill(Runnable complete, Player player, long time) public void useActiveSkill(Runnable complete, Player player, long time)
{ {
long now = System.currentTimeMillis();
long ticks = (long) (time / 1000D); long ticks = (long) (time / 1000D);
ItemStack itemStack = player.getInventory().getItem(getSlot()); ItemStack itemStack = player.getInventory().getItem(getSlot());
itemStack.setAmount((int) (ticks / 20D)); itemStack.setAmount((int) (ticks / 20D));
UtilInv.addDullEnchantment(itemStack); UtilInv.addDullEnchantment(itemStack);
Recharge.Instance.useForce(player, GetName(), time, true);
Recharge.Instance.setDisplayForce(player, GetName(), true); Manager.runSyncTimer(new BukkitRunnable()
{
@Override
public void run()
{
long timeLeft = now + time - System.currentTimeMillis();
double percentage = (double) timeLeft / (double) time;
if (percentage <= 0)
{
UtilTextBottom.display(C.cRedB + GetName(), player);
cancel();
return;
}
UtilTextBottom.displayProgress(C.cWhiteB + GetName(), percentage, UtilTime.MakeStr(timeLeft), player);
}
}, 0, 1);
Manager.runSyncTimer(new BukkitRunnable() Manager.runSyncTimer(new BukkitRunnable()
{ {
@ -343,6 +356,7 @@ public class HeroSkill extends Perk
complete.run(); complete.run();
} }
useSkill(player); useSkill(player);
Kit.GiveItems(player);
cancel(); cancel();
return; return;
} }
@ -359,7 +373,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

@ -96,7 +96,7 @@ public class HeroBardolf extends HeroKit
if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false)) if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false))
{ {
Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, true, false, data.getOwner().getName(), "Wolf"); Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 1, true, true, false, data.getOwner().getName(), "Wolf");
} }
} }
else if (ownerOffset > MAX_DIST_SQUARED) else if (ownerOffset > MAX_DIST_SQUARED)

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

@ -32,7 +32,7 @@ public class SkillSummonWolf extends HeroSkill
}; };
private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE);
private static final int MAX_WOLVES = 5; private static final int MAX_WOLVES = 5;
private static final int HEALTH = 6; private static final int HEALTH = 8;
public SkillSummonWolf(int slot) public SkillSummonWolf(int slot)
{ {

View File

@ -133,7 +133,7 @@ public class SkillWarHorse extends HeroSkill
} }
owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + ".")); owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + "."));
Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 10, false, true, false, UtilEnt.getName(owner), GetName()); Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(owner), GetName());
buffManager.apply(new BuffRooting(game, player, 1000)); buffManager.apply(new BuffRooting(game, player, 1000));
} }
} }

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

@ -60,12 +60,12 @@ public class SkillDanaDash extends DashSkill
if (entity instanceof Player) if (entity instanceof Player)
{ {
damage = 10; damage = 12;
UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25));
} }
else else
{ {
damage = 6; damage = 8;
UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5)); UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5));
} }

View File

@ -43,7 +43,7 @@ public class SkillPulseHeal extends HeroSkill
Player player = event.getPlayer(); Player player = event.getPlayer();
useSkill(player); useSkill(player);
for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 7).keySet())
{ {
// Don't heal enemies // Don't heal enemies
if (!isTeamDamage(entity, player)) if (!isTeamDamage(entity, player))
@ -68,7 +68,7 @@ public class SkillPulseHeal extends HeroSkill
@Override @Override
public void run() public void run()
{ {
if (radius > 5) if (radius > 7)
{ {
cancel(); cancel();
return; return;

View File

@ -151,7 +151,7 @@ public class SkillRally extends HeroSkill
for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet())
{ {
Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 5, true, true, false, UtilEnt.getName(player), GetName()); Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 7, true, true, false, UtilEnt.getName(player), GetName());
} }
} }
} }

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())
{ {
@ -140,7 +140,7 @@ public class SkillLightArrows extends HeroSkill
for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet())
{ {
if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) if (!isTeamDamage(entity, player) && Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false))
{ {
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F);
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName());

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;
@ -27,6 +22,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -36,7 +32,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 +46,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 +63,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 +73,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 +126,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)
@ -192,4 +182,16 @@ public class MinionManager implements Listener
// sign.update(); // sign.update();
// } // }
} }
public List<Location> getPath(boolean redTeam)
{
List<Location> path = new ArrayList<>(_path);
if (redTeam)
{
Collections.reverse(path);
}
return path;
}
} }

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
{ {
@ -365,7 +359,7 @@ public class MinionWave implements Listener
for (MobaBoss boss : bosses) for (MobaBoss boss : bosses)
{ {
// Dead, not close enough // Dead, not close enough
if (boss.isDead() || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED)
{ {
continue; continue;
} }

View File

@ -0,0 +1,70 @@
package nautilus.game.arcade.game.games.moba.overtime;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.boss.MobaBoss;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.concurrent.TimeUnit;
public class OvertimeManager implements Listener
{
private static final long OVERTIME = TimeUnit.MINUTES.toMillis(15);
private final Moba _host;
private boolean _enabled;
private boolean _overtime;
public OvertimeManager(Moba host)
{
_host = host;
_enabled = true;
}
public void disableOvertime()
{
_enabled = false;
}
@EventHandler
public void updateOvertime(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), OVERTIME) || _overtime || !_enabled)
{
return;
}
_overtime = true;
UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!");
_host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false);
for (MobaBoss boss : _host.getBossManager().getBosses())
{
if (boss instanceof WitherBoss)
{
((WitherBoss) boss).setDamageable(true);
}
}
for (Player player : Bukkit.getOnlinePlayers())
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1.2F);
}
}
public boolean isOvertime()
{
return _enabled && _overtime;
}
}

View File

@ -1,9 +1,14 @@
package nautilus.game.arcade.game.games.moba.prepare; package nautilus.game.arcade.game.games.moba.prepare;
import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.entity.ClientArmorStand;
import mineplex.core.common.util.*; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketHandler.ListenerPriority;
@ -17,7 +22,7 @@ import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.bukkit.ChatColor; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -40,6 +45,7 @@ public class PrepareSelection implements Listener, IPacketHandler
private final Moba _host; private final Moba _host;
private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>(); private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>();
private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>(); private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>();
private final Map<Player, ClientArmorStand> _goBackStands = new HashMap<>();
public PrepareSelection(Moba host) public PrepareSelection(Moba host)
{ {
@ -84,6 +90,8 @@ public class PrepareSelection implements Listener, IPacketHandler
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average)));
try
{
MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]);
ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players);
@ -97,6 +105,10 @@ public class PrepareSelection implements Listener, IPacketHandler
_roleStands.put(stand, role); _roleStands.put(stand, role);
} }
catch (IllegalArgumentException e)
{
}
}
// Only spawn the NPCs once all players have been loaded into the world. // Only spawn the NPCs once all players have been loaded into the world.
}, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10);
} }
@ -109,10 +121,20 @@ public class PrepareSelection implements Listener, IPacketHandler
Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Location average = UtilAlg.getAverageLocation(team.GetSpawns());
MobaPlayer mobaPlayer = _host.getMobaData(player); MobaPlayer mobaPlayer = _host.getMobaData(player);
List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole()); List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole());
ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); Location goBack = spawns.remove("KIT " + team.GetName().toUpperCase() + " GO_BACK");
ClientArmorStand goBackStand = ClientArmorStand.spawn(goBack.clone().add(0, 1, 0), player);
goBackStand.setCustomNameVisible(true);
goBackStand.setCustomName(C.cGreenB + "Go Back");
goBackStand.setArms(true);
goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM));
goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build());
goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build());
goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build());
_goBackStands.put(player, goBackStand);
UtilServer.runSyncLater(() -> UtilServer.runSyncLater(() ->
{ {
@ -126,10 +148,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);
@ -171,6 +193,26 @@ public class PrepareSelection implements Listener, IPacketHandler
Player player = packetInfo.getPlayer(); Player player = packetInfo.getPlayer();
int entityId = packet.a; int entityId = packet.a;
ClientArmorStand goBackStand = _goBackStands.get(player);
if (goBackStand != null && goBackStand.getEntityId() == entityId)
{
packetInfo.setCancelled(true);
_host.getMobaData(player).setRole(null);
_goBackStands.remove(player).remove();
for (ClientArmorStand stand2 : _kitStands.keySet())
{
stand2.remove(player);
}
for (ClientArmorStand stand2 : _roleStands.keySet())
{
stand2.teleport(stand2.getLocation(), player);
}
return;
}
for (ClientArmorStand stand : _roleStands.keySet()) for (ClientArmorStand stand : _roleStands.keySet())
{ {
if (stand.getEntityId() != entityId) if (stand.getEntityId() != entityId)
@ -191,7 +233,7 @@ public class PrepareSelection implements Listener, IPacketHandler
for (ClientArmorStand stand2 : _roleStands.keySet()) for (ClientArmorStand stand2 : _roleStands.keySet())
{ {
stand2.remove(player); stand2.teleport(stand2.getLocation().add(0, 100, 0), player);
} }
GameTeam team = _host.GetTeam(player); GameTeam team = _host.GetTeam(player);
@ -201,15 +243,7 @@ public class PrepareSelection implements Listener, IPacketHandler
return; return;
} }
if (team.GetColor() == ChatColor.RED)
{
spawnKitUI(player); spawnKitUI(player);
}
else
{
spawnKitUI(player);
}
displayKitInformation(player, role); displayKitInformation(player, role);
} }
@ -224,6 +258,11 @@ public class PrepareSelection implements Listener, IPacketHandler
HeroKit kit = _kitStands.get(stand); HeroKit kit = _kitStands.get(stand);
if (goBackStand != null)
{
_goBackStands.remove(player).remove();
}
for (ClientArmorStand stand2 : _kitStands.keySet()) for (ClientArmorStand stand2 : _kitStands.keySet())
{ {
stand2.remove(player); stand2.remove(player);
@ -268,6 +307,14 @@ public class PrepareSelection implements Listener, IPacketHandler
stand.remove(); stand.remove();
} }
for (ClientArmorStand stand : _goBackStands.values())
{
stand.remove();
}
_roleStands.clear();
_kitStands.clear();
_goBackStands.clear();
removePodiums(); removePodiums();
_host.getArcadeManager().getPacketHandler().removePacketHandler(this); _host.getArcadeManager().getPacketHandler().removePacketHandler(this);
} }

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

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