Skip to content

Commit

Permalink
Merge branch 'nova-features'
Browse files Browse the repository at this point in the history
  • Loading branch information
NichtStudioCode committed Oct 7, 2023
2 parents bf9b012 + 28f3f6d commit ada57b1
Show file tree
Hide file tree
Showing 104 changed files with 803 additions and 786 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build-addons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
arguments: |
jetpacks:addonJar
-PoutDir=../artifacts/
-PxenondevsNms
env:
ORG_GRADLE_PROJECT_xenondevsNmsUsername: ${{ secrets.XENONDEVS_NMS_USERNAME }}
ORG_GRADLE_PROJECT_xenondevsNmsPassword: ${{ secrets.XENONDEVS_NMS_PASSWORD }}
Expand Down Expand Up @@ -68,7 +67,6 @@ jobs:
arguments: |
logistics:addonJar
-PoutDir=../artifacts/
-PxenondevsNms
env:
ORG_GRADLE_PROJECT_xenondevsNmsUsername: ${{ secrets.XENONDEVS_NMS_USERNAME }}
ORG_GRADLE_PROJECT_xenondevsNmsPassword: ${{ secrets.XENONDEVS_NMS_PASSWORD }}
Expand Down Expand Up @@ -104,7 +102,6 @@ jobs:
arguments: |
machines:addonJar
-PoutDir=../artifacts/
-PxenondevsNms
env:
ORG_GRADLE_PROJECT_xenondevsNmsUsername: ${{ secrets.XENONDEVS_NMS_USERNAME }}
ORG_GRADLE_PROJECT_xenondevsNmsPassword: ${{ secrets.XENONDEVS_NMS_PASSWORD }}
Expand Down Expand Up @@ -140,7 +137,6 @@ jobs:
arguments: |
simple-upgrades:addonJar
-PoutDir=../artifacts/
-PxenondevsNms
env:
ORG_GRADLE_PROJECT_xenondevsNmsUsername: ${{ secrets.XENONDEVS_NMS_USERNAME }}
ORG_GRADLE_PROJECT_xenondevsNmsPassword: ${{ secrets.XENONDEVS_NMS_PASSWORD }}
Expand Down Expand Up @@ -176,7 +172,6 @@ jobs:
arguments: |
vanilla-hammers:addonJar
-PoutDir=../artifacts/
-PxenondevsNms
env:
ORG_GRADLE_PROJECT_xenondevsNmsUsername: ${{ secrets.XENONDEVS_NMS_USERNAME }}
ORG_GRADLE_PROJECT_xenondevsNmsPassword: ${{ secrets.XENONDEVS_NMS_PASSWORD }}
Expand Down
75 changes: 38 additions & 37 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import xyz.xenondevs.stringremapper.StringRemapExtension

group = "xyz.xenondevs.nova.addon"

val mojangMapped = project.hasProperty("mojang-mapped")

plugins {
alias(libs.plugins.paperweight)
alias(libs.plugins.kotlin)
alias(libs.plugins.nova)
alias(libs.plugins.specialsource)
alias(libs.plugins.stringremapper)
}

repositories { configureRepositories() }
dependencies { configureDependencies() }

