mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-12 15:56:00 +08:00
Update fabric to 1.19.1 (#2519)
This commit is contained in:
parent
b53dc253f5
commit
053fe2528b
@ -8,10 +8,10 @@ dependencies {
|
||||
|
||||
shadow "net.playeranalytics:platform-abstraction-layer-api:$palVersion"
|
||||
|
||||
minecraft "com.mojang:minecraft:1.19"
|
||||
mappings "net.fabricmc:yarn:1.19+build.1:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.14.7"
|
||||
modImplementation('me.lucko:fabric-permissions-api:0.1-SNAPSHOT')
|
||||
minecraft "com.mojang:minecraft:1.19.1"
|
||||
mappings "net.fabricmc:yarn:1.19.1+build.1:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:0.14.8"
|
||||
modImplementation('me.lucko:fabric-permissions-api:0.2-SNAPSHOT')
|
||||
|
||||
// Fabric API
|
||||
Set<String> apiModules = [
|
||||
@ -19,18 +19,19 @@ dependencies {
|
||||
'fabric-command-api-v2',
|
||||
'fabric-entity-events-v1',
|
||||
'fabric-lifecycle-events-v1',
|
||||
'fabric-networking-api-v1'
|
||||
'fabric-networking-api-v1',
|
||||
'fabric-message-api-v1'
|
||||
]
|
||||
|
||||
apiModules.forEach {
|
||||
modImplementation(fabricApi.module(it, "0.55.3+1.19"))
|
||||
modImplementation(fabricApi.module(it, "0.58.5+1.19.1"))
|
||||
}
|
||||
|
||||
testImplementation project(path: ":common", configuration: 'testArtifacts')
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.release = 17
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
processResources {
|
||||
@ -77,8 +78,6 @@ shadowJar {
|
||||
exclude "jakarta/xml/**/*"
|
||||
exclude "javassist/**/*"
|
||||
|
||||
relocate 'org.slf4j', 'plan.org.slf4j'
|
||||
|
||||
relocate('org.apache', 'plan.org.apache') {
|
||||
exclude 'org/apache/logging/**'
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ public class PlanFabricEvents {
|
||||
}
|
||||
});
|
||||
|
||||
public static final Event<OnChat> ON_CHAT = EventFactory.createArrayBacked(OnChat.class, callbacks -> (handler, message) -> {
|
||||
for (OnChat callback : callbacks) {
|
||||
callback.onChat(handler, message);
|
||||
public static final Event<OnCommand> ON_COMMAND = EventFactory.createArrayBacked(OnCommand.class, callbacks -> (handler, command) -> {
|
||||
for (OnCommand callback : callbacks) {
|
||||
callback.onCommand(handler, command);
|
||||
}
|
||||
});
|
||||
|
||||
@ -113,14 +113,14 @@ public class PlanFabricEvents {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface OnChat {
|
||||
public interface OnCommand {
|
||||
/**
|
||||
* Called when a player sends a chat message / command
|
||||
*
|
||||
* @param handler the handler of the sending player
|
||||
* @param message the message sent (starts with "/" if it is a command)
|
||||
*/
|
||||
void onChat(ServerPlayNetworkHandler handler, String message);
|
||||
void onCommand(ServerPlayNetworkHandler handler, String message);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.playeranalytics.plan.gathering.listeners.events.mixin;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class EntityMixin {
|
||||
|
||||
@Inject(method = "onKilledOther", at = @At(value = "TAIL"))
|
||||
public void onDeath(ServerWorld world, LivingEntity other, CallbackInfoReturnable<Boolean> cir) {
|
||||
PlanFabricEvents.ON_KILLED.invoker().onKilled(other, (Entity) (Object) this);
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.playeranalytics.plan.gathering.listeners.events.mixin;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public class PlayerEntityMixin {
|
||||
|
||||
@Inject(method = "onKilledOther", at = @At("TAIL"))
|
||||
public void onDeath(ServerWorld world, LivingEntity other, CallbackInfoReturnable<Boolean> cir) {
|
||||
PlanFabricEvents.ON_KILLED.invoker().onKilled(other, (PlayerEntity) (Object) this);
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
package net.playeranalytics.plan.gathering.listeners.events.mixin;
|
||||
|
||||
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||
import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket;
|
||||
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
|
||||
@ -28,9 +28,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
public class ServerPlayNetworkHandlerMixin {
|
||||
|
||||
@Inject(method = "onChatMessage", at = @At("TAIL"))
|
||||
public void onChatMessage(ChatMessageC2SPacket packet, CallbackInfo ci) {
|
||||
PlanFabricEvents.ON_CHAT.invoker().onChat((ServerPlayNetworkHandler) (Object) this, packet.getChatMessage());
|
||||
@Inject(method = "onCommandExecution", at = @At("TAIL"))
|
||||
public void onCommand(CommandExecutionC2SPacket packet, CallbackInfo ci) {
|
||||
PlanFabricEvents.ON_COMMAND.invoker().onCommand((ServerPlayNetworkHandler) (Object) this, packet.command());
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;getWorld()Lnet/minecraft/server/world/ServerWorld;"))
|
||||
|
@ -23,10 +23,9 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.playeranalytics.plan.gathering.listeners.FabricListener;
|
||||
import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.UUID;
|
||||
@ -59,18 +58,17 @@ public class ChatListener implements FabricListener {
|
||||
this.errorLogger = errorLogger;
|
||||
}
|
||||
|
||||
public void onChat(ServerPlayNetworkHandler handler, String message) {
|
||||
public void onChat(ServerPlayerEntity player, String message) {
|
||||
|
||||
try {
|
||||
actOnChatEvent(handler);
|
||||
actOnChatEvent(player);
|
||||
} catch (Exception e) {
|
||||
errorLogger.error(e, ErrorContext.builder().related(handler, message).build());
|
||||
errorLogger.error(e, ErrorContext.builder().related(player, message).build());
|
||||
}
|
||||
}
|
||||
|
||||
private void actOnChatEvent(ServerPlayNetworkHandler handler) {
|
||||
private void actOnChatEvent(ServerPlayerEntity player) {
|
||||
long time = System.currentTimeMillis();
|
||||
ServerPlayerEntity player = handler.player;
|
||||
UUID uuid = player.getUuid();
|
||||
String displayName = player.getDisplayName().getString();
|
||||
|
||||
@ -82,12 +80,11 @@ public class ChatListener implements FabricListener {
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
PlanFabricEvents.ON_CHAT.register((handler, message) -> {
|
||||
ServerMessageEvents.CHAT_MESSAGE.register((message, sender, params) -> {
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
}
|
||||
onChat(handler, message);
|
||||
|
||||
onChat(sender, message.getContent().getString());
|
||||
});
|
||||
|
||||
this.enable();
|
||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.processing.processors.player.MobKillProcessor;
|
||||
import com.djrapitops.plan.processing.processors.player.PlayerKillProcessor;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityCombatEvents;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
@ -58,6 +59,9 @@ public class DeathEventListener implements FabricListener {
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, killer, killedEntity) -> {
|
||||
PlanFabricEvents.ON_KILLED.invoker().onKilled(killedEntity, killer);
|
||||
});
|
||||
PlanFabricEvents.ON_KILLED.register((victim, killer) -> {
|
||||
if (!this.isEnabled) {
|
||||
return;
|
||||
|
@ -21,6 +21,7 @@ import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorContext;
|
||||
import com.djrapitops.plan.utilities.logging.ErrorLogger;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.playeranalytics.plan.commands.CommandManager;
|
||||
@ -85,12 +86,18 @@ public class FabricAFKListener implements FabricListener {
|
||||
@Override
|
||||
public void register() {
|
||||
this.enable();
|
||||
PlanFabricEvents.ON_CHAT.register((handler, message) -> {
|
||||
ServerMessageEvents.CHAT_MESSAGE.register((message, sender, params) -> {
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
}
|
||||
event(sender);
|
||||
});
|
||||
PlanFabricEvents.ON_COMMAND.register((handler, command) -> {
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
}
|
||||
event(handler.player);
|
||||
boolean isAfkCommand = message.substring(1).toLowerCase().startsWith("afk");
|
||||
boolean isAfkCommand = command.toLowerCase().startsWith("afk");
|
||||
if (isAfkCommand) {
|
||||
UUID uuid = handler.player.getUuid();
|
||||
afkTracker.usedAfkCommand(uuid, System.currentTimeMillis());
|
||||
|
@ -19,7 +19,8 @@
|
||||
"fabric-command-api-v2": "*",
|
||||
"fabric-entity-events-v1": "*",
|
||||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-networking-v0": "*"
|
||||
"fabric-networking-v0": "*",
|
||||
"fabric-message-api-v1": "*"
|
||||
},
|
||||
"suggests": {
|
||||
"fabric-permissions-api-v0": "*"
|
||||
|
@ -4,9 +4,7 @@
|
||||
"package": "net.playeranalytics.plan.gathering.listeners.events.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"EntityMixin",
|
||||
"KickCommandMixin",
|
||||
"PlayerEntityMixin",
|
||||
"PlayerManagerMixin",
|
||||
"ServerCommandSourceMixin",
|
||||
"ServerPlayerEntityMixin",
|
||||
|
Loading…
Reference in New Issue
Block a user