Massive code sorting. One array out of bounds fix.

This commit is contained in:
nossr50 2011-02-07 01:12:47 -08:00
parent 6e5c93f955
commit 346a19dc2c
5 changed files with 646 additions and 549 deletions

View File

@ -24,81 +24,6 @@ public class mcBlockListener extends BlockListener {
if(block.getTypeId() == 42) if(block.getTypeId() == 42)
event.getPlayer().sendMessage(ChatColor.DARK_RED+"You have placed an anvil, anvils can repair tools and armor."); event.getPlayer().sendMessage(ChatColor.DARK_RED+"You have placed an anvil, anvils can repair tools and armor.");
} }
public void blockProcSimulate(Block block){
Location loc = block.getLocation();
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
block.getWorld().dropItemNaturally(loc, item);
if(block.getTypeId() == 73 || block.getTypeId() == 74){
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
//Since redstone gives 4-5, lets simulate that
if(Math.random() * 10 > 5){
block.getWorld().dropItemNaturally(loc, item);
}
}
if(block.getTypeId() == 21){
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 56){
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 1){
mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 16){
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
}
}
public void blockProcCheck(Block block, Player player){
if(mcUsers.getProfile(player).getMiningInt() > 3000){
blockProcSimulate(block);
return;
}
if(mcUsers.getProfile(player).getMiningInt() > 2000){
if((Math.random() * 10) > 2){
blockProcSimulate(block);
return;
}
}
if(mcUsers.getProfile(player).getMiningInt() > 750){
if((Math.random() * 10) > 4){
blockProcSimulate(block);
return;
}
}
if(mcUsers.getProfile(player).getMiningInt() > 150){
if((Math.random() * 10) > 6){
blockProcSimulate(block);
return;
}
}
if(mcUsers.getProfile(player).getMiningInt() > 25){
if((Math.random() * 10) > 8){
blockProcSimulate(block);
return;
}
}
}
//put all Block related code here //put all Block related code here
public void onBlockDamage(BlockDamageEvent event) { public void onBlockDamage(BlockDamageEvent event) {
//STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2); //STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
@ -108,113 +33,17 @@ public class mcBlockListener extends BlockListener {
int dmg = event.getDamageLevel().getLevel(); int dmg = event.getDamageLevel().getLevel();
//Smooth Stone //Smooth Stone
if(dmg == 3 && !mcConfig.getInstance().isBlockWatched(block)){ if(dmg == 3 && !mcConfig.getInstance().isBlockWatched(block)){
if(block.getTypeId() == 1){ mcm.getInstance().miningBlockCheck(player, block);
mcUsers.getProfile(player).addgather(1);
blockProcCheck(block, player);
}
//COAL
if(block.getTypeId() == 16){
mcUsers.getProfile(player).addgather(3);
blockProcCheck(block, player);
}
//GOLD
if(block.getTypeId() == 14){
mcUsers.getProfile(player).addgather(20);
blockProcCheck(block, player);
}
//DIAMOND
if(block.getTypeId() == 56){
mcUsers.getProfile(player).addgather(50);
blockProcCheck(block, player);
}
//IRON
if(block.getTypeId() == 15){
mcUsers.getProfile(player).addgather(10);
blockProcCheck(block, player);
}
//REDSTONE
if(block.getTypeId() == 73 || block.getTypeId() == 74){
mcUsers.getProfile(player).addgather(15);
blockProcCheck(block, player);
}
//LAPUS
if(block.getTypeId() == 21){
mcUsers.getProfile(player).addgather(50);
blockProcCheck(block, player);
}
//Give skill for woodcutting //Give skill for woodcutting
if(block.getTypeId() == 17) if(block.getTypeId() == 17)
mcUsers.getProfile(player).addwgather(1); mcUsers.getProfile(player).addwgather(1);
//Skill up players based on gather/wgather stuff
if(mcUsers.getProfile(player).getwgatheramt() > 10){ mcm.getInstance().simulateSkillUp(player);
while(mcUsers.getProfile(player).getwgatheramt() > 10){
mcUsers.getProfile(player).removewgather(10);
mcUsers.getProfile(player).skillUpWoodcutting(1);
player.sendMessage(ChatColor.YELLOW+"Wood Cutting skill increased by 1. Total ("+mcUsers.getProfile(player).getWoodCutting()+")");
}
}
if(mcUsers.getProfile(player).getgatheramt() > 50){
while(mcUsers.getProfile(player).getgatheramt() > 50){
mcUsers.getProfile(player).removegather(50);
mcUsers.getProfile(player).skillUpMining(1);
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by 1. Total ("+mcUsers.getProfile(player).getMining()+")");
}
}
/*
* WOODCUTTING
*/
if(block.getTypeId() == 17){ if(block.getTypeId() == 17){
if(mcUsers.getProfile(player).getWoodCuttingint() > 1000){ mcm.getInstance().woodCuttingProcCheck(player, block, loc);
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 750){
if((Math.random() * 10) > 2){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 300){
if((Math.random() * 10) > 4){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 100){
if((Math.random() * 10) > 6){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 10){
if((Math.random() * 10) > 8){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
} }
}
//GOLD ORE = 14
//DIAMOND ORE = 56
//REDSTONE = 73 && 74
} }
}
public void onBlockFlow(BlockFromToEvent event) { public void onBlockFlow(BlockFromToEvent event) {

View File

@ -2,7 +2,11 @@ package com.bukkit.nossr50.mcMMO;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class mcConfig { public class mcConfig {
private static volatile mcConfig instance; private static volatile mcConfig instance;
@ -38,4 +42,49 @@ public class mcConfig {
addPartyToggled(playerName); addPartyToggled(playerName);
} }
} }
public void woodProcChecks(Player player, Block block, Location loc){
if(mcUsers.getProfile(player).getWoodCuttingint() > 1000){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 750){
if((Math.random() * 10) > 2){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 300){
if((Math.random() * 10) > 4){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 100){
if((Math.random() * 10) > 6){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 10){
if((Math.random() * 10) > 8){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
}
} }

View File

@ -3,7 +3,6 @@ package com.bukkit.nossr50.mcMMO;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
@ -18,6 +17,16 @@ public class mcPlayerListener extends PlayerListener {
public mcPlayerListener(mcMMO instance) { public mcPlayerListener(mcMMO instance) {
plugin = instance; plugin = instance;
} }
private static volatile mcPlayerListener instance;
public static mcPlayerListener getInstance() {
if (instance == null) {
instance = new mcPlayerListener(plugin);
}
return instance;
}
public Player[] getPlayersOnline() {
return plugin.getServer().getOnlinePlayers();
}
public void onPlayerJoin(PlayerEvent event) { public void onPlayerJoin(PlayerEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
mcUsers.addUser(player); mcUsers.addUser(player);
@ -25,180 +34,6 @@ public class mcPlayerListener extends PlayerListener {
player.sendMessage(ChatColor.RED+"WARNING: "+ChatColor.DARK_GRAY+ "Using /myspawn will clear your inventory!"); player.sendMessage(ChatColor.RED+"WARNING: "+ChatColor.DARK_GRAY+ "Using /myspawn will clear your inventory!");
} }
//Check if string is a player //Check if string is a player
public boolean isPlayer(String playerName){
for(Player herp : plugin.getServer().getOnlinePlayers()){
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
return true;
}
}
return false;
}
public int partyCount(Player player){
Player players[] = plugin.getServer().getOnlinePlayers();
int x = 0;
for(Player hurrdurr: players){
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty()))
x++;
}
return x;
}
public Player getPlayer(String playerName){
for(Player herp : plugin.getServer().getOnlinePlayers()){
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
return herp;
}
}
return null;
}
// IS TOOLS FUNCTION
public boolean isTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || //IRON
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279) //DIAMOND
{
return true;
} else {
return false;
}
}
public boolean isIronTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267)
{
return true;
} else {
return false;
}
}
public boolean isDiamondTools(ItemStack is){
if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279)
{
return true;
} else {
return false;
}
}
public void removeIron(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 265){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
}
}
}
public void removeDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 264){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
}
}
}
public boolean hasDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 264){
return true;
}
}
return false;
}
public boolean hasIron(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 265){
return true;
}
}
return false;
}
//This determines how much we repair
public short getRepairAmount(ItemStack is, short durability, Player player){
//IRON SHOVEL
if(is.getTypeId() == 256){
return 0; //full repair
}
//DIAMOND SHOVEL
if(is.getTypeId() == 277){
return 0; //full repair
}
//IRON TOOLS
if(is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267){
if(durability < 84){
return 0;
}else {
if(mcUsers.getProfile(player).getRepairInt() > 750){
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 450){
if(Math.random() * 10 > 4){
player.sendMessage(ChatColor.GRAY + "That felt really easy.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 150){
if(Math.random() * 10 > 6){
player.sendMessage(ChatColor.GRAY + "That felt pretty easy.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 50){
if(Math.random() * 10 > 8){
player.sendMessage(ChatColor.GRAY + "That felt easy.");
return 0;
}
}
return (short) (durability-84);
}
//DIAMOND TOOLS
} else if(is.getTypeId() == 276 || is.getTypeId() == 278 || is.getTypeId() == 279){
if(durability < 509){
return 0;
} else {
if(mcUsers.getProfile(player).getRepairInt() > 750){
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 450){
if(Math.random() * 10 > 4){
player.sendMessage(ChatColor.GRAY + "That was simple.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 150){
if(Math.random() * 10 > 6){
player.sendMessage(ChatColor.GRAY + "That felt pretty easy.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 50){
if(Math.random() * 10 > 8){
player.sendMessage(ChatColor.GRAY + "That felt easy.");
return 0;
}
}
return (short) (durability-509);
}
} else {
return durability;
}
}
public void onPlayerItem(PlayerItemEvent event) { public void onPlayerItem(PlayerItemEvent event) {
Block block = event.getBlockClicked(); Block block = event.getBlockClicked();
@ -206,23 +41,23 @@ public class mcPlayerListener extends PlayerListener {
ItemStack is = player.getItemInHand(); ItemStack is = player.getItemInHand();
if(block != null && block.getTypeId() == 42){ if(block != null && block.getTypeId() == 42){
short durability = is.getDurability(); short durability = is.getDurability();
if(isTools(is) && player.isOp() && block.getTypeId() == 42){ if(mcm.getInstance().isTools(is) && player.isOp() && block.getTypeId() == 42){
if(isIronTools(is) && hasIron(player)){ //Check if its iron and the player has iron if(mcm.getInstance().isIronTools(is) && mcm.getInstance().hasIron(player)){
is.setDurability(getRepairAmount(is, durability, player)); is.setDurability(mcm.getInstance().getRepairAmount(is, durability, player));
removeIron(player); mcm.getInstance().removeIron(player);
mcUsers.getProfile(player).skillUpRepair(1); mcUsers.getProfile(player).skillUpRepair(1);
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")"); player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")");
} else if (isDiamondTools(is) && hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() > 50){ //Check if its diamond and the player has diamonds } else if (mcm.getInstance().isDiamondTools(is) && mcm.getInstance().hasDiamond(player) && mcUsers.getProfile(player).getRepairInt() > 50){ //Check if its diamond and the player has diamonds
is.setDurability(getRepairAmount(is, durability, player)); is.setDurability(mcm.getInstance().getRepairAmount(is, durability, player));
removeDiamond(player); mcm.getInstance().removeDiamond(player);
mcUsers.getProfile(player).skillUpRepair(1); mcUsers.getProfile(player).skillUpRepair(1);
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")"); player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")");
} else if (isDiamondTools(is) && mcUsers.getProfile(player).getRepairInt() < 50){ } else if (mcm.getInstance().isDiamondTools(is) && mcUsers.getProfile(player).getRepairInt() < 50){
player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond");
} else if (isDiamondTools(is) && !hasDiamond(player) || isIronTools(is) && !hasIron(player)){ } else if (mcm.getInstance().isDiamondTools(is) && !mcm.getInstance().hasDiamond(player) || mcm.getInstance().isIronTools(is) && !mcm.getInstance().hasIron(player)){
if(!hasDiamond(player)) if(!mcm.getInstance().hasDiamond(player))
player.sendMessage(ChatColor.DARK_RED+"You need more"+ChatColor.BLUE+ "Diamonds"); player.sendMessage(ChatColor.DARK_RED+"You need more"+ChatColor.BLUE+ "Diamonds");
if(!hasIron(player)) if(!mcm.getInstance().hasIron(player))
player.sendMessage(ChatColor.DARK_RED+"You need more"+ChatColor.GRAY+ "Iron"); player.sendMessage(ChatColor.DARK_RED+"You need more"+ChatColor.GRAY+ "Iron");
} }
} }
@ -231,167 +66,7 @@ public class mcPlayerListener extends PlayerListener {
public void onPlayerCommand(PlayerChatEvent event) { public void onPlayerCommand(PlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String[] split = event.getMessage().split(" "); String[] split = event.getMessage().split(" ");
String playerName = player.getName(); mcc.getInstance().CommandCheck(player, split, spawn);
//mcMMO command
if(split[0].equalsIgnoreCase("/mcmmo")){
player.sendMessage(ChatColor.GRAY+"mcMMO is an RPG inspired plugin");
player.sendMessage(ChatColor.GRAY+"You can gain skills in several professions by");
player.sendMessage(ChatColor.GRAY+"doing things related to that profession.");
player.sendMessage(ChatColor.GRAY+"Mining for example will increase your mining XP.");
player.sendMessage(ChatColor.GRAY+"Wood Cutting will increase Wood Cutting, etc...");
player.sendMessage(ChatColor.GRAY+"Repairing is simple in mcMMO");
player.sendMessage(ChatColor.GRAY+"Say you want to repair an iron shovel");
player.sendMessage(ChatColor.GRAY+"start by making an anvil by combining 9 iron ingots");
player.sendMessage(ChatColor.GRAY+"on a workbench. Place the anvil and while holding the shovel");
player.sendMessage(ChatColor.GRAY+"right click the anvil interact with it, If you have spare iron ingots");
player.sendMessage(ChatColor.GRAY+"in your inventory the item will be repaired.");
player.sendMessage(ChatColor.GRAY+"You cannot hurt other party members");
player.sendMessage(ChatColor.BLUE+"Set your own spawn with "+ChatColor.RED+"/myspawn");
player.sendMessage(ChatColor.GREEN+"Based on your skills you will get "+ChatColor.DARK_RED+"random procs "+ChatColor.GREEN+ "when");
player.sendMessage(ChatColor.GREEN+"using your profession, like "+ChatColor.DARK_RED+"double drops "+ChatColor.GREEN+"or "+ChatColor.DARK_RED+"better repairs");
player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with /mcc");
}
if(split[0].equalsIgnoreCase("/mcc")){
player.sendMessage(ChatColor.GRAY+"mcMMO has a party system included");
player.sendMessage(ChatColor.GRAY+"Commands are /party <name> - to join a party");
player.sendMessage(ChatColor.GRAY+"/ptp <name> - party teleport");
player.sendMessage(ChatColor.GRAY+"/p - toggles party chat");
}
if(mcUsers.getProfile(player).inParty() && split[0].equalsIgnoreCase("/ptp")){
if(split.length < 2){
player.sendMessage(ChatColor.RED+"Usage is /ptp <playername>");
return;
}
if(isPlayer(split[1])){
Player target = getPlayer(split[1]);
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(target).getParty())){
player.teleportTo(target);
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
}
}
}
if(player.isOp() && split[0].equalsIgnoreCase("/whois")){
if(split.length < 2){
player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
return;
}
//if split[1] is a player
if(isPlayer(split[1])){
Player target = getPlayer(split[1]);
double x,y,z;
x = target.getLocation().getX();
y = target.getLocation().getY();
z = target.getLocation().getZ();
player.sendMessage(ChatColor.GREEN + "~~WHOIS RESULTS~~");
player.sendMessage(target.getName());
if(mcUsers.getProfile(target).inParty())
player.sendMessage("Party: "+mcUsers.getProfile(target).getParty());
player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)");
player.sendMessage("OP: " + target.isOp());
player.sendMessage(ChatColor.GREEN+"~~mcMMO stats~~");
player.sendMessage("Mining Skill: "+mcUsers.getProfile(target).getMining());
player.sendMessage("Repair Skill: "+mcUsers.getProfile(target).getRepair());
player.sendMessage("Woodcutting Skill: "+mcUsers.getProfile(target).getWoodCutting());
player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~");
player.sendMessage("X: "+x);
player.sendMessage("Y: "+y);
player.sendMessage("Z: "+z);
}
}
if(split[0].equalsIgnoreCase("/setmyspawn")){
double x = player.getLocation().getX();
double y = player.getLocation().getY();
double z = player.getLocation().getZ();
mcUsers.getProfile(player).setMySpawn(x, y, z);
player.sendMessage(ChatColor.DARK_AQUA + "Myspawn has been set to your current location.");
}
if(player.isOp() && split[0].equalsIgnoreCase("/setspawn")){
spawn = event.getPlayer().getLocation();
player.sendMessage("Spawn set to current location");
}
if(split[0].equalsIgnoreCase("/stats")){
event.setCancelled(true);
player.sendMessage(ChatColor.DARK_GREEN + "mcMMO stats");
player.sendMessage(ChatColor.DARK_GREEN + "Mining Skill: " + mcUsers.getProfile(player).getMining());
player.sendMessage(ChatColor.DARK_GREEN + "Repair Skill: " + mcUsers.getProfile(player).getRepair());
player.sendMessage(ChatColor.DARK_GREEN + "Woodcutting Skill: "+mcUsers.getProfile(player).getWoodCutting());
player.sendMessage(ChatColor.GRAY + "Increases depending on the material you mine");
}
//Party command
if(split[0].equalsIgnoreCase("/party")){
event.setCancelled(true);
if(split.length == 1 && !mcUsers.getProfile(player).inParty()){
player.sendMessage("Proper usage is /party <name> or 'q' to quit");
return;
}
if(split.length == 1 && mcUsers.getProfile(player).inParty()){
String tempList = "";
int x = 0;
for(Player p : plugin.getServer().getOnlinePlayers())
{
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(p).getParty())){
if(p != null && x+1 >= partyCount(player)){
tempList+= p.getName();
x++;
}
if(p != null && x < partyCount(player)){
tempList+= p.getName() +", ";
x++;
}
}
}
player.sendMessage(ChatColor.GREEN+"You are in party \""+mcUsers.getProfile(player).getParty()+"\"");
player.sendMessage(ChatColor.GREEN + "Party Members ("+ChatColor.WHITE+tempList+ChatColor.GREEN+")");
}
if(split.length > 1 && split[1].equals("q") && mcUsers.getProfile(player).inParty()){
informPartyMembersQuit(player);
mcUsers.getProfile(player).removeParty();
player.sendMessage(ChatColor.RED + "You have left that party");
return;
}
mcUsers.getProfile(player).setParty(split[1]);
player.sendMessage("Joined Party: " + split[1]);
informPartyMembers(player);
}
if(split[0].equalsIgnoreCase("/p")){
if(mcConfig.getInstance().isAdminToggled(player.getName()))
mcConfig.getInstance().toggleAdminChat(playerName);
mcConfig.getInstance().togglePartyChat(playerName);
if(mcConfig.getInstance().isPartyToggled(playerName)){
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On");
} else {
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off");
}
}
if(split[0].equalsIgnoreCase("/a") && player.isOp()){
if(mcConfig.getInstance().isPartyToggled(player.getName()))
mcConfig.getInstance().togglePartyChat(playerName);
mcConfig.getInstance().toggleAdminChat(playerName);
if(mcConfig.getInstance().isAdminToggled(playerName)){
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
} else {
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
}
}
if(split[0].equalsIgnoreCase("/myspawn")){
if(mcUsers.getProfile(player).getMySpawn(player) != null){
player.getInventory().clear();
player.setHealth(20);
player.teleportTo(mcUsers.getProfile(player).getMySpawn(player));
player.sendMessage("Inventory cleared & health restored");
}else{
player.sendMessage(ChatColor.RED+"Configure your myspawn first with /setmyspawn");
}
}
if(split[0].equalsIgnoreCase("/spawn")){
if(spawn != null){
player.teleportTo(spawn);
player.sendMessage("Welcome to spawn, home of the feeble.");
return;
}
player.sendMessage("Spawn isn't configured. Have an OP set it with /setspawn");
}
} }
public void onPlayerChat(PlayerChatEvent event) { public void onPlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -402,7 +77,7 @@ public class mcPlayerListener extends PlayerListener {
event.setCancelled(true); event.setCancelled(true);
for(Player herp : plugin.getServer().getOnlinePlayers()){ for(Player herp : plugin.getServer().getOnlinePlayers()){
if(mcUsers.getProfile(herp).inParty()){ if(mcUsers.getProfile(herp).inParty()){
if(inSameParty(herp, player)){ if(mcm.inSameParty(herp, player)){
herp.sendMessage(x+event.getMessage()); herp.sendMessage(x+event.getMessage());
} }
} }
@ -425,30 +100,7 @@ public class mcPlayerListener extends PlayerListener {
derp.sendMessage(z+event.getMessage()); derp.sendMessage(z+event.getMessage());
} }
} }
event.setCancelled(true);
} }
public static void informPartyMembers(Player player){
int x = 0;
for(Player p : plugin.getServer().getOnlinePlayers()){
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party");
x++;
}
}
}
public static void informPartyMembersQuit(Player player){
int x = 0;
for(Player p : plugin.getServer().getOnlinePlayers()){
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party");
x++;
}
}
}
public static boolean inSameParty(Player playera, Player playerb){
if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){
return true;
} else {
return false;
}
}
} }