fun RepositoryHandler.configureRepositories() {
mavenLocal { content { includeGroup("org.spigotmc") } }
mavenLocal { content { includeGroupAndSubgroups("xyz.xenondevs") } }
mavenCentral()
maven("https://repo.xenondevs.xyz/releases")
maven("https://libraries.minecraft.net")

// include xenondevs-nms repository if requested
if (project.hasProperty("xenondevsNms")) {
maven("https://repo.papermc.io/repository/maven-public/") // authlib, brigadier, etc.
maven {
name = "xenondevsNms"
url = uri("https://repo.xenondevs.xyz/nms/")
credentials(PasswordCredentials::class)
}
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.xenondevs.xyz/releases/")
}

fun DependencyHandlerScope.configureDependencies() {
paperweight.paperDevBundle(rootProject.libs.versions.paper)
configurations.getByName("mojangMappedServer").apply {
exclude("org.spongepowered", "configurate-yaml")
}
implementation(rootProject.libs.nova)
}

repositories { configureRepositories() }
fun StringRemapExtension.configureRemapStrings() {
remapGoal.set(if (mojangMapped) "mojang" else "spigot")
gameVersion.set(libs.versions.paper.get().substringBefore("-"))
}

subprojects {
apply(plugin = rootProject.libs.plugins.kotlin.get().pluginId)
apply(plugin = rootProject.libs.plugins.nova.get().pluginId)
apply(plugin = rootProject.libs.plugins.specialsource.get().pluginId)
apply(plugin = rootProject.libs.plugins.paperweight.get().pluginId)
apply(plugin = rootProject.libs.plugins.stringremapper.get().pluginId)

repositories { configureRepositories() }
dependencies { configureDependencies() }
remapStrings { configureRemapStrings() }

dependencies {
implementation(rootProject.libs.nova)
}

addon {
id.set(this@subprojects.name)
name.set(this@subprojects.name.capitalized())
novaVersion.set(rootProject.libs.versions.nova)
}

spigotRemap {
spigotVersion.set(rootProject.libs.versions.spigot.map { it.substringBefore('-') })
sourceJarTask.set(tasks.jar)
}

remapStrings {
remapGoal.set(if (mojangMapped) "mojang" else "spigot")
spigotVersion.set(rootProject.libs.versions.spigot)
}


tasks {
val buildDir = project.layout.buildDirectory.get().asFile
val outDir = (project.findProperty("outDir") as? String)?.let(::File) ?: buildDir

register<Copy>("addonJar") {
group = "build"
dependsOn("addon", if (mojangMapped) "jar" else "remapObfToSpigot")

from(File(project.buildDir, "libs/${project.name}-${project.version}.jar"))
into((project.findProperty("outDir") as? String)?.let(::File) ?: project.buildDir)
rename { it.replace(project.name, addon.get().addonName.get()) }
if (mojangMapped) {
dependsOn("jar")
from(File(buildDir, "libs/${project.name}-${project.version}-dev.jar"))
} else {
dependsOn("reobfJar")
from(File(buildDir, "libs/${project.name}-${project.version}.jar"))
}

into(outDir)
rename { "${addonMetadata.get().addonName.get()}-${project.version}.jar" }
}

withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 10 additions & 6 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,26 +130,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
2 changes: 1 addition & 1 deletion jetpacks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.1.10"
version = "0.1.11-RC.1"

addon {
main.set("xyz.xenondevs.nova.addon.jetpacks.Jetpacks")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package xyz.xenondevs.nova.addon.jetpacks

import xyz.xenondevs.nova.item.NovaItem
import xyz.xenondevs.nova.addon.jetpacks.ability.JetpackFlyAbility
import xyz.xenondevs.nova.addon.jetpacks.registry.Abilities
import xyz.xenondevs.nova.addon.jetpacks.registry.Attachments
import xyz.xenondevs.nova.addon.jetpacks.registry.Items
import xyz.xenondevs.nova.item.NovaItem
import xyz.xenondevs.nova.player.ability.AbilityType
import xyz.xenondevs.nova.player.attachment.AttachmentType

enum class JetpackTier(
lazyAbilityType: () -> AbilityType<JetpackFlyAbility>,
lazyAttachmentType: () -> AttachmentType<*>,
lazyMaterials: () -> List<NovaItem>
lazyItems: () -> List<NovaItem>
) {

BASIC({ Abilities.BASIC_JETPACK_FLY }, { Attachments.BASIC_JETPACK }, { listOf(Items.BASIC_JETPACK, Items.ARMORED_BASIC_JETPACK) }),
ADVANCED({ Abilities.ADVANCED_JETPACK_FLY }, { Attachments.ADVANCED_JETPACK }, { listOf(Items.ADVANCED_JETPACK, Items.ARMORED_BASIC_JETPACK) }),
ADVANCED({ Abilities.ADVANCED_JETPACK_FLY }, { Attachments.ADVANCED_JETPACK }, { listOf(Items.ADVANCED_JETPACK, Items.ARMORED_ADVANCED_JETPACK) }),
ELITE({ Abilities.ELITE_JETPACK_FLY }, { Attachments.ELITE_JETPACK }, { listOf(Items.ELITE_JETPACK, Items.ARMORED_ELITE_JETPACK) }),
ULTIMATE({ Abilities.ULTIMATE_JETPACK_FLY }, { Attachments.ULTIMATE_JETPACK }, { listOf(Items.ULTIMATE_JETPACK, Items.ARMORED_ULTIMATE_JETPACK) });

val abilityType by lazy(lazyAbilityType)
val attachmentType by lazy(lazyAttachmentType)
val materials by lazy(lazyMaterials)
val items by lazy(lazyItems)

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import org.bukkit.Sound
import org.bukkit.entity.Player
import xyz.xenondevs.commons.provider.Provider
import xyz.xenondevs.nmsutils.particle.ParticleBuilder
import xyz.xenondevs.nova.data.config.NovaConfig
import xyz.xenondevs.nova.data.config.configReloadable
import xyz.xenondevs.nova.item.behavior.Chargeable
import xyz.xenondevs.nova.addon.jetpacks.ui.JetpackOverlay
import xyz.xenondevs.nova.data.config.Configs
import xyz.xenondevs.nova.data.config.entry
import xyz.xenondevs.nova.item.behavior.Chargeable
import xyz.xenondevs.nova.player.ability.Ability
import xyz.xenondevs.nova.player.ability.AbilityManager
import xyz.xenondevs.nova.ui.overlay.actionbar.ActionbarOverlayManager
Expand All @@ -19,10 +19,7 @@ import xyz.xenondevs.nova.util.broadcast
import xyz.xenondevs.nova.util.item.novaItem
import xyz.xenondevs.nova.util.serverTick

private val IGNORED_GAME_MODES by configReloadable {
val modesRaw = NovaConfig["jetpacks:config"].getStringList("ignored_game_modes")
GameMode.values().filter { gameMode -> modesRaw.any { it.equals(gameMode.name, ignoreCase = true) } }
}
private val IGNORED_GAME_MODES by Configs["jetpacks:config"].entry<Set<GameMode>>("ignored_game_modes")

class JetpackFlyAbility(player: Player, flySpeed: Provider<Float>, energyPerTick: Provider<Long>) : Ability(player) {

Expand All @@ -34,7 +31,7 @@ class JetpackFlyAbility(player: Player, flySpeed: Provider<Float>, energyPerTick
private val previousFlySpeed = player.flySpeed

private val overlay = JetpackOverlay()
private val jetpackItem by lazy { player.equipment?.chestplate }
private val jetpackItem by lazy { player.equipment.chestplate }
private val novaItem by lazy { jetpackItem?.novaItem }

init {
Expand Down Expand Up @@ -70,9 +67,9 @@ class JetpackFlyAbility(player: Player, flySpeed: Provider<Float>, energyPerTick
player.flySpeed = previousFlySpeed
}

val chargeable = novaItem.getBehavior(Chargeable::class)!!
val chargeable = novaItem.getBehavior(Chargeable::class)
val energyLeft = chargeable.getEnergy(jetpackItem)
overlay.percentage = energyLeft / chargeable.options.maxEnergy.toDouble()
overlay.percentage = energyLeft / chargeable.maxEnergy.toDouble()

if (energyLeft > energyPerTick || !isValidGameMode()) {
if (player.isFlying) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package xyz.xenondevs.nova.addon.jetpacks.item

import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import xyz.xenondevs.nova.item.behavior.ItemBehavior
import xyz.xenondevs.nova.addon.jetpacks.JetpackTier
import xyz.xenondevs.nova.item.behavior.ItemBehavior
import xyz.xenondevs.nova.player.ability.AbilityManager
import xyz.xenondevs.nova.player.attachment.AttachmentManager
import xyz.xenondevs.nova.player.equipment.ArmorEquipEvent

class JetpackBehavior(
private val tier: JetpackTier
) : ItemBehavior() {
) : ItemBehavior {

override fun handleEquip(player: Player, itemStack: ItemStack, equipped: Boolean, event: ArmorEquipEvent) {
if (equipped) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package xyz.xenondevs.nova.addon.jetpacks.registry

import xyz.xenondevs.nova.addon.registry.AbilityTypeRegistry
import xyz.xenondevs.nova.data.config.NovaConfig
import xyz.xenondevs.nova.data.config.configReloadable
import xyz.xenondevs.nova.initialize.Init
import xyz.xenondevs.nova.addon.jetpacks.Jetpacks
import xyz.xenondevs.nova.addon.jetpacks.ability.JetpackFlyAbility
import xyz.xenondevs.nova.util.data.getFloat
import xyz.xenondevs.nova.addon.registry.AbilityTypeRegistry
import xyz.xenondevs.nova.data.config.entry
import xyz.xenondevs.nova.initialize.Init
import xyz.xenondevs.nova.initialize.InitStage

private val BASIC_FLY_SPEED = configReloadable { NovaConfig["jetpacks:basic_jetpack"].getFloat("fly_speed") }
private val BASIC_ENERGY_PER_TICK = configReloadable { NovaConfig["jetpacks:basic_jetpack"].getLong("energy_per_tick") }
private val ADVANCED_FLY_SPEED = configReloadable { NovaConfig["jetpacks:advanced_jetpack"].getFloat("fly_speed") }
private val ADVANCED_ENERGY_PER_TICK = configReloadable { NovaConfig["jetpacks:advanced_jetpack"].getLong("energy_per_tick") }
private val ELITE_FLY_SPEED = configReloadable { NovaConfig["jetpacks:elite_jetpack"].getFloat("fly_speed") }
private val ELITE_ENERGY_PER_TICK = configReloadable { NovaConfig["jetpacks:elite_jetpack"].getLong("energy_per_tick") }
private val ULTIMATE_FLY_SPEED = configReloadable { NovaConfig["jetpacks:ultimate_jetpack"].getFloat("fly_speed") }
private val ULTIMATE_ENERGY_PER_TICK = configReloadable { NovaConfig["jetpacks:ultimate_jetpack"].getLong("energy_per_tick") }
private val BASIC_FLY_SPEED = Items.BASIC_JETPACK.config.entry<Float>("fly_speed")
private val BASIC_ENERGY_PER_TICK = Items.BASIC_JETPACK.config.entry<Long>("energy_per_tick")
private val ADVANCED_FLY_SPEED = Items.ADVANCED_JETPACK.config.entry<Float>("fly_speed")
private val ADVANCED_ENERGY_PER_TICK = Items.ADVANCED_JETPACK.config.entry<Long>("energy_per_tick")
private val ELITE_FLY_SPEED = Items.ELITE_JETPACK.config.entry<Float>("fly_speed")
private val ELITE_ENERGY_PER_TICK = Items.ELITE_JETPACK.config.entry<Long>("energy_per_tick")
private val ULTIMATE_FLY_SPEED = Items.ULTIMATE_JETPACK.config.entry<Float>("fly_speed")
private val ULTIMATE_ENERGY_PER_TICK = Items.ULTIMATE_JETPACK.config.entry<Long>("energy_per_tick")

@Init
@Init(stage = InitStage.POST_PACK_PRE_WORLD)
object Abilities : AbilityTypeRegistry by Jetpacks.registry {

val BASIC_JETPACK_FLY = registerAbilityType("basic_jetpack_fly") { JetpackFlyAbility(it, BASIC_FLY_SPEED, BASIC_ENERGY_PER_TICK) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package xyz.xenondevs.nova.addon.jetpacks.registry

import xyz.xenondevs.nova.addon.jetpacks.Jetpacks
import xyz.xenondevs.nova.addon.registry.AttachmentTypeRegistry
import xyz.xenondevs.nova.initialize.Init
import xyz.xenondevs.nova.initialize.InitStage
import xyz.xenondevs.nova.item.NovaItem
import xyz.xenondevs.nova.addon.jetpacks.Jetpacks
import xyz.xenondevs.nova.player.attachment.AttachmentType
import xyz.xenondevs.nova.player.attachment.HideDownItemAttachment

@Init
@Init(stage = InitStage.POST_PACK_PRE_WORLD)
object Attachments : AttachmentTypeRegistry by Jetpacks.registry {

private fun registerJetpackAttachment(name: String, material: NovaItem): AttachmentType<*> =
Expand Down
Loading

0 comments on commit ada57b1

Please sign in to comment.