Search in sources :

Example 1 with PremiumToggleReason

use of com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason 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");
}
Also used : StoredProfile(com.github.games647.fastlogin.core.StoredProfile) VelocityFastLoginPremiumToggleEvent(com.github.games647.fastlogin.velocity.event.VelocityFastLoginPremiumToggleEvent) PremiumToggleReason(com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason)

Example 2 with PremiumToggleReason

use of com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason 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 || !sender.getName().equalsIgnoreCase(playerProfile.getName())) ? PremiumToggleReason.COMMAND_OTHER : PremiumToggleReason.COMMAND_SELF;
    core.getPlugin().getProxy().getPluginManager().callEvent(new BungeeFastLoginPremiumToggleEvent(playerProfile, reason));
    sendMessage("remove-premium");
}
Also used : StoredProfile(com.github.games647.fastlogin.core.StoredProfile) PremiumToggleReason(com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason) BungeeFastLoginPremiumToggleEvent(com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent)

Example 3 with PremiumToggleReason

use of com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason 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");
}
Also used : StoredProfile(com.github.games647.fastlogin.core.StoredProfile) PremiumToggleReason(com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason) BungeeFastLoginPremiumToggleEvent(com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent)

Example 4 with PremiumToggleReason

use of com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason 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");
}
Also used : StoredProfile(com.github.games647.fastlogin.core.StoredProfile) VelocityFastLoginPremiumToggleEvent(com.github.games647.fastlogin.velocity.event.VelocityFastLoginPremiumToggleEvent) PremiumToggleReason(com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason)

Aggregations

StoredProfile (com.github.games647.fastlogin.core.StoredProfile)4 PremiumToggleReason (com.github.games647.fastlogin.core.shared.event.FastLoginPremiumToggleEvent.PremiumToggleReason)4 BungeeFastLoginPremiumToggleEvent (com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent)2 VelocityFastLoginPremiumToggleEvent (com.github.games647.fastlogin.velocity.event.VelocityFastLoginPremiumToggleEvent)2