View File

@ -0,0 +1,180 @@
package com.bukkit.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class mcc {
private static volatile mcc instance;
public static mcc getInstance() {
if (instance == null) {
instance = new mcc();
}
return instance;
}
public void CommandCheck(Player player, String split[], Location spawn){
String playerName = player.getName();
if(split[0].equalsIgnoreCase("/mcmmo")){
player.sendMessage(ChatColor.GRAY+"mcMMO is an RPG inspired plugin");
player.sendMessage(ChatColor.GRAY+"You can gain skills in several professions by");
player.sendMessage(ChatColor.GRAY+"doing things related to that profession.");
player.sendMessage(ChatColor.GRAY+"Mining for example will increase your mining XP.");
player.sendMessage(ChatColor.GRAY+"Wood Cutting will increase Wood Cutting, etc...");
player.sendMessage(ChatColor.GRAY+"Repairing is simple in mcMMO");
player.sendMessage(ChatColor.GRAY+"Say you want to repair an iron shovel");
player.sendMessage(ChatColor.GRAY+"start by making an anvil by combining 9 iron ingots");
player.sendMessage(ChatColor.GRAY+"on a workbench. Place the anvil and while holding the shovel");
player.sendMessage(ChatColor.GRAY+"right click the anvil interact with it, If you have spare");
player.sendMessage(ChatColor.GRAY+"iron ingots in your inventory the item will be repaired.");
player.sendMessage(ChatColor.GRAY+"You cannot hurt other party members");
player.sendMessage(ChatColor.BLUE+"Set your own spawn with "+ChatColor.RED+"/myspawn");
player.sendMessage(ChatColor.GREEN+"Based on your skills you will get "+ChatColor.DARK_RED+"random procs "+ChatColor.GREEN+ "when");
player.sendMessage(ChatColor.GREEN+"using your profession, like "+ChatColor.DARK_RED+"double drops "+ChatColor.GREEN+"or "+ChatColor.DARK_RED+"better repairs");
player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with /mcc");
}
if(split[0].equalsIgnoreCase("/mcc")){
player.sendMessage(ChatColor.GRAY+"mcMMO has a party system included");
player.sendMessage(ChatColor.GREEN+"~~Commands~~");
player.sendMessage(ChatColor.GRAY+"/party <name> - to join a party");
player.sendMessage(ChatColor.GRAY+"/party q - to quit a party");
player.sendMessage(ChatColor.GRAY+"/ptp <name> - party teleport");
player.sendMessage(ChatColor.GRAY+"/p - toggles party chat");
}
if(mcUsers.getProfile(player).inParty() && split[0].equalsIgnoreCase("/ptp")){
if(split.length < 2){
player.sendMessage(ChatColor.RED+"Usage is /ptp <playername>");
return;
}
if(mcm.getInstance().isPlayer(split[1])){
Player target = mcm.getInstance().getPlayer(split[1]);
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(target).getParty())){
player.teleportTo(target);
player.sendMessage(ChatColor.GREEN+"You have teleported to "+target.getName());
target.sendMessage(ChatColor.GREEN+player.getName() + " has teleported to you.");
}
}
}
if(player.isOp() && split[0].equalsIgnoreCase("/whois")){
if(split.length < 2){
player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
return;
}
//if split[1] is a player
if(mcm.getInstance().isPlayer(split[1])){
Player target = mcm.getInstance().getPlayer(split[1]);
double x,y,z;
x = target.getLocation().getX();
y = target.getLocation().getY();
z = target.getLocation().getZ();
player.sendMessage(ChatColor.GREEN + "~~WHOIS RESULTS~~");
player.sendMessage(target.getName());
if(mcUsers.getProfile(target).inParty())
player.sendMessage("Party: "+mcUsers.getProfile(target).getParty());
player.sendMessage("Health: "+target.getHealth()+ChatColor.GRAY+" (20 is full health)");
player.sendMessage("OP: " + target.isOp());
player.sendMessage(ChatColor.GREEN+"~~mcMMO stats~~");
player.sendMessage("Mining Skill: "+mcUsers.getProfile(target).getMining());
player.sendMessage("Repair Skill: "+mcUsers.getProfile(target).getRepair());
player.sendMessage("Woodcutting Skill: "+mcUsers.getProfile(target).getWoodCutting());
player.sendMessage(ChatColor.GREEN+"~~COORDINATES~~");
player.sendMessage("X: "+x);
player.sendMessage("Y: "+y);
player.sendMessage("Z: "+z);
}
}
if(split[0].equalsIgnoreCase("/setmyspawn")){
double x = player.getLocation().getX();
double y = player.getLocation().getY();
double z = player.getLocation().getZ();
mcUsers.getProfile(player).setMySpawn(x, y, z);
player.sendMessage(ChatColor.DARK_AQUA + "Myspawn has been set to your current location.");
}
if(player.isOp() && split[0].equalsIgnoreCase("/setspawn")){
spawn = player.getLocation();
player.sendMessage("Spawn set to current location");
}
if(split[0].equalsIgnoreCase("/stats")){
player.sendMessage(ChatColor.DARK_GREEN + "mcMMO stats");
player.sendMessage(ChatColor.DARK_GREEN + "Mining Skill: " + mcUsers.getProfile(player).getMining());
player.sendMessage(ChatColor.DARK_GREEN + "Repair Skill: " + mcUsers.getProfile(player).getRepair());
player.sendMessage(ChatColor.DARK_GREEN + "Woodcutting Skill: "+mcUsers.getProfile(player).getWoodCutting());
player.sendMessage(ChatColor.GRAY + "Increases depending on the material you mine");
}
//Party command
if(split[0].equalsIgnoreCase("/party")){
if(split.length == 1 && !mcUsers.getProfile(player).inParty()){
player.sendMessage("Proper usage is /party <name> or 'q' to quit");
return;
}
if(split.length == 1 && mcUsers.getProfile(player).inParty()){
String tempList = "";
int x = 0;
for(Player p : mcPlayerListener.getInstance().getPlayersOnline())
{
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(p).getParty())){
if(p != null && x+1 >= mcm.getInstance().partyCount(player)){
tempList+= p.getName();
x++;
}
if(p != null && x < mcm.getInstance().partyCount(player)){
tempList+= p.getName() +", ";
x++;
}
}
}
player.sendMessage(ChatColor.GREEN+"You are in party \""+mcUsers.getProfile(player).getParty()+"\"");
player.sendMessage(ChatColor.GREEN + "Party Members ("+ChatColor.WHITE+tempList+ChatColor.GREEN+")");
}
if(split.length > 1 && split[1].equals("q") && mcUsers.getProfile(player).inParty()){
mcm.getInstance().informPartyMembersQuit(player);
mcUsers.getProfile(player).removeParty();
player.sendMessage(ChatColor.RED + "You have left that party");
return;
}
if(split.length >= 2){
mcUsers.getProfile(player).setParty(split[1]);
player.sendMessage("Joined Party: " + split[1]);
mcm.getInstance().informPartyMembers(player);
}
}
if(split[0].equalsIgnoreCase("/p")){
if(mcConfig.getInstance().isAdminToggled(player.getName()))
mcConfig.getInstance().toggleAdminChat(playerName);
mcConfig.getInstance().togglePartyChat(playerName);
if(mcConfig.getInstance().isPartyToggled(playerName)){
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On");
} else {
player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off");
}
}
if(split[0].equalsIgnoreCase("/a") && player.isOp()){
if(mcConfig.getInstance().isPartyToggled(player.getName()))
mcConfig.getInstance().togglePartyChat(playerName);
mcConfig.getInstance().toggleAdminChat(playerName);
if(mcConfig.getInstance().isAdminToggled(playerName)){
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
} else {
player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
}
}
if(split[0].equalsIgnoreCase("/myspawn")){
if(mcUsers.getProfile(player).getMySpawn(player) != null){
player.getInventory().clear();
player.setHealth(20);
player.teleportTo(mcUsers.getProfile(player).getMySpawn(player));
player.sendMessage("Inventory cleared & health restored");
}else{
player.sendMessage(ChatColor.RED+"Configure your myspawn first with /setmyspawn");
}
}
if(split[0].equalsIgnoreCase("/spawn")){
if(spawn != null){
player.teleportTo(spawn);
player.sendMessage("Welcome to spawn, home of the feeble.");
return;
}
player.sendMessage("Spawn isn't configured. Have an OP set it with /setspawn");
}
}
}

