summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/command
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-05-13 13:42:26 -0400
committerGitHub <noreply@github.com>2022-05-13 13:42:26 -0400
commit7d152668d753c611c2f1b553332e257283fadcd6 (patch)
tree3c8ae0fc7edfac96191d80a31d38e8afc57a6113 /src/main/java/net/tylermurphy/hideAndSeek/command
parentparallel change on master (diff)
parenttypos: fix typos in CONTRIBUTING.md (diff)
downloadkenshinshideandseek-7d152668d753c611c2f1b553332e257283fadcd6.tar.gz
kenshinshideandseek-7d152668d753c611c2f1b553332e257283fadcd6.tar.bz2
kenshinshideandseek-7d152668d753c611c2f1b553332e257283fadcd6.zip
Merge pull request #53 from bobby29831/1.4.3
Implement better coding practices
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/command')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Help.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Join.java11
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java13
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java13
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java15
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java21
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java23
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java11
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java11
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java16
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java19
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Start.java27
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java10
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Top.java16
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java12
15 files changed, 103 insertions, 118 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
index c1934a9..d773e60 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
@@ -19,10 +19,9 @@
package net.tylermurphy.hideAndSeek.command;
-import org.bukkit.command.CommandSender;
-
import net.md_5.bungee.api.ChatColor;
import net.tylermurphy.hideAndSeek.game.CommandHandler;
+import org.bukkit.command.CommandSender;
public class Help implements ICommand {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
index 0ca21d1..446fb2d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
@@ -19,29 +19,28 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.Game;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.isNotSetup()) {
+ if (Game.isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
Player player = Bukkit.getServer().getPlayer(sender.getName());
- if(player == null) {
+ if (player == null) {
sender.sendMessage(errorPrefix + message("COMMAND_ERROR"));
return;
}
- if(Board.isPlayer(player)){
+ if (Board.contains(player)) {
sender.sendMessage(errorPrefix + message("GAME_INGAME"));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
index 8d8cf76..f508498 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
@@ -19,31 +19,28 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.Game;
-import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.Bukkit;
-import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Leave implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.isNotSetup()) {
+ if (Game.isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
Player player = Bukkit.getServer().getPlayer(sender.getName());
- if(player == null) {
+ if (player == null) {
sender.sendMessage(errorPrefix + message("COMMAND_ERROR"));
return;
}
- if(!Board.isPlayer(player)) {
+ if (!Board.contains(player)) {
sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
index fc2592b..d2ed069 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
@@ -19,23 +19,22 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
+import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Items;
+import net.tylermurphy.hideAndSeek.configuration.Localization;
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.command.CommandSender;
-import net.tylermurphy.hideAndSeek.configuration.Config;
-import net.tylermurphy.hideAndSeek.configuration.Localization;
-
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Reload implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
index f5e63a5..83f2580 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
@@ -19,8 +19,7 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
+import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.Bukkit;
@@ -28,30 +27,30 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
-import net.tylermurphy.hideAndSeek.Main;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SaveMap implements ICommand {
public static boolean runningBackup = false;
public void execute(CommandSender sender, String[] args) {
- if(!mapSaveEnabled){
+ if (!mapSaveEnabled) {
sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED"));
return;
}
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
+ if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
World world = Bukkit.getServer().getWorld(spawnWorld);
- if(world == null){
+ if (world == null) {
throw new RuntimeException("Unable to get world: " + spawnWorld);
}
world.save();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
index 798b99f..e049a8e 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
@@ -19,33 +19,32 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetBorder implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if(spawnPosition == null) {
+ if (spawnPosition == null) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
- if(args.length < 3) {
+ if (args.length < 3) {
worldborderEnabled = false;
addToConfig("worldBorder.enabled",false);
saveConfig();
sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
- Game.resetWorldborder(spawnWorld);
+ Game.resetWorldBorder(spawnWorld);
return;
}
int num,delay,change;
@@ -61,11 +60,11 @@ public class SetBorder implements ICommand {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[2]));
return;
}
- if(num < 100) {
+ if (num < 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_MIN_SIZE"));
return;
}
- if(change < 1) {
+ if (change < 1) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE"));
return;
}
@@ -74,7 +73,7 @@ public class SetBorder implements ICommand {
newWorldborderPosition.setX(player.getLocation().getBlockX());
newWorldborderPosition.setY(0);
newWorldborderPosition.setZ(player.getLocation().getBlockZ());
- if(spawnPosition.distance(newWorldborderPosition) > 100) {
+ if (spawnPosition.distance(newWorldborderPosition) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
return;
}
@@ -91,7 +90,7 @@ public class SetBorder implements ICommand {
addToConfig("worldBorder.move", worldborderChange);
sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
saveConfig();
- Game.resetWorldborder(spawnWorld);
+ Game.resetWorldBorder(spawnWorld);
}
public String getLabel() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
index 9f4101a..719d675 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
@@ -19,43 +19,42 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetBounds implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if(spawnPosition == null) {
+ if (spawnPosition == null) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
Player player = (Player) sender;
- if(!player.getWorld().getName().equals(spawnWorld)){
+ if (!player.getWorld().getName().equals(spawnWorld)) {
sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
return;
}
- if(player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0){
+ if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0) {
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
return;
}
boolean first = true;
- if(saveMinX != 0 && saveMinZ != 0 && saveMaxX != 0 && saveMaxZ != 0) {
+ if (saveMinX != 0 && saveMinZ != 0 && saveMaxX != 0 && saveMaxZ != 0) {
saveMinX = 0; saveMinZ= 0; saveMaxX = 0; saveMaxZ = 0;
}
- if(saveMaxX == 0) {
+ if (saveMaxX == 0) {
addToConfig("bounds.max.x", player.getLocation().getBlockX());
saveMaxX = player.getLocation().getBlockX();
- } else if(saveMaxX < player.getLocation().getBlockX()) {
+ } else if (saveMaxX < player.getLocation().getBlockX()) {
first = false;
addToConfig("bounds.max.x", player.getLocation().getBlockX());
addToConfig("bounds.min.x", saveMaxX);
@@ -66,10 +65,10 @@ public class SetBounds implements ICommand {
addToConfig("bounds.min.x", player.getLocation().getBlockX());
saveMinX = player.getLocation().getBlockX();
}
- if(saveMaxZ == 0) {
+ if (saveMaxZ == 0) {
addToConfig("bounds.max.z", player.getLocation().getBlockZ());
saveMaxZ = player.getLocation().getBlockZ();
- } else if(saveMaxZ < player.getLocation().getBlockZ()) {
+ } else if (saveMaxZ < player.getLocation().getBlockZ()) {
first = false;
addToConfig("bounds.max.z", player.getLocation().getBlockZ());
addToConfig("bounds.min.z", saveMaxZ);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
index 7461767..de33b93 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
@@ -19,8 +19,6 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.World;
@@ -28,18 +26,19 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetExitLocation implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Vector newExitPosition = new Vector();
Player player = (Player) sender;
- if(player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
+ if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0) {
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
return;
}
@@ -47,7 +46,7 @@ public class SetExitLocation implements ICommand {
newExitPosition.setY(player.getLocation().getBlockY());
newExitPosition.setZ(player.getLocation().getBlockZ());
World world = player.getLocation().getWorld();
- if(world == null){
+ if (world == null) {
throw new RuntimeException("Unable to get world: " + spawnWorld);
}
exitWorld = world.getName();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java
index 69e5e52..a9351fd 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetLobbyLocation.java
@@ -19,8 +19,6 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.World;
@@ -28,18 +26,19 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetLobbyLocation implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Vector newLobbyPosition = new Vector();
Player player = (Player) sender;
- if(player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
+ if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0) {
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
return;
}
@@ -47,7 +46,7 @@ public class SetLobbyLocation implements ICommand {
newLobbyPosition.setY(player.getLocation().getBlockY());
newLobbyPosition.setZ(player.getLocation().getBlockZ());
World world = player.getLocation().getWorld();
- if(world == null){
+ if (world == null) {
throw new RuntimeException("Unable to get world: " + spawnWorld);
}
lobbyWorld = world.getName();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java
index d5e1cba..6a9b572 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetSpawnLocation.java
@@ -19,8 +19,6 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import net.tylermurphy.hideAndSeek.world.WorldLoader;
@@ -29,34 +27,34 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
-import static net.tylermurphy.hideAndSeek.configuration.Config.addToConfig;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class SetSpawnLocation implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Vector newSpawnPosition = new Vector();
Player player = (Player) sender;
- if(player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
+ if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0) {
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
return;
}
newSpawnPosition.setX(player.getLocation().getBlockX());
newSpawnPosition.setY(player.getLocation().getBlockY());
newSpawnPosition.setZ(player.getLocation().getBlockZ());
- if(worldborderEnabled && newSpawnPosition.distance(worldborderPosition) > 100) {
+ if (worldborderEnabled && newSpawnPosition.distance(worldborderPosition) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
return;
}
World world = player.getLocation().getWorld();
- if(world == null){
+ if (world == null) {
throw new RuntimeException("Unable to get world: " + spawnWorld);
}
- if(mapSaveEnabled && !world.getName().equals(spawnWorld)){
+ if (mapSaveEnabled && !world.getName().equals(spawnWorld)) {
Game.worldLoader.unloadMap();
Game.worldLoader = new WorldLoader(world.getName());
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
index 14a5d6f..ec932d8 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
@@ -19,15 +19,14 @@
package net.tylermurphy.hideAndSeek.command;
+import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.Game;
import org.bukkit.command.CommandSender;
-import net.tylermurphy.hideAndSeek.Main;
+import java.io.File;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-import java.io.File;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Setup implements ICommand {
@@ -36,30 +35,30 @@ public class Setup implements ICommand {
String msg = message("SETUP").toString();
int count = 0;
- if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
+ if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_GAME");
count++;
}
- if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) {
+ if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_LOBBY");
count++;
}
- if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
+ if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
msg = msg + "\n" + message("SETUP_EXIT");
count++;
}
- if(saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) {
+ if (saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) {
msg = msg + "\n" + message("SETUP_BOUNDS");
count++;
}
- if(mapSaveEnabled) {
+ if (mapSaveEnabled) {
File destenation = new File(Main.root + File.separator + Game.getGameWorld());
if (!destenation.exists()) {
msg = msg + "\n" + message("SETUP_SAVEMAP");
count++;
}
}
- if(count < 1) {
+ if (count < 1) {
sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
} else {
sender.sendMessage(msg);
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
index 8605764..78f9a64 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
@@ -19,8 +19,7 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
-
+import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
@@ -28,36 +27,36 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import net.tylermurphy.hideAndSeek.Main;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import java.util.Optional;
import java.util.Random;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
public class Start implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.isNotSetup()) {
+ if (Game.isNotSetup()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
- if(Game.status != Status.STANDBY) {
+ if (Game.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if(!Board.isPlayer(sender)) {
+ if (!Board.contains(sender)) {
sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
return;
}
- if(Board.size() < minPlayers) {
+ if (Board.size() < minPlayers) {
sender.sendMessage(errorPrefix + message("START_MIN_PLAYERS").addAmount(minPlayers));
return;
}
String seekerName;
- if(args.length < 1) {
+ if (args.length < 1) {
Optional<Player> rand = Board.getPlayers().stream().skip(new Random().nextInt(Board.size())).findFirst();
- if(!rand.isPresent()){
+ if (!rand.isPresent()) {
Main.plugin.getLogger().warning("Failed to select random seeker.");
return;
}
@@ -66,12 +65,12 @@ public class Start implements ICommand {
seekerName = args[0];
}
Player temp = Bukkit.getPlayer(seekerName);
- if(temp == null) {
+ if (temp == null) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName));
return;
}
Player seeker = Board.getPlayer(temp.getUniqueId());
- if(seeker == null) {
+ if (seeker == null) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName));
return;
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
index efbbfac..2a310e8 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
@@ -19,22 +19,22 @@
package net.tylermurphy.hideAndSeek.command;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
import net.tylermurphy.hideAndSeek.game.Game;
import net.tylermurphy.hideAndSeek.util.Status;
import org.bukkit.command.CommandSender;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Stop implements ICommand {
public void execute(CommandSender sender, String[] args) {
- if(Game.isNotSetup()) {
+ if (Game.isNotSetup()) {
sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
return;
}
- if(Game.status == Status.STARTING || Game.status == Status.PLAYING) {
+ if (Game.status == Status.STARTING || Game.status == Status.PLAYING) {
Game.broadcastMessage(abortPrefix + message("STOP"));
Game.end();
} else {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
index 51e3574..916656d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
@@ -27,21 +27,21 @@ import org.bukkit.command.CommandSender;
import java.util.List;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Top implements ICommand {
public void execute(CommandSender sender, String[] args) {
int page;
- if(args.length == 0) page = 1;
+ if (args.length == 0) page = 1;
else try{
page = Integer.parseInt(args[0]);
- } catch(Exception e){
+ } catch(Exception e) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
return;
}
- if(page < 1){
+ if (page < 1) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(page));
return;
}
@@ -50,14 +50,14 @@ public class Top implements ICommand {
ChatColor.WHITE, ChatColor.BOLD, ChatColor.GRAY, page, ChatColor.WHITE));
List<PlayerInfo> infos = Database.playerInfo.getInfoPage(page);
int i = 1 + (page-1)*10;
- if(infos == null){
+ if (infos == null) {
sender.sendMessage(errorPrefix + message("NO_GAME_INFO"));
return;
}
- for(PlayerInfo info : infos){
+ for(PlayerInfo info : infos) {
String name = Main.plugin.getServer().getOfflinePlayer(info.uuid).getName();
ChatColor color;
- switch (i){
+ switch (i) {
case 1: color = ChatColor.YELLOW; break;
case 2: color = ChatColor.GRAY; break;
case 3: color = ChatColor.GOLD; break;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
index 9140f49..1366f07 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
@@ -29,8 +29,8 @@ import org.bukkit.entity.Player;
import java.util.UUID;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Wins implements ICommand {
@@ -39,9 +39,9 @@ public class Wins implements ICommand {
UUID uuid;
String name;
- if(args.length == 0) {
+ if (args.length == 0) {
Player player = Main.plugin.getServer().getPlayer(sender.getName());
- if(player == null){
+ if (player == null) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(sender.getName()));
return;
}
@@ -52,13 +52,13 @@ public class Wins implements ICommand {
try {
name = args[0];
uuid = UUIDFetcher.getUUID(args[0]);
- } catch (Exception e){
+ } catch (Exception e) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(args[0]));
return;
}
}
PlayerInfo info = Database.playerInfo.getInfo(uuid);
- if(info == null){
+ if (info == null) {
sender.sendMessage(errorPrefix + message("NO_GAME_INFO"));
return;
}