Skip to content

Commit

Permalink
Revert "add: custom event PrePlayerDeathEvent"
Browse files Browse the repository at this point in the history
This reverts commit 8848fa5
  • Loading branch information
sakurawald committed Jul 7, 2024
1 parent 29f61fa commit 3ec26c1
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 69 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ modrinth {
syncBodyFrom = rootProject.file("README.md").text
}
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
tasks.modrinthSyncBody.dependsOn(tasks.replaceReadme)

// test framework
test {
Expand Down
2 changes: 1 addition & 1 deletion fuji-fabric.wiki
4 changes: 4 additions & 0 deletions src/main/java/io/github/sakurawald/Fuji.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

// TODO: remove fabric-api dep

// TODO: a program to generate module reference DAG

// TODO: add loom module

public class Fuji implements ModInitializer {
public static final String MOD_ID = "fuji";
public static final Logger LOGGER = LogUtil.createLogger(StringUtils.capitalize(MOD_ID));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.sakurawald.common;
package io.github.sakurawald.common.structure;

import io.github.sakurawald.Fuji;
import io.github.sakurawald.util.MessageUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.sakurawald.config.model;

import io.github.sakurawald.common.Position;
import io.github.sakurawald.common.structure.Position;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import io.github.sakurawald.common.event.PrePlayerDeathEvent;
import io.github.sakurawald.config.Configs;
import io.github.sakurawald.module.initializer.ModuleInitializer;
import io.github.sakurawald.common.Position;
import io.github.sakurawald.common.structure.Position;
import io.github.sakurawald.util.CommandUtil;
import io.github.sakurawald.util.MessageUtil;
import lombok.Getter;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;

import java.util.HashMap;

@SuppressWarnings("LombokGetterMayBeUsed")
Expand All @@ -24,14 +21,6 @@ public class BackModule extends ModuleInitializer {
@Getter
private final HashMap<String, Position> player2lastPos = new HashMap<>();

@Override
public void onInitialize() {
PrePlayerDeathEvent.EVENT.register((player, damageSource) -> {
this.updatePlayer(player);
return ActionResult.PASS;
});
}

@Override
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
dispatcher.register(CommandManager.literal("back").executes(this::$back));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import io.github.sakurawald.Fuji;
import io.github.sakurawald.common.event.PrePlayerDeathEvent;
import io.github.sakurawald.module.initializer.ModuleInitializer;
import io.github.sakurawald.util.CommandUtil;
import io.github.sakurawald.util.RegistryUtil;
Expand All @@ -26,7 +25,6 @@
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Uuids;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Vec3d;
Expand Down Expand Up @@ -65,13 +63,6 @@ public class DeathLogModule extends ModuleInitializer {
@Override
public void onInitialize() {
STORAGE_PATH.toFile().mkdirs();

PrePlayerDeathEvent.EVENT.register((player, damageSource) -> {
// don't store empty inventory
if (player.getInventory().isEmpty()) return ActionResult.PASS;
this.store(player);
return ActionResult.PASS;
});
}

@SuppressWarnings({"UnusedReturnValue", "unused"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.github.sakurawald.config.handler.ObjectConfigHandler;
import io.github.sakurawald.config.model.HomeModel;
import io.github.sakurawald.module.initializer.ModuleInitializer;
import io.github.sakurawald.common.Position;
import io.github.sakurawald.common.structure.Position;
import io.github.sakurawald.util.CommandUtil;
import io.github.sakurawald.util.MessageUtil;
import io.github.sakurawald.util.ScheduleUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.sakurawald.module.ModuleManager;
import io.github.sakurawald.module.initializer.resource_world.interfaces.SimpleRegistryMixinInterface;
import io.github.sakurawald.common.Position;
import io.github.sakurawald.common.structure.Position;
import io.github.sakurawald.module.initializer.teleport_warmup.TeleportTicket;
import io.github.sakurawald.module.initializer.teleport_warmup.TeleportWarmupModule;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.sakurawald.module.initializer.teleport_warmup;

import io.github.sakurawald.common.Position;
import io.github.sakurawald.common.structure.Position;
import io.github.sakurawald.util.MessageUtil;
import net.kyori.adventure.bossbar.BossBar;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(PlayerManager.class)

public abstract class PlayerListMixin {
@Inject(at = @At(value = "TAIL"), method = "onPlayerConnect")
private void $onPlayerConnect(ClientConnection connection, ServerPlayerEntity serverPlayer, ConnectedClientData commonListenerCookie, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerMixin {


@Unique
private static final BackModule module = ModuleManager.getInitializer(BackModule.class);
@Unique
private static final TeleportWarmupModule teleportWarmupModule = ModuleManager.getInitializer(TeleportWarmupModule.class);

@Inject(method = "onDeath", at = @At("HEAD"))
public void $onDeath(DamageSource damageSource, CallbackInfo ci) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
module.updatePlayer(player);
}

@Inject(method = "teleport(Lnet/minecraft/server/world/ServerWorld;DDDFF)V", at = @At("HEAD"))
public void $teleport(ServerWorld targetWorld, double x, double y, double z, float yaw, float pitch, CallbackInfo ci) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(CommandManager.class)

public class CommandsMixin {

// If you issue "///abcdefg", then commandLine = "//abcdefg"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.sakurawald.module.mixin.deathlog;

import io.github.sakurawald.module.ModuleManager;
import io.github.sakurawald.module.initializer.deathlog.DeathLogModule;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerMixin {
@Unique
private static final DeathLogModule module = ModuleManager.getInitializer(DeathLogModule.class);

@Inject(method = "onDeath", at = @At("HEAD"))
public void $onDeath(DamageSource damageSource, CallbackInfo ci) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
// don't store empty inventory
if (player.getInventory().isEmpty()) return;
module.store(player);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.github.sakurawald.module.ModuleManager;
import io.github.sakurawald.module.initializer.back.BackModule;
import io.github.sakurawald.common.Position;
import io.github.sakurawald.common.structure.Position;
import io.github.sakurawald.module.initializer.teleport_warmup.ServerPlayerCombatStateAccessor;
import io.github.sakurawald.module.initializer.teleport_warmup.TeleportTicket;
import io.github.sakurawald.module.initializer.teleport_warmup.TeleportWarmupModule;
Expand Down
21 changes: 5 additions & 16 deletions src/main/resources/fuji.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
"compatibilityLevel": "JAVA_17",
"plugin": "io.github.sakurawald.module.mixin.ModuleMixinConfigPlugin",
"mixins": [
"_internal.event.PlayerManagerMixin",
"_internal.event.ServerPlayerEntityMixin",
"_internal.event.ServerPlayNetworkHandlerMixin",
"_internal.server_instance.MinecraftServerMixin",
"_internal.low_level.GameProfileCacheMixin",
"_internal.low_level.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 All @@ -24,8 +18,9 @@
"command_cooldown.CommandsMixin",
"command_interactive.SignBlockMixin",
"command_permission.CommandNodeAccessor",
"command_spy.CommandsMixin",
"command_rewrite.ServerPlayNetworkHandlerMixin",
"command_spy.CommandsMixin",
"deathlog.ServerPlayerMixin",
"enchantment.EnchantmentScreenHandlerMixin",
"fake_player_manager.PlayerCommandMixin",
"fake_player_manager.PlayerListMixin",
Expand All @@ -47,21 +42,15 @@
"resource_world.MinecraftServerMixin",
"resource_world.ServerWorldMixin",
"resource_world.registry.DimensionOptionsMixin",
"resource_world.registry.DimensionOptionsRegistryHolderMixin",
"resource_world.registry.SimpleRegistryMixin",
"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",
"fix_whitelist.UserWhiteListMixin",
"works.HopperBlockEntityMixin",
"command_permission.CommandNodeAccessor"
"works.HopperBlockEntityMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 3ec26c1

Please sign in to comment.