Search in sources :

Example 1 with PrimarySkillType

use of com.gmail.nossr50.datatypes.skills.PrimarySkillType in project Depenizen by DenizenScript.

the class McMMOCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) {
    ElementTag action = scriptEntry.getElement("action");
    ElementTag state = scriptEntry.getElement("state");
    ElementTag type = scriptEntry.getElement("type");
    ElementTag quantity = scriptEntry.getElement("quantity");
    ElementTag party = scriptEntry.getElement("party");
    ElementTag skill = scriptEntry.getElement("skill");
    PlayerTag player = Utilities.getEntryPlayer(scriptEntry);
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, getName(), action, type, state, quantity, party, skill);
    }
    switch(Action.valueOf(action.asString().toUpperCase())) {
        case ADD:
            {
                if (quantity.asDouble() >= 0 && skill != null && player != null) {
                    switch(Type.valueOf(type.asString().toUpperCase())) {
                        case LEVELS:
                            {
                                if (player.isOnline()) {
                                    ExperienceAPI.addLevel(player.getPlayerEntity(), skill.asString(), quantity.asInt());
                                } else {
                                    ExperienceAPI.addLevelOffline(player.getName(), skill.asString(), quantity.asInt());
                                }
                                break;
                            }
                        case XP:
                            {
                                if (player.isOnline()) {
                                    ExperienceAPI.addRawXP(player.getPlayerEntity(), skill.asString(), quantity.asFloat());
                                } else {
                                    ExperienceAPI.addRawXPOffline(player.getName(), skill.asString(), quantity.asFloat());
                                }
                            }
                    }
                } else if (party != null && PartyManager.getParty(party.asString()) != null) {
                    PartyAPI.addToParty(player.getPlayerEntity(), party.asString());
                }
                break;
            }
        case REMOVE:
            {
                if (quantity.asDouble() >= 0 && skill != null && player != null) {
                    switch(Type.valueOf(type.asString().toUpperCase())) {
                        case LEVELS:
                            {
                                if (player.isOnline()) {
                                    ExperienceAPI.setLevel(player.getPlayerEntity(), skill.asString(), ExperienceAPI.getLevel(player.getPlayerEntity(), skill.asString()) - quantity.asInt());
                                } else {
                                    ExperienceAPI.setLevelOffline(player.getName(), skill.asString(), ExperienceAPI.getLevelOffline(player.getName(), skill.asString()) - quantity.asInt());
                                }
                                break;
                            }
                        case XP:
                            {
                                if (player.isOnline()) {
                                    ExperienceAPI.removeXP(player.getPlayerEntity(), skill.asString(), quantity.asInt());
                                } else {
                                    ExperienceAPI.removeXPOffline(player.getName(), skill.asString(), quantity.asInt());
                                }
                                break;
                            }
                    }
                } else if (player != null && player.isOnline() && party != null && PartyManager.getParty(party.asString()) != null) {
                    if (PartyAPI.getPartyLeader(party.asString()).equals(player.getName())) {
                        PartyManager.disbandParty(PartyManager.getParty(party.asString()));
                    } else {
                        PartyAPI.removeFromParty(player.getPlayerEntity());
                    }
                } else if (player != null) {
                    mcMMO.getDatabaseManager().removeUser(player.getName(), player.getUUID());
                }
                break;
            }
        case SET:
            {
                if (quantity.asDouble() >= 0 && skill != null && player != null) {
                    switch(Type.valueOf(type.asString().toUpperCase())) {
                        case LEVELS:
                            {
                                if (player.isOnline()) {
                                    ExperienceAPI.setLevel(player.getPlayerEntity(), skill.asString(), quantity.asInt());
                                } else {
                                    ExperienceAPI.setLevelOffline(player.getName(), skill.asString(), quantity.asInt());
                                }
                                break;
                            }
                        case XP:
                            {
                                if (player.isOnline()) {
                                    ExperienceAPI.setXP(player.getPlayerEntity(), skill.asString(), quantity.asInt());
                                } else {
                                    ExperienceAPI.setXPOffline(player.getName(), skill.asString(), quantity.asInt());
                                }
                                break;
                            }
                    }
                } else {
                    switch(Type.valueOf(type.asString().toUpperCase())) {
                        case LEADER:
                            {
                                if (party != null && PartyManager.getParty(party.asString()) != null) {
                                    PartyAPI.setPartyLeader(party.asString(), player.getName());
                                }
                                break;
                            }
                        case XPRATE:
                            {
                                if (quantity.asInt() > 0) {
                                    ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(quantity.asInt());
                                }
                                break;
                            }
                        case HARDCORE:
                            {
                                if (skill == null) {
                                    return;
                                }
                                PrimarySkillType skillType = PrimarySkillType.getSkill(skill.asString());
                                boolean isEnabled = mcMMO.p.getGeneralConfig().getHardcoreStatLossEnabled(skillType);
                                switch(State.valueOf(state.asString().toUpperCase())) {
                                    case TOGGLE:
                                        {
                                            mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, !isEnabled);
                                            break;
                                        }
                                    case TRUE:
                                        {
                                            mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, true);
                                            break;
                                        }
                                    case FALSE:
                                        {
                                            mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, false);
                                            break;
                                        }
                                }
                                break;
                            }
                        case VAMPIRISM:
                            {
                                if (skill == null) {
                                    return;
                                }
                                PrimarySkillType skillType = PrimarySkillType.getSkill(skill.asString());
                                boolean isEnabled = mcMMO.p.getGeneralConfig().getHardcoreVampirismEnabled(skillType);
                                switch(State.valueOf(state.asString().toUpperCase())) {
                                    case TOGGLE:
                                        {
                                            mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, !isEnabled);
                                            break;
                                        }
                                    case TRUE:
                                        {
                                            mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, true);
                                            break;
                                        }
                                    case FALSE:
                                        {
                                            mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, false);
                                            break;
                                        }
                                }
                                break;
                            }
                    }
                }
                break;
            }
    }
}
Also used : PrimarySkillType(com.gmail.nossr50.datatypes.skills.PrimarySkillType) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag)

