Skip to content

Commit 3860cf2

Browse files
committed
Fix: initialize wildness in AreaEntitySelectorCheckerTest.
1 parent 52c1be5 commit 3860cf2

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/main/java/org/teacon/areacontrol/AreaControl.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,7 @@ public static void onServerStart(ServerAboutToStartEvent event) {
8585
}
8686
}
8787

88-
if (AreaManager.INSTANCE.findBy(AreaControlAPI.WILDNESS) == null) {
89-
// if no wildness exist, it do will be null.
90-
91-
Area area = new Area();
92-
area.uid = AreaControlAPI.WILDNESS;
93-
area.minX = area.minZ = -1;
94-
area.maxX = area.maxZ = 1;
95-
area.minY = Integer.MAX_VALUE >> 8;
96-
area.maxY = area.minY + 1;
97-
AreaManager.INSTANCE.add(area, Level.OVERWORLD, null);
98-
}
88+
AreaManager.INSTANCE.initWildness();
9989
}
10090

10191
@SubscribeEvent

src/main/java/org/teacon/areacontrol/AreaManager.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ public void load() throws Exception {
146146
}
147147
}
148148

149+
public void initWildness() {
150+
if (AreaManager.INSTANCE.findBy(AreaControlAPI.WILDNESS) == null) {
151+
// if no wildness exist, it do will be null.
152+
153+
Area area = new Area();
154+
area.uid = AreaControlAPI.WILDNESS;
155+
area.minX = area.minZ = -1;
156+
area.maxX = area.maxZ = 1;
157+
area.minY = Integer.MAX_VALUE >> 8;
158+
area.maxY = area.minY + 1;
159+
AreaManager.INSTANCE.add(area, Level.OVERWORLD, null);
160+
}
161+
}
162+
149163
void saveDimension(ResourceKey<Level> key) throws Exception {
150164
var writeLock = this.lock.writeLock();
151165
try {

src/test/java/org/teacon/areacontrol/test/impl/AreaEntitySelectorCheckerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public static void initAreaManager() {
125125
try {
126126
AreaManager.INSTANCE.init(areaRepo);
127127
AreaManager.INSTANCE.load();
128+
AreaManager.INSTANCE.initWildness();
128129
AreaControlAPI.areaLookup = AreaLookupImpl.INSTANCE;
129130
} catch (Exception ex) {
130131
Assertions.fail("Failed to initialize AreaManager, which should not happen!");

0 commit comments

Comments
 (0)