Skip to content

Commit

Permalink
🎄- Beta 2, merry christmas!
Browse files Browse the repository at this point in the history
  • Loading branch information
ixnoahlive committed Dec 25, 2023
1 parent cb3c1fc commit 95e4df4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Add functions, ChatTriggers modules & more! It's an all-in-one Housing importer!
| Command | Purpose
| -------------------- | ------------------------------------------------------
| `/hpm` | Opens a list of all commands
| `/hpm add <package>` | Adds a package from the HPM Action Library, these are curated heavily
| ~~`/hpm add <package>`~~ | ~~Adds a package from the HPM Action Library, these are curated heavily~~
| `/hpm atlas` | Browse the mod atlas to manage your mods!
| `/hpm import <mod>` | Checks the mod atlas and downloads the mod if it's on there
| `/hpm reload` | Fetches the updated version of the mod link atlas (you won't need this, unless imports break)

Expand Down
19 changes: 15 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { installModule } from './src/modImporter';
import axios from './modules/axios';
import { formatAtlasToChat } from './src/modExplorer';
import { viewModReleases } from './src/modReleases';

const helpMessage = new Message([
'\n',
'&7&lâ–  HPM Commands\n',
'&7 | &e/hpm reload &8- &7Reload HPM\'s atlas to check for new mods\n',
'&7 | &e/hpm import &8- &7Import a ChatTriggers module from our atlas\n',
'&7 | &e&m/hpm install&8 -&7 &mInstall a HPM Package from our Action Library\n',
''
'&7 | &e/hpm atlas&8 - &7Manage your HPM Atlas modules\n',
'&7 | &e/hpm import&8 - &7Import a HPM Atlas module\n',
'&7 | &e/hpm delete&8 - &7Delete a HPM Atlas module\n',
'&7 | &e&m/hpm package&8 - &7&mImport an Action Package\n'
])

let atlas = { loaded: false };
Expand Down Expand Up @@ -35,11 +37,20 @@ register('command', (subcommand, ...args) => {
case 'import':
installModule(atlas, args[0]?.toLowerCase() || undefined)
break;
case 'atlas':
if (!args[0]) return formatAtlasToChat(atlas)
viewModReleases(atlas, args[0])
break;
case 'reload':
ChatLib.chat('&cReloading HPM...')
initialise(true)
break;
case 'delete':
if (args[0]=="hpm") return ChatLib.chat(new Message([
new TextComponent("\n&cAre you sure you want to delete HPM? You'll lose out on critical patches, easy installing of modules & more!\n"),
new TextComponent('&c&lDELETE HPM\n').setHover('show_text','&cDelete HPM').setClick('run_command','/ct delete hpm')
]))

ChatLib.command(`ct delete ${...args}`)
break;
default:
Expand Down
37 changes: 37 additions & 0 deletions src/modExplorer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export function formatAtlasToChat(atlas) {
if (!atlas.loaded) return ChatLib.chat('&cHPM Atlas hasn\'t loaded yet! Please wait!')
delete atlas.loaded // Fucks with iteration, gtfo

let components = []
components.push('\n&7&lâ–  Module Atlas\n')

Object.values(atlas).forEach(moduleData => {
components.push(`&7 | `)

if (FileLib.exists(`./config/ChatTriggers/modules/${moduleData.name}`)) {
components.push(
new TextComponent('&c&lx ')
.setHover('show_text','&cDelete Module')
.setClick('run_command',`/hpm delete ${moduleData.name}`),
new TextComponent('&a&l+ ')
.setHover('show_text','&aCheck for Updates')
.setClick('run_command',`/hpm import ${moduleData.name}`),
)
} else {
components.push(
new TextComponent('&8&lx ').setHover('show_text', '&7&mDelete Module'),
new TextComponent('&a&l+ ')
.setHover('show_text', '&aImport Module')
.setClick('run_command', `/hpm import ${moduleData.name}`)
)
}
components.push(
new TextComponent(`&7| &b${moduleData.name}\n`) // kill me
.setHover('show_text', `&a${moduleData.name}\n&7by &b${moduleData.creator}\n\n&eClick to view ${Object.keys(moduleData.releases).length} release${Object.keys(moduleData.releases).length == 1 ? '' : 's'}!`)
.setClick('run_command',`/hpm atlas ${moduleData.name}`)
)
})

ChatLib.chat(new Message(components).setChatLineId(694201337))
atlas.loaded = true
}
2 changes: 1 addition & 1 deletion src/modImporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function installModule(atlas, moduleName) {
moduleName = moduleName.split(':')
if (!atlas[moduleName[0]]) return ChatLib.chat('&cThis module doesn\'t exist!')

let release = atlas[moduleName].releases[moduleName[1] || '$main'] // Multi version support
let release = atlas[moduleName].releases[moduleName[1] || '$default'] // Multi version support

const tempId = Date.now()
FileUtilities.urlToFile(release.url, `./config/ChatTriggers/modules/hpm-temp-${tempId}.zip`, 5000, 5000)
Expand Down
29 changes: 29 additions & 0 deletions src/modReleases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export function viewModReleases(atlas, moduleName) {
if (!atlas.loaded) return ChatLib.chat('&cHPM Atlas hasn\'t loaded yet! Please wait!')
if (!moduleName) return ChatLib.chat('&cPlease input a module name!')

moduleName = moduleName.split(':')[0].toLowerCase()
const moduleData = atlas[moduleName]

if (!moduleData) return ChatLib.chat('&cThis module doesn\'t exist!')

let components = [
new TextComponent('\n&7 ✖').setClick('run_command','/hpm atlas').setHover('show_text','&7Click to return to the atlas!'),
` &7&l${moduleData.name}\n`,
`&7 | Created by: ${moduleData.creator}\n`,
]

Object.keys(moduleData.releases).forEach(releaseName => {
const releaseData = moduleData.releases[releaseName]

components.push('&7 | ')
components.push(
new TextComponent('&a&l+')
.setClick('run_command',`/hpm import ${moduleName}:${releaseName}`)
.setHover('show_text', `&aImport ${moduleName}:${releaseName}`)
)
components.push(` &7| &b${releaseName} ${releaseData.unstable ? '&6(Unstable)' : ''}\n`)
})

ChatLib.chat(new Message(components).setChatLineId(694201337))
}

0 comments on commit 95e4df4

Please sign in to comment.