diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index 0d6b0ea54..fad8f1eef 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -6,6 +6,7 @@ import java.util.Set; import java.util.TreeSet; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -92,6 +93,10 @@ public class UtilAlg if (y <= 0) pitch += 90; else pitch -= 90; + //Fix for two vectors at same Y giving 180 + if (pitch == 180) + pitch = 0; + return (float) pitch; } @@ -244,4 +249,15 @@ public class UtilAlg return bestLoc; } + + public static boolean isInPyramid(Vector a, Vector b, double angleLimit) + { + return (Math.abs(GetPitch(a) - GetPitch(b)) < angleLimit) && (Math.abs(GetYaw(a) - GetYaw(b)) < angleLimit); + } + + public static boolean isTargetInPlayerPyramid(Player player, Player target, double angleLimit) + { + return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) || + isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit); + } } 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 ca8b82677..322a55134 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 @@ -22,555 +22,575 @@ import net.minecraft.server.v1_7_R4.PlayerConnection; public class UtilPlayer { - private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max) - { - final double epsilon = 0.0001f; + private static boolean hasIntersection(Vector3D p1, Vector3D p2, Vector3D min, Vector3D max) + { + final double epsilon = 0.0001f; - Vector3D d = p2.subtract(p1).multiply(0.5); - Vector3D e = max.subtract(min).multiply(0.5); - Vector3D c = p1.add(d).subtract(min.add(max).multiply(0.5)); - Vector3D ad = d.abs(); + Vector3D d = p2.subtract(p1).multiply(0.5); + Vector3D e = max.subtract(min).multiply(0.5); + Vector3D c = p1.add(d).subtract(min.add(max).multiply(0.5)); + Vector3D ad = d.abs(); - if (Math.abs(c.x) > e.x + ad.x) - return false; - if (Math.abs(c.y) > e.y + ad.y) - return false; - if (Math.abs(c.z) > e.z + ad.z) - return false; + if (Math.abs(c.x) > e.x + ad.x) + return false; + if (Math.abs(c.y) > e.y + ad.y) + return false; + if (Math.abs(c.z) > e.z + ad.z) + return false; - if (Math.abs(d.y * c.z - d.z * c.y) > e.y * ad.z + e.z * ad.y + epsilon) - return false; - if (Math.abs(d.z * c.x - d.x * c.z) > e.z * ad.x + e.x * ad.z + epsilon) - return false; - if (Math.abs(d.x * c.y - d.y * c.x) > e.x * ad.y + e.y * ad.x + epsilon) - return false; + if (Math.abs(d.y * c.z - d.z * c.y) > e.y * ad.z + e.z * ad.y + epsilon) + return false; + if (Math.abs(d.z * c.x - d.x * c.z) > e.z * ad.x + e.x * ad.z + epsilon) + return false; + if (Math.abs(d.x * c.y - d.y * c.x) > e.x * ad.y + e.y * ad.x + epsilon) + return false; - return true; - } + return true; + } - private static class Vector3D - { + private static class Vector3D + { - // Use protected members, like Bukkit - private final double x; - private final double y; - private final double z; + // Use protected members, like Bukkit + private final double x; + private final double y; + private final double z; - private Vector3D(double x, double y, double z) - { - this.x = x; - this.y = y; - this.z = z; - } + private Vector3D(double x, double y, double z) + { + this.x = x; + this.y = y; + this.z = z; + } - private Vector3D(Location location) - { - this(location.toVector()); - } + private Vector3D(Location location) + { + this(location.toVector()); + } - private Vector3D(Vector vector) - { - if (vector == null) - throw new IllegalArgumentException("Vector cannot be NULL."); - this.x = vector.getX(); - this.y = vector.getY(); - this.z = vector.getZ(); - } + private Vector3D(Vector vector) + { + if (vector == null) + throw new IllegalArgumentException("Vector cannot be NULL."); + this.x = vector.getX(); + this.y = vector.getY(); + this.z = vector.getZ(); + } - private Vector3D abs() - { - return new Vector3D(Math.abs(x), Math.abs(y), Math.abs(z)); - } + private Vector3D abs() + { + return new Vector3D(Math.abs(x), Math.abs(y), Math.abs(z)); + } - private Vector3D add(double x, double y, double z) - { - return new Vector3D(this.x + x, this.y + y, this.z + z); - } + private Vector3D add(double x, double y, double z) + { + return new Vector3D(this.x + x, this.y + y, this.z + z); + } - private Vector3D add(Vector3D other) - { - if (other == null) - throw new IllegalArgumentException("other cannot be NULL"); + private Vector3D add(Vector3D other) + { + if (other == null) + throw new IllegalArgumentException("other cannot be NULL"); - return new Vector3D(x + other.x, y + other.y, z + other.z); - } + return new Vector3D(x + other.x, y + other.y, z + other.z); + } - private Vector3D multiply(double factor) - { - return new Vector3D(x * factor, y * factor, z * factor); - } + private Vector3D multiply(double factor) + { + return new Vector3D(x * factor, y * factor, z * factor); + } - private Vector3D multiply(int factor) - { - return new Vector3D(x * factor, y * factor, z * factor); - } + private Vector3D multiply(int factor) + { + return new Vector3D(x * factor, y * factor, z * factor); + } - private Vector3D subtract(Vector3D other) - { - if (other == null) - throw new IllegalArgumentException("other cannot be NULL"); - return new Vector3D(x - other.x, y - other.y, z - other.z); - } - } + private Vector3D subtract(Vector3D other) + { + if (other == null) + throw new IllegalArgumentException("other cannot be NULL"); + return new Vector3D(x - other.x, y - other.y, z - other.z); + } + } - public static Player getPlayerInSight(Player p, int range, boolean lineOfSight) - { - Location observerPos = p.getEyeLocation(); - Vector3D observerDir = new Vector3D(observerPos.getDirection()); - Vector3D observerStart = new Vector3D(observerPos); - Vector3D observerEnd = observerStart.add(observerDir.multiply(range)); + public static Player getPlayerInSight(Player p, int range, boolean lineOfSight) + { + Location observerPos = p.getEyeLocation(); + Vector3D observerDir = new Vector3D(observerPos.getDirection()); + Vector3D observerStart = new Vector3D(observerPos); + Vector3D observerEnd = observerStart.add(observerDir.multiply(range)); - Player hit = null; + Player hit = null; - for (Entity entity : p.getNearbyEntities(range, range, range)) - { + for (Entity entity : p.getNearbyEntities(range, range, range)) + { - if (entity == p || UtilPlayer.isSpectator(entity)) - continue; + if (entity == p || UtilPlayer.isSpectator(entity)) + continue; - double theirDist = p.getEyeLocation().distance(entity.getLocation()); + double theirDist = p.getEyeLocation().distance(entity.getLocation()); - if (lineOfSight - && p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (int) Math.ceil(theirDist)).get(0).getLocation() - .distance(p.getEyeLocation()) + 1 < theirDist) - continue; + if (lineOfSight + && p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (int) Math.ceil(theirDist)).get(0).getLocation() + .distance(p.getEyeLocation()) + 1 < theirDist) + continue; - Vector3D targetPos = new Vector3D(entity.getLocation()); - Vector3D minimum = targetPos.add(-0.5, 0, -0.5); - Vector3D maximum = targetPos.add(0.5, 1.67, 0.5); + Vector3D targetPos = new Vector3D(entity.getLocation()); + Vector3D minimum = targetPos.add(-0.5, 0, -0.5); + Vector3D maximum = targetPos.add(0.5, 1.67, 0.5); - if (hasIntersection(observerStart, observerEnd, minimum, maximum)) - { - if (hit == null - || hit.getLocation().distanceSquared(observerPos) > entity.getLocation().distanceSquared(observerPos)) - { - hit = (Player) entity; - } - } - } - return hit; - } + if (hasIntersection(observerStart, observerEnd, minimum, maximum)) + { + if (hit == null + || hit.getLocation().distanceSquared(observerPos) > entity.getLocation().distanceSquared(observerPos)) + { + hit = (Player) entity; + } + } + } + return hit; + } - /** - * AviodAllies doesn't work. Leaving as a param as it sounds like something you may want in the future. - */ - public static Entity getEntityInSight(Player player, int rangeToScan, boolean avoidAllies, boolean avoidNonLiving, - boolean lineOfSight, float expandBoxesPercentage) - { - Location observerPos = player.getEyeLocation(); - Vector3D observerDir = new Vector3D(observerPos.getDirection()); - Vector3D observerStart = new Vector3D(observerPos); - Vector3D observerEnd = observerStart.add(observerDir.multiply(rangeToScan)); + /** + * AviodAllies doesn't work. Leaving as a param as it sounds like something you may want in the future. + */ + public static Entity getEntityInSight(Player player, int rangeToScan, boolean avoidAllies, boolean avoidNonLiving, + boolean lineOfSight, float expandBoxesPercentage) + { + Location observerPos = player.getEyeLocation(); + Vector3D observerDir = new Vector3D(observerPos.getDirection()); + Vector3D observerStart = new Vector3D(observerPos); + Vector3D observerEnd = observerStart.add(observerDir.multiply(rangeToScan)); - Entity hit = null; + Entity hit = null; - for (Entity entity : player.getNearbyEntities(rangeToScan, rangeToScan, rangeToScan)) - { - if (entity == player || UtilPlayer.isSpectator(entity)) - continue; + for (Entity entity : player.getNearbyEntities(rangeToScan, rangeToScan, rangeToScan)) + { + if (entity == player || UtilPlayer.isSpectator(entity)) + continue; - if (avoidNonLiving && !(entity instanceof LivingEntity)) - continue; + if (avoidNonLiving && !(entity instanceof LivingEntity)) + continue; - double theirDist = player.getEyeLocation().distance(entity.getLocation()); - if (lineOfSight - && player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (int) Math.ceil(theirDist)).get(0) - .getLocation().distance(player.getEyeLocation()) + 1 < theirDist) - continue; + double theirDist = player.getEyeLocation().distance(entity.getLocation()); + if (lineOfSight + && player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, (int) Math.ceil(theirDist)).get(0) + .getLocation().distance(player.getEyeLocation()) + 1 < theirDist) + continue; - Vector3D targetPos = new Vector3D(entity.getLocation()); + Vector3D targetPos = new Vector3D(entity.getLocation()); - float width = (((CraftEntity) entity).getHandle().width / 1.8F) * expandBoxesPercentage; + float width = (((CraftEntity) entity).getHandle().width / 1.8F) * expandBoxesPercentage; - Vector3D minimum = targetPos.add(-width, -0.1 / expandBoxesPercentage, -width); - Vector3D maximum = targetPos.add(width, ((CraftEntity) entity).getHandle().length * expandBoxesPercentage, width); + Vector3D minimum = targetPos.add(-width, -0.1 / expandBoxesPercentage, -width); + Vector3D maximum = targetPos.add(width, ((CraftEntity) entity).getHandle().length * expandBoxesPercentage, width); - if (hasIntersection(observerStart, observerEnd, minimum, maximum)) - { - if (hit == null - || hit.getLocation().distanceSquared(observerPos) > entity.getLocation().distanceSquared(observerPos)) - { - hit = entity; - } - } - } - return hit; - } + if (hasIntersection(observerStart, observerEnd, minimum, maximum)) + { + if (hit == null + || hit.getLocation().distanceSquared(observerPos) > entity.getLocation().distanceSquared(observerPos)) + { + hit = entity; + } + } + } + return hit; + } - public static void message(Entity client, LinkedList messageList) - { - message(client, messageList, false); - } + 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, 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, 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; + public static void message(Entity client, String message, boolean wiki) + { + if (client == null) + return; - if (!(client instanceof Player)) - return; + if (!(client instanceof Player)) + return; - /* + /* if (wiki) message = UtilWiki.link(message); - */ - - ((Player) client).sendMessage(message); - } - - public static Player searchExact(String name) - { - for (Player cur : UtilServer.getPlayers()) - if (cur.getName().equalsIgnoreCase(name)) - return cur; - - return null; - } - - public static Player searchExact(UUID uuid) - { - return UtilServer.getServer().getPlayer(uuid); - } - - public static String searchCollection(Player caller, String player, Collection coll, String collName, boolean inform) - { - LinkedList matchList = new LinkedList(); - - for (String cur : coll) - { - if (cur.equalsIgnoreCase(player)) - return cur; - - if (cur.toLowerCase().contains(player.toLowerCase())) - matchList.add(cur); - } - - // No / Non-Unique - if (matchList.size() != 1) - { - if (!inform) - return null; - - // Inform - message(caller, - F.main(collName + " Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + player - + C.mBody + "].")); - - if (matchList.size() > 0) - { - String matchString = ""; - for (String cur : matchList) - matchString += cur + " "; - - message(caller, - F.main(collName + " Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "].")); - } - - return null; - } - - return matchList.get(0); - } - - 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); - } - - public static void searchOffline(List matches, final Callback callback, final Player caller, - final String player, final boolean inform) - { - // No / Non-Unique - if (matches.size() != 1) - { - if (!inform || !caller.isOnline()) - { - callback.run(null); - return; - } - - // Inform - message(caller, - F.main("Offline Player Search", "" + C.mCount + matches.size() + C.mBody + " matches for [" + C.mElem - + player + C.mBody + "].")); - - if (matches.size() > 0) - { - String matchString = ""; - for (String cur : matches) - matchString += cur + " "; - if (matchString.length() > 1) - matchString = matchString.substring(0, matchString.length() - 1); - - message(caller, - F.main("Offline Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "].")); - } - - callback.run(null); - return; - } - - callback.run(matches.get(0)); - } - - public static LinkedList matchOnline(Player caller, String players, boolean inform) - { - LinkedList matchList = new LinkedList(); - - String failList = ""; - - for (String cur : players.split(",")) - { - Player match = searchOnline(caller, cur, inform); - - if (match != null) - matchList.add(match); - - else - failList += cur + " "; - } - - if (inform && failList.length() > 0) - { - failList = failList.substring(0, failList.length() - 1); - message(caller, F.main("Online Player(s) Search", "" + C.mBody + "Invalid [" + C.mElem + failList + C.mBody + "].")); - } - - return matchList; - } - - public static LinkedList getNearby(Location loc, double maxDist) - { - LinkedList nearbyMap = new LinkedList(); - - for (Player cur : loc.getWorld().getPlayers()) - { - if (UtilPlayer.isSpectator(cur)) - continue; - - if (cur.isDead()) - continue; - - double dist = loc.toVector().subtract(cur.getLocation().toVector()).length(); - - if (dist > maxDist) - continue; - - for (int i = 0; i < nearbyMap.size(); i++) - { - if (dist < loc.toVector().subtract(nearbyMap.get(i).getLocation().toVector()).length()) - { - nearbyMap.add(i, cur); - break; - } - } - - if (!nearbyMap.contains(cur)) - nearbyMap.addLast(cur); - } - - return nearbyMap; - } - - public static Player getClosest(Location loc, Collection ignore) - { - Player best = null; - double bestDist = 0; - - for (Player cur : loc.getWorld().getPlayers()) - { - if (UtilPlayer.isSpectator(cur)) - continue; - - if (cur.isDead()) - continue; + */ + + ((Player) client).sendMessage(message); + } + + public static Player searchExact(String name) + { + for (Player cur : UtilServer.getPlayers()) + if (cur.getName().equalsIgnoreCase(name)) + return cur; + + return null; + } + + public static Player searchExact(UUID uuid) + { + return UtilServer.getServer().getPlayer(uuid); + } + + public static String searchCollection(Player caller, String player, Collection coll, String collName, boolean inform) + { + LinkedList matchList = new LinkedList(); + + for (String cur : coll) + { + if (cur.equalsIgnoreCase(player)) + return cur; + + if (cur.toLowerCase().contains(player.toLowerCase())) + matchList.add(cur); + } + + // No / Non-Unique + if (matchList.size() != 1) + { + if (!inform) + return null; + + // Inform + message(caller, + F.main(collName + " Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + player + + C.mBody + "].")); + + if (matchList.size() > 0) + { + String matchString = ""; + for (String cur : matchList) + matchString += cur + " "; + + message(caller, + F.main(collName + " Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "].")); + } + + return null; + } + + return matchList.get(0); + } + + 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); + } + + public static void searchOffline(List matches, final Callback callback, final Player caller, + final String player, final boolean inform) + { + // No / Non-Unique + if (matches.size() != 1) + { + if (!inform || !caller.isOnline()) + { + callback.run(null); + return; + } + + // Inform + message(caller, + F.main("Offline Player Search", "" + C.mCount + matches.size() + C.mBody + " matches for [" + C.mElem + + player + C.mBody + "].")); + + if (matches.size() > 0) + { + String matchString = ""; + for (String cur : matches) + matchString += cur + " "; + if (matchString.length() > 1) + matchString = matchString.substring(0, matchString.length() - 1); + + message(caller, + F.main("Offline Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "].")); + } + + callback.run(null); + return; + } + + callback.run(matches.get(0)); + } + + public static LinkedList matchOnline(Player caller, String players, boolean inform) + { + LinkedList matchList = new LinkedList(); + + String failList = ""; + + for (String cur : players.split(",")) + { + Player match = searchOnline(caller, cur, inform); + + if (match != null) + matchList.add(match); + + else + failList += cur + " "; + } + + if (inform && failList.length() > 0) + { + failList = failList.substring(0, failList.length() - 1); + message(caller, F.main("Online Player(s) Search", "" + C.mBody + "Invalid [" + C.mElem + failList + C.mBody + "].")); + } + + return matchList; + } + + public static LinkedList getNearby(Location loc, double maxDist) + { + LinkedList nearbyMap = new LinkedList(); + + for (Player cur : loc.getWorld().getPlayers()) + { + if (UtilPlayer.isSpectator(cur)) + continue; + + if (cur.isDead()) + continue; + + double dist = loc.toVector().subtract(cur.getLocation().toVector()).length(); + + if (dist > maxDist) + continue; + + for (int i = 0; i < nearbyMap.size(); i++) + { + if (dist < loc.toVector().subtract(nearbyMap.get(i).getLocation().toVector()).length()) + { + nearbyMap.add(i, cur); + break; + } + } + + if (!nearbyMap.contains(cur)) + nearbyMap.addLast(cur); + } + + return nearbyMap; + } + + public static Player getClosest(Location loc, Collection ignore) + { + Player best = null; + double bestDist = 0; + + for (Player cur : loc.getWorld().getPlayers()) + { + if (UtilPlayer.isSpectator(cur)) + continue; + + if (cur.isDead()) + continue; + + if (ignore != null && ignore.contains(cur)) + continue; + + double dist = UtilMath.offset(cur.getLocation(), loc); + + if (best == null || dist < bestDist) + { + best = cur; + bestDist = dist; + } + } - if (ignore != null && ignore.contains(cur)) - continue; + return best; + } - double dist = UtilMath.offset(cur.getLocation(), loc); + public static Player getClosest(Location loc, Entity ignore) + { + Player best = null; + double bestDist = 0; - if (best == null || dist < bestDist) - { - best = cur; - bestDist = dist; - } - } + for (Player cur : loc.getWorld().getPlayers()) + { + if (UtilPlayer.isSpectator(cur)) + continue; - return best; - } + if (cur.isDead()) + continue; - public static Player getClosest(Location loc, Entity ignore) - { - Player best = null; - double bestDist = 0; + if (ignore != null && ignore.equals(cur)) + continue; - for (Player cur : loc.getWorld().getPlayers()) - { - if (UtilPlayer.isSpectator(cur)) - continue; + double dist = UtilMath.offset(cur.getLocation(), loc); - if (cur.isDead()) - continue; + if (best == null || dist < bestDist) + { + best = cur; + bestDist = dist; + } + } - if (ignore != null && ignore.equals(cur)) - continue; + return best; + } - double dist = UtilMath.offset(cur.getLocation(), loc); + public static void kick(Player player, String module, String message) + { + kick(player, module, message, true); + } - if (best == null || dist < bestDist) - { - best = cur; - bestDist = dist; - } - } + public static void kick(Player player, String module, String message, boolean log) + { + if (player == null) + return; - return best; - } + String out = ChatColor.RED + module + ChatColor.WHITE + " - " + ChatColor.YELLOW + message; + player.kickPlayer(out); - public static void kick(Player player, String module, String message) - { - kick(player, module, message, true); - } + // Log + if (log) + System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]"); + } - public static void kick(Player player, String module, String message, boolean log) - { - if (player == null) - return; + public static HashMap getInRadius(Location loc, double dR) + { + HashMap players = new HashMap(); - String out = ChatColor.RED + module + ChatColor.WHITE + " - " + ChatColor.YELLOW + message; - player.kickPlayer(out); + for (Player cur : loc.getWorld().getPlayers()) + { + if (UtilPlayer.isSpectator(cur)) + continue; - // Log - if (log) - System.out.println("Kicked Client [" + player.getName() + "] for [" + module + " - " + message + "]"); - } + double offset = UtilMath.offset(loc, cur.getLocation()); - public static HashMap getInRadius(Location loc, double dR) - { - HashMap players = new HashMap(); + if (offset < dR) + players.put(cur, 1 - (offset / dR)); + } - for (Player cur : loc.getWorld().getPlayers()) - { - if (UtilPlayer.isSpectator(cur)) - continue; + return players; + } - double offset = UtilMath.offset(loc, cur.getLocation()); + public static HashMap getPlayersInPyramid(Player player, double angleLimit, double distance) + { + HashMap players = new HashMap(); - if (offset < dR) - players.put(cur, 1 - (offset / dR)); - } + for (Player cur : player.getWorld().getPlayers()) + { + if (UtilPlayer.isSpectator(cur)) + continue; - return players; - } + //Get lower offset (eye to eye, eye to feet) + double offset = Math.min(UtilMath.offset(player.getEyeLocation(), cur.getEyeLocation()), + UtilMath.offset(player.getEyeLocation(), cur.getLocation())); - public static void health(Player player, double mod) - { - if (player.isDead()) - return; + if (offset < distance && UtilAlg.isTargetInPlayerPyramid(player, cur, angleLimit)) + players.put(cur, 1 - (offset / distance)); + } - double health = player.getHealth() + mod; + return players; + } - if (health < 0) - health = 0; + public static void health(Player player, double mod) + { + if (player.isDead()) + return; - if (health > player.getMaxHealth()) - health = player.getMaxHealth(); + double health = player.getHealth() + mod; - player.setHealth(health); - } + if (health < 0) + health = 0; - public static void hunger(Player player, int mod) - { - if (player.isDead()) - return; + if (health > player.getMaxHealth()) + health = player.getMaxHealth(); - int hunger = player.getFoodLevel() + mod; + player.setHealth(health); + } - if (hunger < 0) - hunger = 0; + public static void hunger(Player player, int mod) + { + if (player.isDead()) + return; - if (hunger > 20) - hunger = 20; + int hunger = player.getFoodLevel() + mod; - player.setFoodLevel(hunger); - } + if (hunger < 0) + hunger = 0; - public static boolean isOnline(String name) - { - return (searchExact(name) != null); - } + if (hunger > 20) + hunger = 20; - public static String safeNameLength(String name) - { - if (name.length() > 16) - name = name.substring(0, 16); + player.setFoodLevel(hunger); + } - return name; - } + public static boolean isOnline(String name) + { + return (searchExact(name) != null); + } - public static boolean isChargingBow(Player player) - { - if (!UtilGear.isMat(player.getItemInHand(), Material.BOW)) - return false; + public static String safeNameLength(String name) + { + if (name.length() > 16) + name = name.substring(0, 16); - return (((CraftEntity) player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0; - } + return name; + } - public static boolean is1_8(Player player) - { - return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47; - } + public static boolean isChargingBow(Player player) + { + if (!UtilGear.isMat(player.getItemInHand(), Material.BOW)) + return false; + + return (((CraftEntity) player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0; + } + + public static boolean is1_8(Player player) + { + return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47; + } public static void sendPacket(Player player, Packet... packets) { @@ -589,16 +609,16 @@ public class UtilPlayer return false; } - /* + /* public void setListName(Player player, CoreClient client) { StringBuilder playerNameBuilder = new StringBuilder(); String prefixChar = "*"; - + if (client.NAC().IsUsing()) playerNameBuilder.append(ChatColor.GREEN + prefixChar); else playerNameBuilder.append(ChatColor.DARK_GRAY + prefixChar); - + if (client.Rank().Has(Rank.OWNER, false)) playerNameBuilder.append(ChatColor.AQUA + prefixChar + ChatColor.RED); else if (client.Rank().Has(Rank.MODERATOR, false)) playerNameBuilder.append(ChatColor.AQUA + prefixChar + ChatColor.GOLD); else if (client.Rank().Has(Rank.DIAMOND, false)) playerNameBuilder.append(ChatColor.AQUA + prefixChar + ChatColor.WHITE); @@ -609,13 +629,13 @@ public class UtilPlayer playerNameBuilder.append(player.getName()); String playerName = playerNameBuilder.toString(); - + if (playerNameBuilder.length() > 16) { playerName = playerNameBuilder.substring(0, 16); } - + player.setPlayerListName(playerName); } - */ + */ } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index c5fc4caf5..761a2b7c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -39,9 +39,11 @@ import mineplex.core.chat.Chat; 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.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; import mineplex.core.disguise.DisguiseManager; @@ -66,6 +68,8 @@ import mineplex.core.status.ServerStatusManager; import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.timing.TimingManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; @@ -127,8 +131,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private Fire _fire; private ProjectileManager _projectileManager; - - private Portal _portal; private ArcadeShop _arcadeShop; @@ -1197,7 +1199,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation //Set Spec State player.setVelocity(new Vector(0,1,0)); -// player.setGameMode(GameMode.CREATIVE); // player.setAllowFlight(true); player.setFlying(true); player.setFlySpeed(0.1f); @@ -1206,7 +1207,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true); - //Game Team + //Game Team GetGame().GetScoreboard().SetPlayerTeam(player, "SPEC"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index e45dd4d46..c82c521cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -1500,38 +1500,6 @@ public class SurvivalGames extends SoloGame Collection blocks = UtilBlock.getInRadius(event.getEntity().getLocation(), 2.4).keySet(); - -// Iterator blockIter = blocks.iterator(); -// while (blockIter.hasNext()) -// { -// Block block = blockIter.next(); -// -// block.setType(Material.NETHERRACK); -// -// //Dont destroy above hollow ground -// -// if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN))) -// { -// blockIter.remove(); -// continue; -// } -// -// //Unstable, feel free to destroy! -// if (!isStableBlock(block)) -// continue; -// -// //Check for block stability via neighbours -// int stableSides = 0; -// if (isStableBlock(block.getRelative(BlockFace.NORTH))) stableSides++; -// if (isStableBlock(bl ck.getRelative(BlockFace.EAST))) stableSides++; -// if (isStableBlock(block.getRelative(BlockFace.SOUTH))) stableSides++; -// if (isStableBlock(block.getRelative(BlockFace.WEST))) stableSides++; -// -// //Stable! -// if (stableSides >= 3) -// blockIter.remove(); -// } - Manager.GetExplosion().BlockExplosion(blocks, event.getEntity().getLocation(), false); }