Skip to content

Commit

Permalink
Release 2.8.0
Browse files Browse the repository at this point in the history
- 新模块 Fly 飞行
    - 仅限PAS模式
    - *Fly to the moon.*
- 新模块 Writer 作家
    - 写一本书。
- 新修复 NoJumpDelay 无跳跃延迟
    - 拍空格不是必须的
- 改进ServerFreeze修复
    - 现在会显示服务器冻结时间
- 改进ClickGUI
- 重写AntiVanish反隐身模块
    - 是的上个版本的反隐身有一万个bug
    - 现在可以检测进入隐身和退出隐身
- 移除MoreKB模块
  • Loading branch information
xia-mc committed May 18, 2024
1 parent 3af6b6f commit 179b541
Show file tree
Hide file tree
Showing 35 changed files with 1,037 additions and 180 deletions.
9 changes: 9 additions & 0 deletions bookUtils/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
inputStr = ""
while True:
cur = input()
if cur == "done": break
inputStr += cur + "\n"

for line in inputStr.split("\n"):
if line != "":
print(line)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.1
loader_version=0.14.23

# Mod Properties
mod_version = 2.7.4
mod_version = 2.8.0
maven_group = top.infsky
archives_base_name = CheatDetector

Expand Down
1 change: 1 addition & 0 deletions src/main/java/top/infsky/cheatdetector/CheatDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void onInitializeClient() {
ClickGUI.register(configManager);
CONFIG_HANDLER = new ConfigHandler(MOD_ID, configManager, 1);
ConfigHandler.register(CONFIG_HANDLER);
CONFIG_HANDLER.configManager.getAllOptions().forEach(option -> option.setValueChangeCallback(configOption -> ClickGUI.update()));

// command
ClientCommandRegistrationCallback.EVENT.register(CommandEvent::register);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public static void register(@NotNull CommandDispatcher<FabricClientCommandSource
.then(argument("brand", StringArgumentType.string())
.executes(ClientSpoofCommand::execute))
)
.then(literal("writer")
.then(argument("part", IntegerArgumentType.integer(1, 2))
.executes(WriterCommand::execute))
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class HelpCommand {
§r/ctr notebot <path> §f- §7修改音符机器人.nbs文件路径§r
§r/ctr blockdetector (<x> <y> <z>) §f- §7设置方块检测器坐标§r
§r/ctr clientspoof <brand> §f- §7设置客户端伪装名§r
§r/ctr writer <part> §f- §7写一本书。§r
""";

public static int execute(@NotNull CommandContext<FabricClientCommandSource> context) {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/top/infsky/cheatdetector/commands/WriterCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package top.infsky.cheatdetector.commands;

import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.CheatDetector;

public class WriterCommand {
public static int execute(@NotNull CommandContext<FabricClientCommandSource> context) {
int part = context.getArgument("part", Integer.class);
if (CheatDetector.CONFIG_HANDLER.configManager.setValue("writerPart", part)) {
CheatDetector.CONFIG_HANDLER.configManager.setValue("writerEnabled", true);
return 1;
} else {
return -1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ public class Advanced2Config {
public static int serverFreezeAlertBuffer = 1;
@Numeric(minValue = -1, maxValue = 600)
@Config(category = ConfigCategory.ADVANCED2)
public static int serverFreezePostDelay = 1;
public static int serverFreezePostDelay = -1;
@Numeric(minValue = 0, maxValue = Integer.MAX_VALUE)
@Config(category = ConfigCategory.ADVANCED2)
public static int serverFreezeMaxTicks = 20;
@Config(category = ConfigCategory.ADVANCED2)
public static boolean serverFreezeAutoDisableCheck = true;
@Config(category = ConfigCategory.ADVANCED2)
public static boolean serverFreezeAlert = true;
}
11 changes: 11 additions & 0 deletions src/main/java/top/infsky/cheatdetector/config/Advanced3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ public class Advanced3Config {
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static String clientSpoofBrand = "vanilla";

@Numeric(minValue = 0, maxValue = 5)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static double flyAcceptTeleportMaxDistance = 1;

@Numeric(minValue = 1, maxValue = 2)
@Config(category = ConfigCategory.ADVANCED3)
public static int writerPart = 1;

@Config(category = ConfigCategory.ADVANCED3)
public static boolean writerToBook = false;

public static NotebotUtils.NotebotMode getNoteBotMode() {
if (noteBotMode.equals("AnyInstrument")) {
return NotebotUtils.NotebotMode.AnyInstrument;
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/top/infsky/cheatdetector/config/ModuleConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,13 @@ public class ModuleConfig {

@Hotkey
@Config(category = ConfigCategory.MODULES)
public static boolean moreKBEnabled = false;
public static boolean noJumpDelayEnabled = false;

@Hotkey
@Config(category = ConfigCategory.MODULES, predicate = ConfigPredicate.PASMode.class)
public static boolean flyEnabled = false;

@Hotkey
@Config(category = ConfigCategory.MODULES)
public static boolean writerEnabled = false;
}
11 changes: 0 additions & 11 deletions src/main/java/top/infsky/cheatdetector/impl/Fix.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,4 @@ public void flag(String extraMsg) {
if (violations % getAlertBuffer() != 0) return;
LogUtils.alert(player.fabricPlayer.getName().getString(), checkName, String.format("(VL:%s) %s%s", violations, ChatFormatting.GRAY, extraMsg));
}

public void flag(String name, String extraMsg) {
if (player.manager.disableTick > 0) return;
if (!FixesConfig.packetFixEnabled) return;
if (isDisabled()) return;
violations++;
if (!AlertConfig.allowAlertFixes) return;
if (!AlertConfig.disableBuffer)
if (violations % getAlertBuffer() != 0) return;
LogUtils.alert(name, checkName, String.format("(VL:%s) %s%s", violations, ChatFormatting.GRAY, extraMsg));
}
}
14 changes: 6 additions & 8 deletions src/main/java/top/infsky/cheatdetector/impl/checks/SpeedC.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.config.AdvancedConfig;
import top.infsky.cheatdetector.impl.Check;
import top.infsky.cheatdetector.impl.utils.world.PlayerMove;
import top.infsky.cheatdetector.utils.TRPlayer;

public class SpeedC extends Check {
Expand All @@ -14,17 +15,14 @@ public SpeedC(@NotNull TRPlayer player) {
@Override
public void _onTick() {
if (player.fabricPlayer.isSprinting()) {
double distance = player.lastPos.distanceTo(player.currentPos);
Vec3 motion = player.fabricPlayer.getDeltaMovement();
if (distance == 0)
flag(distance, motion);
double speed = PlayerMove.getXzTickSpeed(player.lastPos, player.currentPos);
if (speed == 0) {
Vec3 motion = player.fabricPlayer.getDeltaMovement();
flag("MotionX:%.2f MotionZ:%.2f".formatted(motion.x(), motion.z()));
}
}
}

public void flag(double distance, @NotNull Vec3 motion) {
flag("distance: %.1f, motion: %.2f,%.2f,%.2f".formatted(distance, motion.x(), motion.y(), motion.z()));
}

@Override
public int getAlertBuffer() {
return AdvancedConfig.speedCAlertBuffer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package top.infsky.cheatdetector.impl.fixes;

import io.netty.channel.ChannelHandlerContext;
import net.minecraft.ChatFormatting;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.status.ServerboundPingRequestPacket;
import net.minecraft.network.protocol.game.ServerboundPongPacket;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import top.infsky.cheatdetector.CheatDetector;
import top.infsky.cheatdetector.config.Advanced2Config;
import top.infsky.cheatdetector.config.AntiCheatConfig;
import top.infsky.cheatdetector.impl.Fix;
import top.infsky.cheatdetector.utils.TRPlayer;
import top.infsky.cheatdetector.utils.TRSelf;

public class ServerFreeze extends Fix {
private long lastReceiveTime = -1;
public boolean freeze = false;
private int pingRequest = 0;

public ServerFreeze(@NotNull TRSelf player) {
super("ServerFreeze", player);
Expand All @@ -30,12 +33,19 @@ public void _onTick() {
if (player.upTime - lastReceiveTime > Advanced2Config.serverFreezeMaxTicks) {
if (Advanced2Config.serverFreezeAutoDisableCheck)
CheatDetector.manager.getDataMap().forEach((uuid, player1) -> player1.manager.disableTick = 10);
if (!freeze)
flag("Server", "frozen over %s ms!".formatted(player.upTime - lastReceiveTime));
if (Advanced2Config.serverFreezeAlert) {
TRPlayer.CLIENT.gui.setOverlayMessage(
Component.literal(Component.translatable("cheatdetector.overlay.alert.serverFreezeAlert")
.withStyle(ChatFormatting.DARK_RED)
.getString()
.formatted((player.upTime - lastReceiveTime) * 50)),
true);
}
}

if (Advanced2Config.serverFreezePostDelay != -1 && player.upTime % Advanced2Config.serverFreezePostDelay == 0) {
player.fabricPlayer.connection.send(new ServerboundPingRequestPacket(System.currentTimeMillis()));
player.fabricPlayer.connection.send(new ServerboundPongPacket(pingRequest));
pingRequest = pingRequest < -32767 ? 0 : pingRequest - 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public class ClickGUI extends Module {
@Getter(lazy = true)
private static final @NotNull ConfigGui configGui = create(CheatDetector.MOD_ID, ConfigCategory.ANTICHEAT, CheatDetector.CONFIG_HANDLER.configManager);

private boolean lastPASModeEnabled = false;
private Advanced3Config.FakelagMode lastFakelagMode = Advanced3Config.FakelagMode.LATENCY;
private boolean lastAimAssistInteract = false;

public ClickGUI(@NotNull TRSelf player) {
super("ClickGUI", player);
instance = this;
Expand All @@ -46,13 +42,6 @@ public void _onTick() {
TRPlayer.CLIENT.setScreen(getConfigGui());
update();
}

if (lastPASModeEnabled != ModuleConfig.aaaPASModeEnabled
|| lastFakelagMode != Advanced3Config.getFakelagMode()
|| lastAimAssistInteract != Advanced3Config.aimAssistInteract) update();
lastPASModeEnabled = ModuleConfig.aaaPASModeEnabled;
lastFakelagMode = Advanced3Config.getFakelagMode();
lastAimAssistInteract = Advanced3Config.aimAssistInteract;
}

@Contract("_, _, _ -> new")
Expand All @@ -77,12 +66,8 @@ public static void register(@NotNull ConfigManager manager) {
manager.parseConfigClass(Advanced3Config.class);
}

/*
如果你修改了配置文件,执行这个函数以显式更新。
TODO 自动更新仍在开发中。
*/
public static void update() {
getConfigGui().reDraw();
// CheatDetector.CONFIG_HANDLER.save();
CheatDetector.CONFIG_HANDLER.save();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package top.infsky.cheatdetector.impl.modules.common;

import com.mojang.authlib.GameProfile;
import io.netty.channel.ChannelHandlerContext;
import lombok.Getter;
import lombok.SneakyThrows;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
Expand All @@ -20,7 +18,6 @@
import top.infsky.cheatdetector.utils.TRSelf;
import top.infsky.cheatdetector.config.ModuleConfig;

import javax.naming.NameNotFoundException;
import java.util.*;
import java.util.concurrent.TimeUnit;

Expand All @@ -29,84 +26,58 @@ public class AntiVanish extends Module {
@Nullable
private static Module instance = null;

private final Map<GameProfile, Integer> playerLeaveCache = new HashMap<>();
private final Map<String, Integer> playerLeaveCache = new HashMap<>();

private final List<String> currentVanish = new LinkedList<>();
public AntiVanish(@NotNull TRSelf player) {
super("AntiVanish", player);
instance = this;
}

@SneakyThrows
@Override
public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePacket, Connection connection, ChannelHandlerContext channelHandlerContext, CallbackInfo ci) {
if (isDisabled()) return false;
if (basePacket instanceof ClientboundPlayerInfoRemovePacket packet) {
packet.profileIds().forEach(uuid -> {
GameProfile profile = getProfile(uuid);
if (playerLeaveCache.containsKey(profile)) {
playerLeaveCache.remove(profile);
packet.profileIds().forEach(uuid -> getName(uuid).ifPresentOrElse(name -> {
if (currentVanish.contains(name)) {
currentVanish.remove(name);
customMsg(Component.translatable("cheatdetector.chat.alert.stopVanish").getString().formatted(name));
}

if (playerLeaveCache.containsKey(name)) {
playerLeaveCache.remove(name);
} else {
playerLeaveCache.put(profile, 1);
playerLeaveCache.put(name, 1);
player.timeTask.schedule(() -> {
if (playerLeaveCache.getOrDefault(profile, 2) < 2) {
customMsg(Component.translatable("cheatdetector.chat.alert.foundVanish").append(profile.getName()).getString());
if (playerLeaveCache.getOrDefault(name, 1) < 2) {
customMsg(Component.translatable("cheatdetector.chat.alert.startVanish").getString().formatted(name));
currentVanish.add(name);
}
playerLeaveCache.remove(profile);
}, player.getLatency() + 50, TimeUnit.MILLISECONDS);
playerLeaveCache.remove(name);
}, 150, TimeUnit.MILLISECONDS);
}
});
}, () -> customMsg("receive invalid player leave packet: %s".formatted(uuid))));
}
if (basePacket instanceof ClientboundSystemChatPacket packet && packet.content().getString().endsWith("退出了游戏")) {
String msg = packet.content().getString();
GameProfile profile = getProfile(msg.substring(0, msg.length() - 6));
if (profile != null) {
playerLeaveCache.put(profile, playerLeaveCache.getOrDefault(profile, 0));

if (playerLeaveCache.containsKey(profile)) {
playerLeaveCache.remove(profile);
} else {
playerLeaveCache.put(profile, 1);
player.timeTask.schedule(() -> {
if (playerLeaveCache.getOrDefault(profile, 2) < 2) {
customMsg(Component.translatable("cheatdetector.chat.alert.foundVanish").append(profile.getName()).getString());
}
playerLeaveCache.remove(profile);
}, player.getLatency() + 50, TimeUnit.MILLISECONDS);
}
} else {
throw new NameNotFoundException("receive invalid player leave msg: %s".formatted(msg));
}
String name = msg.substring(0, msg.length() - 5);
playerLeaveCache.put(name, playerLeaveCache.getOrDefault(name, 1) + 1);
}
return false;
}

private @NotNull GameProfile getProfile(UUID uuid) {
private @NotNull Optional<String> getName(UUID uuid) {
TRPlayer trPlayer = CheatDetector.manager.getDataMap().getOrDefault(uuid, null);
if (trPlayer != null) {
return trPlayer.fabricPlayer.getGameProfile();
return Optional.of(trPlayer.fabricPlayer.getGameProfile().getName());
}

PlayerInfo playerInfo = player.fabricPlayer.connection.getPlayerInfo(uuid);
if (playerInfo != null) {
return playerInfo.getProfile();
}

return new GameProfile(uuid, uuid.toString());
}

private @Nullable GameProfile getProfile(String name) {
for (TRPlayer trPlayer : CheatDetector.manager.getDataMap().values()) {
if (trPlayer.fabricPlayer.getName().getString().equals(name)) {
return trPlayer.fabricPlayer.getGameProfile();
}
}


PlayerInfo playerInfo = player.fabricPlayer.connection.getPlayerInfo(name);
if (playerInfo != null) {
return playerInfo.getProfile();
return Optional.of(playerInfo.getProfile().getName());
}

return null;
return Optional.empty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import top.infsky.cheatdetector.impl.Module;
import top.infsky.cheatdetector.impl.utils.packet.PacketHandler;
import top.infsky.cheatdetector.utils.TRSelf;
import top.infsky.cheatdetector.impl.modules.ClickGUI;
import top.infsky.cheatdetector.impl.utils.packet.IncomingPacket;
import top.infsky.cheatdetector.impl.utils.packet.OutgoingPacket;
import top.infsky.cheatdetector.config.Advanced3Config;
Expand Down Expand Up @@ -90,7 +89,6 @@ public void _onTeleport() {

if (Advanced3Config.blinkAutoDisable) {
CheatDetector.CONFIG_HANDLER.configManager.setValue("blinkEnabled", false);
ClickGUI.update();
}
}

Expand Down
Loading

0 comments on commit 179b541

Please sign in to comment.