From c9e27397c06a39a7c9b32dd9cd1865f2c85b97db Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 23 Nov 2013 12:06:26 -0700 Subject: [PATCH] Builder job buffs Lv5&10. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 7 +- .../src/me/kaZep/Base/PlayerData.java | 8 + .../src/me/kaZep/Base/PlayerListener.java | 855 +++++++++--------- 3 files changed, 451 insertions(+), 419 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index c8e1e3e..19fff26 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -591,7 +591,7 @@ public class Main extends JavaPlugin Builder_job.addData("BRICK", 0.075, 11, 0); Builder_job.setBuffData("Builders gain access to the 'line' tool. Typing /line will make building in straight lines easier.", "Builders gain access to the 'rectangle' tool. Typing /rectangle will make building in rectangles easier.", - "When crafting irreversible Builder blocks, 75% of the blocks used for crafting will be restored to your inventory. When cooking Builder blocks, the block results will be doubled.", + "When crafting irreversible Builder blocks, 75% of the materials used for crafting will be restored to your inventory. When cooking Builder blocks, the block results will be doubled.", "Gain experience orbs (equivalent to the job XP you get) as you build.", "Building will stack a jump boost buff up to Jump Boost seconds.", "Builders gain the ability to fly when building. They immediately lose the ability to fly if they stop building for a moment, destroy a block, or enter combat. Every 100 Builder XP gained gives the Builder 5 Glowstone blocks and a stack of torches."); @@ -4117,6 +4117,11 @@ public void payDay(int time) } return 0; } + + public PlayerData getPlayerData(Player p) { + //Find my data. + return playerdata_list.get(getPlayerDataSlot(p)); + } public int getJobLv(String job, Player p) { if (PlayerinJob(p,job)) { diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerData.java b/BankEconomyMod/src/me/kaZep/Base/PlayerData.java index f72eb15..a2aa8a3 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerData.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerData.java @@ -1,6 +1,7 @@ package me.kaZep.Base; import org.bukkit.Bukkit; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -10,6 +11,7 @@ public class PlayerData { long lastinteracttime=0; long lastminetime=0; int minestreak=0; + Location clickedblock1=null; //Stores the location of a clicked block. Player data=null; public PlayerData(Player p) { this.data=p; @@ -63,6 +65,12 @@ public class PlayerData { buildamt+=2; } } + public void SetClickedBlock(Location l) { + clickedblock1 = l; + } + public Location GetClickedBlock() { + return clickedblock1; + } public Player getPlayer() { return data; } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 86f9b71..f503b4a 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -4749,6 +4749,43 @@ implements Listener } */ } + + private void restoreItems(CraftingInventory craft, ClickType click, Player p) { + ItemStack[] crafteditems = craft.getMatrix(); + if (click==ClickType.SHIFT_RIGHT || click==ClickType.SHIFT_LEFT) { + int lowestamt=9999; + for (int i=0;i=20) { - if (Math.random()<=0.05) { - ItemStack replenishitem = e.getItemInHand().clone(); - replenishitem.setAmount(1); - p.getInventory().addItem(replenishitem); - p.updateInventory(); - } - } else - if (this.plugin.getJobLv("Builder", p)>=10) { - if (Math.random()<=0.01) { - ItemStack replenishitem = e.getItemInHand().clone(); - replenishitem.setAmount(1); - p.getInventory().addItem(replenishitem); - p.updateInventory(); - } - } - if (e.getBlockPlaced().getType()==Material.COBBLESTONE) { - this.plugin.gainMoneyExp(p,"Builder",0.005,1); - if (this.plugin.getJobLv("Builder", p)>=5 && (int)this.plugin.getcurrentJobExp("Builder", p)%5==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - if (e.getBlockPlaced().getType()==Material.WOOD) { - this.plugin.gainMoneyExp(p,"Builder",0.005,2); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.LOG) { - this.plugin.gainMoneyExp(p,"Builder",0.01,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.WOOD_STEP) { - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.COBBLESTONE_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<2;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.STONE) { - this.plugin.gainMoneyExp(p,"Builder",0.015,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.FENCE) { - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.STEP) { - switch (e.getBlockPlaced().getData()) { - case 0:{ - this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 1:{ - this.plugin.gainMoneyExp(p,"Builder",0.025,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 3:{ - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 4:{ - this.plugin.gainMoneyExp(p,"Builder",0.05,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 5:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 6:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 7:{ - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 8:{ - this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 9:{ - this.plugin.gainMoneyExp(p,"Builder",0.025,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 10:{ - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 11:{ - this.plugin.gainMoneyExp(p,"Builder",0.015,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 12:{ - this.plugin.gainMoneyExp(p,"Builder",0.05,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 13:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 14:{ - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - case 15:{ - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - }break; - } - } - if (e.getBlockPlaced().getType()==Material.WOOD_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.02,4); - for (int i=0;i<4;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.LAPIS_BLOCK) { - this.plugin.gainMoneyExp(p,"Builder",0.02,3); - for (int i=0;i<3;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.COBBLE_WALL) { - this.plugin.gainMoneyExp(p,"Builder",0.025,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.NETHER_BRICK_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.025,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.NETHER_BRICK) { - this.plugin.gainMoneyExp(p,"Builder",0.03,5); - for (int i=0;i<5;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.NETHER_FENCE) { - this.plugin.gainMoneyExp(p,"Builder",0.03,6); - for (int i=0;i<6;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.WOOL) { - this.plugin.gainMoneyExp(p,"Builder",0.035,7); - for (int i=0;i<7;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.getMaterial(109)) { - this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.getMaterial(98)) { - this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.GLASS) { - this.plugin.gainMoneyExp(p,"Builder",0.04,8); - for (int i=0;i<8;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.GLOWSTONE) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.HARD_CLAY) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.STAINED_CLAY) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.SANDSTONE_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.05,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.SANDSTONE) { - this.plugin.gainMoneyExp(p,"Builder",0.06,10); - for (int i=0;i<10;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.QUARTZ_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.IRON_FENCE) { - this.plugin.gainMoneyExp(p,"Builder",0.06,12); - for (int i=0;i<12;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.BRICK_STAIRS) { - this.plugin.gainMoneyExp(p,"Builder",0.065,9); - for (int i=0;i<9;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.QUARTZ_BLOCK) { - this.plugin.gainMoneyExp(p,"Builder",0.07,14); - for (int i=0;i<14;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - if (e.getBlockPlaced().getType()==Material.BRICK) { - this.plugin.gainMoneyExp(p,"Builder",0.075,11); - for (int i=0;i<11;i++) { - if (this.plugin.getJobLv("Builder", p)>=5 && ((((int)this.plugin.getcurrentJobExp("Builder", p))%5)-i)==0) { - //Give a torch to the player. - p.getInventory().addItem(new ItemStack(Material.TORCH,1)); p.updateInventory(); - } - } - } - } - } + if (this.plugin.PlayerinJob(p, "Miner")) { this.plugin.playerdata_list.get(myData).BadInteract(e.getBlockPlaced().getType()); } @@ -12577,6 +12222,144 @@ implements Listener } return new ItemStack(insert_item); //Something went wrong. Just return the item itself so it's back to the player. So we don't get rid of it. } + + void getBuilderCredit(Block b, Player p) { + int myData = this.plugin.getPlayerDataSlot(p); + if (this.plugin.PlayerinJob(p, "Builder")) { + if (this.plugin.playerdata_list.get(myData).GoodInteract()) { + if (b.getType()==Material.COBBLESTONE) { + this.plugin.gainMoneyExp(p,"Builder",0.005,1); + } + if (b.getType()==Material.WOOD) { + this.plugin.gainMoneyExp(p,"Builder",0.005,2); + } + if (b.getType()==Material.LOG) { + this.plugin.gainMoneyExp(p,"Builder",0.01,3); + } + if (b.getType()==Material.WOOD_STEP) { + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + } + if (b.getType()==Material.COBBLESTONE_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + } + if (b.getType()==Material.STONE) { + this.plugin.gainMoneyExp(p,"Builder",0.015,4); + } + if (b.getType()==Material.FENCE) { + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + } + if (b.getType()==Material.STEP) { + switch (b.getData()) { + case 0:{ + this.plugin.gainMoneyExp(p,"Builder",0.02,4); + }break; + case 1:{ + this.plugin.gainMoneyExp(p,"Builder",0.025,4); + }break; + case 3:{ + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + }break; + case 4:{ + this.plugin.gainMoneyExp(p,"Builder",0.05,9); + }break; + case 5:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + }break; + case 6:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + }break; + case 7:{ + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + }break; + case 8:{ + this.plugin.gainMoneyExp(p,"Builder",0.02,4); + }break; + case 9:{ + this.plugin.gainMoneyExp(p,"Builder",0.025,4); + }break; + case 10:{ + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + }break; + case 11:{ + this.plugin.gainMoneyExp(p,"Builder",0.015,3); + }break; + case 12:{ + this.plugin.gainMoneyExp(p,"Builder",0.05,9); + }break; + case 13:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + }break; + case 14:{ + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + }break; + case 15:{ + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + }break; + } + } + if (b.getType()==Material.WOOD_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.02,4); + } + if (b.getType()==Material.LAPIS_BLOCK) { + this.plugin.gainMoneyExp(p,"Builder",0.02,3); + } + if (b.getType()==Material.COBBLE_WALL) { + this.plugin.gainMoneyExp(p,"Builder",0.025,5); + } + if (b.getType()==Material.NETHER_BRICK_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.025,5); + } + if (b.getType()==Material.NETHER_BRICK) { + this.plugin.gainMoneyExp(p,"Builder",0.03,5); + } + if (b.getType()==Material.NETHER_FENCE) { + this.plugin.gainMoneyExp(p,"Builder",0.03,6); + } + if (b.getType()==Material.WOOL) { + this.plugin.gainMoneyExp(p,"Builder",0.035,7); + } + if (b.getType()==Material.getMaterial(109)) { + this.plugin.gainMoneyExp(p,"Builder",0.04,8); + } + if (b.getType()==Material.getMaterial(98)) { + this.plugin.gainMoneyExp(p,"Builder",0.04,8); + } + if (b.getType()==Material.GLASS) { + this.plugin.gainMoneyExp(p,"Builder",0.04,8); + } + if (b.getType()==Material.GLOWSTONE) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + } + if (b.getType()==Material.HARD_CLAY) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + } + if (b.getType()==Material.STAINED_CLAY) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + } + if (b.getType()==Material.SANDSTONE_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.05,10); + } + if (b.getType()==Material.SANDSTONE) { + this.plugin.gainMoneyExp(p,"Builder",0.06,10); + } + if (b.getType()==Material.QUARTZ_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + } + if (b.getType()==Material.IRON_FENCE) { + this.plugin.gainMoneyExp(p,"Builder",0.06,12); + } + if (b.getType()==Material.BRICK_STAIRS) { + this.plugin.gainMoneyExp(p,"Builder",0.065,9); + } + if (b.getType()==Material.QUARTZ_BLOCK) { + this.plugin.gainMoneyExp(p,"Builder",0.07,14); + } + if (b.getType()==Material.BRICK) { + this.plugin.gainMoneyExp(p,"Builder",0.075,11); + } + } + } + } @EventHandler public void onPlayerInteract(PlayerInteractEvent e) @@ -12588,6 +12371,260 @@ implements Listener boolean stats = this.plugin.getAccountsConfig().getBoolean(p.getName() + ".status"); double actMon = this.plugin.getAccountsConfig().getDouble(p.getName() + ".money"); int actHand = (int)Main.economy.getBalance(p.getName()); + + //******************************//All Job Buff related items go in here. + if (e.getAction()==Action.LEFT_CLICK_BLOCK || e.getAction()==Action.RIGHT_CLICK_AIR) { + if (this.plugin.hasJobBuff("Builder", p, Job.JOB10)) { + //See if they are holding a line tool. + if (p.getItemInHand().getType()==Material.getMaterial(142)) { + //Check to see if this is the first block they clicked. + Block checkblock = null; + if (e.getAction()==Action.RIGHT_CLICK_AIR) { + checkblock = p.getTargetBlock(null, 10); + } else { + checkblock=e.getClickedBlock(); + } + PlayerData pd = this.plugin.getPlayerData(p); + if (pd.GetClickedBlock()==null) { + p.sendMessage("Set first block. Left-click another block of the same type to build an outlined rectangle of that block between them."); + p.sendMessage("Right-click another block of the same type to build a filled rectangle of that block between them. "+ChatColor.GRAY+ChatColor.ITALIC+"If you wish to cancel, swap items."); + pd.SetClickedBlock(checkblock.getLocation()); + } else { + if (pd.GetClickedBlock().distance(checkblock.getLocation())<=500) {//Make sure the range is small enough. + //Compare the blocks and see if they are the same. + boolean successful=true; + if (pd.GetClickedBlock().getBlock().getType().getId()==checkblock.getType().getId() && + pd.GetClickedBlock().getBlock().getData()==checkblock.getData()) { + boolean ranOutOfBlocks=false; + Location pt1 = pd.GetClickedBlock(); + Location pt2 = checkblock.getLocation(); + if (e.getAction()==Action.LEFT_CLICK_BLOCK) { + //This is an outlined rectangle. + int xdiff=pt2.getBlockX()-pt1.getBlockX(); + int ydiff=pt2.getBlockY()-pt1.getBlockY(); + int zdiff=pt2.getBlockZ()-pt1.getBlockZ(); + Bukkit.getLogger().info("xdiff:"+xdiff+", ydiff:"+ydiff+", zdiff:"+zdiff); + for (int x=0;xmaxdiff) {maxdiff=Math.abs(xdiff); mode=0;} + if (Math.abs(ydiff)>maxdiff) {maxdiff=Math.abs(ydiff); mode=1;} + if (Math.abs(zdiff)>maxdiff) {maxdiff=Math.abs(zdiff); mode=2;} + + if (mode==0) { + ystep = (double)ydiff/xdiff; + zstep = (double)zdiff/xdiff; + } + if (mode==1) { + xstep = (double)xdiff/ydiff; + zstep = (double)zdiff/ydiff; + } + if (mode==2) { + xstep = (double)xdiff/zdiff; + ystep = (double)ydiff/zdiff; + } + if ((int)Math.signum(xstep)!=(int)Math.signum(xdiff)) {xstep*=-1;} + if ((int)Math.signum(ystep)!=(int)Math.signum(ydiff)) {ystep*=-1;} + if ((int)Math.signum(zstep)!=(int)Math.signum(zdiff)) {zstep*=-1;} + + Bukkit.getLogger().info("Line Drawer: Initialized mode "+mode+". xstep="+xstep+", ystep="+ystep+", zstep="+zstep+" | xdiff="+xdiff+", ydiff="+ydiff+", zdiff="+zdiff+"."); + Bukkit.getLogger().info("Going from: "+pt1+" to "+pt2); + + boolean ranOutOfBlocks = false; //Turns true if the player runs out of building blocks. + + //Now that we know which direction we always step in, start moving coords. + while ((pt1.clone().add(xcur,ycur,zcur).getBlockX()!=pt2.getBlockX() || + pt1.clone().add(xcur,ycur,zcur).getBlockY()!=pt2.getBlockY() || + pt1.clone().add(xcur,ycur,zcur).getBlockZ()!=pt2.getBlockZ()) && !ranOutOfBlocks) { + Bukkit.getLogger().info(" Location: ("+pt1.clone().add(xcur,ycur,zcur).toString()+")"); + //Get the block at this location. Make sure it's AIR, and then see if the block is in the player's inventory. + //If it is, we can place one down and subtract one from the inventory. + if (e.getPlayer().getWorld().getBlockAt(pt1.clone().add(xcur,ycur,zcur)).getType()==Material.AIR) { + if (e.getPlayer().getInventory().containsAtLeast(new ItemStack(pd.GetClickedBlock().getBlock().getType(),1,(short)pd.GetClickedBlock().getBlock().getData()), 1)) { + Bukkit.getLogger().info(" Was AIR. Block has been changed."); + //Get the amount holding. Then remove it and add one back for the player. + ItemStack[] items = e.getPlayer().getInventory().getContents(); + //Loop through items until we find the right type. + for (int i=0;i