# Fixed an issue with the scoreboard when a player leaves an island team when there's only one member of the island left and no visitors occupying the island.
# Fixed visitors teleporting to the Main spawn point rather than the Visitor spawn point when they fall into the void at an island.
# Fixed island data not saving when ownership is transferred - this essentially broke the teaming system (Only affects build 40).
# Fixed NPE when performing the command '/island coop' if the player doesn't have permission.
# Fixed player not being removed from island when they leave the team.
# The levelling data now has its own file rather than being stored in the island data file.
This commit is contained in:
Unknown 2018-12-09 04:22:07 +00:00
parent 08728495fd
commit 623b3a9b82
5 changed files with 66 additions and 45 deletions

View File

@ -117,25 +117,22 @@ public class LeaveCommand extends SubCommand {
.replace("%player", player.getName())));
soundManager.playSound(all, Sounds.IRONGOLEM_HIT.bukkitSound(), 5.0F, 5.0F);
if (scoreboardManager != null) {
if (island.getRole(IslandRole.Member).size() == 0
&& island.getRole(IslandRole.Operator).size() == 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
languageConfig.getFileConfiguration()
.getString("Scoreboard.Island.Solo.Displayname")));
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
} else {
if (island.getRole(IslandRole.Member).size() == 0
&& island.getRole(IslandRole.Operator).size() == 0) {
if (scoreboardManager != null) {
if (islandManager.getVisitorsAtIsland(island).size() != 0) {
Scoreboard scoreboard = scoreboardManager.getScoreboard(all);
scoreboard.cancel();
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
languageConfig.getFileConfiguration()
.getString("Scoreboard.Island.Solo.Displayname")));
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
scoreboard.run();
}
scoreboard.run();
}
break;
}
}
}

View File

@ -103,10 +103,7 @@ public class LevelCommand extends SubCommand {
player.closeInventory();
if (skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
island.getOwnerUUID().toString() + ".yml"))
.getFileConfiguration().getString("Levelling.Materials") == null) {
if (!island.getLevel().hasMaterials()) {
LevellingManager levellingManager = skyblock.getLevellingManager();
if (levellingManager.hasLevelling(island.getOwnerUUID())) {

View File

@ -70,6 +70,8 @@ public class Island {
islandLocations.add(new Location(Location.World.Normal, Location.Environment.Island, islandNormalLocation));
islandLocations.add(new Location(Location.World.Nether, Location.Environment.Island, islandNetherLocation));
level = new Level(getOwnerUUID(), skyblock);
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
Config config = fileManager.getConfig(new File(configFile, uuid + ".yml"));
@ -89,6 +91,10 @@ public class Island {
configLoad.set("Settings", null);
}
if (configLoad.getString("Levelling.Materials") != null) {
configLoad.set("Levelling.Materials", null);
}
if (configLoad.getString("Members") != null) {
List<String> members = configLoad.getStringList("Members");
@ -243,8 +249,6 @@ public class Island {
}
}
level = new Level(getOwnerUUID(), skyblock);
VisitManager visitManager = skyblock.getVisitManager();
if (!visitManager.hasIsland(getOwnerUUID())) {
@ -713,6 +717,8 @@ public class Island {
e.printStackTrace();
}
}
getLevel().save();
}
public me.goodandevil.skyblock.api.island.Island getAPIWrapper() {

View File

@ -293,8 +293,12 @@ public class IslandManager {
if (containsIsland(islandOwnerUUID)) {
Island island = getIsland(islandOwnerUUID);
island.getLevel().setOwnerUUID(uuid);
island.setOwnerUUID(uuid);
island.save();
Level level = island.getLevel();
level.save();
level.setOwnerUUID(uuid);
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
@ -305,16 +309,25 @@ public class IslandManager {
File oldCoopDataFile = new File(new File(skyblock.getDataFolder().toString() + "/coop-data"),
islandOwnerUUID.toString() + ".yml");
fileManager.unloadConfig(oldCoopDataFile);
if (fileManager.isFileExist(oldCoopDataFile)) {
File newCoopDataFile = new File(new File(skyblock.getDataFolder().toString() + "/coop-data"),
uuid.toString() + ".yml");
fileManager.unloadConfig(oldCoopDataFile);
fileManager.unloadConfig(newCoopDataFile);
oldCoopDataFile.renameTo(newCoopDataFile);
}
File oldLevelDataFile = new File(new File(skyblock.getDataFolder().toString() + "/level-data"),
islandOwnerUUID.toString() + ".yml");
File newLevelDataFile = new File(new File(skyblock.getDataFolder().toString() + "/level-data"),
uuid.toString() + ".yml");
fileManager.unloadConfig(oldLevelDataFile);
fileManager.unloadConfig(newLevelDataFile);
oldLevelDataFile.renameTo(newLevelDataFile);
File oldSettingDataFile = new File(new File(skyblock.getDataFolder().toString() + "/setting-data"),
islandOwnerUUID.toString() + ".yml");
File newSettingDataFile = new File(new File(skyblock.getDataFolder().toString() + "/setting-data"),
@ -420,6 +433,8 @@ public class IslandManager {
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/coop-data"),
island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"),
island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/setting-data"),
island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),

View File

@ -26,8 +26,8 @@ public class Level {
this.skyblock = skyblock;
this.ownerUUID = ownerUUID;
Config config = skyblock.getFileManager().getConfig(new File(
new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
Map<String, Integer> materials = new HashMap<>();
@ -101,26 +101,17 @@ public class Level {
}
public void setMaterialAmount(String material, int amount) {
Config config = skyblock.getFileManager().getConfig(new File(
new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Levelling.Materials." + material + ".Amount", amount);
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
skyblock.getFileManager()
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/level-data"),
ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Levelling.Materials." + material + ".Amount", amount);
this.materials.put(material, amount);
}
public void setMaterials(Map<String, Integer> materials) {
Config config = skyblock.getFileManager().getConfig(new File(
new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"));
File configFile = config.getFile();
Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Levelling.Materials", null);
@ -129,13 +120,15 @@ public class Level {
configLoad.set("Levelling.Materials." + materialList + ".Amount", materials.get(materialList));
}
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
this.materials = materials;
}
public boolean hasMaterials() {
if (materials.size() == 0) {
return false;
}
this.materials = materials;
return true;
}
public Map<String, Integer> getMaterials() {
@ -157,4 +150,17 @@ public class Level {
public int getLastCalculatedLevel() {
return lastCalculatedLevel;
}
public void save() {
Config config = skyblock.getFileManager().getConfig(
new File(new File(skyblock.getDataFolder().toString() + "/level-data"), ownerUUID.toString() + ".yml"));
File configFile = config.getFile();
FileConfiguration configLoad = config.getFileConfiguration();
try {
configLoad.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}