Example 2 with PrimarySkillType

use of com.gmail.nossr50.datatypes.skills.PrimarySkillType in project McRPG by Eunoians.

the class McConvert method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
        return true;
    } else {
        if (McRPG.getInstance().isMcmmoEnabled()) {
            Bukkit.getLogger().log(Level.INFO, Methods.color(McRPG.getInstance().getPluginPrefix() + "&eBeginning McMMO conversion... please hold."));
            Parser equation = new Parser(McRPG.getInstance().getConfig().getString("Configuration.McMMOConversionEquation"));
            int playersConverted = 0;
            a: for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
                if (playersConverted != 0 && playersConverted % 5 == 0) {
                    Bukkit.getLogger().log(Level.INFO, Methods.color(McRPG.getInstance().getPluginPrefix() + "&eConverted " + playersConverted + " players so far..."));
                }
                McRPGPlayer mp = new McRPGPlayer(offlinePlayer.getUniqueId());
                int expToConvert = 0;
                for (PrimarySkillType skillType : PrimarySkillType.NON_CHILD_SKILLS) {
                    try {
                        expToConvert += mcMMO.getFormulaManager().calculateTotalExperience(ExperienceAPI.getLevelOffline(offlinePlayer.getUniqueId(), skillType.getName()), ExperienceAPI.getOfflineXP(offlinePlayer.getUniqueId(), skillType.getName()));
                    } catch (Exception e) {
                        Bukkit.getLogger().log(Level.INFO, Methods.color(McRPG.getInstance().getPluginPrefix() + "&eUnable to find data to convert for player " + offlinePlayer.getName() + "."));
                        continue a;
                    }
                }
                if (expToConvert == 0) {
                    Bukkit.getLogger().log(Level.INFO, Methods.color(McRPG.getInstance().getPluginPrefix() + "&eUnable to find data to convert for player " + offlinePlayer.getName() + "."));
                    continue;
                }
                equation.setVariable("skill_exp", expToConvert);
                mp.setBoostedExp((int) equation.getValue());
                mp.saveData();
                playersConverted++;
            }
            Bukkit.getLogger().log(Level.INFO, Methods.color(McRPG.getInstance().getPluginPrefix() + "&aFinished converting " + playersConverted + " players to McRPG. Please keep a copy of your mcmmo files in case you want to change back! :)" + " Thank you for running McRPG. Remember to shut down server and remove mcMMO for this to function properly!"));
        } else {
            sender.sendMessage(Methods.color(McRPG.getInstance().getPluginPrefix() + "&cMcMMO was not found on the server and so data could not be converted"));
        }
        // Legacy commandMcRPG.getInstance().getMcRPGDb().convertLegacyToFlatDB();
        return true;
    }
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) McRPGPlayer(us.eunoians.mcrpg.players.McRPGPlayer) PrimarySkillType(com.gmail.nossr50.datatypes.skills.PrimarySkillType) OfflinePlayer(org.bukkit.OfflinePlayer) McRPGPlayer(us.eunoians.mcrpg.players.McRPGPlayer) Parser(us.eunoians.mcrpg.util.Parser)

Example 3 with PrimarySkillType

use of com.gmail.nossr50.datatypes.skills.PrimarySkillType in project Nexus by ProjectEdenGG.

the class McMMOResetProvider method prestigeAll.

public void prestigeAll(Player player) {
    Koda.say(Nickname.of(player) + " has reset all of their mcMMO skills!");
    PlayerUtils.runCommandAsConsole("ce give " + player.getName() + " diamond_chestplate enlighted:1 beserk:1 durability:3 mending:1");
    McMMOPlayer mcmmoPlayer = UserManager.getPlayer(player);
    boolean allMax = true;
    for (PrimarySkillType skillType : PrimarySkillType.values()) {
        if (skillType.isChildSkill())
            continue;
        if (mcmmoPlayer.getSkillLevel(skillType) < TIER_TWO)
            allMax = false;
        prestige(player, ResetSkillType.valueOf(skillType.name()), false);
    }
    int deposit = DEPOSIT_ALL;
    if (allMax)
        deposit += MAX_DEPOSIT_ALL_MULTIPLIER;
    new BankerService().deposit(player, deposit, ShopGroup.SURVIVAL, TransactionCause.MCMMO_RESET);
    McMMOPrestige mcMMOPrestige = service.getPrestige(player.getUniqueId().toString());
    mcMMOPrestige.prestige("all");
    service.save(mcMMOPrestige);
}
Also used : PrimarySkillType(com.gmail.nossr50.datatypes.skills.PrimarySkillType) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) BankerService(gg.projecteden.nexus.models.banker.BankerService) McMMOPrestige(gg.projecteden.nexus.models.mcmmo.McMMOPrestige)

Aggregations

PrimarySkillType (com.gmail.nossr50.datatypes.skills.PrimarySkillType)3 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 McMMOPlayer (com.gmail.nossr50.datatypes.player.McMMOPlayer)1 BankerService (gg.projecteden.nexus.models.banker.BankerService)1 McMMOPrestige (gg.projecteden.nexus.models.mcmmo.McMMOPrestige)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 Player (org.bukkit.entity.Player)1 McRPGPlayer (us.eunoians.mcrpg.players.McRPGPlayer)1 Parser (us.eunoians.mcrpg.util.Parser)1