Skip to content

Commit

Permalink
Fixed incorrect field names after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jan 4, 2022
1 parent b0156ca commit 904729d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Expand Up @@ -30,23 +30,23 @@ public final class CachedIslandInfo {

private static final SuperiorSkyblockPlugin plugin = SuperiorSkyblockPlugin.getPlugin();

public final Location[] teleportLocations = new Location[World.Environment.values().length];
public final Location[] islandHomes = new Location[World.Environment.values().length];
public final List<SuperiorPlayer> members = new ArrayList<>();
public final List<SuperiorPlayer> banned = new ArrayList<>();
public final List<SuperiorPlayer> bannedPlayers = new ArrayList<>();
public final Map<SuperiorPlayer, PlayerPermissionNode> playerPermissions = new HashMap<>();
public final Map<IslandPrivilege, PlayerRole> rolePermissions = new HashMap<>();
public final Map<String, Integer> upgrades = new HashMap<>();
public final KeyMap<UpgradeValue<Integer>> blockLimits = new KeyMap<>();
public final Map<UUID, Rating> ratings = new HashMap<>();
public final Map<Mission<?>, Integer> completedMissions = new HashMap<>();
public final Map<IslandFlag, Byte> islandSettings = new HashMap<>();
public final Map<IslandFlag, Byte> islandFlags = new HashMap<>();
public final KeyMap<UpgradeValue<Integer>>[] cobbleGeneratorValues = new KeyMap[World.Environment.values().length];
public final List<Pair<SuperiorPlayer, Long>> uniqueVisitors = new ArrayList<>();
public final KeyMap<UpgradeValue<Integer>> entityLimits = new KeyMap<>();
public final Map<PotionEffectType, UpgradeValue<Integer>> islandEffects = new HashMap<>();
public final List<ItemStack[]> islandChest = new ArrayList<>(plugin.getSettings().getIslandChests().getDefaultPages());
public final List<ItemStack[]> islandChests = new ArrayList<>(plugin.getSettings().getIslandChests().getDefaultPages());
public final Map<PlayerRole, UpgradeValue<Integer>> roleLimits = new HashMap<>();
public final Location[] visitorsLocations = new Location[World.Environment.values().length];
public final Location[] visitorHomes = new Location[World.Environment.values().length];
public UpgradeValue<Integer> islandSize = UpgradeValue.NEGATIVE;
public UpgradeValue<Integer> warpsLimit = UpgradeValue.NEGATIVE;
public UpgradeValue<Integer> teamLimit = UpgradeValue.NEGATIVE;
Expand Down
Expand Up @@ -79,7 +79,7 @@ public static void deserializeBanned(DatabaseBridge databaseBridge, DatabaseCach

UUID playerUUID = UUID.fromString((String) bansRow.get("player"));
SuperiorPlayer superiorPlayer = plugin.getPlayers().getSuperiorPlayer(playerUUID);
cachedIslandInfo.banned.add(superiorPlayer);
cachedIslandInfo.bannedPlayers.add(superiorPlayer);
});
}

Expand Down Expand Up @@ -242,7 +242,7 @@ public static void deserializeIslandFlags(DatabaseBridge databaseBridge, Databas
try {
IslandFlag islandFlag = IslandFlag.getByName((String) islandFlagRow.get("name"));
byte status = getAsByte(islandFlagRow.get("status"));
cachedIslandInfo.islandSettings.put(islandFlag, status);
cachedIslandInfo.islandFlags.put(islandFlag, status);
} catch (Exception error) {
SuperiorSkyblockPlugin.log("&cError occurred while loading island flags:");
error.printStackTrace();
Expand Down Expand Up @@ -275,7 +275,7 @@ public static void deserializeIslandHomes(DatabaseBridge databaseBridge, Databas
UUID uuid = UUID.fromString((String) teleportLocationRow.get("island"));
CachedIslandInfo cachedIslandInfo = databaseCache.addCachedInfo(uuid, new CachedIslandInfo());
int environment = World.Environment.valueOf((String) teleportLocationRow.get("environment")).ordinal();
cachedIslandInfo.teleportLocations[environment] = FileUtils.toLocation((String) teleportLocationRow.get("location"));
cachedIslandInfo.islandHomes[environment] = FileUtils.toLocation((String) teleportLocationRow.get("location"));
});
}

