diff options
author | Ninjune <enderknight537@gmail.com> | 2022-11-23 11:50:54 -0600 |
---|---|---|
committer | Ninjune <enderknight537@gmail.com> | 2022-11-23 11:50:54 -0600 |
commit | 9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20 (patch) | |
tree | 56837d423243990da63152d0e9c119189f1d121b /commands/claim.js | |
parent | 5e76b8b00ac668768f5295ac4b2cb7c79c71ee36 (diff) | |
download | coleweight-9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20.tar.gz coleweight-9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20.tar.bz2 coleweight-9bb7bf0b2f4dbc9269b0e5fa446d8480b814fe20.zip |
v1.6.4 forgot to push lmao
Diffstat (limited to 'commands/claim.js')
-rw-r--r-- | commands/claim.js | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/commands/claim.js b/commands/claim.js index cb691f3..5abeda8 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -2,7 +2,7 @@ import axios from "../../axios" import settings from "../settings" import constants from "../util/constants" const PREFIX = constants.PREFIX - +const serverId = java.util.UUID.randomUUID().toString().replace("-", "") export function claim(structure) { @@ -23,33 +23,59 @@ export function claim(structure) ChatLib.chat(`${PREFIX}&cPlease enter the structure you wish to claim! (&3throne&c or &3spiral&c)`) return } - - axios.get(`https://ninjune.dev/api/claim?type=${structure}&id=${constants.serverData.server}&key=${constants.data.api_key}`) + + axios.get(`https://ninjune.dev/api/claim?type=${structure}&lobby=${constants.serverData.server}&method=auth&username=${Player.getName()}&serverID=${serverId}`) .then(res => { if(res.data.success) ChatLib.chat(`${PREFIX}&aSuccessfully claimed ${constants.serverData.server} as your server!`) else - ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}`) + { + ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}.`) + if(res.data.code == 501) + { + ChatLib.chat(`${PREFIX}&cError: Not logged into the auth server. Try running the command again.`) + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) + } + } }) .catch(err => { ChatLib.chat(`${PREFIX}&cError: ${err}`) }) - // key is used above to verify that the player trying to claim the lobby is the intended player, don't know a better way of doing this. + } +register('gameLoad', (event) => { + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) +}) register('worldLoad', () => { if(!settings.claiming) return + axios.get(`https://ninjune.dev/api/unclaim?method=auth&username=${Player.getName()}&serverID=${serverId}`) + .then(res => { + if(settings.debug && !res.data.success) + ChatLib.chat("Unclaim: " + res.data.reason) + if(res.data.code == 501) + Client.getMinecraft().func_152347_ac().joinServer(Client.getMinecraft().func_110432_I().func_148256_e(), Client.getMinecraft().func_110432_I().func_148254_d(), serverId) + }) + .catch(err => { + if(settings.debug) + ChatLib.chat(`${PREFIX}&cError: ${err}`) + }) + // unclaims the lobby, isn't needed but will allow another player to claim lobby after claimer leaves. setTimeout(() => { + const NetHandlerPlayClient = Client.getConnection(), + PlayerMap = NetHandlerPlayClient.func_175106_d() // getPlayerInfoMap + if(settings.debug) console.log(constants.serverData.server) axios.get(`https://ninjune.dev/api/claim?claimedlobby=${constants.serverData.server}`) .then(res => { if(res.data.claimed) { - ChatLib.chat("here") - World.getAllPlayers().forEach((player) => { + PlayerMap.filter(player => player.func_178853_c() /* getResponseTime */ > 0 && !player.func_178845_a()/* getGameProfile */.name.startsWith("!")).forEach((PlayerMP) => { + let player = PlayerMP.func_178845_a()/* getGameProfile */.name + res.data.structures.forEach((structure) => { - if (player.getName() == structure.player) + if (player == structure.player) ChatLib.chat(`${PREFIX}&cThe ${structure.structure} in ${structure.server} is claimed by ${structure.player}.`) //holy im so good at naming things, structure.structure I must be a genius. }) @@ -61,9 +87,4 @@ register('worldLoad', () => { ChatLib.chat(`${PREFIX}&cError: ${err}`) }) }, 2000) -}) - -register('worldUnload', () => { - axios.get(`https://ninjune.dev/api/unclaim?claimedlobby=${constants.serverData.server}&key=${constants.data.api_key}`) - // unclaims the lobby, isn't needed but will allow another player to claim lobby after claimer leaves. key used to verify identity of unclaimer. })
\ No newline at end of file |