Skip to content

Commit 1dcc66b

Browse files
committed
AOneBlock Support
+ Adds support for BentoBox/AOneBlock + Added LockettePro to softdepend #19
1 parent 3f5931b commit 1dcc66b

File tree

9 files changed

+60
-5
lines changed

9 files changed

+60
-5
lines changed

AutoPickup - Recode.iml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@
2828
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
2929
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
3030
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
31+
<orderEntry type="library" scope="PROVIDED" name="Maven: world.bentobox:bentobox:1.15.1" level="project" />
32+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongodb-driver:3.8.0" level="project" />
33+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:bson:3.8.0" level="project" />
34+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:mongodb-driver-core:3.8.0" level="project" />
35+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.200" level="project" />
3136
</component>
3237
</module>

pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>us.thezircon.play</groupId>
88
<artifactId>AutoPickup</artifactId>
9-
<version>1.1.10-SNAPSHOT</version>
9+
<version>1.1.11-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AutoPickup</name>
@@ -63,6 +63,10 @@
6363
<id>sonatype</id>
6464
<url>https://oss.sonatype.org/content/groups/public/</url>
6565
</repository>
66+
<repository>
67+
<id>codemc-repo</id>
68+
<url>https://repo.codemc.org/repository/maven-public/</url>
69+
</repository>
6670
</repositories>
6771

6872
<dependencies>
@@ -72,5 +76,11 @@
7276
<version>1.16.1-R0.1-SNAPSHOT</version>
7377
<scope>provided</scope>
7478
</dependency>
79+
<dependency>
80+
<groupId>world.bentobox</groupId>
81+
<artifactId>bentobox</artifactId>
82+
<version>1.15.1</version>
83+
<scope>provided</scope>
84+
</dependency>
7585
</dependencies>
7686
</project>

src/main/java/us/thezircon/play/autopickup/AutoPickup.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public final class AutoPickup extends JavaPlugin {
2828

2929
public static boolean usingUpgradableHoppers = false; // UpgradableHoppers Patch
3030
public static boolean usingLocketteProByBrunyman = false; // LockettePro Patch
31+
public static boolean usingBentoBox = false; // BentoBox - AOneBlock Patch
3132
public static ArrayList<String> worldsBlacklist = null;
3233

3334
@Override
@@ -48,6 +49,10 @@ public void onEnable() {
4849
if ((getServer().getPluginManager().getPlugin("LockettePro") != null)) {
4950
usingLocketteProByBrunyman = true;
5051
}
52+
// BentoBox - AOneBlock Patch
53+
if ((getServer().getPluginManager().getPlugin("BentoBox") != null)) {
54+
usingBentoBox = true;
55+
}
5156

5257
messages = new Messages();
5358

src/main/java/us/thezircon/play/autopickup/listeners/BlockBreakEventListener.java

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package us.thezircon.play.autopickup.listeners;
22

33
import me.crafter.mc.lockettepro.LocketteProAPI;
4-
import org.bukkit.*;
4+
import org.bukkit.Location;
5+
import org.bukkit.Material;
6+
import org.bukkit.NamespacedKey;
57
import org.bukkit.block.*;
68
import org.bukkit.enchantments.Enchantment;
9+
import org.bukkit.entity.Entity;
10+
import org.bukkit.entity.Item;
711
import org.bukkit.entity.Player;
812
import org.bukkit.event.EventHandler;
913
import org.bukkit.event.EventPriority;
@@ -14,13 +18,13 @@
1418
import org.bukkit.inventory.meta.Damageable;
1519
import org.bukkit.inventory.meta.ItemMeta;
1620
import org.bukkit.scheduler.BukkitRunnable;
17-
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
1821
import us.thezircon.play.autopickup.AutoPickup;
1922
import us.thezircon.play.autopickup.utils.Mendable;
2023
import us.thezircon.play.autopickup.utils.TallCrops;
24+
import world.bentobox.bentobox.BentoBox;
25+
import world.bentobox.bentobox.database.objects.Island;
2126

2227
import java.util.ArrayList;
23-
import java.util.Arrays;
2428
import java.util.List;
2529

2630
public class BlockBreakEventListener implements Listener {
@@ -51,6 +55,35 @@ public void onBreak(BlockBreakEvent e) {
5155
}
5256
}
5357

58+
// AOneBlock Patch
59+
new BukkitRunnable() {
60+
@Override
61+
public void run() {
62+
if (AutoPickup.usingBentoBox) {
63+
BentoBox bb = BentoBox.getInstance();
64+
if (BentoBox.getInstance().getAddonsManager().getAddonByName("AOneBlock").isPresent()) {
65+
Island island = bb.getIslands().getIslandAt(loc).get();
66+
if (island.getCenter().equals(block.getLocation())) {
67+
for (Entity ent : loc.getWorld().getNearbyEntities(block.getLocation().add(0, 1, 0), 1, 1, 1)) {
68+
if (ent instanceof Item) {
69+
if (player.getInventory().firstEmpty() == -1) { // Checks for inventory space
70+
//Player has no space
71+
if (doFullInvMSG) {
72+
player.sendMessage(PLUGIN.getMsg().getPrefix() + " " + PLUGIN.getMsg().getFullInventory());
73+
}
74+
return;
75+
} else {
76+
player.getInventory().addItem(((Item) ent).getItemStack());
77+
ent.remove();
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}
84+
}
85+
}.runTaskLater(PLUGIN, 1);
86+
5487
// Mend Items & Give Player XP
5588
int xp = e.getExpToDrop();
5689
player.giveExp(xp); // Give player XP

src/main/resources/plugin.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ authors: [BUTTERFIELD8]
66
description: Automatically pickup broken blocks.
77
website: https://discord.gg/ncHH4FP
88
api-version: 1.13
9+
softdepend: [BentoBox, LockettePro]
910
commands:
1011
autopickup:
1112
description: Toggles the ability to automaticly pickup blocks when you mine them.

target/classes/plugin.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: AutoPickup
2-
version: 1.1.10-SNAPSHOT
2+
version: 1.1.11-SNAPSHOT
33
main: us.thezircon.play.autopickup.AutoPickup
44
prefix: AutoPickup
55
authors: [BUTTERFIELD8]
66
description: Automatically pickup broken blocks.
77
website: https://discord.gg/ncHH4FP
88
api-version: 1.13
9+
softdepend: [BentoBox, LockettePro]
910
commands:
1011
autopickup:
1112
description: Toggles the ability to automaticly pickup blocks when you mine them.
0 Bytes
Binary file not shown.
88 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)