mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-29 18:27:36 +02:00
Only add Floodgate prefixes if they are needed
Without this patch, Java players would also get a prefix.
This commit is contained in:
@ -120,7 +120,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
||||
|
||||
if (isPluginInstalled("floodgate")) {
|
||||
if (getConfig().getBoolean("floodgatePrefixWorkaround")){
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new ManualNameChange(this));
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(new ManualNameChange(this, floodgateService));
|
||||
logger.info("Floodgate prefix injection workaround has been enabled.");
|
||||
logger.info("If you have problems joining the server, try disabling it in the configuration.");
|
||||
} else {
|
||||
|
@ -30,6 +30,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||
import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
|
||||
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
|
||||
@ -45,18 +46,27 @@ import static com.comphenix.protocol.PacketType.Login.Client.START;
|
||||
*/
|
||||
public class ManualNameChange extends PacketAdapter {
|
||||
|
||||
public ManualNameChange(FastLoginBukkit plugin) {
|
||||
private final FloodgateService floodgate;
|
||||
|
||||
public ManualNameChange(FastLoginBukkit plugin, FloodgateService floodgate) {
|
||||
super(params()
|
||||
.plugin(plugin)
|
||||
.types(START));
|
||||
|
||||
this.plugin = plugin;
|
||||
this.floodgate = floodgate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||
PacketContainer packet = packetEvent.getPacket();
|
||||
WrappedGameProfile originalProfile = packet.getGameProfiles().read(0);
|
||||
|
||||
if (floodgate.getBedrockPlayer(originalProfile.getName()) == null) {
|
||||
//not a Floodgate player, no need to add a prefix
|
||||
return;
|
||||
}
|
||||
|
||||
packet.setMeta("original_name", originalProfile.getName());
|
||||
String prefixedName = FloodgateApi.getInstance().getPlayerPrefix() + originalProfile.getName();
|
||||
WrappedGameProfile updatedProfile = originalProfile.withName(prefixedName);
|
||||
|
Reference in New Issue
Block a user