Compare commits

..

25 Commits

Author SHA1 Message Date
Auxilor
969329486d Reverted publication changes 2022-02-02 16:00:01 +00:00
Auxilor
aab2e8237c Gave up trying to have separate java and kotlin modules 2022-02-02 15:57:45 +00:00
Auxilor
30457c29a1 Gave up trying to have separate java and kotlin modules 2022-02-02 15:57:37 +00:00
Auxilor
9ad480ecf0 Shadow publication attempt 1 2022-02-02 15:50:43 +00:00
Auxilor
b0d3256d1b Fixed conflicting jvm names 2022-02-02 14:23:51 +00:00
Auxilor
4ff9d82cc1 Added kotlin builders for GUIs 2022-02-02 13:21:28 +00:00
Auxilor
f9178e248b Updated paperweight userdev 2022-02-02 12:47:56 +00:00
Auxilor
cc8a799438 Added log-full-extension-errors 2022-02-02 12:46:49 +00:00
Auxilor
90b81f56df Codestyle 2022-02-02 12:43:55 +00:00
Auxilor
1240c14c14 Added kotlin extensions 2022-02-02 12:42:38 +00:00
Auxilor
ed46900f2f Re-added NMS Modules after build checks 2022-02-02 12:20:33 +00:00
Auxilor
dade3d7fbb Fixed build.gradle in eco-api 2022-02-02 12:16:39 +00:00
Auxilor
df141875d3 Updated CI workflows 2022-02-02 12:15:34 +00:00
Auxilor
50b07de5d1 Updated CI workflows 2022-02-02 12:13:58 +00:00
Auxilor
e2a033c24f Dev changes 2022-02-02 12:13:36 +00:00
Auxilor
3fa574105f Hopefully resolved circular dependencies 2022-02-02 11:40:39 +00:00
Auxilor
a64386f980 Hopefully resolved circular dependencies 2022-02-02 11:40:03 +00:00
Auxilor
4c5a0f9887 Even more buildscript changes 2022-02-02 11:31:21 +00:00
Auxilor
cbd43f5757 More buildscript changes 2022-02-02 11:24:33 +00:00
Auxilor
01f1425557 buildscript changes 2022-02-02 11:24:12 +00:00
Auxilor
25e8cc0837 Refactored API, added kotlin extensions 2022-02-02 11:22:19 +00:00
Auxilor
7ff3eeef06 Updated to 6.22.3 2022-02-01 19:09:24 +00:00
Auxilor
58faf6de23 Fixed more server profile issues 2022-02-01 19:09:10 +00:00
Auxilor
7f42cbe32e Updated to 6.22.2 2022-02-01 18:55:18 +00:00
Auxilor
ae12ab17fe Fixed server profile 2022-02-01 18:55:07 +00:00
22 changed files with 369 additions and 12 deletions

42
.github/workflows/test-publish.yml vendored Normal file
View 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

View File

@@ -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

View 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()

View File

@@ -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)

View File

@@ -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()
}

View 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)

View 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)

View 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)

View 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)

View 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)

View 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()

View 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)
}
}

View 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
)

View 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)

View File

@@ -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()
}
}
}
}

View File

@@ -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 { } }

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"
}

View File

@@ -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))

View File

@@ -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

View File

@@ -1,3 +1,3 @@
version = 6.22.1
version = 6.23.0
plugin-name = eco
kotlin.code.style = official