1
0

Deprecated very badly written backend server, please refer to the one in the new repo

This commit is contained in:
labalityowo
2023-05-23 22:58:36 +07:00
parent 754d8eb26b
commit 03988fbe4e
4 changed files with 1 additions and 342 deletions

View File

@ -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

View File

@ -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();

View File

@ -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"
}
}

View File

@ -1,2 +0,0 @@
@echo off
node index.js