Skip to content

Commit 4c75cf7

Browse files
committed
Merge branch '1.21.8' into 1.21.10
# Conflicts: # fabric/build.gradle.kts # settings.gradle.kts
2 parents 518bb0b + 2a3e9a6 commit 4c75cf7

14 files changed

Lines changed: 97 additions & 68 deletions

common/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77

88
architectury {
99
common(providers.gradleProperty("enabled_platforms").get().split(","))
10+
injectInjectables = false
1011
}
1112

1213
loom {
@@ -23,7 +24,7 @@ dependencies {
2324
modCompileOnly(libs.baritone.fabric)
2425
modCompileOnly(libs.waystones.fabric)
2526
modCompileOnly(libs.balm.fabric)
26-
modCompileOnly(libs.fabric.waystones)
27+
modCompileOnly(libs.wraith.waystones)
2728
modCompileOnly(libs.worldtools)
2829
implementation(libs.oldbiomes)
2930
implementation(libs.sqlite)

common/src/main/java/xaeroplus/module/impl/WaystoneSync.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,31 @@
2222
import xaeroplus.settings.Settings;
2323
import xaeroplus.util.BlayWaystonesHelper;
2424
import xaeroplus.util.ColorHelper.WaystoneColor;
25-
import xaeroplus.util.FabricWaystonesHelper;
25+
import xaeroplus.util.DefaultWraithWaystonesHelper;
26+
import xaeroplus.util.IWraithWaystonesHelper;
2627
import xaeroplus.util.WaystonesHelper;
2728

2829
import java.util.List;
2930
import java.util.Locale;
31+
import java.util.ServiceLoader;
3032

3133
import static xaeroplus.event.XaeroWorldChangeEvent.WorldChangeType.EXIT_WORLD;
3234

3335
public class WaystoneSync extends Module {
3436
private final BlayWaystonesHelper blayWaystonesHelper = new BlayWaystonesHelper();
37+
private final IWraithWaystonesHelper wraithWaystonesHelper = initWraithWaystonesHelper();
38+
private static IWraithWaystonesHelper initWraithWaystonesHelper() {
39+
try {
40+
if (WaystonesHelper.isWraithWaystonesPresent()) {
41+
return ServiceLoader.load(IWraithWaystonesHelper.class).findFirst().get();
42+
}
43+
} catch (Exception e) {
44+
// fall through
45+
XaeroPlus.LOGGER.error("Error loading Wraith Waystones Helper, falling back to default", e);
46+
}
47+
return new DefaultWraithWaystonesHelper();
48+
}
49+
3550
private WaystoneColor color = WaystoneColor.RANDOM;
3651
private boolean separateWaypointSet = false;
3752
private WaypointVisibilityType visibilityType = WaypointVisibilityType.LOCAL;
@@ -41,9 +56,6 @@ public void onEnable() {
4156
if (WaystonesHelper.isWaystonesPresent()) {
4257
blayWaystonesHelper.subscribeWaystonesEvent();
4358
}
44-
if (WaystonesHelper.isFabricWaystonesPresent()) {
45-
FabricWaystonesHelper.subcribeWaystonesEventsRunnable.run();
46-
}
4759
reloadWaystones();
4860
}
4961

@@ -69,16 +81,17 @@ public void onClientTickEvent(final ClientTickEvent.Post event) {
6981
}
7082
}
7183
}
72-
} else if (WaystonesHelper.isFabricWaystonesPresent()) {
73-
if (FabricWaystonesHelper.shouldSync) {
84+
}
85+
if (WaystonesHelper.isWraithWaystonesPresent()) {
86+
if (wraithWaystonesHelper.shouldSync()) {
7487
syncFabricWaystones();
75-
FabricWaystonesHelper.shouldSync = false;
88+
wraithWaystonesHelper.setShouldSync(false);
7689
}
7790
}
7891
}
7992

8093
public void syncFabricWaystones() {
81-
commonWaystoneSync(FabricWaystonesHelper.getWaystones());
94+
commonWaystoneSync(wraithWaystonesHelper.getWaystones());
8295
}
8396

