Compare commits
6 Commits
v5.0.0
...
1a5d9f088f
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a5d9f088f | |||
| d74fb27d30 | |||
| 2d3f8c151b | |||
| 20dc34714e | |||
| 267bd3644c | |||
| d6515d9cbb |
@@ -33,6 +33,14 @@ jobs:
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'oracle'
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: make gradle wrapper executable
|
||||
if: ${{ runner.os != 'Windows' }}
|
||||
run: |
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package fr.altarik.toolbox.core.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
||||
public interface PlayerLifecycleCallback {
|
||||
|
||||
Event<PlayerJoin> PLAYER_JOIN = EventFactory.createArrayBacked(PlayerJoin.class, listeners -> player -> {
|
||||
for(PlayerJoin listener : listeners) {
|
||||
ActionResult result = listener.onPlayerJoin(player);
|
||||
if (result != ActionResult.PASS)
|
||||
return result;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
Event<PlayerLeave> PLAYER_LEAVE = EventFactory.createArrayBacked(PlayerLeave.class, listeners -> player -> {
|
||||
for(PlayerLeave listener : listeners) {
|
||||
ActionResult result = listener.onPlayerLeave(player);
|
||||
if (result != ActionResult.PASS)
|
||||
return result;
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
});
|
||||
|
||||
@FunctionalInterface
|
||||
interface PlayerJoin {
|
||||
ActionResult onPlayerJoin(ServerPlayerEntity player);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface PlayerLeave {
|
||||
ActionResult onPlayerLeave(ServerPlayerEntity player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package fr.altarik.toolbox.core.mixin;
|
||||
|
||||
import fr.altarik.toolbox.core.event.PlayerLifecycleCallback;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ConnectedClientData;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(PlayerManager.class)
|
||||
public class PlayerJoinEvent {
|
||||
|
||||
@Inject(method = "onPlayerConnect", at = @At(value = "RETURN"))
|
||||
private void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData, CallbackInfo ci) {
|
||||
PlayerLifecycleCallback.PLAYER_JOIN.invoker().onPlayerJoin(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package fr.altarik.toolbox.core.mixin;
|
||||
|
||||
import fr.altarik.toolbox.core.event.PlayerLifecycleCallback;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public class PlayerLeaveEvent {
|
||||
|
||||
@Shadow
|
||||
public ServerPlayerEntity player;
|
||||
|
||||
@Inject(at = @At(value = "HEAD"), method = "onDisconnected")
|
||||
private void onPlayerQuit(Text reason, CallbackInfo ci) {
|
||||
PlayerLifecycleCallback.PLAYER_LEAVE.invoker().onPlayerLeave(player);
|
||||
}
|
||||
}
|
||||
14
Core/src/main/resources/Core.mixins.json
Normal file
14
Core/src/main/resources/Core.mixins.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "fr.altarik.toolbox.core.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"PlayerJoinEvent",
|
||||
"PlayerLeaveEvent"
|
||||
],
|
||||
"verbose": false,
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,9 @@
|
||||
"entrypoints": {
|
||||
"main": []
|
||||
},
|
||||
"mixins": [],
|
||||
"mixins": [
|
||||
"Core.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": "^${loaderVersion}",
|
||||
"fabric-api": "*",
|
||||
|
||||
@@ -2,6 +2,19 @@ dependencies {
|
||||
implementation 'org.postgresql:postgresql:42.6.0'
|
||||
testImplementation 'com.google.code.gson:gson:2.10'
|
||||
implementation project(':Core')
|
||||
// implementation "org.hibernate.orm:hibernate-core:${project.hibernate_version}"
|
||||
include "org.hibernate.orm:hibernate-core:${project.hibernate_version}"
|
||||
include "jakarta.activation:jakarta.activation-api:2.1.1"
|
||||
include "jakarta.inject:jakarta.inject-api:2.0.1"
|
||||
include "jakarta.persistence:jakarta.persistence-api:3.1.0"
|
||||
include "jakarta.transaction:jakarta.transaction-api:2.0.1"
|
||||
include "jakarta.xml.bind:jakarta.xml.bind-api:4.0.0"
|
||||
include "org.hibernate.common:hibernate-commons-annotations:7.0.3.Final"
|
||||
include "org.jboss.logging:jboss-logging:3.5.0.Final"
|
||||
include "com.fasterxml:classmate:1.5.1"
|
||||
include "net.bytebuddy:byte-buddy:1.14.18"
|
||||
include "org.antlr:antlr4-runtime:4.13.0"
|
||||
include "io.smallrye:jandex:3.2.0"
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -2,7 +2,7 @@ import fr.altarik.CreateTag
|
||||
import fr.altarik.ReportDiscord
|
||||
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.5-SNAPSHOT' apply false
|
||||
id 'fabric-loom' version '1.9-SNAPSHOT' apply false
|
||||
}
|
||||
|
||||
Properties local = new Properties()
|
||||
|
||||
@@ -4,11 +4,13 @@ fabric.loom.multiProjectOptimisation=true
|
||||
junit_version=5.9.0
|
||||
minecraft_version=1.20.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.6
|
||||
fabric_version=0.95.4+1.20.4
|
||||
loader_version=0.16.9
|
||||
fabric_version=0.97.2+1.20.4
|
||||
hibernate_version=6.6.3.Final
|
||||
|
||||
|
||||
maven_group=fr.altarik.toolbox
|
||||
maven_version=5.0.0
|
||||
maven_version=5.1.1
|
||||
|
||||
git_owner=quentinlegot
|
||||
git_repo=Toolbox
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user