Skip to content

Commit 03850ae

Browse files
committed
Only add Floodgate prefixes if they are needed
Without this patch, Java players would also get a prefix.
1 parent b92911b commit 03850ae

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void onEnable() {
120120

121121
if (isPluginInstalled("floodgate")) {
122122
if (getConfig().getBoolean("floodgatePrefixWorkaround")){
123-
ProtocolLibrary.getProtocolManager().addPacketListener(new ManualNameChange(this));
123+
ProtocolLibrary.getProtocolManager().addPacketListener(new ManualNameChange(this, floodgateService));
124124
logger.info("Floodgate prefix injection workaround has been enabled.");
125125
logger.info("If you have problems joining the server, try disabling it in the configuration.");
126126
} else {

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.comphenix.protocol.events.PacketEvent;
3131
import com.comphenix.protocol.wrappers.WrappedGameProfile;
3232
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
33+
import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
3334

3435
import org.geysermc.floodgate.api.FloodgateApi;
3536

@@ -45,18 +46,27 @@
4546
*/
4647
public class ManualNameChange extends PacketAdapter {
4748

48-
public ManualNameChange(FastLoginBukkit plugin) {
49+
private final FloodgateService floodgate;
50+
51+
public ManualNameChange(FastLoginBukkit plugin, FloodgateService floodgate) {
4952
super(params()
5053
.plugin(plugin)
5154
.types(START));
5255

5356
this.plugin = plugin;
57+
this.floodgate = floodgate;
5458
}
5559

5660
@Override
5761
public void onPacketReceiving(PacketEvent packetEvent) {
5862
PacketContainer packet = packetEvent.getPacket();
5963
WrappedGameProfile originalProfile = packet.getGameProfiles().read(0);
64+
65+
if (floodgate.getBedrockPlayer(originalProfile.getName()) == null) {
66+
//not a Floodgate player, no need to add a prefix
67+
return;
68+
}
69+
6070
packet.setMeta("original_name", originalProfile.getName());
6171
String prefixedName = FloodgateApi.getInstance().getPlayerPrefix() + originalProfile.getName();
6272
WrappedGameProfile updatedProfile = originalProfile.withName(prefixedName);

0 commit comments

Comments
 (0)