2021-10-11 15:52:56 +00:00
|
|
|
package net.tylermurphy.hideAndSeek.command;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import net.tylermurphy.hideAndSeek.util.ICommand;
|
|
|
|
|
|
|
|
import static net.tylermurphy.hideAndSeek.Store.*;
|
|
|
|
|
|
|
|
public class Join implements ICommand {
|
|
|
|
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
2021-10-11 21:06:21 +00:00
|
|
|
if(!lobbyManualJoin) {
|
2021-10-11 21:13:25 +00:00
|
|
|
sender.sendMessage(errorPrefix + "Manual join/leave isnt enabled in this server");
|
2021-10-11 15:52:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!status.equals("Standby")) {
|
|
|
|
sender.sendMessage(errorPrefix + "Game is currently in session");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!lobbyStarted) {
|
|
|
|
sender.sendMessage(errorPrefix + "There is currently no lobby in session");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Player player = Bukkit.getServer().getPlayer(sender.getName());
|
|
|
|
if(player == null) {
|
|
|
|
sender.sendMessage(errorPrefix + "An internal error has occured");
|
|
|
|
return;
|
|
|
|
}
|
2021-10-11 21:06:21 +00:00
|
|
|
if(playerList.containsKey(player.getName())){
|
|
|
|
sender.sendMessage(errorPrefix + "You are already in the lobby");
|
|
|
|
return;
|
|
|
|
}
|
2021-10-11 15:52:56 +00:00
|
|
|
playerList.put(player.getName(), player);
|
|
|
|
Hider.add(player.getName());
|
|
|
|
HiderTeam.addEntry(player.getName());
|
2021-10-11 21:06:21 +00:00
|
|
|
playerLastLocationList.put(player.getName(), player.getLocation());
|
2021-10-11 15:52:56 +00:00
|
|
|
player.teleport(new Location(Bukkit.getWorld(spawnWorld), spawnPosition.getX(),spawnPosition.getY(),spawnPosition.getZ()));
|
2021-10-11 21:06:21 +00:00
|
|
|
if(lobbyAnnounced) Bukkit.broadcastMessage(messagePrefix + sender.getName() + " has joined the HideAndSeek lobby");
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getLabel() {
|
2021-10-11 21:06:21 +00:00
|
|
|
return "join";
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getUsage() {
|
2021-10-11 21:06:21 +00:00
|
|
|
return "";
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
2021-10-11 21:06:21 +00:00
|
|
|
return "Joins the lobby if game is set to manual join/leave";
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|