forked from ChomeNS/chomens-bot-java
fix chat.type.text after ages
This commit is contained in:
parent
6f5587c232
commit
2dec676bdc
1 changed files with 5 additions and 12 deletions
|
@ -1,19 +1,16 @@
|
||||||
package land.chipmunk.chayapak.chomens_bot.chatParsers;
|
package land.chipmunk.chayapak.chomens_bot.chatParsers;
|
||||||
|
|
||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
|
||||||
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.ChatParser;
|
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.ChatParser;
|
||||||
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.MutablePlayerListEntry;
|
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.MutablePlayerListEntry;
|
||||||
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.PlayerMessage;
|
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.PlayerMessage;
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MinecraftChatParser implements ChatParser {
|
public class MinecraftChatParser implements ChatParser {
|
||||||
private final Bot bot;
|
private final Bot bot;
|
||||||
|
@ -48,14 +45,10 @@ public class MinecraftChatParser implements ChatParser {
|
||||||
final Component senderComponent = args.get(0);
|
final Component senderComponent = args.get(0);
|
||||||
final Component contents = args.get(1);
|
final Component contents = args.get(1);
|
||||||
|
|
||||||
// try to find the sender then make it a player list entry
|
final String stringUsername = ComponentUtilities.stringify(senderComponent);
|
||||||
final HoverEvent<?> hoverEvent = senderComponent.hoverEvent();
|
MutablePlayerListEntry sender = bot.players().getEntry(stringUsername);
|
||||||
if (hoverEvent == null || !hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) return null;
|
|
||||||
HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
|
|
||||||
final UUID senderUUID = entityInfo.id();
|
|
||||||
|
|
||||||
MutablePlayerListEntry sender = bot.players().getEntry(senderUUID);
|
if (sender == null) return null;
|
||||||
if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(senderUUID, null), GameMode.SURVIVAL, 0, entityInfo.name(), 0L, null, new byte[0]);
|
|
||||||
|
|
||||||
parameters.put("sender", senderComponent);
|
parameters.put("sender", senderComponent);
|
||||||
parameters.put("contents", contents);
|
parameters.put("contents", contents);
|
||||||
|
|
Loading…
Reference in a new issue