mirror of
https://github.com/WorldEditAxe/eaglerproxy.git
synced 2024-12-21 14:54:13 -08:00
fixed bug that would cause the client to not disconnect if an error occurs whilst switching servers
This commit is contained in:
parent
b348c2bef2
commit
3e6f59b9e0
4
example_plugins/AutokickPlugin/config.js
Normal file
4
example_plugins/AutokickPlugin/config.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
export const config = {
|
||||||
|
bindInternalServerPort: 25569,
|
||||||
|
bindInternalServerIp: "127.0.0.1",
|
||||||
|
};
|
|
@ -1,4 +0,0 @@
|
||||||
export const config = {
|
|
||||||
bindInternalServerPort: 25569,
|
|
||||||
bindInternalServerIp: "127.0.0.1",
|
|
||||||
};
|
|
|
@ -1,9 +1,7 @@
|
||||||
import metadata from "./metadata.json" assert { type: "json" };
|
import metadata from "./metadata.json" assert { type: "json" };
|
||||||
import { createServer } from "minecraft-protocol";
|
import { createServer } from "minecraft-protocol";
|
||||||
import { config } from "./config.js";
|
import { config } from "./config.js";
|
||||||
|
const PluginManager = PLUGIN_MANAGER;
|
||||||
const PluginManager = PLUGIN_MANAGER as any;
|
|
||||||
|
|
||||||
const Logger = PluginManager.Logger;
|
const Logger = PluginManager.Logger;
|
||||||
const Enums = PluginManager.Enums;
|
const Enums = PluginManager.Enums;
|
||||||
const Chat = PluginManager.Chat;
|
const Chat = PluginManager.Chat;
|
||||||
|
@ -13,36 +11,28 @@ const Player = PluginManager.Player;
|
||||||
const MineProtocol = PluginManager.MineProtocol;
|
const MineProtocol = PluginManager.MineProtocol;
|
||||||
const EaglerSkins = PluginManager.EaglerSkins;
|
const EaglerSkins = PluginManager.EaglerSkins;
|
||||||
const Util = PluginManager.Util;
|
const Util = PluginManager.Util;
|
||||||
|
|
||||||
const logger = new Logger("AutoKicker");
|
const logger = new Logger("AutoKicker");
|
||||||
logger.info(`Starting ${metadata.name} v${metadata.version}...`);
|
logger.info(`Starting ${metadata.name} v${metadata.version}...`);
|
||||||
logger.info(
|
logger.info(`(internal server port: ${config.bindInternalServerPort}, internal server IP: ${config.bindInternalServerPort})`);
|
||||||
`(internal server port: ${config.bindInternalServerPort}, internal server IP: ${config.bindInternalServerPort})`
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.info("Starting internal server...");
|
logger.info("Starting internal server...");
|
||||||
let server = createServer({
|
let server = createServer({
|
||||||
host: config.bindInternalServerIp,
|
host: config.bindInternalServerIp,
|
||||||
port: config.bindInternalServerPort,
|
port: config.bindInternalServerPort,
|
||||||
motdMsg: `${Enums.ChatColor.GOLD}EaglerProxy as a Service`,
|
motdMsg: `${Enums.ChatColor.GOLD}EaglerProxy as a Service`,
|
||||||
"online-mode": false,
|
"online-mode": false,
|
||||||
version: "1.8.9",
|
version: "1.8.9",
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("login", (client) => {
|
server.on("login", (client) => {
|
||||||
logger.info(`Client ${client.username} has connected to the dummy server.`);
|
logger.info(`Client ${client.username} has connected to the dummy server.`);
|
||||||
client.write("kick_disconnect", {
|
client.write("kick_disconnect", {
|
||||||
reason: "NO",
|
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 = {
|
CONFIG.adapter.server = {
|
||||||
host: config.bindInternalServerIp,
|
host: config.bindInternalServerIp,
|
||||||
port: config.bindInternalServerPort,
|
port: config.bindInternalServerPort,
|
||||||
};
|
};
|
||||||
CONFIG.adapter.motd = {
|
CONFIG.adapter.motd = {
|
||||||
l1: Enums.ChatColor.RED + "Server Under Maintenance",
|
l1: Enums.ChatColor.RED + "Server Under Maintenance",
|
||||||
};
|
};
|
5
example_plugins/AutokickPlugin/types.d.ts
vendored
5
example_plugins/AutokickPlugin/types.d.ts
vendored
|
@ -1,5 +0,0 @@
|
||||||
declare global {
|
|
||||||
var PLUGIN_MANAGER;
|
|
||||||
}
|
|
||||||
|
|
||||||
export {};
|
|
|
@ -290,7 +290,7 @@ export class Player extends EventEmitter {
|
||||||
}, 30000);
|
}, 30000);
|
||||||
client.on("error", errListener);
|
client.on("error", errListener);
|
||||||
client.on("end", (reason) => {
|
client.on("end", (reason) => {
|
||||||
if (!this._switchingServers) {
|
if (!this._switchingServers && !switchingServers) {
|
||||||
this.disconnect(this._kickMessage ?? reason);
|
this.disconnect(this._kickMessage ?? reason);
|
||||||
}
|
}
|
||||||
this.ws.removeListener("message", listener);
|
this.ws.removeListener("message", listener);
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"sourceMap": false,
|
"sourceMap": false,
|
||||||
"outDir": "build",
|
"outDir": "build",
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true,
|
||||||
|
"rootDir": "src"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.json", "src/**/*", "example_plugins/AutokickPlugin"],
|
"include": ["src/**/*.json", "src/**/*"],
|
||||||
"hooks": ["copy-files"]
|
"hooks": ["copy-files"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user