mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 21:48:43 +01:00
Make reward items list thread safe; resolves #177
This commit is contained in:
parent
c1c04bc187
commit
4863dbca61
@ -30,6 +30,7 @@ import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
|||||||
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -55,7 +56,7 @@ public class DGlobalPlayer {
|
|||||||
|
|
||||||
private ItemStack[] respawnInventory;
|
private ItemStack[] respawnInventory;
|
||||||
private ItemStack[] respawnArmor;
|
private ItemStack[] respawnArmor;
|
||||||
private List<ItemStack> rewardItems;
|
private CopyOnWriteArrayList<ItemStack> rewardItems;
|
||||||
|
|
||||||
public DGlobalPlayer(Player player) {
|
public DGlobalPlayer(Player player) {
|
||||||
this(player, false);
|
this(player, false);
|
||||||
@ -236,7 +237,7 @@ public class DGlobalPlayer {
|
|||||||
/**
|
/**
|
||||||
* @return the reward items
|
* @return the reward items
|
||||||
*/
|
*/
|
||||||
public List<ItemStack> getRewardItems() {
|
public CopyOnWriteArrayList<ItemStack> getRewardItems() {
|
||||||
return rewardItems;
|
return rewardItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +252,7 @@ public class DGlobalPlayer {
|
|||||||
* @param rewardItems
|
* @param rewardItems
|
||||||
* the reward items to set
|
* the reward items to set
|
||||||
*/
|
*/
|
||||||
public void setRewardItems(List<ItemStack> rewardItems) {
|
public void setRewardItems(CopyOnWriteArrayList<ItemStack> rewardItems) {
|
||||||
this.rewardItems = rewardItems;
|
this.rewardItems = rewardItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import io.github.dre2n.dungeonsxl.config.DMessages;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ public class ItemReward extends Reward {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
new DLootInventory(player, items.subList(0, 54).toArray(new ItemStack[54]));
|
new DLootInventory(player, items.subList(0, 54).toArray(new ItemStack[54]));
|
||||||
plugin.getDPlayers().getByPlayer(player).setRewardItems(items.subList(54, items.size()));
|
plugin.getDPlayers().getByPlayer(player).setRewardItems(new CopyOnWriteArrayList<>(items.subList(54, items.size())));
|
||||||
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_REWARDS.getMessage());
|
MessageUtil.sendMessage(player, DMessages.ERROR_TOO_MANY_REWARDS.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user