Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Custom chat types at login are valid
Fixes https://github.com/GeyserMC/Geyser-Fabric/issues/55
Dieser Commit ist enthalten in:
Ursprung
aa097ecdc4
Commit
ddd2262380
@ -155,7 +155,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.GeyserMC</groupId>
|
<groupId>com.github.GeyserMC</groupId>
|
||||||
<artifactId>MCProtocolLib</artifactId>
|
<artifactId>MCProtocolLib</artifactId>
|
||||||
<version>bb2b414</version>
|
<version>54fc9f0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -80,6 +80,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
@ -499,7 +501,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
* Stores a map of all statistics sent from the server.
|
* Stores a map of all statistics sent from the server.
|
||||||
* The server only sends new statistics back to us, so in order to show all statistics we need to cache existing ones.
|
* The server only sends new statistics back to us, so in order to show all statistics we need to cache existing ones.
|
||||||
*/
|
*/
|
||||||
private final Map<Statistic, Integer> statistics = new HashMap<>();
|
private final Object2IntMap<Statistic> statistics = new Object2IntOpenHashMap<>(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether we're expecting statistics to be sent back to us.
|
* Whether we're expecting statistics to be sent back to us.
|
||||||
@ -1688,7 +1690,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
|||||||
*
|
*
|
||||||
* @param statistics Updated statistics values
|
* @param statistics Updated statistics values
|
||||||
*/
|
*/
|
||||||
public void updateStatistics(@NonNull Map<Statistic, Integer> statistics) {
|
public void updateStatistics(@Nonnull Object2IntMap<Statistic> statistics) {
|
||||||
if (this.statistics.isEmpty()) {
|
if (this.statistics.isEmpty()) {
|
||||||
// Initialize custom statistics to 0, so that they appear in the form
|
// Initialize custom statistics to 0, so that they appear in the form
|
||||||
for (CustomStatistic customStatistic : CustomStatistic.values()) {
|
for (CustomStatistic customStatistic : CustomStatistic.values()) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.translator.protocol.java;
|
package org.geysermc.geyser.translator.protocol.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.MessageType;
|
import com.github.steveice10.mc.protocol.data.game.BuiltinChatType;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
@ -82,14 +82,15 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
|||||||
textDecoration = new TextDecoration(decorationTag);
|
textDecoration = new TextDecoration(decorationTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageType type = MessageType.from(((StringTag) tag.get("name")).getValue());
|
BuiltinChatType type = BuiltinChatType.from(((StringTag) tag.get("name")).getValue());
|
||||||
// TODO new types?
|
// TODO new types?
|
||||||
TextPacket.Type bedrockType = switch (type) {
|
// The built-in type can be null if custom plugins/mods add in new types
|
||||||
|
TextPacket.Type bedrockType = type != null ? switch (type) {
|
||||||
case CHAT -> TextPacket.Type.CHAT;
|
case CHAT -> TextPacket.Type.CHAT;
|
||||||
case SYSTEM -> TextPacket.Type.SYSTEM;
|
case SYSTEM -> TextPacket.Type.SYSTEM;
|
||||||
case GAME_INFO -> TextPacket.Type.TIP;
|
case GAME_INFO -> TextPacket.Type.TIP;
|
||||||
default -> TextPacket.Type.RAW;
|
default -> TextPacket.Type.RAW;
|
||||||
};
|
} : TextPacket.Type.RAW;
|
||||||
chatTypes.put(id, new ChatTypeEntry(bedrockType, textDecoration));
|
chatTypes.put(id, new ChatTypeEntry(bedrockType, textDecoration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren