From 979e0c497d5e7b5eb5cc8ca231b4ec86856ed780 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 21 Nov 2013 20:17:31 -0700 Subject: [PATCH] Implement all Woodcutter job buffs. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 208 ++++++++++- .../src/me/kaZep/Base/PlayerListener.java | 327 ++++++++++++++++-- .../src/me/kaZep/Commands/JobsDataInfo.java | 4 +- .../me/kaZep/Commands/commandBankEconomy.java | 6 +- 4 files changed, 496 insertions(+), 49 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index fe8779f..b3ee0a9 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -21,6 +21,7 @@ import java.util.logging.Logger; import java.text.*; import me.kaZep.Commands.JobsDataInfo; +import me.kaZep.Commands.JobsDataInfo.Job; import me.kaZep.Commands.commandBankEconomy; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; @@ -3696,9 +3697,19 @@ public void payDay(int time) return; } if (PlayerinJob(p,job)) { - getAccountsConfig().set(p.getName().toLowerCase()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); - saveAccountsConfig(); - p.sendMessage(ChatColor.YELLOW+"Set Declared Ultimate job to "+job); + if (getJobLv(job,p)>=40) { + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.ultimate", String.valueOf(ValidJobs[matchedjob])); + saveAccountsConfig(); + p.sendMessage(ChatColor.YELLOW+"Set Declared Ultimate job to "+job); + p.sendMessage(""); + p.sendMessage(ChatColor.GOLD+""+ChatColor.ITALIC+"Unlike other buffs, you do not just receive the buff immediately. You have to earn it."); + p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"Earn enough job exp to be proven worthy, and then search mob drops for a special trinket. The more exp you have built up, the better the chance you'll find one."); + p.sendMessage(""); + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"(Note you can still change your declared ultimate at any time during this time.)"); + } else { + p.sendMessage(ChatColor.GOLD+"Sorry, you are not a high enough level in that job yet!"); + return; + } } else { p.sendMessage(ChatColor.GOLD+"Sorry, you are not in that job!"); return; @@ -3779,8 +3790,7 @@ public void payDay(int time) } public String[] getJobs(Player p) { - String[] string= {getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"),getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"),getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")}; - return string; + return getJobs(p.getName()); } public String[] getJobs(String p) { @@ -3799,13 +3809,7 @@ public void payDay(int time) } public boolean PlayerinJob(Player p,String job) { - String[] jobs = getJobs(p); - for (int i=0;i=5) { + return true; + } else { + return false; + } + } + case JOB10: { + if (level>=10) { + return true; + } else { + return false; + } + } + case JOB20: { + if (level>=20) { + return true; + } else { + return false; + } + } + case JOB30A: { + if (level>=30 && getAccountsConfig().getInt(p.toLowerCase()+".jobs.job"+(slot+1)+"_30")==1) { + return true; + } else { + return false; + } + } + case JOB30B: { + if (level>=30 && getAccountsConfig().getInt(p.toLowerCase()+".jobs.job"+(slot+1)+"_30")==2) { + return true; + } else { + return false; + } + } + case JOB40: { + if (level>=40 && getAccountsConfig().getString(p.toLowerCase()+".jobs.ultimate").equalsIgnoreCase(job) && getAccountsConfig().getBoolean(p.toLowerCase()+".jobs.ultimatesealed")) { + return true; + } else { + return false; + } + } + default: { + return false; + } + } + } else { + return false; + } + } + return false; + } + public int getPlayerDataSlot(Player p) { //Find my data. 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) { + //We are making a valid choice. + getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(getJobSlot(arg1)+1)+"_30",Integer.valueOf(arg2)); + saveAccountsConfig(); + 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 { + p.sendMessage(ChatColor.RED+"Sorry, you already picked your Lv30 Buff Choice for that job! You can't change it."); + } + } else { + p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs [JobName] 1"+ChatColor.WHITE+" or "+ChatColor.GREEN+"/jobs [JobName] 2"+ChatColor.WHITE+" - Set Lv30 Buff Choice."); + } + } else { + p.sendMessage(ChatColor.RED+"Sorry, you are not a high enough level in that job to set your buff choice yet!"); + } + } + + public void notifyBuffMessages(Player p) { + notifyBuffMessages(p, 20); + } + + public void notifyBuffMessages(final Player p, int tick_delay) { + //Same as notifyBuffMessages(), but waits a number of ticks before displaying it. + //See which messages we have to display. + int total_tick_delay=tick_delay; + if (getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job1lv")>=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job1_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"); + int color_slot = 0; + for (int i=0;i=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job2_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"); + int color_slot = 0; + for (int i=0;i=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job3_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"); + int color_slot = 0; + for (int i=0;i=30 && getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job3_30")==0) { + //Have not selected first job's buff. + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"); + int color_slot = 0; + for (int i=0;i=40 || getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job2lv")>=40 || getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job3lv")>=40) && !getAccountsConfig().getBoolean(p.getName().toLowerCase()+".jobs.ultimate")) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + String job = getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"); + int color_slot = 0; + for (int i=0;i"+ChatColor.RESET+ChatColor.ITALIC+" replacing it with the ultimate job you want!"); + } + },total_tick_delay+=tick_delay); + } + } } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index a6add57..11f9eb5 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -33,6 +33,7 @@ import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Sound; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BrewingStand; @@ -165,6 +166,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.MaterialData; import org.bukkit.material.Pumpkin; +import org.bukkit.material.Tree; import org.bukkit.material.Wool; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; @@ -186,6 +188,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.data.DataException; import com.sk89q.worldedit.schematic.SchematicFormat; +import com.sk89q.worldedit.util.TreeGenerator.TreeType; import me.kaZep.Base.BrewingStandData; import me.kaZep.Base.FurnaceData; @@ -200,6 +203,7 @@ import me.kaZep.Base.PersistentExplorerList; import me.kaZep.Base.PlayerData; import me.kaZep.Base.SupportEntity; import me.kaZep.Base.SupportPlayer; +import me.kaZep.Commands.JobsDataInfo.Job; public class PlayerListener implements Listener @@ -1375,7 +1379,7 @@ implements Listener @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { - Player p = e.getPlayer(); + final Player p = e.getPlayer(); Team tempteam; if (this.plugin.getConfig().getBoolean("halloween-enabled")) { Bukkit.getWorld("world").setDifficulty(Difficulty.EASY); @@ -1486,31 +1490,10 @@ implements Listener playerwhitelisted=true; } } - /* - //Boss platform is created +,+ coordinates from the location specified. - File file = new File("plugins/WorldEdit/schematics/boss.schematic"); - if (file.exists()) { - try { - com.sk89q.worldedit.Vector v = new com.sk89q.worldedit.Vector(p.getLocation().getX()-8, p.getLocation().getY(), p.getLocation().getZ()-8); - World worldf = Bukkit.getWorld("world"); - BukkitWorld BWf = new BukkitWorld(worldf); - EditSession es = new EditSession(BWf, 2000000); - CuboidClipboard c1 = SchematicFormat.MCEDIT.load(file); - c1.place(es, v, true); - } catch (DataException ex) { - Bukkit.getLogger().warning("DataException while trying to create structure."); - } catch (IOException ex) { - Bukkit.getLogger().warning("IOException while trying to create structure."); - } catch (MaxChangedBlocksException ex) { - Bukkit.getLogger().warning("MaxChangedBlocksException while trying to create structure."); - } - } else { - Bukkit.getLogger().warning(("File does not exist.")); - } - */ + //System.out.println("Whitelisted Players: "+playerslist); //System.out.println("Maximum Air: "+p.getMaximumAir()); - if (!this.plugin.getAccountsConfig().contains(p.getName())) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase().toLowerCase())) { //This is a brand new player. Main.economy.withdrawPlayer(p.getName(), Main.economy.getBalance(p.getName())); Main.economy.depositPlayer(p.getName(), 70); @@ -1523,12 +1506,15 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1lv", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job1_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2lv", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job2_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3lv", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3exp", Double.valueOf(0.0d)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.job3_30", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); @@ -1579,11 +1565,19 @@ implements Listener p.sendMessage("----------------------------"); p.sendMessage(ChatColor.YELLOW+"Current Money Balance: $ "+df.format(Main.economy.bankBalance(p.getName()).balance)+", Bank Balance: $"+df.format(this.plugin.getAccountsConfig().getDouble(p.getName().toLowerCase()+".money"))); //Update account information for the stat point update. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".bonus.witherskeleton")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".jobs.job1_30")) { + //Update account information for Jobs 2.1 + Bukkit.getLogger().info("Update player "+p.getName()+" to Jobs 2.1 account format."); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1_30", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2_30", Integer.valueOf(0)); + this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3_30", Integer.valueOf(0)); + this.plugin.saveAccountsConfig(); + } + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".bonus.witherskeleton")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase()+".bonus.witherskeleton", Integer.valueOf(0)); this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".stats.stat1")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".stats.stat1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat1", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat2", Integer.valueOf(0)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".stats.stat3", Integer.valueOf(0)); @@ -1598,7 +1592,7 @@ implements Listener System.out.println("Updated " + p.getName() + "'s data with stat point update."); } //Update account information for notification settings. - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".settings.notify1")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".settings.notify1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify1", Boolean.valueOf(true)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify2", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".settings.notify3", Boolean.valueOf(true)); @@ -1619,7 +1613,7 @@ implements Listener } } if (!full) { - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_book")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_book")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_book", Boolean.valueOf(true)); this.plugin.saveAccountsConfig(); System.out.println("Updated " + p.getName() + "'s data with a Halloween Book."); @@ -1637,7 +1631,7 @@ implements Listener book.setItemMeta(bookdata); p.getInventory().addItem(book); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_vote_signs")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".join.halloween_vote_signs", Boolean.valueOf(true)); this.plugin.saveAccountsConfig(); ItemStack sign = new ItemStack(Material.SIGN,2); @@ -1648,11 +1642,11 @@ implements Listener p.sendMessage("You have received 2 vote signs. Go vote at the Pumpkin Patch for the best pumpkin! (Note that voting for yourself does not count. Please vote the best of the others' pumpkins.)"); } } else { - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".join.halloween_vote_signs")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".join.halloween_vote_signs")) { p.sendMessage("You do not have enough room in your inventory to receive Pumpkin vote signs. Clear some of your inventory and then rejoin."); } } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".halloween.chest1")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.chest1")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest1", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest2", Boolean.valueOf(false)); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest3", Boolean.valueOf(false)); @@ -1665,12 +1659,12 @@ implements Listener this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.chest10", Boolean.valueOf(false)); this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".jobs.ultimate")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".jobs.ultimate")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimate", String.valueOf("None")); this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".jobs.ultimatesealed", Boolean.valueOf(false)); this.plugin.saveAccountsConfig(); } - if (!this.plugin.getAccountsConfig().contains(p.getName() + ".halloween.wand")) { + if (!this.plugin.getAccountsConfig().contains(p.getName().toLowerCase() + ".halloween.wand")) { this.plugin.getAccountsConfig().set(p.getName().toLowerCase() + ".halloween.wand", Long.valueOf(Main.SERVER_TICK_TIME)); this.plugin.saveAccountsConfig(); } @@ -1737,6 +1731,9 @@ implements Listener Bukkit.getLogger().warning("Potion Effect Collection not accessible while trying to slow down player."); } updateTopSPLEEFSigns(); + + + this.plugin.notifyBuffMessages(p); } /* @@ -3175,6 +3172,60 @@ implements Listener } } } + + private void destroyNearbyTree(World w, Location treeNode, Location checkloc, byte type, boolean silk_touch) { + //treeNode is where the original tree is located. checkloc is the current checking location. + //Code for destroying a tree. This iterates on itself. Using a base point to determine how far out it can go. + if (treeNode.distance(checkloc)<3) { + //Loop around and find all leaves/logs. + Location newloc = null; + for (int i=-1;i<2;i++) { + for (int j=-1;j<2;j++) { + for (int k=-1;k<2;k++) { + newloc = checkloc.clone().add(i,j,k); + if (w.getBlockAt(newloc).getType()==Material.LOG && w.getBlockAt(newloc).getData()%4==type) { + //logs.add(newloc.getBlock()); + w.dropItemNaturally(newloc, new ItemStack(w.getBlockAt(newloc).getType(),1,(short)(w.getBlockAt(newloc).getData()%4))); + newloc.getBlock().setType(Material.AIR); + destroyNearbyTree(w, newloc, newloc, type, silk_touch); + } else + if (w.getBlockAt(newloc).getType()==Material.LEAVES && w.getBlockAt(newloc).getData()%4==type) { + //leaves.add(newloc.getBlock()); + //Emulate apples / saplings dropping. + if (w.getBlockAt(newloc).getData()==3) { + //Jungle sapling. + if (silk_touch) { + w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1)); + } else + if (Math.random()<=0.025) { + ItemStack item = new ItemStack(Material.SAPLING,1); + item.setDurability((short)(w.getBlockAt(newloc).getData()%4)); + w.dropItemNaturally(newloc, item); + } + } else { + if (w.getBlockAt(newloc).getData()%4==0) { + //Chance to drop an apple. + if (Math.random()<=0.02) { + w.dropItemNaturally(newloc, new ItemStack(Material.APPLE,1)); + } + } + if (silk_touch) { + w.dropItemNaturally(newloc, new ItemStack(Material.LEAVES,1)); + } else + if (Math.random()<=0.05) { + ItemStack item = new ItemStack(Material.SAPLING,1); + item.setDurability((short)(w.getBlockAt(newloc).getData()%4)); + w.dropItemNaturally(newloc, item); + } + } + newloc.getBlock().setType(Material.AIR); + destroyNearbyTree(w, treeNode, newloc, type, silk_touch); + } + } + } + } + } + } @EventHandler public void onBlockBreak(BlockBreakEvent e) { @@ -3182,6 +3233,51 @@ implements Listener //p.sendMessage("Block broke."); //p.sendMessage("Has name: "+p.getItemInHand().getItemMeta().hasDisplayName()); //p.sendMessage("Name is: "+p.getItemInHand().getItemMeta().getDisplayName()); + + //*******************************//Job Buffs Begin here! + if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB20)) { + if (p.getItemInHand().getType().name().toLowerCase().contains("axe") && !p.getItemInHand().getType().name().toLowerCase().contains("pickaxe")) { + //Make sure it's not a pickaxe before reducing durability. + if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB30A)) { + p.getItemInHand().setDurability((short)0); + } else { + if (Math.random()<=0.5) { + p.getItemInHand().setDurability((short)(p.getItemInHand().getDurability()>=1?p.getItemInHand().getDurability()-1:0)); + } + } + } + if ((e.getBlock().getType()==Material.LOG || e.getBlock().getType()==Material.WOOD)) { + p.removePotionEffect(PotionEffectType.JUMP); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,200,10)); + } + } + if (e.getBlock().getType()==Material.LOG && this.plugin.hasJobBuff("Woodcutter", p, Job.JOB40)) { + //Cut down the whole tree if you hit a log. Make sure it's a tree. + boolean findleaves=false; + boolean findground=false; + Location currentpos = e.getBlock().getLocation(); + //Look straight up, look on the sides for leaves. + while (!findleaves && currentpos.getWorld().getBlockAt(currentpos).getType()==Material.LOG) { + Location checktemp = currentpos.clone().add(0,1,0); + if (e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES || + e.getBlock().getWorld().getBlockAt(checktemp).getType()==Material.LEAVES) { + findleaves=true; //This is considered a tree. Make sure the ground below it is dirt. + //Bukkit.getLogger().info("Found leaves."); + } + currentpos=currentpos.add(0,1,0); + } + if (findleaves) { + //This is definitely a tree we can chop down. Destroy it then. + //Bukkit.getLogger().info("Identified as tree. Start Destroying."); + destroyNearbyTree(e.getBlock().getWorld() ,e.getBlock().getLocation(), e.getBlock().getLocation(), (byte)(e.getBlock().getData()%4), p.getItemInHand().getEnchantmentLevel(Enchantment.SILK_TOUCH)>0); + } + } + //*******************************//Job Buffs end here! + int myData=this.plugin.getPlayerDataSlot(p); boolean has_silktouch=false; if (!p.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { @@ -4001,9 +4097,39 @@ implements Listener } } + @EventHandler + public void onLeavesDecay(LeavesDecayEvent e) { + if (e.getBlock().getData()==0/*Has to be oak.*/) { + //We will check for nearby players. + for (int i=0;i7) && e.getClickedBlock().getData()%4==0) { + //This is Oak Leaves that were NOT placed by a player. + //Bukkit.getLogger().info("A Valid oak leaf! Apple!"); + if (this.plugin.hasJobBuff("Woodcutter", p, Job.JOB20)) { + if (Math.random()<=0.02) { + p.getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), new ItemStack(Material.APPLE)); + } + } + } + e.getClickedBlock().setType(Material.AIR); + p.playSound(e.getClickedBlock().getLocation(), Sound.DIG_GRASS, 1, 1); + p.getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, Material.LEAVES.getId()); + //Randomly drop a sapling based on type. + if (e.getClickedBlock().getData()%4==3) { + //This is a jungle leaf. + if (Math.random()<=0.025) { + e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), new ItemStack(Material.SAPLING,1,(short)(e.getClickedBlock().getData()%4))); + } + } else { + if (Math.random()<=0.05) { + e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), new ItemStack(Material.SAPLING,1,(short)(e.getClickedBlock().getData()%4))); + } + } + } + } + if (e.getAction()==Action.RIGHT_CLICK_BLOCK && p.getItemInHand().getType()==Material.SAPLING && (e.getClickedBlock().getType()==Material.GRASS || e.getClickedBlock().getType()==Material.DIRT) && this.plugin.hasJobBuff("Woodcutter", p, Job.JOB30B)) { + //Instantly grow the tree! + //Check out the data value of the sapling. + Byte data = p.getItemInHand().getData().getData(); + //Bukkit.getLogger().info("Data value for this sapling: "+data.toString()); + int tries=0; + BukkitWorld BWf = new BukkitWorld(p.getWorld()); + EditSession es = new EditSession(BWf, 1000); //STart a new editing session to create trees. + switch (data) { + case (byte)0: { + //This is a normal sapling. see if we're in a swamp biome. + //Bukkit.getLogger().info("This is a normal sapling!"); + if (e.getClickedBlock().getWorld().getBiome(e.getClickedBlock().getLocation().getBlockX(), e.getClickedBlock().getLocation().getBlockZ())==Biome.SWAMPLAND) { + if (Math.random()<=0.90) { + while (tries<100) { + //e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation().add(0,1,0), TreeType.SWAMP); + BWf.generateTree(TreeType.SWAMP, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } else { + while (tries<100) { + BWf.generateTree(TreeType.TREE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } + } else { + if (Math.random()<=0.90) { + while (tries<100) { + BWf.generateTree(TreeType.TREE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } else { + while (tries<100) { + BWf.generateTree(TreeType.BIG_TREE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } + } + }break; + case (byte)1: { + while (tries<100) { + /* + e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation().add(0,1,0), TreeType.REDWOOD); + e.getClickedBlock().getWorld().generateTree(e.getClickedBlock().getLocation().add(0,1,0), com.sk89q.worldedit.blocks.tr);*/ + BWf.generateTree(TreeType.PINE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + BWf.generateTree(TreeType.REDWOOD, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + BWf.generateTree(TreeType.TALL_REDWOOD, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + }break; + case (byte)2: { + while (tries<100) { + BWf.generateTree(TreeType.BIRCH, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + }break; + case (byte)3: { + if (Math.random()<=0.90) { + while (tries<100) { + BWf.generateTree(TreeType.SHORT_JUNGLE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } else { + while (tries<100) { + BWf.generateTree(TreeType.JUNGLE, es, new com.sk89q.worldedit.Vector(e.getClickedBlock().getLocation().add(0,1,0).getX(),e.getClickedBlock().getLocation().add(0,1,0).getY(),e.getClickedBlock().getLocation().add(0,1,0).getZ())); + tries++; + } + } + }break; + } + } + //*****************// End Job Buffs section. + if (e.getAction()==Action.RIGHT_CLICK_AIR || e.getAction()==Action.RIGHT_CLICK_BLOCK) { if (p.getItemInHand()!=null && (p.getItemInHand().getType()==Material.FLINT_AND_STEEL || p.getItemInHand().getType()==Material.LAVA_BUCKET)) { if (this.plugin.PlayerinJob(p, "Support")) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java b/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java index bedec28..2805541 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java +++ b/BankEconomyMod/src/me/kaZep/Commands/JobsDataInfo.java @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class JobsDataInfo { - enum Job {JOB5,JOB10,JOB20,JOB30A,JOB30B,JOB40}; + public enum Job {JOB5,JOB10,JOB20,JOB30A,JOB30B,JOB40}; String jobname; String introstring; String actionname1; @@ -131,7 +131,7 @@ public class JobsDataInfo { this.lv10buff=lv10; this.lv20buff=lv20; this.lv30_1buff=lv30_1; - this.lv30_2buff=lv30_1; + this.lv30_2buff=lv30_2; this.lv40buff=lv40; } public void setAction(int numb, String name) { diff --git a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java index af501f1..b8d557a 100644 --- a/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java +++ b/BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java @@ -1936,7 +1936,11 @@ public String convertToItemName(String val) { p.sendMessage(ChatColor.GOLD+"Could not find player!"); } } - } + } else + if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2) { + //Attempt to set the level 30 aspect of the job. + this.plugin.setLv30Choice(p,args[0],args[1]); + } else { p.sendMessage(this.invARGT2); }