[NEED HELP] Two Problems

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

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

    JHG0

    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

    JHG0

  3. Offline

    xTrollxDudex

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

    newboyhun

    JHG0
    Use this to get a player's mining level from MCMMO.
    Code:
    ExperienceAPI.getLevel(player, "Mining");
     
  5. Offline

    JHG0

    newboyhun
    Know anything about the fortune of dropping more than one item?
     
  6. Offline

    newboyhun

  7. Offline

    JHG0

    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
     
  8. Offline

    newboyhun

    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" 
      }
    }
     
  9. Offline

    JHG0

Thread Status:
Not open for further replies.

Share This Page