From 25795c00f9b0f56e644e372b92760523616b06e8 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 29 Nov 2013 07:26:00 -0700 Subject: [PATCH] Implement all Digger job buffs. Add in artifact crafting / identifying system. Modify arrow shooters to allow for customizable speed and spread settings. Remove unnecessary spawn calls for mobs (also causes server slowdowns). Add in Sturdy buff. --- .../src/me/kaZep/Base/ArrowShooter.java | 13 +- BankEconomyMod/src/me/kaZep/Base/Main.java | 913 ++++++++++++------ .../src/me/kaZep/Base/PlayerListener.java | 313 ++++-- .../me/kaZep/Commands/commandBankEconomy.java | 2 +- 4 files changed, 848 insertions(+), 393 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/ArrowShooter.java b/BankEconomyMod/src/me/kaZep/Base/ArrowShooter.java index 8531e12..9cd281f 100644 --- a/BankEconomyMod/src/me/kaZep/Base/ArrowShooter.java +++ b/BankEconomyMod/src/me/kaZep/Base/ArrowShooter.java @@ -7,14 +7,21 @@ import org.bukkit.util.Vector; public class ArrowShooter { public int timer=0; public int frequency=0; - public Vector spd; + public Vector dir; public Location loc; public LivingEntity shooter; - public ArrowShooter(Vector spd, Location loc, int duration, int frequency, LivingEntity shooter) { - this.spd=spd; + public float spd = 0.6f; + public float spread = 12f; + public ArrowShooter(Vector dir, Location loc, int duration, int frequency, LivingEntity shooter) { + this(dir, loc, duration, frequency, shooter, 0.6f, 12f); + } + public ArrowShooter(Vector dir, Location loc, int duration, int frequency, LivingEntity shooter, float spd, float spread) { + this.dir=dir; this.loc=loc; this.frequency=frequency; this.timer=duration; this.shooter=shooter; + this.spd=spd; + this.spread=spread; } } diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index 0f956f1..86b3571 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -335,7 +335,9 @@ public class Main extends JavaPlugin //Add Recipe for water source crafting. ItemStack water = new ItemStack(Material.WATER, 8); ItemMeta water_name = water.getItemMeta(); - + + + List waterlore = new ArrayList(); waterlore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"Infused with the power of a"); waterlore.add(ChatColor.AQUA+"Nether Star"+ChatColor.GRAY+""+ChatColor.ITALIC+", this water can"); @@ -355,6 +357,26 @@ public class Main extends JavaPlugin Bukkit.addRecipe(nether_water); + + + //Add Battle Shovel recipe. + ItemStack shovel = new ItemStack(Material.WOOD_SPADE); + ItemMeta shovel_meta = shovel.getItemMeta(); + List shovel_meta_lore = new ArrayList(); + shovel_meta_lore.add(ChatColor.GOLD+"Whenever this shovel destroys"); + shovel_meta_lore.add(ChatColor.GOLD+"a block, it releases 20 arrows"); + shovel_meta_lore.add(ChatColor.GOLD+"that fire in the destructing"); + shovel_meta_lore.add(ChatColor.GOLD+"player's facing direction."); + shovel_meta.setLore(shovel_meta_lore); + shovel_meta.setDisplayName(ChatColor.RED+"Battle Shovel"); + shovel.setItemMeta(shovel_meta); + shovel.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, 1); + ShapedRecipe battle_shovel = new ShapedRecipe(shovel); + battle_shovel.shape("-a-","-b-","-b-"); + battle_shovel.setIngredient('a', Material.LAPIS_BLOCK); + battle_shovel.setIngredient('b', Material.STICK); + Bukkit.addRecipe(battle_shovel); + //Add Recipe for orb of distortion ItemStack orb = new ItemStack(Material.SLIME_BALL, 1); ItemMeta orb_name = orb.getItemMeta(); @@ -781,8 +803,8 @@ public class Main extends JavaPlugin "Shovels gain Unbreaking V and Efficiency IV.", "Destroying the bottom row of Sand or Gravel with a Wooden Shovel will destroy the whole stack instantly. Artifact discovery rate increased by 25%.", "Shovels you use will not break.", - "Diggers can craft a Battle Shovel (Use a Lapis block with sticks to build it). Any blocks you destroy with it will shoot 10 arrows rapidly from the destroyed block's position in the direction you are facing.", - "Artifacts will be able to be identified immediately with no identify tomes."); + "Diggers can craft a Battle Shovel (Use a Lapis block with sticks to build it). Any blocks you destroy with it will shoot 20 arrows rapidly from the destroyed block's position in the direction you are facing.", + "Artifacts will have a 100% identify rate."); /* Farmer_job.setJobName("Farmer"); @@ -864,7 +886,7 @@ public class Main extends JavaPlugin Hunter_job.setBuffData("Damage dealt increased by 4.", "Sneaking gives you invisibility. Anything targeting you loses aggro.", "Swords inflict Poison II on mobs. Movement speed increased by 20%.", - "Each time you get hit, the next hit has a 10% stacking chance of blocking for 10 seconds.", + "Each time you get hit, the next hit has a 10% increased stacking chance of blocking for 10 seconds. Hitting an enemy removes this buff.", "Attacks deal an additional 10 armor penetration damage.", "Damage dealt increased by 4, damage taken decreased by 30%, at night you are invisible. Health increased by 20."); @@ -1210,8 +1232,8 @@ public void runTick() { for (int i=0;i arrows = Bukkit.getWorld("world").getEntities(); for (int j=0;j=96) { - heightmodifier=126; - } else { - heightmodifier=63; - } - if (nearby.get(i).getType()==EntityType.CREEPER) { - LivingEntity l = (LivingEntity)nearby.get(i); - if (l.getCustomName()==null && l.getTicksLived()<6400 && !l.hasPotionEffect(PotionEffectType.INVISIBILITY)) { - if (l.getLocation().getY()<=40 && Math.random()<=0.08+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Explosive Creeper"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*1.25d,1)); - } else - if (Math.random()<=0.15) { - l.setCustomName(ChatColor.GOLD+"Explosive Creeper II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*1.75d,2)); - } else - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Destructive Creeper"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*1.25d,3)); - } else { - l.setCustomName(ChatColor.GOLD+"Destructive Creeper II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*1.75d,4)); - } - if (l!=null && l.isValid()) { - l.setHealth(Warning(l.getMaxHealth(),20)); - } - } - l.setTicksLived(6400); - } - } else - if (nearby.get(i).getType()==EntityType.SPIDER) { - LivingEntity l = (LivingEntity)nearby.get(i); - if (l.getCustomName()==null && l.getTicksLived()<6400 && !l.hasPotionEffect(PotionEffectType.INVISIBILITY)) { - if (Math.random()<=0.08+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Venomous Spider"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth(),5)); - } else - if (Math.random()<=0.15) { - l.setCustomName(ChatColor.GOLD+"Venomous Spider II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*1.5,6)); - } else - if (Math.random()<=0.35) { - l.setCustomName(ChatColor.YELLOW+"Snaring Spider"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*1.5,7)); - } else { - l.setCustomName(ChatColor.GOLD+"Snaring Spider II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()*2,8)); - } - if (l!=null && l.isValid()) { - l.setHealth(Warning(l.getMaxHealth(),21)); - } - } - l.setTicksLived(6400); - } - } else - if (nearby.get(i).getType()==EntityType.SKELETON) { - LivingEntity l = (LivingEntity)nearby.get(i); - if (l.getCustomName()==null && l.getTicksLived()<6400 && !l.hasPotionEffect(PotionEffectType.INVISIBILITY)) { - if (Math.random()<=0.10+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.85) { - l.setCustomName(ChatColor.YELLOW+"Sniper"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()/2,9)); - } else { - l.setCustomName(ChatColor.GOLD+"Sniper II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()/4,10)); - } - if (l!=null && l.isValid()) { - l.setHealth(Warning(l.getMaxHealth(),11)); - } - } - l.setTicksLived(6400); - } - } else - if (nearby.get(i).getType()==EntityType.ZOMBIE) { - LivingEntity l = (LivingEntity)nearby.get(i); - if (l.getCustomName()==null && l.getTicksLived()<6400 && !l.hasPotionEffect(PotionEffectType.INVISIBILITY)) { - if (l.getLocation().getY()<=35 && Math.random()<=0.15) { - if (Math.random()<=0.85) { - l.setCustomName(ChatColor.YELLOW+"Charge Zombie"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - l.setMaxHealth(Warning(l.getMaxHealth()+5,12)); - } else { - l.setCustomName(ChatColor.GOLD+"Charge Zombie II"); - l.setCustomNameVisible(false); - //l.setCustomNameVisible(true); - Warning(l,13); - if (l!=null && l.isValid()) { - l.setMaxHealth(l.getMaxHealth()+20); - } - } - Warning(l,23); - if (l!=null && l.isValid()) { - l.setMaxHealth(l.getMaxHealth()); - } - } else { - if (Math.random()<=0.10+((heightmodifier-l.getLocation().getY())*0.01d)) { - if (Math.random()<=0.25) { - l.setCustomName(ChatColor.GRAY+"Zombie Ninja"); - l.setCustomNameVisible(false); - l.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0, true)); - l.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 2, true)); - //l.setCustomNameVisible(true); - //A Zombie Ninja will not wear armor to stay hidden. But may carry a sword. - l.getEquipment().setChestplate(new ItemStack(Material.AIR)); - l.getEquipment().setBoots(new ItemStack(Material.AIR)); - l.getEquipment().setLeggings(new ItemStack(Material.AIR)); - l.getEquipment().setHelmet(new ItemStack(Material.AIR)); - Zombie g = (Zombie)l; - g.setBaby(true); - Warning(l,14); - if (l!=null && l.isValid()) { - l.setMaxHealth(l.getMaxHealth()*0.65d); - Warning(l,15); - if (l!=null && l.isValid()) { - l.setHealth(l.getMaxHealth()); - } - } - } - } - } - l.setTicksLived(6400); - } else { - if (l.getCustomName()!=null && (l.getCustomName().compareTo(ChatColor.YELLOW+"Charge Zombie")==0 || l.getCustomName().compareTo(ChatColor.GOLD+"Charge Zombie II")==0 || l.getCustomName().compareTo(ChatColor.DARK_PURPLE+"Charge Zombie III")==0)) { - //Destroy blocks around it. - /*Block b = l.getLocation().getBlock(); - if (b.getType()==Material.WATER || b.getType()==Material.STATIONARY_WATER || - b.getType()==Material.LAVA || b.getType()==Material.STATIONARY_LAVA) { - Vector knockback = l.getVelocity().multiply(8f); - l.setVelocity(knockback);*/ - boolean doit=true; - if (l.getKiller()!=null && l.getKiller().getLocation().getY()>l.getLocation().getY()) { - doit=false; - } - if (l.hasPotionEffect(PotionEffectType.INVISIBILITY)) { - l.removePotionEffect(PotionEffectType.INVISIBILITY); - } - if (doit) { - //Bukkit.getPlayer("sigonasr2").sendMessage("Charge Zombie!"); - if (l.getCustomName().compareTo(ChatColor.DARK_PURPLE+"Charge Zombie III")==0 && !l.isDead()) { - /*//OLD CHARGE ZOMBIE BEHAVIOR. Charge Zombie II now does this weak block destruction. - for (int k=-1;k<2;k++) { - for (int j=-1;j<2;j++) { - Location checkloc = l.getLocation().add(k,1,j); - Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,2,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,0,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - } - }*/ - for (int k=-2;k<3;k++) { - for (int j=-2;j<3;j++) { - Location checkloc = l.getLocation().add(k,1,j); - Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,2,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,0,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,-1,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - } - } - } else { - if (l.getCustomName().compareTo(ChatColor.GOLD+"Charge Zombie II")==0 && !l.isDead() && l.getKiller()!=null) { - /* - for (int k=-1;k<2;k++) { - for (int j=-1;j<2;j++) { - Location checkloc = l.getLocation().add(k,1,j); - Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,2,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,0,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - } - }*/ //Charge Zombie II's now only break blocks when YOU get hit by them. - //OLD CHARGE ZOMBIE II BEHAVIOR. - for (int k=-2;k<3;k++) { - for (int j=-2;j<3;j++) { - Location checkloc = l.getLocation().add(k,1,j); - Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER && bl.getType()!=Material.COMMAND) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,2,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER && bl.getType()!=Material.COMMAND) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,0,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER && bl.getType()!=Material.COMMAND) { - bl.breakNaturally(); - } - } - } - } else - if (l.getCustomName().compareTo(ChatColor.YELLOW+"Charge Zombie")==0 && !l.isDead() && l.getKiller()!=null) { - for (int k=-1;k<2;k++) { - for (int j=-1;j<2;j++) { - Location checkloc = l.getLocation().add(k,1,j); - Block bl = Bukkit.getWorld("world").getBlockAt(checkloc); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,2,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - bl = Bukkit.getWorld("world").getBlockAt(checkloc); - checkloc = l.getLocation().add(k,0,j); - if (bl.getType()!=Material.BEDROCK && bl.getType()!=Material.ENDER_PORTAL_FRAME && bl.getType()!=Material.ENDER_PORTAL && bl.getType()!=Material.MOB_SPAWNER) { - bl.breakNaturally(); - } - } - } - } - } - } + if (nearby.get(i) instanceof Monster) { + Monster m = (Monster)nearby.get(i); + if (m.getTarget() instanceof Player) { + if (hasJobBuff("Hunter",(Player)(m.getTarget()),Job.JOB10) && ((Player)(m.getTarget())).hasPotionEffect(PotionEffectType.INVISIBILITY)) { + m.setTarget(null); } } } @@ -3993,6 +3747,11 @@ public void payDay(int time) return ChatColor.WHITE; } + /** + * Returns the job slot of the job in the GLOBAL JOB LIST. NOT for players! + * @param job The job name to find the slot of. + * @return The slot in the array ValidJobs[]. + */ public int getJobSlot(String job) { for (int i=0;i=30) { if (arg2.equals("1") || arg2.equals("2")) { - if (getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30")==0) { + if (getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(getPlayerJobSlot(arg1, p))+"_30")==0) { //We are making a valid choice. - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30",Integer.valueOf(arg2)); + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(getPlayerJobSlot(arg1, p))+"_30",Integer.valueOf(arg2)); //saveAccountsConfig() //Commented out; p.sendMessage(ChatColor.GREEN+"You have set your Lv30 Buff choice for your "+arg1+" job to the "+((Integer.valueOf(arg2)==1)?"first":"second")+" version."); } else { @@ -5163,6 +4970,152 @@ public void payDay(int time) public void notifyBuffMessages(Player p) { notifyBuffMessages(p, 20); } + + /** + * + * @param numb The number to convert to Roman Numerals. + * @return A String version of the number converted in Roman Numeral Format. + */ + public String toRomanNumeral(int numb) { + String[] ones = {"I","II","III","IV","V","VI","VII","VIII","IX"}; + String[] tens = {"X","XX","XXX","XL","L","LX","LXX","LXXX","XC"}; + String[] hundreds = {"C","CC","CCC","CD","D","DC","DCC","DCCC","CM"}; + String RomanNumeral = ""; + if (numb>999) { + //The number is too big for our converter. + return String.valueOf(numb); + } else { + String numb_reader = String.valueOf(numb); + //Bukkit.getLogger().info("Number is "+numb_reader+". Length is "+numb_reader.length()); + int offset = 3-numb_reader.length(); + for (int i=0;i LoreData = item.getItemMeta().getLore(); + ItemMeta meta = item.getItemMeta(); + List newLoreData = new ArrayList(); + //First find all 'extra' special enchantments. + for (int i=0;i lore = new ArrayList(); + if (type==2) { + int bonus_enchant1 = (int)(Math.random()*6); //0-5. + int bonus_enchant2 = (int)(Math.random()*6); //0-5. + while (bonus_enchant2==bonus_enchant1) { + bonus_enchant2 = (int)(Math.random()*6); + } + switch (bonus_enchant1) { + case 0: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*32)+16+1)+" "+ChatColor.BLUE+"Health"); + }break; + case 1: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+20+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + }break; + case 2: { + lore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*200)+100+1)*10)+"% "+ChatColor.BLUE+"Durability"); + }break; + case 3: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+"% "+ChatColor.BLUE+"Block Chance"); + }break; + case 4: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*35)+20+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + }break; + case 5: { + lore.add(ChatColor.GRAY+"Sturdy "+toRomanNumeral((int)(Math.random()*9)+2)); + }break; + } + switch (bonus_enchant2) { + case 0: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*16)+8+1)+" "+ChatColor.BLUE+"Health"); + }break; + case 1: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*15)+10+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + }break; + case 2: { + lore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*100)+50+1)*10)+"% "+ChatColor.BLUE+"Durability"); + }break; + case 3: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*15)+5+1)+"% "+ChatColor.BLUE+"Block Chance"); + }break; + case 4: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*16)+10+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + }break; + case 5: { + lore.add(ChatColor.GRAY+"Sturdy "+toRomanNumeral((int)(Math.random()*4)+1)); + }break; + } + } else { + int bonus_enchant1 = (int)(Math.random()*5); //0-4. + int bonus_enchant2 = (int)(Math.random()*5); //0-4. + while (bonus_enchant2==bonus_enchant1) { + bonus_enchant2 = (int)(Math.random()*5); + } + switch (bonus_enchant1) { + case 0: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); + }break; + case 1: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); + }break; + case 2: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); + }break; + case 3: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*90)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); + }break; + case 4: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*15)+10+1)+" "+ChatColor.BLUE+"Damage"); + }break; + } + switch (bonus_enchant2) { + case 0: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*15)+10+1)+"% "+ChatColor.BLUE+"Critical Chance"); + }break; + case 1: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*5)+2+1)+" "+ChatColor.BLUE+"Armor Penetration"); + }break; + case 2: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*15)+10+1)+"% "+ChatColor.BLUE+"Life Steal"); + }break; + case 3: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*45)+30+1)+"% "+ChatColor.BLUE+"Attack Speed"); + }break; + case 4: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*7)+5+1)+" "+ChatColor.BLUE+"Damage"); + }break; + } + } + ItemMeta meta = legendary.getItemMeta(); + meta.setLore(lore); + meta.setDisplayName(ChatColor.BOLD+"Spiritual"+" " + itemname); + legendary.setItemMeta(meta); + sortEnchantments(legendary); + return legendary; + } + default: { + return new ItemStack(Material.AIR); //Something bad happened. So we just return nothing / a null item. + } } } else { //This is an actual Artifact piece. Has extremely strong stats with very high durability. + String itemname = ""; + if (!diamond) { + itemname+="Iron"; + } else { + itemname+="Diamond"; + } + int type=1; + double random_choose = Math.random()*9.0d; + //Bukkit.getLogger().info("Random choose is "+random_choose); + switch ((int)random_choose) { + case 0: { + itemname+=" Chestplate"; + type=2; + }break; + case 1: { + itemname+=" Helmet"; + type=2; + }break; + case 2: { + itemname+=" Leggings"; + type=2; + }break; + case 3: { + itemname+=" Boots"; + type=2; + }break; + case 4: { + itemname+=" Pickaxe"; + type=1; + }break; + case 5: { + itemname+=" Axe"; + type=1; + }break; + case 6: { + itemname+=" Spade"; + type=1; + }break; + case 7: { + itemname+=" Sword"; + type=1; + } + case 8: { + itemname="Bow"; + type=1; + }break; + } + //Choose a random enchanment. + int randomenchant = (int)(Math.random()*enchantment_id_list.length); + int enchantcount=0; + List lore = new ArrayList(); + if (type==2) { + int bonus_enchant1 = (int)(Math.random()*6); //0-5. + int enchant_count = 0; + boolean[] done = {false, false, false, false, false, false}; + while (enchant_count<3) { + switch (bonus_enchant1) { + case 0: { + if (!done[bonus_enchant1]) { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*32)+16+1)+" "+ChatColor.BLUE+"Health"); + enchant_count++; + } + }break; + case 1: { + if (!done[bonus_enchant1]) { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+20+1)+"% "+ChatColor.BLUE+"Damage Reduction"); + enchant_count++; + } + }break; + case 2: { + if (!done[bonus_enchant1]) { + lore.add(ChatColor.YELLOW+"+"+(((int)(Math.random()*200)+100+1)*10)+"% "+ChatColor.BLUE+"Durability"); + enchant_count++; + } + }break; + case 3: { + if (!done[bonus_enchant1]) { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+10+1)+"% "+ChatColor.BLUE+"Block Chance"); + enchant_count++; + } + }break; + case 4: { + if (!done[bonus_enchant1]) { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*35)+20+1)+"% "+ChatColor.BLUE+"Speed Boost Chance"); + enchant_count++; + } + }break; + case 5: { + if (!done[bonus_enchant1]) { + lore.add(ChatColor.GRAY+"Sturdy "+toRomanNumeral((int)(Math.random()*9)+2)); + } + }break; + } + done[bonus_enchant1]=true; + bonus_enchant1 = (int)(Math.random()*6); + } + } else { + int bonus_enchant1 = (int)(Math.random()*5); //0-4. + int enchant_count = 0; + boolean[] done = {false, false, false, false, false}; + while (enchant_count<3) { + if (!done[bonus_enchant1]) { + switch (bonus_enchant1) { + case 0: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+20+1)+"% "+ChatColor.BLUE+"Critical Chance"); + }break; + case 1: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*10)+4+1)+" "+ChatColor.BLUE+"Armor Penetration"); + }break; + case 2: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*30)+20+1)+"% "+ChatColor.BLUE+"Life Steal"); + }break; + case 3: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*90)+60+1)+"% "+ChatColor.BLUE+"Attack Speed"); + }break; + case 4: { + lore.add(ChatColor.YELLOW+"+"+((int)(Math.random()*15)+10+1)+" "+ChatColor.BLUE+"Damage"); + }break; + } + enchant_count++; + done[bonus_enchant1]=true; + } + bonus_enchant1 = (int)(Math.random()*5); + } + } + + ItemStack legendary = new ItemStack(Material.getMaterial(itemname.toUpperCase().replace(" ", "_"))); + while (enchantcount lore = new ArrayList(); @@ -3714,6 +3747,99 @@ implements Listener e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), artifact); } } + if (p.getItemInHand().getType()==Material.WOOD_SPADE && this.plugin.hasJobBuff("Digger", p, Job.JOB20)) { + if (this.plugin.getPlayerData(p).GoodInteract()) { + if (e.getBlock().getType()==Material.DIRT) { + this.plugin.gainMoneyExp(p,"Digger",0.005,1); + } + if (e.getBlock().getType()==Material.GRASS) { + this.plugin.gainMoneyExp(p,"Digger",0.005,2); + } + if (e.getBlock().getType()==Material.SAND) { + this.plugin.gainMoneyExp(p,"Digger",0.01,2); + } + if (e.getBlock().getType()==Material.GRAVEL) { + this.plugin.gainMoneyExp(p,"Digger",0.02,5); + } + if (e.getBlock().getType()==Material.SOUL_SAND) { + this.plugin.gainMoneyExp(p,"Digger",0.04,8); + } + if (e.getBlock().getType()==Material.CLAY) { + this.plugin.gainMoneyExp(p,"Digger",0.05,10); + } + } + if (e.getBlock().getType()==Material.SAND || + e.getBlock().getType()==Material.GRAVEL) { + double findrate = 0.0025; /*0.25% chance*/ + if (this.plugin.hasJobBuff("Digger", p, Job.JOB20)) { + findrate=0.003125; /*0.31% chance*/ + } + //Check above blocks and destroy them if possible. + //If it's gravel, drop flint sometimes instead. Check if there is silk touch and fortune too to modify the result. + int y = 1; + while ((e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(0,y,0)).getType()==Material.SAND || + e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(0,y,0)).getType()==Material.GRAVEL) && + e.getBlock().getLocation().getBlockY()+y<=256) { + if (e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(0,y,0)).getType()==Material.SAND) { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0,y,0), new ItemStack(Material.SAND)); + } else { + //This is gravel. + if (p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)>0) { + //Multiply chance of getting flint instead of gravel. + if (Math.random()<=0.25*p.getItemInHand().getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS)) { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0,y,0), new ItemStack(Material.FLINT)); + } else { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0,y,0), new ItemStack(Material.GRAVEL)); + } + } else + if (p.getItemInHand().getEnchantmentLevel(Enchantment.SILK_TOUCH)>0) { + //Always drop gravel. + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0,y,0), new ItemStack(Material.GRAVEL)); + } else { + //Drop flint sometimes. + if (Math.random()<=0.10) { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0,y,0), new ItemStack(Material.FLINT)); + } else { + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().add(0,y,0), new ItemStack(Material.GRAVEL)); + } + } + } + getDiggerCredit(p, e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(0,y,0))); + e.getBlock().getWorld().getBlockAt(e.getBlock().getLocation().add(0,y,0)).setType(Material.AIR); + if (Math.random()<=findrate) { + ItemStack artifact = new ItemStack(Material.CLAY_BALL); + ItemMeta meta = artifact.getItemMeta(); + List lore = new ArrayList(); + lore.add("This clump of material seems to"); + lore.add("be part of something ancient."); + lore.add(""); + lore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"Combine this piece with Eyes of Ender"); + lore.add(ChatColor.GRAY+""+ChatColor.ITALIC+"to perhaps restore its true potential."); + meta.setLore(lore); + artifact.setItemMeta(meta); + e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), artifact); + } + y++; + } + } + } + if (p.getItemInHand().getType()==Material.WOOD_SPADE && this.plugin.hasJobBuff("Digger", p, Job.JOB30B)) { + boolean is_battleShovel=false; + if (p.getItemInHand().hasItemMeta() && p.getItemInHand().getItemMeta().hasLore()) { + for (int i=0;i=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); - } else { - //if (currentitem.getEnchantmentLevel()) - } - } - } else - if (this.plugin.PlayerinJob(p, "Miner") && this.plugin.getJobLv("Miner", p)>=5) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_PICKAXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_PICKAXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } - } - } - if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=5) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { + + //**************************//Job Buffs begin here. + if (p.getInventory().getContents()[e.getNewSlot()]!=null) { + if (p.getInventory().getContents()[e.getNewSlot()].getType().name().toLowerCase().contains("pickaxe") && this.plugin.hasJobBuff("Miner", p, Job.JOB10)) { ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); - } - } - } else - if (this.plugin.PlayerinJob(p, "Digger") && this.plugin.getJobLv("Digger", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SPADE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SPADE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 2); - } + if (currentitem.getEnchantmentLevel(Enchantment.getByName("DIG_SPEED"))<3) { + currentitem.addUnsafeEnchantment(Enchantment.getByName("DIG_SPEED"), 3); } } - if (this.plugin.PlayerinJob(p, "Hunter") && this.plugin.getJobLv("Hunter", p)>=20) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_SWORD || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_SWORD)) { + if (p.getInventory().getContents()[e.getNewSlot()].getType().name().toLowerCase().contains("spade") && this.plugin.hasJobBuff("Digger", p, Job.JOB10)) { ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("FIRE_ASPECT"))) { - currentitem.addEnchantment(Enchantment.getByName("FIRE_ASPECT"), 2); + if (currentitem.getEnchantmentLevel(Enchantment.getByName("DURABILITY"))<5) { + currentitem.addUnsafeEnchantment(Enchantment.getByName("DURABILITY"), 5); } - } - } - if (this.plugin.PlayerinJob(p, "Woodcutter") && this.plugin.getJobLv("Woodcutter", p)>=10) { - if (p.getInventory().getContents()[e.getNewSlot()]!=null && - (p.getInventory().getContents()[e.getNewSlot()].getType()==Material.WOOD_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.IRON_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.GOLD_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.DIAMOND_AXE || - p.getInventory().getContents()[e.getNewSlot()].getType()==Material.STONE_AXE)) { - ItemStack currentitem = p.getInventory().getContents()[e.getNewSlot()]; - if (!currentitem.containsEnchantment(Enchantment.getByName("DIG_SPEED"))) { - currentitem.addEnchantment(Enchantment.getByName("DIG_SPEED"), 1); + if (currentitem.getEnchantmentLevel(Enchantment.getByName("DIG_SPEED"))<4) { + currentitem.addUnsafeEnchantment(Enchantment.getByName("DIG_SPEED"), 4); } } } + //**************************//Job Buffs end here. } public void open_LootChest(int tier, Location loc) { @@ -8761,7 +8862,7 @@ implements Listener } } } - if (this.plugin.PlayerinJob((Player)e.getDamager(), "Hunter") && this.plugin.getJobLv("Hunter", (Player)e.getDamager())>=5) { + if (this.plugin.hasJobBuff("Hunter", (Player)e.getDamager(), Job.JOB5)) { //Deal 2 extra damage. e.setDamage(e.getDamage()+4); } @@ -8935,7 +9036,7 @@ implements Listener } } } - if (this.plugin.PlayerinJob((Player)((Projectile)e.getDamager()).getShooter(), "Hunter") && this.plugin.getJobLv("Hunter", (Player)((Projectile)e.getDamager()).getShooter())>=5) { + if (this.plugin.hasJobBuff("Hunter", (Player)((Projectile)e.getDamager()).getShooter(), Job.JOB5)) { //Deal 2 extra damage. e.setDamage(e.getDamage()+4); } @@ -10023,16 +10124,23 @@ implements Listener } //*****************************// Job buffs here - if (event.getSlotType()==SlotType.RESULT && (event.getInventory().getType()==InventoryType.CRAFTING || event.getInventory().getType()==InventoryType.PLAYER || event.getInventory().getType()==InventoryType.WORKBENCH)) { + if (event.getSlotType()==SlotType.RESULT && (event.getClick()==ClickType.LEFT || event.getClick()==ClickType.RIGHT) && (event.getInventory().getType()==InventoryType.CRAFTING || event.getInventory().getType()==InventoryType.PLAYER || event.getInventory().getType()==InventoryType.WORKBENCH)) { //Check if level 5 digger. if (this.plugin.hasJobBuff("Digger", p, Job.JOB5) && event.getCurrentItem().getType()==Material.CLAY_BALL) { //This could potentially be an artifact. Check the lore. - ItemStack result = event.getCurrentItem(); + ItemStack result = event.getInventory().getItem(event.getSlot()); if (result.hasItemMeta() && result.getItemMeta().hasLore()) { if (result.getItemMeta().getLore().contains("This clump of material seems to")) { //This is an artifact. There is a 7.5% chance of it turning into an equipment. - if (Math.random()<=0.075) { - event.setCurrentItem(stack) + double identifychance = 0.075; + if (this.plugin.hasJobBuff("Digger", p, Job.JOB40)) { + identifychance = 1.0; + } + if (Math.random()<=identifychance) { + p.sendMessage(ChatColor.LIGHT_PURPLE+"You feel a magical presence convert before you."); + event.setCurrentItem(this.plugin.convertArtifact(result.clone())); + } else { + p.sendMessage(ChatColor.DARK_GRAY+"The air remains unstirred."); } } } @@ -11454,6 +11562,7 @@ implements Listener @EventHandler public void onShootArrow(ProjectileHitEvent e) { LivingEntity l = e.getEntity().getShooter(); + //Bukkit.getLogger().info("Arrow vector is: "+e.getEntity().getVelocity().toString()); if (l!=null && l.getType()==EntityType.SKELETON && l.getCustomName()!=null) { if ((l.getCustomName().compareTo(ChatColor.YELLOW+"Sniper")==0)) { boolean found=false; @@ -14290,7 +14399,7 @@ implements Listener } } - public String convertToItemName(String val) { + public static String convertToItemName(String val) { val=val.replace('_', ' '); char[] mod = val.toCharArray(); boolean first=false; diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index 99aaa89..d90a72f 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1609,7 +1609,7 @@ public String convertToItemName(String val) { teleportloc = p.getWorld().getSpawnLocation(); } teleportloc.setX(deathX); - teleportloc.setY(deathY); + teleportloc.setY(deathY+1); teleportloc.setZ(deathZ); teleportloc.setWorld(Bukkit.getWorld(deathWorld)); //p.sendMessage("Got 6.");