Expand All @@ -284,7 +284,7 @@ public static void deserializeVisitorHomes(DatabaseBridge databaseBridge, Databa
UUID uuid = UUID.fromString((String) teleportLocationRow.get("island"));
CachedIslandInfo cachedIslandInfo = databaseCache.addCachedInfo(uuid, new CachedIslandInfo());
int environment = World.Environment.valueOf((String) teleportLocationRow.get("environment")).ordinal();
cachedIslandInfo.visitorsLocations[environment] = FileUtils.toLocation((String) teleportLocationRow.get("location"));
cachedIslandInfo.visitorHomes[environment] = FileUtils.toLocation((String) teleportLocationRow.get("location"));
});
}

Expand All @@ -307,11 +307,11 @@ public static void deserializeIslandChest(DatabaseBridge databaseBridge, Databas
int index = (int) islandChestRow.get("index");
String contents = (String) islandChestRow.get("contents");

while (index > cachedIslandInfo.islandChest.size()) {
cachedIslandInfo.islandChest.add(new ItemStack[plugin.getSettings().getIslandChests().getDefaultSize()]);
while (index > cachedIslandInfo.islandChests.size()) {
cachedIslandInfo.islandChests.add(new ItemStack[plugin.getSettings().getIslandChests().getDefaultSize()]);
}

cachedIslandInfo.islandChest.add(ItemUtils.deserialize(contents));
cachedIslandInfo.islandChests.add(ItemUtils.deserialize(contents));
});
}

Expand Down
Expand Up @@ -3207,32 +3207,32 @@ private void deserializeBlockCounts(String blockCounts) {
}

private void loadFromCachedInfo(CachedIslandInfo cachedIslandInfo) {
this.teleportLocations.set(cachedIslandInfo.teleportLocations);
this.islandHomes.set(cachedIslandInfo.islandHomes);
this.members.write(members -> {
members.addAll(cachedIslandInfo.members);
members.forEach(member -> member.setIsland(this));
});
this.banned.addAll(cachedIslandInfo.banned);
this.bannedPlayers.addAll(cachedIslandInfo.bannedPlayers);
this.playerPermissions.putAll(cachedIslandInfo.playerPermissions);
this.playerPermissions.values().forEach(permissionNode -> permissionNode.setIsland(this));
this.rolePermissions.putAll(cachedIslandInfo.rolePermissions);
this.upgrades.putAll(cachedIslandInfo.upgrades);
this.blockLimits.putAll(cachedIslandInfo.blockLimits);
this.ratings.putAll(cachedIslandInfo.ratings);
this.completedMissions.putAll(cachedIslandInfo.completedMissions);
this.islandSettings.putAll(cachedIslandInfo.islandSettings);
this.islandFlags.putAll(cachedIslandInfo.islandFlags);
System.arraycopy(cachedIslandInfo.cobbleGeneratorValues, 0, this.cobbleGeneratorValues,
0, this.cobbleGeneratorValues.length);
this.uniqueVisitors.write(uniqueVisitors -> uniqueVisitors.addAll(cachedIslandInfo.uniqueVisitors));
this.entityLimits.putAll(cachedIslandInfo.entityLimits);
this.islandEffects.putAll(cachedIslandInfo.islandEffects);
this.islandChest.write(islandChest -> {
for (int index = 0; index < cachedIslandInfo.islandChest.size(); ++index) {
islandChest[index] = SIslandChest.createChest(this, index, cachedIslandInfo.islandChest.get(index));
this.islandChests.write(islandChest -> {
for (int index = 0; index < cachedIslandInfo.islandChests.size(); ++index) {
islandChest[index] = SIslandChest.createChest(this, index, cachedIslandInfo.islandChests.get(index));
}
});
this.roleLimits.putAll(cachedIslandInfo.roleLimits);
this.visitorsLocations.set(cachedIslandInfo.visitorsLocations);
this.visitorHomes.set(cachedIslandInfo.visitorHomes);

this.islandSize = cachedIslandInfo.islandSize;
this.teamLimit = cachedIslandInfo.teamLimit;
Expand Down

0 comments on commit 904729d

Please sign in to comment.