Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. package net.etheria.lobby.commands;
  2.  
  3. import it.xquickglare.quicklib.command.Command;
  4. import it.xquickglare.quicklib.command.CommandSenderType;
  5. import it.xquickglare.quicklib.utils.Message;
  6. import net.etheria.core.Etheria;
  7. import net.etheria.lobby.EtheriaLobby;
  8. import net.etheria.lobby.utils.BungeecordUtils;
  9. import net.etheria.lobby.utils.Config;
  10. import org.bukkit.ChatColor;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.entity.Player;
  13.  
  14. import java.util.Collections;
  15.  
  16. import static net.etheria.lobby.utils.Config.getConfig;
  17.  
  18. public class SelectNation extends Command {
  19.  
  20. private final EtheriaLobby plugin = EtheriaLobby.getInstance();
  21.  
  22. public SelectNation() {
  23. super("selectnation",
  24. "etherialobby.selectnation",
  25. Message.format(getConfig().getConfiguration().getString("noPermission"), '&'),
  26. "",
  27. "",
  28. new CommandSenderType[] { CommandSenderType.PLAYER },
  29. true,
  30. 0,
  31. Collections.emptyList()
  32. );
  33. }
  34.  
  35. @Override
  36. public void onCommand(CommandSender sender, String[] args) {
  37. Player player = (Player)sender;
  38. if(args.length == 0)
  39. return;
  40.  
  41. try {
  42. int nation = Integer.parseInt(args[0]);
  43. if(nation >= 4 || nation < 0)
  44. return;
  45.  
  46. if(plugin.getSelector().hasSelectedNation(player))
  47. return;
  48.  
  49. if(!plugin.getSelector().canJoin(nation)) {
  50. player.sendMessage(ChatColor.RED + "Non puoi entrare in questa nazione, scegline un altra.");
  51. return;
  52. }
  53.  
  54. if (Etheria.getInstance().getNationsManager().getNation(nation).getCapital().isConquisted()) {
  55. player.sendMessage(ChatColor.RED + "Non puoi entrare in questa nazione perché è stata già conquistata. Scegline un altra.");
  56. return;
  57. }
  58.  
  59. if(plugin.getSelector().selectNation(player, nation)) {
  60. player.chat("/queue nations");
  61. player.teleport(getConfig().getConfiguration().getLocation("lobbyLocation"));
  62. Config.getConfig().getConfiguration().getMessage("queueNation").send(sender);
  63. }
  64. } catch (NumberFormatException ignored) {
  65.  
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement