format everything + fix plugin events

This commit is contained in:
yourfriend 2022-06-03 15:36:34 +03:00
parent cf8772f0ed
commit d40e90240c
No known key found for this signature in database
GPG key ID: C28FFD8607DAC4DE
9 changed files with 280 additions and 37 deletions

View file

@ -13,7 +13,7 @@ export default class CommandPlugin extends Plugin {
super();
this.server = server;
this.on("command", async (command, player) => {
if (command == "help") {
let allComamnds = "";

View file

@ -1,4 +1,4 @@
import { PacketDefinitions, Plugin, World } from "../classes/classes.ts";
import { Plugin, World } from "../classes/classes.ts";
import { Server } from "../classes/Server.ts";
import { config } from "../deps.ts";
@ -13,20 +13,16 @@ export default class CommandPlugin extends Plugin {
super();
this.server = server;
this.on("setblock", (player, _mode, _id, position, blockBefore) => {
this.on("setblock", (player, _mode, _id) => {
const world = server.worlds.find((e) => e.name == player.world)!;
if (!world.optionalJson?.builders?.includes("*")) {
if (!world.optionalJson?.builders?.includes(player.username)) {
player.message("You are %cnot allowed &fto build in this world!");
world.setBlock(position, blockBefore);
server.players.forEach(async (e) => {
if (e.world == player.world) {
await PacketDefinitions.setBlock(position, blockBefore, e);
}
});
return true;
}
}
return false;
});
this.on("command", async (command, player, args) => {
if (command == "g") {