Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02: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>
|
||||
<groupId>com.github.GeyserMC</groupId>
|
||||
<artifactId>MCProtocolLib</artifactId>
|
||||
<version>bb2b414</version>
|
||||
<version>54fc9f0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -80,6 +80,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
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.ObjectOpenHashSet;
|
||||
import lombok.AccessLevel;
|
||||
@ -499,7 +501,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
@ -1688,7 +1690,7 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
*
|
||||
* @param statistics Updated statistics values
|
||||
*/
|
||||
public void updateStatistics(@NonNull Map<Statistic, Integer> statistics) {
|
||||
public void updateStatistics(@Nonnull Object2IntMap<Statistic> statistics) {
|
||||
if (this.statistics.isEmpty()) {
|
||||
// Initialize custom statistics to 0, so that they appear in the form
|
||||
for (CustomStatistic customStatistic : CustomStatistic.values()) {
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
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.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
@ -82,14 +82,15 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
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?
|
||||
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 SYSTEM -> TextPacket.Type.SYSTEM;
|
||||
case GAME_INFO -> TextPacket.Type.TIP;
|
||||
default -> TextPacket.Type.RAW;
|
||||
};
|
||||
} : TextPacket.Type.RAW;
|
||||
chatTypes.put(id, new ChatTypeEntry(bedrockType, textDecoration));
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren