Search in sources :

Example 11 with SkillType

use of com.gmail.nossr50.datatypes.skills.SkillType in project TriggerReactor by wysohn.

the class McMmoSupport method setLevel.

/**
 * set level of target player's 'skillType' to 'level'
 *
 * @param player
 * @param skillType
 * @param level
 */
public void setLevel(Player player, String skillType, int level) {
    McMMOPlayer mmoPlayer = (McMMOPlayer) player(player.getName());
    if (mmoPlayer == null)
        throw new RuntimeException("Could not find MCMMO info for player " + player.getName());
    SkillType type = SkillType.valueOf(skillType);
    mmoPlayer.modifySkill(type, level);
}
Also used : McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) SkillType(com.gmail.nossr50.datatypes.skills.SkillType)

Example 12 with SkillType

use of com.gmail.nossr50.datatypes.skills.SkillType 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 13 with SkillType

use of com.gmail.nossr50.datatypes.skills.SkillType in project GDHooks by bloodmc.

the class McMMOProvider method onPlayerAbilityActivate.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerAbilityActivate(McMMOPlayerAbilityActivateEvent event) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Location location = player.getLocation();
    final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
    final Claim claim = GriefDefender.getCore().getClaimAt(location);
    final String ability = event.getAbility().name().toLowerCase().replace(" ", "_");
    final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
    final Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("mcmmo:skill_level", String.valueOf(event.getSkillLevel())));
    contexts.add(new Context("mcmmo:skill_type", skillType));
    final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), ABILITY_ACTIVATE, player, ability, contexts, null, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
    }
    this.playerAbilityMap.put(player.getUniqueId(), new McMMOPlayerAbilityData(player.getUniqueId(), event.getAbility(), event.getSkill(), event.getSkillLevel(), contexts));
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) McMMOPlayerAbilityData(com.griefdefender.hooks.provider.mcmmo.McMMOPlayerAbilityData) Tristate(com.griefdefender.api.Tristate) World(org.bukkit.World) PlayerData(com.griefdefender.api.data.PlayerData) Claim(com.griefdefender.api.claim.Claim) Location(org.bukkit.Location) HashSet(java.util.HashSet) EventHandler(org.bukkit.event.EventHandler)

Example 14 with SkillType

use of com.gmail.nossr50.datatypes.skills.SkillType 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

McMMOPlayer (com.gmail.nossr50.datatypes.player.McMMOPlayer)12 SkillType (com.gmail.nossr50.datatypes.skills.SkillType)7 Player (org.bukkit.entity.Player)5 Claim (com.griefdefender.api.claim.Claim)4 PlayerData (com.griefdefender.api.data.PlayerData)4 Context (com.griefdefender.api.permission.Context)4 Location (org.bukkit.Location)4 World (org.bukkit.World)4 PrimarySkillType (com.gmail.nossr50.datatypes.skills.PrimarySkillType)3 Tristate (com.griefdefender.api.Tristate)3 HashSet (java.util.HashSet)3 EventHandler (org.bukkit.event.EventHandler)3 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)1 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)1 McMMOPlayerAbilityData (com.griefdefender.hooks.provider.mcmmo.McMMOPlayerAbilityData)1 BankerService (gg.projecteden.nexus.models.banker.BankerService)1 McMMOPrestige (gg.projecteden.nexus.models.mcmmo.McMMOPrestige)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 McRPGPlayer (us.eunoians.mcrpg.players.McRPGPlayer)1 Parser (us.eunoians.mcrpg.util.Parser)1