Skip to content

Commit

Permalink
Revert "refactor: use custom events"
Browse files Browse the repository at this point in the history
This reverts commit 90db1a3
  • Loading branch information
sakurawald committed Jul 7, 2024
1 parent 4b16f3c commit 8fba23f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 112 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package io.github.sakurawald.module.mixin._internal.event;
package io.github.sakurawald.module.mixin.op_protect;


import io.github.sakurawald.common.event.PrePlayerDisconnectEvent;
import net.minecraft.entity.passive.SheepEntity;
import io.github.sakurawald.Fuji;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.minecraft.network.DisconnectionInfo;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
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 ServerPlayNetworkHandlerMixin {

@Shadow
public ServerPlayerEntity player;

@Inject(at = @At(value = "HEAD"), method = "onDisconnected", cancellable = true)
@Inject(at = @At(value = "HEAD"), method = "onDisconnected")
private void $onDisconnected(DisconnectionInfo disconnectionInfo, CallbackInfo ci) {
ActionResult result = PrePlayerDisconnectEvent.EVENT.invoker().interact(player, disconnectionInfo);
if (result == ActionResult.FAIL) {
ci.cancel();
if (Fuji.SERVER.getPlayerManager().isOperator(player.getGameProfile())) {
Fuji.LOGGER.info("op protect -> deop {}", player.getGameProfile().getName());
Fuji.SERVER.getPlayerManager().removeFromOperators(player.getGameProfile());
}
}
}


17 changes: 12 additions & 5 deletions src/main/resources/fuji.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"compatibilityLevel": "JAVA_17",
"plugin": "io.github.sakurawald.module.mixin.ModuleMixinConfigPlugin",
"mixins": [
"_internal.event.PlayerManagerMixin",
"_internal.event.ServerPlayNetworkHandlerMixin",
"_internal.low_level.GameProfileCacheMixin",
"_internal.low_level.MinecraftServerMixin",
"_internal.server_instance.MinecraftServerMixin",
"afk.PlayerListMixin",
"afk.ServerPlayerMixin",
"back.ServerPlayerMixin",
"fake_player_manager.PlayerCommandMixin",
"fake_player_manager.PlayerListMixin",
"fake_player_manager.PlayerMixin",
"better_info.InfoCommandMixin",
"biome_lookup_cache.NaturalSpawnerMixin",
"bypass_chat_speed.ServerGamePacketListenerImplMixin",
"bypass_max_player_limit.DedicatedPlayerManagerMixin",
"bypass_move_speed.ServerGamePacketListenerImplMixin",
Expand Down Expand Up @@ -42,16 +44,21 @@
"resource_world.MinecraftServerMixin",
"resource_world.ServerWorldMixin",
"resource_world.registry.DimensionOptionsMixin",
"resource_world.registry.DimensionOptionsRegistryHolderMixin",
"resource_world.registry.SimpleRegistryMixin",
"resource_world.registry.WorldGenSettingsMixin",
"seen.GameProfileCacheMixin",
"seen.PlayerListMixin",
"sit.InteractModifierMixin",
"skin.PlayerListMixin",
"skin.ServerLoginNetworkHandlerMixin",
"fix_player_list_cme.PlayerListMixin",
"fix_player_list_cme.ServerLevelMixin",
"system_message.ComponentMixin",
"teleport_warmup.ServerPlayerMixin",
"top_chunks.ThreadedAnvilChunkStorageMixin",
"works.HopperBlockEntityMixin"
"fix_whitelist.UserWhiteListMixin",
"works.HopperBlockEntityMixin",
"command_permission.CommandNodeAccessor"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 8fba23f

Please sign in to comment.