use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class AsyncToggleMessage method activatePremium.
private void activatePremium() {
StoredProfile playerProfile = core.getStorage().loadProfile(targetPlayer);
if (playerProfile.isPremium()) {
sendMessage("already-exists");
return;
}
playerProfile.setPremium(true);
core.getStorage().save(playerProfile);
PremiumToggleReason reason = (!isPlayerSender || !sender.getName().equalsIgnoreCase(playerProfile.getName())) ? PremiumToggleReason.COMMAND_OTHER : PremiumToggleReason.COMMAND_SELF;
core.getPlugin().getProxy().getPluginManager().callEvent(new BungeeFastLoginPremiumToggleEvent(playerProfile, reason));
sendMessage("add-premium");
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class ConnectListener method onGameprofileRequest.
@Subscribe
public void onGameprofileRequest(GameProfileRequestEvent event) {
if (event.isOnlineMode()) {
LoginSession session = plugin.getSession().get(event.getConnection().getRemoteAddress());
UUID verifiedUUID = event.getGameProfile().getId();
String verifiedUsername = event.getUsername();
session.setUuid(verifiedUUID);
session.setVerifiedUsername(verifiedUsername);
StoredProfile playerProfile = session.getProfile();
playerProfile.setId(verifiedUUID);
if (!plugin.getCore().getConfig().get("premiumUuid", true)) {
UUID offlineUUID = UUIDAdapter.generateOfflineId(playerProfile.getName());
event.setGameProfile(event.getGameProfile().withId(offlineUUID));
plugin.getLog().info("Overridden UUID from {} to {} (based of {}) on {}", verifiedUUID, offlineUUID, verifiedUsername, event.getConnection());
}
if (!plugin.getCore().getConfig().get("forwardSkin", true)) {
event.setGameProfile(event.getGameProfile().withProperties(removeSkin(event.getGameProfile().getProperties())));
}
}
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class AsyncToggleMessage method activatePremium.
private void activatePremium() {
StoredProfile playerProfile = core.getStorage().loadProfile(targetPlayer);
if (playerProfile.isPremium()) {
sendMessage("already-exists");
return;
}
playerProfile.setPremium(true);
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("add-premium");
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class FloodgateManagement method run.
@Override
public void run() {
core.getPlugin().getLog().info("Player {} is connecting through Geyser Floodgate.", username);
// check if the Bedrock player is linked to a Java account
isLinked = floodgatePlayer.getLinkedPlayer() != null;
// if that's the case, players will be logged in via plugin messages
if (core.getStorage() == null) {
return;
}
profile = core.getStorage().loadProfile(username);
AuthPlugin<P> authPlugin = core.getAuthPluginHook();
try {
// maybe Bungee without auth plugin
if (authPlugin == null) {
if (profile != null) {
isRegistered = profile.isPremium();
} else {
isRegistered = false;
}
} else {
isRegistered = authPlugin.isRegistered(username);
}
} catch (Exception ex) {
core.getPlugin().getLog().error("An error has occured while checking if player {} is registered", username, ex);
return;
}
// decide if checks should be made for conflicting Java player names
if (isNameCheckRequired()) {
// check for conflicting Premium Java name
Optional<Profile> premiumUUID = Optional.empty();
try {
premiumUUID = core.getResolver().findProfile(username);
} catch (IOException | RateLimitException e) {
core.getPlugin().getLog().error("Could not check whether Floodgate Player {}'s name conflicts a premium Java account's name.", username, e);
return;
}
// stop execution if player's name is conflicting
if (premiumUUID.isPresent()) {
return;
}
}
if (!isRegistered && !isAutoAuthAllowed(autoRegisterFloodgate)) {
return;
}
// logging in from bedrock for a second time threw an error with UUID
if (profile == null) {
profile = new StoredProfile(getUUID(player), username, true, getAddress(player).toString());
}
// start Bukkit/Bungee specific tasks
startLogin();
}
use of com.github.games647.fastlogin.core.StoredProfile in project FastLogin by games647.
the class ForceLoginManagement method run.
@Override
public void run() {
if (!isOnline(player)) {
core.getPlugin().getLog().info("Player {} disconnected", player);
return;
}
if (session == null) {
core.getPlugin().getLog().info("No valid session found for {}", player);
return;
}
SQLStorage storage = core.getStorage();
StoredProfile playerProfile = session.getProfile();
try {
if (isOnlineMode()) {
// premium player
AuthPlugin<P> authPlugin = core.getAuthPluginHook();
if (authPlugin == null) {
// maybe only bungeecord plugin
onForceActionSuccess(session);
} else {
boolean success = true;
String playerName = getName(player);
if (core.getConfig().get("autoLogin", true)) {
if (session.needsRegistration() || (core.getConfig().get("auto-register-unknown", false) && !authPlugin.isRegistered(playerName))) {
success = forceRegister(player);
} else if (!callFastLoginAutoLoginEvent(session, playerProfile).isCancelled()) {
success = forceLogin(player);
}
}
if (success) {
// update only on success to prevent corrupt data
if (playerProfile != null) {
playerProfile.setId(session.getUuid());
playerProfile.setPremium(true);
storage.save(playerProfile);
}
onForceActionSuccess(session);
}
}
} else if (playerProfile != null) {
// cracked player
playerProfile.setId(null);
playerProfile.setPremium(false);
storage.save(playerProfile);
}
} catch (Exception ex) {
core.getPlugin().getLog().warn("ERROR ON FORCE LOGIN of {}", getName(player), ex);
}
}
Aggregations