6 Commits

Author SHA1 Message Date
1a5d9f088f Merge pull request '5.1.1' (#34) from dev into master
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 2m11s
Test and Deploy / deploy (17, ubuntu-latest) (push) Successful in 4m23s
Reviewed-on: #34
2024-12-13 19:33:23 +01:00
d74fb27d30 Update loader and fabricapi, dump to 5.1.1
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 5m32s
Test and Deploy / build (17, ubuntu-latest) (pull_request) Successful in 2m10s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
Test and Deploy / deploy (17, ubuntu-latest) (pull_request) Has been skipped
2024-12-13 19:25:04 +01:00
2d3f8c151b Include hibernate inside Toolbox archive 2024-12-13 19:23:08 +01:00
20dc34714e Merge pull request '5.1.0: add player life cycle events' (#33) from dev into master
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 2m53s
Test and Deploy / deploy (17, ubuntu-latest) (push) Successful in 4m4s
Reviewed-on: #33
2024-08-20 18:52:18 +02:00
267bd3644c ci: add cache
All checks were successful
Test and Deploy / build (17, ubuntu-latest) (push) Successful in 6m12s
Test and Deploy / deploy (17, ubuntu-latest) (push) Has been skipped
Test and Deploy / build (17, ubuntu-latest) (pull_request) Successful in 2m26s
Test and Deploy / deploy (17, ubuntu-latest) (pull_request) Has been skipped
2024-08-20 18:42:39 +02:00
d6515d9cbb feat: add player join and leave events
Some checks failed
Test and Deploy / deploy (17, ubuntu-latest) (push) Blocked by required conditions
Test and Deploy / build (17, ubuntu-latest) (push) Has been cancelled
2024-08-20 18:39:30 +02:00
10 changed files with 125 additions and 6 deletions

View File

@@ -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: |

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View 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
}
}

View File

@@ -19,7 +19,9 @@
"entrypoints": {
"main": []
},
"mixins": [],
"mixins": [
"Core.mixins.json"
],
"depends": {
"fabricloader": "^${loaderVersion}",
"fabric-api": "*",

View File

@@ -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 {

View File

@@ -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()

View File

@@ -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

View File

@@ -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