Skip to content

Commit

Permalink
core: Simplify player preQuit event definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkmar committed Sep 17, 2023
1 parent af3a18f commit 43343eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.silkmc.silk.core.mixin.server;

import com.mojang.authlib.GameProfile;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
Expand All @@ -14,8 +13,6 @@
@Mixin(ServerGamePacketListenerImpl.class)
public abstract class MixinServerGamePacketListenerImpl {

@Shadow protected abstract GameProfile playerProfile();

@Shadow public ServerPlayer player;

@Inject(
Expand All @@ -25,6 +22,6 @@ public abstract class MixinServerGamePacketListenerImpl {
private void onPreQuit(Component reason,
CallbackInfo ci) {
PlayerEvents.INSTANCE.getPreQuit()
.invoke(new PlayerEvents.PlayerQuitEvent<>(player, reason));
.invoke(new PlayerEvents.PlayerQuitEvent(player, reason));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ object PlayerEvents {
*/
val postLogin = Event.syncAsync<PlayerEvent<ServerPlayer>>()

open class PlayerQuitEvent<T : Player?>(
player: T,
open class PlayerQuitEvent(
player: ServerPlayer,
val reason: Component,
) : PlayerEvent<T>(player)
) : PlayerEvent<ServerPlayer>(player)

/**
* Called before a player leaves the server. Will only be called when
Expand All @@ -33,7 +33,7 @@ object PlayerEvents {
* @see quitDuringLogin
* @see quitDuringConfiguration
*/
val preQuit = Event.syncAsync<PlayerQuitEvent<ServerPlayer>>()
val preQuit = Event.syncAsync<PlayerQuitEvent>()

open class PlayerQuitDuringLoginEvent(
val gameProfile: GameProfile?,
Expand Down

0 comments on commit 43343eb

Please sign in to comment.