Skip to content

Commit

Permalink
Merge pull request #39 from EvoEsports/dev
Browse files Browse the repository at this point in the history
Version 0.4.0
  • Loading branch information
reaby authored Jul 8, 2024
2 parents 378ecf3 + a697cfc commit b41374b
Show file tree
Hide file tree
Showing 82 changed files with 5,823 additions and 1,284 deletions.
76 changes: 42 additions & 34 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
## Server
XMLRPC_HOST="127.0.0.1"
XMLRPC_PORT=5000
XMLRPC_USER="SuperAdmin"
XMLRPC_PASS="SuperAdmin"

## Controller

# comma separated list of admins for the server
ADMINS=""

EXCLUDED_PLUGINS="tmnf/freezone, tmnf/dedimania"

# set ansilevel:
# 0 = no color, 1 = 4bit color (console), 2 = 24bit color (rgb)
ANSILEVEL=1

# Debug info.. or not
DEBUG=false

## Plugins
FREEZONE_PASS=""
DEDIMANIA_PASS=""

TALIMIT=300
VOTE_TIMEOUT=30
VOTE_RATIO=0.55

## Theme

# COLOR_TITLE_BG="0ad"
# COLOR_TITLE_FG="fff"
# COLOR_BG="026"
# COLOR_INFO="abc"
## Server
XMLRPC_HOST="127.0.0.1"
XMLRPC_PORT=5000
XMLRPC_USER="SuperAdmin"
XMLRPC_PASS="SuperAdmin"

# database connection string examples:

# DATABASE="postgres://user:[email protected]:5432/databaseName"
# DATABASE="mysql://user:[email protected]:3306/databaseName"
# DATABASE="sqlite://userdata/local.sqlite"

DATABASE="sqlite://userdata/local.sqlite"

## Controller

# comma separated list of admins for the server
ADMINS=""

EXCLUDED_PLUGINS="tmnf/freezone, tmnf/dedimania"

# set ansilevel:
# 0 = no color, 1 = 4bit color (console), 2 = 24bit color (rgb)
ANSILEVEL=1

# Debug info.. or not
DEBUG=false

## Plugins
FREEZONE_PASS=""
DEDIMANIA_PASS=""

TALIMIT=300
VOTE_TIMEOUT=30
VOTE_RATIO=0.55

## Theme

