fix mixins
This commit is contained in:
17 files changed
+35
-41
No files matched your search
+6
-3
@@ -29,9 +29,11 @@ dependencies {
|
||||
// modImplementation so Loom loads it as a mod in the dev runtime; plain
|
||||
// implementation only adds it to the classpath, so Loader can't find the `fabric` mod.
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
shadow('com.maxmind.geoip2:geoip2:4.2.0')
|
||||
shadow("io.javalin:javalin:6.4.0")
|
||||
include(implementation "io.ib67.kiwi:lang:1.2.3-SNAPSHOT")
|
||||
shadow('com.maxmind.geoip2:geoip2:5.2.0')
|
||||
shadow("io.javalin:javalin:7.2.2") {
|
||||
exclude group: "org.eclipse.jetty.ee10", module: "jetty-ee10-annotations"
|
||||
}
|
||||
shadow("io.ib67.kiwi:lang:1.2.3-SNAPSHOT")
|
||||
shadow('com.github.houbb:pinyin:0.4.0')
|
||||
shadow('com.google.inject:guice:7.0.0') {
|
||||
exclude group: 'com.google.guava', module: 'guava'
|
||||
@@ -44,6 +46,7 @@ configurations.implementation.extendsFrom(configurations.shadow)
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadow]
|
||||
exclude("META-INF")
|
||||
relocate 'kotlin', 'sfcraft-kotlin'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
@@ -40,19 +40,19 @@ public class MaxMindGeoIPService implements Module, GeoIPService {
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Clock clockOf(InetAddress address) throws GeoIp2Exception {
|
||||
return Clock.system(TimeZone.getTimeZone(databaseReader.city(address).getLocation().getTimeZone()).toZoneId());
|
||||
return Clock.system(TimeZone.getTimeZone(databaseReader.city(address).location().timeZone()).toZoneId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public City cityOf(InetAddress address) throws GeoIp2Exception {
|
||||
return databaseReader.city(address).getCity();
|
||||
return databaseReader.city(address).city();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Country countryOf(InetAddress address) throws GeoIp2Exception {
|
||||
return databaseReader.country(address).getCountry();
|
||||
return databaseReader.country(address).country();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.ib67.sfcraft.mixin.common;
|
||||
|
||||
import net.minecraft.world.entity.monster.zombie.Zombie;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package io.ib67.sfcraft.mixin.common.bridge;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Item.class)
|
||||
public interface ItemBridge {
|
||||
@Accessor
|
||||
void setBuiltInRegistryHolder(Holder.Reference<Item> value);
|
||||
}
|
||||
@@ -8,5 +8,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
@Mixin(ServerLevel.class)
|
||||
public interface ServerWorldBridge {
|
||||
@Accessor
|
||||
SleepStatus getDEEPSLATE_BRICKS();
|
||||
SleepStatus getSleepStatus();
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public abstract class AbstractFurnaceBlockMixin extends BaseEntityBlock {
|
||||
var world = (ServerLevel) _world;
|
||||
AbstractFurnaceBlockEntity.serverTick(world, pos, state, blockEntity);
|
||||
int i = world.getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE);
|
||||
if (((ServerWorldBridge) world).getDEEPSLATE_BRICKS().areEnoughSleeping(i)) {
|
||||
if (((ServerWorldBridge) world).getSleepStatus().areEnoughSleeping(i)) {
|
||||
AbstractFurnaceBlockEntity.serverTick(world, pos, state, blockEntity); //todo: config support?
|
||||
AbstractFurnaceBlockEntity.serverTick(world, pos, state, blockEntity);
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ public abstract class ServerPlayNetworkHandlerMixin {
|
||||
* @author icybear
|
||||
* @reason small method, overwrite to reduce overhead
|
||||
*/
|
||||
@Redirect(method = "method_44900", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getChatDecorator()Lnet/minecraft/network/chat/ChatDecorator;"))
|
||||
@Redirect(method = "lambda$handleChat$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getChatDecorator()Lnet/minecraft/network/chat/ChatDecorator;"))
|
||||
public ChatDecorator getMessageDecorator(MinecraftServer instance) {
|
||||
return SFCraft.getInjector().getInstance(SimpleMessageDecorator.class);
|
||||
}
|
||||
|
||||
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;disconnect(Lnet/minecraft/network/chat/Component;)V", ordinal = 2))
|
||||
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;disconnect(Lnet/minecraft/network/chat/Component;)V"))
|
||||
public void onPlayerIdling(ServerGamePacketListenerImpl instance, Component text) {
|
||||
((ServerPlayerBridge) instance.player).setLastActionTime(Long.MAX_VALUE);
|
||||
SFCallbacks.PLAYER_IDLE.invoker().onSwitchIdle(instance.player, true);
|
||||
|
||||
@@ -12,7 +12,7 @@ public abstract class ServerWorldMixin {
|
||||
@ModifyArg(method = "tickTime", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/ServerLevelData;setGameTime(J)V"))
|
||||
public long setTimeOfDay(long timeOfDay) {
|
||||
int i = ((ServerLevel) (Object) this).getGameRules().get(GameRules.PLAYERS_SLEEPING_PERCENTAGE);
|
||||
if (((ServerWorldBridge) this).getDEEPSLATE_BRICKS().areEnoughSleeping(i)) {
|
||||
if (((ServerWorldBridge) this).getSleepStatus().areEnoughSleeping(i)) {
|
||||
MixinHelper.spedUp = true;
|
||||
return timeOfDay + 10;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.ib67.sfcraft.mixin.server.subserver;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import io.ib67.sfcraft.module.RoomModule;
|
||||
import io.ib67.sfcraft.util.Helper;
|
||||
import net.minecraft.server.players.NameAndId;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -41,9 +42,9 @@ public class PlayerSaveHandlerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/storage/PlayerDataStorage;playerDir:Ljava/io/File;"), method = "load(Lnet/minecraft/world/entity/player/Player;Ljava/lang/String;)Ljava/util/Optional;")
|
||||
private File sf$saveGetPlayerFolder(PlayerDataStorage instance, Player player) {
|
||||
if (RoomModule.isVirtual(player.getUUID())) {
|
||||
@Redirect(at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/storage/PlayerDataStorage;playerDir:Ljava/io/File;"), method = "Lnet/minecraft/world/level/storage/PlayerDataStorage;load(Lnet/minecraft/server/players/NameAndId;Ljava/lang/String;)Ljava/util/Optional;")
|
||||
private File sf$saveGetPlayerFolder(PlayerDataStorage instance, NameAndId player) {
|
||||
if (RoomModule.isVirtual(player.id())) {
|
||||
return virtualPlayerFolder;
|
||||
} else {
|
||||
return this.playerDir;
|
||||
|
||||
@@ -27,14 +27,14 @@ public class BackModule extends ServerModule {
|
||||
private void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext registryAccess, Commands.CommandSelection registrationEnvironment) {
|
||||
dispatcher.register(LiteralArgumentBuilder.<CommandSourceStack>literal("back")
|
||||
.requires(it -> this.isEnabled())
|
||||
.requires(it -> it.getPlayer() != null)
|
||||
.requires(it -> it.getPlayer().getLastDeathLocation().isPresent())
|
||||
.requires(it -> it.getPlayer() != null && it.getPlayer().getLastDeathLocation().isPresent())
|
||||
.requires(it -> SFConsts.COMMAND_BACK.hasPermission(it.getPlayer()))
|
||||
.executes(this::onBack));
|
||||
}
|
||||
|
||||
public int onBack(CommandContext<CommandSourceStack> it) {
|
||||
var player = it.getSource().getPlayer();
|
||||
if (player == null) return 0;
|
||||
var pos = player.getLastDeathLocation().get();
|
||||
var wld = player.level().getServer().getLevel(pos.dimension());
|
||||
var _pos = pos.pos();
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ManagementModule extends ServerModule {
|
||||
var city = geoIPService.cityOf(addr);
|
||||
src.sendSystemMessage(
|
||||
Component.literal(" - ")
|
||||
.append(Component.literal("[" + city.getName() + "] ").withColor(CommonColors.BLUE))
|
||||
.append(Component.literal("[" + city.name() + "] ").withColor(CommonColors.BLUE))
|
||||
.append(Component.literal(serverPlayerEntity.getName().tryCollapseToString()))
|
||||
.append(Component.literal(" (" + Helper.hideIp(addr) + ")").withColor(CommonColors.LIGHT_GRAY))
|
||||
);
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.CommonColors;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.gamerules.GameRules;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -2,7 +2,8 @@ package io.ib67.sfcraft.module.supervisor;
|
||||
|
||||
import io.ib67.sfcraft.ServerModule;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.config.JavalinConfig;
|
||||
|
||||
public abstract class WebHandler extends ServerModule {
|
||||
protected abstract void register(Javalin javalin);
|
||||
protected abstract void register(JavalinConfig javalin);
|
||||
}
|
||||
@@ -17,13 +17,14 @@ public class WebModule extends ServerModule {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
javalin = Javalin.create(cfg -> cfg.useVirtualThreads = false);
|
||||
var moduleManager = SFCraft.getInjector().getInstance(ModuleManager.class);
|
||||
for (ServerModule module : moduleManager.getModules()) {
|
||||
if(module instanceof WebHandler webHandler) {
|
||||
webHandler.register(javalin);
|
||||
javalin = Javalin.create(cfg -> {
|
||||
for (ServerModule module : moduleManager.getModules()) {
|
||||
if(module instanceof WebHandler webHandler) {
|
||||
webHandler.register(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Thread.ofVirtual().name("SFCraft API Web").start(() -> javalin.start(config.httpPort));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@ import io.ib67.sfcraft.inject.MinecraftServerSupplier;
|
||||
import io.ib67.sfcraft.module.SignatureService;
|
||||
import io.ib67.sfcraft.module.supervisor.WebHandler;
|
||||
import io.ib67.sfcraft.util.Helper;
|
||||
import io.ib67.sfcraft.util.Permission;
|
||||
import io.ib67.sfcraft.util.SFConsts;
|
||||
import io.ib67.sfcraft.util.litematic.LitematicConverterV3;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.config.JavalinConfig;
|
||||
import io.javalin.http.Context;
|
||||
import io.javalin.http.UploadedFile;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -75,8 +74,8 @@ public class SchematicUploader extends WebHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Javalin javalin) {
|
||||
javalin.options("/api/schematics/{name}", this::onUploadOptions).put("/api/schematics/{name}", this::uploadSchematic);
|
||||
public void register(JavalinConfig javalin) {
|
||||
javalin.routes.options("/api/schematics/{name}", this::onUploadOptions).put("/api/schematics/{name}", this::uploadSchematic);
|
||||
}
|
||||
|
||||
public String generateSchematicUrl(String issuer) {
|
||||
|
||||
@@ -15,6 +15,7 @@ public record Permission<T extends Entity>(String key, boolean byDefault) {
|
||||
}
|
||||
|
||||
public boolean hasPermission(T t) {
|
||||
if(t == null) return false;
|
||||
if (check(t, SFConsts.SPECIAL_SUDO)) return true;
|
||||
if (byDefault) {
|
||||
return !check(t, "-"+key);
|
||||
@@ -23,6 +24,7 @@ public record Permission<T extends Entity>(String key, boolean byDefault) {
|
||||
}
|
||||
|
||||
private boolean check(T t, String permission){
|
||||
if(t == null) return false;
|
||||
if(t instanceof Player player) {
|
||||
if (player.entityTags().contains(permission)){
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
"common.PlayerEntityMixin",
|
||||
"common.ZombieMixin",
|
||||
"common.bridge.EntityBridge",
|
||||
"common.bridge.ItemBridge",
|
||||
"common.bridge.ServerChunkManagerBridge",
|
||||
"common.bridge.ServerPlayerBridge",
|
||||
"common.bridge.ServerWorldBridge",
|
||||
|
||||
Reference in new issue
Block a user