Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov Date: 2014/4/25 上午 12:23:49
- // Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
- // Decompiler options: packimports(3)
- // Source File Name: uSkyBlock.java
- package us.talabrek.ultimateskyblock;
- import com.sk89q.worldedit.MaxChangedBlocksException;
- import com.sk89q.worldedit.data.DataException;
- import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
- import com.sk89q.worldguard.protection.managers.RegionManager;
- import java.io.*;
- import java.text.DateFormat;
- import java.text.DecimalFormat;
- import java.util.*;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import net.milkbowl.vault.economy.Economy;
- import org.bukkit.*;
- import org.bukkit.block.*;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.PluginCommand;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.*;
- import org.bukkit.generator.ChunkGenerator;
- import org.bukkit.inventory.*;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.inventory.meta.SkullMeta;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitScheduler;
- // Referenced classes of package us.talabrek.ultimateskyblock:
- // VaultHandler, IslandCommand, ChallengesCommand, DevCommand,
- // Settings, PlayerInfo, WorldGuardHandler, PlayerJoin,
- // ProtectionEvents, SkyBlockChunkGenerator, WorldEditHandler, SerializableLocation,
- // Challenge
- public class uSkyBlock extends JavaPlugin
- {
- public uSkyBlock()
- {
- df = new DecimalFormat(".#");
- levelConfig = null;
- lastIslandConfig = null;
- orphans = null;
- tempIsland = null;
- tempPlayer = null;
- islands = new HashMap();
- levelConfigFile = null;
- orphanFile = null;
- lastIslandConfigFile = null;
- islandConfigFile = null;
- tempIslandFile = null;
- tempPlayerFile = null;
- removeList = new ArrayList();
- orphaned = new Stack();
- tempOrphaned = new Stack();
- reverseOrphaned = new Stack();
- islandTestLocation = null;
- infoCooldown = new HashMap();
- restartCooldown = new HashMap();
- biomeCooldown = new HashMap();
- activePlayers = new HashMap();
- challenges = new LinkedHashMap();
- requiredList = new HashMap();
- purgeActive = false;
- skyblockData = null;
- skyblockDataFile = null;
- GUIparty = null;
- GUIpartyPlayer = null;
- GUIisland = null;
- GUIchallenge = null;
- GUIbiome = null;
- GUIlog = null;
- pHead = new ItemStack(397, 1, (short)3);
- sign = new ItemStack(323, 1);
- biome = new ItemStack(6, 1, (short)3);
- lock = new ItemStack(101, 1);
- warpset = new ItemStack(90, 1);
- warptoggle = new ItemStack(69, 1);
- invite = new ItemStack(398, 1);
- kick = new ItemStack(301, 1);
- currentBiomeItem = null;
- currentIslandItem = null;
- currentChallengeItem = null;
- currentLogItem = null;
- lores = new ArrayList();
- }
- public void onDisable()
- {
- try
- {
- unloadPlayerFiles();
- if(lastIsland != null)
- setLastIsland(lastIsland);
- }
- catch(Exception e)
- {
- System.out.println("Something went wrong saving the island and/or party data!");
- e.printStackTrace();
- }
- log.info((new StringBuilder(String.valueOf(pluginFile.getName()))).append(" v").append(pluginFile.getVersion()).append(" disabled.").toString());
- }
- public void onEnable()
- {
- instance = this;
- saveDefaultConfig();
- saveDefaultLevelConfig();
- saveDefaultOrphans();
- pluginFile = getDescription();
- log = getLogger();
- pName = (new StringBuilder()).append(ChatColor.WHITE).append("[").append(ChatColor.GREEN).append(pluginFile.getName()).append(ChatColor.WHITE).append("] ").toString();
- VaultHandler.setupEconomy();
- if(!getDataFolder().exists())
- getDataFolder().mkdir();
- configPlugin = getConfig();
- filePlugin = new File(getDataFolder(), "config.yml");
- loadPluginConfig();
- loadLevelConfig();
- registerEvents();
- directoryPlayers = new File((new StringBuilder()).append(getDataFolder()).append(File.separator).append("players").toString());
- directoryIslands = new File((new StringBuilder()).append(getDataFolder()).append(File.separator).append("islands").toString());
- if(!directoryPlayers.exists())
- {
- directoryPlayers.mkdir();
- loadPlayerFiles();
- } else
- {
- loadPlayerFiles();
- }
- if(!directoryIslands.exists())
- directoryIslands.mkdir();
- directorySchematics = new File((new StringBuilder()).append(getDataFolder()).append(File.separator).append("schematics").toString());
- if(!directorySchematics.exists())
- directorySchematics.mkdir();
- schemFile = directorySchematics.listFiles();
- if(schemFile == null)
- System.out.print("[uSkyBlock] No schematic file loaded.");
- else
- System.out.print((new StringBuilder("[uSkyBlock] ")).append(schemFile.length).append(" schematics loaded.").toString());
- getCommand("island").setExecutor(new IslandCommand());
- getCommand("challenges").setExecutor(new ChallengesCommand());
- getCommand("dev").setExecutor(new DevCommand());
- if(Settings.island_useTopTen)
- getInstance().updateTopTen(getInstance().generateTopTen());
- populateChallengeList();
- log.info((new StringBuilder(String.valueOf(pluginFile.getName()))).append(" v.").append(pluginFile.getVersion()).append(" enabled.").toString());
- getInstance().getServer().getScheduler().runTaskLater(getInstance(), new Runnable() {
- public void run()
- {
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("Vault"))
- {
- System.out.print("[uSkyBlock] Using vault for permissions");
- VaultHandler.setupPermissions();
- try
- {
- if(!getLastIslandConfig().contains("options.general.lastIslandX") && getConfig().contains("options.general.lastIslandX"))
- {
- getLastIslandConfig();
- FileConfiguration.createPath(getLastIslandConfig().getConfigurationSection("options.general"), "lastIslandX");
- getLastIslandConfig();
- FileConfiguration.createPath(getLastIslandConfig().getConfigurationSection("options.general"), "lastIslandZ");
- getLastIslandConfig().set("options.general.lastIslandX", Integer.valueOf(getConfig().getInt("options.general.lastIslandX")));
- getLastIslandConfig().set("options.general.lastIslandZ", Integer.valueOf(getConfig().getInt("options.general.lastIslandZ")));
- saveLastIslandConfig();
- }
- lastIsland = new Location(uSkyBlock.getSkyBlockWorld(), getLastIslandConfig().getInt("options.general.lastIslandX"), Settings.island_height, getLastIslandConfig().getInt("options.general.lastIslandZ"));
- }
- catch(Exception e)
- {
- lastIsland = new Location(uSkyBlock.getSkyBlockWorld(), getConfig().getInt("options.general.lastIslandX"), Settings.island_height, getConfig().getInt("options.general.lastIslandZ"));
- }
- if(lastIsland == null)
- lastIsland = new Location(uSkyBlock.getSkyBlockWorld(), 0.0D, Settings.island_height, 0.0D);
- if(Settings.island_protectWithWorldGuard && !Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard"))
- {
- PluginManager manager = uSkyBlock.getInstance().getServer().getPluginManager();
- System.out.print("[uSkyBlock] WorldGuard not loaded! Using built in protection.");
- manager.registerEvents(new ProtectionEvents(), uSkyBlock.getInstance());
- }
- uSkyBlock.getInstance().setupOrphans();
- }
- }
- final uSkyBlock this$0;
- {
- this$0 = uSkyBlock.this;
- super();
- }
- }
- , 0L);
- }
- public static uSkyBlock getInstance()
- {
- return instance;
- }
- public void loadPlayerFiles()
- {
- int onlinePlayerCount = 0;
- onlinePlayerCount = Bukkit.getServer().getOnlinePlayers().length;
- Player onlinePlayers[] = Bukkit.getServer().getOnlinePlayers();
- for(int i = 0; i < onlinePlayerCount; i++)
- if(onlinePlayers[i].isOnline())
- {
- File f = new File(getInstance().directoryPlayers, onlinePlayers[i].getName());
- PlayerInfo pi = new PlayerInfo(onlinePlayers[i].getName());
- if(f.exists())
- {
- PlayerInfo pi2 = getInstance().readPlayerFile(onlinePlayers[i].getName());
- if(pi2 != null)
- {
- pi.setIslandLocation(pi2.getIslandLocation());
- pi.setHomeLocation(pi2.getHomeLocation());
- pi.setHasIsland(pi2.getHasIsland());
- if(getInstance().getIslandConfig(pi.locationForParty()) == null)
- getInstance().createIslandConfig(pi.locationForParty(), onlinePlayers[i].getName());
- getInstance().clearIslandConfig(pi.locationForParty(), onlinePlayers[i].getName());
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard"))
- WorldGuardHandler.protectIsland(onlinePlayers[i], onlinePlayers[i].getName(), pi);
- }
- f.delete();
- }
- getInstance().addActivePlayer(onlinePlayers[i].getName(), pi);
- if(pi.getHasIsland() && getInstance().getTempIslandConfig(pi.locationForParty()) == null)
- {
- getInstance().createIslandConfig(pi.locationForParty(), onlinePlayers[i].getName());
- System.out.println("Creating new Config File");
- }
- getInstance().getIslandConfig(pi.locationForParty());
- }
- System.out.print("Island Configs Loaded:");
- getInstance().displayIslandConfigs();
- }
- public void unloadPlayerFiles()
- {
- for(int i = 0; i < Bukkit.getServer().getOnlinePlayers().length; i++)
- {
- Player removedPlayers[] = Bukkit.getServer().getOnlinePlayers();
- if(getActivePlayers().containsKey(removedPlayers[i].getName()))
- removeActivePlayer(removedPlayers[i].getName());
- }
- }
- public void registerEvents()
- {
- PluginManager manager = getServer().getPluginManager();
- manager.registerEvents(new PlayerJoin(), this);
- if(!Settings.island_protectWithWorldGuard)
- {
- System.out.print("[uSkyBlock] Using built in protection.");
- manager.registerEvents(new ProtectionEvents(), getInstance());
- } else
- {
- System.out.print("[uSkyBlock] Using WorldGuard protection.");
- }
- }
- public void loadPluginConfig()
- {
- try
- {
- getConfig();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- try
- {
- Settings.general_maxPartySize = getConfig().getInt("options.general.maxPartySize");
- if(Settings.general_maxPartySize < 0)
- Settings.general_maxPartySize = 0;
- }
- catch(Exception e)
- {
- Settings.general_maxPartySize = 4;
- }
- try
- {
- Settings.island_distance = getConfig().getInt("options.island.distance");
- if(Settings.island_distance < 50)
- Settings.island_distance = 50;
- }
- catch(Exception e)
- {
- Settings.island_distance = 110;
- }
- try
- {
- Settings.island_protectionRange = getConfig().getInt("options.island.protectionRange");
- if(Settings.island_protectionRange > Settings.island_distance)
- Settings.island_protectionRange = Settings.island_distance;
- }
- catch(Exception e)
- {
- Settings.island_protectionRange = 100;
- }
- try
- {
- Settings.general_cooldownInfo = getConfig().getInt("options.general.cooldownInfo");
- if(Settings.general_cooldownInfo < 0)
- Settings.general_cooldownInfo = 0;
- }
- catch(Exception e)
- {
- Settings.general_cooldownInfo = 60;
- }
- try
- {
- Settings.general_biomeChange = getConfig().getInt("options.general.biomeChange");
- if(Settings.general_biomeChange < 0)
- Settings.general_biomeChange = 0;
- }
- catch(Exception e)
- {
- Settings.general_biomeChange = 3600;
- }
- try
- {
- Settings.general_cooldownRestart = getConfig().getInt("options.general.cooldownRestart");
- if(Settings.general_cooldownRestart < 0)
- Settings.general_cooldownRestart = 0;
- }
- catch(Exception e)
- {
- Settings.general_cooldownRestart = 60;
- }
- try
- {
- Settings.island_height = getConfig().getInt("options.island.height");
- if(Settings.island_height < 20)
- Settings.island_height = 20;
- }
- catch(Exception e)
- {
- Settings.island_height = 120;
- }
- try
- {
- Settings.challenges_rankLeeway = getConfig().getInt("options.challenges.rankLeeway");
- if(Settings.challenges_rankLeeway < 0)
- Settings.challenges_rankLeeway = 0;
- }
- catch(Exception e)
- {
- Settings.challenges_rankLeeway = 0;
- }
- if(!getConfig().contains("options.extras.obsidianToLava"))
- {
- getConfig().set("options.extras.obsidianToLava", Boolean.valueOf(true));
- saveConfig();
- }
- if(!getConfig().contains("options.general.spawnSize"))
- {
- getConfig().set("options.general.spawnSize", Integer.valueOf(50));
- saveConfig();
- }
- try
- {
- Settings.general_spawnSize = getConfig().getInt("options.general.spawnSize");
- if(Settings.general_spawnSize < 50)
- Settings.general_spawnSize = 50;
- }
- catch(Exception e)
- {
- Settings.general_spawnSize = 50;
- }
- String chestItemString[] = getConfig().getString("options.island.chestItems").split(" ");
- ItemStack tempChest[] = new ItemStack[chestItemString.length];
- String amountdata[] = new String[2];
- for(int i = 0; i < tempChest.length; i++)
- {
- amountdata = chestItemString[i].split(":");
- tempChest[i] = new ItemStack(Integer.parseInt(amountdata[0]), Integer.parseInt(amountdata[1]));
- }
- Settings.island_chestItems = tempChest;
- Settings.island_allowPvP = getConfig().getString("options.island.allowPvP");
- Settings.island_schematicName = getConfig().getString("options.island.schematicName");
- if(!Settings.island_allowPvP.equalsIgnoreCase("allow"))
- Settings.island_allowPvP = "deny";
- Set permissionList = getConfig().getConfigurationSection("options.island.extraPermissions").getKeys(true);
- Settings.island_addExtraItems = getConfig().getBoolean("options.island.addExtraItems");
- Settings.extras_obsidianToLava = getConfig().getBoolean("options.extras.obsidianToLava");
- Settings.island_useIslandLevel = getConfig().getBoolean("options.island.useIslandLevel");
- Settings.island_extraPermissions = (String[])permissionList.toArray(new String[0]);
- Settings.island_protectWithWorldGuard = getConfig().getBoolean("options.island.protectWithWorldGuard");
- Settings.extras_sendToSpawn = getConfig().getBoolean("options.extras.sendToSpawn");
- Settings.island_useTopTen = getConfig().getBoolean("options.island.useTopTen");
- Settings.general_worldName = getConfig().getString("options.general.worldName");
- Settings.island_removeCreaturesByTeleport = getConfig().getBoolean("options.island.removeCreaturesByTeleport");
- Settings.island_allowIslandLock = getConfig().getBoolean("options.island.allowIslandLock");
- Settings.island_useOldIslands = getConfig().getBoolean("options.island.useOldIslands");
- Set challengeList = getConfig().getConfigurationSection("options.challenges.challengeList").getKeys(false);
- Settings.challenges_challengeList = challengeList;
- Settings.challenges_broadcastCompletion = getConfig().getBoolean("options.challenges.broadcastCompletion");
- Settings.challenges_broadcastText = getConfig().getString("options.challenges.broadcastText");
- Settings.challenges_challengeColor = getConfig().getString("options.challenges.challengeColor");
- Settings.challenges_enableEconomyPlugin = getConfig().getBoolean("options.challenges.enableEconomyPlugin");
- Settings.challenges_finishedColor = getConfig().getString("options.challenges.finishedColor");
- Settings.challenges_repeatableColor = getConfig().getString("options.challenges.repeatableColor");
- Settings.challenges_requirePreviousRank = getConfig().getBoolean("options.challenges.requirePreviousRank");
- Settings.challenges_allowChallenges = getConfig().getBoolean("options.challenges.allowChallenges");
- String rankListString[] = getConfig().getString("options.challenges.ranks").split(" ");
- Settings.challenges_ranks = rankListString;
- }
- public List readPartyFile()
- {
- File f = new File(getDataFolder(), "partylist.bin");
- if(!f.exists())
- return null;
- try
- {
- FileInputStream fileIn = new FileInputStream(f);
- ObjectInputStream in = new ObjectInputStream(fileIn);
- List p = (List)in.readObject();
- in.close();
- fileIn.close();
- return p;
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- return null;
- }
- public void writePartyFile(List pi)
- {
- File f = new File(getDataFolder(), "partylist.bin");
- try
- {
- FileOutputStream fileOut = new FileOutputStream(f);
- ObjectOutputStream out = new ObjectOutputStream(fileOut);
- out.writeObject(pi);
- out.flush();
- out.close();
- fileOut.close();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- public PlayerInfo readPlayerFile(String playerName)
- {
- File f = new File(directoryPlayers, playerName);
- if(!f.exists())
- return null;
- try
- {
- FileInputStream fileIn = new FileInputStream(f);
- ObjectInputStream in = new ObjectInputStream(fileIn);
- PlayerInfo p = (PlayerInfo)in.readObject();
- in.close();
- fileIn.close();
- return p;
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- return null;
- }
- public boolean displayTopTen(Player player)
- {
- int i = 1;
- int playerrank = 0;
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Displaying the top 10 islands:").toString());
- if(topTen == null)
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("Top ten list not generated yet!").toString());
- return false;
- }
- for(Iterator iterator = topTen.keySet().iterator(); iterator.hasNext();)
- {
- String playerName = (String)iterator.next();
- if(i <= 10)
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("#").append(i).append(": ").append(playerName).append(" - Island level ").append(((Double)topTen.get(playerName)).intValue()).toString());
- if(playerName.equalsIgnoreCase(player.getName()))
- playerrank = i;
- i++;
- }
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Your rank is: ").append(ChatColor.WHITE).append(playerrank).toString());
- return true;
- }
- public void updateTopTen(LinkedHashMap map)
- {
- topTen = map;
- }
- public Location getLocationString(String s)
- {
- if(s == null || s.trim() == "")
- return null;
- String parts[] = s.split(":");
- if(parts.length == 4)
- {
- World w = getServer().getWorld(parts[0]);
- int x = Integer.parseInt(parts[1]);
- int y = Integer.parseInt(parts[2]);
- int z = Integer.parseInt(parts[3]);
- return new Location(w, x, y, z);
- } else
- {
- return null;
- }
- }
- public String getStringLocation(Location l)
- {
- if(l == null)
- return "";
- else
- return (new StringBuilder(String.valueOf(l.getWorld().getName()))).append(":").append(l.getBlockX()).append(":").append(l.getBlockY()).append(":").append(l.getBlockZ()).toString();
- }
- public void setStringbyPath(FileConfiguration fc, File f, String path, Object value)
- {
- fc.set(path, value.toString());
- try
- {
- fc.save(f);
- }
- catch(IOException e)
- {
- e.printStackTrace();
- }
- }
- public String getStringbyPath(FileConfiguration fc, File file, String path, Object stdValue, boolean addMissing)
- {
- if(!fc.contains(path))
- {
- if(addMissing)
- setStringbyPath(fc, file, path, stdValue);
- return stdValue.toString();
- } else
- {
- return fc.getString(path);
- }
- }
- public static World getSkyBlockWorld()
- {
- if(skyBlockWorld == null)
- {
- skyBlockWorld = WorldCreator.name(Settings.general_worldName).type(WorldType.FLAT).environment(org.bukkit.World.Environment.NORMAL).generator(new SkyBlockChunkGenerator()).createWorld();
- if(Bukkit.getServer().getPluginManager().isPluginEnabled("Multiverse-Core"))
- Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), (new StringBuilder("mv import ")).append(Settings.general_worldName).append(" normal -g uSkyBlock").toString());
- }
- return skyBlockWorld;
- }
- public void clearOrphanedIsland()
- {
- for(; hasOrphanedIsland(); orphaned.pop());
- }
- public void clearArmorContents(Player player)
- {
- player.getInventory().setArmorContents(new ItemStack[player.getInventory().getArmorContents().length]);
- }
- public void getAllFiles(String path)
- {
- File dirpath = new File(path);
- if(!dirpath.exists())
- return;
- File afile[];
- int j = (afile = dirpath.listFiles()).length;
- for(int i = 0; i < j; i++)
- {
- File f = afile[i];
- try
- {
- if(!f.isDirectory())
- sfiles.add(f);
- else
- getAllFiles(f.getAbsolutePath());
- }
- catch(Exception ex)
- {
- log.warning(ex.getMessage());
- }
- }
- }
- public Location getYLocation(Location l)
- {
- for(int y = 0; y < 254; y++)
- {
- int px = l.getBlockX();
- int py = y;
- int pz = l.getBlockZ();
- Block b1 = (new Location(l.getWorld(), px, py, pz)).getBlock();
- Block b2 = (new Location(l.getWorld(), px, py + 1, pz)).getBlock();
- Block b3 = (new Location(l.getWorld(), px, py + 2, pz)).getBlock();
- if(!b1.getType().equals(Material.AIR) && b2.getType().equals(Material.AIR) && b3.getType().equals(Material.AIR))
- return b2.getLocation();
- }
- return l;
- }
- public Location getSafeHomeLocation(PlayerInfo p)
- {
- Location home = null;
- if(p.getHomeLocation() == null)
- {
- if(p.getIslandLocation() != null)
- home = p.getIslandLocation();
- } else
- {
- home = p.getHomeLocation();
- }
- if(isSafeLocation(home))
- return home;
- for(int y = home.getBlockY() + 25; y > 0; y--)
- {
- Location n = new Location(home.getWorld(), home.getBlockX(), y, home.getBlockZ());
- if(isSafeLocation(n))
- return n;
- }
- for(int y = home.getBlockY(); y < 255; y++)
- {
- Location n = new Location(home.getWorld(), home.getBlockX(), y, home.getBlockZ());
- if(isSafeLocation(n))
- return n;
- }
- Location island = p.getIslandLocation();
- if(isSafeLocation(island))
- return island;
- for(int y = island.getBlockY() + 25; y > 0; y--)
- {
- Location n = new Location(island.getWorld(), island.getBlockX(), y, island.getBlockZ());
- if(isSafeLocation(n))
- return n;
- }
- for(int y = island.getBlockY(); y < 255; y++)
- {
- Location n = new Location(island.getWorld(), island.getBlockX(), y, island.getBlockZ());
- if(isSafeLocation(n))
- return n;
- }
- return p.getHomeLocation();
- }
- public Location getSafeWarpLocation(PlayerInfo p)
- {
- Location warp = null;
- getTempIslandConfig(p.locationForParty());
- if(tempIsland.getInt("general.warpLocationX") == 0)
- {
- if(p.getHomeLocation() == null)
- {
- if(p.getIslandLocation() != null)
- warp = p.getIslandLocation();
- } else
- {
- warp = p.getHomeLocation();
- }
- } else
- {
- warp = new Location(skyBlockWorld, tempIsland.getInt("general.warpLocationX"), tempIsland.getInt("general.warpLocationY"), tempIsland.getInt("general.warpLocationZ"));
- }
- if(warp == null)
- {
- System.out.print((new StringBuilder("Error warping player to ")).append(p.getPlayerName()).append("'s island.").toString());
- return null;
- }
- if(isSafeLocation(warp))
- return warp;
- for(int y = warp.getBlockY() + 25; y > 0; y--)
- {
- Location n = new Location(warp.getWorld(), warp.getBlockX(), y, warp.getBlockZ());
- if(isSafeLocation(n))
- return n;
- }
- for(int y = warp.getBlockY(); y < 255; y++)
- {
- Location n = new Location(warp.getWorld(), warp.getBlockX(), y, warp.getBlockZ());
- if(isSafeLocation(n))
- return n;
- }
- return null;
- }
- public boolean isSafeLocation(Location l)
- {
- if(l == null)
- return false;
- Block ground = l.getBlock().getRelative(BlockFace.DOWN);
- Block air1 = l.getBlock();
- Block air2 = l.getBlock().getRelative(BlockFace.UP);
- if(ground.getType().equals(Material.AIR))
- return false;
- if(ground.getType().equals(Material.LAVA))
- return false;
- if(ground.getType().equals(Material.STATIONARY_LAVA))
- return false;
- if(ground.getType().equals(Material.CACTUS))
- return false;
- return (air1.getType().equals(Material.AIR) || air1.getType().equals(Material.CROPS) || air1.getType().equals(Material.LONG_GRASS) || air1.getType().equals(Material.RED_ROSE) || air1.getType().equals(Material.YELLOW_FLOWER) || air1.getType().equals(Material.DEAD_BUSH) || air1.getType().equals(Material.SIGN_POST) || air1.getType().equals(Material.SIGN)) && air2.getType().equals(Material.AIR);
- }
- public void removeCreatures(Location l)
- {
- if(!Settings.island_removeCreaturesByTeleport || l == null)
- return;
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -1; x <= 1; x++)
- {
- for(int z = -1; z <= 1; z++)
- {
- Chunk c = l.getWorld().getChunkAt(new Location(l.getWorld(), px + x * 16, py, pz + z * 16));
- Entity aentity[];
- int j = (aentity = c.getEntities()).length;
- for(int i = 0; i < j; i++)
- {
- Entity e = aentity[i];
- if(e.getType() == EntityType.SPIDER || e.getType() == EntityType.CREEPER || e.getType() == EntityType.ENDERMAN || e.getType() == EntityType.SKELETON || e.getType() == EntityType.ZOMBIE)
- e.remove();
- }
- }
- }
- }
- public void deletePlayerIsland(String player)
- {
- if(!getActivePlayers().containsKey(player))
- {
- PlayerInfo pi = new PlayerInfo(player);
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard") && WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).hasRegion((new StringBuilder(String.valueOf(player))).append("Island").toString()))
- WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).removeRegion((new StringBuilder(String.valueOf(player))).append("Island").toString());
- orphaned.push(pi.getIslandLocation());
- removeIsland(pi.getIslandLocation());
- deleteIslandConfig(pi.locationForParty());
- pi.removeFromIsland();
- saveOrphans();
- pi.savePlayerConfig(player);
- } else
- {
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard") && WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).hasRegion((new StringBuilder(String.valueOf(player))).append("Island").toString()))
- WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).removeRegion((new StringBuilder(String.valueOf(player))).append("Island").toString());
- orphaned.push(((PlayerInfo)getActivePlayers().get(player)).getIslandLocation());
- removeIsland(((PlayerInfo)getActivePlayers().get(player)).getIslandLocation());
- deleteIslandConfig(((PlayerInfo)getActivePlayers().get(player)).locationForParty());
- PlayerInfo pi = new PlayerInfo(player);
- pi.removeFromIsland();
- addActivePlayer(player, pi);
- saveOrphans();
- }
- }
- public void restartPlayerIsland(Player player, Location next)
- {
- boolean hasIslandNow = false;
- if(next.getBlockX() == 0 && next.getBlockZ() == 0)
- return;
- removeIsland(next);
- if(getInstance().getSchemFile().length > 0 && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldEdit"))
- {
- String cSchem = "";
- for(int i = 0; i < getInstance().getSchemFile().length; i++)
- if(!hasIslandNow)
- {
- if(getInstance().getSchemFile()[i].getName().lastIndexOf('.') > 0)
- cSchem = getInstance().getSchemFile()[i].getName().substring(0, getInstance().getSchemFile()[i].getName().lastIndexOf('.'));
- else
- cSchem = getInstance().getSchemFile()[i].getName();
- if(VaultHandler.checkPerk(player.getName(), (new StringBuilder("usb.schematic.")).append(cSchem).toString(), getSkyBlockWorld()))
- try
- {
- if(WorldEditHandler.loadIslandSchematic(getSkyBlockWorld(), getInstance().getSchemFile()[i], next))
- {
- setChest(next, player);
- hasIslandNow = true;
- }
- }
- catch(MaxChangedBlocksException e)
- {
- e.printStackTrace();
- }
- catch(DataException e)
- {
- e.printStackTrace();
- }
- catch(IOException e)
- {
- e.printStackTrace();
- }
- }
- if(!hasIslandNow)
- {
- for(int i = 0; i < getInstance().getSchemFile().length; i++)
- {
- if(getInstance().getSchemFile()[i].getName().lastIndexOf('.') > 0)
- cSchem = getInstance().getSchemFile()[i].getName().substring(0, getInstance().getSchemFile()[i].getName().lastIndexOf('.'));
- else
- cSchem = getInstance().getSchemFile()[i].getName();
- if(cSchem.equalsIgnoreCase(Settings.island_schematicName))
- try
- {
- if(WorldEditHandler.loadIslandSchematic(getSkyBlockWorld(), getInstance().getSchemFile()[i], next))
- {
- setChest(next, player);
- hasIslandNow = true;
- }
- }
- catch(MaxChangedBlocksException e)
- {
- e.printStackTrace();
- }
- catch(DataException e)
- {
- e.printStackTrace();
- }
- catch(IOException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
- if(!hasIslandNow)
- if(!Settings.island_useOldIslands)
- generateIslandBlocks(next.getBlockX(), next.getBlockZ(), player, getSkyBlockWorld());
- else
- oldGenerateIslandBlocks(next.getBlockX(), next.getBlockZ(), player, getSkyBlockWorld());
- next.setY(Settings.island_height);
- System.out.println(next.getBlockY());
- setNewPlayerIsland(player, next);
- player.getInventory().clear();
- player.getEquipment().clear();
- getInstance().changePlayerBiome(player, "OCEAN");
- for(int x = (Settings.island_protectionRange / 2) * -1 - 16; x <= Settings.island_protectionRange / 2 + 16; x += 16)
- {
- for(int z = (Settings.island_protectionRange / 2) * -1 - 16; z <= Settings.island_protectionRange / 2 + 16; z += 16)
- getSkyBlockWorld().refreshChunk((next.getBlockX() + x) / 16, (next.getBlockZ() + z) / 16);
- }
- for(Iterator ents = player.getNearbyEntities(Settings.island_protectionRange / 2, 250D, Settings.island_protectionRange / 2).iterator(); ents.hasNext();)
- {
- Entity tempent = (Entity)ents.next();
- if(!(tempent instanceof Player))
- tempent.remove();
- }
- }
- public void devDeletePlayerIsland(String player)
- {
- if(!getActivePlayers().containsKey(player))
- {
- PlayerInfo pi = new PlayerInfo(player);
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard") && WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).hasRegion((new StringBuilder(String.valueOf(player))).append("Island").toString()))
- WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).removeRegion((new StringBuilder(String.valueOf(player))).append("Island").toString());
- pi = new PlayerInfo(player);
- pi.savePlayerConfig(player);
- } else
- {
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard") && WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).hasRegion((new StringBuilder(String.valueOf(player))).append("Island").toString()))
- WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).removeRegion((new StringBuilder(String.valueOf(player))).append("Island").toString());
- PlayerInfo pi = new PlayerInfo(player);
- removeActivePlayer(player);
- addActivePlayer(player, pi);
- }
- }
- public boolean devSetPlayerIsland(Player sender, Location l, String player)
- {
- if(!getActivePlayers().containsKey(player))
- {
- PlayerInfo pi = new PlayerInfo(player);
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -10; x <= 10; x++)
- {
- for(int y = -10; y <= 10; y++)
- {
- for(int z = -10; z <= 10; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(b.getTypeId() == 7)
- {
- pi.setHomeLocation(new Location(l.getWorld(), px + x, py + y + 3, pz + z));
- pi.setHasIsland(true);
- pi.setIslandLocation(b.getLocation());
- pi.savePlayerConfig(player);
- getInstance().createIslandConfig(pi.locationForParty(), player);
- getInstance().clearIslandConfig(pi.locationForParty(), player);
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard"))
- WorldGuardHandler.protectIsland(sender, player, pi);
- getInstance().getIslandConfig(pi.locationForParty());
- return true;
- }
- }
- }
- }
- } else
- {
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -10; x <= 10; x++)
- {
- for(int y = -10; y <= 10; y++)
- {
- for(int z = -10; z <= 10; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(b.getTypeId() == 7)
- {
- ((PlayerInfo)getActivePlayers().get(player)).setHomeLocation(new Location(l.getWorld(), px + x, py + y + 3, pz + z));
- ((PlayerInfo)getActivePlayers().get(player)).setHasIsland(true);
- ((PlayerInfo)getActivePlayers().get(player)).setIslandLocation(b.getLocation());
- PlayerInfo pi = (PlayerInfo)getActivePlayers().get(player);
- removeActivePlayer(player);
- addActivePlayer(player, pi);
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard"))
- WorldGuardHandler.protectIsland(sender, player, pi);
- return true;
- }
- }
- }
- }
- }
- return false;
- }
- public int orphanCount()
- {
- return orphaned.size();
- }
- public void removeIsland(Location loc)
- {
- if(loc != null)
- {
- Location l = loc;
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = (Settings.island_protectionRange / 2) * -1; x <= Settings.island_protectionRange / 2; x++)
- {
- for(int y = 0; y <= 255; y++)
- {
- for(int z = (Settings.island_protectionRange / 2) * -1; z <= Settings.island_protectionRange / 2; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(!b.getType().equals(Material.AIR))
- {
- if(b.getType().equals(Material.CHEST))
- {
- Chest c = (Chest)b.getState();
- ItemStack items[] = new ItemStack[c.getInventory().getContents().length];
- c.getInventory().setContents(items);
- } else
- if(b.getType().equals(Material.FURNACE))
- {
- Furnace f = (Furnace)b.getState();
- ItemStack items[] = new ItemStack[f.getInventory().getContents().length];
- f.getInventory().setContents(items);
- } else
- if(b.getType().equals(Material.DISPENSER))
- {
- Dispenser d = (Dispenser)b.getState();
- ItemStack items[] = new ItemStack[d.getInventory().getContents().length];
- d.getInventory().setContents(items);
- }
- b.setType(Material.AIR);
- }
- }
- }
- }
- }
- }
- public void removeIslandBlocks(Location loc)
- {
- if(loc != null)
- {
- System.out.print("Removing blocks from an abandoned island.");
- Location l = loc;
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -20; x <= 20; x++)
- {
- for(int y = -20; y <= 20; y++)
- {
- for(int z = -20; z <= 20; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(!b.getType().equals(Material.AIR))
- {
- if(b.getType().equals(Material.CHEST))
- {
- Chest c = (Chest)b.getState();
- ItemStack items[] = new ItemStack[c.getInventory().getContents().length];
- c.getInventory().setContents(items);
- } else
- if(b.getType().equals(Material.FURNACE))
- {
- Furnace f = (Furnace)b.getState();
- ItemStack items[] = new ItemStack[f.getInventory().getContents().length];
- f.getInventory().setContents(items);
- } else
- if(b.getType().equals(Material.DISPENSER))
- {
- Dispenser d = (Dispenser)b.getState();
- ItemStack items[] = new ItemStack[d.getInventory().getContents().length];
- d.getInventory().setContents(items);
- }
- b.setType(Material.AIR);
- }
- }
- }
- }
- }
- }
- public boolean hasParty(String playername)
- {
- if(getActivePlayers().containsKey(playername))
- return getIslandConfig(((PlayerInfo)getActivePlayers().get(playername)).locationForParty()).getInt("party.currentSize") > 1;
- PlayerInfo pi = new PlayerInfo(playername);
- if(!pi.getHasIsland())
- return false;
- return getTempIslandConfig(pi.locationForParty()).getInt("party.currentSize") > 1;
- }
- public Location getLastIsland()
- {
- if(lastIsland.getWorld().getName().equalsIgnoreCase(Settings.general_worldName))
- {
- return lastIsland;
- } else
- {
- setLastIsland(new Location(getSkyBlockWorld(), 0.0D, Settings.island_height, 0.0D));
- return new Location(getSkyBlockWorld(), 0.0D, Settings.island_height, 0.0D);
- }
- }
- public void setLastIsland(Location island)
- {
- getLastIslandConfig().set("options.general.lastIslandX", Integer.valueOf(island.getBlockX()));
- getLastIslandConfig().set("options.general.lastIslandZ", Integer.valueOf(island.getBlockZ()));
- saveLastIslandConfig();
- lastIsland = island;
- }
- public boolean hasOrphanedIsland()
- {
- return !orphaned.empty();
- }
- public Location checkOrphan()
- {
- return (Location)orphaned.peek();
- }
- public Location getOrphanedIsland()
- {
- if(hasOrphanedIsland())
- return (Location)orphaned.pop();
- else
- return null;
- }
- public void addOrphan(Location island)
- {
- orphaned.push(island);
- }
- public void removeNextOrphan()
- {
- orphaned.pop();
- }
- public void saveOrphans()
- {
- String fullOrphan = "";
- for(tempOrphaned = (Stack)orphaned.clone(); !tempOrphaned.isEmpty(); reverseOrphaned.push((Location)tempOrphaned.pop()));
- while(!reverseOrphaned.isEmpty())
- {
- Location tempLoc = (Location)reverseOrphaned.pop();
- fullOrphan = (new StringBuilder(String.valueOf(fullOrphan))).append(tempLoc.getBlockX()).append(",").append(tempLoc.getBlockZ()).append(";").toString();
- }
- getOrphans().set("orphans.list", fullOrphan);
- saveOrphansFile();
- }
- public void setupOrphans()
- {
- if(getOrphans().contains("orphans.list"))
- {
- String fullOrphan = getOrphans().getString("orphans.list");
- if(!fullOrphan.isEmpty())
- {
- String orphanArray[] = fullOrphan.split(";");
- orphaned = new Stack();
- for(int i = 0; i < orphanArray.length; i++)
- {
- String orphanXY[] = orphanArray[i].split(",");
- Location tempLoc = new Location(getSkyBlockWorld(), Integer.parseInt(orphanXY[0]), Settings.island_height, Integer.parseInt(orphanXY[1]));
- orphaned.push(tempLoc);
- }
- }
- }
- }
- public boolean homeTeleport(Player player)
- {
- Location homeSweetHome = null;
- if(getActivePlayers().containsKey(player.getName()))
- homeSweetHome = getInstance().getSafeHomeLocation((PlayerInfo)getActivePlayers().get(player.getName()));
- if(homeSweetHome == null)
- {
- player.performCommand("spawn");
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You are not part of an island. Returning you the spawn area!").toString());
- return true;
- } else
- {
- getInstance().removeCreatures(homeSweetHome);
- player.teleport(homeSweetHome);
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("Teleporting you to your island.").toString());
- return true;
- }
- }
- public boolean warpTeleport(Player player, PlayerInfo pi)
- {
- Location warpSweetWarp = null;
- if(pi == null)
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("That player does not exist!").toString());
- return true;
- }
- warpSweetWarp = getInstance().getSafeWarpLocation(pi);
- if(warpSweetWarp == null)
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("Unable to warp you to that player's island!").toString());
- return true;
- } else
- {
- player.teleport(warpSweetWarp);
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("Teleporting you to ").append(pi.getPlayerName()).append("'s island.").toString());
- return true;
- }
- }
- public boolean homeSet(Player player)
- {
- if(!player.getWorld().getName().equalsIgnoreCase(getSkyBlockWorld().getName()))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You must be closer to your island to set your skyblock home!").toString());
- return true;
- }
- if(playerIsOnIsland(player))
- {
- if(getActivePlayers().containsKey(player.getName()))
- ((PlayerInfo)getActivePlayers().get(player.getName())).setHomeLocation(player.getLocation());
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("Your skyblock home has been set to your current location.").toString());
- return true;
- } else
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You must be closer to your island to set your skyblock home!").toString());
- return true;
- }
- }
- public boolean warpSet(Player player)
- {
- if(!player.getWorld().getName().equalsIgnoreCase(getSkyBlockWorld().getName()))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You must be closer to your island to set your warp!").toString());
- return true;
- }
- if(playerIsOnIsland(player))
- {
- if(getActivePlayers().containsKey(player.getName()))
- setWarpLocation(((PlayerInfo)getActivePlayers().get(player.getName())).locationForParty(), player.getLocation());
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("Your skyblock incoming warp has been set to your current location.").toString());
- return true;
- } else
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You must be closer to your island to set your warp!").toString());
- return true;
- }
- }
- public boolean homeSet(String player, Location loc)
- {
- if(getActivePlayers().containsKey(player))
- {
- ((PlayerInfo)getActivePlayers().get(player)).setHomeLocation(loc);
- } else
- {
- PlayerInfo pi = new PlayerInfo(player);
- pi.setHomeLocation(loc);
- pi.savePlayerConfig(player);
- }
- return true;
- }
- public boolean playerIsOnIsland(Player player)
- {
- if(getActivePlayers().containsKey(player.getName()))
- {
- if(((PlayerInfo)getActivePlayers().get(player.getName())).getHasIsland())
- islandTestLocation = ((PlayerInfo)getActivePlayers().get(player.getName())).getIslandLocation();
- if(islandTestLocation == null)
- return false;
- if(player.getLocation().getX() > islandTestLocation.getX() - (double)(Settings.island_protectionRange / 2) && player.getLocation().getX() < islandTestLocation.getX() + (double)(Settings.island_protectionRange / 2) && player.getLocation().getZ() > islandTestLocation.getZ() - (double)(Settings.island_protectionRange / 2) && player.getLocation().getZ() < islandTestLocation.getZ() + (double)(Settings.island_protectionRange / 2))
- return true;
- }
- return false;
- }
- public boolean locationIsOnIsland(Player player, Location loc)
- {
- if(getActivePlayers().containsKey(player.getName()))
- {
- if(((PlayerInfo)getActivePlayers().get(player.getName())).getHasIsland())
- islandTestLocation = ((PlayerInfo)getActivePlayers().get(player.getName())).getIslandLocation();
- if(islandTestLocation == null)
- return false;
- if(loc.getX() > islandTestLocation.getX() - (double)(Settings.island_protectionRange / 2) && loc.getX() < islandTestLocation.getX() + (double)(Settings.island_protectionRange / 2) && loc.getZ() > islandTestLocation.getZ() - (double)(Settings.island_protectionRange / 2) && loc.getZ() < islandTestLocation.getZ() + (double)(Settings.island_protectionRange / 2))
- return true;
- }
- return false;
- }
- public boolean playerIsInSpawn(Player player)
- {
- return player.getLocation().getX() > (double)(Settings.general_spawnSize * -1) && player.getLocation().getX() < (double)Settings.general_spawnSize && player.getLocation().getZ() > (double)(Settings.general_spawnSize * -1) && player.getLocation().getZ() < (double)Settings.general_spawnSize;
- }
- public boolean hasIsland(String playername)
- {
- if(getActivePlayers().containsKey(playername))
- {
- return ((PlayerInfo)getActivePlayers().get(playername)).getHasIsland();
- } else
- {
- PlayerInfo pi = new PlayerInfo(playername);
- return pi.getHasIsland();
- }
- }
- public Location getPlayerIsland(String playername)
- {
- if(getActivePlayers().containsKey(playername))
- return ((PlayerInfo)getActivePlayers().get(playername)).getIslandLocation();
- PlayerInfo pi = new PlayerInfo(playername);
- if(!pi.getHasIsland())
- return null;
- else
- return pi.getIslandLocation();
- }
- public boolean islandAtLocation(Location loc)
- {
- if(loc == null)
- return true;
- int px = loc.getBlockX();
- int py = loc.getBlockY();
- int pz = loc.getBlockZ();
- for(int x = -2; x <= 2; x++)
- {
- for(int y = -50; y <= 50; y++)
- {
- for(int z = -2; z <= 2; z++)
- {
- Block b = (new Location(loc.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(b.getTypeId() != 0)
- return true;
- }
- }
- }
- return false;
- }
- public boolean islandInSpawn(Location loc)
- {
- if(loc == null)
- return true;
- return loc.getX() > -50D && loc.getX() < 50D && loc.getZ() > -50D && loc.getZ() < 50D;
- }
- public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
- {
- return new SkyBlockChunkGenerator();
- }
- public Stack changeStackToFile(Stack stack)
- {
- Stack finishStack = new Stack();
- Stack tempStack = new Stack();
- for(; !stack.isEmpty(); tempStack.push((Location)stack.pop()));
- while(!tempStack.isEmpty())
- if(tempStack.peek() != null)
- finishStack.push(new SerializableLocation((Location)tempStack.pop()));
- else
- tempStack.pop();
- return finishStack;
- }
- public Stack changestackfromfile(Stack stack)
- {
- Stack tempStack = new Stack();
- Stack finishStack = new Stack();
- for(; !stack.isEmpty(); tempStack.push((SerializableLocation)stack.pop()));
- while(!tempStack.isEmpty())
- if(tempStack.peek() != null)
- finishStack.push(((SerializableLocation)tempStack.pop()).getLocation());
- else
- tempStack.pop();
- return finishStack;
- }
- public boolean largeIsland(Location l)
- {
- int blockcount = 0;
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -30; x <= 30; x++)
- {
- for(int y = -30; y <= 30; y++)
- {
- for(int z = -30; z <= 30; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(b.getTypeId() != 0 && b.getTypeId() != 8 && b.getTypeId() != 10 && blockcount > 200)
- return true;
- }
- }
- }
- return blockcount > 200;
- }
- public boolean clearAbandoned()
- {
- int numOffline = 0;
- OfflinePlayer oplayers[] = Bukkit.getServer().getOfflinePlayers();
- System.out.print("Attemping to add more orphans");
- for(int i = 0; i < oplayers.length; i++)
- {
- long offlineTime = oplayers[i].getLastPlayed();
- offlineTime = (System.currentTimeMillis() - offlineTime) / 0x36ee80L;
- if(offlineTime > 250L && getInstance().hasIsland(oplayers[i].getName()) && offlineTime < 50000L)
- {
- PlayerInfo pi = new PlayerInfo(oplayers[i].getName());
- Location l = pi.getIslandLocation();
- int blockcount = 0;
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -30; x <= 30; x++)
- {
- for(int y = -30; y <= 30; y++)
- {
- for(int z = -30; z <= 30; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- if(b.getTypeId() != 0 && b.getTypeId() != 8 && b.getTypeId() != 10)
- blockcount++;
- }
- }
- }
- if(blockcount < 200)
- {
- numOffline++;
- WorldGuardHandler.getWorldGuard().getRegionManager(getSkyBlockWorld()).removeRegion((new StringBuilder(String.valueOf(oplayers[i].getName()))).append("Island").toString());
- orphaned.push(pi.getIslandLocation());
- pi.setHomeLocation(null);
- pi.setHasIsland(false);
- pi.setIslandLocation(null);
- pi.savePlayerConfig(pi.getPlayerName());
- }
- }
- }
- if(numOffline > 0)
- {
- System.out.print((new StringBuilder("Added ")).append(numOffline).append(" new orphans.").toString());
- saveOrphans();
- return true;
- } else
- {
- System.out.print("No new orphans to add!");
- return false;
- }
- }
- public LinkedHashMap generateTopTen()
- {
- HashMap tempMap = new LinkedHashMap();
- File folder = directoryIslands;
- File listOfFiles[] = folder.listFiles();
- for(int i = 0; i < listOfFiles.length; i++)
- if(getTempIslandConfig(listOfFiles[i].getName().replaceAll(".yml", "")) != null && getTempIslandConfig(listOfFiles[i].getName().replaceAll(".yml", "")).getInt("general.level") > 0)
- tempMap.put(getTempIslandConfig(listOfFiles[i].getName().replaceAll(".yml", "")).getString("party.leader"), Double.valueOf(getTempIslandConfig(listOfFiles[i].getName().replaceAll(".yml", "")).getInt("general.level")));
- LinkedHashMap sortedMap = sortHashMapByValuesD(tempMap);
- return sortedMap;
- }
- public LinkedHashMap sortHashMapByValuesD(HashMap passedMap)
- {
- List mapKeys = new ArrayList(passedMap.keySet());
- List mapValues = new ArrayList(passedMap.values());
- Collections.sort(mapValues);
- Collections.reverse(mapValues);
- Collections.sort(mapKeys);
- Collections.reverse(mapKeys);
- LinkedHashMap sortedMap = new LinkedHashMap();
- for(Iterator valueIt = mapValues.iterator(); valueIt.hasNext();)
- {
- Double val = (Double)valueIt.next();
- for(Iterator keyIt = mapKeys.iterator(); keyIt.hasNext();)
- {
- String key = (String)keyIt.next();
- String comp1 = ((Double)passedMap.get(key)).toString();
- String comp2 = val.toString();
- if(comp1.equals(comp2))
- {
- passedMap.remove(key);
- mapKeys.remove(key);
- sortedMap.put(key, val);
- break;
- }
- }
- }
- return sortedMap;
- }
- public boolean onInfoCooldown(Player player)
- {
- if(infoCooldown.containsKey(player.getName()))
- return ((Long)infoCooldown.get(player.getName())).longValue() > Calendar.getInstance().getTimeInMillis();
- else
- return false;
- }
- public boolean onBiomeCooldown(Player player)
- {
- if(biomeCooldown.containsKey(player.getName()))
- return ((Long)biomeCooldown.get(player.getName())).longValue() > Calendar.getInstance().getTimeInMillis();
- else
- return false;
- }
- public boolean onRestartCooldown(Player player)
- {
- if(restartCooldown.containsKey(player.getName()))
- return ((Long)restartCooldown.get(player.getName())).longValue() > Calendar.getInstance().getTimeInMillis();
- else
- return false;
- }
- public long getInfoCooldownTime(Player player)
- {
- if(infoCooldown.containsKey(player.getName()))
- {
- if(((Long)infoCooldown.get(player.getName())).longValue() > Calendar.getInstance().getTimeInMillis())
- return ((Long)infoCooldown.get(player.getName())).longValue() - Calendar.getInstance().getTimeInMillis();
- else
- return 0L;
- } else
- {
- return 0L;
- }
- }
- public long getBiomeCooldownTime(Player player)
- {
- if(biomeCooldown.containsKey(player.getName()))
- {
- if(((Long)biomeCooldown.get(player.getName())).longValue() > Calendar.getInstance().getTimeInMillis())
- return ((Long)biomeCooldown.get(player.getName())).longValue() - Calendar.getInstance().getTimeInMillis();
- else
- return 0L;
- } else
- {
- return 0L;
- }
- }
- public long getRestartCooldownTime(Player player)
- {
- if(restartCooldown.containsKey(player.getName()))
- {
- if(((Long)restartCooldown.get(player.getName())).longValue() > Calendar.getInstance().getTimeInMillis())
- return ((Long)restartCooldown.get(player.getName())).longValue() - Calendar.getInstance().getTimeInMillis();
- else
- return 0L;
- } else
- {
- return 0L;
- }
- }
- public void setInfoCooldown(Player player)
- {
- infoCooldown.put(player.getName(), Long.valueOf(Calendar.getInstance().getTimeInMillis() + (long)(Settings.general_cooldownInfo * 1000)));
- }
- public void setBiomeCooldown(Player player)
- {
- biomeCooldown.put(player.getName(), Long.valueOf(Calendar.getInstance().getTimeInMillis() + (long)(Settings.general_biomeChange * 1000)));
- }
- public void setRestartCooldown(Player player)
- {
- restartCooldown.put(player.getName(), Long.valueOf(Calendar.getInstance().getTimeInMillis() + (long)(Settings.general_cooldownRestart * 1000)));
- }
- public File[] getSchemFile()
- {
- return schemFile;
- }
- public boolean testForObsidian(Block block)
- {
- for(int x = -3; x <= 3; x++)
- {
- for(int y = -3; y <= 3; y++)
- {
- for(int z = -3; z <= 3; z++)
- {
- Block testBlock = getSkyBlockWorld().getBlockAt(block.getX() + x, block.getY() + y, block.getZ() + z);
- if((x != 0 || y != 0 || z != 0) && testBlock.getType() == Material.OBSIDIAN)
- return true;
- }
- }
- }
- return false;
- }
- public void removeInactive(List removePlayerList)
- {
- getInstance().getServer().getScheduler().scheduleSyncRepeatingTask(getInstance(), new Runnable() {
- public void run()
- {
- if(uSkyBlock.getInstance().getRemoveList().size() > 0 && !uSkyBlock.getInstance().isPurgeActive())
- {
- uSkyBlock.getInstance().deletePlayerIsland((String)uSkyBlock.getInstance().getRemoveList().get(0));
- System.out.print((new StringBuilder("[uSkyBlock] Purge: Removing ")).append((String)uSkyBlock.getInstance().getRemoveList().get(0)).append("'s island").toString());
- uSkyBlock.getInstance().deleteFromRemoveList();
- }
- }
- final uSkyBlock this$0;
- {
- this$0 = uSkyBlock.this;
- super();
- }
- }
- , 0L, 200L);
- }
- public List getRemoveList()
- {
- return removeList;
- }
- public void addToRemoveList(String string)
- {
- removeList.add(string);
- }
- public void deleteFromRemoveList()
- {
- removeList.remove(0);
- }
- public boolean isPurgeActive()
- {
- return purgeActive;
- }
- public void activatePurge()
- {
- purgeActive = true;
- }
- public void deactivatePurge()
- {
- purgeActive = false;
- }
- public HashMap getActivePlayers()
- {
- return activePlayers;
- }
- public void addActivePlayer(String player, PlayerInfo pi)
- {
- activePlayers.put(player, pi);
- }
- public void removeActivePlayer(String player)
- {
- if(activePlayers.containsKey(player))
- {
- ((PlayerInfo)activePlayers.get(player)).savePlayerConfig(player);
- activePlayers.remove(player);
- System.out.print((new StringBuilder("Removing player from memory: ")).append(player).toString());
- }
- }
- public void populateChallengeList()
- {
- List templist = new ArrayList();
- for(int i = 0; i < Settings.challenges_ranks.length; i++)
- {
- challenges.put(Settings.challenges_ranks[i], templist);
- templist = new ArrayList();
- }
- for(Iterator itr = Settings.challenges_challengeList.iterator(); itr.hasNext();)
- {
- String tempString = (String)itr.next();
- if(challenges.containsKey(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(tempString).append(".rankLevel").toString())))
- ((List)challenges.get(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(tempString).append(".rankLevel").toString()))).add(tempString);
- }
- }
- public String getChallengesFromRank(Player player, String rank)
- {
- rankDisplay = (List)challenges.get(rank);
- String fullString = "";
- PlayerInfo pi = (PlayerInfo)getActivePlayers().get(player.getName());
- for(Iterator itr = rankDisplay.iterator(); itr.hasNext();)
- {
- String tempString = (String)itr.next();
- if(pi.checkChallenge(tempString) > 0)
- {
- if(getConfig().getBoolean((new StringBuilder("options.challenges.challengeList.")).append(tempString).append(".repeatable").toString()))
- fullString = (new StringBuilder(String.valueOf(fullString))).append(Settings.challenges_repeatableColor.replace('&', '\247')).append(tempString).append(ChatColor.DARK_GRAY).append(" - ").toString();
- else
- fullString = (new StringBuilder(String.valueOf(fullString))).append(Settings.challenges_finishedColor.replace('&', '\247')).append(tempString).append(ChatColor.DARK_GRAY).append(" - ").toString();
- } else
- {
- fullString = (new StringBuilder(String.valueOf(fullString))).append(Settings.challenges_challengeColor.replace('&', '\247')).append(tempString).append(ChatColor.DARK_GRAY).append(" - ").toString();
- }
- }
- if(fullString.length() > 4)
- fullString = fullString.substring(0, fullString.length() - 3);
- return fullString;
- }
- public int checkRankCompletion(Player player, String rank)
- {
- if(!Settings.challenges_requirePreviousRank)
- return 0;
- rankDisplay = (List)challenges.get(rank);
- int ranksCompleted = 0;
- PlayerInfo pi = (PlayerInfo)getActivePlayers().get(player.getName());
- for(Iterator itr = rankDisplay.iterator(); itr.hasNext();)
- {
- String tempString = (String)itr.next();
- if(pi.checkChallenge(tempString) > 0)
- ranksCompleted++;
- }
- return rankDisplay.size() - Settings.challenges_rankLeeway - ranksCompleted;
- }
- public boolean isRankAvailable(Player player, String rank)
- {
- if(challenges.size() < 2)
- return true;
- for(int i = 0; i < Settings.challenges_ranks.length; i++)
- if(Settings.challenges_ranks[i].equalsIgnoreCase(rank))
- {
- if(i == 0)
- return true;
- if(checkRankCompletion(player, Settings.challenges_ranks[i - 1]) <= 0)
- return true;
- }
- return false;
- }
- public boolean checkIfCanCompleteChallenge(Player player, String challenge)
- {
- PlayerInfo pi = (PlayerInfo)getActivePlayers().get(player.getName());
- if(!isRankAvailable(player, getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".rankLevel").toString())))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You have not unlocked this challenge yet!").toString());
- return false;
- }
- if(!pi.challengeExists(challenge))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("Unknown challenge name (check spelling)!").toString());
- return false;
- }
- if(pi.checkChallenge(challenge) > 0 && !getConfig().getBoolean((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatable").toString()))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("This challenge is not repeatable!").toString());
- return false;
- }
- if(pi.checkChallenge(challenge) > 0 && (getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".type").toString()).equalsIgnoreCase("onIsland") || getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".type").toString()).equalsIgnoreCase("onIsland")))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("This challenge is not repeatable!").toString());
- return false;
- }
- if(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".type").toString()).equalsIgnoreCase("onPlayer"))
- if(!hasRequired(player, challenge, "onPlayer"))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".description").toString())).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You don't have enough of the required item(s)!").toString());
- return false;
- } else
- {
- return true;
- }
- if(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".type").toString()).equalsIgnoreCase("onIsland"))
- {
- if(!playerIsOnIsland(player))
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You must be on your island to do that!").toString());
- if(!hasRequired(player, challenge, "onIsland"))
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".description").toString())).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("You must be standing within 10 blocks of all required items.").toString());
- return false;
- } else
- {
- return true;
- }
- }
- if(getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".type").toString()).equalsIgnoreCase("islandLevel"))
- {
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("general.level") >= getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".requiredItems").toString()))
- {
- return true;
- } else
- {
- player.sendMessage((new StringBuilder()).append(ChatColor.RED).append("Your island must be level ").append(getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".requiredItems").toString())).append(" to complete this challenge!").toString());
- return false;
- }
- } else
- {
- return false;
- }
- }
- public boolean takeRequired(Player player, String challenge, String type)
- {
- if(type.equalsIgnoreCase("onPlayer"))
- {
- String reqList[] = getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".requiredItems").toString()).split(" ");
- int reqItem = 0;
- int reqAmount = 0;
- int reqMod = -1;
- String as[];
- int j = (as = reqList).length;
- for(int i = 0; i < j; i++)
- {
- String s = as[i];
- String sPart[] = s.split(":");
- if(sPart.length == 2)
- {
- reqItem = Integer.parseInt(sPart[0]);
- String sScale[] = sPart[1].split(";");
- if(sScale.length == 1)
- reqAmount = Integer.parseInt(sPart[1]);
- else
- if(sScale.length == 2)
- if(sScale[1].charAt(0) == '+')
- reqAmount = Integer.parseInt(sScale[0]) + Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '*')
- reqAmount = Integer.parseInt(sScale[0]) * (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- else
- if(sScale[1].charAt(0) == '-')
- reqAmount = Integer.parseInt(sScale[0]) - Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '/')
- reqAmount = Integer.parseInt(sScale[0]) / (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- if(!player.getInventory().contains(reqItem, reqAmount))
- return false;
- player.getInventory().removeItem(new ItemStack[] {
- new ItemStack(reqItem, reqAmount)
- });
- } else
- if(sPart.length == 3)
- {
- reqItem = Integer.parseInt(sPart[0]);
- String sScale[] = sPart[2].split(";");
- if(sScale.length == 1)
- reqAmount = Integer.parseInt(sPart[2]);
- else
- if(sScale.length == 2)
- if(sScale[1].charAt(0) == '+')
- reqAmount = Integer.parseInt(sScale[0]) + Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '*')
- reqAmount = Integer.parseInt(sScale[0]) * (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- else
- if(sScale[1].charAt(0) == '-')
- reqAmount = Integer.parseInt(sScale[0]) - Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '/')
- reqAmount = Integer.parseInt(sScale[0]) / (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- reqMod = Integer.parseInt(sPart[1]);
- if(!player.getInventory().containsAtLeast(new ItemStack(reqItem, reqAmount, (short)reqMod), reqAmount))
- return false;
- player.getInventory().removeItem(new ItemStack[] {
- new ItemStack(reqItem, reqAmount, (short)reqMod)
- });
- }
- }
- return true;
- }
- if(type.equalsIgnoreCase("onIsland"))
- return true;
- return type.equalsIgnoreCase("islandLevel");
- }
- public boolean hasRequired(Player player, String challenge, String type)
- {
- String reqList[] = getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".requiredItems").toString()).split(" ");
- if(type.equalsIgnoreCase("onPlayer"))
- {
- int reqItem = 0;
- int reqAmount = 0;
- int reqMod = -1;
- String as[];
- int k = (as = reqList).length;
- for(int j = 0; j < k; j++)
- {
- String s = as[j];
- String sPart[] = s.split(":");
- if(sPart.length == 2)
- {
- reqItem = Integer.parseInt(sPart[0]);
- String sScale[] = sPart[1].split(";");
- if(sScale.length == 1)
- reqAmount = Integer.parseInt(sPart[1]);
- else
- if(sScale.length == 2)
- if(sScale[1].charAt(0) == '+')
- reqAmount = Integer.parseInt(sScale[0]) + Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '*')
- reqAmount = Integer.parseInt(sScale[0]) * (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- else
- if(sScale[1].charAt(0) == '-')
- reqAmount = Integer.parseInt(sScale[0]) - Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '/')
- reqAmount = Integer.parseInt(sScale[0]) / (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- if(!player.getInventory().containsAtLeast(new ItemStack(reqItem, reqAmount, (short)0), reqAmount))
- return false;
- } else
- if(sPart.length == 3)
- {
- reqItem = Integer.parseInt(sPart[0]);
- String sScale[] = sPart[2].split(";");
- if(sScale.length == 1)
- reqAmount = Integer.parseInt(sPart[2]);
- else
- if(sScale.length == 2)
- if(sScale[1].charAt(0) == '+')
- reqAmount = Integer.parseInt(sScale[0]) + Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '*')
- reqAmount = Integer.parseInt(sScale[0]) * (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- else
- if(sScale[1].charAt(0) == '-')
- reqAmount = Integer.parseInt(sScale[0]) - Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge);
- else
- if(sScale[1].charAt(0) == '/')
- reqAmount = Integer.parseInt(sScale[0]) / (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challenge));
- reqMod = Integer.parseInt(sPart[1]);
- if(!player.getInventory().containsAtLeast(new ItemStack(reqItem, reqAmount, (short)reqMod), reqAmount))
- return false;
- }
- }
- if(getConfig().getBoolean((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".takeItems").toString()))
- takeRequired(player, challenge, type);
- return true;
- }
- if(type.equalsIgnoreCase("onIsland"))
- {
- int neededItem[][] = new int[reqList.length][2];
- for(int i = 0; i < reqList.length; i++)
- {
- String sPart[] = reqList[i].split(":");
- neededItem[i][0] = Integer.parseInt(sPart[0]);
- neededItem[i][1] = Integer.parseInt(sPart[1]);
- }
- Location l = player.getLocation();
- int px = l.getBlockX();
- int py = l.getBlockY();
- int pz = l.getBlockZ();
- for(int x = -10; x <= 10; x++)
- {
- for(int y = -3; y <= 10; y++)
- {
- for(int z = -10; z <= 10; z++)
- {
- Block b = (new Location(l.getWorld(), px + x, py + y, pz + z)).getBlock();
- for(int i = 0; i < neededItem.length; i++)
- if(b.getTypeId() == neededItem[i][0])
- neededItem[i][1]--;
- }
- }
- }
- for(int i = 0; i < neededItem.length; i++)
- if(neededItem[i][1] > 0)
- return false;
- return true;
- } else
- {
- return true;
- }
- }
- public boolean giveReward(Player player, String challenge)
- {
- String permList[] = getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge.toLowerCase()).append(".permissionReward").toString()).split(" ");
- double rewCurrency = 0.0D;
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append("You have completed the ").append(challenge).append(" challenge!").toString());
- String rewList[];
- if(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallenge(challenge) == 0)
- {
- rewList = getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge.toLowerCase()).append(".itemReward").toString()).split(" ");
- if(Settings.challenges_enableEconomyPlugin && VaultHandler.econ != null)
- rewCurrency = getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge.toLowerCase()).append(".currencyReward").toString());
- } else
- {
- rewList = getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge.toLowerCase()).append(".repeatItemReward").toString()).split(" ");
- if(Settings.challenges_enableEconomyPlugin && VaultHandler.econ != null)
- rewCurrency = getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge.toLowerCase()).append(".repeatCurrencyReward").toString());
- }
- int rewItem = 0;
- int rewAmount = 0;
- double rewBonus = 1.0D;
- int rewMod = -1;
- if(Settings.challenges_enableEconomyPlugin && VaultHandler.econ != null)
- {
- if(VaultHandler.checkPerk(player.getName(), "group.memberplus", getSkyBlockWorld()))
- rewBonus += 0.050000000000000003D;
- if(VaultHandler.checkPerk(player.getName(), "usb.donor.all", getSkyBlockWorld()))
- rewBonus += 0.050000000000000003D;
- if(VaultHandler.checkPerk(player.getName(), "usb.donor.25", getSkyBlockWorld()))
- rewBonus += 0.050000000000000003D;
- if(VaultHandler.checkPerk(player.getName(), "usb.donor.50", getSkyBlockWorld()))
- rewBonus += 0.050000000000000003D;
- if(VaultHandler.checkPerk(player.getName(), "usb.donor.75", getSkyBlockWorld()))
- rewBonus += 0.10000000000000001D;
- if(VaultHandler.checkPerk(player.getName(), "usb.donor.100", getSkyBlockWorld()))
- rewBonus += 0.20000000000000001D;
- VaultHandler.econ.depositPlayer(player.getName(), rewCurrency * rewBonus);
- if(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallenge(challenge) > 0)
- {
- player.giveExp(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatXpReward").toString()));
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Repeat reward(s): ").append(ChatColor.WHITE).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatRewardText").toString()).replace('&', '\247')).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Repeat exp reward: ").append(ChatColor.WHITE).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatXpReward").toString())).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Repeat currency reward: ").append(ChatColor.WHITE).append(df.format((double)getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatCurrencyReward").toString()) * rewBonus)).append(" ").append(VaultHandler.econ.currencyNamePlural()).append("\247a(+").append(df.format((rewBonus - 1.0D) * 100D)).append("%)").toString());
- } else
- {
- if(Settings.challenges_broadcastCompletion)
- Bukkit.getServer().broadcastMessage((new StringBuilder(String.valueOf(Settings.challenges_broadcastText.replace('&', '\247')))).append(player.getName()).append(" has completed the ").append(challenge).append(" challenge!").toString());
- player.giveExp(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".xpReward").toString()));
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Reward(s): ").append(ChatColor.WHITE).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".rewardText").toString()).replace('&', '\247')).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Exp reward: ").append(ChatColor.WHITE).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".xpReward").toString())).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Currency reward: ").append(ChatColor.WHITE).append(df.format((double)getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".currencyReward").toString()) * rewBonus)).append(" ").append(VaultHandler.econ.currencyNamePlural()).append("\247a(+").append(df.format((rewBonus - 1.0D) * 100D)).append("%)").toString());
- }
- } else
- if(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallenge(challenge) > 0)
- {
- player.giveExp(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatXpReward").toString()));
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Repeat reward(s): ").append(ChatColor.WHITE).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatRewardText").toString()).replace('&', '\247')).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Repeat exp reward: ").append(ChatColor.WHITE).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".repeatXpReward").toString())).toString());
- } else
- {
- if(Settings.challenges_broadcastCompletion)
- Bukkit.getServer().broadcastMessage((new StringBuilder(String.valueOf(Settings.challenges_broadcastText.replace('&', '\247')))).append(player.getName()).append(" has completed the ").append(challenge).append(" challenge!").toString());
- player.giveExp(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".xpReward").toString()));
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Reward(s): ").append(ChatColor.WHITE).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".rewardText").toString()).replace('&', '\247')).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Exp reward: ").append(ChatColor.WHITE).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challenge).append(".xpReward").toString())).toString());
- }
- String as[];
- int k = (as = permList).length;
- for(int i = 0; i < k; i++)
- {
- String s = as[i];
- if(!s.equalsIgnoreCase("none") && !VaultHandler.checkPerk(player.getName(), s, player.getWorld()))
- VaultHandler.addPerk(player, s);
- }
- k = (as = rewList).length;
- for(int j = 0; j < k; j++)
- {
- String s = as[j];
- String sPart[] = s.split(":");
- if(sPart.length == 2)
- {
- rewItem = Integer.parseInt(sPart[0]);
- rewAmount = Integer.parseInt(sPart[1]);
- player.getInventory().addItem(new ItemStack[] {
- new ItemStack(rewItem, rewAmount)
- });
- } else
- if(sPart.length == 3)
- {
- rewItem = Integer.parseInt(sPart[0]);
- rewAmount = Integer.parseInt(sPart[2]);
- rewMod = Integer.parseInt(sPart[1]);
- player.getInventory().addItem(new ItemStack[] {
- new ItemStack(rewItem, rewAmount, (short)rewMod)
- });
- }
- }
- ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).completeChallenge(challenge);
- return true;
- }
- public void reloadData()
- {
- if(skyblockDataFile == null)
- skyblockDataFile = new File(getDataFolder(), "skyblockData.yml");
- skyblockData = YamlConfiguration.loadConfiguration(skyblockDataFile);
- InputStream defConfigStream = getResource("skyblockData.yml");
- if(defConfigStream != null)
- {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- skyblockData.setDefaults(defConfig);
- }
- }
- public FileConfiguration getData()
- {
- if(skyblockData == null)
- reloadData();
- return skyblockData;
- }
- double dReturns(double val, double scale)
- {
- if(val < 0.0D)
- {
- return -dReturns(-val, scale);
- } else
- {
- double mult = val / scale;
- double trinum = (Math.sqrt(8D * mult + 1.0D) - 1.0D) / 2D;
- return trinum * scale;
- }
- }
- public void reloadLevelConfig()
- {
- if(levelConfigFile == null)
- levelConfigFile = new File(getDataFolder(), "levelConfig.yml");
- levelConfig = YamlConfiguration.loadConfiguration(levelConfigFile);
- InputStream defConfigStream = getResource("levelConfig.yml");
- if(defConfigStream != null)
- {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- levelConfig.setDefaults(defConfig);
- }
- }
- public FileConfiguration getLevelConfig()
- {
- if(levelConfig == null)
- reloadLevelConfig();
- return levelConfig;
- }
- public void saveLevelConfig()
- {
- if(levelConfig == null || levelConfigFile == null)
- return;
- try
- {
- getLevelConfig().save(levelConfigFile);
- }
- catch(IOException ex)
- {
- getLogger().log(Level.SEVERE, (new StringBuilder("Could not save config to ")).append(levelConfigFile).toString(), ex);
- }
- }
- public void saveDefaultLevelConfig()
- {
- if(levelConfigFile == null)
- levelConfigFile = new File(getDataFolder(), "levelConfig.yml");
- if(!levelConfigFile.exists())
- getInstance().saveResource("levelConfig.yml", false);
- }
- public void loadLevelConfig()
- {
- try
- {
- getLevelConfig();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- for(int i = 1; i <= 255; i++)
- {
- if(getLevelConfig().contains((new StringBuilder("blockValues.")).append(i).toString()))
- Settings.blockList[i] = getLevelConfig().getInt((new StringBuilder("blockValues.")).append(i).toString());
- else
- Settings.blockList[i] = getLevelConfig().getInt("general.default");
- if(getLevelConfig().contains((new StringBuilder("blockLimits.")).append(i).toString()))
- Settings.limitList[i] = getLevelConfig().getInt((new StringBuilder("blockLimits.")).append(i).toString());
- else
- Settings.limitList[i] = -1;
- if(getLevelConfig().contains((new StringBuilder("diminishingReturns.")).append(i).toString()))
- Settings.diminishingReturnsList[i] = getLevelConfig().getInt((new StringBuilder("diminishingReturns.")).append(i).toString());
- else
- if(getLevelConfig().getBoolean("general.useDiminishingReturns"))
- Settings.diminishingReturnsList[i] = getLevelConfig().getInt("general.defaultScale");
- else
- Settings.diminishingReturnsList[i] = -1;
- }
- System.out.print(Settings.blockList[57]);
- System.out.print(Settings.diminishingReturnsList[57]);
- System.out.print(Settings.limitList[57]);
- }
- public void clearIslandConfig(String location, String leader)
- {
- getIslandConfig(location).set("general.level", Integer.valueOf(0));
- getIslandConfig(location).set("general.warpLocationX", Integer.valueOf(0));
- getIslandConfig(location).set("general.warpLocationY", Integer.valueOf(0));
- getIslandConfig(location).set("general.warpLocationZ", Integer.valueOf(0));
- getIslandConfig(location).set("general.warpActive", Boolean.valueOf(false));
- getIslandConfig(location).set("log.logPos", Integer.valueOf(1));
- getIslandConfig(location).set("log.1", "\247d[skyblock] The island has been created.");
- setupPartyLeader(location, leader);
- }
- public void setupPartyLeader(String location, String leader)
- {
- getIslandConfig(location).createSection((new StringBuilder("party.members.")).append(leader).toString());
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(leader).toString()), "canChangeBiome");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(leader).toString()), "canToggleLock");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(leader).toString()), "canChangeWarp");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(leader).toString()), "canToggleWarp");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(leader).toString()), "canInviteOthers");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(leader).toString()), "canKickOthers");
- getIslandConfig(location).set("party.leader", leader);
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(leader).append(".canChangeBiome").toString(), Boolean.valueOf(true));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(leader).append(".canToggleLock").toString(), Boolean.valueOf(true));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(leader).append(".canChangeWarp").toString(), Boolean.valueOf(true));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(leader).append(".canToggleWarp").toString(), Boolean.valueOf(true));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(leader).append(".canInviteOthers").toString(), Boolean.valueOf(true));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(leader).append(".canKickOthers").toString(), Boolean.valueOf(true));
- saveIslandConfig(location);
- }
- public void setupPartyMember(String location, String member)
- {
- getIslandConfig(location).createSection((new StringBuilder("party.members.")).append(member).toString());
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(member).toString()), "canChangeBiome");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(member).toString()), "canToggleLock");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(member).toString()), "canChangeWarp");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(member).toString()), "canToggleWarp");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(member).toString()), "canInviteOthers");
- getIslandConfig(location);
- FileConfiguration.createPath(getIslandConfig(location).getConfigurationSection((new StringBuilder("party.members.")).append(member).toString()), "canKickOthers");
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canChangeBiome").toString(), Boolean.valueOf(false));
- getIslandConfig(location).set("party.currentSize", Integer.valueOf(getIslandConfig(location).getInt("party.currentSize") + 1));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canToggleLock").toString(), Boolean.valueOf(false));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canChangeWarp").toString(), Boolean.valueOf(false));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canToggleWarp").toString(), Boolean.valueOf(false));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canInviteOthers").toString(), Boolean.valueOf(false));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canKickOthers").toString(), Boolean.valueOf(false));
- getIslandConfig(location).set((new StringBuilder("party.members.")).append(member).append(".canBanOthers").toString(), Boolean.valueOf(false));
- saveIslandConfig(location);
- }
- public void reloadIslandConfig(String location)
- {
- islandConfigFile = new File(directoryIslands, (new StringBuilder(String.valueOf(location))).append(".yml").toString());
- islands.put(location, YamlConfiguration.loadConfiguration(islandConfigFile));
- InputStream defConfigStream = getResource("island.yml");
- if(defConfigStream != null)
- {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- ((FileConfiguration)islands.get(location)).setDefaults(defConfig);
- }
- saveIslandConfig(location);
- }
- public FileConfiguration getTempIslandConfig(String location)
- {
- tempIslandFile = new File(directoryIslands, (new StringBuilder(String.valueOf(location))).append(".yml").toString());
- tempIsland = YamlConfiguration.loadConfiguration(tempIslandFile);
- return tempIsland;
- }
- public FileConfiguration getCurrentPlayerConfig(String player)
- {
- tempPlayerFile = new File(directoryPlayers, (new StringBuilder(String.valueOf(player))).append(".yml").toString());
- tempPlayer = YamlConfiguration.loadConfiguration(tempPlayerFile);
- return tempPlayer;
- }
- public void createIslandConfig(String location, String leader)
- {
- saveDefaultIslandsConfig(location);
- islandConfigFile = new File(directoryIslands, (new StringBuilder(String.valueOf(location))).append(".yml").toString());
- InputStream defConfigStream = getResource("island.yml");
- if(defConfigStream != null)
- {
- islands.put(location, YamlConfiguration.loadConfiguration(defConfigStream));
- getIslandConfig(location);
- setupPartyLeader(location, leader);
- }
- }
- public FileConfiguration getIslandConfig(String location)
- {
- if(islands.get(location) == null)
- reloadIslandConfig(location);
- return (FileConfiguration)islands.get(location);
- }
- public void saveIslandConfig(String location)
- {
- if(islands.get(location) == null)
- return;
- try
- {
- islandConfigFile = new File(directoryIslands, (new StringBuilder(String.valueOf(location))).append(".yml").toString());
- getIslandConfig(location).save(islandConfigFile);
- }
- catch(IOException ex)
- {
- getLogger().log(Level.SEVERE, (new StringBuilder("Could not save config to ")).append(islandConfigFile).toString(), ex);
- }
- }
- public void deleteIslandConfig(String location)
- {
- islandConfigFile = new File(directoryIslands, (new StringBuilder(String.valueOf(location))).append(".yml").toString());
- islandConfigFile.delete();
- }
- public void saveDefaultIslandsConfig(String location)
- {
- try
- {
- if(islandConfigFile == null)
- {
- islandConfigFile = new File(directoryIslands, (new StringBuilder(String.valueOf(location))).append(".yml").toString());
- getIslandConfig(location).save(islandConfigFile);
- }
- }
- catch(IOException ex)
- {
- getLogger().log(Level.SEVERE, (new StringBuilder("Could not save config to ")).append(islandConfigFile).toString(), ex);
- }
- }
- public void reloadLastIslandConfig()
- {
- if(lastIslandConfigFile == null)
- lastIslandConfigFile = new File(getDataFolder(), "lastIslandConfig.yml");
- lastIslandConfig = YamlConfiguration.loadConfiguration(lastIslandConfigFile);
- InputStream defConfigStream = getResource("lastIslandConfig.yml");
- if(defConfigStream != null)
- {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- lastIslandConfig.setDefaults(defConfig);
- }
- }
- public FileConfiguration getLastIslandConfig()
- {
- if(lastIslandConfig == null)
- reloadLastIslandConfig();
- return lastIslandConfig;
- }
- public void saveLastIslandConfig()
- {
- if(lastIslandConfig == null || lastIslandConfigFile == null)
- return;
- try
- {
- getLastIslandConfig().save(lastIslandConfigFile);
- }
- catch(IOException ex)
- {
- getLogger().log(Level.SEVERE, (new StringBuilder("Could not save config to ")).append(lastIslandConfigFile).toString(), ex);
- }
- }
- public void saveDefaultLastIslandConfig()
- {
- if(lastIslandConfigFile == null)
- lastIslandConfigFile = new File(getDataFolder(), "lastIslandConfig.yml");
- if(!lastIslandConfigFile.exists())
- getInstance().saveResource("lastIslandConfig.yml", false);
- }
- public void reloadOrphans()
- {
- if(orphanFile == null)
- orphanFile = new File(getDataFolder(), "orphans.yml");
- orphans = YamlConfiguration.loadConfiguration(orphanFile);
- InputStream defConfigStream = getResource("orphans.yml");
- if(defConfigStream != null)
- {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- orphans.setDefaults(defConfig);
- }
- }
- public FileConfiguration getOrphans()
- {
- if(orphans == null)
- reloadOrphans();
- return orphans;
- }
- public void saveOrphansFile()
- {
- if(orphans == null || orphanFile == null)
- return;
- try
- {
- getOrphans().save(orphanFile);
- }
- catch(IOException ex)
- {
- getLogger().log(Level.SEVERE, (new StringBuilder("Could not save config to ")).append(orphanFile).toString(), ex);
- }
- }
- public void saveDefaultOrphans()
- {
- if(orphanFile == null)
- orphanFile = new File(getDataFolder(), "orphans.yml");
- if(!orphanFile.exists())
- getInstance().saveResource("orphans.yml", false);
- }
- public boolean setBiome(Location loc, String bName)
- {
- int px = loc.getBlockX();
- int pz = loc.getBlockZ();
- Biome bType = Biome.OCEAN;
- if(bName.equalsIgnoreCase("jungle"))
- bType = Biome.JUNGLE;
- else
- if(bName.equalsIgnoreCase("hell"))
- bType = Biome.HELL;
- else
- if(bName.equalsIgnoreCase("sky"))
- bType = Biome.SKY;
- else
- if(bName.equalsIgnoreCase("mushroom"))
- bType = Biome.MUSHROOM_ISLAND;
- else
- if(bName.equalsIgnoreCase("ocean"))
- bType = Biome.OCEAN;
- else
- if(bName.equalsIgnoreCase("swampland"))
- bType = Biome.SWAMPLAND;
- else
- if(bName.equalsIgnoreCase("taiga"))
- bType = Biome.TAIGA;
- else
- if(bName.equalsIgnoreCase("desert"))
- bType = Biome.DESERT;
- else
- if(bName.equalsIgnoreCase("forest"))
- bType = Biome.FOREST;
- else
- bType = Biome.OCEAN;
- for(int x = (Settings.island_protectionRange / 2) * -1 - 16; x <= Settings.island_protectionRange / 2 + 16; x += 16)
- {
- for(int z = (Settings.island_protectionRange / 2) * -1 - 16; z <= Settings.island_protectionRange / 2 + 16; z += 16)
- getSkyBlockWorld().loadChunk((px + x) / 16, (pz + z) / 16);
- }
- for(int x = (Settings.island_protectionRange / 2) * -1; x <= Settings.island_protectionRange / 2; x++)
- {
- for(int z = (Settings.island_protectionRange / 2) * -1; z <= Settings.island_protectionRange / 2; z++)
- getSkyBlockWorld().setBiome(px + x, pz + z, bType);
- }
- for(int x = (Settings.island_protectionRange / 2) * -1 - 16; x <= Settings.island_protectionRange / 2 + 16; x += 16)
- {
- for(int z = (Settings.island_protectionRange / 2) * -1 - 16; z <= Settings.island_protectionRange / 2 + 16; z += 16)
- getSkyBlockWorld().refreshChunk((px + x) / 16, (pz + z) / 16);
- }
- return bType != Biome.OCEAN;
- }
- public boolean changePlayerBiome(Player player, String bName)
- {
- if(VaultHandler.checkPerk(player.getName(), (new StringBuilder("usb.biome.")).append(bName).toString(), player.getWorld()))
- {
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(player.getName()).append(".canChangeBiome").toString()))
- {
- setBiome(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).getIslandLocation(), bName);
- setConfigBiome(player, bName);
- return true;
- } else
- {
- return false;
- }
- } else
- {
- return false;
- }
- }
- public void listBiomes(Player player)
- {
- String biomeList = ", ";
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.ocean", getSkyBlockWorld()))
- biomeList = "OCEAN, ";
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.forest", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("FOREST, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.jungle", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("JUNGLE, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.desert", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("DESERT, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.taiga", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("TAIGA, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.swampland", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("SWAMPLAND, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.mushroom", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("MUSHROOM, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.hell", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("HELL, ").toString();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.sky", getSkyBlockWorld()))
- biomeList = (new StringBuilder(String.valueOf(biomeList))).append("SKY, ").toString();
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("You have access to the following Biomes:").toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.GREEN).append(biomeList.substring(0, biomeList.length() - 2)).toString());
- player.sendMessage((new StringBuilder()).append(ChatColor.YELLOW).append("Use /island biome <biomename> to change your biome. You must wait ").append(Settings.general_biomeChange / 60).append(" minutes between each biome change.").toString());
- }
- public boolean createIsland(CommandSender sender, PlayerInfo pi)
- {
- System.out.println("Creating player island...");
- Player player = (Player)sender;
- Location last = getInstance().getLastIsland();
- last.setY(Settings.island_height);
- try
- {
- for(; getInstance().hasOrphanedIsland() && getInstance().islandAtLocation(getInstance().checkOrphan()); getInstance().removeNextOrphan());
- for(; getInstance().hasOrphanedIsland() && !getInstance().checkOrphan().getWorld().getName().equalsIgnoreCase(Settings.general_worldName); getInstance().removeNextOrphan());
- Location next;
- if(getInstance().hasOrphanedIsland() && !getInstance().islandAtLocation(getInstance().checkOrphan()))
- {
- next = getInstance().getOrphanedIsland();
- getInstance().saveOrphans();
- } else
- {
- next = nextIslandLocation(last);
- getInstance().setLastIsland(next);
- for(; getInstance().islandAtLocation(next); next = nextIslandLocation(next));
- for(; getInstance().islandInSpawn(next); next = nextIslandLocation(next));
- getInstance().setLastIsland(next);
- }
- boolean hasIslandNow = false;
- if(getInstance().getSchemFile().length > 0 && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldEdit"))
- {
- String cSchem = "";
- for(int i = 0; i < getInstance().getSchemFile().length; i++)
- if(!hasIslandNow)
- {
- if(getInstance().getSchemFile()[i].getName().lastIndexOf('.') > 0)
- cSchem = getInstance().getSchemFile()[i].getName().substring(0, getInstance().getSchemFile()[i].getName().lastIndexOf('.'));
- else
- cSchem = getInstance().getSchemFile()[i].getName();
- if(VaultHandler.checkPerk(player.getName(), (new StringBuilder("usb.schematic.")).append(cSchem).toString(), getSkyBlockWorld()) && WorldEditHandler.loadIslandSchematic(getSkyBlockWorld(), getInstance().getSchemFile()[i], next))
- {
- setChest(next, player);
- hasIslandNow = true;
- }
- }
- if(!hasIslandNow)
- {
- for(int i = 0; i < getInstance().getSchemFile().length; i++)
- {
- if(getInstance().getSchemFile()[i].getName().lastIndexOf('.') > 0)
- cSchem = getInstance().getSchemFile()[i].getName().substring(0, getInstance().getSchemFile()[i].getName().lastIndexOf('.'));
- else
- cSchem = getInstance().getSchemFile()[i].getName();
- if(cSchem.equalsIgnoreCase(Settings.island_schematicName) && WorldEditHandler.loadIslandSchematic(getSkyBlockWorld(), getInstance().getSchemFile()[i], next))
- {
- setChest(next, player);
- hasIslandNow = true;
- }
- }
- }
- }
- if(!hasIslandNow)
- if(!Settings.island_useOldIslands)
- generateIslandBlocks(next.getBlockX(), next.getBlockZ(), player, getSkyBlockWorld());
- else
- oldGenerateIslandBlocks(next.getBlockX(), next.getBlockZ(), player, getSkyBlockWorld());
- next.setY(Settings.island_height);
- System.out.println(next.getBlockY());
- System.out.println("Preparing to set new player information...");
- setNewPlayerIsland(player, next);
- System.out.println("Finished setting new player information.");
- player.getInventory().clear();
- player.getEquipment().clear();
- System.out.println("Preparing to set initial player biome...");
- getInstance().changePlayerBiome(player, "OCEAN");
- System.out.println("Finished setting initial player biome.");
- for(int x = (Settings.island_protectionRange / 2) * -1 - 16; x <= Settings.island_protectionRange / 2 + 16; x += 16)
- {
- for(int z = (Settings.island_protectionRange / 2) * -1 - 16; z <= Settings.island_protectionRange / 2 + 16; z += 16)
- getSkyBlockWorld().refreshChunk((next.getBlockX() + x) / 16, (next.getBlockZ() + z) / 16);
- }
- for(Iterator ents = player.getNearbyEntities(50D, 250D, 50D).iterator(); ents.hasNext();)
- {
- Entity tempent = (Entity)ents.next();
- if(!(tempent instanceof Player))
- tempent.remove();
- }
- if(Settings.island_protectWithWorldGuard && Bukkit.getServer().getPluginManager().isPluginEnabled("WorldGuard"))
- WorldGuardHandler.protectIsland(player, sender.getName(), pi);
- }
- catch(Exception ex)
- {
- player.sendMessage("Could not create your Island. Pleace contact a server moderator.");
- ex.printStackTrace();
- return false;
- }
- System.out.println("Finished creating player island.");
- return true;
- }
- public void generateIslandBlocks(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- Block blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(7);
- islandLayer1(x, z, player, world);
- islandLayer2(x, z, player, world);
- islandLayer3(x, z, player, world);
- islandLayer4(x, z, player, world);
- islandExtras(x, z, player, world);
- }
- public void oldGenerateIslandBlocks(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- for(int x_operate = x; x_operate < x + 3; x_operate++)
- {
- for(int y_operate = y; y_operate < y + 3; y_operate++)
- {
- for(int z_operate = z; z_operate < z + 6; z_operate++)
- {
- Block blockToChange = world.getBlockAt(x_operate, y_operate, z_operate);
- blockToChange.setTypeId(2);
- }
- }
- }
- for(int x_operate = x + 3; x_operate < x + 6; x_operate++)
- {
- for(int y_operate = y; y_operate < y + 3; y_operate++)
- {
- for(int z_operate = z + 3; z_operate < z + 6; z_operate++)
- {
- Block blockToChange = world.getBlockAt(x_operate, y_operate, z_operate);
- blockToChange.setTypeId(2);
- }
- }
- }
- for(int x_operate = x + 3; x_operate < x + 7; x_operate++)
- {
- for(int y_operate = y + 7; y_operate < y + 10; y_operate++)
- {
- for(int z_operate = z + 3; z_operate < z + 7; z_operate++)
- {
- Block blockToChange = world.getBlockAt(x_operate, y_operate, z_operate);
- blockToChange.setTypeId(18);
- }
- }
- }
- for(int y_operate = y + 3; y_operate < y + 9; y_operate++)
- {
- Block blockToChange = world.getBlockAt(x + 5, y_operate, z + 5);
- blockToChange.setTypeId(17);
- }
- Block blockToChange = world.getBlockAt(x + 1, y + 3, z + 1);
- blockToChange.setTypeId(54);
- Chest chest = (Chest)blockToChange.getState();
- Inventory inventory = chest.getInventory();
- inventory.clear();
- inventory.setContents(Settings.island_chestItems);
- if(Settings.island_addExtraItems)
- {
- for(int i = 0; i < Settings.island_extraPermissions.length; i++)
- if(VaultHandler.checkPerk(player.getName(), (new StringBuilder("usb.")).append(Settings.island_extraPermissions[i]).toString(), player.getWorld()))
- {
- String chestItemString[] = getInstance().getConfig().getString((new StringBuilder("options.island.extraPermissions.")).append(Settings.island_extraPermissions[i]).toString()).split(" ");
- ItemStack tempChest[] = new ItemStack[chestItemString.length];
- String amountdata[] = new String[2];
- for(int j = 0; j < chestItemString.length; j++)
- {
- amountdata = chestItemString[j].split(":");
- tempChest[j] = new ItemStack(Integer.parseInt(amountdata[0]), Integer.parseInt(amountdata[1]));
- inventory.addItem(new ItemStack[] {
- tempChest[j]
- });
- }
- }
- }
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(7);
- blockToChange = world.getBlockAt(x + 2, y + 1, z + 1);
- blockToChange.setTypeId(12);
- blockToChange = world.getBlockAt(x + 2, y + 1, z + 2);
- blockToChange.setTypeId(12);
- blockToChange = world.getBlockAt(x + 2, y + 1, z + 3);
- blockToChange.setTypeId(12);
- }
- private Location nextIslandLocation(Location lastIsland)
- {
- int x = (int)lastIsland.getX();
- int z = (int)lastIsland.getZ();
- Location nextPos = lastIsland;
- if(x < z)
- if(-1 * x < z)
- {
- nextPos.setX(nextPos.getX() + (double)Settings.island_distance);
- return nextPos;
- } else
- {
- nextPos.setZ(nextPos.getZ() + (double)Settings.island_distance);
- return nextPos;
- }
- if(x > z)
- if(-1 * x >= z)
- {
- nextPos.setX(nextPos.getX() - (double)Settings.island_distance);
- return nextPos;
- } else
- {
- nextPos.setZ(nextPos.getZ() - (double)Settings.island_distance);
- return nextPos;
- }
- if(x <= 0)
- {
- nextPos.setZ(nextPos.getZ() + (double)Settings.island_distance);
- return nextPos;
- } else
- {
- nextPos.setZ(nextPos.getZ() - (double)Settings.island_distance);
- return nextPos;
- }
- }
- private void islandLayer1(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- y = Settings.island_height + 4;
- for(int x_operate = x - 3; x_operate <= x + 3; x_operate++)
- {
- for(int z_operate = z - 3; z_operate <= z + 3; z_operate++)
- {
- Block blockToChange = world.getBlockAt(x_operate, y, z_operate);
- blockToChange.setTypeId(2);
- }
- }
- Block blockToChange = world.getBlockAt(x - 3, y, z + 3);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x - 3, y, z - 3);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x + 3, y, z - 3);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x + 3, y, z + 3);
- blockToChange.setTypeId(0);
- }
- private void islandLayer2(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- y = Settings.island_height + 3;
- for(int x_operate = x - 2; x_operate <= x + 2; x_operate++)
- {
- for(int z_operate = z - 2; z_operate <= z + 2; z_operate++)
- {
- Block blockToChange = world.getBlockAt(x_operate, y, z_operate);
- blockToChange.setTypeId(3);
- }
- }
- Block blockToChange = world.getBlockAt(x - 3, y, z);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x + 3, y, z);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z - 3);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z + 3);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(12);
- }
- private void islandLayer3(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- y = Settings.island_height + 2;
- for(int x_operate = x - 1; x_operate <= x + 1; x_operate++)
- {
- for(int z_operate = z - 1; z_operate <= z + 1; z_operate++)
- {
- Block blockToChange = world.getBlockAt(x_operate, y, z_operate);
- blockToChange.setTypeId(3);
- }
- }
- Block blockToChange = world.getBlockAt(x - 2, y, z);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x + 2, y, z);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z - 2);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z + 2);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(12);
- }
- private void islandLayer4(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- y = Settings.island_height + 1;
- Block blockToChange = world.getBlockAt(x - 1, y, z);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x + 1, y, z);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z - 1);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z + 1);
- blockToChange.setTypeId(3);
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(12);
- }
- private void islandExtras(int x, int z, Player player, World world)
- {
- int y = Settings.island_height;
- Block blockToChange = world.getBlockAt(x, y + 5, z);
- blockToChange.setTypeId(17);
- blockToChange = world.getBlockAt(x, y + 6, z);
- blockToChange.setTypeId(17);
- blockToChange = world.getBlockAt(x, y + 7, z);
- blockToChange.setTypeId(17);
- y = Settings.island_height + 8;
- for(int x_operate = x - 2; x_operate <= x + 2; x_operate++)
- {
- for(int z_operate = z - 2; z_operate <= z + 2; z_operate++)
- {
- blockToChange = world.getBlockAt(x_operate, y, z_operate);
- blockToChange.setTypeId(18);
- }
- }
- blockToChange = world.getBlockAt(x + 2, y, z + 2);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x + 2, y, z - 2);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x - 2, y, z + 2);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x - 2, y, z - 2);
- blockToChange.setTypeId(0);
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(17);
- y = Settings.island_height + 9;
- for(int x_operate = x - 1; x_operate <= x + 1; x_operate++)
- {
- for(int z_operate = z - 1; z_operate <= z + 1; z_operate++)
- {
- blockToChange = world.getBlockAt(x_operate, y, z_operate);
- blockToChange.setTypeId(18);
- }
- }
- blockToChange = world.getBlockAt(x - 2, y, z);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x + 2, y, z);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, y, z - 2);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, y, z + 2);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(17);
- y = Settings.island_height + 10;
- blockToChange = world.getBlockAt(x - 1, y, z);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x + 1, y, z);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, y, z - 1);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, y, z + 1);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, y, z);
- blockToChange.setTypeId(17);
- blockToChange = world.getBlockAt(x, y + 1, z);
- blockToChange.setTypeId(18);
- blockToChange = world.getBlockAt(x, Settings.island_height + 5, z + 1);
- blockToChange.setTypeId(54);
- Chest chest = (Chest)blockToChange.getState();
- Inventory inventory = chest.getInventory();
- inventory.clear();
- inventory.setContents(Settings.island_chestItems);
- if(Settings.island_addExtraItems)
- {
- for(int i = 0; i < Settings.island_extraPermissions.length; i++)
- if(VaultHandler.checkPerk(player.getName(), (new StringBuilder("usb.")).append(Settings.island_extraPermissions[i]).toString(), player.getWorld()))
- {
- String chestItemString[] = getInstance().getConfig().getString((new StringBuilder("options.island.extraPermissions.")).append(Settings.island_extraPermissions[i]).toString()).split(" ");
- ItemStack tempChest[] = new ItemStack[chestItemString.length];
- String amountdata[] = new String[2];
- for(int j = 0; j < chestItemString.length; j++)
- {
- amountdata = chestItemString[j].split(":");
- tempChest[j] = new ItemStack(Integer.parseInt(amountdata[0]), Integer.parseInt(amountdata[1]));
- inventory.addItem(new ItemStack[] {
- tempChest[j]
- });
- }
- }
- }
- }
- public void setChest(Location loc, Player player)
- {
- for(int x = -15; x <= 15; x++)
- {
- for(int y = -15; y <= 15; y++)
- {
- for(int z = -15; z <= 15; z++)
- if(getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + z).getTypeId() == 54)
- {
- Block blockToChange = getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + z);
- Chest chest = (Chest)blockToChange.getState();
- Inventory inventory = chest.getInventory();
- inventory.clear();
- inventory.setContents(Settings.island_chestItems);
- if(Settings.island_addExtraItems)
- {
- for(int i = 0; i < Settings.island_extraPermissions.length; i++)
- if(VaultHandler.checkPerk(player.getName(), (new StringBuilder("usb.")).append(Settings.island_extraPermissions[i]).toString(), player.getWorld()))
- {
- String chestItemString[] = getInstance().getConfig().getString((new StringBuilder("options.island.extraPermissions.")).append(Settings.island_extraPermissions[i]).toString()).split(" ");
- ItemStack tempChest[] = new ItemStack[chestItemString.length];
- String amountdata[] = new String[2];
- for(int j = 0; j < chestItemString.length; j++)
- {
- amountdata = chestItemString[j].split(":");
- tempChest[j] = new ItemStack(Integer.parseInt(amountdata[0]), Integer.parseInt(amountdata[1]));
- inventory.addItem(new ItemStack[] {
- tempChest[j]
- });
- }
- }
- }
- }
- }
- }
- }
- public Location getChestSpawnLoc(Location loc, Player player)
- {
- for(int x = -15; x <= 15; x++)
- {
- for(int y = -15; y <= 15; y++)
- {
- for(int z = -15; z <= 15; z++)
- if(getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + z).getTypeId() == 54)
- {
- if(getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + (z + 1)).getTypeId() == 0 && getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + (y - 1), loc.getBlockZ() + (z + 1)).getTypeId() != 0)
- return new Location(getSkyBlockWorld(), loc.getBlockX() + x, loc.getBlockY() + (y + 1), loc.getBlockZ() + (z + 1));
- if(getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + (z - 1)).getTypeId() == 0 && getSkyBlockWorld().getBlockAt(loc.getBlockX() + x, loc.getBlockY() + (y - 1), loc.getBlockZ() + (z - 1)).getTypeId() != 0)
- return new Location(getSkyBlockWorld(), loc.getBlockX() + x, loc.getBlockY() + (y + 1), loc.getBlockZ() + (z + 1));
- if(getSkyBlockWorld().getBlockAt(loc.getBlockX() + (x + 1), loc.getBlockY() + y, loc.getBlockZ() + z).getTypeId() == 0 && getSkyBlockWorld().getBlockAt(loc.getBlockX() + (x + 1), loc.getBlockY() + (y - 1), loc.getBlockZ() + z).getTypeId() != 0)
- return new Location(getSkyBlockWorld(), loc.getBlockX() + x, loc.getBlockY() + (y + 1), loc.getBlockZ() + (z + 1));
- if(getSkyBlockWorld().getBlockAt(loc.getBlockX() + (x - 1), loc.getBlockY() + y, loc.getBlockZ() + z).getTypeId() == 0 && getSkyBlockWorld().getBlockAt(loc.getBlockX() + (x - 1), loc.getBlockY() + (y - 1), loc.getBlockZ() + z).getTypeId() != 0)
- {
- return new Location(getSkyBlockWorld(), loc.getBlockX() + x, loc.getBlockY() + (y + 1), loc.getBlockZ() + (z + 1));
- } else
- {
- loc.setY(loc.getY() + 1.0D);
- return loc;
- }
- }
- }
- }
- return loc;
- }
- private void setNewPlayerIsland(Player player, Location loc)
- {
- ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).startNewIsland(loc);
- player.teleport(getChestSpawnLoc(loc, player));
- if(getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()) == null)
- createIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty(), player.getName());
- clearIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty(), player.getName());
- getInstance().updatePartyNumber(player);
- getInstance().homeSet(player);
- ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).savePlayerConfig(player.getName());
- }
- public void setWarpLocation(String location, Location loc)
- {
- getIslandConfig(location).set("general.warpLocationX", Integer.valueOf(loc.getBlockX()));
- getIslandConfig(location).set("general.warpLocationY", Integer.valueOf(loc.getBlockY()));
- getIslandConfig(location).set("general.warpLocationZ", Integer.valueOf(loc.getBlockZ()));
- getIslandConfig(location).set("general.warpActive", Boolean.valueOf(true));
- saveIslandConfig(location);
- }
- public void buildIslandList()
- {
- File folder = getInstance().directoryPlayers;
- File listOfFiles[] = folder.listFiles();
- System.out.print((new StringBuilder()).append(ChatColor.YELLOW).append("[uSkyBlock] Building a new island list...").toString());
- for(int i = 0; i < listOfFiles.length; i++)
- {
- PlayerInfo pi = new PlayerInfo(listOfFiles[i].getName());
- if(pi.getHasIsland())
- {
- System.out.print((new StringBuilder("Creating new island file for ")).append(pi.getPlayerName()).toString());
- createIslandConfig(pi.locationForParty(), pi.getPlayerName());
- saveIslandConfig(pi.locationForParty());
- }
- }
- for(int i = 0; i < listOfFiles.length; i++)
- {
- PlayerInfo pi = new PlayerInfo(listOfFiles[i].getName());
- if(!pi.getHasIsland() && pi.getPartyIslandLocation() != null && getTempIslandConfig(pi.locationForPartyOld()) != null && !getTempIslandConfig(pi.locationForPartyOld()).contains((new StringBuilder("party.members.")).append(pi.getPlayerName()).toString()))
- {
- setupPartyMember(pi.locationForPartyOld(), pi.getPlayerName());
- saveIslandConfig(pi.locationForParty());
- }
- }
- System.out.print((new StringBuilder()).append(ChatColor.YELLOW).append("[uSkyBlock] Party list completed.").toString());
- }
- public void removeIslandConfig(String location)
- {
- islands.remove(location);
- }
- public void displayIslandConfigs()
- {
- for(Iterator islandList = islands.keySet().iterator(); islandList.hasNext(); System.out.print((String)islandList.next()));
- }
- public void updatePartyNumber(Player player)
- {
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize") < 8 && VaultHandler.checkPerk(player.getName(), "usb.extra.partysize", player.getWorld()))
- {
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).set("party.maxSize", Integer.valueOf(8));
- getInstance().saveIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty());
- return;
- }
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize") < 7 && VaultHandler.checkPerk(player.getName(), "usb.extra.party3", player.getWorld()))
- {
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).set("party.maxSize", Integer.valueOf(7));
- getInstance().saveIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty());
- return;
- }
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize") < 6 && VaultHandler.checkPerk(player.getName(), "usb.extra.party2", player.getWorld()))
- {
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).set("party.maxSize", Integer.valueOf(6));
- getInstance().saveIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty());
- return;
- }
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize") < 5 && VaultHandler.checkPerk(player.getName(), "usb.extra.party1", player.getWorld()))
- {
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).set("party.maxSize", Integer.valueOf(5));
- getInstance().saveIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty());
- return;
- } else
- {
- return;
- }
- }
- public void changePlayerPermission(Player player, String playername, String perm)
- {
- if(!getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).contains((new StringBuilder("party.members.")).append(playername).append(".").append(perm).toString()))
- return;
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(playername).append(".").append(perm).toString()))
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).set((new StringBuilder("party.members.")).append(playername).append(".").append(perm).toString(), Boolean.valueOf(false));
- else
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).set((new StringBuilder("party.members.")).append(playername).append(".").append(perm).toString(), Boolean.valueOf(true));
- getInstance().saveIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty());
- }
- public boolean checkForOnlineMembers(Player p)
- {
- for(Iterator temp = getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(p.getName())).locationForParty()).getConfigurationSection("party.members").getKeys(false).iterator(); temp.hasNext();)
- {
- String tString = (String)temp.next();
- if(Bukkit.getPlayer(tString) != null && !Bukkit.getPlayer(tString).getName().equalsIgnoreCase(p.getName()))
- return true;
- }
- return false;
- }
- public boolean checkCurrentBiome(Player p, String biome)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(p.getName())).locationForParty()).getString("general.biome").equalsIgnoreCase(biome);
- }
- public void setConfigBiome(Player p, String biome)
- {
- getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(p.getName())).locationForParty()).set("general.biome", biome);
- getInstance().saveIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(p.getName())).locationForParty());
- }
- public Inventory displayPartyPlayerGUI(Player player, String pname)
- {
- GUIpartyPlayer = Bukkit.createInventory(null, 9, (new StringBuilder(String.valueOf(pname))).append(" <Permissions>").toString());
- ItemStack pHead = new ItemStack(397, 1, (short)3);
- SkullMeta meta3 = (SkullMeta)pHead.getItemMeta();
- ItemMeta meta4 = sign.getItemMeta();
- meta4.setDisplayName("\247hPlayer Permissions");
- lores.add("\247eClick here to return to");
- lores.add("\247eyour island group's info.");
- meta4.setLore(lores);
- sign.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- sign
- });
- lores.clear();
- meta3.setDisplayName((new StringBuilder(String.valueOf(pname))).append("'s Permissions").toString());
- lores.add("\247eHover over an icon to view");
- lores.add("\247ea permission. Change the");
- lores.add("\247epermission by clicking it.");
- meta3.setLore(lores);
- pHead.setItemMeta(meta3);
- GUIpartyPlayer.addItem(new ItemStack[] {
- pHead
- });
- lores.clear();
- meta4 = biome.getItemMeta();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(pname).append(".canChangeBiome").toString()))
- {
- meta4.setDisplayName("\247aChange Biome");
- lores.add("\247fThis player \247acan\247f change the");
- lores.add("\247fisland's biome. Click here");
- lores.add("\247fto remove this permission.");
- } else
- {
- meta4.setDisplayName("\247cChange Biome");
- lores.add("\247fThis player \247ccannot\247f change the");
- lores.add("\247fisland's biome. Click here");
- lores.add("\247fto grant this permission.");
- }
- meta4.setLore(lores);
- biome.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- biome
- });
- lores.clear();
- meta4 = lock.getItemMeta();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(pname).append(".canToggleLock").toString()))
- {
- meta4.setDisplayName("\247aToggle Island Lock");
- lores.add("\247fThis player \247acan\247f toggle the");
- lores.add("\247fisland's lock, which prevents");
- lores.add("\247fnon-group members from entering.");
- lores.add("\247fClick here to remove this permission.");
- } else
- {
- meta4.setDisplayName("\247cToggle Island Lock");
- lores.add("\247fThis player \247ccannot\247f toggle the");
- lores.add("\247fisland's lock, which prevents");
- lores.add("\247fnon-group members from entering.");
- lores.add("\247fClick here to add this permission");
- }
- meta4.setLore(lores);
- lock.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- lock
- });
- lores.clear();
- meta4 = warpset.getItemMeta();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(pname).append(".canChangeWarp").toString()))
- {
- meta4.setDisplayName("\247aSet Island Warp");
- lores.add("\247fThis player \247acan\247f set the");
- lores.add("\247fisland's warp, which allows");
- lores.add("\247fnon-group members to teleport");
- lores.add("\247fto the island. Click here to");
- lores.add("\247fremove this permission.");
- } else
- {
- meta4.setDisplayName("\247cSet Island Warp");
- lores.add("\247fThis player \247ccannot\247f set the");
- lores.add("\247fisland's warp, which allows");
- lores.add("\247fnon-group members to teleport");
- lores.add("\247fto the island. Click here to");
- lores.add("\247fadd this permission.");
- }
- meta4.setLore(lores);
- warpset.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- warpset
- });
- lores.clear();
- meta4 = warptoggle.getItemMeta();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(pname).append(".canToggleWarp").toString()))
- {
- meta4.setDisplayName("\247aToggle Island Warp");
- lores.add("\247fThis player \247acan\247f toggle the");
- lores.add("\247fisland's warp, allowing them");
- lores.add("\247fto turn it on or off at anytime.");
- lores.add("\247fbut not set the location. Click");
- lores.add("\247fhere to remove this permission.");
- } else
- {
- meta4.setDisplayName("\247cToggle Island Warp");
- lores.add("\247fThis player \247ccannot\247f toggle the");
- lores.add("\247fisland's warp, allowing them");
- lores.add("\247fto turn it on or off at anytime,");
- lores.add("\247fbut not set the location. Click");
- lores.add("\247fhere to add this permission.");
- }
- meta4.setLore(lores);
- warptoggle.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- warptoggle
- });
- lores.clear();
- meta4 = invite.getItemMeta();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(pname).append(".canInviteOthers").toString()))
- {
- meta4.setDisplayName("\247aInvite Players");
- lores.add("\247fThis player \247acan\247f invite");
- lores.add("\247fother players to the island if");
- lores.add("\247fthere is enough room for more");
- lores.add("\247fmembers. Click here to remove");
- lores.add("\247fthis permission.");
- } else
- {
- meta4.setDisplayName("\247cInvite Players");
- lores.add("\247fThis player \247ccannot\247f invite");
- lores.add("\247fother players to the island.");
- lores.add("\247fClick here to add this permission.");
- }
- meta4.setLore(lores);
- invite.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- invite
- });
- lores.clear();
- meta4 = kick.getItemMeta();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(pname).append(".canKickOthers").toString()))
- {
- meta4.setDisplayName("\247aKick Players");
- lores.add("\247fThis player \247acan\247f kick");
- lores.add("\247fother players from the island,");
- lores.add("\247fbut they are unable to kick");
- lores.add("\247fthe island leader. Click here");
- lores.add("\247fto remove this permission.");
- } else
- {
- meta4.setDisplayName("\247cKick Players");
- lores.add("\247fThis player \247ccannot\247f kick");
- lores.add("\247fother players from the island.");
- lores.add("\247fClick here to add this permission.");
- }
- meta4.setLore(lores);
- kick.setItemMeta(meta4);
- GUIpartyPlayer.addItem(new ItemStack[] {
- kick
- });
- lores.clear();
- return GUIpartyPlayer;
- }
- public Inventory displayPartyGUI(Player player)
- {
- GUIparty = Bukkit.createInventory(null, 18, "\2479Island Group Members");
- Set memberList = getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getConfigurationSection("party.members").getKeys(false);
- tempIt = memberList.iterator();
- SkullMeta meta3 = (SkullMeta)pHead.getItemMeta();
- ItemMeta meta4 = sign.getItemMeta();
- meta4.setDisplayName("\247aGroup Info");
- lores.add((new StringBuilder("Group Members: \2472")).append(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.currentSize")).append("\2477/\247e").append(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize")).toString());
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.currentSize") < getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize"))
- lores.add("\247aMore players can be invited to this island.");
- else
- lores.add("\247cThis island is full.");
- lores.add("\247eHover over a player's icon to");
- lores.add("\247eview their permissions. The");
- lores.add("\247eleader can change permissions");
- lores.add("\247eby clicking a player's icon.");
- meta4.setLore(lores);
- sign.setItemMeta(meta4);
- GUIparty.addItem(new ItemStack[] {
- sign
- });
- lores.clear();
- for(; tempIt.hasNext(); GUIparty.addItem(new ItemStack[] {
- pHead
- }))
- {
- String temp = (String)tempIt.next();
- if(temp.equalsIgnoreCase(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getString("party.leader")))
- {
- meta3.setDisplayName((new StringBuilder("\247f")).append(temp).toString());
- lores.add("\247a\247lLeader");
- lores.add("\247aCan \247fchange the island's biome.");
- lores.add("\247aCan \247flock/unlock the island.");
- lores.add("\247aCan \247fset the island's warp.");
- lores.add("\247aCan \247ftoggle the island's warp.");
- lores.add("\247aCan \247finvite others to the island.");
- lores.add("\247aCan \247fkick others from the island.");
- meta3.setLore(lores);
- lores.clear();
- } else
- {
- meta3.setDisplayName((new StringBuilder("\247f")).append(temp).toString());
- lores.add("\247e\247lMember");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(temp).append(".canChangeBiome").toString()))
- lores.add("\247aCan \247fchange the island's biome.");
- else
- lores.add("\247cCannot \247fchange the island's biome.");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(temp).append(".canToggleLock").toString()))
- lores.add("\247aCan \247flock/unlock the island.");
- else
- lores.add("\247cCannot \247flock/unlock the island.");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(temp).append(".canChangeWarp").toString()))
- lores.add("\247aCan \247fset the island's warp.");
- else
- lores.add("\247cCannot \247fset the island's warp.");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(temp).append(".canToggleWarp").toString()))
- lores.add("\247aCan \247ftoggle the island's warp.");
- else
- lores.add("\247cCannot \247ftoggle the island's warp.");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(temp).append(".canInviteOthers").toString()))
- lores.add("\247aCan \247finvite others to the island.");
- else
- lores.add("\247cCannot \247finvite others to the island.");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(temp).append(".canKickOthers").toString()))
- lores.add("\247aCan \247fkick others from the island.");
- else
- lores.add("\247cCannot \247fkick others from the island.");
- if(player.getName().equalsIgnoreCase(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getString("party.leader")))
- lores.add("\247e<Click to change this player's permissions>");
- meta3.setLore(lores);
- lores.clear();
- }
- meta3.setOwner(temp);
- pHead.setItemMeta(meta3);
- }
- return GUIparty;
- }
- public Inventory displayLogGUI(Player player)
- {
- GUIlog = Bukkit.createInventory(null, 9, "\2479Island Log");
- ItemMeta meta4 = sign.getItemMeta();
- meta4.setDisplayName("\247lIsland Log");
- lores.add("\247eClick here to return to");
- lores.add("\247ethe main island screen.");
- meta4.setLore(lores);
- sign.setItemMeta(meta4);
- GUIlog.addItem(new ItemStack[] {
- sign
- });
- lores.clear();
- currentLogItem = new ItemStack(Material.BOOK_AND_QUILL, 1);
- meta4 = currentLogItem.getItemMeta();
- meta4.setDisplayName("\247e\247lIsland Log");
- for(int i = 1; i <= 10; i++)
- if(getInstance().getIslandConfig(((PlayerInfo)getActivePlayers().get(player.getName())).locationForParty()).contains((new StringBuilder("log.")).append(i).toString()))
- lores.add(getInstance().getIslandConfig(((PlayerInfo)getActivePlayers().get(player.getName())).locationForParty()).getString((new StringBuilder("log.")).append(i).toString()));
- meta4.setLore(lores);
- currentLogItem.setItemMeta(meta4);
- GUIlog.setItem(8, currentLogItem);
- lores.clear();
- return GUIlog;
- }
- public Inventory displayBiomeGUI(Player player)
- {
- GUIbiome = Bukkit.createInventory(null, 18, "\2479Island Biome");
- ItemMeta meta4 = sign.getItemMeta();
- meta4.setDisplayName("\247hIsland Biome");
- lores.add("\247eClick here to return to");
- lores.add("\247ethe main island screen.");
- meta4.setLore(lores);
- sign.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- sign
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.WATER, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.ocean", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Ocean");
- lores.add("\247fThe ocean biome is the basic");
- lores.add("\247fstarting biome for all islands.");
- lores.add("\247fpassive mobs like animals will");
- lores.add("\247fnot spawn. Hostile mobs will");
- lores.add("\247fspawn normally.");
- if(checkCurrentBiome(player, "OCEAN"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Ocean");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The ocean biome is the basic");
- lores.add("\2477starting biome for all islands.");
- lores.add("\2477passive mobs like animals will");
- lores.add("\2477not spawn. Hostile mobs will");
- lores.add("\2477spawn normally.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.SAPLING, 1, (short)1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.forst", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Forest");
- lores.add("\247fThe forest biome will allow");
- lores.add("\247fyour island to spawn passive.");
- lores.add("\247fmobs like animals (including");
- lores.add("\247fwolves). Hostile mobs will");
- lores.add("\247fspawn normally.");
- if(checkCurrentBiome(player, "FOREST"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Forest");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The forest biome will allow");
- lores.add("\2477your island to spawn passive.");
- lores.add("\2477mobs like animals (including");
- lores.add("\2477wolves). Hostile mobs will");
- lores.add("\2477spawn normally.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.SAND, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.desert", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Desert");
- lores.add("\247fThe desert biome makes it so");
- lores.add("\247fthat there is no rain or snow");
- lores.add("\247fon your island. Passive mobs");
- lores.add("\247fwon't spawn. Hostile mobs will");
- lores.add("\247fspawn normally.");
- if(checkCurrentBiome(player, "DESERT"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Desert");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The desert biome makes it so");
- lores.add("\2477that there is no rain or snow");
- lores.add("\2477on your island. Passive mobs");
- lores.add("\2477won't spawn. Hostile mobs will");
- lores.add("\2477spawn normally.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.SAPLING, 1, (short)3);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.jungle", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Jungle");
- lores.add("\247fThe jungle biome is bright");
- lores.add("\247fand colorful. Passive mobs");
- lores.add("\247f(including ocelots) will");
- lores.add("\247fspawn. Hostile mobs will");
- lores.add("\247fspawn normally.");
- if(checkCurrentBiome(player, "JUNGLE"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Jungle");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The jungle biome is bright");
- lores.add("\2477and colorful. Passive mobs");
- lores.add("\2477(including ocelots) will");
- lores.add("\2477spawn. Hostile mobs will");
- lores.add("\2477spawn normally.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.WATER_LILY, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.swampland", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Swampland");
- lores.add("\247fThe swamp biome is dark");
- lores.add("\247fand dull. Passive mobs");
- lores.add("\247fwill spawn normally and");
- lores.add("\247fslimes have a small chance");
- lores.add("\247fto spawn at night depending");
- lores.add("\247fon the moon phase.");
- if(checkCurrentBiome(player, "SWAMPLAND"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Swampland");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The swamp biome is dark");
- lores.add("\2477and dull. Passive mobs");
- lores.add("\2477will spawn normally and");
- lores.add("\2477slimes have a small chance");
- lores.add("\2477to spawn at night depending");
- lores.add("\2477on the moon phase.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.SNOW, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.taiga", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Taiga");
- lores.add("\247fThe taiga biome has snow");
- lores.add("\247finstead of rain. Passive");
- lores.add("\247fmobs will spawn normally");
- lores.add("\247f(including wolves) and");
- lores.add("\247fhostile mobs will spawn.");
- if(checkCurrentBiome(player, "TAIGA"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Taiga");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The taiga biome has snow");
- lores.add("\2477instead of rain. Passive");
- lores.add("\2477mobs will spawn normally");
- lores.add("\2477(including wolves) and");
- lores.add("\2477hostile mobs will spawn.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.RED_MUSHROOM, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.mushroom", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Mushroom");
- lores.add("\247fThe mushroom biome is");
- lores.add("\247fbright and colorful.");
- lores.add("\247fMooshrooms are the only");
- lores.add("\247fmobs that will spawn.");
- lores.add("\247fNo other passive or");
- lores.add("\247fhostile mobs will spawn.");
- if(checkCurrentBiome(player, "MUSHROOM"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Mushroom");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The mushroom biome is");
- lores.add("\2477bright and colorful.");
- lores.add("\2477Mooshrooms are the only");
- lores.add("\2477mobs that will spawn.");
- lores.add("\2477No other passive or");
- lores.add("\2477hostile mobs will spawn.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.FIRE, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.hell", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Hell(Nether)");
- lores.add("\247fThe hell biome looks");
- lores.add("\247fdark and dead. Some");
- lores.add("\247fmobs from the nether will");
- lores.add("\247fspawn in this biome");
- lores.add("\247f(excluding ghasts and");
- lores.add("\247fblazes).");
- if(checkCurrentBiome(player, "HELL"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Hell(Nether)");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The hell biome looks");
- lores.add("\2477dark and dead. Some");
- lores.add("\2477mobs from the nether will");
- lores.add("\2477spawn in this biome");
- lores.add("\2477(excluding ghasts and");
- lores.add("\2477blazes).");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- currentBiomeItem = new ItemStack(Material.EYE_OF_ENDER, 1);
- meta4 = currentBiomeItem.getItemMeta();
- if(VaultHandler.checkPerk(player.getName(), "usb.biome.sky", player.getWorld()))
- {
- meta4.setDisplayName("\247aBiome: Sky(End)");
- lores.add("\247fThe sky biome gives your");
- lores.add("\247fisland a special dark sky.");
- lores.add("\247fOnly endermen will spawn");
- lores.add("\247fin this biome.");
- if(checkCurrentBiome(player, "SKY"))
- lores.add("\2472\247lThis is your current biome.");
- else
- lores.add("\247e\247lClick to change to this biome.");
- } else
- {
- meta4.setDisplayName("\2478Biome: Sky(End)");
- lores.add("\247cYou cannot use this biome.");
- lores.add("\2477The sky biome gives your");
- lores.add("\2477island a special dark sky.");
- lores.add("\2477Only endermen will spawn");
- lores.add("\2477in this biome.");
- }
- meta4.setLore(lores);
- currentBiomeItem.setItemMeta(meta4);
- GUIbiome.addItem(new ItemStack[] {
- currentBiomeItem
- });
- lores.clear();
- return GUIbiome;
- }
- public Inventory displayChallengeGUI(Player player)
- {
- GUIchallenge = Bukkit.createInventory(null, 36, "\2479Challenge Menu");
- PlayerInfo pi = (PlayerInfo)getInstance().getActivePlayers().get(player.getName());
- populateChallengeRank(player, 0, Material.DIRT, 0, pi);
- populateChallengeRank(player, 1, Material.IRON_BLOCK, 9, pi);
- populateChallengeRank(player, 2, Material.GOLD_BLOCK, 18, pi);
- populateChallengeRank(player, 3, Material.DIAMOND_BLOCK, 27, pi);
- return GUIchallenge;
- }
- public Inventory displayIslandGUI(Player player)
- {
- GUIisland = Bukkit.createInventory(null, 18, "\2479Island Menu");
- if(hasIsland(player.getName()))
- {
- currentIslandItem = new ItemStack(Material.ENDER_PORTAL, 1);
- ItemMeta meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lReturn Home");
- lores.add("\247fReturn to your island's home");
- lores.add("\247fpoint. You can change your home");
- lores.add("\247fpoint to any location on your");
- lores.add("\247fisland using \247b/island sethome");
- lores.add("\247e\247lClick here to return home.");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.DIAMOND_ORE, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lChallenges");
- lores.add("\247fView a list of challenges that");
- lores.add("\247fyou can complete on your island");
- lores.add("\247fto earn skybucks, items, perks,");
- lores.add("\247fand titles.");
- lores.add("\247e\247lClick here to view challenges.");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.EXP_BOTTLE, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lIsland Level");
- lores.add((new StringBuilder("\247eCurrent Level: \247a")).append(showIslandLevel(player)).toString());
- lores.add("\247fGain island levels by expanding");
- lores.add("\247fyour skyblock and completing");
- lores.add("\247fcertain challenges. Rarer blocks");
- lores.add("\247fwill add more to your level.");
- lores.add("\247e\247lClick here to refresh.");
- lores.add("\247e\247l(must be on island)");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
- SkullMeta meta3 = (SkullMeta)currentIslandItem.getItemMeta();
- meta3.setDisplayName("\247a\247lIsland Group");
- lores.add((new StringBuilder("\247eMembers: \2472")).append(showCurrentMembers(player)).append("/").append(showMaxMembers(player)).toString());
- lores.add("\247fView the members of your island");
- lores.add("\247fgroup and their permissions. If");
- lores.add("\247fyou are the island leader, you");
- lores.add("\247fcan change the member permissions.");
- lores.add("\247e\247lClick here to view or change.");
- meta3.setLore(lores);
- currentIslandItem.setItemMeta(meta3);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.SAPLING, 1, (short)3);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lChange Island Biome");
- lores.add((new StringBuilder("\247eCurrent Biome: \247b")).append(getCurrentBiome(player).toUpperCase()).toString());
- lores.add("\247fThe island biome affects things");
- lores.add("\247flike grass color and spawning");
- lores.add("\247fof both animals and monsters.");
- if(checkIslandPermission(player, "canChangeBiome"))
- lores.add("\247e\247lClick here to change biomes.");
- else
- lores.add("\247c\247lYou can't change the biome.");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.IRON_FENCE, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lIsland Lock");
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean("general.locked"))
- {
- lores.add("\247eLock Status: \247aActive");
- lores.add("\247fYour island is currently \247clocked.");
- lores.add("\247fPlayers outside of your group");
- lores.add("\247fare unable to enter your island.");
- if(checkIslandPermission(player, "canToggleLock"))
- lores.add("\247e\247lClick here to unlock your island.");
- else
- lores.add("\247c\247lYou can't change the lock.");
- } else
- {
- lores.add("\247eLock Status: \2478Inactive");
- lores.add("\247fYour island is currently \247aunlocked.");
- lores.add("\247fAll players are able to enter your");
- lores.add("\247fisland, but only you and your group");
- lores.add("\247fmembers may build there.");
- if(checkIslandPermission(player, "canToggleLock"))
- lores.add("\247e\247lClick here to lock your island.");
- else
- lores.add("\247c\247lYou can't change the lock.");
- }
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- if(getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean("general.warpActive"))
- {
- currentIslandItem = new ItemStack(Material.PORTAL, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lIsland Warp");
- lores.add("\247eWarp Status: \247aActive");
- lores.add("\247fOther players may warp to your");
- lores.add("\247fisland at anytime to the point");
- lores.add("\247fyou set using \247d/island setwarp.");
- if(checkIslandPermission(player, "canToggleWarp") && VaultHandler.checkPerk(player.getName(), "usb.extra.addwarp", getSkyBlockWorld()))
- lores.add("\247e\247lClick here to deactivate.");
- else
- lores.add("\247c\247lYou can't change the warp.");
- } else
- {
- currentIslandItem = new ItemStack(Material.ENDER_STONE, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lIsland Warp");
- lores.add("\247eWarp Status: \2478Inactive");
- lores.add("\247fOther players can't warp to your");
- lores.add("\247fisland. Set a warp point using");
- lores.add("\247d/island setwarp \247fbefore activating.");
- if(checkIslandPermission(player, "canToggleWarp") && VaultHandler.checkPerk(player.getName(), "usb.extra.addwarp", getSkyBlockWorld()))
- lores.add("\247e\247lClick here to activate.");
- else
- lores.add("\247c\247lYou can't change the warp.");
- }
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.CHEST, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lBuy Perks");
- lores.add("\247fVisit the perk shop to buy");
- lores.add("\247fspecial abilities for your");
- lores.add("\247fisland and character, as well");
- lores.add("\247fas titles and more.");
- lores.add("\247e\247lClick here to open the shop!");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.ENDER_CHEST, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lBuy Donor Perks");
- lores.add("\247fThis special perk shop is");
- lores.add("\247fonly available to donors!");
- if(VaultHandler.checkPerk(player.getName(), "group.donor", player.getWorld()))
- lores.add("\247e\247lClick here to open the shop!");
- else
- lores.add("\247a\247lClick here to become a donor!");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.setItem(16, currentIslandItem);
- lores.clear();
- currentIslandItem = new ItemStack(Material.BOOK_AND_QUILL, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lIsland Log");
- lores.add("\247fView a log of events from");
- lores.add("\247fyour island such as member,");
- lores.add("\247fbiome, and warp changes.");
- lores.add("\247e\247lClick to view the log.");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.BED, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lChange Home Location");
- lores.add("\247fWhen you teleport to your");
- lores.add("\247fisland you will be taken to");
- lores.add("\247fthis location.");
- lores.add("\247e\247lClick here to change.");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.HOPPER, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lChange Warp Location");
- lores.add("\247fWhen your warp is activated,");
- lores.add("\247fother players will be taken to");
- lores.add("\247fthis point when they teleport");
- lores.add("\247fto your island.");
- lores.add("\247e\247lClick here to change.");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.setItem(15, currentIslandItem);
- lores.clear();
- } else
- if(VaultHandler.checkPerk(player.getName(), "group.member", getSkyBlockWorld()))
- {
- currentIslandItem = new ItemStack(Material.GRASS, 1);
- ItemMeta meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lStart an Island");
- lores.add("\247fStart your skyblock journey");
- lores.add("\247fby starting your own island.");
- lores.add("\247fComplete challenges to earn");
- lores.add("\247fitems and skybucks to help");
- lores.add("\247fexpand your skyblock. You can");
- lores.add("\247finvite others to join in");
- lores.add("\247fbuilding your island empire!");
- lores.add("\247e\247lClick here to start!");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- currentIslandItem = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
- SkullMeta meta3 = (SkullMeta)currentIslandItem.getItemMeta();
- meta3.setDisplayName("\247a\247lJoin an Island");
- lores.add("\247fWant to join another player's");
- lores.add("\247fisland instead of starting");
- lores.add("\247fyour own? If another player");
- lores.add("\247finvites you to their island");
- lores.add("\247fyou can click here or use");
- lores.add("\247e/island accept \247fto join them.");
- lores.add("\247e\247lClick here to accept an invite!");
- lores.add("\247e\247l(You must be invited first)");
- meta3.setLore(lores);
- currentIslandItem.setItemMeta(meta3);
- GUIisland.setItem(4, currentIslandItem);
- lores.clear();
- currentIslandItem = new ItemStack(Material.SIGN, 1);
- meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lIsland Help");
- lores.add("\247fNeed help with skyblock");
- lores.add("\247fconcepts or commands? View");
- lores.add("\247fdetails about them here.");
- lores.add("\247e\247lClick here for help!");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.setItem(8, currentIslandItem);
- lores.clear();
- } else
- {
- currentIslandItem = new ItemStack(Material.BOOK, 1);
- ItemMeta meta4 = currentIslandItem.getItemMeta();
- meta4.setDisplayName("\247a\247lWelcome to the Server!");
- lores.add("\247fPlease read and accept the");
- lores.add("\247fserver rules to become a");
- lores.add("\247fmember and start your skyblock.");
- lores.add("\247e\247lClick here to read!");
- meta4.setLore(lores);
- currentIslandItem.setItemMeta(meta4);
- GUIisland.addItem(new ItemStack[] {
- currentIslandItem
- });
- lores.clear();
- }
- return GUIisland;
- }
- public boolean isPartyLeader(Player player)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getString("party.leader").equalsIgnoreCase(player.getName());
- }
- public boolean checkIslandPermission(Player player, String permission)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getBoolean((new StringBuilder("party.members.")).append(player.getName()).append(".").append(permission).toString());
- }
- public String getCurrentBiome(Player player)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getString("general.biome");
- }
- public int showIslandLevel(Player player)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("general.level");
- }
- public int showCurrentMembers(Player player)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.currentSize");
- }
- public int showMaxMembers(Player player)
- {
- return getInstance().getIslandConfig(((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).locationForParty()).getInt("party.maxSize");
- }
- public void populateChallengeRank(Player player, int rankIndex, Material mat, int location, PlayerInfo pi)
- {
- int rankComplete = 0;
- currentChallengeItem = new ItemStack(mat, 1);
- ItemMeta meta4 = currentChallengeItem.getItemMeta();
- meta4.setDisplayName((new StringBuilder("\247e\247lRank: ")).append(Settings.challenges_ranks[rankIndex]).toString());
- lores.add("\247fComplete most challenges in");
- lores.add("\247fthis rank to unlock the next rank.");
- meta4.setLore(lores);
- currentChallengeItem.setItemMeta(meta4);
- GUIchallenge.setItem(location, currentChallengeItem);
- lores.clear();
- String challengeList[] = getChallengesFromRank(player, Settings.challenges_ranks[rankIndex]).split(" - ");
- for(int i = 0; i < challengeList.length; i++)
- {
- if(rankIndex > 0)
- {
- rankComplete = getInstance().checkRankCompletion(player, Settings.challenges_ranks[rankIndex - 1]);
- if(rankComplete > 0)
- {
- currentChallengeItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)14);
- meta4 = currentChallengeItem.getItemMeta();
- meta4.setDisplayName("\2474\247lLocked Challenge");
- lores.add((new StringBuilder("\2477Complete ")).append(rankComplete).append(" more ").append(Settings.challenges_ranks[rankIndex - 1]).append(" challenges").toString());
- lores.add("\2477to unlock this rank.");
- meta4.setLore(lores);
- currentChallengeItem.setItemMeta(meta4);
- GUIchallenge.setItem(++location, currentChallengeItem);
- lores.clear();
- continue;
- }
- }
- if(challengeList[i].charAt(1) == 'e')
- {
- currentChallengeItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)4);
- meta4 = currentChallengeItem.getItemMeta();
- meta4.setDisplayName(challengeList[i].replace("\247e", "\247e\247l"));
- challengeList[i] = challengeList[i].replace("\247e", "");
- challengeList[i] = challengeList[i].replace("\2478", "");
- } else
- if(challengeList[i].charAt(1) == 'a')
- {
- if(!getInstance().getConfig().contains((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].replace("\247a", "").replace("\2472", "").replace("\247e", "").replace("\2478", "").toLowerCase()).append(".displayItem").toString()))
- currentChallengeItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)5);
- else
- currentChallengeItem = new ItemStack(Material.getMaterial(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].replace("\247a", "").replace("\2472", "").replace("\247e", "").replace("\2478", "").toLowerCase()).append(".displayItem").toString())), 1);
- meta4 = currentChallengeItem.getItemMeta();
- meta4.setDisplayName(challengeList[i].replace("\247a", "\247a\247l"));
- challengeList[i] = challengeList[i].replace("\247a", "");
- challengeList[i] = challengeList[i].replace("\2478", "");
- } else
- if(challengeList[i].charAt(1) == '2')
- {
- currentChallengeItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)13);
- meta4 = currentChallengeItem.getItemMeta();
- meta4.setDisplayName(challengeList[i].replace("\2472", "\2472\247l"));
- challengeList[i] = challengeList[i].replace("\2472", "");
- challengeList[i] = challengeList[i].replace("\2478", "");
- } else
- {
- currentChallengeItem = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)4);
- meta4 = currentChallengeItem.getItemMeta();
- meta4.setDisplayName(challengeList[i].replace("\247e", "\247e\247l"));
- challengeList[i] = challengeList[i].replace("\247e", "");
- challengeList[i] = challengeList[i].replace("\2478", "");
- }
- lores.add((new StringBuilder("\2477")).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".description").toString())).toString());
- lores.add("\247eThis challenge requires the following:");
- String reqList[] = getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".requiredItems").toString()).split(" ");
- int reqItem = 0;
- int reqAmount = 0;
- int reqMod = -1;
- String as[];
- int k = (as = reqList).length;
- for(int j = 0; j < k; j++)
- {
- String s = as[j];
- String sPart[] = s.split(":");
- if(sPart.length == 2)
- {
- reqItem = Integer.parseInt(sPart[0]);
- String sScale[] = sPart[1].split(";");
- if(sScale.length == 1)
- reqAmount = Integer.parseInt(sPart[1]);
- else
- if(sScale.length == 2)
- if(sScale[1].charAt(0) == '+')
- reqAmount = Integer.parseInt(sScale[0]) + Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase());
- else
- if(sScale[1].charAt(0) == '*')
- reqAmount = Integer.parseInt(sScale[0]) * (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase()));
- else
- if(sScale[1].charAt(0) == '-')
- reqAmount = Integer.parseInt(sScale[0]) - Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase());
- else
- if(sScale[1].charAt(0) == '/')
- reqAmount = Integer.parseInt(sScale[0]) / (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase()));
- } else
- if(sPart.length == 3)
- {
- reqItem = Integer.parseInt(sPart[0]);
- String sScale[] = sPart[2].split(";");
- if(sScale.length == 1)
- reqAmount = Integer.parseInt(sPart[2]);
- else
- if(sScale.length == 2)
- if(sScale[1].charAt(0) == '+')
- reqAmount = Integer.parseInt(sScale[0]) + Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase());
- else
- if(sScale[1].charAt(0) == '*')
- reqAmount = Integer.parseInt(sScale[0]) * (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase()));
- else
- if(sScale[1].charAt(0) == '-')
- reqAmount = Integer.parseInt(sScale[0]) - Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase());
- else
- if(sScale[1].charAt(0) == '/')
- reqAmount = Integer.parseInt(sScale[0]) / (Integer.parseInt(sScale[1].substring(1)) * ((PlayerInfo)getInstance().getActivePlayers().get(player.getName())).checkChallengeSinceTimer(challengeList[i].toLowerCase()));
- reqMod = Integer.parseInt(sPart[1]);
- }
- ItemStack newItem = new ItemStack(reqItem, reqAmount, (short)reqMod);
- lores.add((new StringBuilder("\247f")).append(newItem.getAmount()).append(" ").append(newItem.getType().toString()).toString());
- }
- if(pi.checkChallenge(challengeList[i].toLowerCase()) > 0 && getInstance().getConfig().getBoolean((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".repeatable").toString()))
- {
- if(pi.onChallengeCooldown(challengeList[i].toLowerCase()))
- if(pi.getChallengeCooldownTime(challengeList[i].toLowerCase()) / 0x5265c00L >= 1L)
- {
- int days = (int)pi.getChallengeCooldownTime(challengeList[i].toLowerCase()) / 0x5265c00;
- lores.add((new StringBuilder("\2474Requirements will reset in ")).append(days).append(" days.").toString());
- } else
- {
- int hours = (int)pi.getChallengeCooldownTime(challengeList[i].toLowerCase()) / 0x36ee80;
- lores.add((new StringBuilder("\2474Requirements will reset in ")).append(hours).append(" hours.").toString());
- }
- lores.add((new StringBuilder("\2476Item Reward: \247a")).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".repeatRewardText").toString())).toString());
- lores.add((new StringBuilder("\2476Currency Reward: \247a")).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".repeatCurrencyReward").toString())).toString());
- lores.add((new StringBuilder("\2476Exp Reward: \247a")).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".repeatXpReward").toString())).toString());
- lores.add((new StringBuilder("\247dTotal times completed: \247f")).append(pi.getChallenge(challengeList[i].toLowerCase()).getTimesCompleted()).toString());
- lores.add("\247e\247lClick to complete this challenge.");
- } else
- {
- lores.add((new StringBuilder("\2476Item Reward: \247a")).append(getInstance().getConfig().getString((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".rewardText").toString())).toString());
- lores.add((new StringBuilder("\2476Currency Reward: \247a")).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".currencyReward").toString())).toString());
- lores.add((new StringBuilder("\2476Exp Reward: \247a")).append(getInstance().getConfig().getInt((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".xpReward").toString())).toString());
- if(getInstance().getConfig().getBoolean((new StringBuilder("options.challenges.challengeList.")).append(challengeList[i].toLowerCase()).append(".repeatable").toString()))
- lores.add("\247e\247lClick to complete this challenge.");
- else
- lores.add("\2474\247lYou can't repeat this challenge.");
- }
- meta4.setLore(lores);
- currentChallengeItem.setItemMeta(meta4);
- GUIchallenge.setItem(++location, currentChallengeItem);
- lores.clear();
- }
- }
- public void sendMessageToIslandGroup(String location, String message)
- {
- Iterator temp = getInstance().getIslandConfig(location).getConfigurationSection("party.members").getKeys(false).iterator();
- date = new Date();
- String myDateString = DateFormat.getDateInstance(3).format(date).toString();
- String dateTxt = myDateString;
- int currentLogPos = getInstance().getIslandConfig(location).getInt("log.logPos");
- while(temp.hasNext())
- {
- String player = (String)temp.next();
- if(Bukkit.getPlayer(player) != null)
- Bukkit.getPlayer(player).sendMessage((new StringBuilder("\247d[skyblock] ")).append(message).toString());
- }
- getInstance().getIslandConfig(location).set((new StringBuilder("log.")).append(++currentLogPos).toString(), (new StringBuilder("\247d[")).append(dateTxt).append("] ").append(message).toString());
- if(currentLogPos < 10)
- getInstance().getIslandConfig(location).set("log.logPos", Integer.valueOf(currentLogPos));
- else
- getInstance().getIslandConfig(location).set("log.logPos", Integer.valueOf(0));
- }
- public PluginDescriptionFile pluginFile;
- public Logger log;
- Date date;
- public DecimalFormat df;
- private FileConfiguration levelConfig;
- private FileConfiguration lastIslandConfig;
- private FileConfiguration orphans;
- private FileConfiguration tempIsland;
- private FileConfiguration tempPlayer;
- private HashMap islands;
- private File levelConfigFile;
- private File orphanFile;
- private File lastIslandConfigFile;
- private File islandConfigFile;
- private File tempIslandFile;
- private File tempPlayerFile;
- public static World skyBlockWorld = null;
- private static uSkyBlock instance;
- public List removeList;
- List rankDisplay;
- public FileConfiguration configPlugin;
- public File filePlugin;
- private Location lastIsland;
- private Stack orphaned;
- private Stack tempOrphaned;
- private Stack reverseOrphaned;
- public File directoryPlayers;
- public File directoryIslands;
- private File directorySchematics;
- public File schemFile[];
- public String pName;
- public Location islandTestLocation;
- LinkedHashMap topTen;
- HashMap infoCooldown;
- HashMap restartCooldown;
- HashMap biomeCooldown;
- HashMap activePlayers;
- LinkedHashMap challenges;
- HashMap requiredList;
- public boolean purgeActive;
- private FileConfiguration skyblockData;
- private File skyblockDataFile;
- public Inventory GUIparty;
- public Inventory GUIpartyPlayer;
- public Inventory GUIisland;
- public Inventory GUIchallenge;
- public Inventory GUIbiome;
- public Inventory GUIlog;
- ItemStack pHead;
- ItemStack sign;
- ItemStack biome;
- ItemStack lock;
- ItemStack warpset;
- ItemStack warptoggle;
- ItemStack invite;
- ItemStack kick;
- ItemStack currentBiomeItem;
- ItemStack currentIslandItem;
- ItemStack currentChallengeItem;
- ItemStack currentLogItem;
- List lores;
- Iterator tempIt;
- private ArrayList sfiles;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement