mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
fix some scoreboard issues
This commit is contained in:
parent
04c154d42d
commit
18842d9a51
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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")
|
||||
}
|
||||
}
|
@ -95,6 +95,7 @@ class TabListElement(hudRenderer: HUDRenderer) : Element(hudRenderer) {
|
||||
|
||||
val toRender: MutableList<TabListEntryElement> = 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)
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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<UUID, TabListItemData>,
|
||||
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||
|
||||
constructor(connection: PlayConnection, packet: TabListDataS2CP) : this(connection, EventInitiators.SERVER, packet.items)
|
||||
}
|
@ -23,7 +23,7 @@ class TabListEntryChangeEvent(
|
||||
connection: PlayConnection,
|
||||
initiator: EventInitiators,
|
||||
val items: Map<UUID, TabListItemData>,
|
||||
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||
) : PlayConnectionEvent(connection, initiator) {
|
||||
|
||||
constructor(connection: PlayConnection, packet: TabListDataS2CP) : this(connection, EventInitiators.SERVER, packet.items)
|
||||
}
|
||||
|
@ -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<E : Event> private constructor(
|
||||
@ -29,7 +30,7 @@ class CallbackEventInvoker<E : Event> private constructor(
|
||||
if (!this.isIgnoreCancelled && event is CancelableEvent && event.cancelled) {
|
||||
return
|
||||
}
|
||||
callback(event as E)
|
||||
callback(event.unsafeCast())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)" }
|
||||
}
|
||||
}
|
||||
|
@ -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)" }
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user