diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/scoreboard/ScoreboardEntry.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/scoreboard/ScoreboardEntry.kt
new file mode 100644
index 000000000..33434bfb0
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/scoreboard/ScoreboardEntry.kt
@@ -0,0 +1,29 @@
+/*
+ * Minosoft
+ * Copyright (C) 2021 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.gui.rendering.gui.hud.elements.scoreboard
+
+import de.bixilon.minosoft.gui.rendering.gui.elements.Element
+import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
+import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
+import glm_.vec2.Vec2i
+
+class ScoreboardEntry(hudRenderer: HUDRenderer) : Element(hudRenderer) {
+ override fun render(offset: Vec2i, z: Int, consumer: GUIVertexConsumer): Int {
+ TODO("Not yet implemented")
+ }
+
+ override fun silentApply() {
+ TODO("Not yet implemented")
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/tab/TabListElement.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/tab/TabListElement.kt
index e36790d38..1424fd9ee 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/tab/TabListElement.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/elements/tab/TabListElement.kt
@@ -95,6 +95,7 @@ class TabListElement(hudRenderer: HUDRenderer) : Element(hudRenderer) {
val toRender: MutableList = mutableListOf()
+ // ToDo: Sorting isn't working correct: java.lang.IllegalArgumentException: Comparison method violates its general contract!
val tabListItems = hudRenderer.connection.tabList.tabListItemsByUUID.toSynchronizedMap().entries.sortedWith { a, b -> a.value.compareTo(b.value) }
val previousSize = Vec2i(size)
diff --git a/src/main/java/de/bixilon/minosoft/modding/event/events/PlayerListItemChangeEvent.kt b/src/main/java/de/bixilon/minosoft/modding/event/events/PlayerListItemChangeEvent.kt
deleted file mode 100644
index 145db1e23..000000000
--- a/src/main/java/de/bixilon/minosoft/modding/event/events/PlayerListItemChangeEvent.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Minosoft
- * Copyright (C) 2020 Moritz Zwerger
- *
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- *
- * This software is not affiliated with Mojang AB, the original developer of Minecraft.
- */
-package de.bixilon.minosoft.modding.event.events
-
-import de.bixilon.minosoft.data.player.tab.TabListItemData
-import de.bixilon.minosoft.modding.event.EventInitiators
-import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
-import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
-import de.bixilon.minosoft.protocol.packets.s2c.play.TabListDataS2CP
-import java.util.*
-
-class PlayerListItemChangeEvent(
- connection: PlayConnection,
- initiator: EventInitiators,
- val items: Map,
-) : PlayConnectionEvent(connection, initiator), CancelableEvent {
-
- constructor(connection: PlayConnection, packet: TabListDataS2CP) : this(connection, EventInitiators.SERVER, packet.items)
-}
diff --git a/src/main/java/de/bixilon/minosoft/modding/event/events/TabListEntryChangeEvent.kt b/src/main/java/de/bixilon/minosoft/modding/event/events/TabListEntryChangeEvent.kt
index 43f2ec6f0..75f9532ec 100644
--- a/src/main/java/de/bixilon/minosoft/modding/event/events/TabListEntryChangeEvent.kt
+++ b/src/main/java/de/bixilon/minosoft/modding/event/events/TabListEntryChangeEvent.kt
@@ -23,7 +23,7 @@ class TabListEntryChangeEvent(
connection: PlayConnection,
initiator: EventInitiators,
val items: Map,
-) : PlayConnectionEvent(connection, initiator), CancelableEvent {
+) : PlayConnectionEvent(connection, initiator) {
constructor(connection: PlayConnection, packet: TabListDataS2CP) : this(connection, EventInitiators.SERVER, packet.items)
}
diff --git a/src/main/java/de/bixilon/minosoft/modding/event/invoker/CallbackEventInvoker.kt b/src/main/java/de/bixilon/minosoft/modding/event/invoker/CallbackEventInvoker.kt
index e3f3b9bdc..f49a73991 100644
--- a/src/main/java/de/bixilon/minosoft/modding/event/invoker/CallbackEventInvoker.kt
+++ b/src/main/java/de/bixilon/minosoft/modding/event/invoker/CallbackEventInvoker.kt
@@ -15,6 +15,7 @@ package de.bixilon.minosoft.modding.event.invoker
import de.bixilon.minosoft.modding.event.events.CancelableEvent
import de.bixilon.minosoft.modding.event.events.Event
import de.bixilon.minosoft.modding.loading.Priorities
+import de.bixilon.minosoft.util.KUtil.unsafeCast
import kotlin.reflect.KClass
class CallbackEventInvoker private constructor(
@@ -29,7 +30,7 @@ class CallbackEventInvoker private constructor(
if (!this.isIgnoreCancelled && event is CancelableEvent && event.cancelled) {
return
}
- callback(event as E)
+ callback(event.unsafeCast())
}
companion object {
diff --git a/src/main/java/de/bixilon/minosoft/modding/event/master/EventMaster.kt b/src/main/java/de/bixilon/minosoft/modding/event/master/EventMaster.kt
index e25014a90..ace1598b4 100644
--- a/src/main/java/de/bixilon/minosoft/modding/event/master/EventMaster.kt
+++ b/src/main/java/de/bixilon/minosoft/modding/event/master/EventMaster.kt
@@ -49,7 +49,11 @@ open class EventMaster(vararg parents: AbstractEventMaster) : AbstractEventMaste
if (!invoker.eventType.isAssignableFrom(event::class.java)) {
continue
}
- invoker(event)
+ try {
+ invoker(event)
+ } catch (exception: Throwable) {
+ exception.printStackTrace()
+ }
if (invoker is OneShotInvoker && invoker.oneShot) {
eventInvokers -= invoker
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/TabListDataS2CP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/TabListDataS2CP.kt
index 14eb03d15..4d5ae0f6e 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/TabListDataS2CP.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/TabListDataS2CP.kt
@@ -18,7 +18,6 @@ import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity
import de.bixilon.minosoft.data.player.PlayerProperty
import de.bixilon.minosoft.data.player.tab.TabListItem
import de.bixilon.minosoft.data.player.tab.TabListItemData
-import de.bixilon.minosoft.modding.event.events.PlayerListItemChangeEvent
import de.bixilon.minosoft.modding.event.events.TabListEntryChangeEvent
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
@@ -116,9 +115,6 @@ class TabListDataS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
}
override fun handle(connection: PlayConnection) {
- if (connection.fireEvent(PlayerListItemChangeEvent(connection, this))) {
- return
- }
for ((uuid, data) in items) {
// legacy
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/PutScoreboardScoreS2CP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/PutScoreboardScoreS2CP.kt
index 630e19866..0d4393fde 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/PutScoreboardScoreS2CP.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/PutScoreboardScoreS2CP.kt
@@ -36,6 +36,6 @@ class PutScoreboardScoreS2CP(val entity: String, buffer: PlayInByteBuffer) : Pla
override fun log() {
- Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Put scoreboard score (entity=$entity, objective=$objective, score=$score)" }
+ Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Put scoreboard score (entity=$entity§r, objective=$objective§r, score=$score)" }
}
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/RemoveScoreboardScoreS2CP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/RemoveScoreboardScoreS2CP.kt
index fecdf6e0f..c3c99b465 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/RemoveScoreboardScoreS2CP.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/RemoveScoreboardScoreS2CP.kt
@@ -16,26 +16,19 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.scoreboard.score
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
-import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
class RemoveScoreboardScoreS2CP(val entity: String, buffer: PlayInByteBuffer) : PlayS2CPacket() {
- val objective = if (buffer.versionId <= ProtocolVersions.V_14W04A) { // ToDo
- buffer.readString()
- } else {
- null
- }
+ val objective = buffer.readString()
override fun handle(connection: PlayConnection) {
- objective?.let {
- connection.scoreboardManager.objectives[it]?.scores?.remove(entity)
- } ?: TODO("Don't know where to remove null objective (entity=$entity)")
+ connection.scoreboardManager.objectives[objective]?.scores?.remove(entity)
}
override fun log() {
- Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Remove scoreboard score (entity=$entity, objective=$objective)" }
+ Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Remove scoreboard score (entity=$entity§r, objective=$objective§r)" }
}
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/ScoreboardScoreS2CF.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/ScoreboardScoreS2CF.kt
index 1a326096b..81e6cd456 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/ScoreboardScoreS2CF.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/scoreboard/score/ScoreboardScoreS2CF.kt
@@ -22,7 +22,7 @@ object ScoreboardScoreS2CF {
fun createPacket(buffer: PlayInByteBuffer): PlayS2CPacket {
val entity = buffer.readString()
- return when (ScoreboardScoreActions[buffer.readUnsignedByte()]) {
+ return when (ScoreboardScoreActions[buffer.readVarInt()]) {
ScoreboardScoreActions.PUT -> PutScoreboardScoreS2CP(entity, buffer)
ScoreboardScoreActions.REMOVE -> RemoveScoreboardScoreS2CP(entity, buffer)
}