Skip to content

Commit

Permalink
Lore And Packet TS の修正
Browse files Browse the repository at this point in the history
  • Loading branch information
gamelist1990 committed Oct 24, 2024
1 parent ff953d9 commit 36a8ab5
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 78 deletions.
19 changes: 16 additions & 3 deletions devFolder/src/command/plugin/lore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ function removeSpecificLore(item: any, loreText: string, player: Player, targetS
}, 1);
}


registerCommand({
name: 'lore',
description: 'loreCom',
parent: false,
maxArgs: -1,
minArgs: 2,
minArgs: 1, // Changed minArgs to 1 to allow for just 'lore -clear'
require: (player: Player) => verifier(player, config().commands['lore']),
executor: (player: Player, args: string[]) => {
// 引数が提供されていない場合のチェックを追加
if (!args || args.length < 2) {
if (!args || args.length < 1) { // Changed condition to check for at least 1 argument
player.sendMessage(translate(player, "command.UsageLore", { prefix: `${prefix}` }));
return;
}
Expand Down Expand Up @@ -123,10 +124,18 @@ registerCommand({
const subCommand = args[0].toLowerCase();

if (subCommand === '-set') {
if (args.length < 2) { // Check if there's enough arguments for -set
player.sendMessage(translate(player, "command.UsageLore", { prefix: `${prefix}` }));
return;
}
const loreText = args.slice(1).join(' ');
AddLore(heldItem, loreText, player, targetSlot);
player.sendMessage(translate(player, "command.AddLore"));
} else if (subCommand === '-remove') {
if (args.length < 2) { // Check if there's enough arguments for -remove
player.sendMessage(translate(player, "command.UsageLore", { prefix: `${prefix}` }));
return;
}
const loreText = args.slice(1).join(' ');
removeSpecificLore(heldItem, loreText, player, targetSlot);
const currentLore = heldItem.getLore() || [];
Expand All @@ -136,6 +145,10 @@ registerCommand({
player.sendMessage(translate(player, "command.RemoveLore"));
}
} else if (subCommand === '-rename') {
if (args.length < 2) { // Check if there's enough arguments for -rename
player.sendMessage(translate(player, "command.UsageLore", { prefix: `${prefix}` }));
return;
}
const NewName = args.slice(1).join(' ');
renameItem(heldItem, NewName, player, targetSlot);
player.sendMessage(translate(player, "command.ChangeNames"));
Expand All @@ -146,4 +159,4 @@ registerCommand({
player.sendMessage(translate(player, "command.UsageLore", { prefix: `${prefix}` }));
}
},
});
});
74 changes: 25 additions & 49 deletions devFolder/src/command/plugin/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ function executeRollback(player: Player): void {
playerDataManager.reset(player);
}

function hasAnyEffectExcept(player: Player, excludedEffects: string[]): boolean {
return player.getEffects().some((effect) => !excludedEffects.includes(effect.typeId));
}


async function executeFreeze(player: Player): Promise<void> {
const data = playerDataManager.get(player);
Expand Down Expand Up @@ -304,10 +302,8 @@ world.afterEvents.itemUse.subscribe((event) => {

function hasEffect(player:Player, effectName:any) {
try {
// getEffect() はエフェクトが存在しない場合に undefined を返す
return player.getEffect(effectName) !== undefined;
} catch (error) {
// getEffect() はエフェクトが存在しない場合にエラーをスローすることもある
return false;
}
}
Expand All @@ -322,9 +318,9 @@ function detectAirJump(player: Player): { cheatType: string } | null {
!data ||
data.isTeleporting ||
player.isGliding ||
data.recentlyUsedEnderPearl ||
getGamemode(player.name) === 1 ||
getGamemode(player.name) === 3
player.isInWater ||
player.isFlying ||
data.recentlyUsedEnderPearl
) {
return null;
}
Expand Down Expand Up @@ -595,37 +591,7 @@ world.beforeEvents.playerBreakBlock.subscribe((event) => {
});
});

function getExcludedEffects(): string[] {
return [
'minecraft:absorption',
'minecraft:bad_omen',
'minecraft:blindness',
'minecraft:conduit_power',
'minecraft:darkness',
'minecraft:fatal_poison',
'minecraft:fire_resistance',
'minecraft:glowing',
'minecraft:haste',
'minecraft:health_boost',
'minecraft:hunger',
'minecraft:instant_damage',
'minecraft:instant_health',
'minecraft:invisibility',
'minecraft:mining_fatigue',
'minecraft:nausea',
'minecraft:night_vision',
'minecraft:poison',
'minecraft:regeneration',
'minecraft:resistance',
'minecraft:saturation',
'minecraft:slow_falling',
'minecraft:slowness',
'minecraft:strength',
'minecraft:water_breathing',
'minecraft:weakness',
'minecraft:wither',
];
}


function monitorItemUseOn(player: Player, itemId: string): void {
if (!monitoring) return; // アンチチートが無効の場合は何もしない
Expand Down Expand Up @@ -770,26 +736,36 @@ function updateTimerData(player: Player, now: number) {
}



function isPlayerOnGround(player: Player): boolean {
const viewDirection = player.getViewDirection();
viewDirection.y = -1; // y座標を-1にして 下向きにビーム

const blockBelow = player.getBlockFromViewDirection({
maxDistance: 1.5, //距離は1.5Block
includePassableBlocks: false,
});
console.log(`IsPlayerOnground:${JSON.stringify(blockBelow,null,2)}`)

return blockBelow !== undefined && blockBelow.block.isSolid;
}

function detectFlyHack(player: Player): { cheatType: string } | null {
const data = playerDataManager.get(player);

// プレイヤーデータが取得できない場合、テレポート中、グライディング中、エンダーパール使用後、
// クリエイティブモード、スペクテイターモードの場合は処理をスキップ

if (
!data ||
data.isTeleporting ||
player.isGliding ||
data.recentlyUsedEnderPearl ||
getGamemode(player.name) === 1 ||
getGamemode(player.name) === 3
player.isInWater ||
player.isFalling ||
player.isFlying ||
data.recentlyUsedEnderPearl
) {
return null;
}

// 特定の効果を除いて、効果が付与されている場合は処理をスキップ
if (hasAnyEffectExcept(player, getExcludedEffects())) {
return null;
}

const isOnGround = player.isOnGround; // 地面にいるかどうか
const currentPosition = player.location; // 現在の位置
Expand All @@ -813,7 +789,7 @@ function detectFlyHack(player: Player): { cheatType: string } | null {
const velocityChangeRate = (currentVelocityY - twoTicksAgoVelocityY) / (50 * 2);

// FlyHack判定 (地面にいない状態で異常な垂直移動)
if (!isOnGround && currentVelocityY > 0.5) {
if (!isPlayerOnGround(player) && currentVelocityY > 0.5) {
// 異常な上昇速度
if (
currentVelocityY > 1.2 || // 高速上昇
Expand Down
2 changes: 1 addition & 1 deletion devFolder/src/command/utility/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ registerCommand({
}).then(() => { });
}
} else {
player.sendMessage('Invalid argument. Use "-pause", "-check", "-checkban", "-info <seed|uptime|tps>", or "-ping [-true|-false]".');
player.sendMessage('Invalid argument. Use "-pause", "-check", "-checkban", "-info uptime", or "-ping [-true|-false]".');
}
},
});
6 changes: 3 additions & 3 deletions devFolder/src/node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions devFolder/src/node_modules/@minecraft/server/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion devFolder/src/node_modules/@minecraft/server/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36a8ab5

Please sign in to comment.