-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 21 | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
- name: Build with Gradle | ||
run: ./gradlew build | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: build/libs/*.jar | ||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: build/libs/*.jar | ||
generate_release_notes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
The MIT License (MIT) | ||
===================== | ||
|
||
Copyright © 2024 Uni0305 | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the “Software”), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# OraxenExtras | ||
|
||
[![GitHub License](https://img.shields.io/github/license/Uni0305/OraxenExtras?style=for-the-badge)](LICENSE.md) | ||
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Uni0305/OraxenExtras/build.yml?style=for-the-badge)](https://github.com/Uni0305/OraxenExtras/actions) | ||
[![GitHub Release](https://img.shields.io/github/v/release/Uni0305/OraxenExtras?style=for-the-badge)](https://github.com/Uni0305/OraxenExtras/releases) | ||
|
||
A plugin that adds extra features to Oraxen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package me.uni0305.oraxen | ||
|
||
import io.th0rgal.oraxen.api.OraxenPack | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.command.defaults.BukkitCommand | ||
import org.bukkit.plugin.java.JavaPlugin | ||
|
||
class OraxenExtrasCommand(private val plugin: JavaPlugin) : BukkitCommand("oraxen-extras") { | ||
init { | ||
this.permission = "op" | ||
plugin.server.commandMap.register("uni0305", this) | ||
} | ||
|
||
override fun execute(sender: CommandSender, label: String, args: Array<String>): Boolean { | ||
if (args.isEmpty()) { | ||
sender.sendRichMessage("<yellow>Usage: <white>/$label reload") | ||
sender.sendRichMessage("<yellow>Usage: <white>/$label pack <reload|upload>") | ||
return true | ||
} | ||
|
||
when (args[0].lowercase()) { | ||
"reload" -> { | ||
plugin.saveDefaultConfig() | ||
plugin.reloadConfig() | ||
sender.sendRichMessage("<gold>Configuration reloaded.") | ||
return true | ||
} | ||
"pack" -> { | ||
if (args.size < 2) { | ||
sender.sendRichMessage("<yellow>Usage: <white>/$label pack <reload|upload>") | ||
return false | ||
} | ||
|
||
when (args[1].lowercase()) { | ||
"reload" -> { | ||
OraxenExtrasPlugin.externalPackImportService.importPacks() | ||
OraxenPack.reloadPack() | ||
sender.sendRichMessage("<gold>Reloaded Oraxen pack.") | ||
return true | ||
} | ||
"upload" -> { | ||
OraxenPack.uploadPack() | ||
sender.sendRichMessage("<gold>Uploaded Oraxen pack.") | ||
return true | ||
} | ||
else -> { | ||
sender.sendRichMessage("<red>Unknown subcommand: ${args[1]}") | ||
return false | ||
} | ||
} | ||
} | ||
else -> { | ||
sender.sendRichMessage("<red>Unknown subcommand: ${args[0]}") | ||
return false | ||
} | ||
} | ||
} | ||
|
||
override fun tabComplete(sender: CommandSender, label: String, args: Array<String>): List<String> { | ||
return if (args.size <= 1 || args[0].isEmpty()) listOf("reload", "pack") | ||
else if (args.size == 2 && args[0].lowercase() == "pack") listOf("reload", "upload") | ||
else emptyList() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
package me.uni0305.oraxen | ||
|
||
import me.uni0305.oraxen.config.ExternalPackImportConfig | ||
import me.uni0305.oraxen.service.ExternalPackImportService | ||
import org.bukkit.plugin.java.JavaPlugin | ||
|
||
class OraxenExtrasPlugin : JavaPlugin() | ||
class OraxenExtrasPlugin : JavaPlugin() { | ||
companion object { | ||
lateinit var externalPackImportService: ExternalPackImportService private set | ||
} | ||
|
||
override fun onEnable() { | ||
saveDefaultConfig() | ||
reloadConfig() | ||
|
||
val externalPackImportConfig = ExternalPackImportConfig(config) | ||
externalPackImportService = ExternalPackImportService(externalPackImportConfig) | ||
OraxenExtrasCommand(this) | ||
} | ||
|
||
override fun onDisable() { | ||
saveConfig() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/me/uni0305/oraxen/config/ExternalPackImportConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package me.uni0305.oraxen.config | ||
|
||
import org.bukkit.Bukkit | ||
import org.bukkit.configuration.file.FileConfiguration | ||
import java.io.File | ||
|
||
class ExternalPackImportConfig(private val config: FileConfiguration) { | ||
companion object { | ||
private const val SECTION_PATH = "import-external-packs" | ||
} | ||
|
||
fun isEnabled() = config.getBoolean("$SECTION_PATH.enabled", false) | ||
|
||
fun getPacks(): List<File> = config.getStringList("$SECTION_PATH.packs") | ||
.map { File(Bukkit.getServer().pluginsFolder, it).resolve("assets") } | ||
.filter { it.exists() } | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/me/uni0305/oraxen/service/ExternalPackImportService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.uni0305.oraxen.service | ||
|
||
import io.th0rgal.oraxen.api.OraxenPack | ||
import me.uni0305.oraxen.config.ExternalPackImportConfig | ||
import org.slf4j.LoggerFactory | ||
|
||
class ExternalPackImportService(private val config: ExternalPackImportConfig) { | ||
private val logger = LoggerFactory.getLogger(this.javaClass) | ||
|
||
fun getPacks() = if (config.isEnabled()) config.getPacks() else emptyList() | ||
|
||
fun importPacks() { | ||
if (!config.isEnabled()) { | ||
logger.warn("External pack import is disabled") | ||
return | ||
} | ||
|
||
val packs = config.getPacks() | ||
if (packs.isEmpty()) { | ||
logger.warn("No external packs to import") | ||
return | ||
} | ||
|
||
try { | ||
OraxenPack.addFilesToPack(packs.toTypedArray()) | ||
logger.info("Imported ${packs.size} external packs") | ||
} catch (e: Exception) { | ||
logger.error("Failed to import external packs", e) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import-external-packs: | ||
enabled: false | ||
packs: | ||
- ModelEngine/resource pack |