Merge remote-tracking branch 'origin/master'

This commit is contained in:
Esophose 2019-03-22 17:03:53 -06:00
commit d6c409cccc
5 changed files with 92 additions and 48 deletions

View File

@ -29,6 +29,13 @@ public class Island {
this.player = player; this.player = player;
} }
/**
* @return The Island UUID
*/
public UUID getIslandUUID() {
return this.handle.getIslandUUID();
}
/** /**
* @return The Island owner UUID * @return The Island owner UUID
*/ */

View File

@ -346,6 +346,21 @@ public class IslandManager {
return new Island(null, player); return new Island(null, player);
} }
/**
* Gets an Island by its UUID
* Returns null if an Island with the given UUID does not exist
*
* @param islandUUID The UUID of the Island
* @return The Island with the given UUID, or null if one was not found
*/
public Island getIslandByUUID(UUID islandUUID) {
Preconditions.checkArgument(islandUUID != null, "Cannot get island with a null UUID");
me.goodandevil.skyblock.island.Island island = this.islandManager.getIslandByUUID(islandUUID);
return island != null ? island.getAPIWrapper() : null;
}
/** /**
* @return A List of loaded Islands * @return A List of loaded Islands
*/ */

View File

@ -37,7 +37,8 @@ public class Island {
private List<IslandLocation> islandLocations = new ArrayList<>(); private List<IslandLocation> islandLocations = new ArrayList<>();
private Set<UUID> coopPlayers = new HashSet<>(); private Set<UUID> coopPlayers = new HashSet<>();
private UUID uuid; private UUID islandUUID;
private UUID ownerUUID;
private IslandLevel level; private IslandLevel level;
private int size; private int size;
private boolean deleted = false; private boolean deleted = false;
@ -47,7 +48,8 @@ public class Island {
FileManager fileManager = skyblock.getFileManager(); FileManager fileManager = skyblock.getFileManager();
this.uuid = player.getUniqueId(); this.islandUUID = UUID.randomUUID();
this.ownerUUID = player.getUniqueId();
this.size = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() this.size = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getInt("Island.Size.Minimum"); .getInt("Island.Size.Minimum");
@ -59,15 +61,21 @@ public class Island {
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data"); File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
Config config = fileManager.getConfig(new File(configFile, uuid + ".yml")); Config config = fileManager.getConfig(new File(configFile, ownerUUID + ".yml"));
Config defaultSettingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "settings.yml")); Config defaultSettingsConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "settings.yml"));
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")); Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration(); FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
if (fileManager.isFileExist(new File(configFile, uuid + ".yml"))) { if (fileManager.isFileExist(new File(configFile, ownerUUID + ".yml"))) {
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("UUID") != null) {
islandUUID = UUID.fromString(configLoad.getString("UUID"));
} else {
configLoad.set("UUID", islandUUID.toString());
}
if (configLoad.getString("Size") != null) { if (configLoad.getString("Size") != null) {
size = configLoad.getInt("Size"); size = configLoad.getInt("Size");
} }
@ -95,7 +103,7 @@ public class Island {
FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration(); FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration();
if (playerDataConfigLoad.getString("Island.Owner") == null if (playerDataConfigLoad.getString("Island.Owner") == null
|| !playerDataConfigLoad.getString("Island.Owner").equals(uuid.toString())) { || !playerDataConfigLoad.getString("Island.Owner").equals(ownerUUID.toString())) {
members.remove(member); members.remove(member);
} }
} }
@ -113,7 +121,7 @@ public class Island {
FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration(); FileConfiguration playerDataConfigLoad = playerDataConfig.getFileConfiguration();
if (playerDataConfigLoad.getString("Island.Owner") == null if (playerDataConfigLoad.getString("Island.Owner") == null
|| !playerDataConfigLoad.getString("Island.Owner").equals(uuid.toString())) { || !playerDataConfigLoad.getString("Island.Owner").equals(ownerUUID.toString())) {
operators.remove(operator); operators.remove(operator);
} }
} }
@ -149,6 +157,7 @@ public class Island {
} else { } else {
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("UUID", islandUUID.toString());
configLoad.set("Visitor.Open", mainConfigLoad.getBoolean("Island.Visitor.Open")); configLoad.set("Visitor.Open", mainConfigLoad.getBoolean("Island.Visitor.Open"));
configLoad.set("Border.Enable", true); configLoad.set("Border.Enable", true);
configLoad.set("Border.Color", WorldBorder.Color.Blue.name()); configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
@ -156,7 +165,7 @@ public class Island {
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised"));
configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time")); configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time"));
configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase()); configLoad.set("Weather.Weather", mainConfigLoad.getString("Island.Weather.Default.Weather").toUpperCase());
configLoad.set("Ownership.Original", uuid.toString()); configLoad.set("Ownership.Original", ownerUUID.toString());
for (IslandRole roleList : IslandRole.values()) { for (IslandRole roleList : IslandRole.values()) {
List<IslandSetting> settings = new ArrayList<>(); List<IslandSetting> settings = new ArrayList<>();
@ -172,9 +181,9 @@ public class Island {
save(); save();
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(Bukkit.getServer().getPlayer(uuid)); PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(Bukkit.getServer().getPlayer(ownerUUID));
playerData.setPlaytime(0); playerData.setPlaytime(0);
playerData.setOwner(uuid); playerData.setOwner(ownerUUID);
playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date())); playerData.setMemberSince(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new Date()));
playerData.save(); playerData.save();
} }
@ -198,13 +207,17 @@ public class Island {
this.apiWrapper = new me.goodandevil.skyblock.api.island.Island(this, player); this.apiWrapper = new me.goodandevil.skyblock.api.island.Island(this, player);
} }
public UUID getIslandUUID() {
return islandUUID;
}
public UUID getOwnerUUID() { public UUID getOwnerUUID() {
return uuid; return ownerUUID;
} }
public void setOwnerUUID(UUID uuid) { public void setOwnerUUID(UUID uuid) {
getVisit().setOwnerUUID(uuid); getVisit().setOwnerUUID(uuid);
this.uuid = uuid; this.ownerUUID = uuid;
} }
public UUID getOriginalOwnerUUID() { public UUID getOriginalOwnerUUID() {
@ -212,7 +225,7 @@ public class Island {
.fromString( .fromString(
skyblock.getFileManager() skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
uuid.toString() + ".yml")) ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Ownership.Original")); .getFileConfiguration().getString("Ownership.Original"));
} }
@ -227,7 +240,7 @@ public class Island {
this.size = size; this.size = size;
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Size", size); .getFileConfiguration().set("Size", size);
} }
@ -237,13 +250,13 @@ public class Island {
public boolean hasPassword() { public boolean hasPassword() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Ownership.Password") != null; .getFileConfiguration().getString("Ownership.Password") != null;
} }
public String getPassword() { public String getPassword() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Ownership.Password"); .getFileConfiguration().getString("Ownership.Password");
} }
@ -253,7 +266,7 @@ public class Island {
skyblock.getFileManager() skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
uuid.toString() + ".yml")) ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Ownership.Password", islandPasswordChangeEvent.getPassword()); .getFileConfiguration().set("Ownership.Password", islandPasswordChangeEvent.getPassword());
} }
@ -315,31 +328,31 @@ public class Island {
public boolean isBorder() { public boolean isBorder() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getBoolean("Border.Enable"); .getFileConfiguration().getBoolean("Border.Enable");
} }
public void setBorder(boolean border) { public void setBorder(boolean border) {
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Border.Enable", border); .getFileConfiguration().set("Border.Enable", border);
} }
public WorldBorder.Color getBorderColor() { public WorldBorder.Color getBorderColor() {
return WorldBorder.Color.valueOf(skyblock.getFileManager().getConfig( return WorldBorder.Color.valueOf(skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Border.Color")); .getFileConfiguration().getString("Border.Color"));
} }
public void setBorderColor(WorldBorder.Color color) { public void setBorderColor(WorldBorder.Color color) {
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Border.Color", color.name()); .getFileConfiguration().set("Border.Color", color.name());
} }
public Biome getBiome() { public Biome getBiome() {
return Biome.valueOf(skyblock.getFileManager().getConfig( return Biome.valueOf(skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Biome.Type")); .getFileConfiguration().getString("Biome.Type"));
} }
@ -353,13 +366,13 @@ public class Island {
skyblock.getFileManager() skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
uuid.toString() + ".yml")) ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Biome.Type", islandBiomeChangeEvent.getBiome().name()); .getFileConfiguration().set("Biome.Type", islandBiomeChangeEvent.getBiome().name());
} }
public boolean isWeatherSynchronized() { public boolean isWeatherSynchronized() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getBoolean("Weather.Synchronised"); .getFileConfiguration().getBoolean("Weather.Synchronised");
} }
@ -369,13 +382,13 @@ public class Island {
Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent); Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent);
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Weather.Synchronised", sync); .getFileConfiguration().set("Weather.Synchronised", sync);
} }
public WeatherType getWeather() { public WeatherType getWeather() {
String weatherTypeName = skyblock.getFileManager().getConfig( String weatherTypeName = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Weather.Weather"); .getFileConfiguration().getString("Weather.Weather");
WeatherType weatherType; WeatherType weatherType;
@ -399,13 +412,13 @@ public class Island {
Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent); Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent);
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Weather.Weather", weatherType.name()); .getFileConfiguration().set("Weather.Weather", weatherType.name());
} }
public int getTime() { public int getTime() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getInt("Weather.Time"); .getFileConfiguration().getInt("Weather.Time");
} }
@ -415,7 +428,7 @@ public class Island {
Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent); Bukkit.getServer().getPluginManager().callEvent(islandWeatherChangeEvent);
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Weather.Time", time); .getFileConfiguration().set("Weather.Time", time);
} }
@ -442,7 +455,7 @@ public class Island {
islandRoles.add(getOwnerUUID()); islandRoles.add(getOwnerUUID());
} else { } else {
Config config = skyblock.getFileManager().getConfig( Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString(role.name() + "s") != null) { if (configLoad.getString(role.name() + "s") != null) {
@ -550,7 +563,7 @@ public class Island {
public void setUpgrade(Player player, Upgrade.Type type, boolean status) { public void setUpgrade(Player player, Upgrade.Type type, boolean status) {
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Upgrade." + type.name(), status); .getFileConfiguration().set("Upgrade." + type.name(), status);
Bukkit.getServer().getPluginManager() Bukkit.getServer().getPluginManager()
@ -559,13 +572,13 @@ public class Island {
public void removeUpgrade(Upgrade.Type type) { public void removeUpgrade(Upgrade.Type type) {
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Upgrade." + type.name(), null); .getFileConfiguration().set("Upgrade." + type.name(), null);
} }
public boolean hasUpgrade(Upgrade.Type type) { public boolean hasUpgrade(Upgrade.Type type) {
if (skyblock.getFileManager().getConfig( if (skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Upgrade." + type.name()) == null) { .getFileConfiguration().getString("Upgrade." + type.name()) == null) {
return false; return false;
} }
@ -575,7 +588,7 @@ public class Island {
public boolean isUpgrade(Upgrade.Type type) { public boolean isUpgrade(Upgrade.Type type) {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getBoolean("Upgrade." + type.name()); .getFileConfiguration().getBoolean("Upgrade." + type.name());
} }
@ -601,27 +614,27 @@ public class Island {
public double getBankBalance() { public double getBankBalance() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getDouble("Bank.Balance"); .getFileConfiguration().getDouble("Bank.Balance");
} }
public void addToBank(double value) { public void addToBank(double value) {
value = value + getBankBalance(); value = value + getBankBalance();
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Bank.Balance", value); .getFileConfiguration().set("Bank.Balance", value);
} }
public void removeFromBank(double value) { public void removeFromBank(double value) {
value = getBankBalance() - value; value = getBankBalance() - value;
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Bank.Balance", value); .getFileConfiguration().set("Bank.Balance", value);
} }
public boolean isOpen() { public boolean isOpen() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getBoolean("Visitor.Open"); .getFileConfiguration().getBoolean("Visitor.Open");
} }
@ -631,7 +644,7 @@ public class Island {
if (!islandOpenEvent.isCancelled()) { if (!islandOpenEvent.isCancelled()) {
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Visitor.Open", open); .getFileConfiguration().set("Visitor.Open", open);
getVisit().setOpen(open); getVisit().setOpen(open);
} }
@ -641,7 +654,7 @@ public class Island {
List<String> islandMessage = new ArrayList<>(); List<String> islandMessage = new ArrayList<>();
Config config = skyblock.getFileManager().getConfig( Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Visitor." + message.name() + ".Message") != null) { if (configLoad.getString("Visitor." + message.name() + ".Message") != null) {
@ -653,7 +666,7 @@ public class Island {
public String getMessageAuthor(IslandMessage message) { public String getMessageAuthor(IslandMessage message) {
Config config = skyblock.getFileManager().getConfig( Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getString("Visitor." + message.name() + ".Author") != null) { if (configLoad.getString("Visitor." + message.name() + ".Author") != null) {
@ -670,7 +683,7 @@ public class Island {
if (!islandMessageChangeEvent.isCancelled()) { if (!islandMessageChangeEvent.isCancelled()) {
Config config = skyblock.getFileManager().getConfig( Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")); new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Visitor." + message.name() + ".Message", islandMessageChangeEvent.getLines()); configLoad.set("Visitor." + message.name() + ".Message", islandMessageChangeEvent.getLines());
configLoad.set("Visitor." + message.name() + ".Author", islandMessageChangeEvent.getAuthor()); configLoad.set("Visitor." + message.name() + ".Author", islandMessageChangeEvent.getAuthor());
@ -683,7 +696,7 @@ public class Island {
public void setStructure(String structure) { public void setStructure(String structure) {
skyblock.getFileManager().getConfig( skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Structure", structure); .getFileConfiguration().set("Structure", structure);
} }
@ -697,7 +710,7 @@ public class Island {
public String getStructure() { public String getStructure() {
return skyblock.getFileManager().getConfig( return skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml")) new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Structure"); .getFileConfiguration().getString("Structure");
} }
@ -725,7 +738,7 @@ public class Island {
FileManager fileManager = skyblock.getFileManager(); FileManager fileManager = skyblock.getFileManager();
Config config = fileManager Config config = fileManager
.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", uuid.toString() + ".yml")); .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml"));
try { try {
config.getFileConfiguration().save(config.getFile()); config.getFileConfiguration().save(config.getFile());
@ -734,7 +747,7 @@ public class Island {
} }
config = fileManager config = fileManager
.getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", uuid.toString() + ".yml")); .getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
for (IslandRole roleList : islandSettings.keySet()) { for (IslandRole roleList : islandSettings.keySet()) {
@ -752,7 +765,7 @@ public class Island {
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration() if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Coop.Unload")) { .getBoolean("Island.Coop.Unload")) {
config = fileManager config = fileManager
.getConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", uuid.toString() + ".yml")); .getConfig(new File(skyblock.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml"));
configLoad = config.getFileConfiguration(); configLoad = config.getFileConfiguration();
List<String> coopPlayersAsString = new ArrayList<>(); List<String> coopPlayersAsString = new ArrayList<>();
@ -781,7 +794,7 @@ public class Island {
FileConfiguration configLoad = config.getFileConfiguration(); FileConfiguration configLoad = config.getFileConfiguration();
Config islandData = fileManager Config islandData = fileManager
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
uuid.toString() + ".yml")); ownerUUID.toString() + ".yml"));
FileConfiguration configLoadIslandData = islandData.getFileConfiguration(); FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice"); double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice");

View File

@ -893,6 +893,15 @@ public class IslandManager {
return null; return null;
} }
public Island getIslandByUUID(UUID islandUUID) {
for (Island island : islandStorage.values()) {
if (island.getIslandUUID().equals(islandUUID)) {
return island;
}
}
return null;
}
public void removeIsland(UUID islandOwnerUUID) { public void removeIsland(UUID islandOwnerUUID) {
islandStorage.remove(islandOwnerUUID); islandStorage.remove(islandOwnerUUID);
} }

View File

@ -470,7 +470,7 @@ public class Entity implements Listener {
} else { } else {
try { try {
materials = Materials.requestMaterials(event.getTo().name(), materials = Materials.requestMaterials(event.getTo().name(),
(byte) event.getClass().getMethod("getData", byte.class).invoke(event)); (byte) event.getClass().getMethod("getData").invoke(event));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) { | NoSuchMethodException | SecurityException e) {
e.printStackTrace(); e.printStackTrace();