Skip to content

Commit

Permalink
Merge pull request #6 from Vulpeus-Server/feature/disableIAECrash
Browse files Browse the repository at this point in the history
added `disableIAECrash`
  • Loading branch information
hu-ja-ja authored Oct 7, 2024
2 parents b16ce53 + 2fe1599 commit 7855dbe
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
8 changes: 8 additions & 0 deletions docs/en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ yeet the server crash caused by ClassCastException.
- Default value: `false`
- Categories: `VULPEUS`

### disableIAECrash

yeet the server crash caused by IllegalArgumentException.

- Type: `boolean`
- Default value: `false`
- Categories: `VULPEUS`

### disableSOECrash

yeet the server crash caused by StackOverflowError.
Expand Down
8 changes: 8 additions & 0 deletions docs/ja_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ ClassCastException によるサーバーのクラッシュの無効化。
- 既定値: `false`
- 分類: `VULPEUS`

### disableIAECrash

IllegalArgumentException によるサーバーのクラッシュの無効化。

- Type: `boolean`
- Default value: `false`
- Categories: `VULPEUS`

### disableSOECrash

StackOverflowError によるサーバーのクラッシュの無効化。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class VulpeusCarpetSettings {
@Rule(categories = {VULPEUS})
public static boolean disableSOECrash = false;

@Rule(categories = {VULPEUS})
public static boolean disableIAECrash = false;

//#if MC<=12101
//$$ @Rule(categories = {BUGFIX, VULPEUS})
//#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,23 @@

package com.vulpeus.vulpeus_carpet.mixins.disableCrash;

import com.llamalad7.mixinextras.sugar.Local;
import com.vulpeus.vulpeus_carpet.VulpeusCarpetSettings;
import com.vulpeus.vulpeus_carpet.utils.sendMessage;
import java.util.Iterator;
import java.util.function.BooleanSupplier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {

@Inject(method = {"tickWorlds"}, at = {
@At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;create(Ljava/lang/Throwable;Ljava/lang/String;)Lnet/minecraft/util/crash/CrashReport;")}, locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
@At(value = "INVOKE", target = "Lnet/minecraft/util/crash/CrashReport;create(Ljava/lang/Throwable;Ljava/lang/String;)Lnet/minecraft/util/crash/CrashReport;")}, cancellable = true)
public void injectTickWorlds(BooleanSupplier shouldKeepTicking, CallbackInfo ci,
@SuppressWarnings("all") Iterator var2, ServerWorld serverWorld, Throwable throwable) {
@Local Throwable throwable) {

Throwable causeErr = throwable.getCause();

Expand All @@ -51,5 +49,9 @@ public void injectTickWorlds(BooleanSupplier shouldKeepTicking, CallbackInfo ci,
ci.cancel();
sendMessage.sendGlobalMessage((MinecraftServer) (Object) this, "now SOE Crashed.");
}
if (VulpeusCarpetSettings.disableIAECrash && causeErr instanceof IllegalArgumentException) {
ci.cancel();
sendMessage.sendGlobalMessage((MinecraftServer) (Object) this, "now SOE Crashed.");
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/vulpeus_carpet/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ carpet:
disableCCECrash:
desc: yeet the server crash caused by ClassCastException.

disableIAECrash:
desc: yeet the server crash caused by IllegalArgumentException.

disableSOECrash:
desc: yeet the server crash caused by StackOverflowError.

Expand Down

0 comments on commit 7855dbe

Please sign in to comment.