diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballGame.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballGame.java index 74353a71c..23ec55c0e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballGame.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballGame.java @@ -52,6 +52,9 @@ import org.bukkit.util.Vector; import com.google.common.collect.Lists; +/** + * Instance class for running a basketball game in the hub + */ public class BasketballGame implements Listener { private HubManager _hub; @@ -90,7 +93,6 @@ public class BasketballGame implements Listener _start = System.currentTimeMillis(); } - //PRIVATE NON-VOID private Entity spawnBall(Location loc) { _velocity = -7; @@ -143,7 +145,6 @@ public class BasketballGame implements Listener return 2; } - //PRIVATE VOID private void reboundBall() { if (_ball == null) @@ -390,12 +391,21 @@ public class BasketballGame implements Listener } } - //PUBLIC NON-VOID + /** + * Checks how long this game has been running + * @return The amount of time this game has been running + */ public long getGameAge() { return System.currentTimeMillis() - _start; } + /** + * Checks whether a location is out of bounds of the main arena + * @param loc The location to check + * @param ball Whether to base calculations on the location being the location of the ball + * @return Whether the location is out of bounds + */ public boolean isOutOfBounds(Location loc, boolean ball) { if (ball) @@ -424,6 +434,10 @@ public class BasketballGame implements Listener return false; } + /** + * Fetches the entity representing the ball in this game + * @return The entity representing the ball, or null if a player is dribbling + */ public Entity getBall() { return _ball; @@ -448,12 +462,18 @@ public class BasketballGame implements Listener return null; } + /** + * Fetches the list of players in this game + * @return The list containing all players in this game + */ public List getPlayers() { return _players; } - //PUBLIC VOID + /** + * Forces the game to end, unregistering all listeners and cleaning up created entities + */ public void end() { HandlerList.unregisterAll(this); @@ -539,7 +559,7 @@ public class BasketballGame implements Listener } } } - if (_dribbling != null && !_dribbling.isOnline()) + if (_dribbling != null && (!_dribbling.isOnline() || !_players.contains(_dribbling))) { _dribbling = null; spawnNeutralBall(); @@ -609,13 +629,6 @@ public class BasketballGame implements Listener return; } - if (isOutOfBounds(event.getTo(), false)) - { - event.getPlayer().teleport(event.getFrom()); - Vector bounce = UtilAlg.getTrajectory(event.getTo(), DataLoc.CENTER_COURT.getLocation(_world)); - event.getPlayer().setVelocity(bounce.normalize()); - event.getPlayer().sendMessage(F.main("Game", "You aren't allowed to go out of bounds!")); - } if (_dribbling != null && event.getPlayer().getEntityId() == _dribbling.getEntityId()) { _lastDribbleMove = System.currentTimeMillis(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballManager.java index b7bdbe541..62655fc6f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballManager.java @@ -39,6 +39,9 @@ import org.bukkit.plugin.java.JavaPlugin; import com.google.common.collect.Lists; +/** + * Manager class for creating and maintaining basketball games in the hub + */ public class BasketballManager extends MiniPlugin { private HubManager _hubManager; @@ -70,7 +73,47 @@ public class BasketballManager extends MiniPlugin _game = null; } } + + private void setBasketballMode(Player player, boolean enabled, Color color) + { + if (_game == null) + { + return; + } + + if (enabled) + { + _game.getPlayers().add(player); + if (color == null) + UtilPlayer.message(player, F.main("Basketball", "You have entered " + F.elem("Basketball Mode") + ".")); + else if (color == Color.RED) + UtilPlayer.message(player, F.main("Basketball", "You have joined " + F.elem(C.cRed + "Red Basketball Team") + ".")); + else if (color == Color.AQUA) + UtilPlayer.message(player, F.main("Basketball", "You have joined " + F.elem(C.cAqua + "Blue Basketball Team") + ".")); + + ArrayList outfit = new ArrayList(); + outfit.add("Team Helmet"); + outfit.add("Team Shirt"); + outfit.add("Team Pants"); + outfit.add("Team Boots"); + + _hubManager.GetGadget().disableAll(player, outfit); + _hubManager.GetMount().DisableAll(player); + _hubManager.getPetManager().disableAll(player); + } + else + { + _game.getPlayers().remove(player); + UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Basketball Mode") + ".")); + } + } + + /** + * Fetches the color of a player's team based on their outfit + * @param player The player to check + * @return The color of the player's team, or null if they are not wearing a team outfit + */ public Color getTeamColor(Player player) { //All pieces are always same color! @@ -82,7 +125,12 @@ public class BasketballManager extends MiniPlugin return null; } - + + /** + * Checks whether an entity is in the bounds considered the basketball court + * @param entity The entity to check + * @return Whether the entity is in the bounds considered the basketball court + */ public boolean inPlayerArena(Entity entity) { if(!entity.getWorld().equals(_world.getWorld())) @@ -204,41 +252,6 @@ public class BasketballManager extends MiniPlugin } } - public void setBasketballMode(Player player, boolean enabled, Color color) - { - if (_game == null) - { - return; - } - - if (enabled) - { - _game.getPlayers().add(player); - - if (color == null) - UtilPlayer.message(player, F.main("Basketball", "You have entered " + F.elem("Basketball Mode") + ".")); - else if (color == Color.RED) - UtilPlayer.message(player, F.main("Basketball", "You have joined " + F.elem(C.cRed + "Red Basketball Team") + ".")); - else if (color == Color.AQUA) - UtilPlayer.message(player, F.main("Basketball", "You have joined " + F.elem(C.cAqua + "Blue Basketball Team") + ".")); - - ArrayList outfit = new ArrayList(); - outfit.add("Team Helmet"); - outfit.add("Team Shirt"); - outfit.add("Team Pants"); - outfit.add("Team Boots"); - - _hubManager.GetGadget().disableAll(player, outfit); - _hubManager.GetMount().DisableAll(player); - _hubManager.getPetManager().disableAll(player); - } - else - { - _game.getPlayers().remove(player); - UtilPlayer.message(player, F.main("Parkour", "You have exited " + F.elem("Basketball Mode") + ".")); - } - } - @EventHandler public void disableGadgets(GadgetEnableEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballTeam.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballTeam.java index 8a36b23d7..73b0a27f9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballTeam.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/basketball/BasketballTeam.java @@ -5,6 +5,9 @@ import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.World; +/** + * Enum containing all teams for hub basketball + */ public enum BasketballTeam { RED(Color.RED, ChatColor.RED, "Red", DataLoc.RED_SPAWNS), @@ -24,26 +27,48 @@ public enum BasketballTeam _spawns = spawns; } + /** + * Fetches the color of this team's uniform + * @return The color of this team's uniform + */ public Color getColor() { return _color; } + /** + * Fetches the color of this team in chat + * @return The color of this team in chat + */ public ChatColor getChatColor() { return _cColor; } + /** + * Fetches the display name of this team + * @return The display name of this team + */ public String getName() { return _cColor + _name + " Team"; } + /** + * Fetches all possible spawns for this team + * @param world The world to create the locations in + * @return All possible spawns for this team + */ public Location[] getSpawns(World world) { return _spawns.getLocations(world); } + /** + * Fetches the team matching a color + * @param color The color to match a team to + * @return The team matching the color, or null if one is not found + */ public static BasketballTeam getFromColor(Color color) { for (BasketballTeam team : BasketballTeam.values()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/Basketball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/Basketball.java index 9dd0e9418..3314430fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/Basketball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/Basketball.java @@ -85,7 +85,10 @@ public class Basketball extends TeamGame { "Dribble the ball to the other side of the court", "Shoot into the hoop to score 2 or 3 points", - "Team with most points at the end wins!" + "Team with most points at the end wins!", + "Left Click to pass or do a layup", + "Right Click to make a distance shot", + "Left Click an opposing player to try and steal the ball" } ); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/kit/BasketballPlayerKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/kit/BasketballPlayerKit.java index cd4faf95a..0bbfea658 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/kit/BasketballPlayerKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/basketball/kit/BasketballPlayerKit.java @@ -12,11 +12,17 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +/** + * Kit for Basketball Game + */ public class BasketballPlayerKit extends ProgressingKit { private static final String[] DESCRIPTION = { - "A true NBA Champion!" + "A true Basketball Champion!", + "Left Click to pass or do a layup", + "Right Click to make a distance shot", + "Left Click an opposing player to try and steal the ball" }; private static final Perk[] PERKS =