Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
implementation("com.akuleshov7:ktoml-core:0.5.1")
implementation("com.akuleshov7:ktoml-file:0.5.1")
implementation("net.bytebuddy:byte-buddy-agent:1.14.12")
implementation("org.jctools:jctools-core:4.0.5")

api("io.github.dockyardmc:bytesocks-client-java:1.0-SNAPSHOT") {
exclude(module = "slf4j-api")
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/github/dockyardmc/DockyardServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class DockyardServer(configBuilder: Config.() -> Unit) {
if (ConfigManager.config.implementationConfig.applyBlockPlacementRules) DefaultBlockHandlers().register()
}

NetworkCompression.compressionThreshold = ConfigManager.config.networkCompressionThreshold
NetworkCompression.COMPRESSION_THRESHOLD = ConfigManager.config.networkCompressionThreshold
WorldManager.loadDefaultWorld()

Events.dispatch(ServerFinishLoadEvent(this))
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/io/github/dockyardmc/apis/Hologram.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class Hologram(spawnLocation: Location, builder: HologramBuilder) : Entity(spawn
}

fun addStaticLine(line: StaticContentLine) {
val lineIndex = lines.size
lines.add(line)
if (viewers.isEmpty()) return
viewers.forEach(::updateFull)
}

Expand All @@ -73,8 +73,8 @@ class Hologram(spawnLocation: Location, builder: HologramBuilder) : Entity(spawn
}

fun addPlayerLine(line: PlayerContentLine) {
val lineIndex = lines.size
lines.add(line)
if (viewers.isEmpty()) return
viewers.forEach(::updateFull)
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/io/github/dockyardmc/apis/sidebar/Sidebar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ class Sidebar(initialTitle: String, initialLines: Map<Int, SidebarLine>) : Viewa
}

fun setGlobalLine(index: Int, value: String) {
if (viewers.isEmpty()) return
val before = indexToLineMap[index] as SidebarLine.Static?
indexToLineMap[index] = SidebarLine.Static(value)
if (before?.value != value) viewers.forEach { viewer -> sendLinePacket(viewer, index) }
}

fun setPlayerLine(index: Int, value: (Player) -> String) {
if (viewers.isEmpty()) return
indexToLineMap[index] = SidebarLine.Player(value)
viewers.forEach { viewer -> sendLinePacket(viewer, index) }
}
Expand Down Expand Up @@ -116,6 +118,7 @@ class Sidebar(initialTitle: String, initialLines: Map<Int, SidebarLine>) : Viewa

init {
title.valueChanged { event ->
if (viewers.isEmpty()) return@valueChanged
val packet = ClientboundScoreboardObjectivePacket(objective, ScoreboardMode.EDIT_TEXT, event.newValue, ScoreboardType.INTEGER)
viewers.sendPacket(packet)
}
Expand Down
92 changes: 0 additions & 92 deletions src/main/kotlin/io/github/dockyardmc/bindables/BindablePairMap.kt

This file was deleted.

21 changes: 0 additions & 21 deletions src/main/kotlin/io/github/dockyardmc/data/DataComponentHasher.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import io.github.dockyardmc.data.components.*
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import java.util.concurrent.atomic.AtomicInteger
import kotlin.reflect.KClass

object DataComponentRegistry {

val protocolIdCounter = AtomicInteger()
var protocolIdCounter = 0
val dataComponentsById = Int2ObjectOpenHashMap<KClass<out DataComponent>>()
val dataComponentsByIdentifier = Object2ObjectOpenHashMap<String, KClass<out DataComponent>>()

Expand Down Expand Up @@ -113,13 +112,14 @@ object DataComponentRegistry {
val SHULKER_COLOR = register("minecraft:shulker/color", ShulkerColorComponent::class)

fun register(identifier: String, kclass: KClass<out DataComponent>): KClass<out DataComponent> {
val protocolId = protocolIdCounter.getAndIncrement()
val protocolId = protocolIdCounter
dataComponentsById[protocolId] = kclass
dataComponentsByIdReversed[kclass] = protocolId

dataComponentsByIdentifier[identifier] = kclass
dataComponentsByIdentifierReversed[kclass] = identifier

protocolIdCounter++
return kclass
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PotionContentsComponent(
override fun write(buffer: ByteBuf) {
buffer.writeOptional(potion?.getProtocolId(), ByteBuf::writeVarInt)
buffer.writeOptional(customColor, CustomColor::writePackedInt)
buffer.writeList(effects, ByteBuf::writeAppliedPotionEffect)
buffer.writeList(effects, AppliedPotionEffect::write)
buffer.writeOptional(customName, ByteBuf::writeString)
}

Expand All @@ -42,7 +42,7 @@ class PotionContentsComponent(
return PotionContentsComponent(
buffer.readOptional(ByteBuf::readVarInt)?.let { PotionTypeRegistry.getByProtocolId(it) },
buffer.readOptional(ByteBuf::readInt)?.let { CustomColor.fromRGBInt(it) },
buffer.readAppliedPotionEffectsList(),
buffer.readList(AppliedPotionEffect::read),
buffer.readOptional(ByteBuf::readString)
)
}
Expand Down
29 changes: 20 additions & 9 deletions src/main/kotlin/io/github/dockyardmc/events/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@ interface Event {
other: Set<Any> = setOf<Any>(),
val isGlobalEvent: Boolean = false
) {
// what the fuck
val players = players + entities.filterIsInstance<Player>()
var entities = entities + players
val locations = locations + this.entities.map { it.location }
val worlds = worlds + this.locations.map { it.world }
// combining sets is expensive and is done in initialization of every event.
// In most cases, either none or only one is accessed. Let's make them lazy so they are
// computed only when needed
val players: Set<Player> by lazy {
players + entities.filterIsInstance<Player>()
}

val other: Set<Any> = this.players + this.entities + this.worlds + this.locations + other
val entities: Set<Entity> by lazy {
entities + players
}

operator fun contains(element: Any) = other.contains(element)
val locations: Set<Location> by lazy {
locations + this.entities.map { entity -> entity.location }
}
val worlds: Set<World> by lazy {
worlds + this.locations.map { location -> location.world }
}

val other: Set<Any> by lazy {
this.players + this.entities + this.worlds + this.locations + other
}

// i hate everything about this
// please suggest something better.
operator fun contains(element: Any) = other.contains(element)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package io.github.dockyardmc.events.system
import io.github.dockyardmc.events.*
import io.github.dockyardmc.events.EventListener
import io.github.dockyardmc.utils.Disposable
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import java.util.*
import kotlin.reflect.KClass

@Suppress("UNCHECKED_CAST")
abstract class EventSystem : Disposable {
val eventMap = mutableMapOf<KClass<out Event>, HandlerList>()
val eventMap = Object2ObjectOpenHashMap<KClass<out Event>, HandlerList>()
var filter = EventFilter.empty()

val children = ObjectOpenHashSet<EventSystem>()
Expand Down
Loading
Loading