Skip to content

Commit 0e3f612

Browse files
committed
Fix issues on fabric
1 parent 1bfd84d commit 0e3f612

File tree

13 files changed

+75
-51
lines changed

13 files changed

+75
-51
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
## v3.0.5
2-
- Prevent issues while migrating old config fields
1+
## v3.0.6
2+
- Fix logging on bukkit and bungeecord
3+
- Fix error with night config on fabric
4+
- Fix loading problems on fabric

common/src/main/java/gs/mclo/MclogsCommon.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ > Collection<Command<ComponentType, StyleType, ClickEventType>> getCommands(
8181
IComponentFactory<ComponentType, StyleType, ClickEventType> componentFactory
8282
) {
8383
return List.of(
84-
new MclogsCommand<>(apiClient, componentFactory),
85-
new MclogsListCommand<>(apiClient, componentFactory),
86-
new MclogsShareCommand<>(apiClient, componentFactory)
84+
new MclogsCommand<>(this, componentFactory),
85+
new MclogsListCommand<>(this, componentFactory),
86+
new MclogsShareCommand<>(this, componentFactory)
8787
);
8888
}
8989

@@ -104,4 +104,8 @@ > void registerCommands(
104104
dispatcher.register(command.build(context, builder));
105105
}
106106
}
107+
108+
public MclogsClient getApiClient() {
109+
return apiClient;
110+
}
107111
}

common/src/main/java/gs/mclo/commands/Command.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
44
import com.mojang.brigadier.context.CommandContext;
55
import gs.mclo.Constants;
6-
import gs.mclo.api.MclogsClient;
6+
import gs.mclo.MclogsCommon;
77
import gs.mclo.components.ClickEventAction;
88
import gs.mclo.components.IComponent;
99
import gs.mclo.components.IComponentFactory;
@@ -26,22 +26,22 @@ public abstract class Command<
2626
/**
2727
* The Mclogs API client
2828
*/
29-
protected final MclogsClient apiClient;
29+
protected final MclogsCommon common;
3030
/**
3131
* A component factory
3232
*/
3333
protected final IComponentFactory<ComponentType, StyleType, ClickEventType> componentFactory;
3434

3535
/**
3636
* Create a new command
37-
* @param apiClient The Mclogs API client
37+
* @param common Common mod/plugin instance
3838
* @param componentFactory A component factory
3939
*/
4040
public Command(
41-
MclogsClient apiClient,
41+
MclogsCommon common,
4242
IComponentFactory<ComponentType, StyleType, ClickEventType> componentFactory
4343
) {
44-
this.apiClient = apiClient;
44+
this.common = common;
4545
this.componentFactory = componentFactory;
4646
}
4747

@@ -86,7 +86,7 @@ public <T> int share(CommandContext<T> context, BuildContext<T, ComponentType> b
8686

8787
Constants.LOG.info("Sharing {}", source.getRootDirectory().relativize(path));
8888

89-
apiClient.uploadLog(path).thenAccept(response -> {
89+
common.getApiClient().uploadLog(path).thenAccept(response -> {
9090
if (response.isSuccess()) {
9191
var link = componentFactory.literal(response.getUrl()).style(openUrlStyle(response.getUrl()));
9292
var message = componentFactory.literal("Your log has been uploaded: ").append(link);

common/src/main/java/gs/mclo/commands/MclogsCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
44
import com.mojang.brigadier.context.CommandContext;
5-
import gs.mclo.api.MclogsClient;
5+
import gs.mclo.MclogsCommon;
66
import gs.mclo.components.IComponent;
77
import gs.mclo.components.IComponentFactory;
88
import gs.mclo.components.IStyle;
@@ -13,10 +13,10 @@ public class MclogsCommand<
1313
ClickEventType
1414
> extends Command<ComponentType, StyleType, ClickEventType> {
1515
public MclogsCommand(
16-
MclogsClient apiClient,
16+
MclogsCommon common,
1717
IComponentFactory<ComponentType, StyleType, ClickEventType> componentFactory
1818
) {
19-
super(apiClient, componentFactory);
19+
super(common, componentFactory);
2020
}
2121

2222
@Override

common/src/main/java/gs/mclo/commands/MclogsListCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
44
import com.mojang.brigadier.context.CommandContext;
55
import gs.mclo.Constants;
6-
import gs.mclo.api.MclogsClient;
6+
import gs.mclo.MclogsCommon;
77
import gs.mclo.api.Util;
88
import gs.mclo.components.ClickEventAction;
99
import gs.mclo.components.IComponent;
@@ -16,10 +16,10 @@ public class MclogsListCommand<
1616
ClickEventType
1717
> extends Command<ComponentType, StyleType, ClickEventType> {
1818
public MclogsListCommand(
19-
MclogsClient apiClient,
19+
MclogsCommon common,
2020
IComponentFactory<ComponentType, StyleType, ClickEventType> componentFactory
2121
) {
22-
super(apiClient, componentFactory);
22+
super(common, componentFactory);
2323
}
2424

2525
@Override

common/src/main/java/gs/mclo/commands/MclogsShareCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.mojang.brigadier.suggestion.Suggestions;
88
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
99
import gs.mclo.Constants;
10-
import gs.mclo.api.MclogsClient;
10+
import gs.mclo.MclogsCommon;
1111
import gs.mclo.api.Util;
1212
import gs.mclo.components.IComponent;
1313
import gs.mclo.components.IComponentFactory;
@@ -23,10 +23,10 @@ public class MclogsShareCommand<
2323
private static final String ARGUMENT_NAME = "filename";
2424

2525
public MclogsShareCommand(
26-
MclogsClient apiClient,
26+
MclogsCommon common,
2727
IComponentFactory<ComponentType, StyleType, ClickEventType> componentFactory
2828
) {
29-
super(apiClient, componentFactory);
29+
super(common, componentFactory);
3030
}
3131

3232
@Override

fabric/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dependencies {
2020
include(libs.mclogs.api)
2121
implementation(libs.nightconfig.toml)
2222
include(libs.nightconfig.toml)
23+
include(libs.nightconfig.core)
2324
}
2425

2526
loom {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package gs.mclo;
2+
3+
import gs.mclo.command.FabricClientCommandBuildContext;
4+
import net.fabricmc.api.ClientModInitializer;
5+
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
6+
7+
public class FabricClientInitializer implements ClientModInitializer {
8+
@Override
9+
public void onInitializeClient() {
10+
ClientCommandRegistrationCallback.EVENT.register((
11+
dispatcher,
12+
dedicated
13+
) -> MclogsFabric.INSTANCE.registerCommandsOnDedicatedServer(
14+
dispatcher, new FabricClientCommandBuildContext()
15+
));
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package gs.mclo;
2+
3+
import net.fabricmc.api.ModInitializer;
4+
5+
public class FabricInitializer implements ModInitializer {
6+
@Override
7+
public void onInitialize() {
8+
MclogsFabric.INSTANCE.init();
9+
}
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package gs.mclo;
2+
3+
import net.fabricmc.api.DedicatedServerModInitializer;
4+
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
5+
6+
public class FabricServerInitializer implements DedicatedServerModInitializer {
7+
@Override
8+
public void onInitializeServer() {
9+
CommandRegistrationCallback.EVENT.register(((
10+
dispatcher,
11+
registryAccess,
12+
environment
13+
) -> MclogsFabric.INSTANCE.registerCommandsOnDedicatedServer(dispatcher)));
14+
}
15+
}

0 commit comments

Comments
 (0)