Skip to content

Commit e0e2d27

Browse files
committed
Update AutoDropPlus.java
1 parent 054f963 commit e0e2d27

File tree

1 file changed

+64
-42
lines changed

1 file changed

+64
-42
lines changed

src/main/java/nekiplay/meteorplus/features/modules/player/AutoDropPlus.java

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,70 @@ public AutoDropPlus() {
2424

2525
private final SettingGroup defaultGroup = settings.getDefaultGroup();
2626

27-
private final Setting<List<Item>> items = defaultGroup.add(new ItemListSetting.Builder()
28-
.name("drop-items")
29-
.description("Items to dropping.")
30-
.build()
31-
);
32-
33-
private final Setting<Integer> delay = defaultGroup.add(new IntSetting.Builder()
34-
.name("delay")
35-
.description("drop delay.")
36-
.defaultValue(5)
37-
.min(0)
38-
.build()
39-
);
40-
41-
private final Setting<Boolean> workInstant = defaultGroup.add(new BoolSetting.Builder()
42-
.name("instant-work")
43-
.description("Drop or remove items instant.")
44-
.defaultValue(true)
45-
.visible(() -> delay.get() == 0)
46-
.build()
47-
);
48-
49-
private final Setting<Boolean> removeContainersItems = defaultGroup.add(new BoolSetting.Builder()
50-
.name("work-in-containers")
51-
.description("Remove items in chests?.")
52-
.defaultValue(true)
53-
.build()
54-
);
55-
56-
private final Setting<Boolean> autoDropExcludeHotbar = defaultGroup.add(new BoolSetting.Builder()
57-
.name("work-in-hotbar")
58-
.description("Allow hotbar?.")
59-
.defaultValue(true)
60-
.build()
61-
);
62-
63-
private final Setting<Boolean> removeItems = defaultGroup.add(new BoolSetting.Builder()
64-
.name("remover")
65-
.description("Remove items?.")
66-
.defaultValue(true)
67-
.build()
68-
);
27+
private final Setting<List<Item>> items;
28+
private final Setting<Integer> delay;
29+
private final Setting<Boolean> workInstant;
30+
private final Setting<Boolean> removeContainersItems;
31+
private final Setting<Boolean> autoDropExcludeHotbar;
32+
private final Setting<Boolean> removeItems;
33+
34+
{
35+
// Initialize settings in proper order
36+
items = defaultGroup.add(new ItemListSetting.Builder()
37+
.name("drop-items")
38+
.description("Items to dropping.")
39+
.build()
40+
);
41+
42+
// First declare workInstant without initialization
43+
final Setting<Boolean>[] workInstantRef = new Setting[1];
44+
45+
// Initialize delay with onChanged callback
46+
delay = defaultGroup.add(new IntSetting.Builder()
47+
.name("delay")
48+
.description("drop delay.")
49+
.defaultValue(5)
50+
.min(0)
51+
.onChanged(value -> {
52+
if (value != 0 && workInstantRef[0] != null && workInstantRef[0].get()) {
53+
workInstantRef[0].set(false);
54+
}
55+
})
56+
.build()
57+
);
58+
59+
// Then initialize workInstant
60+
workInstantRef[0] = defaultGroup.add(new BoolSetting.Builder()
61+
.name("instant-work")
62+
.description("Drop or remove items instant.")
63+
.defaultValue(false)
64+
.visible(() -> delay.get() == 0)
65+
.build()
66+
);
67+
workInstant = workInstantRef[0];
68+
69+
// Initialize other settings
70+
removeContainersItems = defaultGroup.add(new BoolSetting.Builder()
71+
.name("work-in-containers")
72+
.description("Work in chests?.")
73+
.defaultValue(true)
74+
.build()
75+
);
76+
77+
autoDropExcludeHotbar = defaultGroup.add(new BoolSetting.Builder()
78+
.name("work-in-hotbar")
79+
.description("Work in hotbar?.")
80+
.defaultValue(true)
81+
.build()
82+
);
83+
84+
removeItems = defaultGroup.add(new BoolSetting.Builder()
85+
.name("remover")
86+
.description("Remove items?.")
87+
.defaultValue(false)
88+
.build()
89+
);
90+
}
6991

7092
private int tick = 0;
7193

0 commit comments

Comments
 (0)