diff --git a/Plugins/Mineplex.Core.Common.Base/pom.xml b/Plugins/Mineplex.Core.Common.Base/pom.xml new file mode 100644 index 000000000..e3697fb8a --- /dev/null +++ b/Plugins/Mineplex.Core.Common.Base/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + + com.mineplex + mineplex-parent + dev-SNAPSHOT + + + mineplex-core-common-base + + + + org.spigotmc + spigot-api + + + diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/DefaultHashMap.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/DefaultHashMap.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/DefaultHashMap.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/DefaultHashMap.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/GenericRunnable.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GenericRunnable.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/GenericRunnable.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GenericRunnable.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/GsonLocation.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GsonLocation.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/GsonLocation.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/GsonLocation.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MaterialData.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/MaterialData.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MaterialData.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/MinecraftVersion.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MinecraftVersion.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/MinecraftVersion.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/MinecraftVersion.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Pair.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Pair.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/Pair.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Pair.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/ProcessRunner.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/ProcessRunner.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/ProcessRunner.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/ProcessRunner.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/RangeShuffleIterator.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/RangeShuffleIterator.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/RangeShuffleIterator.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/RangeShuffleIterator.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java similarity index 98% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java index 834c1eff4..9b2a37f9a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/Rank.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; public enum Rank { @@ -122,7 +122,7 @@ public enum Rank if (inform) { - UtilPlayer.message(player, C.mHead + "Permissions> " + + UtilPlayerBase.message(player, C.mHead + "Permissions> " + C.mBody + "This requires Permission Rank [" + C.mHead + rank.Name.toUpperCase() + C.mBody + "]."); diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/TriConsumer.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/TriConsumer.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/TriConsumer.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/Currency.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/Currency.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/GlobalCurrency.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/currency/GlobalCurrency.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/currency/GlobalCurrency.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/EntityVelocityChangeEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/EntityVelocityChangeEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/EntityVelocityChangeEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerMessageEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerMessageEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerMessageEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerMessageEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/PlayerRecieveBroadcastEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/ServerShutdownEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/events/ServerShutdownEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/events/ServerShutdownEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/C.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/C.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/C.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/Callback.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/Callback.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/Callback.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/Callback.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/F.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/F.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautArrayList.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautArrayList.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautArrayList.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautHashMap.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautHashMap.java similarity index 97% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautHashMap.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautHashMap.java index 2f43abed9..41f9d442c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/NautHashMap.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/NautHashMap.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map.Entry; -import org.apache.commons.lang3.Validate; +import org.apache.commons.lang.Validate; import java.util.Set; diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java new file mode 100644 index 000000000..12c090a72 --- /dev/null +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilBlockBase.java @@ -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 getSurrounding(Block block, boolean diagonals) + { + ArrayList blocks = new ArrayList(); + + 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; + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilCollections.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilCollections.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilEvent.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilGear.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilGear.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilGear.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilMath.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilMath.java diff --git a/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java new file mode 100644 index 000000000..9b2d2b5df --- /dev/null +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilPlayerBase.java @@ -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 messageList) + { + message(client, messageList, false); + } + + public static void message(Entity client, String message) + { + message(client, message, false); + } + + public static void message(Entity client, LinkedList 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 matchList = new LinkedList(); + + 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); + } + +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilTime.java similarity index 96% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilTime.java index 815c56f5e..712e73b3d 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilTime.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilTime.java @@ -6,8 +6,6 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Calendar; -import net.minecraft.server.v1_8_R3.MinecraftServer; - public class UtilTime { 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}. * This method will only work for timestamp's stored using {@link #CENTRAL_ZONE}, if stored using diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java similarity index 88% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java index 86c6083f2..b0d4bd9bc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/UtilWorld.java @@ -3,6 +3,7 @@ package mineplex.core.common.util; import java.util.Collection; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -10,19 +11,16 @@ import org.bukkit.World.Environment; import org.bukkit.WorldBorder; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.util.Vector; import com.google.common.collect.Lists; -import net.minecraft.server.v1_8_R3.AxisAlignedBB; - public class UtilWorld { public static World getWorld(String world) { - return UtilServer.getServer().getWorld(world); + return Bukkit.getServer().getWorld(world); } public static boolean areChunksEqual(Location first, Location second) @@ -100,7 +98,7 @@ public class UtilWorld try { - for (World cur : UtilServer.getServer().getWorlds()) + for (World cur : Bukkit.getServer().getWorlds()) { if (cur.getName().equalsIgnoreCase(parts[0])) { @@ -154,7 +152,7 @@ public class UtilWorld try { - for (World cur : UtilServer.getServer().getWorlds()) + for (World cur : Bukkit.getServer().getWorlds()) { if (cur.getName().equalsIgnoreCase(tokens[0])) { @@ -188,7 +186,7 @@ public class UtilWorld public static World getWorldType(Environment env) { - for (World cur : UtilServer.getServer().getWorlds()) + for (World cur : Bukkit.getServer().getWorlds()) if (cur.getEnvironment() == env) return cur; @@ -305,16 +303,4 @@ public class UtilWorld 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); - } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ZipUtil.java b/Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/ZipUtil.java similarity index 100% rename from Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/ZipUtil.java rename to Plugins/Mineplex.Core.Common.Base/src/mineplex/core/common/util/ZipUtil.java diff --git a/Plugins/Mineplex.Core.Common/pom.xml b/Plugins/Mineplex.Core.Common/pom.xml index 65ec63dd8..99340a056 100644 --- a/Plugins/Mineplex.Core.Common/pom.xml +++ b/Plugins/Mineplex.Core.Common/pom.xml @@ -20,6 +20,11 @@ org.apache.httpcomponents httpclient + + ${project.groupId} + mineplex-core-common-base + ${project.version} + com.mineplex mineplex-serverdata diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java index 239f0af5c..1c49ca731 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java @@ -176,7 +176,7 @@ public class ClientArmorStand implements ArmorStand @Override 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 @@ -240,6 +240,20 @@ public class ClientArmorStand implements ArmorStand 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 public boolean teleport(Location loc) { diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index acfa65274..4370f1a2a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -615,30 +615,7 @@ public class UtilBlock public static ArrayList getSurrounding(Block block, boolean diagonals) { - ArrayList blocks = new ArrayList(); - - 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; + return UtilBlockBase.getSurrounding(block, diagonals); } public static boolean isVisible(Block block) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 0bb9502f6..2ddd54f42 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -348,42 +348,22 @@ public class UtilPlayer public static void message(Entity client, LinkedList messageList) { - message(client, messageList, false); + UtilPlayerBase.message(client, messageList); } public static void message(Entity client, String message) { - message(client, message, false); + UtilPlayerBase.message(client, message); } public static void message(Entity client, LinkedList messageList, boolean wiki) { - for (String curMessage : messageList) - { - message(client, curMessage, wiki); - } + UtilPlayerBase.message(client, messageList, 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 = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message)); - - if (event.isCancelled()) - return; - - - ((Player) client).sendMessage(message); + UtilPlayerBase.message(client, message, wiki); } public static Player searchExact(String name) @@ -454,44 +434,7 @@ public class UtilPlayer public static Player searchOnline(Player caller, String player, boolean inform) { - LinkedList matchList = new LinkedList(); - - 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); + return UtilPlayerBase.searchOnline(caller, player, inform); } public static void searchOffline(List matches, final Callback callback, final Player caller, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java b/Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java deleted file mode 100644 index 302ba7674..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/TimingsFix.java +++ /dev/null @@ -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; - }); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java index cb9ef2898..b1ddf4d48 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/AntiHackGuardian.java @@ -78,39 +78,39 @@ public class AntiHackGuardian implements Listener { UtilServer.RegisterEvents(this); - this.MAX_DISTANCE_X = maxX; - this.MIN_DISTANCE_X = minX; - this.MAX_DISTANCE_Y = maxY; - this.MIN_DISTANCE_Y = minY; - this.MAX_DISTANCE_Z = maxZ; - this.MIN_DISTANCE_Z = minZ; + MAX_DISTANCE_X = maxX; + MIN_DISTANCE_X = minX; + MAX_DISTANCE_Y = maxY; + MIN_DISTANCE_Y = minY; + MAX_DISTANCE_Z = maxZ; + MIN_DISTANCE_Z = minZ; - this.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); - this.CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); + CENTER_X = MIN_DISTANCE_X + ((MAX_DISTANCE_X - MIN_DISTANCE_X) / 2.0); + CENTER_Y = MIN_DISTANCE_Y + ((MAX_DISTANCE_Y - MIN_DISTANCE_Y) / 2.0); + CENTER_Z = MIN_DISTANCE_Z + ((MAX_DISTANCE_Z - MIN_DISTANCE_Z) / 2.0); //debug("Spawning ArmorStand at " + center + ""); CoreClientManager clientManager = Managers.get(CoreClientManager.class); DisguiseManager disguiseManager = Managers.get(DisguiseManager.class); - this._center = center; - this._center.getChunk().load(); + _center = center; + _center.getChunk().load(); - this._armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) this._center.getWorld()).getHandle(), this._center.getX(), this._center.getY(), this._center.getZ()).getBukkitEntity(); - this._armorStand.setGravity(false); - this._armorStand.setVisible(false); - this._armorStand.setRemoveWhenFarAway(false); - this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); - this._nmsEntity.maxNoDamageTicks = 86400; - this._nmsEntity.noDamageTicks = 86400; + _armorStand = (ArmorStand) new EntityArmorStand(((CraftWorld) _center.getWorld()).getHandle(), _center.getX(), _center.getY(), _center.getZ()).getBukkitEntity(); + _armorStand.setGravity(false); + _armorStand.setVisible(false); + _armorStand.setRemoveWhenFarAway(false); + _nmsEntity = ((CraftArmorStand) _armorStand).getHandle(); + _nmsEntity.maxNoDamageTicks = 86400; + _nmsEntity.noDamageTicks = 86400; - this._entityUUID = this._armorStand.getUniqueId(); + _entityUUID = _armorStand.getUniqueId(); - this._disguise = new DisguiseGuardian(this._armorStand); - this._disguise.setHideIfNotDisguised(true); + _disguise = new DisguiseGuardian(_armorStand); + _disguise.setHideIfNotDisguised(true); - disguiseManager.disguise(this._disguise, player -> + disguiseManager.disguise(_disguise, player -> { if (!hideForStaff) return true; @@ -141,17 +141,17 @@ public class AntiHackGuardian implements Listener @EventHandler public void onLoad(ChunkAddEntityEvent event) { - if (event.getEntity().getUniqueId().equals(this._entityUUID)) + if (event.getEntity().getUniqueId().equals(_entityUUID)) { - this._armorStand = (ArmorStand) event.getEntity(); - this._nmsEntity = ((CraftArmorStand) this._armorStand).getHandle(); + _armorStand = (ArmorStand) event.getEntity(); + _nmsEntity = ((CraftArmorStand) _armorStand).getHandle(); } } @EventHandler public void onStack(StackerEvent event) { - if (event.getEntity().getUniqueId().equals(this._entityUUID)) + if (event.getEntity().getUniqueId().equals(_entityUUID)) { event.setCancelled(true); } @@ -159,27 +159,27 @@ public class AntiHackGuardian implements Listener 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; } - if (this._target == null) + if (_target == null) { regularTick(); } else { - this._stalkTime++; + _stalkTime++; targetTick(); } - //debug("Ticking " + this._armorStand + " " + this._armorStand.isDead() + " " + this._armorStand.getLocation() + " " + this._ticksUntilReset); + //debug("Ticking " + _armorStand + " " + _armorStand.isDead() + " " + _armorStand.getLocation() + " " + _ticksUntilReset); } private void regularTick() { - if (this._ticksUntilReset <= 0) + if (_ticksUntilReset <= 0) { reset(); } @@ -187,8 +187,8 @@ public class AntiHackGuardian implements Listener //debug("===== Begin Calculations ====="); - //debug("Target: " + this._targetX + " " + this._targetY + " " + this._targetZ); - //debug("Start: " + this._armorStand.getLocation()); + //debug("Target: " + _targetX + " " + _targetY + " " + _targetZ); + //debug("Start: " + _armorStand.getLocation()); double deltaX = _targetX - _nmsEntity.locX; double deltaY = _targetY - _nmsEntity.locY; double deltaZ = _targetZ - _nmsEntity.locZ; @@ -210,28 +210,28 @@ public class AntiHackGuardian implements Listener _nmsEntity.locY += dy; _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 ====="); // 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); } - this._ticksUntilReset--; + _ticksUntilReset--; } private void targetTick() { - //debug("===== Stalking " + this._target.getName() + " ====="); - EntityPlayer entityPlayer = ((CraftPlayer) this._target).getHandle(); + //debug("===== Stalking " + _target.getName() + " ====="); + 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(); - this._nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); - this._nmsEntity.locY = entityPlayer.locY + 10.0 + nextDouble(-1.0, 1.0); + _nmsEntity.locX = entityPlayer.locX + direction.getX(); + _nmsEntity.locZ = entityPlayer.locZ + direction.getZ(); + _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); } @@ -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)); 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); int ex = nextInt(8, 12); @@ -285,18 +285,18 @@ public class AntiHackGuardian implements Listener //debug("Deltas: " + dx + " " + dy + " " + dz); - this._targetX = x + dx; - this._targetY = y + dy; - this._targetZ = z + dz; - //debug("End: " + this._targetX + " " + this._targetY + " " + this._targetZ); + _targetX = x + dx; + _targetY = y + dy; + _targetZ = z + dz; + //debug("End: " + _targetX + " " + _targetY + " " + _targetZ); // If we can't find a good position, just go to the center if (!locCheck()) { - this._targetX = CENTER_X; - this._targetY = CENTER_Y; - this._targetZ = CENTER_Z; + _targetX = CENTER_X; + _targetY = CENTER_Y; + _targetZ = CENTER_Z; dx = (int) (CENTER_X - x); 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)); - this._ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); + _ticksUntilReset = (int) (maxDelta / DELTA_MOVE_PER_TICK); // Send look update for new target UtilEnt.CreatureLook(_armorStand, _nmsEntity.locX, _nmsEntity.locY, _nmsEntity.locZ, _targetX, _targetY, _targetZ); - //debug("Ticks: " + this._ticksUntilReset); + //debug("Ticks: " + _ticksUntilReset); //debug("======= END RESET ======"); } public void target(Player player) { - this._target = player; + _target = player; } public boolean isTargeting() { - return this._target != null; + return _target != null; } public int getTargetingTime() { - return this._stalkTime; + return _stalkTime; } public void stopTargeting() { - this._target = null; - this._stalkTime = 0; + _target = null; + _stalkTime = 0; reset(); } public void shoot(Player player) { - this._disguise.setTarget(player == null ? 0 : player.getEntityId()); - Managers.get(DisguiseManager.class).updateDisguise(this._disguise); + _disguise.setTarget(player == null ? 0 : player.getEntityId()); + Managers.get(DisguiseManager.class).updateDisguise(_disguise); } public Player getTarget() { - return this._target; + return _target; } private boolean locCheck() @@ -376,31 +376,31 @@ public class AntiHackGuardian implements Listener public void remove() { - this._target = null; + _target = null; UtilServer.Unregister(this); - Managers.get(DisguiseManager.class).undisguise(this._disguise); - this._armorStand.remove(); - this._nmsEntity = null; - this._armorStand = null; - this._center = null; + Managers.get(DisguiseManager.class).undisguise(_disguise); + _armorStand.remove(); + _nmsEntity = null; + _armorStand = null; + _center = null; } public ArmorStand getEntity() { - return this._armorStand; + return _armorStand; } public void moveDelta(double dx, double dy, double dz) { - this._nmsEntity.locX += dx; - this._nmsEntity.locY += dy; - this._nmsEntity.locZ += dz; + _nmsEntity.locX += dx; + _nmsEntity.locY += dy; + _nmsEntity.locZ += dz; } public void move(double x, double y, double z) { - this._nmsEntity.locX = x; - this._nmsEntity.locY = y; - this._nmsEntity.locZ = z; + _nmsEntity.locX = x; + _nmsEntity.locY = y; + _nmsEntity.locZ = z; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java index a5806e753..3d19f0501 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/guardians/GuardianManager.java @@ -41,13 +41,13 @@ public class GuardianManager extends MiniPlugin { 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()) { - this._stalking.remove(guardian.getTarget().getUniqueId()); + _stalking.remove(guardian.getTarget().getUniqueId()); guardian.stopTargeting(); } 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); if (Math.random() <= threshold) { - this._stalking.remove(guardian.getTarget().getUniqueId()); + _stalking.remove(guardian.getTarget().getUniqueId()); _stalkingCooldown.put(guardian.getTarget().getUniqueId(), true); guardian.stopTargeting(); } @@ -64,7 +64,7 @@ public class GuardianManager extends MiniPlugin } }, 0L, 1L); - this._plugin.getServer().getScheduler().runTaskTimer(this._plugin, () -> + _plugin.getServer().getScheduler().runTaskTimer(_plugin, () -> { if (_stalking.size() >= MAX_STALKED_PLAYERS) { @@ -124,6 +124,6 @@ public class GuardianManager extends MiniPlugin public void registerGuardian(AntiHackGuardian guardian) { - this._guardians.add(guardian); + _guardians.add(guardian); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java index bf384c4c8..ae121af76 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/beta/BetaWhitelist.java @@ -55,7 +55,7 @@ public class BetaWhitelist extends MiniPlugin { Player player = event.getPlayer(); 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, || EXTRA_PLAYERS.contains(player.getUniqueId())) // or explicitly whitelisted, { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java index 73010a753..d45b1b023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/arrowtrail/candycane/ArrowTrailCandyCane.java @@ -10,10 +10,11 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilText; -import mineplex.core.common.util.UtilTime; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.ArrowEffectGadget; +import net.minecraft.server.v1_8_R3.MinecraftServer; + public class ArrowTrailCandyCane extends ArrowEffectGadget { @@ -29,7 +30,7 @@ public class ArrowTrailCandyCane extends ArrowEffectGadget public void doTrail(Arrow arrow) { int data = 15; - int tick = Math.abs(UtilTime.getServerTick()%3); + int tick = Math.abs(MinecraftServer.currentTick%3); if(tick == 1) data = 1; if(tick == 2) data = 2; Location loc = arrow.getLocation(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 8b7ec8606..413dbbc8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -104,7 +104,8 @@ public enum GameDisplay 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), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index e9f920567..e34150584 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -2,6 +2,15 @@ package mineplex.core.monitor; 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.account.CoreClientManager; import mineplex.core.common.Rank; @@ -10,17 +19,6 @@ import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; 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 { private CoreClientManager _clientManager; @@ -31,12 +29,6 @@ public class LagMeter extends MiniPlugin private long _lastAverage; private long _start; - private long _lastTick = 0; - - private boolean _timingsRunning; - private boolean _timingsPasted; - private long _timingsStarted; - private HashSet _monitoring = new HashSet(); public LagMeter(JavaPlugin plugin, CoreClientManager clientManager) @@ -98,24 +90,6 @@ public class LagMeter extends MiniPlugin _lastRun = now; _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() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 784e5c230..ed924a65f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -1,12 +1,11 @@ package mineplex.game.clans; -import static mineplex.core.Managers.require; - import java.io.File; import java.io.IOException; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; @@ -15,11 +14,9 @@ import org.spigotmc.SpigotConfig; import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; -import mineplex.core.TimingsFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; -import mineplex.core.antihack.guardians.AntiHackGuardian; import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.aprilfools.AprilFoolsManager; 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.spawn.travel.TravelShop; 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 { @@ -115,8 +113,6 @@ public class Clans extends JavaPlugin _clientManager = new CoreClientManager(this); CommandCenter.Instance.setClientManager(_clientManager); - require(TimingsFix.class); - ItemStackFactory.Initialize(this, false); DelayedTask.Initialize(this); @@ -161,81 +157,6 @@ public class Clans extends JavaPlugin 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); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java index e302d1a26..141e52cb0 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; public class WorldManager extends MiniPlugin { @@ -77,6 +78,9 @@ public class WorldManager extends MiniPlugin { List players = world.getPlayers(); Map> 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()) { @@ -104,11 +108,11 @@ public class WorldManager extends MiniPlugin else if (CULL_LIMITS.containsKey(entityType)) { boolean cull = true; + entity.getLocation(entityLocation); for (Player player : players) { - // Using NMS because this is going to be called quite a few times - // and each getLocation() call creates a new Location object - if (UtilWorld.distanceSquared(player, entity) <= MIN_RANGE_SQUARED) + player.getLocation(playerLocation); + if (playerLocation.distanceSquared(entityLocation) <= MIN_RANGE_SQUARED) { cull = false; break; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 070cd582a..bc02c3628 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -43,7 +43,6 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniClientPlugin; -import mineplex.core.TimingsFix; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -273,7 +272,6 @@ public class HubManager extends MiniClientPlugin implements IChatMess // new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); require(PlayerDisguiseManager.class); - require(TimingsFix.class); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _gadgetManager, statsManager); diff --git a/Plugins/Mineplex.MapParser/pom.xml b/Plugins/Mineplex.MapParser/pom.xml index 65a7236aa..1fd1baade 100644 --- a/Plugins/Mineplex.MapParser/pom.xml +++ b/Plugins/Mineplex.MapParser/pom.xml @@ -14,9 +14,13 @@ mineplex-mapparser + + commons-io + commons-io + ${project.groupId} - mineplex-core-common + mineplex-core-common-base ${project.version} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 6fa838da5..5d62fdf65 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; 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.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilBlockBase; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.command.AddLoreCommand; import mineplex.mapparser.command.AddSplashTextCommand; import mineplex.mapparser.command.AdminCommand; @@ -144,7 +144,7 @@ public class MapParser extends JavaPlugin 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 = ""; @@ -256,7 +256,7 @@ public class MapParser extends JavaPlugin public void announce(String msg) { - for (Player player : UtilServer.getPlayers()) + for (Player player : Bukkit.getOnlinePlayers()) { player.sendMessage(C.cGold + msg); } @@ -390,7 +390,7 @@ public class MapParser extends JavaPlugin if (!blocks.add(current)) 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) continue; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java index 56e3b7218..2ae2e1561 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java @@ -1,6 +1,5 @@ package mineplex.mapparser; -import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.ZipUtil; import org.apache.commons.io.FileUtils; import org.bukkit.Bukkit; @@ -24,7 +23,7 @@ public class WorldManager public World prepMapParse(World world) { //Unload World - MapUtil.UnloadWorld(Host, world, true); + Host.getServer().unloadWorld(world, true); //Delete Non-Map Files String[] folders = new File(world.getName()).list(); @@ -69,7 +68,7 @@ public class WorldManager public void finalizeParsedWorld(World world) { - MapUtil.UnloadWorld(Host, world, true); + Host.getServer().unloadWorld(world, true); ArrayList fileList = new ArrayList(); ArrayList dirList = new ArrayList(); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java index 962a5813a..b808c2796 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AdminCommand.java @@ -4,7 +4,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; 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.MapParser; @@ -42,7 +42,7 @@ public class AdminCommand extends BaseCommand return true; } - Player other = UtilPlayer.searchOnline(player, args[0], true); + Player other = UtilPlayerBase.searchOnline(player, args[0], true); if (player != null) { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java index 16552b9b0..951c0f6a4 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/BaseCommand.java @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.MapParser; /** @@ -59,6 +59,6 @@ public abstract class BaseCommand protected void message(Player player, String message) { - UtilPlayer.message(player, F.main("Parser", message)); + UtilPlayerBase.message(player, F.main("Parser", message)); } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java index 4354a90a1..ea1b4e6ea 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/CopyCommand.java @@ -7,7 +7,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.GameType; import mineplex.mapparser.MapParser; import org.apache.commons.io.FileUtils; @@ -73,7 +72,7 @@ public class CopyCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); message(other, "Unloading world for copy..."); } - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); } File source = new File(worldName); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java index 59b357c42..c3e1b48fd 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/DeleteCommand.java @@ -6,7 +6,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.GameType; import mineplex.mapparser.MapParser; import org.apache.commons.io.FileUtils; @@ -66,7 +65,7 @@ public class DeleteCommand extends BaseCommand //Unload 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 diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java index 4b01a03c9..5d4139b5b 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/GameTypeCommand.java @@ -6,7 +6,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.GameType; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -69,7 +68,7 @@ public class GameTypeCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); message(player, "Unloading world for rename..."); } - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); File typeFolder = new File("map/" + type.GetName()); if (!typeFolder.exists()) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java index 8935eb777..1edb4ad81 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ListCommand.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.C; 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.MapParser; @@ -28,7 +28,7 @@ public class ListCommand extends BaseCommand { if (args.length == 0) { - UtilPlayer.message(player, F.main("Parser", "Listing Maps;")); + UtilPlayerBase.message(player, F.main("Parser", "Listing Maps;")); 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); } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java index 6c504b634..56d98de06 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/MapCommand.java @@ -1,7 +1,7 @@ package mineplex.mapparser.command; 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.MapData; import mineplex.mapparser.MapParser; @@ -32,7 +32,7 @@ public class MapCommand extends BaseCommand { if (args.length < 1) { - //UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map [GameType]"))); + //UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map [GameType]"))); return false; } @@ -50,7 +50,7 @@ public class MapCommand extends BaseCommand { message(player, "Found more than one possible match:"); for (String s : possibleMaps) - UtilPlayer.message(player, s); + UtilPlayerBase.message(player, s); return true; } @@ -126,9 +126,9 @@ public class MapCommand extends BaseCommand MapData data = getPlugin().getData(worldName); - UtilPlayer.message(player, F.value("Map Name", data.MapName)); - UtilPlayer.message(player, F.value("Author", data.MapCreator)); - UtilPlayer.message(player, F.value("Game Type", data.MapGameType.GetName())); + UtilPlayerBase.message(player, F.value("Map Name", data.MapName)); + UtilPlayerBase.message(player, F.value("Author", data.MapCreator)); + UtilPlayerBase.message(player, F.value("Game Type", data.MapGameType.GetName())); return true; } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java index 86c4db4f2..f18483199 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/PMCommand.java @@ -2,7 +2,6 @@ package mineplex.mapparser.command; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilServer; import mineplex.mapparser.MapParser; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -38,14 +37,14 @@ public class PMCommand extends BaseCommand { builder.append(s).append(" "); } - for (Player ops : UtilServer.getPlayers()) + for (Player ops : getPlugin().getServer().getOnlinePlayers()) { if (!ops.isOp()) { continue; } 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; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java index 2f66500c2..dfb0cb030 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/RenameCommand.java @@ -6,7 +6,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -56,7 +55,7 @@ public class RenameCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); message(other, "Unloading world for rename..."); } - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); message(player, "World unloaded!"); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java index c201f152c..46f52a35f 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/SaveCommand.java @@ -6,8 +6,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.MapParser; /** @@ -37,7 +36,7 @@ public class SaveCommand extends BaseCommand { message(player, "More than one map found:"); for (String s : possibleMaps) - UtilPlayer.message(player, s); + UtilPlayerBase.message(player, s); return true; } @@ -63,7 +62,7 @@ public class SaveCommand extends BaseCommand other.teleport(getPlugin().getSpawnLocation()); //Unload World - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); } else { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java index 2b9d6331c..1af45bfaa 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/WorldsCommand.java @@ -3,8 +3,6 @@ package mineplex.mapparser.command; import org.bukkit.World; import org.bukkit.entity.Player; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; import mineplex.mapparser.MapParser; /** diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java index 368b24df9..3cfe1ac73 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/CommandModule.java @@ -2,7 +2,7 @@ package mineplex.mapparser.module.modules; import com.google.common.collect.Maps; 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.command.BaseCommand; import mineplex.mapparser.module.Module; @@ -38,7 +38,7 @@ public class CommandModule extends Module 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; } if (event.getMessage().toLowerCase().startsWith("/help")) @@ -83,8 +83,8 @@ public class CommandModule extends Module if (!baseCommand.execute(player, commandLabel, args)) { - UtilPlayer.message(player, F.main("Parser", "Invalid Input.")); - UtilPlayer.message(player, F.elem(baseCommand.getUsage())); + UtilPlayerBase.message(player, F.main("Parser", "Invalid Input.")); + UtilPlayerBase.message(player, F.elem(baseCommand.getUsage())); } } diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java index 1595b9886..2b617a039 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/module/modules/EventModule.java @@ -27,9 +27,7 @@ import com.google.common.collect.Lists; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilPlayerBase; import mineplex.mapparser.BackupTask; import mineplex.mapparser.MapData; import mineplex.mapparser.MapParser; @@ -135,7 +133,7 @@ public class EventModule extends Module if (world.getPlayers().isEmpty()) { getPlugin().announce("Saving & Closing World: " + F.elem(world.getName())); - MapUtil.UnloadWorld(getPlugin(), world, true); + getPlugin().getServer().unloadWorld(world, true); _updated.remove(world); getPlugin()._mapsBeingZipped.add(world.getName()); System.out.println("Starting backup of " + world); @@ -164,7 +162,7 @@ public class EventModule extends Module String grayName = C.cBlue + event.getPlayer().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())) { @@ -212,7 +210,7 @@ public class EventModule extends Module event.setCancelled(true); - Player target = UtilPlayer.searchOnline(player, tokens[1], true); + Player target = UtilPlayerBase.searchOnline(player, tokens[1], true); if (target != null) { if (!target.getWorld().getName().equals("world")) @@ -224,7 +222,7 @@ public class EventModule extends Module 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); } } @@ -246,7 +244,7 @@ public class EventModule extends Module //Permission 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); } } @@ -276,10 +274,10 @@ public class EventModule extends Module 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) { - UtilPlayer.message(player, F.main("Game", "Invalid Speed Input.")); + UtilPlayerBase.message(player, F.main("Game", "Invalid Speed Input.")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 197d76ff0..ebf57b8d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,10 +1,10 @@ package nautilus.game.arcade; -import static mineplex.core.Managers.require; - import java.io.File; import java.util.HashMap; +import net.minecraft.server.v1_8_R3.MinecraftServer; + import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -16,7 +16,6 @@ import org.spigotmc.SpigotConfig; import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; import mineplex.core.PacketsInteractionFix; -import mineplex.core.TimingsFix; import mineplex.core.TwitchIntegrationFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; @@ -82,10 +81,11 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; + import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; import nautilus.game.arcade.game.Game; 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 { @@ -138,8 +138,6 @@ public class Arcade extends JavaPlugin CommandCenter.Instance.setClientManager(_clientManager); require(ProfileCacheManager.class); - require(TimingsFix.class); - ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index ac4f37774..503422b10 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -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.mineware.BawkBawkBattles; 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.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.oldmineware.OldMineWare; @@ -232,7 +234,8 @@ public enum GameType 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[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java index 562bd08cc..9057da773 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/halloween2016/Crypt.java @@ -14,7 +14,8 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextTop; -import mineplex.core.common.util.UtilTime; + +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Crypt { @@ -42,10 +43,10 @@ public class Crypt { if(isDestroyed()) return false; Integer lastTime = _damageCooldown.get(mob); - if(lastTime != null && lastTime > UtilTime.getServerTick()) return false; + if(lastTime != null && lastTime > MinecraftServer.currentTick) return false; _health -= damage; - _damageCooldown.put(mob, UtilTime.getServerTick() + cooldown); + _damageCooldown.put(mob, MinecraftServer.currentTick + cooldown); updateState(damage); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 3850dcc77..f1db74bae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -4,11 +4,9 @@ import mineplex.core.Managers; import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguisePlayer; 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.TeamGame; 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.fountain.MobaFountain; 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.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; -import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; -import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; -import nautilus.game.arcade.game.games.moba.recall.Recall; +import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager; 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.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.kit.Kit; import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; -import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -76,34 +68,31 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; 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 Set _playerData = new HashSet<>(); - + protected final Set _playerData = new HashSet<>(); private final Set _listeners = new HashSet<>(); - private final MobaShop _shop; - private final GoldManager _goldManager; - private final BossManager _boss; - private final TowerManager _tower; - private final CapturePointManager _capturePoint; - private final ArrowKBManager _arrowKb; - private final BuffManager _buffs; + protected final MobaShop _shop; + protected final GoldManager _goldManager; + protected final BossManager _boss; + protected final OvertimeManager _overtimeManager; + protected final BuffManager _buffs; + protected final ArrowKBManager _arrowKb; + protected final TowerManager _tower; + protected final CapturePointManager _capturePoint; + protected final MinionManager _minion; 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[]{ new HeroHattori(Manager), @@ -118,16 +107,7 @@ public class Moba extends TeamGame }; 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); // Instantiate managers @@ -135,34 +115,20 @@ public class Moba extends TeamGame // Global managers _shop = registerManager(new MobaShop(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 MobaDamageManager(this)); registerManager(new MobaFountain(this)); - registerManager(new Recall(this)); - - // Pregame managers - registerManager(new PrepareManager(this)); - registerManager(new PrepareSelection(this)); - - // Bosses - _boss = registerManager(new BossManager(this)); + registerManager(new EnderPearlManager()); // Structures _tower = registerManager(new TowerManager(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 registerManager(new BetaManager(this)); @@ -183,66 +149,6 @@ public class Moba extends TeamGame .setGiveCompassToAlive(false) .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) { @Override @@ -271,7 +177,7 @@ public class Moba extends TeamGame }); } - private T registerManager(T listener) + protected T registerManager(T listener) { _listeners.add(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) public void prepare(GameStateChangeEvent event) { @@ -445,7 +260,7 @@ public class Moba extends TeamGame { Player player = event.GetPlayer(); - if (GetPlayers(true).size() > 8) + if (++_inPlayers > 8) { SetPlayerState(player, GameTeam.PlayerState.OUT); 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 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 public void RespawnPlayer(Player player) { @@ -529,6 +282,17 @@ public class Moba extends TeamGame _listeners.forEach(UtilServer::Unregister); _listeners.clear(); _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 @@ -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 getLocationStartsWith(String s) { Map map = new HashMap<>(); @@ -753,6 +497,16 @@ public class Moba extends TeamGame return _goldManager; } + public OvertimeManager getOvertimeManager() + { + return _overtimeManager; + } + + public BuffManager getBuffManager() + { + return _buffs; + } + public TowerManager getTowerManager() { return _tower; @@ -773,8 +527,8 @@ public class Moba extends TeamGame return _arrowKb; } - public BuffManager getBuffManager() + public MinionManager getMinionManager() { - return _buffs; + return _minion; } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java new file mode 100644 index 000000000..8fa8ee3cb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaClassic.java @@ -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 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); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java index 29d7083ed..dd2d2a823 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -32,6 +32,7 @@ public class MobaPlayer public void setKit(HeroKit kit) { + _role = kit.getRole(); _kit = kit; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 014d12a4d..dd09209b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -6,7 +6,7 @@ import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.GRAY, ChatColor.DARK_GRAY), + ASSASSIN("Assassin", Color.GRAY, ChatColor.GRAY), HUNTER("Hunter", Color.LIME, ChatColor.GREEN), MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 5b89b9884..1ad97af9e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -23,11 +23,11 @@ public class MobaAI private final float _speedHome; private final Polygon2D _boundaries; - private LivingEntity _entity; + protected LivingEntity _entity; private LivingEntity _target; 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) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index f2a0ef23c..7b45daa6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -24,6 +24,8 @@ public class BossManager implements Listener private Map _teamBosses; private PumpkinBoss _pumpkinBoss; + private boolean _dummyBosses; + public BossManager(Moba host) { _host = host; @@ -32,6 +34,11 @@ public class BossManager implements Listener private void spawnBosses() { + if (_dummyBosses) + { + return; + } + _host.CreatureAllowOverride = true; WorldData worldData = _host.WorldData; @@ -72,7 +79,11 @@ public class BossManager implements Listener } _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); - _pumpkinBoss.cleanup(); + + if (_pumpkinBoss != null) + { + _pumpkinBoss.cleanup(); + } } public String getWitherDisplayString(GameTeam team) @@ -96,4 +107,9 @@ public class BossManager implements Listener return bosses; } + + public void setDummyBosses(boolean dummyBosses) + { + _dummyBosses = dummyBosses; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 086858719..e46cdffd7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -5,22 +5,16 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; 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.ai.MobaAI; -import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; public abstract class MobaBoss implements Listener { @@ -85,7 +79,7 @@ public abstract class MobaBoss implements Listener @EventHandler public void updateMovement(UpdateEvent event) { - if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) + if (event.getType() != UpdateType.TICK || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index edf900681..6e190779b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -40,12 +40,13 @@ public class WitherBoss extends MobaBoss private static final String NAME = "Wither Boss"; private static final float SPEED_TARGET = 4F; 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 int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); - private GameTeam _team; + private final GameTeam _team; private MobaAI _ai; + private MobaAI _aiOvertime; private DisguiseWither _disguise; private boolean _damageable; private long _lastInform; @@ -65,11 +66,11 @@ public class WitherBoss extends MobaBoss { 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.setHealth(INITIAL_HEALTH * 0.1); + stand.setHealth(INITIAL_HEALTH); stand.setGravity(false); + MobaUtil.setTeamEntity(stand, _team); UtilEnt.setBoundingBox(stand, 3, 5); _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); } + 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; } + @Override + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !_host.IsLive()) + { + return; + } + + getAi().updateTarget(); + } + @Override public String getName() { @@ -125,20 +147,6 @@ public class WitherBoss extends MobaBoss 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(); 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 if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) { @@ -191,11 +211,14 @@ public class WitherBoss extends MobaBoss 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; - _entity.setHealth(INITIAL_HEALTH); updateDisplay(); } } @@ -212,13 +235,13 @@ public class WitherBoss extends MobaBoss for (Player player : _team.GetPlayers(true)) { - UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); + UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); } } public double getHealthPercentage() { - return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1; + return _entity.getHealth() / _entity.getMaxHealth(); } private void updateDisplay() @@ -230,4 +253,9 @@ public class WitherBoss extends MobaBoss { return _team; } + + public void setDamageable(boolean damageable) + { + _damageable = damageable; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java new file mode 100644 index 000000000..67bd868be --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBossOvertimeAI.java @@ -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 _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; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java deleted file mode 100644 index aa06f1003..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java +++ /dev/null @@ -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 -{ - - 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() - { - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index e989d5b09..7fa54255c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -43,14 +43,7 @@ public class MobaDamageManager implements Listener return; } - if (damageeTeam.equals(damagerTeam)) - { - event.SetCancelled("Team Damage"); - } - else - { - _host.getScoreboardModule().refreshAsSubject(damagee); - } + _host.getScoreboardModule().refreshAsSubject(damagee); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index afdd3582d..4ce28a71d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -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 public void playerQuit(PlayerQuitEvent event) { @@ -146,7 +132,7 @@ public class GoldManager implements Listener public int getGold(Player player) { - return _playerGold.get(player); + return _playerGold.getOrDefault(player, 0); } 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) { + _playerGold.putIfAbsent(player, 0); _playerGold.put(player, _playerGold.get(player) + amount); _host.getArcadeManager().GetStatsManager().incrementStat(player, _host.GetName() + ".GoldEarned", amount); 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 + ".")); } } public void removeGold(Player player, int amount) { + _playerGold.putIfAbsent(player, 0); _playerGold.put(player, _playerGold.get(player) - amount); } public boolean hasGold(Player player, int amount) { - return _playerGold.get(player) >= amount; + return _playerGold.getOrDefault(player, 0) >= amount; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 0fbecfe73..4758aefcd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.game.games.moba.kit; import com.mojang.authlib.GameProfile; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; @@ -41,14 +40,10 @@ public class HeroKit extends Kit private int _maxAmmo; private SkinData _skin; - private static final int RECALL_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 int SHOP_SLOT = 8; private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) .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(); private boolean _visible = true; @@ -171,10 +166,12 @@ public class HeroKit extends Kit { PlayerInventory inventory = player.getInventory(); + // This is important + inventory.clear(); + // Give standard items inventory.setItem(AMMO_SLOT, _ammo); - //inventory.setItem(RECALL_SLOT, RECALL_ITEM); - inventory.setItem(RECALL_SLOT, SHOP_ITEM); + inventory.setItem(SHOP_SLOT, SHOP_ITEM); Moba game = (Moba) Manager.GetGame(); List items = game.getShop().getOwnedItems(player); @@ -268,6 +265,11 @@ public class HeroKit extends Kit Manager.GetDisguise().disguise(disguise); } + public SkinData getSkinData() + { + return _skin; + } + public boolean isVisible() { return _visible; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 59cdd544a..2a19d34cd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -6,15 +6,14 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; 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.kit.Kit; import nautilus.game.arcade.kit.Perk; @@ -108,12 +107,14 @@ public class HeroSkill extends Perk _item = new ItemBuilder(_item) .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) + .setLore() .addLore(GetDesc()) .setUnbreakable(true) .build(); _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) + .setLore() .addLore(GetDesc()) .setUnbreakable(true) .build(); @@ -280,13 +281,6 @@ public class HeroSkill extends Perk 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) { _lastSkill.remove(player.getUniqueId()); @@ -322,12 +316,31 @@ public class HeroSkill extends Perk public void useActiveSkill(Runnable complete, Player player, long time) { + long now = System.currentTimeMillis(); long ticks = (long) (time / 1000D); ItemStack itemStack = player.getInventory().getItem(getSlot()); itemStack.setAmount((int) (ticks / 20D)); 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() { @@ -343,6 +356,7 @@ public class HeroSkill extends Perk complete.run(); } useSkill(player); + Kit.GiveItems(player); cancel(); return; } @@ -359,7 +373,12 @@ public class HeroSkill extends Perk 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; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 59b39a822..2fd704386 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; 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.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaConstants; @@ -37,7 +38,7 @@ public class SkillFireProjectile extends HeroSkill Player player = event.getPlayer(); - if (!_kit.useAmmo(player, 1)) + if (!Recharge.Instance.use(player, GetName(), 500, false, true) || !_kit.useAmmo(player, 1)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index d28975e95..7ac660d7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -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)) { - 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) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java index c68fab17d..e2cf73353 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -89,6 +89,12 @@ public class SkillFullMoon extends HeroSkill kit.disguise(player); player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); + ItemStack itemStack = player.getInventory().getItem(1); + if (itemStack != null) + { + itemStack.setAmount(1); + } + for (Wolf wolf : data.getWolves()) { wolf.setHealth(0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index d0e43367b..29dbd295f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -32,7 +32,7 @@ public class SkillSummonWolf extends HeroSkill }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); private static final int MAX_WOLVES = 5; - private static final int HEALTH = 6; + private static final int HEALTH = 8; public SkillSummonWolf(int slot) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 9a45a201d..d6997e5e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -133,7 +133,7 @@ public class SkillWarHorse extends HeroSkill } 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)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 7d8899320..217751e16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -20,7 +20,9 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; 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; public class DashSkill extends HeroSkill @@ -127,10 +129,12 @@ public class DashSkill extends HeroSkill return; } - for (Entry entry : _startTime.entrySet()) + Iterator iterator = _startTime.keySet().iterator(); + + while (iterator.hasNext()) { - Player player = entry.getKey(); - long start = entry.getValue(); + Player player = iterator.next(); + long start = _startTime.get(player); if (UtilTime.elapsed(start, _velocityTime)) { @@ -138,7 +142,8 @@ public class DashSkill extends HeroSkill { UtilAction.zeroVelocity(player); } - _startTime.remove(player); + + iterator.remove(); postDash(player); } else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index c7834d07d..db20421c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -6,7 +6,6 @@ import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.shop.MobaItem; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index 8fcb89839..cd2398103 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -60,12 +60,12 @@ public class SkillDanaDash extends DashSkill if (entity instanceof Player) { - damage = 10; + damage = 12; UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); } else { - damage = 6; + damage = 8; UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 6d26e4cc3..4908fdf41 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -43,7 +43,7 @@ public class SkillPulseHeal extends HeroSkill Player player = event.getPlayer(); useSkill(player); - for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 7).keySet()) { // Don't heal enemies if (!isTeamDamage(entity, player)) @@ -68,7 +68,7 @@ public class SkillPulseHeal extends HeroSkill @Override public void run() { - if (radius > 5) + if (radius > 7) { cancel(); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index ec5ac4cc9..19922f0e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -151,7 +151,7 @@ public class SkillRally extends HeroSkill 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()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index f1d06a1dc..094700d99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -33,7 +33,7 @@ public class SkillSnowball extends HeroSkill implements IThrown { super("Shuriken", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); - setCooldown(1000); + setCooldown(1500); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 93e4e5055..64441aa11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -31,6 +31,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; 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); } + @EventHandler + public void emptyBucket(PlayerBucketEmptyEvent event) + { + event.setCancelled(true); + } + @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { @@ -113,6 +120,13 @@ public class SkillAOEHeal extends HeroSkill implements IThrown AOEHealData data = iterator.next(); Player owner = data.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); if (UtilTime.elapsed(data.Start, DURATION)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index 2a64ce53c..e2f7b1c9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -47,7 +47,7 @@ public class SkillAquaCannon extends HeroSkill Player player = event.getPlayer(); - if (!_kit.useAmmo(player, 1)) + if (!Recharge.Instance.use(player, GetName(), 500, false, true) || !_kit.useAmmo(player, 1)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index 69cc3a8f4..21e8686ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -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.ParticleType; 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 org.bukkit.Material; import org.bukkit.entity.Player; @@ -22,7 +18,6 @@ public class SkillWaterDash extends DashSkill "come into contact with." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); - private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3); public SkillWaterDash(int slot) { @@ -40,18 +35,6 @@ public class SkillWaterDash extends DashSkill 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); - 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)); - } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java index cdb3e4838..3607c0f5c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -148,10 +148,6 @@ public class SkillBombardment extends HeroSkill data.Block.setType(Material.AIR); 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); - } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index d4037aa5f..31111ba47 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -127,7 +127,7 @@ public class SkillLightArrows extends HeroSkill { LineParticle lineParticle = iterator.next(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 6; i++) { if (!lineParticle.update()) { @@ -140,7 +140,7 @@ public class SkillLightArrows extends HeroSkill 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); Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index e3c663632..efdb7356b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -4,11 +4,9 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; 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 org.bukkit.ChatColor; 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.Player; import org.bukkit.entity.Zombie; @@ -27,6 +22,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -36,7 +32,6 @@ import java.util.concurrent.TimeUnit; 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 final Moba _host; @@ -51,6 +46,7 @@ public class MinionManager implements Listener { _host = host; _waves = new HashSet<>(); + _enabled = true; 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 public void spawnMinions(UpdateEvent event) { @@ -83,6 +73,11 @@ public class MinionManager implements Listener _lastWave = System.currentTimeMillis(); + if (_path == null) + { + preparePath(); + } + for (GameTeam team : _host.GetTeamList()) { List path = new ArrayList<>(_path); @@ -131,14 +126,9 @@ public class MinionManager implements Listener } } - public void setEnabled(boolean enabled) + public void disableMinions() { - _enabled = enabled; - - if (enabled) - { - preparePath(); - } + _enabled = false; } public void unregisterWave(MinionWave wave) @@ -192,4 +182,16 @@ public class MinionManager implements Listener // sign.update(); // } } + + public List getPath(boolean redTeam) + { + List path = new ArrayList<>(_path); + + if (redTeam) + { + Collections.reverse(path); + } + + return path; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 5d9f3e77f..2ec589c7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -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.wither.WitherBoss; 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 org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; 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.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; -import org.jooq.util.derby.sys.Sys; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; public class MinionWave implements Listener { @@ -365,7 +359,7 @@ public class MinionWave implements Listener for (MobaBoss boss : bosses) { // 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; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java new file mode 100644 index 000000000..f22986f4c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/overtime/OvertimeManager.java @@ -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; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 23f01e5e9..4480e761f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -1,9 +1,14 @@ package nautilus.game.arcade.game.games.moba.prepare; 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.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; 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.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -40,6 +45,7 @@ public class PrepareSelection implements Listener, IPacketHandler private final Moba _host; private final Map _roleStands = new HashMap<>(); private final Map _kitStands = new HashMap<>(); + private final Map _goBackStands = new HashMap<>(); public PrepareSelection(Moba host) { @@ -84,18 +90,24 @@ public class PrepareSelection implements Listener, IPacketHandler location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); - MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); - ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); + try + { + MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); + ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); - stand.setCustomNameVisible(true); - stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); - stand.setArms(true); - stand.setHelmet(head); - stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); - stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); - stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + stand.setCustomNameVisible(true); + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); + stand.setArms(true); + stand.setHelmet(head); + stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); + stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); + stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); - _roleStands.put(stand, role); + _roleStands.put(stand, role); + } + catch (IllegalArgumentException e) + { + } } // Only spawn the NPCs once all players have been loaded into the world. }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); @@ -109,10 +121,20 @@ public class PrepareSelection implements Listener, IPacketHandler Location average = UtilAlg.getAverageLocation(team.GetSpawns()); MobaPlayer mobaPlayer = _host.getMobaData(player); - List 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(() -> { @@ -126,10 +148,10 @@ public class PrepareSelection implements Listener, IPacketHandler stand.setCustomNameVisible(true); stand.setCustomName(C.cGreenB + kit.GetName()); stand.setArms(true); - stand.setHelmet(head); -// stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); -// stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); -// stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + stand.setHelmet(kit.getSkinData().getSkull()); + stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, kit.getRole())); + stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, kit.getRole())); + stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, kit.getRole())); 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); @@ -171,6 +193,26 @@ public class PrepareSelection implements Listener, IPacketHandler Player player = packetInfo.getPlayer(); 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()) { if (stand.getEntityId() != entityId) @@ -191,7 +233,7 @@ public class PrepareSelection implements Listener, IPacketHandler for (ClientArmorStand stand2 : _roleStands.keySet()) { - stand2.remove(player); + stand2.teleport(stand2.getLocation().add(0, 100, 0), player); } GameTeam team = _host.GetTeam(player); @@ -201,15 +243,7 @@ public class PrepareSelection implements Listener, IPacketHandler return; } - if (team.GetColor() == ChatColor.RED) - { - spawnKitUI(player); - } - else - { - spawnKitUI(player); - } - + spawnKitUI(player); displayKitInformation(player, role); } @@ -224,6 +258,11 @@ public class PrepareSelection implements Listener, IPacketHandler HeroKit kit = _kitStands.get(stand); + if (goBackStand != null) + { + _goBackStands.remove(player).remove(); + } + for (ClientArmorStand stand2 : _kitStands.keySet()) { stand2.remove(player); @@ -268,6 +307,14 @@ public class PrepareSelection implements Listener, IPacketHandler stand.remove(); } + for (ClientArmorStand stand : _goBackStands.values()) + { + stand.remove(); + } + + _roleStands.clear(); + _kitStands.clear(); + _goBackStands.clear(); removePodiums(); _host.getArcadeManager().getPacketHandler().removePacketHandler(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java deleted file mode 100644 index 2725ecf1f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java +++ /dev/null @@ -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 _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; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java deleted file mode 100644 index 0abca7401..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java +++ /dev/null @@ -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(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 3e37e1cc4..73b0d1b86 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -54,7 +54,7 @@ public abstract class MobaItemEffect { } - protected void onRespawn(PlayerGameRespawnEvent event) + protected void onRespawn(PlayerGameRespawnEvent event, boolean fake) { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 7300d7385..55c40f2af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -27,6 +28,7 @@ import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -41,6 +43,7 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -131,7 +134,7 @@ public class MobaShop implements Listener LivingEntity entity = entry.getKey(); Location location = entry.getValue(); - ((CraftLivingEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); + ((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); } } @@ -218,11 +221,11 @@ public class MobaShop implements Listener { if (ownedItem.getEffects() != null) { - ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent)); + ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent, true)); } } - _host.GetKit(player).ApplyKit(player); + _host.GetKit(player).GiveItems(player); } public boolean ownsItem(Player player, MobaItem item) @@ -251,6 +254,11 @@ public class MobaShop implements Listener return null; } + public void clearPurchases(Player player) + { + _upgrades.put(player, new ArrayList<>()); + } + @EventHandler public void playerDeath(PlayerDeathEvent event) { @@ -290,11 +298,16 @@ public class MobaShop implements Listener Remove empty potions */ @EventHandler - public void removeEmptyPotions(PlayerItemConsumeEvent event) + public void removeEmptyPotions(UpdateEvent event) { - if (event.getItem().getType() == Material.POTION) + if (event.getType() != UpdateType.FAST) { - _host.getArcadeManager().runSyncLater(() -> event.getPlayer().setItemInHand(null), 1); + return; + } + + for (Player player : _host.GetPlayers(true)) + { + player.getInventory().remove(Material.GLASS_BOTTLE); } } @@ -322,6 +335,11 @@ public class MobaShop implements Listener Player player = event.getPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -342,6 +360,11 @@ public class MobaShop implements Listener Player player = event.getPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -374,6 +397,11 @@ public class MobaShop implements Listener List items = _upgrades.get(damager); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -409,6 +437,11 @@ public class MobaShop implements Listener List items = _upgrades.get(killer); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -429,6 +462,11 @@ public class MobaShop implements Listener Player player = event.getPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -453,6 +491,11 @@ public class MobaShop implements Listener List items = _upgrades.get(event.getSource()); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -473,6 +516,11 @@ public class MobaShop implements Listener Player player = event.GetPlayer(); List items = _upgrades.get(player); + if (items == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) @@ -482,7 +530,7 @@ public class MobaShop implements Listener for (MobaItemEffect effect : item.getEffects()) { - effect.onRespawn(event); + effect.onRespawn(event, false); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 96c28be81..052ced61a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -30,7 +30,7 @@ public class MobaAssassinShop extends MobaShopMenu .build(), 1000), new MobaItem(new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cDRedB + "Pumpkin King's Blade") - .addEnchantment(Enchantment.DAMAGE_ALL, 3) + .addEnchantment(Enchantment.DAMAGE_ALL, 2) .build(), 1750) ), new ItemStack(Material.WOOD_SWORD)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java index 3f19d483c..d8e5221ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java @@ -20,7 +20,7 @@ public class MobaBasicAttackDamageEffect extends MobaItemEffect @Override protected void onDamage(CustomDamageEvent event) { - if (!event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + if (event.GetReason() == null || !event.GetReason().contains(MobaConstants.BASIC_ATTACK)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 15d7d7196..8505a6eb0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -16,7 +16,7 @@ public class MobaSpeedEffect extends MobaItemEffect } @Override - public void onRespawn(PlayerGameRespawnEvent event) + public void onRespawn(PlayerGameRespawnEvent event, boolean fake) { Player player = event.GetPlayer(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java index 80af5c495..7867ce364 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -17,12 +17,16 @@ public class MobaTotalHealthEffect extends MobaItemEffect } @Override - public void onRespawn(PlayerGameRespawnEvent event) + public void onRespawn(PlayerGameRespawnEvent event, boolean fake) { Player player = event.GetPlayer(); player.setMaxHealth(player.getMaxHealth() + _health); - player.setHealth(player.getMaxHealth()); + + if (!fake) + { + player.setHealth(player.getMaxHealth()); + } } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java index 2c9b75b86..2429e6819 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -10,6 +10,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; import nautilus.game.arcade.game.games.moba.shop.effects.*; +import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -74,18 +75,21 @@ public class MobaHunterShop extends MobaShopMenu ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Leather Cap of Nimble Fingers") + .setColor(Color.GREEN) .build(), 400) .addEffects( new MobaCDRAmmoEffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Focused Cap") + .setColor(Color.PURPLE) .build(), 500) .addEffects( new MobaCDREffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Vampiric Helmet") + .setColor(Color.RED) .build(), 500) .addEffects( new MobaHPRegenEffect(0.2) @@ -101,18 +105,21 @@ public class MobaHunterShop extends MobaShopMenu .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Leather Chestplate of Nimble Fingers") + .setColor(Color.GREEN) .build(), 750) .addEffects( new MobaCDRAmmoEffect(0.15) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Focused Chestplate") + .setColor(Color.PURPLE) .build(), 750) .addEffects( new MobaCDREffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Vampiric Chestplate") + .setColor(Color.RED) .build(), 750) .addEffects( new MobaKillHealEffect(3) @@ -128,18 +135,21 @@ public class MobaHunterShop extends MobaShopMenu .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Leather Leggings of Nimble Fingers") + .setColor(Color.GREEN) .build(), 750) .addEffects( new MobaCDRAmmoEffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Focused Leggings") + .setColor(Color.PURPLE) .build(), 750) .addEffects( new MobaCDREffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Vampiric Leggings") + .setColor(Color.RED) .build(), 700) .addEffects( new MobaKillHealEffect(3) @@ -155,18 +165,21 @@ public class MobaHunterShop extends MobaShopMenu .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Leather Boots of Nimble Fingers") + .setColor(Color.GREEN) .build(), 400) .addEffects( new MobaCDRAmmoEffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Focused Boots") + .setColor(Color.PURPLE) .build(), 600) .addEffects( new MobaCDREffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Vampiric Boots") + .setColor(Color.RED) .build(), 500) .addEffects( new MobaKillHealEffect(1) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 11ab9881d..6a9d42ba5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index a7c9d4d54..eaa2f4626 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -281,7 +281,9 @@ public class TowerManager implements Listener for (Tower tower : _towers) { - if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal().getLocation(), location) > PROJECTILE_RANGE_SQUARED) + Location crystalLocation = tower.getCrystal().getLocation(); + + if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(crystalLocation, location) > PROJECTILE_RANGE_SQUARED || shouldCancelDamage(tower, shooter)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java new file mode 100644 index 000000000..439390385 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/MobaTraining.java @@ -0,0 +1,496 @@ +package nautilus.game.arcade.game.games.moba.training; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.hologram.Hologram; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; +import nautilus.game.arcade.game.modules.TrainingGameModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; + +public class MobaTraining extends Moba +{ + + private static final String[] DESCRIPTION = { + "Heroes of GWEN", + "Training Ground" + }; + private static final String[][] HELP_HOLOGRAMS = + { + { + C.cYellow + "Welcome to " + C.cGreen + "Heroes of GWEN", + C.cYellow + "Here you can use learn about the game", + C.cYellow + "and test out the Heroes.", + C.cYellow + "If you know what you are doing you can type", + C.cGreen + "/skip" + C.cYellow + " to skip to the end of the tutorial." + }, + { + C.cGreen + "Heroes of GWEN" + C.cYellow + " is a MOBA style game.", + C.cYellow + "There are " + C.cGreen + "4" + C.cYellow + " Roles of Heroes to play", + C.cYellow + "with many different Heroes within each role." + }, + { + C.cYellow + "This is a " + C.cGreen + "Tower", + C.cYellow + "You need to destroy these in order to be able", + C.cYellow + "to attack the other team's " + C.cGreen + "Wither" + C.cYellow + " to win the game." + }, + { + C.cYellow + "This is a " + C.cGreen + "Beacon", + C.cYellow + "You can capture these for your team.", + C.cYellow + "Capturing and holding these increases the amount", + C.cYellow + "of " + C.cGold + "Gold" + C.cYellow + " your team earns." + }, + { + C.cYellow + "This is the " + C.cDRedB + "Pumpkin King", + C.cYellow + "He spawns at " + C.cGreen + "10 minutes" + C.cYellow + " into the game.", + C.cYellow + "The team that kills him will be given increased", + C.cYellow + "regeneration and damage." + }, + { + C.cYellow + "Once all of the enemy's towers are destroyed", + C.cYellow + "your team can attack their " + C.cGreen + "Wither", + C.cYellow + "Once the Wither is killed the game is over!" + }, + { + C.cGreen + "Minions" + C.cYellow + " spawn for both teams periodically", + C.cYellow + "and make their way to each other's bases.", + C.cYellow + "They will fight each other and help destroy enemy Towers." + }, + { + C.cYellow + "With the " + C.cGold + "Gold" + C.cYellow + " you earn you can", + C.cYellow + "spend it on upgrades for your weapons and armor.", + C.cYellow + "You can do this via the gold ingot in your inventory", + C.cYellow + "during the game or by clicking on the Villager." + }, + { + C.cYellow + "Now you know the basics", + C.cYellow + "Click on this NPC to select a Hero", + C.cYellow + "to try out!" + } + }; + private static final long GAME_TIME = TimeUnit.HOURS.toMillis(3); + private static final int GOLD = 100000; + + private Location _borderA; + private Location _borderB; + private Location _selectKit; + private LivingEntity _selectKitEntity; + + private final Map _entities = new HashMap<>(); + + public MobaTraining(ArcadeManager manager) + { + super(manager, GameType.MOBATraining, DESCRIPTION); + + DamageTeamSelf = true; + DamageFall = false; + DeathOut = false; + DeathSpectateSecs = 2; + PrepareTime = 500; + GiveClock = false; + HideTeamSheep = true; + HungerSet = 20; + + // Prevent the wither from being damaged as well as to not spawn the pumpkin king + _boss.setDummyBosses(true); + _overtimeManager.disableOvertime(); + + // Disable minions + _minion.disableMinions(); + + Function safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB); + Function teamFunction = player -> GetTeam(ChatColor.GRAY); + new TrainingGameModule() + .setGiveReturnToSpawn(false) + .setSkillFunction(safeFunction) + .setDamageFunction(safeFunction) + .setTeamFunction(teamFunction) + .register(this); + + new CustomScoreboardModule() + .setSidebar(this::write) + .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 == null || 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("skip", Rank.ALL) + { + @Override + public void Execute(Player caller, String[] args) + { + if (!safeFunction.apply(caller)) + { + caller.teleport(GetTeam(ChatColor.YELLOW).GetSpawn()); + } + } + }); + } + + private void write(Player player, GameScoreboard scoreboard) + { + boolean alive = IsAlive(player); + MobaPlayer mobaPlayer = getMobaData(player); + + if (mobaPlayer != null && mobaPlayer.getRole() != null && mobaPlayer.getKit() != null) + { + scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Hero"); + scoreboard.write(mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + C.cWhite + ")"); + } + + 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())); + + scoreboard.writeNewLine(); + } + + @Override + public void ParseData() + { + super.ParseData(); + + List locations = WorldData.GetDataLocs("BROWN"); + + _borderA = locations.get(0); + _borderB = locations.get(1); + + _selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0); + SpectatorSpawn = _selectKit; + } + + @EventHandler + public void adjustSpawns(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns()) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); + } + + for (Location location : GetTeam(ChatColor.GRAY).GetSpawns()) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit))); + } + + Location center = WorldData.GetCustomLocs("CENTER").get(0); + for (Location location : WorldData.GetDataLocs("LIME")) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, center))); + } + } + + @EventHandler + public void customTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + { + return; + } + { + GameTeam players = GetTeam(ChatColor.RED); + players.SetColor(ChatColor.GRAY); + players.SetName("Players"); + players.setDisplayName(C.cYellowB + "Players"); + } + { + GameTeam players = GetTeam(ChatColor.GREEN); + players.SetColor(ChatColor.YELLOW); + players.SetName("Players"); + players.setDisplayName(C.cYellowB + "Players"); + } + } + + @Override + public GameTeam ChooseTeam(Player player) + { + return GetTeam(ChatColor.GRAY); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + if (UtilTime.elapsed(GetStateTime(), GAME_TIME)) + { + SetState(GameState.Dead); + } + } + + @EventHandler + public void giveGold(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Player player : GetPlayers(true)) + { + if (_goldManager.getGold(player) < 100) + { + _goldManager.addGold(player, GOLD); + } + } + } + + @EventHandler + public void plaeyrJoin(PlayerJoinEvent event) + { + if (InProgress()) + { + _playerData.add(new MobaPlayer(event.getPlayer())); + } + } + + @EventHandler + public void spawnTutorial(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + CreatureAllowOverride = true; + + spawnHelpText(); + spawnDummies(); + spawnNPCs(); + + for (LivingEntity entity : _entities.keySet()) + { + entity.setCustomNameVisible(true); + UtilEnt.vegetate(entity); + UtilEnt.setFakeHead(entity, true); + UtilEnt.silence(entity, true); + } + + CreatureAllowOverride = false; + } + + @EventHandler + public void entityDamage(CustomDamageEvent event) + { + if (!_entities.containsKey(event.GetDamageeEntity())) + { + return; + } + + event.SetCancelled("NPC"); + + if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity())) + { + openMenu(event.GetDamagerPlayer(false)); + } + } + + @EventHandler + public void entityInteract(PlayerInteractAtEntityEvent event) + { + if (_selectKitEntity != null && event.getRightClicked().equals(_selectKitEntity)) + { + openMenu(event.getPlayer()); + } + } + + @EventHandler + public void updateEntityLocation(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Entry entry : _entities.entrySet()) + { + LivingEntity entity = entry.getKey(); + Location location = entry.getValue(); + + ((CraftEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); + } + } + + private void openMenu(Player player) + { + if (player == null) + { + return; + } + + new SelectKitMenu(Manager).open(player); + } + + private void spawnHelpText() + { + Map locationMap = getLocationStartsWith("HELP"); + + for (Entry entry : locationMap.entrySet()) + { + String[] split = entry.getKey().split(" "); + String index = split[1]; + int indexInt = Integer.parseInt(index); + String[] display = HELP_HOLOGRAMS[indexInt - 1]; + + new Hologram(Manager.getHologramManager(), entry.getValue(), true, display).start(); + } + } + + private void spawnDummies() + { + { + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(WorldData.GetCustomLocs("PUMPKIN_KING").get(0)); + skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + UtilEnt.CreatureLook(skeleton, 90); + + _entities.put(skeleton, skeleton.getLocation()); + } + { + Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0); + ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class); + + // Reducing the wither's health to 10% gives a shield like effect. + stand.setGravity(false); + + UtilEnt.setBoundingBox(stand, 3, 5); + + DisguiseWither disguise = new DisguiseWither(stand); + disguise.setName(C.cAqua + "Blue's Wither"); + disguise.setCustomNameVisible(true); + Manager.GetDisguise().disguise(disguise); + + _entities.put(stand, stand.getLocation()); + } + { + Location location = WorldData.GetCustomLocs("DUMMY_SHOP").get(0); + Villager villager = location.getWorld().spawn(location, Villager.class); + villager.setProfession(Profession.LIBRARIAN); + villager.setCustomName(C.cGoldB + "Gold Upgrades"); + + _entities.put(villager, villager.getLocation()); + } + } + + private void spawnNPCs() + { + Villager villager = WorldData.World.spawn(_selectKit, Villager.class); + villager.setCustomName(C.cYellowB + "Select A Hero"); + UtilEnt.CreatureLook(villager, GetTeam(ChatColor.YELLOW).GetSpawns().get(0)); + + _entities.put(villager, villager.getLocation()); + _selectKitEntity = villager; + } + + public void teleportIntoArena(Player player, HeroKit kit) + { + Kit currentKit = GetKit(player); + if (currentKit == null || !kit.equals(currentKit)) + { + _shop.clearPurchases(player); + } + + player.teleport(UtilAlg.Random(WorldData.GetDataLocs("LIME"))); + SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true); + SetKit(player, kit, true); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java new file mode 100644 index 000000000..2c2efadf3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/training/SelectKitMenu.java @@ -0,0 +1,75 @@ +package nautilus.game.arcade.game.games.moba.training; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class SelectKitMenu extends Menu +{ + + public SelectKitMenu(ArcadeManager plugin) + { + super("Select A Hero", plugin); + } + + @Override + protected Button[] setUp(Player player) + { + MobaTraining moba = (MobaTraining) getPlugin().GetGame(); + Button[] buttons = new Button[36]; + int[] slots = UtilUI.getIndicesFor(moba.GetKits().length, 1); + int i = 0; + + for (int slot : slots) + { + HeroKit kit = (HeroKit) moba.GetKits()[i++]; + + if (!kit.isVisible()) + { + continue; + } + ItemBuilder builder = new ItemBuilder(kit.getSkinData().getSkull()); + + builder.setTitle(C.cGreen + kit.GetName()); + builder.addLore("", "Skills:"); + + for (Perk perk : kit.GetPerks()) + { + builder.addLore(C.cWhite + " - " + C.cYellow + perk.GetName()); + } + + builder.addLore("", C.cGreen + "Click to join the arena with this kit!"); + + buttons[slot] = new SelectKitButton(builder.build(), getPlugin(), kit); + } + + return buttons; + } + + private class SelectKitButton extends Button + { + + private final HeroKit _kit; + + private SelectKitButton(ItemStack item, ArcadeManager plugin, HeroKit kit) + { + super(item, plugin); + + _kit = kit; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + ((MobaTraining) getPlugin().GetGame()).teleportIntoArena(player, _kit); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 54bf4ee50..76721ad08 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -46,7 +46,7 @@ public class MobaUtil } // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + if (isTeamEntity(entity, owner)) { continue; } @@ -72,6 +72,11 @@ public class MobaUtil public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries, LivingEntity target) { + if (boundaries == null) + { + return true; + } + return getEntitiesInBoundary(owner, source, center, boundaries).contains(target); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index 928a2e919..efb25437b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -4,6 +4,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -37,7 +38,7 @@ import java.util.function.BiFunction; * * * @see mineplex.core.scoreboard.MineplexScoreboard - * @see nautilus.game.arcade.game.games.moba.Moba + * @see Moba */ public class CustomScoreboardModule extends Module { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java index 3305ba089..15f877ec2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/TrainingGameModule.java @@ -45,6 +45,7 @@ public class TrainingGameModule extends Module private Function _teamFunction; private Function _skillFunction; private Function _damageFunction; + private boolean _giveReturnToSpawn = true; public TrainingGameModule() { @@ -61,6 +62,12 @@ public class TrainingGameModule extends Module List locations = getGame().WorldData.GetDataLocs("PURPLE"); int i = 0; + + if (locations.isEmpty()) + { + return; + } + getGame().CreatureAllowOverride = true; for (Kit kit : getGame().GetKits()) @@ -282,7 +289,7 @@ public class TrainingGameModule extends Module @EventHandler public void giveReturnToSpawn(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) + if (event.getType() != UpdateType.FAST || !_giveReturnToSpawn) { return; } @@ -343,6 +350,12 @@ public class TrainingGameModule extends Module return this; } + public TrainingGameModule setGiveReturnToSpawn(boolean b) + { + _giveReturnToSpawn = b; + return this; + } + private LobbyEnt getFromEntity(Entity entity) { for (LobbyEnt lobbyEnt : _kits) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 9b8256d80..d4e557763 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -1,8 +1,15 @@ package mineplex.gemhunters; +import net.minecraft.server.v1_8_R3.MinecraftServer; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.plugin.java.JavaPlugin; +import org.spigotmc.SpigotConfig; + import mineplex.core.CustomTagFix; import mineplex.core.FoodDupeFix; -import mineplex.core.TimingsFix; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; @@ -93,12 +100,6 @@ import mineplex.gemhunters.worldevent.WorldEventModule; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; -import net.minecraft.server.v1_8_R3.MinecraftServer; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; -import org.bukkit.plugin.java.JavaPlugin; -import org.spigotmc.SpigotConfig; import static mineplex.core.Managers.require; @@ -132,9 +133,6 @@ public class GemHunters extends JavaPlugin // Command Centre CommandCenter.Instance.setClientManager(clientManager); - // Timings - require(TimingsFix.class); - // ItemStacks ItemStackFactory.Initialize(this, false); diff --git a/Plugins/pom.xml b/Plugins/pom.xml index bbf652166..95880e508 100644 --- a/Plugins/pom.xml +++ b/Plugins/pom.xml @@ -21,6 +21,7 @@ Mineplex.Cache Mineplex.Core Mineplex.Core.Common + Mineplex.Core.Common.Base Mineplex.Database Mineplex.DDoSProtectionSwitcher Mineplex.EnjinTranslator @@ -36,7 +37,7 @@ Mineplex.ServerData Mineplex.ServerMonitor Mineplex.StaffServer - Mineplex.Votifier + Mineplex.Votifier Nautilus.Game.Arcade Nautilus.Game.Arcade.UHC.WorldGen @@ -51,10 +52,20 @@ mineplex http://dev.mineplex.com:8081/nexus/content/groups/public/ + + spigotmc-public + https://hub.spigotmc.org/nexus/content/groups/public/ + + + commons-io + commons-io + 2.5 + compile + commons-codec commons-codec @@ -68,7 +79,7 @@ compile - com.vexsoftware + com.vexsoftware votifier 1.9 provided @@ -133,6 +144,12 @@ 3.5.2 compile + + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT + compile + com.mineplex spigot