Skip to content

Commit

Permalink
Small stability improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
FluxCapacitor2 committed Sep 15, 2024
1 parent d4c39d2 commit 02ce762
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,7 +22,7 @@ abstract class ModuleHolder {
/**
* A list of modules that have been loaded and subscribed to an event node.
*/
val modules = mutableListOf<GameModule>()
val modules: MutableList<GameModule> = CopyOnWriteArrayList()

private fun <T : GameModule> hasModule(type: KClass<T>): Boolean = modules.any { type.isInstance(it) }
inline fun <reified T : GameModule> hasModule(): Boolean = modules.any { it is T }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -160,7 +161,7 @@ class TeamModule(

data class Team(
val name: Component = Component.empty(),
val players: MutableList<Player> = mutableListOf(),
val players: MutableList<Player> = CopyOnWriteArrayList(),
val allowFriendlyFire: Boolean = false,
val nameTagVisible: Boolean = true,
) : PacketGroupingAudience {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit 02ce762

Please sign in to comment.