Skip to content

Commit

Permalink
refactor: generalized bypass modules into disabler module + feature…
Browse files Browse the repository at this point in the history
…: add `module supplier` checker
  • Loading branch information
sakurawald committed Jul 18, 2024
1 parent 107cb7d commit fa75ffc
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 28 deletions.
37 changes: 24 additions & 13 deletions src/main/java/io/github/sakurawald/config/model/ConfigModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public class Modules {
public Profiler profiler = new Profiler();
public CommandSpy command_spy = new CommandSpy();
public Scheduler scheduler = new Scheduler();
public BypassChatSpeed bypass_chat_speed = new BypassChatSpeed();
public BypassMoveSpeed bypass_move_speed = new BypassMoveSpeed();
public BypassMaxPlayerLimit bypass_max_player_limit = new BypassMaxPlayerLimit();
public Config config = new Config();
public Test test = new Test();
public Hat hat = new Hat();
Expand Down Expand Up @@ -513,25 +510,39 @@ public class WorldDownloader {
public int context_cache_size = 5;
}

public Disabler disabler = new Disabler();
@Documentation("""
This module bypass "Kicked for spamming"
This module provides `disabler` to disable checkers in `vaniila minecraft`
""")
public class BypassChatSpeed {
public class Disabler {
public boolean enable = false;
}

@Documentation("Disable `moved too quickly` and `vehicle too quickly` check")
public class BypassMoveSpeed {
public boolean enable = false;
}
public ChatSpeedDisabler chat_speed_disabler = new ChatSpeedDisabler();
public MoveSpeedDisabler move_speed_disabler = new MoveSpeedDisabler();
public MaxPlayerDisabler max_player_disabler = new MaxPlayerDisabler();

@Documentation("""
@Documentation("""
This module bypass "Kicked for spamming"
""")
public class ChatSpeedDisabler {
public boolean enable = true;
}

@Documentation("Disable `moved too quickly` and `vehicle too quickly` check")
public class MoveSpeedDisabler {
public boolean enable = true;
}

@Documentation("""
Bypass the max players limit of the server.
""")
public class BypassMaxPlayerLimit {
public boolean enable = false;
public class MaxPlayerDisabler {
public boolean enable = true;
}
}


@Documentation("""
This module provides `/deathlog` command.
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/github/sakurawald/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ public static boolean shouldEnableModule(JsonElement config, List<String> packag
boolean enable = true;
JsonObject parent = config.getAsJsonObject().get("modules").getAsJsonObject();
for (String packageName : packagePath) {
if (!parent.has(packageName)) break;
parent = parent.getAsJsonObject(packageName);
if (!parent.has("enable")) break;
if (parent == null || !parent.has("enable")) {
throw new RuntimeException("Missing `enable supplier` key for package path %s".formatted(packagePath));
}
if (!parent.getAsJsonPrimitive("enable").getAsBoolean()) {
enable = false;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.sakurawald.module.mixin.bypass_chat_speed;
package io.github.sakurawald.module.mixin.disabler.chat_speed_disabler;

import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.sakurawald.module.mixin.bypass_max_player_limit;
package io.github.sakurawald.module.mixin.disabler.max_player_disabler;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mojang.authlib.GameProfile;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.sakurawald.module.mixin.bypass_move_speed;
package io.github.sakurawald.module.mixin.disabler.move_speed_disabler;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.server.network.ServerPlayNetworkHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.sakurawald.module.mixin.resource_world.registry;
package io.github.sakurawald.module.mixin.resource_world;

import io.github.sakurawald.module.initializer.resource_world.interfaces.DimensionOptionsMixinInterface;
import net.minecraft.world.dimension.DimensionOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package io.github.sakurawald.module.mixin.resource_world.registry;
package io.github.sakurawald.module.mixin.resource_world;

import com.google.common.collect.Maps;
import io.github.sakurawald.module.initializer.resource_world.interfaces.DimensionOptionsMixinInterface;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionOptionsRegistryHolder;
import net.minecraft.world.gen.GeneratorOptions;
import net.minecraft.world.level.WorldGenSettings;
import org.spongepowered.asm.mixin.Final;
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.ModifyArg;

Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/fuji.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"anti_build.ServerPlayerInteractionManagerMixin",
"back.ServerPlayerMixin",
"carpet.better_info.InfoCommandMixin",
"bypass_chat_speed.ServerGamePacketListenerImplMixin",
"bypass_max_player_limit.DedicatedPlayerManagerMixin",
"bypass_move_speed.ServerGamePacketListenerImplMixin",
"disabler.chat_speed_disabler.ServerGamePacketListenerImplMixin",
"disabler.max_player_disabler.DedicatedPlayerManagerMixin",
"disabler.move_speed_disabler.ServerGamePacketListenerImplMixin",
"chat.PlayerListMixin",
"chat.RegistryLoaderMixin",
"chat.ServerGamePacketListenerImplMixin",
Expand Down Expand Up @@ -50,8 +50,8 @@
"resource_world.EndGatewayBlockEntityMixin",
"resource_world.MinecraftServerMixin",
"resource_world.ServerWorldMixin",
"resource_world.registry.DimensionOptionsMixin",
"resource_world.registry.WorldGenSettingsMixin",
"resource_world.DimensionOptionsMixin",
"resource_world.WorldGenSettingsMixin",
"seen.PlayerListMixin",
"sit.InteractModifierMixin",
"skin.PlayerListMixin",
Expand Down

0 comments on commit fa75ffc

Please sign in to comment.