diff options
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/command/location')
5 files changed, 17 insertions, 24 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java index abe6f69..93c0d8c 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java @@ -22,18 +22,14 @@ package net.tylermurphy.hideAndSeek.command.location; import net.tylermurphy.hideAndSeek.command.ICommand; import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import static net.tylermurphy.hideAndSeek.configuration.Config.*; public class SetExitLocation implements ICommand { - public void execute(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) return; - Player player = (Player) sender; - - LocationUtils.setLocation(player, Locations.EXIT, vector -> { - exitWorld = player.getLocation().getWorld().getName(); + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.EXIT, vector -> { + exitWorld = sender.getLocation().getWorld().getName(); exitPosition = vector; }); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java index fab7076..eb228f9 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java @@ -22,19 +22,15 @@ package net.tylermurphy.hideAndSeek.command.location; import net.tylermurphy.hideAndSeek.command.ICommand; import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import static net.tylermurphy.hideAndSeek.configuration.Config.*; public class SetLobbyLocation implements ICommand { - public void execute(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) return; - Player player = (Player) sender; - - LocationUtils.setLocation(player, Locations.LOBBY, vector -> { - lobbyWorld = player.getLocation().getWorld().getName(); + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.LOBBY, vector -> { + lobbyWorld = sender.getLocation().getWorld().getName(); lobbyPosition = vector; }); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java index 1f454d6..5ecfb8d 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java @@ -23,7 +23,6 @@ import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.command.ICommand; import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils; import net.tylermurphy.hideAndSeek.command.location.util.Locations; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import static net.tylermurphy.hideAndSeek.configuration.Config.*; @@ -31,22 +30,19 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message; public class SetSpawnLocation implements ICommand { - public void execute(CommandSender sender, String[] args) { - if (!(sender instanceof Player)) return; - Player player = (Player) sender; - - LocationUtils.setLocation(player, Locations.GAME, vector -> { + public void execute(Player sender, String[] args) { + LocationUtils.setLocation(sender, Locations.GAME, vector -> { if (worldBorderEnabled && vector.distance(worldBorderPosition) > 100) { sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION")); throw new RuntimeException("World border not enabled or not in valid position!"); } - if (!player.getLocation().getWorld().getName().equals(spawnWorld)) { + if (!sender.getLocation().getWorld().getName().equals(spawnWorld)) { Main.getInstance().getGame().getWorldLoader().unloadMap(); - Main.getInstance().getGame().getWorldLoader().setNewMap(player.getLocation().getWorld().getName()); + Main.getInstance().getGame().getWorldLoader().setNewMap(sender.getLocation().getWorld().getName()); } - spawnWorld = player.getLocation().getWorld().getName(); + spawnWorld = sender.getLocation().getWorld().getName(); spawnPosition = vector; }); } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java index e0fc033..50d1776 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java @@ -1,7 +1,6 @@ package net.tylermurphy.hideAndSeek.command.location.util; import net.tylermurphy.hideAndSeek.Main; -import net.tylermurphy.hideAndSeek.game.Game; import net.tylermurphy.hideAndSeek.game.util.Status; import org.bukkit.Location; import org.bukkit.World; @@ -14,6 +13,9 @@ import java.util.function.Consumer; import static net.tylermurphy.hideAndSeek.configuration.Config.*; import static net.tylermurphy.hideAndSeek.configuration.Localization.message; +/** + * @author bobby29831 + */ public class LocationUtils { /** diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java index bde5456..59e1517 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java @@ -1,5 +1,8 @@ package net.tylermurphy.hideAndSeek.command.location.util; +/** + * @author bobby29831 + */ public enum Locations { GAME("spawns.game", "GAME_SPAWN"), |