Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-14 12:00:09 +01:00
Handle both json and plain text in CommonBoss (#3981)
Dieser Commit ist enthalten in:
Ursprung
5a0ca55b97
Commit
8606e5d663
@ -19,6 +19,7 @@ package com.viaversion.viaversion.legacy.bossbar;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.legacy.bossbar.BossBar;
|
||||
@ -26,7 +27,6 @@ import com.viaversion.viaversion.api.legacy.bossbar.BossColor;
|
||||
import com.viaversion.viaversion.api.legacy.bossbar.BossFlag;
|
||||
import com.viaversion.viaversion.api.legacy.bossbar.BossStyle;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9;
|
||||
@ -247,7 +247,11 @@ public class CommonBoss implements BossBar {
|
||||
wrapper.write(Types.VAR_INT, action.getId());
|
||||
switch (action) {
|
||||
case ADD:
|
||||
wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(title));
|
||||
try {
|
||||
wrapper.write(Types.COMPONENT, JsonParser.parseString(this.title));
|
||||
} catch (Exception e) {
|
||||
wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(this.title));
|
||||
}
|
||||
wrapper.write(Types.FLOAT, health);
|
||||
wrapper.write(Types.VAR_INT, color.getId());
|
||||
wrapper.write(Types.VAR_INT, style.getId());
|
||||
@ -259,7 +263,11 @@ public class CommonBoss implements BossBar {
|
||||
wrapper.write(Types.FLOAT, health);
|
||||
break;
|
||||
case UPDATE_TITLE:
|
||||
wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(title));
|
||||
try {
|
||||
wrapper.write(Types.COMPONENT, JsonParser.parseString(this.title));
|
||||
} catch (Exception e) {
|
||||
wrapper.write(Types.COMPONENT, ComponentUtil.plainToJson(this.title));
|
||||
}
|
||||
break;
|
||||
case UPDATE_STYLE:
|
||||
wrapper.write(Types.VAR_INT, color.getId());
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren