diff --git a/common/src/main/kotlin/com/bluedragonmc/server/ModuleHolder.kt b/common/src/main/kotlin/com/bluedragonmc/server/ModuleHolder.kt index 6fce25d..bd08ecb 100644 --- a/common/src/main/kotlin/com/bluedragonmc/server/ModuleHolder.kt +++ b/common/src/main/kotlin/com/bluedragonmc/server/ModuleHolder.kt @@ -3,6 +3,7 @@ package com.bluedragonmc.server import com.bluedragonmc.server.module.GameModule import net.minestom.server.event.Event import org.slf4j.LoggerFactory +import java.util.concurrent.CopyOnWriteArrayList import java.util.function.Consumer import java.util.function.Predicate import kotlin.reflect.KClass @@ -21,7 +22,7 @@ abstract class ModuleHolder { /** * A list of modules that have been loaded and subscribed to an event node. */ - val modules = mutableListOf() + val modules: MutableList = CopyOnWriteArrayList() private fun hasModule(type: KClass): Boolean = modules.any { type.isInstance(it) } inline fun hasModule(): Boolean = modules.any { it is T } diff --git a/common/src/main/kotlin/com/bluedragonmc/server/module/combat/ProjectileModule.kt b/common/src/main/kotlin/com/bluedragonmc/server/module/combat/ProjectileModule.kt index 9a9adbe..971a149 100644 --- a/common/src/main/kotlin/com/bluedragonmc/server/module/combat/ProjectileModule.kt +++ b/common/src/main/kotlin/com/bluedragonmc/server/module/combat/ProjectileModule.kt @@ -248,15 +248,15 @@ class ProjectileModule : GameModule() { player.inventory.setItemInHand(hand, itemStack.withAmount(itemStack.amount() - 1)) } - // Shoot a snowball from the player's position - val snowball = Projectile(player, EntityType.FIREBALL) - snowball.setInstance(instance, getEyePos(player)) - snowball.shoot(getLaunchPos(player), 3.0, 1.0) + // Shoot a fireball from the player's position + val fireball = Projectile(player, EntityType.FIREBALL) + fireball.setInstance(instance, getEyePos(player)) + fireball.shoot(getLaunchPos(player), 3.0, 1.0) player.instance?.playSound( Sound.sound(SoundEvent.ITEM_FIRECHARGE_USE, Sound.Source.MASTER, 1.0f, 1.0f), player.position ) - snowball.scheduleRemove(Duration.ofSeconds(30)) + fireball.scheduleRemove(Duration.ofSeconds(30)) } } @@ -365,7 +365,7 @@ class ProjectileModule : GameModule() { player.inventory.setItemInHand(hand, itemStack.withAmount(itemStack.amount() - 1)) } - // Shoot a snowball from the player's position + // Shoot an egg from the player's position val egg = Projectile(player, EntityType.EGG) egg.setInstance(instance, getEyePos(player)) egg.shoot(getLaunchPos(player), 3.0, 1.0) diff --git a/common/src/main/kotlin/com/bluedragonmc/server/module/minigame/TeamModule.kt b/common/src/main/kotlin/com/bluedragonmc/server/module/minigame/TeamModule.kt index 66d4a62..4d173e2 100644 --- a/common/src/main/kotlin/com/bluedragonmc/server/module/minigame/TeamModule.kt +++ b/common/src/main/kotlin/com/bluedragonmc/server/module/minigame/TeamModule.kt @@ -18,6 +18,7 @@ import net.minestom.server.entity.Player import net.minestom.server.event.Event import net.minestom.server.event.EventNode import java.util.* +import java.util.concurrent.CopyOnWriteArrayList /** * A module that provides team support. @@ -160,7 +161,7 @@ class TeamModule( data class Team( val name: Component = Component.empty(), - val players: MutableList = mutableListOf(), + val players: MutableList = CopyOnWriteArrayList(), val allowFriendlyFire: Boolean = false, val nameTagVisible: Boolean = true, ) : PacketGroupingAudience { diff --git a/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt b/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt index 6ed9293..cc70deb 100644 --- a/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt +++ b/src/main/kotlin/com/bluedragonmc/server/impl/OutgoingRPCHandlerImpl.kt @@ -83,8 +83,10 @@ class OutgoingRPCHandlerImpl(serverAddress: String, serverPort: Int) : OutgoingR } } - override fun deinitialize(): Unit = runBlocking { - Messaging.outgoing.notifyInstanceRemoved(parent.id) + override fun deinitialize() { + Messaging.IO.launch { + Messaging.outgoing.notifyInstanceRemoved(parent.id) + } } }