Compare commits

..

1 Commits

Author SHA1 Message Date
faiz36
5a6bcbf5a4 ๐Ÿ’ซadded 1.20.6 2024-06-08 21:54:56 +09:00
4 changed files with 75 additions and 56 deletions

View File

@ -1,5 +1,5 @@
plugins { plugins {
kotlin("jvm") version "2.0.0-Beta4" kotlin("jvm") version "2.0.0"
id("xyz.jpenilla.run-paper") version "2.2.3" id("xyz.jpenilla.run-paper") version "2.2.3"
// id("io.papermc.paperweight.userdev") version "1.5.4" // id("io.papermc.paperweight.userdev") version "1.5.4"
} }
@ -13,25 +13,20 @@ repositories {
} }
java { java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17)) toolchain.languageVersion.set(JavaLanguageVersion.of(21))
} }
dependencies { dependencies {
testImplementation(kotlin("test")) testImplementation(kotlin("test"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
implementation("io.github.monun:invfx-api:3.3.2") implementation("io.github.monun:invfx-api:latest.release")
// paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT") // paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT")
implementation("io.github.monun:kommand-api:3.1.7") // implementation("io.github.monun:kommand-api:3.1.7")
} }
tasks { tasks {
runServer{ runServer{
minecraftVersion("1.20.1") minecraftVersion("1.20.6")
downloadPlugins{
hangar("ViaVersion","4.9.3-SNAPSHOT+208")
hangar("ViaBackwards", "4.9.2-SNAPSHOT+126")
hangar("Multiverse-Core","4.3.12")
}
} }
} }
@ -40,5 +35,5 @@ tasks.test {
} }
kotlin { kotlin {
jvmToolchain(17) jvmToolchain(21)
} }

View File

@ -5,12 +5,16 @@ import me.faiz.combat_f.data.MainData
import me.faiz.combat_f.listener.MainListener import me.faiz.combat_f.listener.MainListener
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.scheduler.BukkitRunnable
import org.bukkit.scheduler.BukkitTask
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import kotlin.collections.HashMap import kotlin.collections.HashMap
class Main : JavaPlugin() { class Main : JavaPlugin() {
var manager = this.lifecycleManager
// Player UUID, A Pair of Attacker UUID and Current time // Player UUID, A Pair of Attacker UUID and Current time
var clist:HashMap<UUID,Pair<UUID,Long>> = HashMap() var clist:HashMap<UUID,Pair<UUID,Long>> = HashMap()
@ -22,14 +26,7 @@ class Main : JavaPlugin() {
private val maindata by lazy { MainData(this) } private val maindata by lazy { MainData(this) }
private val scheduler = this.server.scheduler.runTaskTimerAsynchronously(this,Runnable{ private lateinit var scheduler: BukkitTask
clist.forEach {
val wuid = Bukkit.getPlayer(it.key)!!.world.uid
if(it.value.second/1000 + maindata.getTimeWorld(wuid.toString()) <= System.currentTimeMillis()/1000){
clist.remove(it.key)
}
}
},1L,1L)
override fun onDisable() { override fun onDisable() {
maindata.save() maindata.save()
} }
@ -37,6 +34,14 @@ class Main : JavaPlugin() {
override fun onEnable() { override fun onEnable() {
MainCommand(this, maindata) MainCommand(this, maindata)
MainListener(this, maindata) MainListener(this, maindata)
scheduler = this.server.scheduler.runTaskTimerAsynchronously(this,Runnable{
clist.forEach {
val wuid = Bukkit.getPlayer(it.key)!!.world.uid
if(it.value.second/1000 + maindata.getTimeWorld(wuid.toString()) <= System.currentTimeMillis()/1000){
clist.remove(it.key)
}
}
},1L,1L)
} }
companion object { companion object {

View File

@ -1,25 +1,35 @@
package me.faiz.combat_f.cmd package me.faiz.combat_f.cmd
import io.github.monun.kommand.kommand import com.mojang.brigadier.Command
import io.papermc.paper.command.brigadier.Commands
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents
import me.faiz.combat_f.Main import me.faiz.combat_f.Main
import me.faiz.combat_f.data.MainData import me.faiz.combat_f.data.MainData
import me.faiz.combat_f.handler.MainHandler import me.faiz.combat_f.handler.MainHandler
import net.kyori.adventure.text.Component
import org.bukkit.entity.Player import org.bukkit.entity.Player
class MainCommand(private val main: Main, private val data: MainData) { class MainCommand(private val main: Main, private val data: MainData) {
init { init {
main.apply { main.apply {
kommand { manager.registerEventHandler(LifecycleEvents.COMMANDS){ ev ->
register("combat") { val cmd = ev.registrar()
requires { isOp } cmd.register(
executes { Commands.literal("combat")
if (sender !is Player) { .requires{ s ->
sender.sendMessage("This command can use Player! \n Please use another command!") s.sender.isOp
return@executes }
} else MainHandler(sender as Player, data, main) .executes{ ctx ->
} if(ctx.source.sender !is Player){
} ctx.source.sender.sendPlainMessage("ํ”Œ๋ ˆ์ด์–ด๋งŒ ์ด ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!")
return@executes Command.SINGLE_SUCCESS
}
MainHandler(ctx.source.sender as Player,data, main)
return@executes Command.SINGLE_SUCCESS
}
.build()
)
} }
} }
} }

View File

@ -6,9 +6,11 @@ import me.faiz.combat_f.data.MainData
import net.kyori.adventure.text.Component import net.kyori.adventure.text.Component
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.entity.EntityType import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler import org.bukkit.event.EventHandler
import org.bukkit.event.Listener import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDamageByEntityEvent import org.bukkit.event.entity.EntityDamageByEntityEvent
import org.bukkit.event.entity.ProjectileHitEvent
@Suppress("unused") @Suppress("unused")
class MainListener(private val main: Main, private val data: MainData) : Listener { class MainListener(private val main: Main, private val data: MainData) : Listener {
@ -24,42 +26,49 @@ class MainListener(private val main: Main, private val data: MainData) : Listene
@EventHandler @EventHandler
fun onDamage(e: EntityDamageByEntityEvent){ fun onDamage(e: EntityDamageByEntityEvent){
if(e.entityType != EntityType.PLAYER) return val clist = main.clist
if(e.damager.type != EntityType.PLAYER) return if(e.damager.type != EntityType.PLAYER || e.entityType != EntityType.PLAYER) return
if(!data.getUseWorld(e.entity.world.uid.toString())) return if(!data.getUseWorld(e.damager.world.uid.toString())) return
val entityD = main.clist[e.entity.uniqueId] if(data.getHitOtherWorld(e.damager.world.uid.toString())){
val damagerD = main.clist[e.damager.uniqueId] main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId, System.currentTimeMillis())
if(main.clist.contains(e.entity.uniqueId)){ main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId, System.currentTimeMillis())
if (data.getHitOtherWorld(e.entity.world.uid.toString())){ return
main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId,System.currentTimeMillis()) }
main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId,System.currentTimeMillis()) if(clist.contains(e.entity.uniqueId)){
return if(clist[e.entity.uniqueId]!!.first == e.damager.uniqueId){
} main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId, System.currentTimeMillis())
if (entityD!!.first == e.damager.uniqueId){ main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId, System.currentTimeMillis())
main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId,System.currentTimeMillis())
main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId,System.currentTimeMillis())
return return
}else{ }else{
e.damager.sendMessage(Component.text("ํ•ด๋‹น ํ”Œ๋ ˆ์ด์–ด๋Š” ${Bukkit.getPlayer(clist[e.entity.uniqueId]!!.first)!!.name}๊ณผ ์ „ํˆฌ์ค‘์ž…๋‹ˆ๋‹ค!"))
e.isCancelled = true e.isCancelled = true
e.damager.sendMessage(Component.text("ํ•ด๋‹น ํ”Œ๋ ˆ์ด์–ด๋Š” ์ „ํˆฌ์ค‘์ž…๋‹ˆ๋‹ค."))
return return
} }
}else if(main.clist.contains(e.damager.uniqueId)){ }else if(clist.contains(e.damager.uniqueId)){
if (data.getHitOtherWorld(e.entity.world.uid.toString())){ if(clist[e.damager.uniqueId]!!.first == e.entity.uniqueId){
main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId,System.currentTimeMillis()) main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId, System.currentTimeMillis())
main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId,System.currentTimeMillis()) main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId, System.currentTimeMillis())
return
}
if(damagerD!!.first == e.entity.uniqueId){
main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId,System.currentTimeMillis())
main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId,System.currentTimeMillis())
return return
}else{ }else{
e.damager.sendMessage("์ด๋ฏธ ${Bukkit.getPlayer(clist[e.entity.uniqueId]!!.first)!!.name}๋‹˜๊ณผ ์ „ํˆฌ์ค‘์ž…๋‹ˆ๋‹ค!")
e.isCancelled = true e.isCancelled = true
e.damager.sendMessage(Component.text("์ด๋ฏธ ${Bukkit.getPlayer(damagerD.first)!!.name}๊ณผ ์ „ํˆฌ์ค‘์ž…๋‹ˆ๋‹ค!"))
return return
} }
}else{
main.clist[e.entity.uniqueId] = Pair(e.damager.uniqueId, System.currentTimeMillis())
main.clist[e.damager.uniqueId] = Pair(e.entity.uniqueId, System.currentTimeMillis())
} }
} }
@EventHandler
fun onArrow(e: ProjectileHitEvent){
if(e.entity.shooter !is Player) return
if(e.hitEntity == null) return
if(e.hitEntity!!.type != EntityType.PLAYER) return
val pl = e.hitEntity as Player
val sh = e.entity.shooter as Player
if(pl.uniqueId == sh.uniqueId) return
}
} }