Skip to content

Commit e82e7c7

Browse files
author
games647
committed
Fix manual name change workaround for floodgate with 1.19
Fixes TuxCoding#854
1 parent 8df5b11 commit e82e7c7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ManualNameChange.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
3434
import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
3535

36+
import java.util.UUID;
37+
3638
import org.geysermc.floodgate.api.FloodgateApi;
3739

3840
import static com.comphenix.protocol.PacketType.Login.Client.START;
@@ -78,7 +80,15 @@ public void onPacketReceiving(PacketEvent packetEvent) {
7880

7981
packet.setMeta("original_name", originalProfile.getName());
8082
String prefixedName = FloodgateApi.getInstance().getPlayerPrefix() + originalProfile.getName();
81-
WrappedGameProfile updatedProfile = originalProfile.withName(prefixedName);
82-
packet.getGameProfiles().write(0, updatedProfile);
83+
setUsername(packet, prefixedName);
84+
}
85+
86+
private void setUsername(PacketContainer packet, String name) {
87+
if (packet.getGameProfiles().size() > 0) {
88+
WrappedGameProfile updatedProfile = new WrappedGameProfile(UUID.randomUUID(), name);
89+
packet.getGameProfiles().write(0, updatedProfile);
90+
} else {
91+
packet.getStrings().write(0, name);
92+
}
8393
}
8494
}

0 commit comments

Comments
 (0)