View File

@ -0,0 +1,387 @@
package com.bukkit.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class mcm {
private static volatile mcm instance;
public static mcm getInstance() {
if (instance == null) {
instance = new mcm();
}
return instance;
}
public boolean isPlayer(String playerName){
for(Player herp : mcPlayerListener.getInstance().getPlayersOnline()){
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
return true;
}
}
return false;
}
public int partyCount(Player player){
Player players[] = mcPlayerListener.getInstance().getPlayersOnline();
int x = 0;
for(Player hurrdurr: players){
if(mcUsers.getProfile(player).getParty().equals(mcUsers.getProfile(hurrdurr).getParty()))
x++;
}
return x;
}
public static void informPartyMembers(Player player){
int x = 0;
for(Player p : mcPlayerListener.getInstance().getPlayersOnline()){
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
p.sendMessage(player.getName() + ChatColor.GREEN + " has joined your party");
x++;
}
}
}
public static void informPartyMembersQuit(Player player){
int x = 0;
for(Player p : mcPlayerListener.getInstance().getPlayersOnline()){
if(inSameParty(player, p) && !p.getName().equals(player.getName())){
p.sendMessage(player.getName() + ChatColor.GREEN + " has left your party");
x++;
}
}
}
public static boolean inSameParty(Player playera, Player playerb){
if(mcUsers.getProfile(playera).getParty().equals(mcUsers.getProfile(playerb).getParty())){
return true;
} else {
return false;
}
}
public Player getPlayer(String playerName){
for(Player herp : mcPlayerListener.getInstance().getPlayersOnline()){
if(herp.getName().toLowerCase().equals(playerName.toLowerCase())){
return herp;
}
}
return null;
}
//This determines how much we repair
public short getRepairAmount(ItemStack is, short durability, Player player){
//IRON SHOVEL
if(is.getTypeId() == 256){
return 0; //full repair
}
//DIAMOND SHOVEL
if(is.getTypeId() == 277){
return 0; //full repair
}
//IRON TOOLS
if(is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267){
if(durability < 84){
return 0;
}else {
if(mcUsers.getProfile(player).getRepairInt() > 750){
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 450){
if(Math.random() * 10 > 4){
player.sendMessage(ChatColor.GRAY + "That felt really easy.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 150){
if(Math.random() * 10 > 6){
player.sendMessage(ChatColor.GRAY + "That felt pretty easy.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 50){
if(Math.random() * 10 > 8){
player.sendMessage(ChatColor.GRAY + "That felt easy.");
return 0;
}
}
return (short) (durability-84);
}
//DIAMOND TOOLS
} else if(is.getTypeId() == 276 || is.getTypeId() == 278 || is.getTypeId() == 279){
if(durability < 509){
return 0;
} else {
if(mcUsers.getProfile(player).getRepairInt() > 750){
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 450){
if(Math.random() * 10 > 4){
player.sendMessage(ChatColor.GRAY + "That was simple.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 150){
if(Math.random() * 10 > 6){
player.sendMessage(ChatColor.GRAY + "That felt pretty easy.");
return 0;
}
} else if (mcUsers.getProfile(player).getRepairInt() > 50){
if(Math.random() * 10 > 8){
player.sendMessage(ChatColor.GRAY + "That felt easy.");
return 0;
}
}
return (short) (durability-509);
}
} else {
return durability;
}
}
public void blockProcSimulate(Block block){
Location loc = block.getLocation();
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56 && block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
block.getWorld().dropItemNaturally(loc, item);
if(block.getTypeId() == 73 || block.getTypeId() == 74){
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
if(Math.random() * 10 > 5){
block.getWorld().dropItemNaturally(loc, item);
}
}
if(block.getTypeId() == 21){
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
block.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 56){
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 1){
mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 16){
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
}
}
public void blockProcCheck(Block block, Player player){
if(mcUsers.getProfile(player).getMiningInt() > 3000){
blockProcSimulate(block);
return;
}
if(mcUsers.getProfile(player).getMiningInt() > 2000){
if((Math.random() * 10) > 2){
blockProcSimulate(block);
return;
}
}
if(mcUsers.getProfile(player).getMiningInt() > 750){
if((Math.random() * 10) > 4){
blockProcSimulate(block);
return;
}
}
if(mcUsers.getProfile(player).getMiningInt() > 150){
if((Math.random() * 10) > 6){
blockProcSimulate(block);
return;
}
}
if(mcUsers.getProfile(player).getMiningInt() > 25){
if((Math.random() * 10) > 8){
blockProcSimulate(block);
return;
}
}
}
public void miningBlockCheck(Player player, Block block){
if(block.getTypeId() == 1){
mcUsers.getProfile(player).addgather(1);
mcm.getInstance().blockProcCheck(block, player);
}
//COAL
if(block.getTypeId() == 16){
mcUsers.getProfile(player).addgather(3);
mcm.getInstance().blockProcCheck(block, player);
}
//GOLD
if(block.getTypeId() == 14){
mcUsers.getProfile(player).addgather(20);
mcm.getInstance().blockProcCheck(block, player);
}
//DIAMOND
if(block.getTypeId() == 56){
mcUsers.getProfile(player).addgather(50);
mcm.getInstance().blockProcCheck(block, player);
}
//IRON
if(block.getTypeId() == 15){
mcUsers.getProfile(player).addgather(10);
mcm.getInstance().blockProcCheck(block, player);
}
//REDSTONE
if(block.getTypeId() == 73 || block.getTypeId() == 74){
mcUsers.getProfile(player).addgather(15);
mcm.getInstance().blockProcCheck(block, player);
}
//LAPUS
if(block.getTypeId() == 21){
mcUsers.getProfile(player).addgather(50);
mcm.getInstance().blockProcCheck(block, player);
}
}
public void woodCuttingProcCheck(Player player, Block block, Location loc){
if(mcUsers.getProfile(player).getWoodCuttingint() > 1000){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 750){
if((Math.random() * 10) > 2){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 300){
if((Math.random() * 10) > 4){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 100){
if((Math.random() * 10) > 6){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
if(mcUsers.getProfile(player).getWoodCuttingint() > 10){
if((Math.random() * 10) > 8){
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
block.getWorld().dropItemNaturally(loc, item);
return;
}
}
}
public void simulateSkillUp(Player player){
if(mcUsers.getProfile(player).getwgatheramt() > 10){
while(mcUsers.getProfile(player).getwgatheramt() > 10){
mcUsers.getProfile(player).removewgather(10);
mcUsers.getProfile(player).skillUpWoodcutting(1);
player.sendMessage(ChatColor.YELLOW+"Wood Cutting skill increased by 1. Total ("+mcUsers.getProfile(player).getWoodCutting()+")");
}
}
if(mcUsers.getProfile(player).getgatheramt() > 50){
while(mcUsers.getProfile(player).getgatheramt() > 50){
mcUsers.getProfile(player).removegather(50);
mcUsers.getProfile(player).skillUpMining(1);
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by 1. Total ("+mcUsers.getProfile(player).getMining()+")");
}
}
}
// IS TOOLS FUNCTION
public boolean isTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || //IRON
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279) //DIAMOND
{
return true;
} else {
return false;
}
}
public boolean isIronTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267)
{
return true;
} else {
return false;
}
}
public boolean isDiamondTools(ItemStack is){
if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279)
{
return true;
} else {
return false;
}
}
public void removeIron(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 265){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
}
}
}
public void removeDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 264){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
}
}
}
public boolean hasDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 264){
return true;
}
}
return false;
}
public boolean hasIron(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x.getTypeId() == 265){
return true;
}
}
return false;
}
}