-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lZiMUl
authored and
lZiMUl
committed
Jan 2, 2023
1 parent
944d5a5
commit 4fab61f
Showing
8 changed files
with
118 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
{ | ||
"cSpell.words": [ | ||
"commandregister", | ||
"locationteleportmenu", | ||
"minecraft", | ||
"overworld", | ||
"teleportmenu", | ||
"tpamenu" | ||
"tpamenu", | ||
"tsbuildinfo" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Player } from '@minecraft/server'; | ||
interface Data { | ||
sender: Player; | ||
args: string[]; | ||
} | ||
interface CallBack { | ||
(data: Data): void; | ||
} | ||
interface Cache { | ||
commandName: string; | ||
callback: CallBack; | ||
} | ||
declare class CommandRegister { | ||
private identifier; | ||
private cache; | ||
constructor(identifier: string); | ||
addCommandListener(commandName: string, callback: CallBack): void; | ||
chatStream(message: string, sender: Player): void; | ||
} | ||
export default CommandRegister; | ||
export type { Data, CallBack, Cache }; | ||
//# sourceMappingURL=commandregister.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 +1,7 @@ | ||
{ | ||
"name": "minecraft-server-teleport", | ||
"description": "Minecraft Server Teleport Tools (By lZiMUl)", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"author": { | ||
"name": "lZiMUl", | ||
"email": "[email protected]", | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 导入基础模块 | ||
import { Player } from '@minecraft/server'; | ||
// 定义数据接口 | ||
interface Data { | ||
sender: Player; | ||
args: string[]; | ||
} | ||
// 定义回调接口 | ||
interface CallBack { | ||
(data: Data): void; | ||
} | ||
// 定义缓存接口 | ||
interface Cache { | ||
commandName: string; | ||
callback: CallBack; | ||
} | ||
// 定义命令注册器类 | ||
class CommandRegister { | ||
// 命令标识符 | ||
private identifier: string; | ||
// 命令缓存栈 | ||
private cache: Cache[] = []; | ||
public constructor(identifier: string) { | ||
this.identifier = identifier; | ||
} | ||
// 公开添加命令监听器方法 | ||
public addCommandListener(commandName: string, callback: CallBack): void { | ||
this.cache.push({ | ||
commandName, | ||
callback, | ||
}); | ||
} | ||
// 公开聊天流方法 | ||
public chatStream(message: string, sender: Player): void { | ||
// 判断玩家是否带有命令标识符 | ||
if (message.split('')[0] === this.identifier) { | ||
// 遍历所有当前所有缓存栈 | ||
this.cache.forEach((item: Cache): void => { | ||
// 判断命令名称是否一致 | ||
if ( | ||
item.commandName === | ||
message.substring(1, message.indexOf(' ') ?? message.length) | ||
) { | ||
// 一致就回调 | ||
item.callback({ | ||
args: message | ||
.substring(message.indexOf(' ') + 1, message.length) | ||
.split(' '), | ||
sender, | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
// 导出命令注册器 | ||
export default CommandRegister; | ||
// 导出接口 | ||
export type { Data, CallBack, Cache }; |