mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2025-02-18 01:31:40 +01:00
Remove locking
This commit is contained in:
parent
3f85df77e5
commit
856a8dbbb8
@ -9,7 +9,12 @@ class EssentialsIntegration : PricesIntegration {
|
||||
private lateinit var manager: IEssentials;
|
||||
|
||||
override fun getPrice(itemStack: ItemStack): Double {
|
||||
return manager.worth.getPrice(manager, itemStack).toDouble() * itemStack.amount
|
||||
val price = manager.worth.getPrice(manager, itemStack)
|
||||
if (price == null) {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
return price.toDouble() * itemStack.amount
|
||||
}
|
||||
|
||||
override fun register() {
|
||||
|
@ -653,7 +653,7 @@ class Minion(
|
||||
if (linkedChest == null) return
|
||||
|
||||
if (ticking) {
|
||||
Scheduler.get().executeAt(linkedChest) {
|
||||
Scheduler.get().runAt(linkedChest) {
|
||||
if (linkedChest!!.world!!.isChunkLoaded(linkedChest!!.blockX shr 4, linkedChest!!.blockZ shr 4)) {
|
||||
linkedInventory = (linkedChest?.block?.state as? Container)?.inventory
|
||||
}
|
||||
|
@ -67,7 +67,26 @@ object Minions {
|
||||
val chunkZ = minion.getLocation().blockZ shr 4
|
||||
val world = minion.getLocation().world ?: return
|
||||
|
||||
lock.write {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
lock.write {
|
||||
var pos: ChunkPos? = null
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
pos = it
|
||||
return@breaking
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pos == null) {
|
||||
pos = ChunkPos(world, chunkX, chunkZ, false)
|
||||
minions.add(pos!!)
|
||||
}
|
||||
|
||||
pos!!.addMinion(minion)
|
||||
}
|
||||
} else {
|
||||
var pos: ChunkPos? = null
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
@ -83,8 +102,7 @@ object Minions {
|
||||
minions.add(pos!!)
|
||||
}
|
||||
|
||||
|
||||
pos!!.addMinion(minion)
|
||||
pos!!.addMinion(minion)
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +111,21 @@ object Minions {
|
||||
val chunkZ = minion.getLocation().blockZ shr 4
|
||||
val world = minion.getLocation().world ?: return
|
||||
|
||||
lock.write {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
lock.write {
|
||||
val iterator = minions.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
val next = iterator.next()
|
||||
|
||||
if (world.uid == next.worldUUID && next.x == chunkX && next.z == chunkZ) {
|
||||
if (next.removeMinion(minion)) {
|
||||
iterator.remove()
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val iterator = minions.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
val next = iterator.next()
|
||||
|
Loading…
Reference in New Issue
Block a user