Skip to content

Commit f31e96b

Browse files
committed
Remove HexDebugCoreAPIStubImpl
1 parent 6f310a7 commit f31e96b

File tree

2 files changed

+13
-31
lines changed

2 files changed

+13
-31
lines changed

Core/src/main/java/gay/object/hexdebug/core/api/HexDebugCoreAPI.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,41 @@
1313
import java.util.stream.Collectors;
1414

1515
public interface HexDebugCoreAPI {
16+
// required methods
17+
1618
@Nullable
17-
DebugEnvironment getDebugEnv(@NotNull CastingEnvironment env);
19+
default DebugEnvironment getDebugEnv(@NotNull CastingEnvironment env) {
20+
return null;
21+
}
1822

19-
void printDebugMessage(
23+
default void printDebugMessage(
2024
@NotNull ServerPlayer caster,
2125
@NotNull UUID sessionId,
2226
@NotNull Component message,
2327
@NotNull DebugOutputCategory category,
2428
boolean withSource
25-
);
29+
) {}
30+
31+
// singleton service loading
2632

2733
HexDebugCoreAPI INSTANCE = findInstance();
2834

2935
private static HexDebugCoreAPI findInstance() {
3036
var providers = ServiceLoader.load(HexDebugCoreAPI.class).stream().toList();
3137
if (providers.size() > 1) {
38+
// this should be impossible, barring shenanigans by other addons
3239
var names = providers.stream()
3340
.map(p -> p.type().getName())
3441
.collect(Collectors.joining(",", "[", "]"));
3542
throw new IllegalStateException(
3643
"Expected at most one HexDebugCoreAPI implementation on the classpath. Found: " + names
3744
);
3845
} else if (providers.size() == 1) {
46+
// use HexDebug's full API implementation
3947
return providers.get(0).get();
4048
} else {
41-
return new HexDebugCoreAPIStubImpl();
49+
// fall back to stub implementation if HexDebug isn't present
50+
return new HexDebugCoreAPI() {};
4251
}
4352
}
4453
}

Core/src/main/java/gay/object/hexdebug/core/api/HexDebugCoreAPIStubImpl.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)