-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move loading functions into internal
- Loading branch information
1 parent
9f29c79
commit 4c8fdbb
Showing
2 changed files
with
30 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,4 @@ | ||
import { world, system, Player } from '@minecraft/server'; | ||
import { TNAntiCheat } from './ac'; | ||
import { events } from './lib/events/index.js'; | ||
import { PropertyIds } from './util/constants'; | ||
import { PermissionType, Permissions } from './util/Permissions'; | ||
import './system/dog.js'; | ||
import './system/register_properties.js'; | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const ac = new TNAntiCheat(); | ||
events.worldLoad.subscribe(() => { | ||
if (world.getDynamicProperty(PropertyIds.ownerId)) { | ||
try { | ||
ac.enable(); | ||
} catch (e) { console.error(e, e.stack) } | ||
|
||
} else { | ||
world.sendMessage('[§l§aTN-AntiCheat§r] 初めに §6/function start§f を実行してください'); | ||
} | ||
}); | ||
|
||
system.afterEvents.scriptEventReceive.subscribe(ev => { | ||
const { id, sourceEntity } = ev; | ||
if (!(sourceEntity instanceof Player) || id != 'ac:start') return; | ||
start(sourceEntity); | ||
}, { | ||
namespaces: [ 'ac' ] | ||
}); | ||
|
||
/** @param {Player} player */ | ||
function start(player) { | ||
if (world.getDynamicProperty(PropertyIds.ownerId)) return player.sendMessage('TNAC is already registered!'); | ||
Permissions.add(player, PermissionType.Admin); | ||
world.setDynamicProperty(PropertyIds.ownerId, player.id); | ||
|
||
ac.enable(); | ||
player.sendMessage('§aAdmin権限が付与されました。"!help" でコマンド一覧を表示します'); | ||
} |