Search in sources :

Example 1 with BungeeFastLoginPremiumToggleEvent

use of com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent 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 2 with BungeeFastLoginPremiumToggleEvent

use of com.github.games647.fastlogin.bungee.event.BungeeFastLoginPremiumToggleEvent 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)

Aggregations

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