From 558b71f866a5d9aa723848adc8bcf9682c8d0a5d Mon Sep 17 00:00:00 2001 From: Cheese Date: Fri, 17 Jul 2015 11:48:14 +1000 Subject: [PATCH 1/5] fixed thigny --- .../mineplex/minecraft/game/classcombat/Class/ClientClass.java | 2 +- .../nautilus/game/arcade/game/games/skywars/TeamSkywars.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index ae8816f3a..e892c5f75 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -341,7 +341,7 @@ public class ClientClass if (notify) { ListSkills(_client.GetPlayer()); - _client.GetPlayer().getWorld().playSound(_client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); + _client.GetPlayer().playSound(_client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); _client.GetPlayer().sendMessage(F.main("Class", "You equipped " + F.skill(customBuild.Name) + ".")); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 3a372bdd5..441278a2d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -125,7 +125,7 @@ public class TeamSkywars extends Skywars private BlockFace getBlockface(BlockFace face) { - for(TeamColors faces : TeamColors.values()) { + for(BlockFace faces : BlockFace.values()) { if(faces.ordinal() == face.ordinal() + 1) { return face; From 3335a7c288c99e5dd4ab8322b81cea31befaa0e2 Mon Sep 17 00:00:00 2001 From: Cheese Date: Fri, 17 Jul 2015 12:07:09 +1000 Subject: [PATCH 2/5] changed skywars teams. forced at 16 teams. --- .../game/games/skywars/TeamSkywars.java | 121 +++++++----------- 1 file changed, 49 insertions(+), 72 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 441278a2d..63414d069 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; @@ -22,11 +23,6 @@ import org.bukkit.event.EventHandler; public class TeamSkywars extends Skywars { - - public boolean ForceTeamSize = true; - public int PlayersPerTeam = 2; - public int TeamCount = 0; - public TeamSkywars(ArcadeManager manager) { super(manager, GameType.SkywarsTeams, @@ -36,9 +32,6 @@ public class TeamSkywars extends Skywars "Craft or loot gear for combat", "Last team alive wins!" }); - - this.PlayersPerTeam = 2; - } @EventHandler @@ -47,82 +40,66 @@ public class TeamSkywars extends Skywars if (event.GetState() != GameState.Recruit) return; - ArrayList tempSpawns = this.GetTeamList().get(0).GetSpawns(); + ArrayList initialSpawns = this.GetTeamList().get(0).GetSpawns(); this.GetTeamList().clear(); ArrayList spawns = new ArrayList(); - for(Location location : tempSpawns) + + TeamColors color = TeamColors.DARK_AQUA; + + //Create 1 Team for each Spawn + int i = 0; + for(Location location : initialSpawns) { - for(int x = -1; x <= 1; x++) + i++; + + spawns.add(location); + + addRelativeSpawns(spawns, location); + + //Got Spawns + color = getNextColor(color); + GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns); + team.SetVisible(true); + GetTeamList().add(team); + } + } + + private void addRelativeSpawns(ArrayList spawns, Location location) + { + //Gather Extra Spawns + for(int x = -1; x <= 1; x++) + { + for(int z = -1; z <= 1; z++) { - for(int z = -1; z <= 1; z++) + if(x != 0 && z != 0) { - if(x != 0 && z != 0) + Location newSpawn = location.clone().add(x, 0, z); + + //Search Downward for Solid + while (UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)) && newSpawn.getY() > location.getY()-5) { - Location spawnLocation = location.clone().add(x, 0, z); - if(spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(BlockFace.DOWN).getType() == Material.AIR) - { - boolean foundBlock = false; - Location tempLocation = spawnLocation.clone(); - BlockFace currentBlockFace = BlockFace.NORTH; - while(!foundBlock) - { - for(BlockFace face : BlockFace.values()) - { - if(spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(face).getType() != Material.AIR) - { - spawnLocation = tempLocation.getWorld().getBlockAt(tempLocation).getRelative(face).getLocation().add(0, 1, 0); - foundBlock = true; - } - } - if(!foundBlock) - { - tempLocation = spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(currentBlockFace).getLocation(); - currentBlockFace = getBlockface(currentBlockFace); - if(currentBlockFace == BlockFace.SELF) - { - currentBlockFace = getBlockface(currentBlockFace); - tempLocation = spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(currentBlockFace).getLocation(); - spawnLocation = tempLocation; - } - } - } - } - while(spawnLocation.getWorld().getBlockAt(spawnLocation).getType() != Material.AIR) - { - spawnLocation.add(0, 1, 0); - } - spawns.add(spawnLocation); + newSpawn.subtract(0, 1, 0); + } + + //Move Up out of Solid + while (!UtilBlock.airFoliage(newSpawn.getBlock()) && newSpawn.getY() < location.getY()+5) + { + newSpawn.add(0, 1, 0); + } + + //On Solid, with 2 Air Above + if (UtilBlock.airFoliage(newSpawn.getBlock()) && + UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) && + !UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN))) + { + spawns.add(newSpawn); } } } } - - TeamColors color = TeamColors.DARK_AQUA; - - if(!this.ForceTeamSize) - { - for(int i = 1; i <= this.TeamCount; i++) - { - color = getNextColor(color); - GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns); - team.SetVisible(true); - GetTeamList().add(team); - } - } - else - { - for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++) - { - System.out.println("Test"); - color = getNextColor(color); - GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns); - team.SetVisible(true); - GetTeamList().add(team); - } - } } - + private BlockFace getBlockface(BlockFace face) { for(BlockFace faces : BlockFace.values()) { From 63f6adf2959de26b5c38b03bc7c934bd4dc19d21 Mon Sep 17 00:00:00 2001 From: Cheese Date: Fri, 17 Jul 2015 12:50:34 +1000 Subject: [PATCH 3/5] fixed spawn picking --- .../mineplex/core/common/util/UtilAlg.java | 93 +++++++++++++++ .../src/nautilus/game/arcade/game/Game.java | 1 + .../nautilus/game/arcade/game/GameTeam.java | 108 ++++++------------ .../games/survivalgames/SurvivalGames.java | 1 + 4 files changed, 129 insertions(+), 74 deletions(-) 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 fad8f1eef..d686faa2d 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 @@ -7,6 +7,7 @@ import java.util.TreeSet; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -260,4 +261,96 @@ public class UtilAlg return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) || isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit); } + + public static Location getLocationAwayFromPlayers(ArrayList locs, ArrayList players) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + for (Player player : players) + { + //Different Worlds + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest > bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } + + public static Location getLocationNearPlayers(ArrayList locs, ArrayList players, ArrayList dontOverlap) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + boolean valid = true; + + //Dont spawn on other players + for (Player player : dontOverlap) + { + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (dist < 0.8) + { + valid = false; + break; + } + } + + if (!valid) + continue; + + //Find closest player + for (Player player : players) + { + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest < bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 7a413d04a..c59fc2353 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -210,6 +210,7 @@ public abstract class Game implements Listener public int TickPerTeleport = 1; public boolean SpawnNearAllies = false; + public boolean SpawnNearEnemies = false; public boolean StrictAntiHack = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index dee18f3d2..bc6940d90 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -7,6 +7,7 @@ import java.util.Iterator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -97,88 +98,47 @@ public class GameTeam public Location GetSpawn() { - //Spawn Allies Together! - if (Host.IsLive() && Host.SpawnNearAllies) + //Keep allies together + if (!Host.IsLive() && Host.SpawnNearAllies) { - Location closestLoc = null; - double closestDist = 0; - - for (Location loc : _spawns) + //Find Location Nearest Ally + Location loc = UtilAlg.getLocationNearPlayers(_spawns, GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; + + //No allies existed spawned yet + + //Spawn near enemies (used for SG) + if (Host.SpawnNearEnemies) { - //Check if Location is closer! - for (Player player : this.GetPlayers(true)) - { - //Different Worlds - if (!player.getWorld().equals(loc.getWorld())) - continue; - - double dist = UtilMath.offset(player.getLocation(), loc); - - //Dont Spawn Inside Ally - if (dist < 0.75) - continue; - - //Find Closest Enemy - double closestEnemy = -1; - - for (Player enemy : Host.GetPlayers(true)) - { - if (!enemy.getWorld().equals(loc.getWorld())) - continue; - - if (this.HasPlayer(enemy)) - continue; - - double enemyDist = UtilMath.offset(player.getLocation(), loc); - - if (closestEnemy == -1 || enemyDist < closestEnemy) - { - closestEnemy = enemyDist; - } - } - - //Dont Spawn Inside Enemy - if (closestEnemy != -1 && closestEnemy < 0.75) - continue; - - //Good Location! - if (closestLoc == null || dist < closestDist) - { - closestLoc = loc; - closestDist = dist; - } - } + loc = UtilAlg.getLocationNearPlayers(_spawns, Host.GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; } - - if (closestLoc != null) - return closestLoc; + //Spawn away from enemies + else + { + loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); + if (loc != null) + return loc; + } } - //Spawn Furthest Away! else { - Location furthestLoc = null; - double furthestDist = 0; - - for (Location loc : _spawns) + //Spawn near players + if (Host.SpawnNearEnemies) { - for (Player player : Host.GetPlayers(true)) - { - //Different Worlds - if (!player.getWorld().equals(loc.getWorld())) - continue; - - double dist = UtilMath.offsetSquared(player.getLocation(), loc); - - if (furthestLoc == null || dist > furthestDist) - { - furthestLoc = loc; - furthestDist = dist; - } - } + Location loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); + if (loc != null) + return loc; + } + //Spawn away from players + else + { + Location loc = UtilAlg.getLocationNearPlayers(_spawns, Host.GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; } - - if (furthestLoc != null) - return furthestLoc; } return _spawns.get(UtilMath.r(_spawns.size())); 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 64d9fa498..4cd409f62 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 @@ -218,6 +218,7 @@ public abstract class SurvivalGames extends Game WorldBoundaryKill = false; SpawnNearAllies = true; + SpawnNearEnemies = true; //This is to ensure theres no 'gaps' of 1 between teams, hence forcing a team to get split. DamageSelf = true; DamageTeamSelf = true; From cfb4911c25ce742cc4efe3d83000027164d34a48 Mon Sep 17 00:00:00 2001 From: Cheese Date: Fri, 17 Jul 2015 12:54:53 +1000 Subject: [PATCH 4/5] added ability for teams will fill before moving onto next team --- .../src/nautilus/game/arcade/game/Game.java | 13 +++++++++++++ .../arcade/game/games/smash/TeamSuperSmash.java | 2 +- .../game/games/survivalgames/TeamSurvivalGames.java | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index c59fc2353..24c3fe27d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -209,6 +209,8 @@ public abstract class Game implements Listener public int TickPerTeleport = 1; + public int EnforceTeamSize = -1; + public boolean SpawnNearAllies = false; public boolean SpawnNearEnemies = false; @@ -614,6 +616,17 @@ public abstract class Game implements Listener public GameTeam ChooseTeam(Player player) { + if (EnforceTeamSize != -1) + { + for (int i = 0; i < _teamList.size(); i++) + { + if (_teamList.get(i).GetSize() < EnforceTeamSize) + { + return _teamList.get(i); + } + } + } + GameTeam team = null; //Random Team diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 6c2d0cffe..1b096c267 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -33,6 +33,7 @@ public class TeamSuperSmash extends SuperSmash }); this.PlayersPerTeam = 2; + this.EnforceTeamSize = 2; } @Override @@ -213,5 +214,4 @@ public class TeamSuperSmash extends SuperSmash return players; } - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java index e2dbcbbb7..0f0d3ca73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -37,6 +37,7 @@ public class TeamSurvivalGames extends SurvivalGames }); this.PlayersPerTeam = 2; + this.EnforceTeamSize = 2; } From 44102842c9df2e4df24aec7430687f730da2cbd2 Mon Sep 17 00:00:00 2001 From: Cheese Date: Fri, 17 Jul 2015 13:27:55 +1000 Subject: [PATCH 5/5] added some velocity debug --- .../src/mineplex/core/common/util/UtilAction.java | 10 +++++++++- .../minecraft/game/core/damage/DamageManager.java | 9 +++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java index 1b870ada9..ab1814725 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java @@ -1,7 +1,9 @@ package mineplex.core.common.util; +import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; public class UtilAction @@ -37,6 +39,12 @@ public class UtilAction //Velocity ent.setFallDistance(0); - ent.setVelocity(vec); + ent.setVelocity(vec); + + //Debug + if (ent instanceof Player && UtilGear.isMat(((Player)ent).getItemInHand(), Material.SUGAR)) + { + UtilPlayer.message(ent, F.main("Debug", "Velocity Sent: " + vec.length())); + } } } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index aab72ed1e..8e052c32d 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -391,10 +391,11 @@ public class DamageManager extends MiniPlugin trajectory.setY(Math.abs(trajectory.getY())); //Apply - UtilAction.velocity(event.GetDamageeEntity(), - trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); + double vel = 0.2 + trajectory.length() * 0.8; + + UtilAction.velocity(event.GetDamageeEntity(), trajectory, vel, + false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); } - } catch (IllegalAccessException e) { @@ -414,7 +415,7 @@ public class DamageManager extends MiniPlugin { for (Player player : UtilServer.getPlayers()) { - if (!UtilGear.isMat(player.getItemInHand(), Material.BOOK)) + if (!UtilGear.isMat(player.getItemInHand(), Material.COMMAND)) continue; UtilPlayer.message(player, " ");