public void mine(Material material, Player p, Block block, byte data) { boolean gotlvl = false; config = new Config(new File("plugins/Runescape/Players/" + p.getName() + ".yml")); config.addDefault(p.getName() + ".miningexp", 0); config.addDefault(p.getName() + ".mininglvl", 0); config.save(); int oexp = (int) config.get(p.getName() + ".miningexp"); int olvl = (int) config.get(p.getName() + ".mininglvl"); int nexp = oexp; int low = 300; int high = 660; nexp = nexp + 25; low = 300; high = 660; gotlvl = true; if (gotlvl == true) { new Timers().Oak(block, material, data, low, high); config.set(p.getName() + ".miningexp", nexp); config.save(); int nlvl = (int) (7 * (Math.log((((Math.pow(2.0, 1.0 / 7.0) - 1.0) / 75.0) * nexp) + 1.0) / Math.log(2.0))); if (nlvl > olvl) { config.set(p.getName() + ".mininglvl", nlvl); config.save(); new LevelUp().lu(p); p.sendMessage( ChatColor.DARK_GREEN + "Congratulation! You've just reached level " + nlvl + " in Mining!"); } } }
@EventHandler public void onBlockBreak(BlockBreakEvent e) { Block block = e.getBlock(); Material material = block.getType(); byte data = block.getData(); Player p = e.getPlayer(); if (material == Material.LOG && p.getGameMode() == GameMode.SURVIVAL) { boolean gotlvl = false; config = new Config(new File("plugins/Runescape/Players/" + p.getName() + ".yml")); config.addDefault(p.getName() + ".wcexp", 0); config.addDefault(p.getName() + ".wclvl", 0); config.save(); int oexp = (int) config.get(p.getName() + ".wcexp"); int olvl = (int) config.get(p.getName() + ".wclvl"); int nexp = oexp; int low = 600; int high = 900; // Oak = Normal if (data == 0 || data == 4 || data == 8 || data == 12) { nexp = nexp + 25; gotlvl = true; } // Spruce == Oak else if (data == 1 || data == 5 || data == 9 || data == 13) { if (olvl >= 15) { nexp = nexp + 100; low = 900; high = 1200; gotlvl = true; } else { p.sendMessage( ChatColor.DARK_GREEN + "You need to be level " + 15 + " in Woodcutting to chop that tree."); } } // Jungle == Maple else if (data == 3 || data == 7 || data == 11 || data == 15) { if (olvl >= 15) { nexp = nexp + 175; low = 1400; high = 1600; gotlvl = true; } else { p.sendMessage( ChatColor.DARK_GREEN + "You need to be level " + 45 + " in Woodcutting to chop that tree."); } } // Birch == Yew else if (data == 2 || data == 6 || data == 10 || data == 14) { if (olvl >= 60) { nexp = nexp + 250; low = 1600; high = 1900; gotlvl = true; } else { p.sendMessage( ChatColor.DARK_GREEN + "You need to be level " + 60 + " in Woodcutting to chop that tree."); } } if (gotlvl == true) { new Timers().Oak(block, material, data, low, high); config.set(p.getName() + ".wcexp", nexp); config.save(); int nlvl = (int) (7 * (Math.log((((Math.pow(2.0, 1.0 / 7.0) - 1.0) / 75.0) * nexp) + 1.0) / Math.log(2.0))); if (nlvl > olvl) { config.set(p.getName() + ".wclvl", nlvl); config.save(); new LevelUp().lu(p); p.sendMessage( ChatColor.DARK_GREEN + "Congratulation! You've just reached level " + nlvl + " in Woodcutting!"); } } } else { // e.setCancelled(true); } }