use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class PluginMessageListener method onSuccessMessage.
private void onSuccessMessage(Player forPlayer) {
if (forPlayer.isOnlineMode()) {
// bukkit module successfully received and force logged in the user
// update only on success to prevent corrupt data
VelocityLoginSession loginSession = plugin.getSession().get(forPlayer.getRemoteAddress());
StoredProfile playerProfile = loginSession.getProfile();
loginSession.setRegistered(true);
if (!loginSession.isAlreadySaved()) {
playerProfile.setPremium(true);
plugin.getCore().getStorage().save(playerProfile);
loginSession.setAlreadySaved(true);
}
}
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class AsyncPremiumCheck method requestPremiumLogin.
@Override
public void requestPremiumLogin(VelocityLoginSource source, StoredProfile profile, String username, boolean registered) {
source.enableOnlinemode();
plugin.getSession().put(source.getConnection().getRemoteAddress(), new VelocityLoginSession(username, registered, profile));
String ip = source.getAddress().getAddress().getHostAddress();
plugin.getCore().getPendingLogin().put(ip + username, new Object());
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class AsyncToggleMessage method turnOffPremium.
private void turnOffPremium() {
StoredProfile playerProfile = core.getStorage().loadProfile(targetPlayer);
// existing player is already cracked
if (playerProfile.isSaved() && !playerProfile.isPremium()) {
sendMessage("not-premium");
return;
}
playerProfile.setPremium(false);
playerProfile.setId(null);
core.getStorage().save(playerProfile);
PremiumToggleReason reason = (!isPlayerSender || !senderName.equalsIgnoreCase(playerProfile.getName())) ? PremiumToggleReason.COMMAND_OTHER : PremiumToggleReason.COMMAND_SELF;
core.getPlugin().getProxy().getEventManager().fire(new VelocityFastLoginPremiumToggleEvent(playerProfile, reason));
sendMessage("remove-premium");
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class ConnectListener method onLogin.
@EventHandler(priority = EventPriority.LOWEST)
public void onLogin(LoginEvent loginEvent) {
if (loginEvent.isCancelled()) {
return;
}
// use the login event instead of the post login event in order to send the login success packet to the client
// with the offline uuid this makes it possible to set the skin then
PendingConnection connection = loginEvent.getConnection();
if (connection.isOnlineMode()) {
LoginSession session = plugin.getSession().get(connection);
UUID verifiedUUID = connection.getUniqueId();
String verifiedUsername = connection.getName();
session.setUuid(verifiedUUID);
session.setVerifiedUsername(verifiedUsername);
StoredProfile playerProfile = session.getProfile();
playerProfile.setId(verifiedUUID);
// bungeecord will do this automatically so override it on disabled option
if (uniqueIdSetter != null) {
InitialHandler initialHandler = (InitialHandler) connection;
if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
setOfflineId(initialHandler, verifiedUsername);
}
if (!plugin.getCore().getConfig().get("forwardSkin", true)) {
// this is null on offline mode
LoginResult loginProfile = initialHandler.getLoginProfile();
loginProfile.setProperties(emptyProperties);
}
}
}
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class AsyncPremiumCheck method requestPremiumLogin.
@Override
public void requestPremiumLogin(BungeeLoginSource source, StoredProfile profile, String username, boolean registered) {
source.enableOnlinemode();
plugin.getSession().put(source.getConnection(), new BungeeLoginSession(username, registered, profile));
String ip = source.getAddress().getAddress().getHostAddress();
plugin.getCore().getPendingLogin().put(ip + username, new Object());
}
Aggregations