diff options
author | Ninjune x <enderknight537@gmail.com> | 2022-11-18 18:00:58 -0600 |
---|---|---|
committer | Ninjune x <enderknight537@gmail.com> | 2022-11-18 18:00:58 -0600 |
commit | 00f4ecbc69216d4aee44bcdac92955c4eb774298 (patch) | |
tree | d012f89ffbd81dc6a9d631589764088ae2561aeb /commands/claim.js | |
parent | 03e93ce21ad426d0e3d47301fa004a41053ce23f (diff) | |
download | coleweight-00f4ecbc69216d4aee44bcdac92955c4eb774298.tar.gz coleweight-00f4ecbc69216d4aee44bcdac92955c4eb774298.tar.bz2 coleweight-00f4ecbc69216d4aee44bcdac92955c4eb774298.zip |
Diffstat (limited to 'commands/claim.js')
-rw-r--r-- | commands/claim.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/commands/claim.js b/commands/claim.js index fc0bc57..d549056 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -40,20 +40,35 @@ export function claim(structure) register('worldLoad', () => { if(!settings.claiming) return + setTimeout(() => { - console.log(constants.serverData.server) + 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) { - World.getAllPlayers().forEach((player) => { - if (player.getName() == res.data.player) - ChatLib.chat(`${PREFIX}&cThe ${res.data.structure} in this lobby is claimed by ${res.data.player}.`) + PlayerMap.filter(player => player.func_178853_c() > 0 && !player.func_178845_a().name.startsWith("!")).forEach((PlayerMP) => { + let player = PlayerMP.func_178845_a().name + + res.data.structures.forEach((structure) => { + 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. + }) }) } }) .catch(err => { - ChatLib.chat(`${PREFIX}Error: ${err}`) + if(!settings.debug) return + 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 |