# COLOR_TITLE_BG="0ad"
# COLOR_TITLE_FG="fff"
# COLOR_BG="026"
# COLOR_INFO="abc"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ userdata/*.sqlite
userdata/*.log
userdata/*.json
userdata/plugins/*
userdata/drizzle/*
userdata/migrations/*
userdata/schemas/*
!userdata/schemas/.gitkeep
!userdata/migrations/.gitkeep
!userdata/plugins/.gitkeep
docker-compose.yml
85 changes: 32 additions & 53 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,32 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "bun",
"request": "launch",
"name": "Debug Bun",

// The path to a JavaScript or TypeScript file to run.
"program": "core/minicontrol.ts",
// The arguments to pass to the program, if any.
"args": [],

// The working directory of the program.
"cwd": "${workspaceFolder}",

// The environment variables to pass to the program.
"env": {},

// If the environment variables should not be inherited from the parent process.
"strictEnv": false,

// If the program should be run in watch mode.
// This is equivalent to passing `--watch` to the `bun` executable.
// You can also set this to "hot" to enable hot reloading using `--hot`.
"watchMode": false,

// If the debugger should stop on the first line of the program.
"stopOnEntry": false,

// If the debugger should be disabled. (for example, breakpoints will not be hit)
"noDebug": false,

// The path to the `bun` executable, defaults to your `PATH` environment variable.
"runtime": "bun",

// The arguments to pass to the `bun` executable, if any.
// Unlike `args`, these are passed to the executable itself, not the program.
"runtimeArgs": [
"--smol"
],
},
{
"type": "bun",
"request": "attach",
"name": "Attach to Bun",

// The URL of the WebSocket inspector to attach to.
// This value can be retrieved by using `bun --inspect`.
"url": "ws://localhost:6499/",
}
]
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"runtimeArgs": [
"start"
],
"runtimeExecutable": "npm",
"name": "Run npm start",
"request": "launch",
"envFile": "${workspaceFolder}/.env",
"type": "node"
},
{
"name": "Launch via NPM",
"request": "launch",
"runtimeArgs": [
"run-script",
"debug"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},

]
}
11 changes: 0 additions & 11 deletions .vscode/settings.json

This file was deleted.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ A very simple plugin host for Trackmania United Forever, Maniaplanet and Trackma

# QuickStart

1. `npm i -g bun`
2. `bun install`
3. copy .env.example to .env and configure
4. `bun start`
1. `npm install`
2. copy .env.example to .env and configure
3. `npm start`

See [documentation](./documentation/index.md) for more info!

Expand All @@ -15,7 +14,7 @@ See [documentation](./documentation/index.md) for more info!
1. run controller once to generate database structure
2. `mysqldump -u root -p databasename > xaseco.sql`
3. move `xaseco.sql` to `tools`
5. run bun from Tools folder: `bun xaseco.ts xaseco.sql`
5. run bun from Tools folder: `tsx xaseco.ts xaseco.sql`
6. start controller


Expand Down
9 changes: 0 additions & 9 deletions build.ts

This file was deleted.

Binary file removed bun.lockb
Binary file not shown.
43 changes: 30 additions & 13 deletions core/gbx/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Buffer} from "buffer";
import type Server from "core/server";
import { Buffer } from "node:buffer";
import { Socket } from 'net';
import type Server from "../../core/server";
import {Readable} from 'stream';
// @ts-ignore
import Serializer from "xmlrpc/lib/serializer";
Expand All @@ -21,6 +22,7 @@ export class GbxClient {
showErrors: false,
throwErrors: true,
};
timeoutHandler:any;
promiseCallbacks: { [key: string]: any } = {};

/**
Expand Down Expand Up @@ -53,24 +55,39 @@ export class GbxClient {
host = host || "127.0.0.1";
port = port || 5000;
const that = this;
this.socket = await Bun.connect({
hostname: host,
const socket = new Socket();
const timeout = 5000;
this.socket = socket;
socket.connect({
host: host,
port: port,
socket: {
end() {
keepAlive: true,
}, () => {
socket.on("connect", () => {
clearTimeout(that.timeoutHandler);
});
socket.on("end", () => {
that.isConnected = false;
that.server.onDisconnect("end");
},
error(error: any) {
});
socket.on("error", (error: any) => {
that.isConnected = false;
that.server.onDisconnect(error.message);
},
data(socket: any, data: Buffer) {
});
socket.on("data", (data: Buffer) => {
clearTimeout(that.timeoutHandler);
that.handleData(data);
}

}
});
socket.on("timeout", () => {
tmc.cli("¤error¤XMLRPC Connection timeout");
process.exit(1);
});
});
this.timeoutHandler = setTimeout(() => {
tmc.cli("¤error¤[ERROR] Attempt at connection exceeded timeout value.");
socket.end();
process.exit(1);
}, timeout);
const res: boolean = await new Promise((resolve, reject) => {
this.promiseCallbacks['onConnect'] = {resolve, reject};
});
Expand Down
3 changes: 2 additions & 1 deletion core/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class log {
console.log(Tm2Console(str, this.ansiLevel));
}
info(str: string) {
console.log(Tm2Console(str, this.ansiLevel));
const date = new Date();
console.log(Tm2Console(`$555[${date.toISOString()}] $z` + str, this.ansiLevel));
}
warn(str: string) {
console.log(Tm2Console(str, this.ansiLevel));
Expand Down
41 changes: 41 additions & 0 deletions core/migrations/00-create-map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { DataTypes } from 'sequelize';
import type { Migration } from '../../migrate';

export const up: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().createTable('maps', {
uuid: {
type: DataTypes.STRING,
allowNull: false,
primaryKey: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
author: {
type: DataTypes.STRING,
allowNull: false
},
authorNickname: {
type: DataTypes.STRING
},
authorTime: {
type: DataTypes.INTEGER,
allowNull:false
},
environment: {
type:DataTypes.STRING
},
updatedAt: {
type: DataTypes.DATE
},
createdAt:
{
type: DataTypes.DATE
}
});
};

export const down: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().dropTable('maps');
};
36 changes: 36 additions & 0 deletions core/migrations/00-create-maplikes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { DataTypes } from 'sequelize';
import type { Migration } from '../../migrate';

export const up: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().createTable('maplikes', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey: true,
},
login: {
type: DataTypes.STRING,
allowNull: false,
},
mapUuid: {
type: DataTypes.STRING,
allowNull:false
},
vote: {
type: DataTypes.FLOAT,
allowNull: false
},
updatedAt: {
type: DataTypes.DATE
},
createdAt:
{
type: DataTypes.DATE
}
});
};

export const down: Migration = async ({ context: sequelize }) => {
await sequelize.getQueryInterface().dropTable('maplikes');
};
Loading

0 comments on commit b41374b

Please sign in to comment.