Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.narusenpai.guilds;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.UUID;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.Chunk;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.InvalidConfigurationException;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockDamageEvent;
- import org.bukkit.event.block.BlockIgniteEvent;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.event.entity.EntityDamageByEntityEvent;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.player.AsyncPlayerChatEvent;
- import org.bukkit.event.player.PlayerBedEnterEvent;
- import org.bukkit.event.player.PlayerBucketEmptyEvent;
- import org.bukkit.event.player.PlayerBucketFillEvent;
- import org.bukkit.event.player.PlayerInteractEntityEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.event.player.PlayerMoveEvent;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin implements Listener
- {
- public Logger myLogger = getLogger();
- public PluginDescriptionFile pdf = getDescription();
- File configFile;
- FileConfiguration config;
- private FileConfiguration ecoConfig = null;
- private File ecoFile = null;
- ArrayList<String> illegalNames = new ArrayList<String>();
- HashMap<UUID, Location> ghome = new HashMap<UUID, Location>();
- @Override
- public void onEnable()
- {
- getServer().getPluginManager().registerEvents(this, this);
- createConfig();
- saveConfig();
- getEcoConfig();
- illegalNames.add("staff");
- illegalNames.add("shit");
- illegalNames.add("fuck");
- illegalNames.add("cunt");
- illegalNames.add("nigger");
- illegalNames.add("ass");
- illegalNames.add("bitch");
- myLogger.info(pdf.getName()+" has been enabled. V. "+pdf.getVersion());
- }
- @Override
- public void onDisable()
- {
- saveConfig();
- myLogger.info(pdf.getName()+" has been disabled. V. "+pdf.getVersion());
- }
- public void saveConfig()
- {
- try
- {
- this.getConfig().options().copyDefaults(true);
- config.save(configFile);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- public void createConfig()
- {
- configFile = new File(getDataFolder(), "config.yml");
- if(!configFile.exists())
- {
- configFile.getParentFile().mkdirs();
- saveResource("config.yml", false);
- }
- config = new YamlConfiguration();
- try
- {
- config.load(configFile);
- }
- catch(IOException | InvalidConfigurationException e)
- {
- e.printStackTrace();
- }
- }
- public FileConfiguration getEcoConfig()
- {
- if (ecoConfig == null)
- {
- this.reloadEcoConfig();
- }
- return ecoConfig;
- }
- public void reloadEcoConfig()
- {
- if (ecoConfig == null)
- {
- ecoFile = new File("plugins/Economy", "config.yml");
- }
- ecoConfig = YamlConfiguration.loadConfiguration(ecoFile);
- }
- public static boolean isInt(String s)
- {
- try {
- Integer.parseInt(s);
- } catch (NumberFormatException nfe) {
- return false;
- }
- return true;
- }
- public boolean isAlphanumeric(String str)
- {
- for (int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
- if (c < 0x30 || (c >= 0x3a && c <= 0x40) || (c > 0x5a && c <= 0x60) || c > 0x7a)
- return false;
- }
- return true;
- }
- public String guildPower(String guildPower)
- {
- String power = "0";
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+guildPower+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- power = config.getInt("players."+member.getUniqueId()+".power") + power;
- }
- config.set("guilds."+guildPower+".power", power);
- saveConfig();
- guildPower = power;
- return guildPower;
- }
- @EventHandler
- public void onGuildJoin(PlayerJoinEvent e)
- {
- Player thePlayer = e.getPlayer();
- if(!(config.isSet("players."+thePlayer.getUniqueId()+".power")))
- {
- config.set("players."+thePlayer.getUniqueId()+".power", 10);
- config.set("players."+thePlayer.getUniqueId()+".kills", 0.0);
- config.set("players."+thePlayer.getUniqueId()+".deaths", 0.0);
- saveConfig();
- }
- }
- @EventHandler
- public void onGuildBucket(PlayerBucketEmptyEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(!thePlayer.hasPermission("guilds.landbypass"))
- {
- if(config.isSet("claims."+chunk))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- @EventHandler
- public void onGuildBucket(PlayerBucketFillEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(!thePlayer.hasPermission("guilds.landbypass"))
- {
- if(config.isSet("claims."+chunk))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- @EventHandler
- public void onGuildInteract(PlayerInteractEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(!thePlayer.hasPermission("guilds.landbypass"))
- {
- if(config.isSet("claims."+chunk))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- @EventHandler
- public void onGuildEInteract(PlayerInteractEntityEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(!thePlayer.hasPermission("guilds.landbypass"))
- {
- if(config.isSet("claims."+chunk))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- @EventHandler
- public void onGuildBed(PlayerBedEnterEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(!thePlayer.hasPermission("guilds.landbypass"))
- {
- if(config.isSet("claims."+chunk))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- @EventHandler
- public void onGuildPlace(BlockPlaceEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(config.isSet("claims."+chunk))
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- @EventHandler
- public void onGuildIgnite(BlockIgniteEvent e)
- {
- String chunk = e.getBlock().getChunk().toString();
- if(config.isSet("claims."+chunk))
- {
- if(e.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL)
- {
- if(e.getIgnitingEntity() instanceof Player)
- {
- Player thePlayer = (Player) e.getIgnitingEntity();
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- }
- @EventHandler
- public void onGuildBreak(BlockDamageEvent e)
- {
- Player thePlayer = e.getPlayer();
- String chunk = thePlayer.getLocation().getChunk().toString();
- if(!thePlayer.hasPermission("guilds.landbypass"))
- {
- if(config.isSet("claims."+chunk))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(!config.getString("claims."+chunk).equalsIgnoreCase(gn))
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- else
- {
- e.setCancelled(true);
- thePlayer.sendMessage("§cYou cannot do that here, this land is owned by "+config.getString("claims."+chunk));
- }
- }
- }
- }
- @EventHandler
- public void onGuildDamage(EntityDamageByEntityEvent e)
- {
- if(e.getEntity() instanceof Player)
- {
- Player thePlayer = (Player) e.getEntity();
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(e.getDamager() instanceof Player)
- {
- Player oPlayer = (Player) e.getDamager();
- if(config.isSet("players."+oPlayer.getUniqueId()+".guild"))
- {
- if(config.getString("players."+thePlayer.getUniqueId()+".guild").equalsIgnoreCase("players."+oPlayer.getUniqueId()+".guild"))
- {
- e.setCancelled(true);
- oPlayer.sendMessage("§aYou cannot hurt members of your guild!");
- }
- }
- }
- }
- }
- }
- @EventHandler
- public void onChat(AsyncPlayerChatEvent e)
- {
- Player thePlayer = (Player) e.getPlayer();
- String msg = e.getMessage();
- String format = "§a<guildrank><guild> <group> §f<player>§6>: §f<message>";
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- format = format.replace("<guild> ", config.getString("players."+thePlayer.getUniqueId()+".guild")+" ");
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.isSet("guilds."+gn+".officers"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(officers.contains(thePlayer.getName()))
- {
- format = format.replace("<guildrank>", "*");
- }
- }
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- format = format.replace("<guildrank>", "**");
- }
- }
- else
- {
- format = format.replace("<guild> ", "");
- format = format.replace("<guildrank> ", "");
- }
- if(config.isSet("players."+thePlayer.getUniqueId()+".rank"))
- {
- format = format.replace("<group> ", "§7[§o"+config.getString("players."+thePlayer.getUniqueId()+".rank")+"§7] ");
- }
- else
- {
- format = format.replace("<group> ", "");
- }
- format = format.replace("<player>", thePlayer.getDisplayName());
- if(!thePlayer.hasPermission("chat.colorcodes"))
- {
- msg = msg.replace("&", "*");
- }
- format = format.replace("<message>", "%2$s");
- e.setFormat(format);
- e.setMessage(msg);
- }
- @EventHandler
- public void onDeath (PlayerDeathEvent e)
- {
- Player victim = e.getEntity();
- if(e.getEntity().getKiller() instanceof Player)
- {
- Player attacker = e.getEntity().getKiller();
- config.set("players."+victim.getUniqueId()+".power", config.getInt("players."+victim.getUniqueId()+".power")-1);
- config.set("players."+attacker.getUniqueId()+".power", config.getInt("players."+attacker.getUniqueId()+".power")+1);
- }
- else
- {
- config.set("players."+victim.getUniqueId()+".power", config.getInt("players."+victim.getUniqueId()+".power")-1);
- }
- }
- @EventHandler
- public void onGMove (PlayerMoveEvent e)
- {
- Player thePlayer = e.getPlayer();
- if (e.getTo().getBlockX() == e.getFrom().getBlockX() && e.getTo().getBlockY() == e.getFrom().getBlockY() && e.getTo().getBlockZ() == e.getFrom().getBlockZ()) return;//The player hasn't moved
- else
- {
- if (ghome.containsKey(thePlayer.getUniqueId()))
- {
- thePlayer.sendMessage("§4Teleportation canceled.");
- ghome.remove(thePlayer.getUniqueId());
- }
- }
- }
- public boolean onCommand(CommandSender theSender, Command cmd, String commandLabel, String[] args)
- {
- if(cmd.getName().equalsIgnoreCase("guildadmin"))
- {
- if(theSender instanceof Player)
- {
- Player thePlayer = (Player) theSender;
- if(thePlayer.hasPermission("guilds.admin"))
- {
- if(args.length == 0)
- {
- thePlayer.performCommand("/guildadmin help");
- }
- if(args.length > 0)
- {
- if(args[0].equalsIgnoreCase("help"))
- {
- thePlayer.sendMessage("§b- - - - - §6[§3GAdmin §b- §3Page 1/1§6] §b- - - - -");
- thePlayer.sendMessage("§6/ga help - §3Displays information on guild admin commands.");
- thePlayer.sendMessage("§6/ga disband [GuildName] - §bDisbands the specified guild.");
- thePlayer.sendMessage("§6/ga join [GuildName] - §3Forcefully joins the specified guild.");
- thePlayer.sendMessage("§6/ga home [GuildName] - §bVisits the home of the specified guild.");
- }
- else if(args[0].equalsIgnoreCase("disband"))
- {
- if(args.length == 2)
- {
- String gn = args[1];
- if(config.isSet("guilds."+gn))
- {
- if(config.isSet("guilds."+gn+".members"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §aYour guild has been disbanded.");
- config.set("players."+member.getUniqueId()+".guild", null);
- }
- }
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- for(int i = 0; i < claims.size(); i++)
- {
- config.set("claims."+claims.get(i), null);
- }
- }
- config.set("guilds."+gn, null);
- @SuppressWarnings("unchecked")
- ArrayList<String> guilds = (ArrayList<String>) config.getList("guildlist");
- guilds.remove(gn);
- config.set("guildlist", guilds);
- saveConfig();
- Bukkit.getServer().broadcastMessage("§6[§3Guilds§6] §a"+gn+" has been disbanded by "+theSender.getName());
- return true;
- }
- else theSender.sendMessage("§cGuild not found.");
- }
- else theSender.sendMessage("§cIncorrect format, use §4/ga disband [GuildName]");
- }
- else if(args[0].equalsIgnoreCase("home"))
- {
- if(args.length == 2)
- {
- String gn = args[1];
- if(config.isSet("guilds."+gn))
- {
- if(config.isSet("guilds."+gn+".homeblock"))
- {
- World w = (World) Bukkit.getServer().getWorld((String) config.get(("guilds."+gn+".sethome.w")));
- double x = config.getDouble(("guilds."+gn+".sethome.x"));
- double y = config.getDouble(("guilds."+gn+".sethome.y"));
- double z = config.getDouble(("guilds."+gn+".sethome.z"));
- Location loc = new Location(w, x, y, z);
- thePlayer.sendMessage("§aTeleporting. . .");
- thePlayer.teleport(loc);
- }
- thePlayer.sendMessage("§cGuild home not found.");
- }
- thePlayer.sendMessage("§cGuild not found.");
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/ga home [GuildName]");
- return false;
- }
- }
- else if(args[0].equalsIgnoreCase("join"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- thePlayer.sendMessage("§cYou must leave or disband your current guild before joining a new one.");
- return false;
- }
- if(args.length != 2)
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/ga join [GuildName]");
- return false;
- }
- String gn = args[1];
- if(config.isSet("guilds."+gn))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- if (members.size() == 20)
- {
- thePlayer.sendMessage("§cI'm sorry, that guild has reached it's maximum player limit.");
- return false;
- }
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+thePlayer.getName()+" has forcefully joined your guild.");
- }
- members.add(thePlayer.getName());
- config.set("guilds."+gn+".members", members);
- config.set("guilds."+gn+".landcount", config.getInt("guilds."+gn+".landcount")+1);
- config.set("guilds."+gn+".power", guildPower(gn));
- config.set("players."+thePlayer.getUniqueId()+".guild", gn);
- saveConfig();
- thePlayer.sendMessage("§aYou have successfully joined "+gn+".");
- return true;
- }
- else thePlayer.sendMessage("§cGuild not found.");
- }
- else
- {
- thePlayer.performCommand("/guildadmin help");
- }
- }
- }
- else theSender.sendMessage("§4You do not have permission to use guild admin commands.");
- }
- else theSender.sendMessage("§4This command can only be used in game.");
- }
- if(commandLabel.equalsIgnoreCase("rank"))
- {
- if(theSender instanceof Player)
- {
- theSender.sendMessage("§4This command can only be used by the console.");
- return false;
- }
- if(args.length == 2)
- {
- if(Bukkit.getPlayer(args[0]) != null)
- {
- Player rankPlayer = Bukkit.getPlayer(args[0]);
- if(args[1].equalsIgnoreCase("default"))
- {
- config.set("players."+rankPlayer.getUniqueId()+".rank", null);
- return true;
- }
- if(args[1].equalsIgnoreCase("chatmod"))
- {
- config.set("players."+rankPlayer.getUniqueId()+".rank", "§eChatMod");
- return true;
- }
- if(args[1].equalsIgnoreCase("mod"))
- {
- config.set("players."+rankPlayer.getUniqueId()+".rank", "§6Mod");
- return true;
- }
- if(args[1].equalsIgnoreCase("builder"))
- {
- config.set("players."+rankPlayer.getUniqueId()+".rank", "§6Builder");
- return true;
- }
- if(args[1].equalsIgnoreCase("admin"))
- {
- config.set("players."+rankPlayer.getUniqueId()+".rank", "§cAdmin");
- return true;
- }
- if(args[1].equalsIgnoreCase("owner"))
- {
- config.set("players."+rankPlayer.getUniqueId()+".rank", "§4Owner");
- return true;
- }
- }
- else
- {
- theSender.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- theSender.sendMessage("§cIncorrect format, use /rank [PlayerName] [RankName]");
- return false;
- }
- }
- if(cmd.getName().equalsIgnoreCase("guild"))
- {
- if(theSender instanceof Player)
- {
- final Player thePlayer = (Player) theSender;
- if(args.length == 0)
- {
- thePlayer.performCommand("/g help 1");
- return false;
- }
- else if (args.length >= 1)
- {
- if(args[0].equalsIgnoreCase("help"))
- {
- if(args.length == 1)
- {
- thePlayer.performCommand("/g help 1");
- return false;
- }
- if(args.length == 2)
- {
- if(args[1].equalsIgnoreCase("1"))
- {
- thePlayer.sendMessage("§b- - - - - §6[§3Guilds §b- §3Page 1/3§6] §b- - - - -");
- thePlayer.sendMessage("§6/g help [1/2/3] - §3Displays information on guild commands.");
- thePlayer.sendMessage("§6/g create [GuildName] - §bCreates a new guild.");
- thePlayer.sendMessage("§6/g p <PlayerName> - §3Finds guild related information on a player.");
- thePlayer.sendMessage("§6/g g <GuildName> - §bFinds information on a guild.");
- thePlayer.sendMessage("§6/g invite [PlayerName] - §3Invites a player to your guild.");
- thePlayer.sendMessage("§6/g join [GuildName] - §bAccepts an invite to a guild.");
- thePlayer.sendMessage("§6/g leave - §3Leaves your guild.");
- thePlayer.sendMessage("§6/g claim - §bClaims the chunk you're in for your guild.");
- thePlayer.sendMessage("§6/g unclaim <all> - §3Unclaims the chunk you're in, or unclaims all of your guild claims.");
- return true;
- }
- if(args[1].equalsIgnoreCase("2"))
- {
- thePlayer.sendMessage("§b- - - - - §6[§3Guilds §b- §3Page 2/3§6] §b- - - - -");
- thePlayer.sendMessage("§6/g sethome - §3Sets a home for your guild.");
- thePlayer.sendMessage("§6/g home - §bTeleports you to your guild home, if set.");
- thePlayer.sendMessage("§6/g balance - §3Shows information about your guild's bank.");
- thePlayer.sendMessage("§6/g deposit [Amount] - §bDeposits money into your guild's bank.");
- thePlayer.sendMessage("§6/g c [Message] - §3Sends a message to your guild members.");
- thePlayer.sendMessage("§6/g invites - §bShows any pending guild invites.");
- thePlayer.sendMessage("§6/g revoke [PlayerName] - §3Revokes an invite to your guild.");
- thePlayer.sendMessage("§6/g kick [PlayerName] - §bKicks a player from your guild.");
- thePlayer.sendMessage("§6/g disband [GuildName] - §3Disbands your guild.");
- return true;
- }
- if(args[1].equalsIgnoreCase("3"))
- {
- thePlayer.sendMessage("§b- - - - - §6[§3Guilds §b- §3Page 3/3§6] §b- - - - -");
- thePlayer.sendMessage("§6/g rename [New GuildName] - §3Renames your guild.");
- thePlayer.sendMessage("§6/g promote [PlayerName] - §bPromotes a player in your guild.");
- thePlayer.sendMessage("§6/g demote [PlayerName] - §3Demotes a player in your guild.");
- thePlayer.sendMessage("§6/g leader [PlayerName] [GuildName] - §bTransfers leadership of your guild to another player.");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cUse /g help <1/2/3>");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cUse /g help <1/2/3>");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("create") || (args[0].equalsIgnoreCase("new")))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- thePlayer.sendMessage("§cYou must leave or disband your current guild before you can create a new one.");
- return false;
- }
- if(args.length == 2)
- {
- String gn = args[1];
- if(!isAlphanumeric(gn))
- {
- thePlayer.sendMessage("§cYour guild name must be alphanumeric, please choose a new name and try again.");
- return false;
- }
- if(illegalNames.contains(gn))
- {
- thePlayer.sendMessage("§cInnappropriate guild name, please choose a new name and try again.");
- return false;
- }
- ArrayList<String> guilds = new ArrayList<String>();
- if(config.isSet("guildlist"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> guilds2 = (ArrayList<String>) config.getList("guildlist");
- for(int i = 0; i < guilds2.size(); i++)
- {
- guilds.add(guilds2.get(i));
- if(guilds2.get(i).equalsIgnoreCase(gn))
- {
- thePlayer.sendMessage("§cThat guild already exists, please choose a new name and try again.");
- return false;
- }
- }
- }
- if(gn.length() > 10)
- {
- thePlayer.sendMessage("§cGuild names cannot be longer than 10 characters, please choose a new name and try again.");
- return false;
- }
- if(ecoConfig.getDouble("economy."+thePlayer.getUniqueId()+".balance") < 500.00)
- {
- thePlayer.sendMessage("§cYou do not have enough money to start a guild, you need $500, you can check your balance with §4/balance");
- return false;
- }
- if(config.getInt("players."+thePlayer.getUniqueId()+".power") != 10)
- {
- thePlayer.sendMessage("§cYou do not have enough power to start a guild, you need 10 power, you have "+config.getDouble("players."+thePlayer.getUniqueId()+".power"));
- return false;
- }
- config.createSection("guilds."+gn);
- Double bal = ecoConfig.getDouble("economy."+thePlayer.getUniqueId()+".balance");
- ecoConfig.set("economy."+thePlayer.getUniqueId()+".balance", bal-500.0);
- config.set("players."+thePlayer.getUniqueId()+".guild", gn);
- config.set("guilds."+gn+".leader", thePlayer.getUniqueId().toString());
- config.set("guilds."+gn+".leadername", thePlayer.getName());
- ArrayList<String> members = new ArrayList<String>();
- members.add(thePlayer.getName());
- config.set("guilds."+gn+".members", members);
- config.set("guilds."+gn+".bal", 250.0);
- config.set("guilds."+gn+".landcount", 1);
- config.set("guilds."+gn+".landclaimed", 0);
- config.set("guilds."+gn+".power", 10);
- guilds.add(gn);
- config.set("guildlist", guilds);
- saveConfig();
- Bukkit.getServer().broadcastMessage("§6[§3Guilds§6] §a"+thePlayer.getName()+" has created a new guild by the name of "+gn+"!");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g create [GuildName]");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("g") || (args[0].equalsIgnoreCase("guild")))
- {
- if(args.length == 2)
- {
- String gn = args[1];
- thePlayer.sendMessage("§6Searching for guild or player, information will be returned if found.");
- if(config.isSet("guildlist"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> guilds = (ArrayList<String>) config.getList("guildlist");
- for(int i = 0; i < guilds.size(); i++)
- {
- if(guilds.get(i).equalsIgnoreCase(gn))
- {
- gn = guilds.get(i);
- thePlayer.sendMessage("§2- - - - - §6[§a"+gn+" - "+config.getString("guilds."+gn+".leadername")+"§6] §2- - - - -");
- thePlayer.sendMessage("§aLand Claimed/Land Count: §2"+config.getInt("guilds."+gn+".landclaimed")+"/"+config.getInt("guilds."+gn+".landcount"));
- thePlayer.sendMessage("§aPower: §2"+guildPower(gn));
- thePlayer.sendMessage("§aBank: §2$"+config.getInt("guilds."+gn+".bal"));
- if(config.isSet("guilds."+gn+".officers"))
- {
- thePlayer.sendMessage("§aOfficers: §2"+config.getList("guilds."+gn+".officers"));
- }
- thePlayer.sendMessage("§aMembers: §2"+config.getList("guilds."+gn+".members"));
- return true;
- }
- }
- }
- else
- {
- thePlayer.sendMessage("§cNo guilds found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g g [GuildName]");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("p") || (args[0].equalsIgnoreCase("player")))
- {
- if(args.length == 2)
- {
- Player player = Bukkit.getPlayer(args[1]);
- if(config.isSet("players."+player.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+player.getUniqueId()+".guild");
- thePlayer.performCommand("g g "+gn);
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cThat player is not a part of a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g p [PlayerName]");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("balance") || (args[0].equalsIgnoreCase("bal")))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- thePlayer.sendMessage("§6[§a"+gn+"§6] §aGuild Bank Balance: §2$"+config.getInt("guilds."+gn+".bal"));
- thePlayer.sendMessage("§aGuild Pricing: New Guild - §2$500§a, Rename - §2$250§a, Claim Wilderness - §2$100§a, Claim Over - §2$200§a, Unclaim + §2$25");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("deposit"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- if(isInt(args[1]))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- int amount = Integer.parseInt(args[1]);
- if(amount > 0)
- {
- if(amount <= ecoConfig.getDouble("economy."+thePlayer.getUniqueId()+".balance"))
- {
- ecoConfig.set("economy."+thePlayer.getUniqueId()+".balance", ecoConfig.getDouble("economy."+thePlayer.getUniqueId()+".balance")-amount);
- config.set("guilds."+gn+".bal", config.getDouble("guilds."+gn+".bal")+amount);
- thePlayer.sendMessage("§6[§a"+gn+"§6] §aDeposit successful, new guild bank balance is §2$"+config.getDouble("guilds."+gn+".bal"));
- saveConfig();
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cCould not deposit, please ensure you have money in your EcoAccount using §4/balance");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cCould not deposit, use §4/g deposit [amount] §cand ensure amount is greater than zero.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cCould not deposit, use §4/g deposit [amount] §cand ensure amount is a number.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g deposit [amount]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("promote"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- if(Bukkit.getPlayer(args[1]) != null)
- {
- Player promotePlayer = Bukkit.getPlayer(args[1]);
- if(config.isSet("players."+promotePlayer.getUniqueId()+".guild") && config.getString("players."+promotePlayer.getUniqueId()+".guild").equals(gn))
- {
- if(thePlayer.getName().equals(promotePlayer.getName()))
- {
- thePlayer.sendMessage("§cYou cannot promote yourself to an Officer.");
- return false;
- }
- if(config.isSet("guilds."+gn+".officers"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(officers.contains(promotePlayer.getName()))
- {
- thePlayer.sendMessage("§cThat player is already an Officer of your guild.");
- return false;
- }
- officers.add(promotePlayer.getName());
- config.set("guilds."+gn+".officers", officers);
- saveConfig();
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+promotePlayer.getName()+" has been promoted to an Officer of your guild.");
- }
- return true;
- }
- else
- {
- ArrayList<String> officers = new ArrayList<String>();
- officers.add(promotePlayer.getName());
- promotePlayer.sendMessage("§6[§a"+gn+"§6] §aYou've been promoted to an Officer of your guild, you can now invite players and claim land.");
- config.set("guilds."+gn+".officers", officers);
- saveConfig();
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+promotePlayer.getName()+" has been promoted to an Officer of your guild.");
- }
- return true;
- }
- }
- else
- {
- thePlayer.sendMessage("§cThat player is not in your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders can choose guild Officers.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g promote [PlayerName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("demote"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- if(Bukkit.getPlayer(args[1]) != null)
- {
- Player demotePlayer = Bukkit.getPlayer(args[1]);
- if(config.isSet("players."+demotePlayer.getUniqueId()+".guild") && config.getString("players."+demotePlayer.getUniqueId()+".guild").equals(gn))
- {
- if(thePlayer.getName().equals(demotePlayer.getName()))
- {
- thePlayer.sendMessage("§cYou cannot demote yourself.");
- return false;
- }
- if(config.isSet("guilds."+gn+".officers"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(officers.contains(demotePlayer.getName()))
- {
- officers.remove(demotePlayer.getName());
- config.set("guilds."+gn+".officers", officers);
- saveConfig();
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+demotePlayer.getName()+" is no longer an Officer for your guild.");
- }
- return true;
- }
- thePlayer.sendMessage("§cThat player is not an Officer of your guild.");
- return false;
- }
- else
- {
- thePlayer.sendMessage("§cThat player is not an Officer of your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cThat player is not in your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders can choose guild Officers.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g demote [PlayerName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("leader"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- if(Bukkit.getPlayer(args[1]) != null)
- {
- Player promotePlayer = Bukkit.getPlayer(args[1]);
- if(config.isSet("players."+promotePlayer.getUniqueId()+".guild") && config.getString("players."+promotePlayer.getUniqueId()+".guild").equals(gn))
- {
- if(thePlayer.getName().equals(promotePlayer.getName()))
- {
- thePlayer.sendMessage("§cYou are already the leader of your guild.");
- return false;
- }
- config.set("guilds."+gn+".leader", promotePlayer.getUniqueId().toString());
- config.set("guilds."+gn+".leadername", promotePlayer.getName());
- saveConfig();
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+promotePlayer.getName()+" is now the leader of your guild.");
- }
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cThat player is not in your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders can choose new guild leaders.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g leader [PlayerName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("invite") || args[0].equalsIgnoreCase("inv") || args[0].equalsIgnoreCase("add"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()) || (officers.contains(thePlayer.getName())))
- {
- if(Bukkit.getPlayer(args[1]) != null)
- {
- Player invPlayer = Bukkit.getPlayer(args[1]);
- if(thePlayer.getName().equals(invPlayer.getName()))
- {
- thePlayer.sendMessage("§cYou cannot invite yourself to your guild.");
- return false;
- }
- if(config.getString("players."+invPlayer.getUniqueId()+".guild").equals(gn))
- {
- thePlayer.sendMessage("§cThat player is already a part of your guild.");
- return false;
- }
- else
- {
- if(config.isSet("players."+invPlayer.getUniqueId()+".invites"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> invs = (ArrayList<String>) config.getList("players."+invPlayer.getUniqueId()+".invites");
- if(invs.contains(gn))
- {
- thePlayer.sendMessage("§cThat player already has an invitation to your guild.");
- return false;
- }
- else
- {
- invs.add(gn);
- config.set("players."+invPlayer.getUniqueId()+".invites", invs);
- saveConfig();
- invPlayer.sendMessage("§aThe guild "+gn+" has extended you an invitation. Use §2/invites §ato see all of your invitations or §2/g join "+gn+" §to accept the invite.");
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+invPlayer.getName()+" has been invited to your guild by "+thePlayer.getName()+".");
- }
- return true;
- }
- }
- else
- {
- ArrayList<String> invites = new ArrayList<String>();
- invites.add(gn);
- config.set("players."+invPlayer.getUniqueId()+".invites", invites);
- saveConfig();
- invPlayer.sendMessage("§aThe guild "+gn+" has extended you an invitation. Use §2/invites §ato see all of your invitations or §2/g join "+gn+" §to accept the invite.");
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+invPlayer.getName()+" has been invited to your guild by "+thePlayer.getName()+".");
- }
- return true;
- }
- }
- }
- else
- {
- thePlayer.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders and officers can invite players to the guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g invite [PlayerName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("revoke") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("deinvite"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()) || (officers.contains(thePlayer.getName())))
- {
- if(Bukkit.getPlayer(args[1]) != null)
- {
- Player invPlayer = Bukkit.getPlayer(args[1]);
- if(config.isSet("players."+invPlayer.getUniqueId()+".invites"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> invs = (ArrayList<String>) config.getList("players."+invPlayer.getUniqueId()+".invites");
- if(invs.contains(gn))
- {
- invs.remove(gn);
- config.set("players."+invPlayer.getUniqueId()+".invites", invs);
- saveConfig();
- invPlayer.sendMessage("§a"+gn+" has revoked their invitation for you to join their guild. Use §2/invites §ato see any other pending invitations.");
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+invPlayer.getName()+"'s invitation to join your guild has been revoked by "+thePlayer.getName()+".");
- }
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cThat player does not have an invitation to your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cThat player does not have an invitation to your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders and officers can revoke invitations.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g revoke [PlayerName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("invs") || args[0].equalsIgnoreCase("invites") || args[0].equalsIgnoreCase("invitations"))
- {
- if(args.length == 1)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".invites"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> invs = (ArrayList<String>) config.getList("players."+thePlayer.getUniqueId()+".invites");
- thePlayer.sendMessage("§aTo accept a pending invitation you must not be a part of a guild currently and use §2/g join [GuildName]");
- thePlayer.sendMessage("§aInvitations: "+invs);
- return true;
- }
- else
- {
- thePlayer.sendMessage("§aYou currently have no pending guild invitations.");
- return true;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g invites");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("join"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- thePlayer.sendMessage("§cYou must leave or disband your current guild before joining a new one.");
- return false;
- }
- if(args.length != 2)
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g join [GuildName]");
- return false;
- }
- String gn = args[1];
- if(config.isSet("guilds."+gn))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> invs = (ArrayList<String>) config.getList("players."+thePlayer.getUniqueId()+".invites");
- if(invs.contains(gn))
- {
- invs.remove(gn);
- config.set("players."+thePlayer.getUniqueId()+".invites", invs);
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- if (members.size() == 20)
- {
- thePlayer.sendMessage("§cI'm sorry, that guild has reached it's maximum player limit.");
- return false;
- }
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+thePlayer.getName()+" has joined your guild.");
- }
- members.add(thePlayer.getName());
- config.set("guilds."+gn+".members", members);
- config.set("guilds."+gn+".landcount", config.getInt("guilds."+gn+".landcount")+1);
- config.set("guilds."+gn+".power", guildPower(gn));
- config.set("players."+thePlayer.getUniqueId()+".guild", gn);
- saveConfig();
- thePlayer.sendMessage("§aYou have successfully joined "+gn+"!");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cYou do not have an invitation from that guild, use §4/invites §cto see your guild invitations.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cGuild not found.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("leave"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- thePlayer.sendMessage("§cYou cannot leave your guild, consider §4/g leader [PlayerName] §cor §4/g disband");
- return false;
- }
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(officers.contains(thePlayer.getName()))
- {
- officers.remove(thePlayer.getName());
- config.set("guilds."+gn+".officers", officers);
- }
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- if(members.contains(thePlayer.getName()))
- {
- members.remove(thePlayer.getName());
- config.set("players."+thePlayer.getUniqueId()+".guild", null);
- config.set("guilds."+gn+".members", members);
- config.set("guilds."+gn+".landcount", config.getInt("guilds."+gn+".landcount")-1);
- config.set("guilds."+gn+".power", guildPower(gn));
- saveConfig();
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+thePlayer.getName()+" has left your guild.");
- }
- return true;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("kick"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()) || (officers.contains(thePlayer.getName())))
- {
- if(Bukkit.getPlayer(args[1]) != null)
- {
- Player kickPlayer = Bukkit.getPlayer(args[1]);
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- if(members.contains(kickPlayer.getName()))
- {
- if(config.getString("guilds."+gn+".leader").equals(kickPlayer.getUniqueId().toString()))
- {
- thePlayer.sendMessage("§cYou cannot do that.");
- return false;
- }
- if(officers.contains(kickPlayer.getName()))
- {
- if(officers.contains(thePlayer.getName()))
- {
- thePlayer.sendMessage("§cOnly the guild leader can kick guild officers.");
- return false;
- }
- officers.remove(thePlayer.getName());
- config.set("guilds."+gn+".officers", officers);
- }
- members.remove(kickPlayer.getName());
- config.set("players."+kickPlayer.getUniqueId()+".guild", null);
- config.set("guilds."+gn+".members", members);
- config.set("guilds."+gn+".landcount", config.getInt("guilds."+gn+".landcount")-1);
- config.set("guilds."+gn+".power", guildPower(gn));
- saveConfig();
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+thePlayer.getName()+" has been kicked from your guild by "+thePlayer.getName()+".");
- }
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cThat player is not a part of your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cPlayer not found.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly the guild leader and guild officers can kick players from the guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g kick [PlayerName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("chat") || (args[0].equalsIgnoreCase("c")))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length > 1)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- StringBuilder sb = new StringBuilder();
- for(int i=0;i<args.length;i++)
- {
- sb.append(args[i] + " ");
- }
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a**"+thePlayer.getName()+": "+sb);
- }
- return true;
- }
- else if(officers.contains(thePlayer.getName()))
- {
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a*"+thePlayer.getName()+": "+sb);
- }
- return true;
- }
- else
- {
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §a"+thePlayer.getName()+": "+sb);
- }
- return true;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g c [Message]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("check"))
- {
- if(args.length == 1)
- {
- Chunk chunk = thePlayer.getLocation().getChunk();
- if(config.isSet("claims."+chunk.toString()))
- {
- String guild = config.getString("claims."+chunk.toString());
- thePlayer.sendMessage("§aThis chunk belongs to "+guild+".");
- }
- else thePlayer.sendMessage("§aThis chunk does not belong to a guild.");
- }
- else thePlayer.sendMessage("§cUse this command while standing in a chunk you wish to know the owner of, correct format is §4/g check");
- }
- if(args[0].equalsIgnoreCase("claim"))
- {
- if(args.length == 1)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()) || (officers.contains(thePlayer.getName())))
- {
- Chunk chunk = thePlayer.getLocation().getChunk();
- if(config.isSet("claims."+chunk.toString()))
- {
- if(config.getString("claims."+chunk.toString()).equals(gn))
- {
- thePlayer.sendMessage("§aYour guild already owns this chunk.");
- return false;
- }
- else
- {
- thePlayer.sendMessage("§aAnalyzing attempt to claim. . .");
- int landcount = config.getInt("guilds."+gn+".landcount");
- int landclaimed = config.getInt("guilds."+gn+".landclaimed");
- if(landclaimed >= landcount)
- {
- thePlayer.sendMessage("§cYour guild cannot claim anymore land.");
- return false;
- }
- if(config.getDouble("guilds."+gn+".bal") < 200.0)
- {
- thePlayer.sendMessage("§cYour guild cannot afford $200.00 to claim this land.");
- return false;
- }
- String ogn = config.getString("claims."+chunk.toString());
- if(config.isSet("guilds."+ogn+".homeblock"))
- {
- if(config.getString("guilds."+ogn+".homeblock").equals(chunk.toString()))
- {
- thePlayer.sendMessage("§cYour guild cannot claim over the home block of "+ogn);
- return false;
- }
- }
- int olandcount = config.getInt("guilds."+ogn+".landcount");
- int olandclaimed = config.getInt("guilds."+ogn+".landclaimed");
- if(olandclaimed > olandcount)
- {
- thePlayer.sendMessage("§a"+ogn+" has claimed more land than they can support, approving your claim. . .");
- @SuppressWarnings("unchecked")
- ArrayList<String> oclaims = (ArrayList<String>) config.getList("guilds."+ogn+".claims");
- oclaims.remove(chunk.toString());
- config.set("guilds."+ogn+".claims", oclaims);
- config.set("guilds."+ogn+".landclaimed", config.getInt("guilds."+ogn+".landclaimed")-1);
- config.set("guilds."+gn+".landclaimed", config.getInt("guilds."+gn+".landclaimed")+1);
- config.set("guilds."+gn+".bal", config.getDouble("guilds."+gn+".bal")-200.0);
- config.set("claims."+chunk.toString(), gn);
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- claims.add(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- }
- else
- {
- ArrayList<String> claims = new ArrayList<String>();
- claims.add(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- }
- landclaimed = config.getInt("guilds."+gn+".landclaimed");
- saveConfig();
- thePlayer.sendMessage("§aLand claimed! You have claimed "+landclaimed+"/"+landcount+" possible claims.");
- return true;
- }
- else
- {
- int opower = Integer.parseInt(guildPower(ogn));
- int oneeded = olandclaimed*10/2;
- if(oneeded >= opower)
- {
- thePlayer.sendMessage("§cCould not claim over the land of "+ogn+". They have not exceeded their claim limit, or fallen below needed power levels.");
- return false;
- }
- else
- {
- thePlayer.sendMessage("§a"+ogn+" does not have enough power to protect this land, approving your claim. . .");
- @SuppressWarnings("unchecked")
- ArrayList<String> oclaims = (ArrayList<String>) config.getList("guilds."+ogn+".claims");
- oclaims.remove(chunk.toString());
- config.set("guilds."+ogn+".claims", oclaims);
- config.set("guilds."+ogn+".landclaimed", config.getInt("guilds."+ogn+".landclaimed")-1);
- config.set("guilds."+gn+".landclaimed", config.getInt("guilds."+gn+".landclaimed")+1);
- config.set("guilds."+gn+".bal", config.getDouble("guilds."+gn+".bal")-200.0);
- config.set("claims."+chunk.toString(), gn);
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- claims.add(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- }
- else
- {
- ArrayList<String> claims = new ArrayList<String>();
- claims.add(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- }
- landclaimed = config.getInt("guilds."+gn+".landclaimed");
- saveConfig();
- thePlayer.sendMessage("§aLand claimed! You have claimed "+landclaimed+"/"+landcount+" possible claims.");
- return true;
- }
- }
- }
- }
- else
- {
- int landcount = config.getInt("guilds."+gn+".landcount");
- int landclaimed = config.getInt("guilds."+gn+".landclaimed");
- if(landclaimed >= landcount)
- {
- thePlayer.sendMessage("§cYour guild cannot claim anymore land.");
- return false;
- }
- if(config.getDouble("guilds."+gn+".bal") < 100.0)
- {
- thePlayer.sendMessage("§cYour guild cannot afford $100.00 to claim this land.");
- return false;
- }
- else
- {
- config.set("guilds."+gn+".landclaimed", config.getInt("guilds."+gn+".landclaimed")+1);
- config.set("guilds."+gn+".bal", config.getDouble("guilds."+gn+".bal")-100.0);
- config.set("claims."+chunk.toString(), gn);
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- claims.add(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- }
- else
- {
- ArrayList<String> claims = new ArrayList<String>();
- claims.add(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- }
- landclaimed = config.getInt("guilds."+gn+".landclaimed");
- saveConfig();
- thePlayer.sendMessage("§aLand claimed! You have claimed "+landclaimed+"/"+landcount+" possible claims.");
- return true;
- }
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders and guild officers can claim land.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g claim");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("unclaim"))
- {
- if(args.length == 1)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()) || (officers.contains(thePlayer.getName())))
- {
- Chunk chunk = thePlayer.getLocation().getChunk();
- if(config.isSet("claims."+chunk.toString()))
- {
- if(config.getString("claims."+chunk.toString()).equals(gn))
- {
- int landcount = config.getInt("guilds."+gn+".landcount");
- int landclaimed = config.getInt("guilds."+gn+".landclaimed");
- config.set("guilds."+gn+".landclaimed", config.getInt("guilds."+gn+".landclaimed")-1);
- config.set("guilds."+gn+".bal", config.getDouble("guilds."+gn+".bal")+25.0);
- config.set("claims."+chunk.toString(), null);
- if(config.isSet("guilds."+gn+".homeblock"))
- {
- if(config.getString("guilds."+gn+".homeblock").equals(chunk.toString()))
- {
- config.set("guilds."+gn+".homeblock", null);
- config.set("guilds."+gn+".sethome", null);
- }
- }
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- claims.remove(chunk.toString());
- config.set("guilds."+gn+".claims", claims);
- landclaimed = config.getInt("guilds."+gn+".landclaimed");
- saveConfig();
- thePlayer.sendMessage("§aUnclaimed. Your guild has now claimed "+landclaimed+"/"+landcount+" claims.");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cThis claim does not belong to your guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cThis chunk is not claimed.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders and guild officers can unclaim land.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args.length == 2)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args[1].equalsIgnoreCase("all"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- for(int i = 0; i < claims.size(); i++)
- {
- String chunk = claims.get(i);
- config.set("claims."+chunk, null);
- config.set("guilds."+gn+".bal", config.getDouble("guilds."+gn+".bal")+25.0);
- claims.remove(i);
- }
- if(config.isSet("guilds."+gn+".homeblock"))
- {
- config.set("guilds."+gn+".homeblock", null);
- config.set("guilds."+gn+".sethome", null);
- }
- config.set("guilds."+gn+".claims", null);
- config.set("guilds."+gn+".landclaimed", 0);
- saveConfig();
- thePlayer.sendMessage("§aLand unclaimed.");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cYour guild does not have any claimed land.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly the guild leader can use that command.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g unclaim §cor §4/g unclaim all");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g unclaim §cor §4/g unclaim all");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("sethome"))
- {
- if(args.length == 1)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- Chunk chunk = thePlayer.getLocation().getChunk();
- if(config.isSet("claims."+chunk.toString()))
- {
- if(config.getString("claims."+chunk.toString()).equals(gn))
- {
- config.set("guilds."+gn+".homeblock", chunk.toString());
- String w = thePlayer.getWorld().getName();
- double x = thePlayer.getLocation().getX();
- double y = thePlayer.getLocation().getY();
- double z = thePlayer.getLocation().getZ();
- config.set("guilds."+gn+".sethome.x", x);
- config.set("guilds."+gn+".sethome.y", y);
- config.set("guilds."+gn+".sethome.z", z);
- config.set("guilds."+gn+".sethome.w", w);
- saveConfig();
- thePlayer.sendMessage("§aGuild home set to your location.");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cYour guild does not own this chunk.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cThis chunk does not belong to a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cOnly guilds leaders can set the guild home.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g sethome");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("home"))
- {
- if(args.length == 1)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.isSet("guilds."+gn+".homeblock"))
- {
- World w = (World) Bukkit.getServer().getWorld((String) config.get(("guilds."+gn+".sethome.w")));
- double x = config.getDouble(("guilds."+gn+".sethome.x"));
- double y = config.getDouble(("guilds."+gn+".sethome.y"));
- double z = config.getDouble(("guilds."+gn+".sethome.z"));
- Location loc = new Location(w, x, y, z);
- thePlayer.sendMessage("§aTeleporting in 3 seconds. . .");
- ghome.put(thePlayer.getUniqueId(), loc);
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
- @Override
- public void run()
- {
- if (ghome.containsKey(thePlayer.getUniqueId()))
- {
- thePlayer.sendMessage("§aTeleporting. . .");
- thePlayer.teleport(ghome.get(thePlayer.getUniqueId()));
- ghome.remove(thePlayer.getUniqueId());
- }
- }
- }, 80);
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g home");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("rename"))
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- if(args.length == 2)
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- String ngn = args[1];
- if(gn.equalsIgnoreCase(ngn))
- {
- thePlayer.sendMessage("§cThat is already the name of your guild.");
- return false;
- }
- if(!isAlphanumeric(ngn))
- {
- thePlayer.sendMessage("§cYour guild name must be alphanumeric, please choose a new name and try again.");
- return false;
- }
- if(illegalNames.contains(ngn))
- {
- thePlayer.sendMessage("§cInnappropriate guild name, please choose a new name and try again.");
- return false;
- }
- @SuppressWarnings("unchecked")
- ArrayList<String> guilds = (ArrayList<String>) config.getList("guildlist");
- for(int i = 0; i < guilds.size(); i++)
- {
- if(guilds.get(i).equalsIgnoreCase(ngn))
- {
- thePlayer.sendMessage("§cThat guild already exists, please choose a new name and try again.");
- return false;
- }
- }
- if(ngn.length() > 10)
- {
- thePlayer.sendMessage("§cGuild names cannot be longer than 10 characters, please choose a new name and try again.");
- return false;
- }
- if(config.getDouble("guilds."+gn+".bal") < 250.00)
- {
- thePlayer.sendMessage("§cYou do not have enough money in your guild bank to rename your guild, you need $250.00, use §4/g balance");
- return false;
- }
- config.createSection("guilds."+ngn);
- if(config.isSet("guilds."+gn+".officers"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> officers = (ArrayList<String>) config.getList("guilds."+gn+".officers");
- ArrayList<String> nofficers = new ArrayList<String>();
- for(int i = 0; i < officers.size(); i++)
- {
- nofficers.add(officers.get(i));
- }
- config.set("guilds."+ngn+".officers", nofficers);
- }
- if(config.isSet("guilds."+gn+".members"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- ArrayList<String> nmembers = new ArrayList<String>();
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§aYour guild has been renamed to "+ngn);
- nmembers.add(members.get(i));
- config.set("players."+member.getUniqueId()+".guild", ngn);
- }
- config.set("guilds."+ngn+".members", nmembers);
- }
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- ArrayList<String> nclaims = new ArrayList<String>();
- for(int i = 0; i < claims.size(); i++)
- {
- nclaims.add(claims.get(i));
- config.set("claims."+claims.get(i), ngn);
- }
- config.set("guilds."+ngn+".claims", nclaims);
- }
- config.set("guilds."+ngn+".bal", config.getDouble("guilds."+gn+".bal"));
- if(config.isSet("guilds."+gn+".sethome.w"))
- {
- config.set("guilds."+ngn+".sethome.w", config.get("guilds."+gn+".sethome.w"));
- config.set("guilds."+ngn+".sethome.x", config.get("guilds."+gn+".sethome.x"));
- config.set("guilds."+ngn+".sethome.y", config.get("guilds."+gn+".sethome.y"));
- config.set("guilds."+ngn+".sethome.z", config.get("guilds."+gn+".sethome.z"));
- config.set("guilds."+ngn+".homeblock", config.get("guilds."+gn+".homeblock"));
- }
- config.set("guilds."+ngn+".leader", config.get("guilds."+gn+".leader"));
- config.set("guilds."+ngn+".leadername", config.get("guilds."+gn+".leadername"));
- config.set("guilds."+ngn+".landcount", config.get("guilds."+gn+".landcount"));
- config.set("guilds."+ngn+".landclaimed", config.get("guilds."+gn+".landclaimed"));
- config.set("guilds."+ngn+".power", guildPower(gn));
- config.set("guilds."+gn, null);
- guilds.remove(gn);
- guilds.add(ngn);
- config.set("guildlist", guilds);
- saveConfig();
- Bukkit.getServer().broadcastMessage("§6[§3Guilds§6] §a"+gn+" has been renamed to "+ngn+"!");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders can rename guilds.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g rename [NewGuildName]");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- if(args[0].equalsIgnoreCase("disband"))
- {
- if(args.length == 1)
- {
- if(config.isSet("players."+thePlayer.getUniqueId()+".guild"))
- {
- String gn = config.getString("players."+thePlayer.getUniqueId()+".guild");
- if(config.getString("guilds."+gn+".leader").equals(thePlayer.getUniqueId().toString()))
- {
- if(config.isSet("guilds."+gn+".members"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> members = (ArrayList<String>) config.getList("guilds."+gn+".members");
- for(int i = 0; i < members.size(); i++)
- {
- Player member = Bukkit.getPlayer(members.get(i));
- member.sendMessage("§6[§a"+gn+"§6] §aYour guild has been disbanded.");
- config.set("players."+member.getUniqueId()+".guild", null);
- }
- }
- if(config.isSet("guilds."+gn+".claims"))
- {
- @SuppressWarnings("unchecked")
- ArrayList<String> claims = (ArrayList<String>) config.getList("guilds."+gn+".claims");
- for(int i = 0; i < claims.size(); i++)
- {
- config.set("claims."+claims.get(i), null);
- }
- }
- config.set("guilds."+gn, null);
- @SuppressWarnings("unchecked")
- ArrayList<String> guilds = (ArrayList<String>) config.getList("guildlist");
- guilds.remove(gn);
- config.set("guildlist", guilds);
- saveConfig();
- Bukkit.getServer().broadcastMessage("§6[§3Guilds§6] §a"+gn+" has been disbanded!");
- return true;
- }
- else
- {
- thePlayer.sendMessage("§cOnly guild leaders can disband guilds.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cYou are not a part of a guild.");
- return false;
- }
- }
- else
- {
- thePlayer.sendMessage("§cIncorrect format, use §4/g rename [NewGuildName]");
- return false;
- }
- }
- }
- }
- else theSender.sendMessage("§cGuild commands can only be used in game.");
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement