Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gamelist1990 committed Sep 2, 2024
1 parent ac61d9c commit 38b96c8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
2 changes: 2 additions & 0 deletions devFolder/src/Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { RunAntiCheat } from './command/plugin/packet';

const startTime = Date.now();



async function loadAllImports() {
try {
await import('./command/import');
Expand Down
48 changes: 45 additions & 3 deletions devFolder/src/command/plugin/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config = {
clickTpThreshold: 25, // ClickTP 判定距離 (ブロック)
clickTpExclusionThreshold: 50, // この距離以上は検出除外
freezeDuration: 20 * 60 * 60, // freeze時間 (ティック): 約1時間
betasystem: true,
betasystem: false,
},
};

Expand All @@ -36,6 +36,9 @@ interface PlayerData {
isFrozen: boolean;
freezeStartTime: number;
isJumping: boolean;
jumpCounter: number;
recentlyUsedEnderPearl: boolean;
enderPearlTimeout: any;
}

// ----------------------------------
Expand Down Expand Up @@ -69,6 +72,9 @@ function initializePlayerData(player: Player) {
isFrozen: false,
freezeStartTime: 0,
isJumping: false,
jumpCounter: 0,
enderPearlTimeout: null,
recentlyUsedEnderPearl: false,
};
console.warn(`プレイヤー ${player.name} (ID: ${player.id}) を監視しています`);
}
Expand Down Expand Up @@ -208,6 +214,8 @@ function detectClickTP(player: Player): { cheatType: string } | null {
return null;
}



const excludedEffects = [
'minecraft:absorption',
'minecraft:bad_omen',
Expand Down Expand Up @@ -263,6 +271,30 @@ function detectClickTP(player: Player): { cheatType: string } | null {
return null;
}

world.afterEvents.itemUse.subscribe((event) => {
const player = event.source;
const item = event.itemStack;

if (item && item.typeId === 'minecraft:ender_pearl') {
const data = playerData[player.id] || {};
playerData[player.id] = data;

if (data.enderPearlTimeout) {
// 既存のタイムアウトをキャンセル
system.clearRun(data.enderPearlTimeout);
}

data.recentlyUsedEnderPearl = true;

// 新しいタイムアウトを設定
data.enderPearlTimeout = system.runTimeout(() => {
data.recentlyUsedEnderPearl = false;
data.enderPearlTimeout = null;
}, 9000); // 9秒後にリセット
}
});


function detectAirJump(player: Player): { cheatType: string } | null {
const data = playerData[player.id];
if (!data || data.isTeleporting || player.isGliding || getGamemode(player.name) === 1) {
Expand All @@ -275,22 +307,31 @@ function detectAirJump(player: Player): { cheatType: string } | null {
const recentPosition = positionHistory[positionHistory.length - 1];
const previousPosition = positionHistory[positionHistory.length - 2];

// Initialize jump counter if not present
if (data.jumpCounter === undefined) {
data.jumpCounter = 0;
}

// プレイヤーがジャンプした場合、ジャンプフラグを立てる
if (isJumping && recentPosition && previousPosition && recentPosition.y > previousPosition.y) {
data.isJumping = true;
}

// プレイヤーが地面に着地した場合、ジャンプフラグをリセット
// プレイヤーが地面に着地した場合、ジャンプフラグとカウンターをリセット
if (isOnGround && data.isJumping) {
data.isJumping = false;
data.jumpCounter = 0;
return null;
}

// 空中ジャンプの検出
if (!isOnGround && data.isJumping && isJumping && recentPosition && previousPosition) {
const jumpHeight = recentPosition.y - previousPosition.y;
if (jumpHeight > 1.25) { // 大体1.25
return { cheatType: '(AirJump|Fly)' };
data.jumpCounter++;
if (data.jumpCounter >= 2) {
return { cheatType: '(AirJump|Fly)' };
}
}
}

Expand All @@ -299,6 +340,7 @@ function detectAirJump(player: Player): { cheatType: string } | null {




function detectESP(player: Player): { cheatType: string } | null {
const viewDirection = player.getViewDirection();
const playerDimension = player.dimension;
Expand Down

0 comments on commit 38b96c8

Please sign in to comment.