Skip to content

Commit

Permalink
Add maxPickupDelay configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Aug 11, 2019
1 parent a0539b5 commit d55986d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/config/magnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ magnet:
# It is HIGHLY UNRECOMMENDED to use a very high value
perSweep: 10

# The maximum pickup delay of items that may be
# sucked into a container
maxPickupDelay: 40

# A blacklist of items that will NOT be picked up
# Item names usually work, but be careful
blacklist:
- 500
- 500
11 changes: 11 additions & 0 deletions src/main/java/com/griefcraft/modules/flag/MagnetModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public class MagnetModule extends JavaModule {
*/
private int perSweep;

/**
* Maximum pickup delay of items to suck up
*/
private int maxPickupDelay;

/**
* The current entity queue
*/
Expand Down Expand Up @@ -109,6 +114,11 @@ public void run() {
Item item = (Item) entity;
ItemStack stack = item.getItemStack();

// check if the pickup delay is ok
if (item.getPickupDelay() > maxPickupDelay) {
continue;
}

// check if it is in the blacklist
if (itemBlacklist.contains(stack.getType())) {
continue;
Expand Down Expand Up @@ -257,6 +267,7 @@ public void load(LWC lwc) {
itemBlacklist = new ArrayList<Material>();
radius = configuration.getInt("magnet.radius", 3);
perSweep = configuration.getInt("magnet.perSweep", 20);
maxPickupDelay = configuration.getInt("magnet.maxPickupDelay", 40);

if (!enabled) {
return;
Expand Down

0 comments on commit d55986d

Please sign in to comment.