[NEED HELP] Two Problems

Discussion in 'Plugin Development' started by Deleted user, Dec 30, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Deleted user

    One
    No enchantments update...they are added, but they get removed or disappear outside of the .addEnchant part
    Code:
    if(fConfig.get(i + ".enchantments.0.name") != null) {
                            for(int j = 0; fConfig.get(i + ".enchantments." + j + ".name") != null; j++) {
                                enchantName = fConfig.getString(i + ".enchantments." + j + ".name");
                                enchantLevel = fConfig.getInt(i + ".enchantments." + j + ".level");
                                ench = Enchantment.getByName(enchantName);
                                try{
                                    item.addEnchantment(ench, enchantLevel);
                                } catch (IllegalArgumentException exep){
                                    safe = false;
                                }
                                if(safe){
                                    item.addEnchantment(ench, enchantLevel);
                                } else {
                                    item.addUnsafeEnchantment(ench, enchantLevel);
                                }
                            }
                        }
    Two
    Anyone have experience coding with McMMO?
    As many of you that use McMMO know, once you get to a certain level...drop rates can double or triple

    I have made something to make gold and iron automatically drop...Can anyone tell me how I would link this in with McMMO's fortune to make it sometimes drop more based on your level?

    Thanks,
    JHG0

    Code For Auto-Drops:
    Code:
    @EventHandler (priority = EventPriority.HIGHEST)
    public void onMine(BlockBreakEvent e){
        Player p = e.getPlayer();
        if(e.getBlock().getType() == Material.IRON_ORE){
            e.setCancelled(true);
            if(Bukkit.getPluginManager().getPlugin("WorldGuard") != null){
                WorldGuardPlugin wg = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard");
                if(wg.canBuild(p, e.getBlock().getLocation())){
                    e.getBlock().setType(Material.AIR);
                    e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(Material.IRON_INGOT));
                }
            }
        } else if(e.getBlock().getType() == Material.GOLD_ORE){
            e.setCancelled(true);
            if(Bukkit.getPluginManager().getPlugin("WorldGuard") != null){
                WorldGuardPlugin wg = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard");
                if(wg.canBuild(p, e.getBlock().getLocation())){
                    e.getBlock().setType(Material.AIR);
                    e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(Material.GOLD_INGOT));
                }
            }
        }
    }
    Thanks JHG0

    Okay, fixed part one a weird way..now need part two help

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    Deleted user

    Someone help
    xTrollxDudex newboyhun

    JHG0
    I don't use McMMO so I don't know what you are talking about.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 19, 2021
  3. Offline

    newboyhun

    JHG0
    Use this to get a player's mining level from MCMMO.
    Code:
    ExperienceAPI.getLevel(player, "Mining");
    newboyhun
    Know anything about the fortune of dropping more than one item?

    JHG0
    What are you talking about?
    The 'right-click ability' for mining?
    https://github.com/mcMMO-Dev/mcMMO/...mail/nossr50/skills/mining/MiningManager.java
    Here is the source for the mining.
    Check Line 78-88

    newboyhun
    There is a thing that if you are mining say diamond. And have level x, you have x% chance of getting two or three diamonds

    JHG0
    Code:
    SkillType skill = SkillType.Mining;
    Player p = e.getPlayer();
    ExperienceAPI.getLevel(p, "Mining");
    int activationChance = PerkUtils.handleLuckyPerks(p, skill);
    for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) {
      if (SkillUtils.activationSuccessful(SecondaryAbility.MINING_DOUBLE_DROPS, p, lvl, activationChance)) {
        // DOUBLE DROP" 
      }
    }
    newboyhun
    Your good thanks :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 19, 2021
Thread Status:
Not open for further replies.

Share This Page