8497
public boolean syncBlayWaystones() {
@@ -185,7 +198,7 @@ public void setVisibilityType(final Settings.WaystoneWpVisibilityType visibility
185198

186199
public void reloadWaystones() {
187200
blayWaystonesHelper.shouldSync = true;
188-
FabricWaystonesHelper.shouldSync = true;
201+
wraithWaystonesHelper.setShouldSync(true);
189202
}
190203

191204
public record Waystone(String name, ResourceKey<Level> dimension, int x, int y, int z, @Nullable WaypointColor color) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package xaeroplus.util;
2+
3+
import xaeroplus.module.impl.WaystoneSync;
4+
5+
import java.util.List;
6+
7+
public class DefaultWraithWaystonesHelper implements IWraithWaystonesHelper {
8+
9+
@Override
10+
public boolean shouldSync() {
11+
return false;
12+
}
13+
14+
@Override
15+
public void setShouldSync(boolean shouldSync) {}
16+
17+
@Override
18+
public List<WaystoneSync.Waystone> getWaystones() {
19+
return List.of();
20+
}
21+
}

common/src/main/java/xaeroplus/util/FabricWaystonesHelper.java

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package xaeroplus.util;
2+
3+
import xaeroplus.module.impl.WaystoneSync;
4+
5+
import java.util.List;
6+
7+
public interface IWraithWaystonesHelper {
8+
boolean shouldSync();
9+
void setShouldSync(boolean shouldSync);
10+
List<WaystoneSync.Waystone> getWaystones();
11+
}

common/src/main/java/xaeroplus/util/WaystonesHelper.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
public class WaystonesHelper {
99
private static boolean isWaystonesPresent = false;
10-
private static boolean isFabricWaystonesPresent = false;
10+
private static boolean isWraithWaystonesPresent = false;
1111
private static boolean checked = false;
12-
private static boolean fabricChecked = false;
12+
private static boolean wraithChecked = false;
1313

1414
public static boolean isWaystonesPresent() {
1515
if (!checked) {
@@ -28,23 +28,23 @@ public static boolean isWaystonesPresent() {
2828
return isWaystonesPresent;
2929
}
3030

31-
public static boolean isFabricWaystonesPresent() {
32-
if (!fabricChecked) {
31+
public static boolean isWraithWaystonesPresent() {
32+
if (!wraithChecked) {
3333
try {
3434
Class.forName(FabricWaystones.class.getName());
35-
XaeroPlus.LOGGER.info("Found Fabric Waystones. Enabling Fabric Waystones support.");
36-
isFabricWaystonesPresent = true;
35+
XaeroPlus.LOGGER.info("Found Wraith Waystones. Enabling Wraith Waystones support.");
36+
isWraithWaystonesPresent = true;
3737
} catch (final Throwable e) {
38-
XaeroPlus.LOGGER.info("Fabric Waystones not found. Disabling Fabric Waystones support.");
39-
isFabricWaystonesPresent = false;
38+
XaeroPlus.LOGGER.info("Wraith Waystones not found. Disabling Wraith Waystones support.");
39+
isWraithWaystonesPresent = false;
4040
}
41-
fabricChecked = true;
41+
wraithChecked = true;
4242
}
43-
return isFabricWaystonesPresent;
43+
return isWraithWaystonesPresent;
4444
}
4545

4646
public static boolean isAnyWaystonesPresent() {
47-
return isWaystonesPresent() || isFabricWaystonesPresent();
47+
return isWaystonesPresent() || isWraithWaystonesPresent();
4848
}
4949

5050
}

fabric/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ plugins {
1010
architectury {
1111
platformSetupLoomIde()
1212
fabric()
13+
injectInjectables = false
1314
}
1415

1516
fabricApi {
@@ -67,7 +68,7 @@ dependencies {
6768
modCompileOnly(libs.baritone.fabric)
6869
modImplementation(libs.waystones.fabric)
6970
modImplementation(libs.balm.fabric)
70-
modCompileOnly(libs.fabric.waystones)
71+
modCompileOnly(libs.wraith.waystones)
7172
modRuntimeOnly(libs.immediatelyfast)
7273
runtimeOnly("net.lenni0451:Reflect:1.6.1") // immediatelyfast jij
7374
modImplementation(libs.modmenu)

fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import net.minecraft.client.Minecraft;
1313
import xaeroplus.XaeroPlus;
1414
import xaeroplus.commands.XPClientCommandSource;
15-
import xaeroplus.fabric.util.FabricWaystonesHelperInit;
1615
import xaeroplus.fabric.util.compat.IncompatibleMinimapWarningScreen;
1716
import xaeroplus.fabric.util.compat.XaeroPlusMinimapCompatibilityChecker;
1817
import xaeroplus.settings.Settings;
@@ -35,7 +34,6 @@ public static void initialize() {
3534
.map(ModMetadata::getVersion)
3635
.map(Version::getFriendlyString)
3736
.orElse("2.x");
38-
FabricWaystonesHelperInit.doInit();
3937
XaeroPlus.initializeSettings();
4038
Settings.REGISTRY.getKeybindings().forEach(KeyBindingHelper::registerKeyBinding);
4139
}

fabric/src/main/java/xaeroplus/fabric/util/FabricWaystonesHelperInit.java renamed to fabric/src/main/java/xaeroplus/fabric/util/WraithWaystonesHelperImpl.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,34 @@
77
import wraith.fwaystones.access.WaystoneValue;
88
import wraith.fwaystones.integration.event.WaystoneEvents;
99
import xaeroplus.module.impl.WaystoneSync;
10-
import xaeroplus.util.FabricWaystonesHelper;
10+
import xaeroplus.util.IWraithWaystonesHelper;
1111

1212
import java.util.Collections;
1313
import java.util.List;
1414
import java.util.concurrent.ConcurrentHashMap;
1515

16-
public class FabricWaystonesHelperInit {
16+
public class WraithWaystonesHelperImpl implements IWraithWaystonesHelper {
17+
private volatile boolean shouldSync = false;
1718

18-
public static void doInit() {
19-
FabricWaystonesHelper.waystoneProvider = FabricWaystonesHelperInit::getWaystones;
20-
FabricWaystonesHelper.subcribeWaystonesEventsRunnable = FabricWaystonesHelperInit::subscribeWaystonesEvents;
19+
public WraithWaystonesHelperImpl() {
20+
WaystoneEvents.FORGET_ALL_WAYSTONES_EVENT.register((p) -> onWaystoneUpdate(null));
21+
WaystoneEvents.DISCOVER_WAYSTONE_EVENT.register(this::onWaystoneUpdate);
22+
WaystoneEvents.REMOVE_WAYSTONE_EVENT.register(this::onWaystoneUpdate);
23+
WaystoneEvents.RENAME_WAYSTONE_EVENT.register(this::onWaystoneUpdate);
2124
}
2225

23-
public static void subscribeWaystonesEvents() {
24-
if (FabricWaystonesHelper.subscribed) return;
25-
WaystoneEvents.FORGET_ALL_WAYSTONES_EVENT.register((p) -> FabricWaystonesHelper.onWaystoneUpdate(null));
26-
WaystoneEvents.DISCOVER_WAYSTONE_EVENT.register(FabricWaystonesHelper::onWaystoneUpdate);
27-
WaystoneEvents.REMOVE_WAYSTONE_EVENT.register(FabricWaystonesHelper::onWaystoneUpdate);
28-
WaystoneEvents.RENAME_WAYSTONE_EVENT.register(FabricWaystonesHelper::onWaystoneUpdate);
29-
FabricWaystonesHelper.subscribed = true;
26+
@Override
27+
public boolean shouldSync() {
28+
return shouldSync;
3029
}
3130

32-
public static List<WaystoneSync.Waystone> getWaystones() {
31+
@Override
32+
public void setShouldSync(final boolean shouldSync) {
33+
this.shouldSync = shouldSync;
34+
}
35+
36+
@Override
37+
public List<WaystoneSync.Waystone> getWaystones() {
3338
var waystoneStorage = FabricWaystones.WAYSTONE_STORAGE;
3439
if (waystoneStorage == null) return Collections.emptyList();
3540
ConcurrentHashMap<String, WaystoneValue> waystones = waystoneStorage.WAYSTONES;
@@ -46,4 +51,8 @@ public static List<WaystoneSync.Waystone> getWaystones() {
4651
))
4752
.toList();
4853
}
54+
55+
void onWaystoneUpdate(final String hash) {
56+
shouldSync = true;
57+
}
4958
}

fabric/src/main/java/xaeroplus/fabric/util/compat/XaeroPlusCompatibleMinimapMixinPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class XaeroPlusCompatibleMinimapMixinPlugin implements IMixinConfigPlugin
2020

2121
@Override
2222
public void onLoad(final String mixinPackage) {
23-
if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) return;
2423
}
2524

2625
@Override

0 commit comments

Comments
 (0)