Skip to content

Commit

Permalink
chore: also freeze camera
Browse files Browse the repository at this point in the history
  • Loading branch information
tutinoko2048 committed Dec 4, 2024
1 parent 3975fe5 commit 6e567e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/commands/data/freeze.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const freezeCommand = new Command({
if (!target) throw new CommandError(`プレイヤー ${targetName} が見つかりませんでした`);
const freezeState = value ? toBoolean(value) : !handler.ac.frozenPlayerMap.has(target.id);
target.inputPermissions.movementEnabled = !freezeState;
target.inputPermissions.cameraEnabled = !freezeState;
if (freezeState) handler.ac.frozenPlayerMap.set(target.id, target.location);
else handler.ac.frozenPlayerMap.delete(target.id);

Expand Down
12 changes: 10 additions & 2 deletions scripts/form/AdminPanel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { world, ItemStack, ItemTypes, EquipmentSlot, Player, ScoreboardObjective } from '@minecraft/server';
import { world, ItemStack, ItemTypes, EquipmentSlot, Player, ScoreboardObjective, InputMode } from '@minecraft/server';
import * as UI from '@minecraft/server-ui';
import { Util } from '../util/util';
import config from '../config.js';
Expand All @@ -12,6 +12,13 @@ import { BanManager } from '../util/BanManager';
import { Duration } from '../lib/duration/main';
import { getTPS } from '../util/tps';

const inputModeMap = {
[InputMode.KeyboardAndMouse]: 'KeyboardMouse',
[InputMode.Gamepad]: 'Controller',
[InputMode.Touch]: 'Touch',
[InputMode.MotionController]: 'MotionController'
}

/** @typedef {{ slot: import('@minecraft/server').ContainerSlot, slotId: EquipmentSlot | number }} ItemInformation */

/** @enum {'NameTag' | 'Lore'} */
Expand Down Expand Up @@ -90,7 +97,7 @@ export class AdminPanel {
`§7ID: §f${target.id}`,
`§7Location: §f${x}, ${y}, ${z} (${target.dimension.id.replace('minecraft:', '')})`,
`§7GameMode: §f${target.getGameMode()}`,
`§7Platform: §f${target.clientSystemInfo.platformType} - ${target.inputInfo.lastInputModeUsed}`,
`§7Platform: §f${target.clientSystemInfo.platformType} (${inputModeMap[target.inputInfo.lastInputModeUsed]})`,
`§7Health: §f${Math.floor(currentValue)} / ${effectiveMax}`,
`§7Permission: §f${perm(target)}`,
target.joinedAt ? `§7JoinedAt: §f${Util.getTime(target.joinedAt)}` : null,
Expand Down Expand Up @@ -299,6 +306,7 @@ export class AdminPanel {

if (freeze !== _freeze) {
target.inputPermissions.movementEnabled = !freeze;
target.inputPermissions.cameraEnabled = !freeze;
if (freeze) this.ac.frozenPlayerMap.set(target.id, target.location);
else this.ac.frozenPlayerMap.delete(target.id);
Util.notify(`§7${this.player.name}§r§7 >> ${target.name} のフリーズを ${freeze} に設定しました`);
Expand Down

0 comments on commit 6e567e0

Please sign in to comment.