mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Correctly set the offline UUID in ProtocolSupport (Thanks to @Shevchik)
This commit is contained in:
@ -1,19 +1,21 @@
|
|||||||
package com.github.games647.fastlogin.bukkit.listener.protocolsupport;
|
package com.github.games647.fastlogin.bukkit.listener.protocolsupport;
|
||||||
|
|
||||||
|
import com.github.games647.craftapi.UUIDAdapter;
|
||||||
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
|
||||||
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
|
||||||
import com.github.games647.fastlogin.core.StoredProfile;
|
import com.github.games647.fastlogin.core.StoredProfile;
|
||||||
import com.github.games647.fastlogin.core.shared.JoinManagement;
|
import com.github.games647.fastlogin.core.shared.JoinManagement;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import protocolsupport.api.events.ConnectionCloseEvent;
|
import protocolsupport.api.events.ConnectionCloseEvent;
|
||||||
import protocolsupport.api.events.PlayerLoginFinishEvent;
|
|
||||||
import protocolsupport.api.events.PlayerLoginStartEvent;
|
import protocolsupport.api.events.PlayerLoginStartEvent;
|
||||||
|
import protocolsupport.api.events.PlayerProfileCompleteEvent;
|
||||||
|
|
||||||
public class ProtocolSupportListener extends JoinManagement<Player, CommandSender, ProtocolLoginSource>
|
public class ProtocolSupportListener extends JoinManagement<Player, CommandSender, ProtocolLoginSource>
|
||||||
implements Listener {
|
implements Listener {
|
||||||
@ -48,16 +50,18 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPropertiesResolve(PlayerLoginFinishEvent loginFinishEvent) {
|
public void onPropertiesResolve(PlayerProfileCompleteEvent profileCompleteEvent) {
|
||||||
if (!loginFinishEvent.isOnlineMode()) {
|
InetSocketAddress address = profileCompleteEvent.getAddress();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InetSocketAddress address = loginFinishEvent.getAddress();
|
|
||||||
BukkitLoginSession session = plugin.getLoginSessions().get(address.toString());
|
BukkitLoginSession session = plugin.getLoginSessions().get(address.toString());
|
||||||
|
|
||||||
if (session != null) {
|
if (session != null && profileCompleteEvent.getConnection().getProfile().isOnlineMode()) {
|
||||||
session.setVerified(true);
|
session.setVerified(true);
|
||||||
|
|
||||||
|
if (!plugin.getConfig().getBoolean("premiumUuid")) {
|
||||||
|
String username = Optional.ofNullable(profileCompleteEvent.getForcedName())
|
||||||
|
.orElse(profileCompleteEvent.getConnection().getProfile().getName());
|
||||||
|
profileCompleteEvent.setForcedUUID(UUIDAdapter.generateOfflineId(username));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user