Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Support Paper 1.20.1 #103

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Psychics (paper 기반의 능력자 플러그인)

[![Kotlin](https://img.shields.io/badge/java-16.0.2-ED8B00.svg?logo=java)](https://www.azul.com/)
[![Kotlin](https://img.shields.io/badge/kotlin-1.5.21-585DEF.svg?logo=kotlin)](http://kotlinlang.org)
[![Gradle](https://img.shields.io/badge/gradle-7.2-02303A.svg?logo=gradle)](https://gradle.org)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.monun/psychics)](https://search.maven.org/artifact/io.github.monun/psychics)
[![Kotlin](https://img.shields.io/badge/java-17-ED8B00.svg?logo=java)](https://www.azul.com/)
[![Kotlin](https://img.shields.io/badge/kotlin-1.7.21-585DEF.svg?logo=kotlin)](http://kotlinlang.org)
[![Gradle](https://img.shields.io/badge/gradle-7.6-02303A.svg?logo=gradle)](https://gradle.org)
[![GitHub](https://img.shields.io/github/license/monun/psychics)](https://www.gnu.org/licenses/gpl-3.0.html)
[![Kotlin](https://img.shields.io/badge/youtube-각별-red.svg?logo=youtube)](https://www.youtube.com/channel/UCDrAR1OWC2MD4s0JLetN0MA)

---

현재 개발 진행중으로 배포버전이 없습니다.

* [docs](https://monun.github.io/psychics/)
* [docs](https://monun.github.io/psychics/)

---
## TODO

* [x] Show Firework without Tap Effect Util
20 changes: 4 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
plugins {
kotlin("jvm") version "1.5.21"
kotlin("jvm") version "1.7.21"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(16))
languageVersion.set(JavaLanguageVersion.of(17))
}
}

allprojects {
repositories {
mavenCentral()
}

tasks {
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
kotlinOptions {
jvmTarget = "16"
}
}
}
}

subprojects {
Expand All @@ -30,15 +22,11 @@ subprojects {
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")

implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))

implementation("io.github.monun:tap-api:4.1.9")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.2")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.2")
testImplementation("org.mockito:mockito-core:3.6.28")
implementation("io.github.monun:tap-api:4.9.8")
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package io.github.monun.psychics.ability.berserker

import io.github.monun.psychics.AbilityConcept
import io.github.monun.psychics.ActiveAbility
import io.github.monun.psychics.effect.spawnFirework
import io.github.monun.tap.config.Config
import io.github.monun.tap.config.Name
import io.github.monun.tap.effect.playFirework
//import io.github.monun.tap.effect.playFirework
import org.bukkit.*
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
Expand Down Expand Up @@ -64,7 +65,7 @@ class AbilityBerserker : ActiveAbility<AbilityConceptBerserker>(), Listener {
val location = player.location.apply { y += 2.0 }
val world = location.world
val firework = FireworkEffect.builder().with(FireworkEffect.Type.BURST).withColor(Color.RED).withFlicker().build()
world.playFirework(location, firework)
world.spawnFirework(location, firework, psychic.plugin)
}

@EventHandler(ignoreCancelled = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,19 @@ class AbilityBomber : ActiveAbility<AbilityConceptBomber>(), Listener {
* 가짜 TNT 효과
*/
inner class TNT(location: Location) {
private val stand: FakeEntity
private val tnt: FakeEntity
private val stand: FakeEntity<ArmorStand>
private val tnt: FakeEntity<TNTPrimed>

init {
val psychic = psychic
stand = psychic.spawnFakeEntity(location, ArmorStand::class.java).apply {
updateMetadata<ArmorStand> {
updateMetadata {
isMarker = true
isInvisible = true
}
}
tnt = psychic.spawnFakeEntity(location, TNTPrimed::class.java).apply {
updateMetadata<TNTPrimed> {
updateMetadata {
fuseTicks = (durationTime / 50L).toInt()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class AbilityFangs : ActiveAbility<AbilityConceptFangs>(), Listener {

private class Fang(
val location: Location,
val fakeEntity: FakeEntity,
val fakeEntity: FakeEntity<EvokerFangs>,
var nextRunTime: Long,
val damaged: MutableSet<Entity>
) : Comparable<Fang> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import io.github.monun.psychics.attribute.EsperAttribute
import io.github.monun.psychics.damage.Damage
import io.github.monun.psychics.damage.DamageType
import io.github.monun.psychics.damage.psychicDamage
import io.github.monun.psychics.effect.spawnFirework
import io.github.monun.psychics.util.TargetFilter
import io.github.monun.tap.config.Name
import io.github.monun.tap.effect.playFirework
//import io.github.monun.tap.effect.playFirework
import io.github.monun.tap.trail.TrailSupport
import net.kyori.adventure.text.Component.text
import net.kyori.adventure.text.format.NamedTextColor
Expand Down Expand Up @@ -132,7 +133,7 @@ class AbilityMagicArchery : Ability<AbilityConceptMagicArchery>(), Listener {
val box = target.boundingBox
val effect = FireworkEffect.builder().with(FireworkEffect.Type.BURST)
.withColor(if (force == 1.0F) Color.RED else Color.ORANGE).build()
world.playFirework(box.centerX, box.maxY + 0.5, box.centerZ, effect)
world.spawnFirework(box.centerX, box.maxY + 0.5, box.centerZ, effect, psychic.plugin)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import io.github.monun.psychics.Channel
import io.github.monun.psychics.attribute.EsperAttribute
import io.github.monun.psychics.damage.Damage
import io.github.monun.psychics.damage.DamageType
import io.github.monun.psychics.effect.spawnFirework
import io.github.monun.psychics.util.hostileFilter
import io.github.monun.tap.config.Name
import io.github.monun.tap.effect.playFirework
//import io.github.monun.tap.effect.playFirework
import net.kyori.adventure.text.Component.text
import org.bukkit.*
import org.bukkit.entity.LivingEntity
Expand All @@ -35,10 +36,6 @@ class AbilityConceptSample : AbilityConcept() {
class AbilitySample : ActiveAbility<AbilityConceptSample>(), Listener {
companion object {
private val effect = FireworkEffect.builder().with(FireworkEffect.Type.BURST).withColor(Color.RED).build()

private fun LivingEntity.playPsychicEffect() {
world.playFirework(location, effect)
}
}

override fun onInitialize() {
Expand Down Expand Up @@ -85,4 +82,8 @@ class AbilitySample : ActiveAbility<AbilityConceptSample>(), Listener {
target.psychicDamage()
target.playPsychicEffect()
}

private fun LivingEntity.playPsychicEffect() {
world.spawnFirework(location, effect, psychic.plugin)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AbilitySlingShot : Ability<AbilityConceptSlingShot>(), Listener {
val projectile = CobblestoneProjectile().apply {
cobblestone =
[email protected](location, ArmorStand::class.java).apply {
updateMetadata<ArmorStand> {
updateMetadata {
isVisible = false
isMarker = true
}
Expand All @@ -97,7 +97,7 @@ class AbilitySlingShot : Ability<AbilityConceptSlingShot>(), Listener {
}

inner class CobblestoneProjectile : PsychicProjectile(1200, concept.range) {
lateinit var cobblestone: FakeEntity
lateinit var cobblestone: FakeEntity<ArmorStand>

override fun onPreUpdate() {
velocity = velocity.apply { y -= concept.stoneGravity }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import io.github.monun.tap.config.Name
import io.github.monun.tap.fake.FakeEntity
import io.github.monun.tap.fake.Movement
import io.github.monun.tap.fake.Trail
import io.github.monun.tap.fake.invisible
import io.github.monun.tap.math.normalizeAndLength
import io.github.monun.tap.math.toRadians
import io.github.monun.tap.trail.TrailSupport
Expand Down Expand Up @@ -109,7 +108,7 @@ class AbilityConceptStormBreaker : AbilityConcept() {
}

class AbilityStormBreaker : Ability<AbilityConceptStormBreaker>() {
private var hittedAxe: FakeEntity? = null
private var hittedAxe: FakeEntity<ArmorStand>? = null

override fun onEnable() {
psychic.registerEvents(AxeListener())
Expand Down Expand Up @@ -207,9 +206,9 @@ class AbilityStormBreaker : Ability<AbilityConceptStormBreaker>() {
).apply {
velocity = location.direction.multiply(concept.axeSpeed)

updateMetadata<ArmorStand> {
updateMetadata {
isMarker = true
invisible = true
isVisible = false
}
updateEquipment {
helmet = item.clone()
Expand All @@ -229,7 +228,7 @@ class AbilityStormBreaker : Ability<AbilityConceptStormBreaker>() {
inner class AxeProjectile(
private val damage: Damage, private val item: ItemStack
) : PsychicProjectile(1200, concept.range) {
var axe: FakeEntity? = null
var axe: FakeEntity<ArmorStand>? = null

override fun onPreUpdate() {
velocity = velocity.apply { y -= concept.axeGravity }
Expand All @@ -239,7 +238,7 @@ class AbilityStormBreaker : Ability<AbilityConceptStormBreaker>() {
val to = movement.to
axe?.let { axe ->
axe.moveTo(to.clone().apply { y -= 1.62; yaw -= 90.0F })
axe.updateMetadata<ArmorStand> {
axe.updateMetadata {
headPose = EulerAngle(0.0, 0.0, ticks * -0.5)
}
}
Expand Down Expand Up @@ -273,7 +272,7 @@ class AbilityStormBreaker : Ability<AbilityConceptStormBreaker>() {
axe?.let { axe ->
this.axe = null
axe.moveTo(hitLocation.clone().apply { y -= 0.5; yaw = from.yaw - 90.0F })
axe.updateMetadata<ArmorStand> {
axe.updateMetadata {
headPose = EulerAngle(0.0, 0.0, (-180.0).toRadians())
}
hittedAxe = axe
Expand Down
19 changes: 16 additions & 3 deletions psychics-abilities/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,21 @@ subprojects {
}

gradle.buildFinished {
val libs = File(buildDir, "libs")
if (!buildDir.exists()) buildDir.mkdir()

if (libs.exists())
zipTo(File(buildDir, "abilities.zip"), libs)
val abilitiesDir = File(buildDir,"abilities")
abilitiesDir.mkdir()

subprojects
.map { File(it.buildDir, "libs") to it }
.filter { (it,_) -> it.exists() }
.mapNotNull { (it,project) -> it.listFiles()!!.find {
it.nameWithoutExtension == "${project.group}.${project.name.removePrefix("ability-")}"
} }
.forEach {
val newFile = File(abilitiesDir,it.name)
it.copyTo(newFile,true)
}

zipTo(File(buildDir, "abilities.zip"), abilitiesDir)
}
6 changes: 3 additions & 3 deletions psychics-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id("org.jetbrains.dokka") version "1.5.0"
id("org.jetbrains.dokka") version "1.7.20"
}

dependencies {
implementation("io.github.monun:kommand-api:2.6.6")
implementation("io.github.monun:invfx-api:3.0.1")
implementation("io.github.monun:kommand-api:3.1.7")
implementation("io.github.monun:invfx-api:3.3.2")
}

tasks {
Expand Down
18 changes: 10 additions & 8 deletions psychics-core/src/main/kotlin/io/github/monun/psychics/Psychic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import org.bukkit.boss.BossBar
import org.bukkit.configuration.ConfigurationSection
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Entity
import org.bukkit.entity.FallingBlock
import org.bukkit.entity.Item
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerEvent
import org.bukkit.inventory.ItemStack
Expand Down Expand Up @@ -132,7 +134,7 @@ class Psychic internal constructor(

private lateinit var listeners: ArrayList<RegisteredEntityListener>

private lateinit var fakeEntities: MutableSet<FakeEntity>
private lateinit var fakeEntities: MutableSet<FakeEntity<*>>

private var prevUpdateTime = 0L

Expand Down Expand Up @@ -166,7 +168,7 @@ class Psychic internal constructor(
ticker = Ticker.precision()
projectiles = FakeProjectileManager()
listeners = arrayListOf()
fakeEntities = Collections.newSetFromMap(WeakHashMap<FakeEntity, Boolean>())
fakeEntities = Collections.newSetFromMap(WeakHashMap())

if (concept.mana > 0.0) {
manaBar = Bukkit.createBossBar(null, concept.manaColor, BarStyle.SEGMENTED_10).apply {
Expand Down Expand Up @@ -360,7 +362,7 @@ class Psychic internal constructor(
* @exception IllegalArgumentException 유효하지 않은 객체일때 발생
* @exception IllegalArgumentException 활성화되지 않은 객체일때 발생
*/
fun spawnFakeEntity(location: Location, entityClass: Class<out Entity>): FakeEntity {
fun <T:Entity> spawnFakeEntity(location: Location, entityClass: Class<T>): FakeEntity<T> {
checkState()
checkEnabled()

Expand All @@ -378,7 +380,7 @@ class Psychic internal constructor(
* @exception IllegalArgumentException 유효하지 않은 객체일때 발생
* @exception IllegalArgumentException 활성화되지 않은 객체일때 발생
*/
fun spawnFakeFallingBlock(location: Location, blockData: BlockData): FakeEntity {
fun spawnFakeFallingBlock(location: Location, blockData: BlockData): FakeEntity<FallingBlock> {
checkState()
checkEnabled()

Expand All @@ -396,7 +398,7 @@ class Psychic internal constructor(
* @exception IllegalArgumentException 유효하지 않은 객체일때 발생
* @exception IllegalArgumentException 활성화되지 않은 객체일때 발생
*/
fun spawnItem(location: Location, itemStack: ItemStack): FakeEntity {
fun spawnItem(location: Location, itemStack: ItemStack): FakeEntity<Item> {
checkState()
checkEnabled()

Expand All @@ -414,9 +416,9 @@ class Psychic internal constructor(
* @exception IllegalArgumentException 유효하지 않은 객체일때 발생
* @exception IllegalArgumentException 활성화되지 않은 객체일때 발생
*/
fun spawnMarker(location: Location): FakeEntity {
fun spawnMarker(location: Location): FakeEntity<ArmorStand> {
return spawnFakeEntity(location, ArmorStand::class.java).apply {
updateMetadata<ArmorStand> {
updateMetadata {
isMarker = true
isInvisible = true
}
Expand All @@ -431,7 +433,7 @@ class Psychic internal constructor(
* @exception IllegalArgumentException 유효하지 않은 객체일때 발생
* @exception IllegalArgumentException 활성화되지 않은 객체일때 발생
*/
fun marker(passenger: FakeEntity): FakeEntity {
fun <T:Entity> marker(passenger: FakeEntity<T>): FakeEntity<ArmorStand> {
return spawnMarker(passenger.location).apply { addPassenger(passenger) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ internal object KommandPsychics {
this.manager = manager

kommand.register("psychics", "psy") {
permission("psychics.commands")
requires {
hasPermission("psychics.commands")
}

val psychicConceptArgument = dynamic { _, input ->
manager.getPsychicConcept(input)
Expand Down
Loading