diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 085e3585..0719bf6b 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -77,7 +77,7 @@ public class GeneralConfigManager { public boolean PayForRenaming, PayForEachCraft, SignsEnabled, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, EnableAnounceMessage, useSilkTouchProtection, UseCustomNames, - UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit; + UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps; public int globalblocktimer, CowMilkingTimer, CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier; @@ -395,7 +395,7 @@ public class GeneralConfigManager { } Jobs.getDBManager().start(c); - + // c.getW().addComment("storage-method", "storage method, can be MySQL, sqlite"); // storageMethod = c.get("storage-method", "sqlite"); // if (storageMethod.equalsIgnoreCase("mysql")) { @@ -758,6 +758,11 @@ public class GeneralConfigManager { c.getW().addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube spliting when they are from spawner"); PreventMagmaCubeSplit = c.get("ExploitProtections.Spawner.PreventMagmaCubeSplit", true); + c.getW().addComment("ExploitProtections.Smelt.PreventHopperFillUps", "Prevent payments when hoppers moving items into furnace", "Player will not get paid, but items will be smellted"); + PreventHopperFillUps = c.get("ExploitProtections.Smelt.PreventHopperFillUps", true); + c.getW().addComment("ExploitProtections.Smelt.PreventMagmaCubeSplit", "Prevent payments when hoppers moving items into brewing stands", "Player will not get paid, but items will be brewd as they supose too"); + PreventBrewingStandFillUps = c.get("ExploitProtections.Brew.PreventBrewingStandFillUps", true); + c.getW().addComment("use-breeder-finder", "Breeder finder.", "If you are not using breeding payment, you can disable this to save little resources. Really little."); useBreederFinder = c.get("use-breeder-finder", true); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index af11d50d..019afa06 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -31,6 +31,8 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.Furnace; +import org.bukkit.block.BrewingStand; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Damageable; import org.bukkit.entity.Entity; @@ -53,19 +55,18 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.SlimeSplitEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.inventory.BrewEvent; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryMoveItemEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -89,8 +90,6 @@ import com.gamingmesh.jobs.actions.ItemActionInfo; import com.gamingmesh.jobs.actions.ItemNameActionInfo; import com.gamingmesh.jobs.api.JobsChunkChangeEvent; import com.gamingmesh.jobs.container.ActionType; -import com.gamingmesh.jobs.container.BlockProtection; -import com.gamingmesh.jobs.container.DBAction; import com.gamingmesh.jobs.container.ExploreRespond; import com.gamingmesh.jobs.container.FastPayment; import com.gamingmesh.jobs.container.JobProgression; @@ -736,6 +735,55 @@ public class JobsPaymentListener implements Listener { } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onInventoryMoveItemEventToFurnace(InventoryMoveItemEvent event) { + try { + if (event.getDestination().getType() != InventoryType.FURNACE) + return; + if (!Jobs.getGCManager().PreventHopperFillUps) + return; + if (event.getItem() == null || event.getItem().getType() == Material.AIR) + return; + Furnace furnace = (Furnace) event.getDestination().getHolder(); + //disabling plugin in world + if (!Jobs.getGCManager().canPerformActionInWorld(furnace.getWorld())) + return; + if (!this.plugin.isEnabled()) + return; + Block block = furnace.getBlock(); + + if (block.hasMetadata(this.furnaceOwnerMetadata)) + block.removeMetadata(this.furnaceOwnerMetadata, this.plugin); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onInventoryMoveItemEventToBrewingStand(InventoryMoveItemEvent event) { + try { + + if (event.getDestination().getType() != InventoryType.BREWING) + return; + if (!Jobs.getGCManager().PreventBrewingStandFillUps) + return; + if (event.getItem() == null || event.getItem().getType() == Material.AIR) + return; + BrewingStand stand = (BrewingStand) event.getDestination().getHolder(); + //disabling plugin in world + if (!Jobs.getGCManager().canPerformActionInWorld(stand.getWorld())) + return; + if (!this.plugin.isEnabled()) + return; + Block block = stand.getBlock(); + + if (block.hasMetadata(this.brewingOwnerMetadata)) + block.removeMetadata(this.brewingOwnerMetadata, this.plugin); + } catch (Exception e) { + e.printStackTrace(); + } + } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onFurnaceSmelt(FurnaceSmeltEvent event) { //disabling plugin in world