Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate fabric implementation to events system #481

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion implementations/fabric-1.15.2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
minecraft ("com.mojang:minecraft:1.15.2")
mappings ("net.fabricmc:yarn:1.15.2+build.17:v2")
modImplementation ("net.fabricmc:fabric-loader:0.9.2+build.206")
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.19.0+build.325-1.15")
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.28.5+1.15")
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")

testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
package de.bluecolored.bluemap.fabric;

import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;

Expand All @@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
this.mod = mod;
this.eventListeners = new ArrayList<>(1);

PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
this.onPlayerJoin(server, handler.player);
});

ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
this.onPlayerLeave(server, handler.player);
});
}

public synchronized void addEventListener(ServerEventListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
Expand Down Expand Up @@ -113,8 +112,13 @@ public void onInitialize() {
Logger.global.logInfo("BlueMap unloaded!");
});

PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
this.onPlayerJoin(server, handler.player);
});

ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
this.onPlayerLeave(server, handler.player);
});

ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
if (server == this.serverInstance) this.updateSomePlayers();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
"de.bluecolored.bluemap.fabric.FabricMod"
]
},
"mixins": [
"bluemap.mixins.json"
],

"depends": {
"fabricloader": ">=0.9.0",
Expand Down
2 changes: 1 addition & 1 deletion implementations/fabric-1.16.2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
minecraft ("com.mojang:minecraft:1.16.3")
mappings ("net.fabricmc:yarn:1.16.3+build.1:v2")
modImplementation ("net.fabricmc:fabric-loader:0.9.3+build.207")
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.20.2+build.402-1.16")
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.28.4+1.16")
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")

testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
package de.bluecolored.bluemap.fabric;

import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;

Expand All @@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
this.mod = mod;
this.eventListeners = new ArrayList<>(1);

PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
this.onPlayerJoin(server, handler.player);
});

ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
this.onPlayerLeave(server, handler.player);
});
}

public synchronized void addEventListener(ServerEventListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
import de.bluecolored.bluemap.core.BlueMap;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
Expand Down Expand Up @@ -115,8 +114,13 @@ public void onInitialize() {
Logger.global.logInfo("BlueMap unloaded!");
});

PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
this.onPlayerJoin(server, handler.player);
});

ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
this.onPlayerLeave(server, handler.player);
});

ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
if (server == this.serverInstance) this.updateSomePlayers();
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading