Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. public class CreateCommand extends PlayerCommand
  2. {
  3. public CreateCommand() {
  4. super(
  5. Commands.GUILD_USER_CREATE_NAME,
  6. Commands.GUILD_USER_CREATE_DESCRIPTION,
  7. Commands.GUILD_USER_CREATE_USAGE,
  8. Commands.GUILD_USER_CREATE_PERMISSION,
  9. Commands.GUILD_USER_CREATE_ALIASES
  10. );
  11. }
  12.  
  13. public boolean onCommand(Player p, String args[]) {
  14. if (!p.hasPermission("kguild.cmd.admin") && !Settings.ENABLE_CREATE) {
  15. return ChatUtil.sendMessage(p, "&c&lBlad! &7Zakladanie gildii jest tymczasowo wylaczone!");
  16. }
  17. if (!p.hasPermission("kguild.cmd.admin") && !Settings.COST_CREATE_TOUR1_ENABLE) {
  18. return ChatUtil.sendMessage(p, "&c&lBlad! &7Pierwsza ani druga tura itemow nie zostala jeszcze podana!");
  19. }
  20. if (!p.hasPermission("kguild.cmd.admin") && !Settings.COST_CREATE_TOUR2_ENABLE) {
  21. return ChatUtil.sendMessage(p, "&c&lBlad! &7Druga tura itemow nie zostala jeszcze podana!");
  22. }
  23. Guild guild = GuildManager.getGuild(p);
  24. if (guild != null) {
  25. return ChatUtil.sendMessage(p, "&c&lBlad! &7Posiadasz juz gildie!");
  26. }
  27. if (args.length != 2) {
  28. return ChatUtil.sendMessage(p, Messages.USE(this.getUsage()));
  29. }
  30. String tag = args[0].toUpperCase();
  31. String name = args[1];
  32. if (tag.length() > 5 || tag.length() < 2 || name.length() > 32 || name.length() < 4) {
  33. return ChatUtil.sendMessage(p, "&c&lBlad! &7Tag gildi musi zawierac 2-5 zankow, nawzwa 4-32 znakow");
  34. }
  35. if (GuildManager.getGuild(tag) != null) {
  36. return ChatUtil.sendMessage(p, "&c&lBlad! &7Istenieje juz gildia o takim tagu!");
  37. }
  38. if (GuildManager.getGuild(name) != null) {
  39. return ChatUtil.sendMessage(p, "&c&lBlad! &7Istenieje juz gildia o takiej nazwie!");
  40. }
  41. if (!ChatUtil.isAlphaNumeric(tag)) {
  42. return ChatUtil.sendMessage(p, "&c&lBlad! &7Tag nie moze byc alfanumeryczny!");
  43. }
  44. if (!ChatUtil.isAlphaNumeric(name)) {
  45. return ChatUtil.sendMessage(p, "&c&lBlad! &7Nazwa nie moze byc alfanumeryczna!");
  46. }
  47. if (!GuildManager.canCreateGuildBySpawn(p.getLocation())) {
  48. return ChatUtil.sendMessage(p, "&c&lBlad! &7Jestes zbyt blisko spawnu!");
  49. }
  50. if (!GuildManager.canCreateGuildByGuild(p.getLocation())) {
  51. return ChatUtil.sendMessage(p, "&c&lBlad! &7W poblizu znajduje sie gildia!");
  52. }
  53. String it = Settings.COST_CREATE_TOUR1_NORMAL + Settings.COST_CREATE_TOUR2_NORMAL;
  54. if (p.hasPermission("kguild.create.admin")) {
  55. it = "1:0-0:nic;";
  56. }
  57. else if (p.hasPermission("kguild.create.svip")) {
  58. it = Settings.COST_CREATE_TOUR1_SVIP + Settings.COST_CREATE_TOUR2_SVIP;
  59. }
  60. else if (p.hasPermission("kguild.create.vip")) {
  61. it = Settings.COST_CREATE_TOUR1_VIP + Settings.COST_CREATE_TOUR2_VIP;
  62. }
  63. if (!ItemUtil.checkItems(p, it, 1)) {
  64. ItemUtil.getItem(p, it, 1);
  65. return true;
  66. }
  67.  
  68. ItemUtil.removeItems(p, it, 1);
  69. Location home = new Location(p.getWorld(), p.getLocation().getX(), p.getWorld().getHighestBlockYAt(p.getLocation().getBlockX(), p.getLocation().getBlockZ()) + 1.5, p.getLocation().getZ());
  70. Guild g = GuildManager.createGuild(tag.toUpperCase(), name, p, home);
  71. try {
  72. NameTagManager.createGuild(g, p);
  73. }
  74. catch (Exception e1) {
  75. Logger.warning("Blad podczas wczytywania tagu ", e1.getMessage());
  76. }
  77. return ChatUtil.sendMessage(Bukkit.getOnlinePlayers(), "&7Gildia &8[&6" + g.getTag() + "&8] &6" + g.getName() + " &7zostala utworzona przez &8" + p.getName() + "&7!");
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement