From 03988fbe4ee2f2a03c2d50f417ca370b7e004ba4 Mon Sep 17 00:00:00 2001 From: labalityowo <56186498+labalityowo@users.noreply.github.com> Date: Tue, 23 May 2023 22:58:36 +0700 Subject: [PATCH] Deprecated very badly written backend server, please refer to the one in the new repo --- README.md | 1 + Webserver/index.js | 325 ----------------------------------------- Webserver/package.json | 15 -- Webserver/start.cmd | 2 - 4 files changed, 1 insertion(+), 342 deletions(-) delete mode 100644 Webserver/index.js delete mode 100644 Webserver/package.json delete mode 100644 Webserver/start.cmd diff --git a/README.md b/README.md index 66310952..da103691 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Mineplex source code dated back to 2018 3. Mineplex's custom spigot maven dependency: ``mvn install:install-file -Dfile=\path\to\Patches\craftbukkit.jar -DgroupId=com.mineplex -DartifactId=spigot -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true`` 4. MySQL 5. [Redis](https://github.com/tporadowski/redis/releases) & [Redis Desktop Manager](https://anonfiles.com/399650s1ze/RedisManager_zip) +6. [Mineplex's Backend Server](https://github.com/timing1337/MineplexMonitor) ## Working status - ✅ Arcade diff --git a/Webserver/index.js b/Webserver/index.js deleted file mode 100644 index c731ffd4..00000000 --- a/Webserver/index.js +++ /dev/null @@ -1,325 +0,0 @@ -const fastify = require('fastify')({ - logger: false -}); - -//Accounts -fastify.register(require('@fastify/mysql'), { - promise: true, - connectionString: 'mysql://root:root@localhost/account' -}) - -async function loginByName(name) { - console.log(`Geting info: ${name}`) - const connection = await fastify.mysql.getConnection() - const accountResult = await connection.query( - 'SELECT * FROM accounts WHERE name=?', [name], - ); - - const account = accountResult[0][0]; - - const accountDonor = { - Gems: account.gems, - Coins: account.coins, - SalesPackages: [], - UnknownSalesPackages: [], - Transactions: [], - CoinRewards: [] - }; - - const accountPunishmentsResult = await connection.query( - 'SELECT * FROM accountpunishments WHERE target=?', [account.name], - ); - - const accountPunishments = []; - - accountPunishmentsResult[0].forEach(punishment => { - accountPunishments.push({ - PunishmentId: punishment.id, - Admin: punishment.admin, - Sentence: punishment.sentence, - Reason: punishment.reason, - Duration: punishment.duration, - Admin: punishment.admin, - Severity: punishment.severity - }); - }); - connection.release(); - console.log(`Logging in: ${account.id} | ${account.name}`) - - const accountRankResult = await connection.query( - 'SELECT * FROM accountranks WHERE accountId=?', [account.id], - ); - - const rsp = { - AccountId: account.id, - LastLogin: new Date().getTime(), - Name: account.name, - Rank: "all", - DonorToken: accountDonor, - Time: 0, - Punishments: accountPunishments - } - const accountRank = accountRankResult[0][0]; - if(accountRank) rsp.Rank = accountRank.rankIdentifier; - return rsp; -} - - -async function loginByUuid(uuid) { - console.log(`Geting info: ${uuid}`) - const connection = await fastify.mysql.getConnection() - const accountResult = await connection.query( - 'SELECT * FROM accounts WHERE uuid=?', [uuid], - ); - - const account = accountResult[0][0]; - - const accountDonor = { - Gems: account.gems, - Coins: account.coins, - SalesPackages: [], - UnknownSalesPackages: [], - Transactions: [], - CoinRewards: [] - }; - - const accountPunishmentsResult = await connection.query( - 'SELECT * FROM accountpunishments WHERE target=?', [account.name], - ); - - const accountPunishments = []; - - accountPunishmentsResult[0].forEach(punishment => { - accountPunishments.push({ - PunishmentId: punishment.id, - Admin: punishment.admin, - Sentence: punishment.sentence, - Reason: punishment.reason, - Duration: punishment.duration, - Admin: punishment.admin, - Severity: punishment.severity - }); - }); - connection.release(); - console.log(`Logging in: ${account.id} | ${account.name}`) - - const accountRankResult = await connection.query( - 'SELECT * FROM accountranks WHERE accountId=?', [account.id], - ); - - const rsp = { - AccountId: account.id, - LastLogin: new Date().getTime(), - Name: account.name, - Rank: "all", - DonorToken: accountDonor, - Time: 0, - Punishments: accountPunishments - } - const accountRank = accountRankResult[0][0]; - if(accountRank) rsp.Rank = accountRank.rankIdentifier; - return rsp; -} - -fastify.post('/PlayerAccount/GetAccountByUUID', { - schema: { - body: { - type: 'string', - } - } -}, async (request, reply) => await loginByUuid(request.body)); - -fastify.post('/PlayerAccount/GetAccount', { - schema: { - body: { - type: 'string', - } - } -}, async (request, reply) => await loginByName(request.body)); - -fastify.post('/PlayerAccount/Login', { - schema: { - body: { - type: 'object', - properties: { - MacAddress: { type: 'string' }, - IpAddress: { type: 'string' }, - Name: { type: 'string' }, - Uuid: { type: 'string' }, - } - } - } -}, - async (request, reply) => await loginByUuid(request.body.Uuid)); - -fastify.post('/PlayerAccount/Punish', { - schema: { - body: { - type: 'object', - properties: { - Target: { type: 'string' }, - Category: { type: 'string' }, - Sentence: { type: 'string' }, - Reason: { type: 'string' }, - Duration: { type: 'integer' }, - Admin: { type: 'string' }, - Severity: { type: 'integer' }, - } - } - } -}, async (request, reply) => { - const connection = await fastify.mysql.getConnection() - const punishment = request.body; - connection.query('INSERT INTO accountpunishments(target, category, sentence, reason, duration, admin, severity) VALUES ("' + punishment.Target + '", "' + punishment.Category + '", "' + punishment.Sentence + '", "' + punishment.Reason + '", "' + punishment.Duration + '", "' + punishment.Admin + '", "' + punishment.Severity + '")'); - connection.release(); - return 'Punished'; //I'm lazy af lmao -}); - - -fastify.post('/PlayerAccount/RemovePunishment', { - schema: { - body: { - type: 'object', - properties: { - PunishmentId: { type: 'integer' }, - Target: { type: 'string' }, - Reason: { type: 'string' }, - Admin: { type: 'string' }, - } - } - } -}, async (request, reply) => { - console.log("RemovePunishment called") - console.log(request.body) -}); - -fastify.post('/PlayerAccount/GemReward', { - schema: { - body: { - type: 'object', - properties: { - Source: { type: 'string' }, - Name: { type: 'string' }, - Amount: { type: 'integer' }, - } - } - } -}, async (request, reply) => { - console.log("GemReward called") - console.log(request.body) -}); - -fastify.post('/PlayerAccount/CoinReward', { - schema: { - body: { - type: 'object', - properties: { - Source: { type: 'string' }, - Name: { type: 'string' }, - Amount: { type: 'integer' }, - } - } - } -}, async (request, reply) => { - console.log("CoinReward called") - console.log(request.body) -}); - -fastify.post('/PlayerAccount/PurchaseKnownSalesPackage', { - schema: { - body: { - type: 'object', - properties: { - AccountName: { type: 'string' }, - UsingCredits: { type: 'boolean' }, - SalesPackageId: { type: 'integer' }, - } - } - } -}, async (request, reply) => { - console.log("CoinReward called") - console.log(request.body) -}); - -//Dummy -fastify.post('/Dominate/GetSkills', async (request, reply) => { - return []; -}); - -fastify.get('/Dominate/GetSkills', async (request, reply) => { - return []; -}); - -fastify.post('/PlayerAccount/GetPunishClient', { - schema: { - body: { - type: 'string' - } - } -}, async (request, reply) => { - const connection = await fastify.mysql.getConnection() - const name = request.body; - const accountPunishmentsResult = await connection.query( - 'SELECT * FROM accountpunishments WHERE target=?', [name], - ); - const accountPunishments = []; - accountPunishmentsResult[0].forEach(punishment => { - accountPunishments.push({ - PunishmentId: punishment.id, - Admin: punishment.admin, - Sentence: punishment.sentence, - Reason: punishment.reason, - Duration: punishment.duration, - Admin: punishment.admin, - Severity: punishment.severity - }); - }); - connection.release(); - return { - Name: name, - Time: 0, - Punishments: accountPunishments - }; -}); - -fastify.post('/PlayerAccount/purchaseUnknownSalesPackage', { - schema: { - body: { - type: 'object', - properties: { - AccountName: { type: 'string' }, - SalesPackageName: { type: 'string' }, - CoinPurchase: { type: 'string' }, - Cost: { type: 'integer' }, - Premium: { type: 'boolean' }, - } - } - } -}, async (request, reply) => { - console.log("CoinReward called") - console.log(request.body) -}); - - -//Booster for arcade group -fastify.get('/arcade', async (request, reply) => { - console.log("Getting boosters called") - return []; //No booster for u haha -}); - -fastify.get('/booster', async (request, reply) => { - console.log("Getting boosters called") - return []; //No booster for u haha -}); - - -//Run the server! -const start = async () => { - try { - await fastify.listen(1000) - } catch (err) { - fastify.log.error(err) - process.exit(1) - } -} -start(); \ No newline at end of file diff --git a/Webserver/package.json b/Webserver/package.json deleted file mode 100644 index e78e2f61..00000000 --- a/Webserver/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "mineplex-node", - "version": "1.0.0", - "description": "Replacement for mineplex server", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "labalityowo", - "license": "ISC", - "dependencies": { - "@fastify/mysql": "^4.1.0", - "fastify": "^4.17.0" - } -} diff --git a/Webserver/start.cmd b/Webserver/start.cmd deleted file mode 100644 index ccf74237..00000000 --- a/Webserver/start.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -node index.js \ No newline at end of file