mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +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 (isPluginInstalled("floodgate")) {
|
||||||
if (getConfig().getBoolean("floodgatePrefixWorkaround")){
|
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("Floodgate prefix injection workaround has been enabled.");
|
||||||
logger.info("If you have problems joining the server, try disabling it in the configuration.");
|
logger.info("If you have problems joining the server, try disabling it in the configuration.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,6 +30,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
|||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
|
import com.github.games647.fastlogin.core.hooks.bedrock.FloodgateService;
|
||||||
|
|
||||||
import org.geysermc.floodgate.api.FloodgateApi;
|
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 class ManualNameChange extends PacketAdapter {
|
||||||
|
|
||||||
public ManualNameChange(FastLoginBukkit plugin) {
|
private final FloodgateService floodgate;
|
||||||
|
|
||||||
|
public ManualNameChange(FastLoginBukkit plugin, FloodgateService floodgate) {
|
||||||
super(params()
|
super(params()
|
||||||
.plugin(plugin)
|
.plugin(plugin)
|
||||||
.types(START));
|
.types(START));
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.floodgate = floodgate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent packetEvent) {
|
public void onPacketReceiving(PacketEvent packetEvent) {
|
||||||
PacketContainer packet = packetEvent.getPacket();
|
PacketContainer packet = packetEvent.getPacket();
|
||||||
WrappedGameProfile originalProfile = packet.getGameProfiles().read(0);
|
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());
|
packet.setMeta("original_name", originalProfile.getName());
|
||||||
String prefixedName = FloodgateApi.getInstance().getPlayerPrefix() + originalProfile.getName();
|
String prefixedName = FloodgateApi.getInstance().getPlayerPrefix() + originalProfile.getName();
|
||||||
WrappedGameProfile updatedProfile = originalProfile.withName(prefixedName);
|
WrappedGameProfile updatedProfile = originalProfile.withName(prefixedName);
|
||||||
|
Reference in New Issue
Block a user