mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-22 02:08:34 +01:00
fix: Fix ConcurrentModificationException on PlayerData-Storage (#39)
This commit is contained in:
parent
018e26c1b0
commit
4dffd7e2a8
@ -5,6 +5,7 @@ import com.craftaro.core.hooks.economies.Economy;
|
||||
import com.craftaro.skyblock.SkyBlock;
|
||||
import com.craftaro.skyblock.config.FileManager;
|
||||
import com.craftaro.skyblock.island.Island;
|
||||
import com.craftaro.skyblock.playerdata.PlayerData;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -12,6 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BankManager {
|
||||
@ -71,8 +73,11 @@ public class BankManager {
|
||||
}
|
||||
|
||||
private void loadTransactions() {
|
||||
for (UUID uid : SkyBlock.getInstance().getPlayerDataManager().getPlayerData().keySet()) {
|
||||
this.log.put(uid, SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(uid).getTransactions());
|
||||
Map<UUID, PlayerData> playerDataStorage = SkyBlock.getInstance().getPlayerDataManager().getPlayerData();
|
||||
synchronized (playerDataStorage) {
|
||||
for (UUID uid : playerDataStorage.keySet()) {
|
||||
this.log.put(uid, playerDataStorage.get(uid).getTransactions());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,9 @@ import com.craftaro.skyblock.playerdata.PlayerData;
|
||||
import com.craftaro.skyblock.playerdata.PlayerDataManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConfirmationTask extends BukkitRunnable {
|
||||
private final PlayerDataManager playerDataManager;
|
||||
|
||||
@ -13,9 +16,12 @@ public class ConfirmationTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (PlayerData playerData : this.playerDataManager.getPlayerData().values()) {
|
||||
if (playerData.getConfirmationTime() > 0) {
|
||||
playerData.setConfirmationTime(playerData.getConfirmationTime() - 1);
|
||||
Map<UUID, PlayerData> playerDataStorage = this.playerDataManager.getPlayerData();
|
||||
synchronized (playerDataStorage) {
|
||||
for (PlayerData playerData : playerDataStorage.values()) {
|
||||
if (playerData.getConfirmationTime() > 0) {
|
||||
playerData.setConfirmationTime(playerData.getConfirmationTime() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1189,14 +1189,16 @@ public class IslandManager {
|
||||
Map<UUID, PlayerData> playerDataStorage = this.plugin.getPlayerDataManager().getPlayerData();
|
||||
Set<UUID> islandVisitors = new HashSet<>();
|
||||
|
||||
for (UUID playerDataStorageList : playerDataStorage.keySet()) {
|
||||
PlayerData playerData = playerDataStorage.get(playerDataStorageList);
|
||||
UUID islandOwnerUUID = playerData.getIsland();
|
||||
synchronized (playerDataStorage) {
|
||||
for (UUID playerDataStorageList : playerDataStorage.keySet()) {
|
||||
PlayerData playerData = playerDataStorage.get(playerDataStorageList);
|
||||
UUID islandOwnerUUID = playerData.getIsland();
|
||||
|
||||
if (islandOwnerUUID != null && islandOwnerUUID.equals(island.getOwnerUUID())) {
|
||||
if (playerData.getOwner() == null || !playerData.getOwner().equals(island.getOwnerUUID())) {
|
||||
if (Bukkit.getServer().getPlayer(playerDataStorageList) != null) {
|
||||
islandVisitors.add(playerDataStorageList);
|
||||
if (islandOwnerUUID != null && islandOwnerUUID.equals(island.getOwnerUUID())) {
|
||||
if (playerData.getOwner() == null || !playerData.getOwner().equals(island.getOwnerUUID())) {
|
||||
if (Bukkit.getServer().getPlayer(playerDataStorageList) != null) {
|
||||
islandVisitors.add(playerDataStorageList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import com.craftaro.skyblock.playerdata.PlayerData;
|
||||
import com.craftaro.skyblock.playerdata.PlayerDataManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VisitTask extends BukkitRunnable {
|
||||
private final PlayerDataManager playerDataManager;
|
||||
|
||||
@ -13,9 +16,12 @@ public class VisitTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (PlayerData playerData : this.playerDataManager.getPlayerData().values()) {
|
||||
if (playerData.getIsland() != null) {
|
||||
playerData.setVisitTime(playerData.getVisitTime() + 1);
|
||||
Map<UUID, PlayerData> playerDataStorage = this.playerDataManager.getPlayerData();
|
||||
synchronized (playerDataStorage) {
|
||||
for (PlayerData playerData : playerDataStorage.values()) {
|
||||
if (playerData.getIsland() != null) {
|
||||
playerData.setVisitTime(playerData.getVisitTime() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user