1
0

removed fallback game, webserver update(...someone rewrite this please im begging)

This commit is contained in:
labalityowo
2023-05-20 13:50:18 +07:00
parent 602b171dbb
commit 4822d26372
3 changed files with 88 additions and 75 deletions

View File

@ -342,6 +342,8 @@ public class CoreClientManager extends MiniPlugin
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
System.out.println(response);
if (client.getAccountId() > 0)
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
@ -422,6 +424,7 @@ public class CoreClientManager extends MiniPlugin
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
System.out.println(response);
if (client.getAccountId() > 0)
{
@ -502,6 +505,7 @@ public class CoreClientManager extends MiniPlugin
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
System.out.println(response);
if (client.getAccountId() > 0)
{
@ -595,6 +599,7 @@ public class CoreClientManager extends MiniPlugin
TimingManager.start(client.getName() + " Event.");
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
System.out.println(response);
TimingManager.stop(client.getName() + " Event.");
TimingManager.stop(client.getName() + " LoadClient Total.");

View File

@ -8,7 +8,7 @@ import java.util.Set;
import mineplex.serverdata.Region;
public class ServerGroup
public class ServerGroup
{
private HashMap<String, String> _dataMap = null;
@ -92,7 +92,7 @@ public class ServerGroup
_tournament = Boolean.valueOf(data.get("tournament"));
_tournamentPoints = Boolean.valueOf(data.get("tournamentPoints"));
_hardMaxPlayerCap = Boolean.valueOf(data.get("hardMaxPlayerCap"));
_games = data.getOrDefault("games", "Smash");
_games = data.get("games");
_modes = data.get("modes");
_boosterGroup = data.get("boosterGroup");
_serverType = data.getOrDefault("serverType", "dedicated");

View File

@ -8,24 +8,14 @@ fastify.register(require('fastify-mysql'), {
connectionString: 'mysql://root:root@localhost/account'
})
fastify.post('/PlayerAccount/GetAccountByUUID', {
schema: {
body: {
type: 'string',
}
}
}, async (request, reply) => {
async function loginByName(name) {
console.log(`Geting info: ${name}`)
const connection = await fastify.mysql.getConnection()
const accountResult = await connection.query(
'SELECT * FROM accounts WHERE uuid=?', [request.body],
'SELECT * FROM accounts WHERE name=?', [name],
);
const account = accountResult[0][0];
const accountRankResult = await connection.query(
'SELECT * FROM accountranks WHERE accountId=?', [account.id],
);
const accountRank = accountRankResult[0][0];
const accountDonor = {
Gems: account.gems,
@ -55,17 +45,89 @@ fastify.post('/PlayerAccount/GetAccountByUUID', {
});
connection.release();
console.log(`Logging in: ${account.id} | ${account.name}`)
//Punishment
return {
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: accountRank.rankIdentifier,
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: {
@ -73,8 +135,7 @@ fastify.post('/PlayerAccount/GetAccount', {
type: 'string',
}
}
}, async (request, reply) => {
});
}, async (request, reply) => await loginByName(request.body));
fastify.post('/PlayerAccount/Login', {
schema: {
@ -89,60 +150,7 @@ fastify.post('/PlayerAccount/Login', {
}
}
},
async (request, reply) => {
const connection = await fastify.mysql.getConnection()
const loginToken = request.body;
const accountResult = await connection.query(
'SELECT * FROM accounts WHERE uuid=?', [loginToken.Uuid],
);
const account = accountResult[0][0];
const accountRankResult = await connection.query(
'SELECT * FROM accountranks WHERE accountId=?', [account.id],
);
const accountRank = accountRankResult[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}`)
//Punishment
return {
AccountId: account.id,
LastLogin: new Date().getTime(),
Name: account.name,
Rank: accountRank.rankIdentifier,
DonorToken: accountDonor,
Time: 0,
Punishments: accountPunishments
};
});
async (request, reply) => await loginByUuid(request.body.Uuid));
fastify.post('/PlayerAccount/Punish', {
schema: {