Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.Stats;
import net.minecraft.unmapped.C_eyqfalbd;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -14,7 +15,7 @@
@Mixin(PlayerManager.class)
public class PlayerManagerMixin {
@Inject(at = @At(value = "TAIL"), method = "onPlayerConnect")
private void onPlayerJoin(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
private void onPlayerJoin(ClientConnection connection, ServerPlayerEntity player, C_eyqfalbd c_eyqfalbd, CallbackInfo ci) {
PlayerJoinCallback.EVENT.invoker().joinServer(player, player.getServer());
if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(Stats.LEAVE_GAME)) < 1) {
PlayerFirstJoinCallback.EVENT.invoker().joinServerForFirstTime(player, player.getServer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import me.bymartrixx.playerevents.api.event.CommandExecutionCallback;
import me.bymartrixx.playerevents.api.event.PlayerLeaveCallback;
import net.minecraft.network.message.MessageSignatureList;
import net.minecraft.network.packet.c2s.play.ChatCommandC2SPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -13,23 +12,21 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Optional;

@Mixin(ServerPlayNetworkHandler.class)
@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"})
//don't want to suppress those warnings, custom commands actually don't work
public class ServerPlayNetworkHandlerMixin {
@Shadow
public ServerPlayerEntity player;

// Just after the command is executed
// 1.20
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;checkForSpam()V"),
method = "method_44356(Lnet/minecraft/class_7472;Ljava/util/Optional;)V", require = 0)
private void onCommandExecuted(ChatCommandC2SPacket packet, Optional<MessageSignatureList> optional, CallbackInfo ci) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;submit(Ljava/lang/Runnable;)Ljava/util/concurrent/CompletableFuture;", shift = At.Shift.AFTER),
method = "onChatCommand(Lnet/minecraft/network/packet/c2s/play/ChatCommandC2SPacket;)V")
private void onCommandExecuted(ChatCommandC2SPacket packet, CallbackInfo ci) {
CommandExecutionCallback.EVENT.invoker().onExecuted(packet.command(), this.player.getCommandSource());
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;onDisconnect()V"), method = "onDisconnected")
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/AbstractServerPacketHandler;onDisconnected(Lnet/minecraft/text/Text;)V"), method = "onDisconnected")
private void onPlayerLeave(Text reason, CallbackInfo info) {
PlayerLeaveCallback.EVENT.invoker().leaveServer(this.player, this.player.getServer());
}
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
minecraft = "1.20.1"
quilt_mappings = "1.20.1+build.11"
fabric_loader = "0.14.21"
minecraft = "1.20.2"
quilt_mappings = "1.20.2+build.1"
fabric_loader = "0.14.22"

fabric_api = "0.85.0+1.20.1"
placeholder_api = "2.1.2+1.20.1"
fabric_api = "0.89.2+1.20.2"
placeholder_api = "2.2.0+1.20.2"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
Expand Down