Skip to content

Commit da1ea20

Browse files
committed
Add a limit for the number of hoppers per chunk
1 parent 7e369ab commit da1ea20

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.untamedears</groupId>
77
<artifactId>Humbug</artifactId>
88
<packaging>jar</packaging>
9-
<version>1.8.22</version>
9+
<version>1.8.23</version>
1010
<name>Humbug</name>
1111
<url>https://github.com/Civcraft/Humbug</url>
1212

src/main/java/com/untamedears/humbug/Humbug.java

+23
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,29 @@ public void EmptyEnderChest(HumanEntity human) {
513513
}
514514
}
515515

516+
@BahHumbugs({
517+
@BahHumbug(opt="hopper_limit", def="false"),
518+
@BahHumbug(opt="hopper_limit_per_chunk", type=OptType.Int, def="4")
519+
})
520+
@EventHandler(priority = EventPriority.LOW)
521+
public void hopperChunkLimit(BlockPlaceEvent e) {
522+
if (!config_.get("hopper_limit").getBool() || e.getBlock().getType() != Material.HOPPER) {
523+
return;
524+
}
525+
526+
int counter = 0;
527+
for(BlockState bs : e.getBlock().getChunk().getTileEntities()) {
528+
if(bs instanceof Hopper) {
529+
counter++;
530+
if(counter >= config_.get("hopper_limit_per_chunk").getInt()) {
531+
e.setCancelled(true);
532+
e.getPlayer().sendMessage(ChatColor.RED + "The chunk you are in has reached the maximum amount of " + config_.get("hopper_limit_per_chunk").getInt() + " hoppers");
533+
return;
534+
}
535+
}
536+
}
537+
}
538+
516539
public void dropInventory(Location loc, Inventory inv) {
517540
final World world = loc.getWorld();
518541
final int end = inv.getSize();

0 commit comments

Comments
 (0)