Skip to content

Commit

Permalink
Added other plugins and APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
toddharrison authored Feb 4, 2023
1 parent 39aa9e2 commit dcaa8fa
Show file tree
Hide file tree
Showing 340 changed files with 71,364 additions and 13 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/publish-adventure-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish adventure-api Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":adventure-api:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-adventure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish adventure Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":adventure:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-command-alias.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish command-alias Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":command-alias:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-data-source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish data-source Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":data-source:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-econ-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish econ-api Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":econ-api:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-econ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish econ Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":econ:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-gui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish gui Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":gui:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-papi-briar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish papi-briar Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":papi-briar:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-region-difficulty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish region-difficulty Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":region-difficulty:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-region-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish region-scan Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":region-scan:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
23 changes: 23 additions & 0 deletions .github/workflows/publish-return-to-wild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish return-to-wild Plugin
on: [workflow_dispatch]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Publish with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: ":return-to-wild:publish"
env:
GITHUB_TOKEN: ${{ github.token }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Ignore Gradle build output directory
build
run
run*

plugins

Expand Down
3 changes: 3 additions & 0 deletions adventure-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Adventure Plugin API

TODO
10 changes: 10 additions & 0 deletions adventure-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("briarcode.kotlin-plugin-api")
}

version = "1.1"
description = ""

dependencies {
api(project(":kotlin"))
}
24 changes: 24 additions & 0 deletions adventure-api/src/main/kotlin/com/briarcraft/adventure/api/Util.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.briarcraft.adventure.api

import org.bukkit.enchantments.Enchantment

const val BYTE_TRUE = 1.toByte()
const val BYTE_FALSE = 0.toByte()

fun registerEnchantment(enchantment: Enchantment) {
unlockEnchantmentRegistration()
Enchantment.registerEnchantment(enchantment)
}

fun registerEnchantments(vararg enchantments: Enchantment) {
unlockEnchantmentRegistration()
enchantments.forEach { enchantment -> Enchantment.registerEnchantment(enchantment) }
}

private fun unlockEnchantmentRegistration() {
if (!Enchantment.isAcceptingRegistrations()) {
val field = Enchantment::class.java.getDeclaredField("acceptingNew")
field.isAccessible = true
field.set(null, true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.briarcraft.adventure.api.enchant

import com.briarcraft.adventure.api.enchant.usage.EnchantmentUsage
import io.papermc.paper.enchantments.EnchantmentRarity
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import net.kyori.adventure.text.format.Style
import net.kyori.adventure.text.format.TextColor
import org.bukkit.NamespacedKey
import org.bukkit.enchantments.Enchantment
import org.bukkit.entity.EntityCategory
import org.bukkit.inventory.ItemStack

abstract class AbstractEnchantment(key: NamespacedKey): Enchantment(key) {
abstract val enchantName: String
abstract val displayColor: TextColor
abstract val usage: EnchantmentUsage

final override fun translationKey() = "enchant.${key.namespace}.${key.key}"

override fun isTreasure() = false
override fun isTradeable() = false
override fun isDiscoverable() = false

override fun getItemTarget() = usage.target
override fun canEnchantItem(item: ItemStack) = usage.canEnchant(item)
override fun getActiveSlots() = usage.activeSlots

override fun getRarity() = EnchantmentRarity.VERY_RARE

override fun getDamageIncrease(level: Int, entityCategory: EntityCategory) = 0.0f

final override fun getStartLevel() = 1

@Deprecated("Deprecated in Java", ReplaceWith("displayName(level)"))
final override fun getName() = enchantName

final override fun displayName(level: Int): TextComponent {
return if (level == 1 && maxLevel == 1) {
Component.text(enchantName, Style.style(displayColor))
} else if (level > 10) {
Component.text("$enchantName $level", Style.style(displayColor))
} else {
Component.text("$enchantName ", Style.style(displayColor))
.append(Component.translatable("enchantment.level.$level", Style.style(displayColor)))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.briarcraft.adventure.api.enchant

import org.bukkit.NamespacedKey
import org.bukkit.enchantments.Enchantment

abstract class BaseEnchantment(
key: NamespacedKey,
private val maxLevel: Int,
private val conflicts: Set<Enchantment>
): AbstractEnchantment(key) {
override fun getMaxLevel() = maxLevel
override fun conflictsWith(other: Enchantment) = conflicts.contains(other)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.briarcraft.adventure.api.enchant

import com.briarcraft.adventure.api.enchant.usage.EnchantmentUsage
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.format.TextColor
import org.bukkit.NamespacedKey
import org.bukkit.enchantments.Enchantment

open class BlessEnchantment(
key: NamespacedKey,
maxLevel: Int,
override val enchantName: String,
override val usage: EnchantmentUsage,
conflicts: Set<Enchantment> = setOf()
): BaseEnchantment(key, maxLevel, conflicts) {
override val displayColor: TextColor = NamedTextColor.GRAY

override fun isCursed() = false
}
Loading

0 comments on commit dcaa8fa

Please sign in to comment.