Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CreateCommand extends PlayerCommand
- {
- public CreateCommand() {
- super(
- Commands.GUILD_USER_CREATE_NAME,
- Commands.GUILD_USER_CREATE_DESCRIPTION,
- Commands.GUILD_USER_CREATE_USAGE,
- Commands.GUILD_USER_CREATE_PERMISSION,
- Commands.GUILD_USER_CREATE_ALIASES
- );
- }
- public boolean onCommand(Player p, String args[]) {
- if (!p.hasPermission("kguild.cmd.admin") && !Settings.ENABLE_CREATE) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Zakladanie gildii jest tymczasowo wylaczone!");
- }
- if (!p.hasPermission("kguild.cmd.admin") && !Settings.COST_CREATE_TOUR1_ENABLE) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Pierwsza ani druga tura itemow nie zostala jeszcze podana!");
- }
- if (!p.hasPermission("kguild.cmd.admin") && !Settings.COST_CREATE_TOUR2_ENABLE) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Druga tura itemow nie zostala jeszcze podana!");
- }
- Guild guild = GuildManager.getGuild(p);
- if (guild != null) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Posiadasz juz gildie!");
- }
- if (args.length != 2) {
- return ChatUtil.sendMessage(p, Messages.USE(this.getUsage()));
- }
- String tag = args[0].toUpperCase();
- String name = args[1];
- if (tag.length() > 5 || tag.length() < 2 || name.length() > 32 || name.length() < 4) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Tag gildi musi zawierac 2-5 zankow, nawzwa 4-32 znakow");
- }
- if (GuildManager.getGuild(tag) != null) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Istenieje juz gildia o takim tagu!");
- }
- if (GuildManager.getGuild(name) != null) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Istenieje juz gildia o takiej nazwie!");
- }
- if (!ChatUtil.isAlphaNumeric(tag)) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Tag nie moze byc alfanumeryczny!");
- }
- if (!ChatUtil.isAlphaNumeric(name)) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Nazwa nie moze byc alfanumeryczna!");
- }
- if (!GuildManager.canCreateGuildBySpawn(p.getLocation())) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7Jestes zbyt blisko spawnu!");
- }
- if (!GuildManager.canCreateGuildByGuild(p.getLocation())) {
- return ChatUtil.sendMessage(p, "&c&lBlad! &7W poblizu znajduje sie gildia!");
- }
- String it = Settings.COST_CREATE_TOUR1_NORMAL + Settings.COST_CREATE_TOUR2_NORMAL;
- if (p.hasPermission("kguild.create.admin")) {
- it = "1:0-0:nic;";
- }
- else if (p.hasPermission("kguild.create.svip")) {
- it = Settings.COST_CREATE_TOUR1_SVIP + Settings.COST_CREATE_TOUR2_SVIP;
- }
- else if (p.hasPermission("kguild.create.vip")) {
- it = Settings.COST_CREATE_TOUR1_VIP + Settings.COST_CREATE_TOUR2_VIP;
- }
- if (!ItemUtil.checkItems(p, it, 1)) {
- ItemUtil.getItem(p, it, 1);
- return true;
- }
- ItemUtil.removeItems(p, it, 1);
- Location home = new Location(p.getWorld(), p.getLocation().getX(), p.getWorld().getHighestBlockYAt(p.getLocation().getBlockX(), p.getLocation().getBlockZ()) + 1.5, p.getLocation().getZ());
- Guild g = GuildManager.createGuild(tag.toUpperCase(), name, p, home);
- try {
- NameTagManager.createGuild(g, p);
- }
- catch (Exception e1) {
- Logger.warning("Blad podczas wczytywania tagu ", e1.getMessage());
- }
- return ChatUtil.sendMessage(Bukkit.getOnlinePlayers(), "&7Gildia &8[&6" + g.getTag() + "&8] &6" + g.getName() + " &7zostala utworzona przez &8" + p.getName() + "&7!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement