Ability to repair armor, fuck year!.

This commit is contained in:
nossr50 2011-02-07 10:42:23 -08:00
parent 346a19dc2c
commit b36e0cb27b
5 changed files with 141 additions and 48 deletions

View File

@ -54,7 +54,6 @@ public class mcBlockListener extends BlockListener {
Block blockTo = event.getToBlock(); Block blockTo = event.getToBlock();
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9; boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
int ox = blockTo.getX(); int ox = blockTo.getX();
int oy = blockTo.getY(); int oy = blockTo.getY();

View File

@ -41,14 +41,27 @@ 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(mcm.getInstance().isTools(is) && player.isOp() && block.getTypeId() == 42){ if(mcm.getInstance().isArmor(is) && block.getTypeId() == 42){
if(mcm.getInstance().isDiamondArmor(is) && mcm.getInstance().hasDiamond(player)){
mcm.getInstance().removeDiamond(player);
is.setDurability(mcm.getInstance().getArmorRepairAmount(is, player));
mcUsers.getProfile(player).skillUpRepair(1);
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")");
} else if (mcm.getInstance().isIronArmor(is) && mcm.getInstance().hasIron(player)){
mcm.getInstance().removeIron(player);
is.setDurability(mcm.getInstance().getArmorRepairAmount(is, player));
mcUsers.getProfile(player).skillUpRepair(1);
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")");
}
}
if(mcm.getInstance().isTools(is) && block.getTypeId() == 42){
if(mcm.getInstance().isIronTools(is) && mcm.getInstance().hasIron(player)){ if(mcm.getInstance().isIronTools(is) && mcm.getInstance().hasIron(player)){
is.setDurability(mcm.getInstance().getRepairAmount(is, durability, player)); is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player));
mcm.getInstance().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 (mcm.getInstance().isDiamondTools(is) && mcm.getInstance().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(mcm.getInstance().getRepairAmount(is, durability, player)); is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player));
mcm.getInstance().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()+")");

View File

@ -40,6 +40,11 @@ public class mcc {
player.sendMessage(ChatColor.GRAY+"/party q - to quit a party"); player.sendMessage(ChatColor.GRAY+"/party q - to quit a party");
player.sendMessage(ChatColor.GRAY+"/ptp <name> - party teleport"); player.sendMessage(ChatColor.GRAY+"/ptp <name> - party teleport");
player.sendMessage(ChatColor.GRAY+"/p - toggles party chat"); player.sendMessage(ChatColor.GRAY+"/p - toggles party chat");
player.sendMessage(ChatColor.GRAY+"/setmyspawn - set your own spawn location");
player.sendMessage(ChatColor.GRAY+"/myspawn - travel to myspawn, clears inventory");
player.sendMessage(ChatColor.GRAY+"/setspawn - Server ops can designate a 'spawn'");
player.sendMessage(ChatColor.GRAY+"/spawn - Travel to the op designated spawn");
player.sendMessage(ChatColor.GRAY+"/whois - view detailed info about a player (req op)");
} }
if(mcUsers.getProfile(player).inParty() && split[0].equalsIgnoreCase("/ptp")){ if(mcUsers.getProfile(player).inParty() && split[0].equalsIgnoreCase("/ptp")){
if(split.length < 2){ if(split.length < 2){

View File

@ -67,9 +67,99 @@ public class mcm {
} }
return null; return null;
} }
public boolean checkPlayerProcRepair(Player player){
if(mcUsers.getProfile(player).getRepairInt() >= 750){
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return true;
}
} else if (mcUsers.getProfile(player).getRepairInt() >= 450 && mcUsers.getProfile(player).getRepairInt() < 750){
if(Math.random() * 10 > 4){
player.sendMessage(ChatColor.GRAY + "That felt really easy.");
return true;
}
} else if (mcUsers.getProfile(player).getRepairInt() >= 150 && mcUsers.getProfile(player).getRepairInt() < 450){
if(Math.random() * 10 > 6){
player.sendMessage(ChatColor.GRAY + "That felt pretty easy.");
return true;
}
} else if (mcUsers.getProfile(player).getRepairInt() >= 50 && mcUsers.getProfile(player).getRepairInt() < 150){
if(Math.random() * 10 > 8){
player.sendMessage(ChatColor.GRAY + "That felt easy.");
return true;
}
}
return false;
}
//This determines how much we repair //This determines how much we repair
public short getRepairAmount(ItemStack is, short durability, Player player){ public short getArmorRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
if(is.getTypeId() == 306){
if(durability < 27 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-27);
}
}
if(is.getTypeId() == 310) {
if(durability < 55 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-55);
}
}
if(is.getTypeId() == 307){
if(durability < 24 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-24);
}
}
if(is.getTypeId() == 311){
if(durability < 48 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-48);
}
}
if(is.getTypeId() == 308){
if(durability < 27 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-27);
}
}
if(is.getTypeId() == 312){
if(durability < 53 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-53);
}
}
if(is.getTypeId() == 309){
player.sendMessage("CURRENT DURABILITY: "+durability);
player.sendMessage("#1 FIRED CORRECTLY");
if(durability < 40 || checkPlayerProcRepair(player)){
player.sendMessage("#2 FIRED CORRECTLY");
return 0;
} else {
player.sendMessage("#3 FIRED CORRECTLY");
return (short) (durability - 40);
}
}
if(is.getTypeId() == 313){
if(durability < 80 || checkPlayerProcRepair(player)){
return 0;
} else {
return (short) (durability-80);
}
} else {
player.sendMessage("#4 FIRED CORRECTLY");
return durability;
}
}
public short getToolRepairAmount(ItemStack is, short durability, Player player){
//IRON SHOVEL //IRON SHOVEL
if(is.getTypeId() == 256){ if(is.getTypeId() == 256){
return 0; //full repair return 0; //full repair
@ -83,27 +173,8 @@ public class mcm {
if(durability < 84){ if(durability < 84){
return 0; return 0;
}else { }else {
if(mcUsers.getProfile(player).getRepairInt() > 750){ if(checkPlayerProcRepair(player))
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return 0; 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); return (short) (durability-84);
} }
//DIAMOND TOOLS //DIAMOND TOOLS
@ -111,27 +182,8 @@ public class mcm {
if(durability < 509){ if(durability < 509){
return 0; return 0;
} else { } else {
if(mcUsers.getProfile(player).getRepairInt() > 750){ if(checkPlayerProcRepair(player))
if(Math.random() * 10 > 2){
player.sendMessage(ChatColor.GRAY + "That took no effort.");
return 0; 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); return (short) (durability-509);
} }
} else { } else {
@ -309,6 +361,30 @@ public class mcm {
} }
} }
// IS TOOLS FUNCTION // IS TOOLS FUNCTION
public boolean isArmor(ItemStack is){
if(is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 ||
is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313){
return true;
} else {
return false;
}
}
public boolean isIronArmor(ItemStack is){
if(is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309)
{
return true;
} else {
return false;
}
}
public boolean isDiamondArmor(ItemStack is){
if(is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313)
{
return true;
} else {
return false;
}
}
public boolean isTools(ItemStack is){ public boolean isTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || //IRON 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 is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279) //DIAMOND

View File

@ -1,3 +1,3 @@
name: mcMMO name: mcMMO
main: com.bukkit.nossr50.mcMMO.mcMMO main: com.bukkit.nossr50.mcMMO.mcMMO
version: alpha version: 0.2