Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
969329486d | ||
|
|
aab2e8237c | ||
|
|
30457c29a1 | ||
|
|
9ad480ecf0 | ||
|
|
b0d3256d1b | ||
|
|
4ff9d82cc1 | ||
|
|
f9178e248b | ||
|
|
cc8a799438 | ||
|
|
90b81f56df | ||
|
|
1240c14c14 | ||
|
|
ed46900f2f | ||
|
|
dade3d7fbb | ||
|
|
df141875d3 | ||
|
|
50b07de5d1 | ||
|
|
e2a033c24f | ||
|
|
3fa574105f | ||
|
|
a64386f980 | ||
|
|
4c5a0f9887 | ||
|
|
cbd43f5757 | ||
|
|
01f1425557 | ||
|
|
25e8cc0837 | ||
|
|
7ff3eeef06 | ||
|
|
58faf6de23 | ||
|
|
7f42cbe32e | ||
|
|
ae12ab17fe |
42
.github/workflows/test-publish.yml
vendored
Normal file
42
.github/workflows/test-publish.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: Publish API (Dev)
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
publish-release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout latest code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set outputs
|
||||
id: vars
|
||||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
- name: Setup build cache
|
||||
uses: actions/cache@v2.1.6
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
|
||||
- name: Publish artifact
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# The GITHUB_REF tag comes in the format 'refs/tags/xxx'.
|
||||
# So if we split on '/' and take the 3rd value, we can get the release name.
|
||||
run: |
|
||||
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
|
||||
echo "New version: ${{ steps.vars.outputs.sha_short }}"
|
||||
echo "Github username: ${GITHUB_ACTOR}"
|
||||
./gradlew -Pversion=${{ steps.vars.outputs.sha_short }} publish
|
||||
@@ -1,11 +1,19 @@
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
group 'com.willfp'
|
||||
version rootProject.version
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
dependencies {
|
||||
// Kotlin
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.6.0'
|
||||
|
||||
// Adventure
|
||||
compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0'
|
||||
compileOnly 'net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT'
|
||||
@@ -17,10 +25,20 @@ dependencies {
|
||||
compileOnly 'com.google.code.gson:gson:2.8.8'
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
}
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
group 'com.willfp'
|
||||
version rootProject.version
|
||||
|
||||
build.dependsOn publishToMavenLocal
|
||||
|
||||
|
||||
18
eco-api/src/main/kotlin/com/willfp/eco/core/data/Profiles.kt
Normal file
18
eco-api/src/main/kotlin/com/willfp/eco/core/data/Profiles.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
@file:JvmName("ProfileExtensions")
|
||||
|
||||
package com.willfp.eco.core.data
|
||||
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.Server
|
||||
|
||||
/**
|
||||
* @see PlayerProfile.load
|
||||
*/
|
||||
val OfflinePlayer.profile: PlayerProfile
|
||||
get() = PlayerProfile.load(this)
|
||||
|
||||
/**
|
||||
* @see ServerProfile.load
|
||||
*/
|
||||
val Server.profile: ServerProfile
|
||||
get() = ServerProfile.load()
|
||||
@@ -0,0 +1,11 @@
|
||||
@file:JvmName("FastItemStackExtensions")
|
||||
|
||||
package com.willfp.eco.core.fast
|
||||
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
/**
|
||||
* @see FastItemStack.wrap
|
||||
*/
|
||||
fun ItemStack.fast(): FastItemStack =
|
||||
FastItemStack.wrap(this)
|
||||
@@ -0,0 +1,96 @@
|
||||
@file:JvmName("GUIHelperExtensions")
|
||||
|
||||
package com.willfp.eco.core.gui
|
||||
|
||||
import com.willfp.eco.core.gui.menu.Menu
|
||||
import com.willfp.eco.core.gui.menu.MenuBuilder
|
||||
import com.willfp.eco.core.gui.slot.Slot
|
||||
import com.willfp.eco.core.gui.slot.SlotBuilder
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.inventory.InventoryClickEvent
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
/**
|
||||
* @see SlotBuilder.onLeftClick
|
||||
*/
|
||||
fun SlotBuilder.onLeftClick(action: (InventoryClickEvent, Slot, Menu) -> Unit): SlotBuilder =
|
||||
this.onLeftClick { a, b, c -> action(a, b, c) }
|
||||
|
||||
/**
|
||||
* @see SlotBuilder.onRightClick
|
||||
*/
|
||||
fun SlotBuilder.onRightClick(action: (InventoryClickEvent, Slot, Menu) -> Unit): SlotBuilder =
|
||||
this.onRightClick { a, b, c -> action(a, b, c) }
|
||||
|
||||
/**
|
||||
* @see SlotBuilder.onShiftLeftClick
|
||||
*/
|
||||
fun SlotBuilder.onShiftLeftClick(action: (InventoryClickEvent, Slot, Menu) -> Unit): SlotBuilder =
|
||||
this.onShiftLeftClick { a, b, c -> action(a, b, c) }
|
||||
|
||||
/**
|
||||
* @see SlotBuilder.onShiftRightClick
|
||||
*/
|
||||
fun SlotBuilder.onShiftRightClick(action: (InventoryClickEvent, Slot, Menu) -> Unit): SlotBuilder =
|
||||
this.onShiftRightClick { a, b, c -> action(a, b, c) }
|
||||
|
||||
/**
|
||||
* @see SlotBuilder.onShiftRightClick
|
||||
*/
|
||||
fun SlotBuilder.onMiddleClick(action: (InventoryClickEvent, Slot, Menu) -> Unit): SlotBuilder =
|
||||
this.onMiddleClick { a, b, c -> action(a, b, c) }
|
||||
|
||||
/**
|
||||
* @see SlotBuilder.setModifier
|
||||
*/
|
||||
fun SlotBuilder.setModifier(action: (Player, Menu, ItemStack) -> Unit): SlotBuilder =
|
||||
this.setModifier { a, b, c -> action(a, b, c) }
|
||||
|
||||
/**
|
||||
* Kotlin builder for slots.
|
||||
*/
|
||||
fun slot(
|
||||
item: ItemStack,
|
||||
init: SlotBuilder.() -> Unit
|
||||
): Slot {
|
||||
val builder = Slot.builder(item)
|
||||
init(builder)
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
/**
|
||||
* Kotlin builder for slots.
|
||||
*/
|
||||
fun slot(
|
||||
provider: (Player, Menu) -> ItemStack,
|
||||
init: SlotBuilder.() -> Unit
|
||||
): Slot {
|
||||
val builder = Slot.builder { a, b -> provider(a, b) }
|
||||
init(builder)
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MenuBuilder.onClose
|
||||
*/
|
||||
fun MenuBuilder.onClose(action: (InventoryCloseEvent, Menu) -> Unit): MenuBuilder =
|
||||
this.onClose { a, b -> action(a, b) }
|
||||
|
||||
/**
|
||||
* @see MenuBuilder.modify
|
||||
*/
|
||||
fun MenuBuilder.modify(modifier: (MenuBuilder) -> Unit): MenuBuilder =
|
||||
this.modfiy { modifier(it) }
|
||||
|
||||
/**
|
||||
* Kotlin builder for menus.
|
||||
*/
|
||||
fun menu(
|
||||
rows: Int,
|
||||
init: MenuBuilder.() -> Unit
|
||||
): Menu {
|
||||
val builder = Menu.builder(rows)
|
||||
init(builder)
|
||||
return builder.build()
|
||||
}
|
||||
12
eco-api/src/main/kotlin/com/willfp/eco/util/ArrowUtils.kt
Normal file
12
eco-api/src/main/kotlin/com/willfp/eco/util/ArrowUtils.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
@file:JvmName("ArrowUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import org.bukkit.entity.Arrow
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
/**
|
||||
* @see ArrowUtils.getBow
|
||||
*/
|
||||
val Arrow.bow: ItemStack?
|
||||
get() = ArrowUtils.getBow(this)
|
||||
11
eco-api/src/main/kotlin/com/willfp/eco/util/BlockUtils.kt
Normal file
11
eco-api/src/main/kotlin/com/willfp/eco/util/BlockUtils.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
@file:JvmName("BlockUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import org.bukkit.block.Block
|
||||
|
||||
/**
|
||||
* @see ArrowUtils.getBow
|
||||
*/
|
||||
val Block.isPlayerPlaced: Boolean
|
||||
get() = BlockUtils.isPlayerPlaced(this)
|
||||
15
eco-api/src/main/kotlin/com/willfp/eco/util/ListUtils.kt
Normal file
15
eco-api/src/main/kotlin/com/willfp/eco/util/ListUtils.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
@file:JvmName("ListUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
/**
|
||||
* @see ListUtils.listToFrequencyMap
|
||||
*/
|
||||
fun <T> List<T>.toFrequencyMap(): Map<T, Int> =
|
||||
ListUtils.listToFrequencyMap(this)
|
||||
|
||||
/**
|
||||
* @see ListUtils.containsIgnoreCase
|
||||
*/
|
||||
fun Iterable<String>.containsIgnoreCase(element: String): Boolean =
|
||||
ListUtils.containsIgnoreCase(this, element)
|
||||
26
eco-api/src/main/kotlin/com/willfp/eco/util/PlayerUtils.kt
Normal file
26
eco-api/src/main/kotlin/com/willfp/eco/util/PlayerUtils.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
@file:JvmName("PlayerUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import net.kyori.adventure.audience.Audience
|
||||
import org.bukkit.OfflinePlayer
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
/**
|
||||
* @see PlayerUtils.getSavedDisplayName
|
||||
*/
|
||||
val OfflinePlayer.savedDisplayName: String
|
||||
get() = PlayerUtils.getSavedDisplayName(this)
|
||||
|
||||
/**
|
||||
* @see PlayerUtils.getAudience
|
||||
*/
|
||||
fun Player.asAudience(): Audience =
|
||||
PlayerUtils.getAudience(this)
|
||||
|
||||
/**
|
||||
* @see PlayerUtils.getAudience
|
||||
*/
|
||||
fun CommandSender.asAudience(): Audience =
|
||||
PlayerUtils.getAudience(this)
|
||||
11
eco-api/src/main/kotlin/com/willfp/eco/util/PotionUtils.kt
Normal file
11
eco-api/src/main/kotlin/com/willfp/eco/util/PotionUtils.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
@file:JvmName("PotionUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import org.bukkit.potion.PotionData
|
||||
|
||||
/**
|
||||
* @see PotionData.duration
|
||||
*/
|
||||
val PotionData.duration: Int
|
||||
get() = PotionUtils.getDuration(this)
|
||||
11
eco-api/src/main/kotlin/com/willfp/eco/util/ServerUtils.kt
Normal file
11
eco-api/src/main/kotlin/com/willfp/eco/util/ServerUtils.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
@file:JvmName("ServerUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import org.bukkit.Server
|
||||
|
||||
/**
|
||||
* @see ServerUtils.getTps
|
||||
*/
|
||||
val Server.tps: Double
|
||||
get() = ServerUtils.getTps()
|
||||
17
eco-api/src/main/kotlin/com/willfp/eco/util/SkullUtils.kt
Normal file
17
eco-api/src/main/kotlin/com/willfp/eco/util/SkullUtils.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
@file:JvmName("SkullUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import org.bukkit.inventory.meta.SkullMeta
|
||||
|
||||
/**
|
||||
* @see SkullUtils.getSkullTexture
|
||||
* @see SkullUtils.setSkullTexture
|
||||
*/
|
||||
var SkullMeta.texture: String?
|
||||
get() = SkullUtils.getSkullTexture(this)
|
||||
set(value) {
|
||||
if (value != null) {
|
||||
SkullUtils.setSkullTexture(this, value)
|
||||
}
|
||||
}
|
||||
42
eco-api/src/main/kotlin/com/willfp/eco/util/StringUtils.kt
Normal file
42
eco-api/src/main/kotlin/com/willfp/eco/util/StringUtils.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
@file:JvmName("StringUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
/**
|
||||
* @see StringUtils.toComponent
|
||||
*/
|
||||
fun String.toComponent(): Component =
|
||||
StringUtils.toComponent(this)
|
||||
|
||||
/**
|
||||
* @see StringUtils.toLegacy
|
||||
*/
|
||||
fun Component.toLegacy(): String =
|
||||
StringUtils.toLegacy(this)
|
||||
|
||||
/**
|
||||
* @see StringUtils.format
|
||||
*/
|
||||
fun String.formatEco(
|
||||
player: Player? = null,
|
||||
formatPlaceholders: Boolean = false
|
||||
) = StringUtils.format(
|
||||
this,
|
||||
player,
|
||||
if (formatPlaceholders) StringUtils.FormatOption.WITH_PLACEHOLDERS else StringUtils.FormatOption.WITHOUT_PLACEHOLDERS
|
||||
)
|
||||
|
||||
/**
|
||||
* @see StringUtils.formatList
|
||||
*/
|
||||
fun List<String>.formatEco(
|
||||
player: Player? = null,
|
||||
formatPlaceholders: Boolean = false
|
||||
) = StringUtils.formatList(
|
||||
this,
|
||||
player,
|
||||
if (formatPlaceholders) StringUtils.FormatOption.WITH_PLACEHOLDERS else StringUtils.FormatOption.WITHOUT_PLACEHOLDERS
|
||||
)
|
||||
17
eco-api/src/main/kotlin/com/willfp/eco/util/VectorUtils.kt
Normal file
17
eco-api/src/main/kotlin/com/willfp/eco/util/VectorUtils.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
@file:JvmName("VectorUtilsExtensions")
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import org.bukkit.util.Vector
|
||||
|
||||
/**
|
||||
* @see VectorUtils.isFinite
|
||||
*/
|
||||
val Vector.isFinite: Boolean
|
||||
get() = VectorUtils.isFinite(this)
|
||||
|
||||
/**
|
||||
* @see VectorUtils.simplifyVector
|
||||
*/
|
||||
fun Vector.simplify(): Vector =
|
||||
VectorUtils.simplifyVector(this)
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.internal.extensions
|
||||
|
||||
import com.google.common.collect.ImmutableSet
|
||||
import com.willfp.eco.core.Eco
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.config.TransientConfig
|
||||
import com.willfp.eco.core.extensions.Extension
|
||||
@@ -32,6 +33,9 @@ class EcoExtensionLoader(
|
||||
|
||||
runCatching { loadExtension(extensionJar) }.onFailure {
|
||||
this.plugin.logger.warning(extensionJar.name + " caused an error!")
|
||||
if (Eco.getHandler().ecoPlugin.configYml.getBool("log-full-extension-errors")) {
|
||||
it.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.willfp.eco.core.gui.slot.functional.SlotProvider
|
||||
|
||||
class EcoSlotBuilder(private val provider: SlotProvider) : SlotBuilder {
|
||||
private var captive = false
|
||||
private var modifier: SlotModifier = SlotModifier{ player, menu, _ -> provider.provide(player, menu)}
|
||||
private var modifier: SlotModifier = SlotModifier { player, menu, _ -> provider.provide(player, menu) }
|
||||
|
||||
private var onLeftClick =
|
||||
SlotHandler { _, _, _ -> run { } }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.3"
|
||||
id("io.papermc.paperweight.userdev") version "1.3.4"
|
||||
}
|
||||
|
||||
group = "com.willfp"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.3"
|
||||
id("io.papermc.paperweight.userdev") version "1.3.4"
|
||||
}
|
||||
|
||||
group = "com.willfp"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.willfp.eco.internal.spigot.data
|
||||
|
||||
import com.willfp.eco.core.data.PlayerProfile
|
||||
import com.willfp.eco.core.data.Profile
|
||||
import com.willfp.eco.core.data.ServerProfile
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.internal.spigot.data.storage.DataHandler
|
||||
import java.util.UUID
|
||||
@@ -10,7 +12,7 @@ abstract class EcoProfile(
|
||||
val data: MutableMap<PersistentDataKey<*>, Any>,
|
||||
val uuid: UUID,
|
||||
private val handler: DataHandler
|
||||
) : PlayerProfile {
|
||||
) : Profile {
|
||||
override fun <T : Any> write(key: PersistentDataKey<T>, value: T) {
|
||||
this.data[key] = value
|
||||
|
||||
@@ -50,7 +52,7 @@ class EcoPlayerProfile(
|
||||
data: MutableMap<PersistentDataKey<*>, Any>,
|
||||
uuid: UUID,
|
||||
handler: DataHandler
|
||||
) : EcoProfile(data, uuid, handler) {
|
||||
) : EcoProfile(data, uuid, handler), PlayerProfile {
|
||||
override fun toString(): String {
|
||||
return "EcoPlayerProfile{uuid=$uuid}"
|
||||
}
|
||||
@@ -59,7 +61,7 @@ class EcoPlayerProfile(
|
||||
class EcoServerProfile(
|
||||
data: MutableMap<PersistentDataKey<*>, Any>,
|
||||
handler: DataHandler
|
||||
) : EcoProfile(data, serverProfileUUID, handler) {
|
||||
) : EcoProfile(data, serverProfileUUID, handler), ServerProfile {
|
||||
override fun toString(): String {
|
||||
return "EcoServerProfile"
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class EcoProfileHandler(
|
||||
}
|
||||
|
||||
override fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
||||
val profile = PlayerProfile.load(uuid)
|
||||
val profile = loadGenericProfile(uuid)
|
||||
|
||||
for (key in keys) {
|
||||
handler.write(uuid, key.key, profile.read(key))
|
||||
|
||||
@@ -48,6 +48,10 @@ display-frame-ttl: 17
|
||||
# at a performance penalty.
|
||||
use-safer-namespacedkey-creation: false
|
||||
|
||||
# If the stack traces of extensions that failed to load should be logged. Disabled by
|
||||
# default to prevent users from reporting bugs. Enable if you're a developer.
|
||||
log-full-extension-errors: false
|
||||
|
||||
# Window items packets have the option to be run asynchronously. This may cause
|
||||
# some bugs and is considered experimental, however it has been tested without
|
||||
# any apparent issues. Enable this if performance is absolutely crucial or if you
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.22.1
|
||||
version = 6.23.0
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user