天上太阳红衫衫
This commit is contained in:
parent
4af20b4df5
commit
8cd07e8521
4 changed files with 84 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Plugin } from "../classes/classes.ts";
|
||||
import { PacketWriter, Player, Plugin } from "../classes/classes.ts";
|
||||
import { Server } from "../classes/Server.ts";
|
||||
import { config } from "../deps.ts";
|
||||
|
||||
|
|
@ -7,14 +7,36 @@ export default class CommandPlugin extends Plugin {
|
|||
"help",
|
||||
"reloadplugins",
|
||||
"clients",
|
||||
"tp",
|
||||
"eval"
|
||||
];
|
||||
|
||||
async tp(from: Player, to: Player) {
|
||||
if(to.world != from.world) {
|
||||
from.toWorld(this.server.worlds.find((e) =>
|
||||
e.name == to.world
|
||||
)!);
|
||||
}
|
||||
|
||||
await from.writeToSocket(
|
||||
new PacketWriter()
|
||||
.writeByte(0x08)
|
||||
.writeSByte(255)
|
||||
.writeShort(to.position.x)
|
||||
.writeShort(to.position.y)
|
||||
.writeShort(to.position.z)
|
||||
.writeByte(to.rotation.yaw)
|
||||
.writeByte(to.rotation.pitch)
|
||||
.toPacket(),
|
||||
);
|
||||
}
|
||||
|
||||
constructor(server: Server) {
|
||||
super();
|
||||
|
||||
this.server = server;
|
||||
|
||||
this.on("command", async (command, player) => {
|
||||
this.on("command", async (command, player, args) => {
|
||||
if (command == "help") {
|
||||
let allComamnds = "";
|
||||
for (const [_k, v] of server.plugins) {
|
||||
|
|
@ -38,7 +60,42 @@ export default class CommandPlugin extends Plugin {
|
|||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if(command == "eval") {
|
||||
if(config.ops.includes(player.username)) {
|
||||
|
||||
server.broadcast(eval(args.join(" ")));
|
||||
}
|
||||
} else if (command == "tp") {
|
||||
if(args.length == 1) {
|
||||
const teleportTo = this.server.players.find((e) => args[0] === e.username)
|
||||
|
||||
if(teleportTo) {
|
||||
await this.tp(player, teleportTo);
|
||||
} else {
|
||||
player.message("Player is missing")
|
||||
}
|
||||
} else if(args.length == 3) {
|
||||
const x = +args[0]
|
||||
const y = +args[1]
|
||||
const z = +args[2]
|
||||
|
||||
if(isNaN(x) || isNaN(y) || isNaN(z)) {
|
||||
player.message("invalid coords")
|
||||
return;
|
||||
}
|
||||
await player.writeToSocket(
|
||||
new PacketWriter()
|
||||
.writeByte(0x08)
|
||||
.writeSByte(255)
|
||||
.writeShort(x * 32)
|
||||
.writeShort(y * 32)
|
||||
.writeShort(z * 32)
|
||||
.writeByte(player.rotation.yaw)
|
||||
.writeByte(player.rotation.pitch)
|
||||
.toPacket(),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue