diff --git a/example_plugins/AutokickPlugin/config.js b/example_plugins/AutokickPlugin/config.js new file mode 100644 index 0000000..1a924a0 --- /dev/null +++ b/example_plugins/AutokickPlugin/config.js @@ -0,0 +1,4 @@ +export const config = { + bindInternalServerPort: 25569, + bindInternalServerIp: "127.0.0.1", +}; diff --git a/example_plugins/AutokickPlugin/config.ts b/example_plugins/AutokickPlugin/config.ts deleted file mode 100644 index 47bb07d..0000000 --- a/example_plugins/AutokickPlugin/config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const config = { - bindInternalServerPort: 25569, - bindInternalServerIp: "127.0.0.1", -}; diff --git a/example_plugins/AutokickPlugin/index.ts b/example_plugins/AutokickPlugin/index.js similarity index 51% rename from example_plugins/AutokickPlugin/index.ts rename to example_plugins/AutokickPlugin/index.js index 3db84da..a7b0d50 100644 --- a/example_plugins/AutokickPlugin/index.ts +++ b/example_plugins/AutokickPlugin/index.js @@ -1,9 +1,7 @@ import metadata from "./metadata.json" assert { type: "json" }; import { createServer } from "minecraft-protocol"; import { config } from "./config.js"; - -const PluginManager = PLUGIN_MANAGER as any; - +const PluginManager = PLUGIN_MANAGER; const Logger = PluginManager.Logger; const Enums = PluginManager.Enums; const Chat = PluginManager.Chat; @@ -13,36 +11,28 @@ const Player = PluginManager.Player; const MineProtocol = PluginManager.MineProtocol; const EaglerSkins = PluginManager.EaglerSkins; const Util = PluginManager.Util; - const logger = new Logger("AutoKicker"); logger.info(`Starting ${metadata.name} v${metadata.version}...`); -logger.info( - `(internal server port: ${config.bindInternalServerPort}, internal server IP: ${config.bindInternalServerPort})` -); - +logger.info(`(internal server port: ${config.bindInternalServerPort}, internal server IP: ${config.bindInternalServerPort})`); logger.info("Starting internal server..."); let server = createServer({ - host: config.bindInternalServerIp, - port: config.bindInternalServerPort, - motdMsg: `${Enums.ChatColor.GOLD}EaglerProxy as a Service`, - "online-mode": false, - version: "1.8.9", + host: config.bindInternalServerIp, + port: config.bindInternalServerPort, + motdMsg: `${Enums.ChatColor.GOLD}EaglerProxy as a Service`, + "online-mode": false, + version: "1.8.9", }); - server.on("login", (client) => { - logger.info(`Client ${client.username} has connected to the dummy server.`); - client.write("kick_disconnect", { - reason: "NO", - }); + logger.info(`Client ${client.username} has connected to the dummy server.`); + client.write("kick_disconnect", { + reason: "NO", + }); }); - -logger.info( - "Redirecting backend server IP... (this is required for the plugin to function)" -); +logger.info("Redirecting backend server IP... (this is required for the plugin to function)"); CONFIG.adapter.server = { - host: config.bindInternalServerIp, - port: config.bindInternalServerPort, + host: config.bindInternalServerIp, + port: config.bindInternalServerPort, }; CONFIG.adapter.motd = { - l1: Enums.ChatColor.RED + "Server Under Maintenance", + l1: Enums.ChatColor.RED + "Server Under Maintenance", }; diff --git a/example_plugins/AutokickPlugin/types.d.ts b/example_plugins/AutokickPlugin/types.d.ts deleted file mode 100644 index fa9b794..0000000 --- a/example_plugins/AutokickPlugin/types.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare global { - var PLUGIN_MANAGER; -} - -export {}; diff --git a/src/proxy/Player.ts b/src/proxy/Player.ts index 6267523..42701a7 100644 --- a/src/proxy/Player.ts +++ b/src/proxy/Player.ts @@ -290,7 +290,7 @@ export class Player extends EventEmitter { }, 30000); client.on("error", errListener); client.on("end", (reason) => { - if (!this._switchingServers) { + if (!this._switchingServers && !switchingServers) { this.disconnect(this._kickMessage ?? reason); } this.ws.removeListener("message", listener); diff --git a/tsconfig.json b/tsconfig.json index 3fdff2f..1125862 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,8 +6,9 @@ "moduleResolution": "node", "sourceMap": false, "outDir": "build", - "resolveJsonModule": true + "resolveJsonModule": true, + "rootDir": "src" }, - "include": ["src/**/*.json", "src/**/*", "example_plugins/AutokickPlugin"], + "include": ["src/**/*.json", "src/**/*"], "hooks": ["copy-files"] }