From b36e0cb27b1f17f4b9cffe9b11ee410c53209ccc Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 7 Feb 2011 10:42:23 -0800 Subject: [PATCH] Ability to repair armor, fuck year!. --- .../bukkit/nossr50/mcMMO/mcBlockListener.java | 1 - .../nossr50/mcMMO/mcPlayerListener.java | 19 +- mcMMO/com/bukkit/nossr50/mcMMO/mcc.java | 5 + mcMMO/com/bukkit/nossr50/mcMMO/mcm.java | 162 +++++++++++++----- mcMMO/plugin.yml | 2 +- 5 files changed, 141 insertions(+), 48 deletions(-) diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java index b7d11051b..cdb37ea5e 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcBlockListener.java @@ -54,7 +54,6 @@ public class mcBlockListener extends BlockListener { Block blockTo = event.getToBlock(); boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9; - boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11; int ox = blockTo.getX(); int oy = blockTo.getY(); diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java index 735c3e44e..9d1567f67 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcPlayerListener.java @@ -41,14 +41,27 @@ public class mcPlayerListener extends PlayerListener { ItemStack is = player.getItemInHand(); if(block != null && block.getTypeId() == 42){ 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)){ - is.setDurability(mcm.getInstance().getRepairAmount(is, durability, player)); + is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player)); mcm.getInstance().removeIron(player); mcUsers.getProfile(player).skillUpRepair(1); 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 - is.setDurability(mcm.getInstance().getRepairAmount(is, durability, player)); + is.setDurability(mcm.getInstance().getToolRepairAmount(is, durability, player)); mcm.getInstance().removeDiamond(player); mcUsers.getProfile(player).skillUpRepair(1); player.sendMessage(ChatColor.YELLOW+"Repair skill increased by 1. Total ("+mcUsers.getProfile(player).getRepair()+")"); diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcc.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcc.java index fda6db044..c03520b01 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcc.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcc.java @@ -40,6 +40,11 @@ public class mcc { player.sendMessage(ChatColor.GRAY+"/party q - to quit a party"); player.sendMessage(ChatColor.GRAY+"/ptp - party teleport"); 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(split.length < 2){ diff --git a/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java b/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java index dcbcc99dd..0192b49c4 100644 --- a/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java +++ b/mcMMO/com/bukkit/nossr50/mcMMO/mcm.java @@ -67,9 +67,99 @@ public class mcm { } 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 - 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 if(is.getTypeId() == 256){ return 0; //full repair @@ -83,27 +173,8 @@ public class mcm { 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; - } - } + if(checkPlayerProcRepair(player)) + return 0; return (short) (durability-84); } //DIAMOND TOOLS @@ -111,27 +182,8 @@ public class mcm { 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; - } - } + if(checkPlayerProcRepair(player)) + return 0; return (short) (durability-509); } } else { @@ -309,6 +361,30 @@ public class mcm { } } // 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){ 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 diff --git a/mcMMO/plugin.yml b/mcMMO/plugin.yml index 5d41b4229..70f9b5ced 100644 --- a/mcMMO/plugin.yml +++ b/mcMMO/plugin.yml @@ -1,3 +1,3 @@ name: mcMMO main: com.bukkit.nossr50.mcMMO.mcMMO -version: alpha \ No newline at end of file +version: 0.2 \ No newline at end of file