mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
packets: split title packet into separate classes
This commit is contained in:
parent
f2cfe4bf9b
commit
212d0221c4
@ -16,7 +16,7 @@ package de.bixilon.minosoft.data.mappings
|
|||||||
import de.bixilon.minosoft.Minosoft
|
import de.bixilon.minosoft.Minosoft
|
||||||
import de.bixilon.minosoft.data.entities.meta.EntityMetaData
|
import de.bixilon.minosoft.data.entities.meta.EntityMetaData
|
||||||
import de.bixilon.minosoft.data.inventory.InventorySlots
|
import de.bixilon.minosoft.data.inventory.InventorySlots
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.PacketTitle
|
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.TitlePacketFactory
|
||||||
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
||||||
|
|
||||||
object DefaultRegistries {
|
object DefaultRegistries {
|
||||||
@ -30,7 +30,7 @@ object DefaultRegistries {
|
|||||||
|
|
||||||
val ENTITY_META_DATA_DATA_TYPES_REGISTRY = PerVersionRegistry(EntityMetaData.EntityMetaDataDataTypes)
|
val ENTITY_META_DATA_DATA_TYPES_REGISTRY = PerVersionRegistry(EntityMetaData.EntityMetaDataDataTypes)
|
||||||
|
|
||||||
val TITLE_ACTIONS_REGISTRY = PerVersionRegistry(PacketTitle.TitleActions)
|
val TITLE_ACTIONS_REGISTRY = PerVersionRegistry(TitlePacketFactory.TitleActions)
|
||||||
|
|
||||||
|
|
||||||
fun load() {
|
fun load() {
|
||||||
|
@ -40,7 +40,7 @@ import de.bixilon.minosoft.data.mappings.statistics.Statistic
|
|||||||
import de.bixilon.minosoft.gui.rendering.chunk.VoxelShape
|
import de.bixilon.minosoft.gui.rendering.chunk.VoxelShape
|
||||||
import de.bixilon.minosoft.gui.rendering.chunk.models.AABB
|
import de.bixilon.minosoft.gui.rendering.chunk.models.AABB
|
||||||
import de.bixilon.minosoft.gui.rendering.chunk.models.loading.BlockModel
|
import de.bixilon.minosoft.gui.rendering.chunk.models.loading.BlockModel
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.PacketTitle
|
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.TitlePacketFactory
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
import de.bixilon.minosoft.util.collections.Clearable
|
import de.bixilon.minosoft.util.collections.Clearable
|
||||||
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
||||||
@ -67,7 +67,7 @@ class VersionMapping(var version: Version?) {
|
|||||||
|
|
||||||
val entityMetaDataDataDataTypesRegistry: EnumRegistry<EntityMetaData.EntityMetaDataDataTypes> = EnumRegistry(values = EntityMetaData.EntityMetaDataDataTypes)
|
val entityMetaDataDataDataTypesRegistry: EnumRegistry<EntityMetaData.EntityMetaDataDataTypes> = EnumRegistry(values = EntityMetaData.EntityMetaDataDataTypes)
|
||||||
|
|
||||||
val titleActionsRegistry: EnumRegistry<PacketTitle.TitleActions> = EnumRegistry(values = PacketTitle.TitleActions)
|
val titleActionsRegistry: EnumRegistry<TitlePacketFactory.TitleActions> = EnumRegistry(values = TitlePacketFactory.TitleActions)
|
||||||
|
|
||||||
val creativeModeTabRegistry: FakeEnumRegistry<CreativeModeTab> = FakeEnumRegistry()
|
val creativeModeTabRegistry: FakeEnumRegistry<CreativeModeTab> = FakeEnumRegistry()
|
||||||
|
|
||||||
|
@ -1,73 +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.text.ChatComponent;
|
|
||||||
import de.bixilon.minosoft.protocol.network.Connection;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.PacketTitle;
|
|
||||||
|
|
||||||
public class TitleChangeEvent extends CancelableEvent {
|
|
||||||
private final PacketTitle.TitleActions action;
|
|
||||||
|
|
||||||
// fields depend on action
|
|
||||||
private final ChatComponent text;
|
|
||||||
private final ChatComponent subText;
|
|
||||||
private final int fadeInTime;
|
|
||||||
private final int stayTime;
|
|
||||||
private final int fadeOutTime;
|
|
||||||
|
|
||||||
public TitleChangeEvent(Connection connection, PacketTitle.TitleActions action, ChatComponent text, ChatComponent subText, int fadeInTime, int stayTime, int fadeOutTime) {
|
|
||||||
super(connection);
|
|
||||||
this.action = action;
|
|
||||||
this.text = text;
|
|
||||||
this.subText = subText;
|
|
||||||
this.fadeInTime = fadeInTime;
|
|
||||||
this.stayTime = stayTime;
|
|
||||||
this.fadeOutTime = fadeOutTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TitleChangeEvent(Connection connection, PacketTitle pkg) {
|
|
||||||
super(connection);
|
|
||||||
this.action = pkg.getAction();
|
|
||||||
this.text = pkg.getText();
|
|
||||||
this.subText = pkg.getSubText();
|
|
||||||
this.fadeInTime = pkg.getFadeInTime();
|
|
||||||
this.stayTime = pkg.getStayTime();
|
|
||||||
this.fadeOutTime = pkg.getFadeOutTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketTitle.TitleActions getAction() {
|
|
||||||
return this.action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatComponent getText() {
|
|
||||||
return this.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatComponent getSubText() {
|
|
||||||
return this.subText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFadeInTime() {
|
|
||||||
return this.fadeInTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStayTime() {
|
|
||||||
return this.stayTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFadeOutTime() {
|
|
||||||
return this.fadeOutTime;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
|
||||||
|
class HideTitlePacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.protocol("[IN] Received hide title")
|
||||||
|
}
|
||||||
|
}
|
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.protocol.packets.clientbound.play.title
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
|
||||||
import de.bixilon.minosoft.modding.event.events.TitleChangeEvent
|
|
||||||
import de.bixilon.minosoft.protocol.network.Connection
|
|
||||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
|
||||||
import de.bixilon.minosoft.util.KUtil
|
|
||||||
import de.bixilon.minosoft.util.enum.ValuesEnum
|
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
|
||||||
|
|
||||||
class PacketTitle(buffer: InByteBuffer) : ClientboundPacket() {
|
|
||||||
val action: TitleActions
|
|
||||||
|
|
||||||
// fields depend on action
|
|
||||||
var text: ChatComponent? = null
|
|
||||||
var subText: ChatComponent? = null
|
|
||||||
var fadeInTime = 0
|
|
||||||
var stayTime = 0
|
|
||||||
var fadeOutTime = 0
|
|
||||||
|
|
||||||
init {
|
|
||||||
action = buffer.connection.mapping.titleActionsRegistry.get(buffer.readVarInt())!!
|
|
||||||
when (action) {
|
|
||||||
TitleActions.SET_TITLE -> this.text = buffer.readChatComponent()
|
|
||||||
TitleActions.SET_SUBTITLE -> this.subText = buffer.readChatComponent()
|
|
||||||
TitleActions.SET_TIMES_AND_DISPLAY -> {
|
|
||||||
this.fadeInTime = buffer.readInt()
|
|
||||||
this.stayTime = buffer.readInt()
|
|
||||||
this.fadeOutTime = buffer.readInt()
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handle(connection: Connection) {
|
|
||||||
if (connection.fireEvent(TitleChangeEvent(connection, this))) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun log() {
|
|
||||||
when (this.action) {
|
|
||||||
TitleActions.SET_TITLE -> Log.protocol(String.format("[IN] Received title (action=%s, text=%s)", this.action, this.text?.ansiColoredMessage))
|
|
||||||
TitleActions.SET_SUBTITLE -> Log.protocol(String.format("[IN] Received title (action=%s, subText=%s)", this.action, this.subText?.ansiColoredMessage))
|
|
||||||
TitleActions.SET_TIMES_AND_DISPLAY -> Log.protocol(String.format("[IN] Received title (action=%s, fadeInTime=%d, stayTime=%d, fadeOutTime=%d)", this.action, this.fadeInTime, this.stayTime, this.fadeOutTime))
|
|
||||||
TitleActions.HIDE, TitleActions.RESET -> Log.protocol(String.format("[IN] Received title (action=%s)", this.action))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class TitleActions {
|
|
||||||
SET_TITLE,
|
|
||||||
SET_SUBTITLE,
|
|
||||||
SET_ACTION_BAR,
|
|
||||||
SET_TIMES_AND_DISPLAY,
|
|
||||||
HIDE,
|
|
||||||
RESET,
|
|
||||||
;
|
|
||||||
|
|
||||||
companion object : ValuesEnum<TitleActions> {
|
|
||||||
override val VALUES = values()
|
|
||||||
override val NAME_MAP = KUtil.getEnumValues(VALUES)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
|
||||||
|
class ResetTitlePacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.protocol("[IN] Received reset title")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.network.Connection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
|
||||||
|
class SetActionBarTextPacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||||
|
val actionBarText = buffer.readChatComponent()
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.protocol("[IN] Received set action bar title (actionBarText=$actionBarText)")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handle(connection: Connection) {
|
||||||
|
Log.game("[ACTION] $actionBarText")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
|
||||||
|
class SetSubTitlePacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||||
|
val subTtitle = buffer.readChatComponent()
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.protocol("[IN] Received title (subText=$subTtitle)")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
|
||||||
|
class SetTimesAndDisplayPacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||||
|
val fadeInTime = buffer.readInt()
|
||||||
|
val stayTime = buffer.readInt()
|
||||||
|
val fadeOutTime = buffer.readInt()
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.protocol("[IN] Received set time and display title (fadeInTime=$fadeInTime, stayTime=$stayTime, fadeOutTime=$fadeOutTime)")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
|
|
||||||
|
class SetTitlePacket(buffer: InByteBuffer) : ClientboundPacket() {
|
||||||
|
val text = buffer.readChatComponent()
|
||||||
|
|
||||||
|
override fun log() {
|
||||||
|
Log.protocol("[IN] Received set title (text=$text)")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.packets.clientbound.play.title
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InByteBuffer
|
||||||
|
import de.bixilon.minosoft.util.KUtil
|
||||||
|
import de.bixilon.minosoft.util.enum.ValuesEnum
|
||||||
|
|
||||||
|
object TitlePacketFactory {
|
||||||
|
|
||||||
|
fun createPacket(buffer: InByteBuffer): ClientboundPacket {
|
||||||
|
return when (buffer.connection.mapping.titleActionsRegistry.get(buffer.readVarInt())!!) {
|
||||||
|
TitleActions.SET_TITLE -> SetTitlePacket(buffer)
|
||||||
|
TitleActions.SET_SUBTITLE -> SetSubTitlePacket(buffer)
|
||||||
|
TitleActions.SET_ACTION_BAR -> SetActionBarTextPacket(buffer)
|
||||||
|
TitleActions.SET_TIMES_AND_DISPLAY -> SetTimesAndDisplayPacket(buffer)
|
||||||
|
TitleActions.HIDE -> HideTitlePacket(buffer)
|
||||||
|
TitleActions.RESET -> ResetTitlePacket(buffer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class TitleActions {
|
||||||
|
SET_TITLE,
|
||||||
|
SET_SUBTITLE,
|
||||||
|
SET_ACTION_BAR,
|
||||||
|
SET_TIMES_AND_DISPLAY,
|
||||||
|
HIDE,
|
||||||
|
RESET,
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object : ValuesEnum<TitleActions> {
|
||||||
|
override val VALUES = values()
|
||||||
|
override val NAME_MAP = KUtil.getEnumValues(VALUES)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.protocol.ErrorHandler
|
|||||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.login.*
|
import de.bixilon.minosoft.protocol.packets.clientbound.login.*
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.play.*
|
import de.bixilon.minosoft.protocol.packets.clientbound.play.*
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.PacketTitle
|
import de.bixilon.minosoft.protocol.packets.clientbound.play.title.TitlePacketFactory
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusPong
|
import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusPong
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusResponse
|
import de.bixilon.minosoft.protocol.packets.clientbound.status.PacketStatusResponse
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ class PacketTypes {
|
|||||||
PLAY_UPDATE_SIGN({ PacketUpdateSignReceiving(it) }),
|
PLAY_UPDATE_SIGN({ PacketUpdateSignReceiving(it) }),
|
||||||
PLAY_STATISTICS({ PacketStatistics(it) }),
|
PLAY_STATISTICS({ PacketStatistics(it) }),
|
||||||
PLAY_SPAWN_ENTITY({ PacketSpawnObject(it) }, false),
|
PLAY_SPAWN_ENTITY({ PacketSpawnObject(it) }, false),
|
||||||
PLAY_TITLE({ PacketTitle(it) }),
|
PLAY_TITLE({ TitlePacketFactory.createPacket(it) }),
|
||||||
PLAY_ENTITY_INITIALISATION({ PacketEntityInitialisation(it) }, false),
|
PLAY_ENTITY_INITIALISATION({ PacketEntityInitialisation(it) }, false),
|
||||||
PLAY_SET_COMPRESSION({ PacketSetCompression(it) }, false),
|
PLAY_SET_COMPRESSION({ PacketSetCompression(it) }, false),
|
||||||
PLAY_ADVANCEMENT_PROGRESS({ TODO() }),
|
PLAY_ADVANCEMENT_PROGRESS({ TODO() }),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user