✨Initial Commit
This commit is contained in:
parent
fb5883997e
commit
1cea344643
2
.idea/.gitignore
vendored
2
.idea/.gitignore
vendored
@ -6,3 +6,5 @@
|
|||||||
# Datasource local storage ignored files
|
# Datasource local storage ignored files
|
||||||
/dataSources/
|
/dataSources/
|
||||||
/dataSources.local.xml
|
/dataSources.local.xml
|
||||||
|
# GitHub Copilot persisted chat sessions
|
||||||
|
/copilot/chatSessions
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.8.0"
|
kotlin("jvm") version "2.0.0-Beta4"
|
||||||
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "group.pvpconnect"
|
group = "me.faiz"
|
||||||
version = "1.0.1"
|
version = "2.0.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -17,11 +18,23 @@ java {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||||
|
implementation("io.github.monun:invfx-api:3.3.2")
|
||||||
// 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 {
|
||||||
|
runServer{
|
||||||
|
minecraftVersion("1.20.1")
|
||||||
|
downloadPlugins{
|
||||||
|
hangar("ViaVersion","4.9.3-SNAPSHOT+208")
|
||||||
|
hangar("ViaBackwards", "4.9.2-SNAPSHOT+126")
|
||||||
|
hangar("Multiverse-Core","4.3.12")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
package group.pvpconnect.combat_f
|
|
||||||
|
|
||||||
import group.pvpconnect.combat_f.cmd.CombatCmd
|
|
||||||
import group.pvpconnect.combat_f.data.CombatData
|
|
||||||
import group.pvpconnect.combat_f.event.CombatEvent
|
|
||||||
import net.kyori.adventure.text.Component
|
|
||||||
import org.bukkit.Bukkit
|
|
||||||
import org.bukkit.ChatColor
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
|
||||||
import org.bukkit.scheduler.BukkitTask
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
class Main:JavaPlugin() {
|
|
||||||
// 첫번째 전투 여부, 두번째 전투자 UUID, 남은 시간?
|
|
||||||
var list:HashMap<UUID,Triple<Boolean,UUID?,Long?>> = HashMap()
|
|
||||||
private lateinit var schedule:BukkitTask
|
|
||||||
private lateinit var schedule2:BukkitTask
|
|
||||||
lateinit var instance: Main
|
|
||||||
|
|
||||||
private val combatData by lazy { CombatData(this) }
|
|
||||||
|
|
||||||
override fun onLoad() {
|
|
||||||
instance = this
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDisable() {
|
|
||||||
combatData.save()
|
|
||||||
schedule.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onEnable() {
|
|
||||||
CombatCmd(this,combatData)
|
|
||||||
CombatEvent(this,combatData)
|
|
||||||
schedule = this.server.scheduler.runTaskTimerAsynchronously(this, Runnable {
|
|
||||||
list.forEach{
|
|
||||||
if(list[it.key] == null) return@forEach
|
|
||||||
if(!list[it.key]!!.first) return@forEach
|
|
||||||
if(list[it.key]!!.second == null) return@forEach
|
|
||||||
if(list[it.key]!!.third == null) return@forEach
|
|
||||||
if(it.value.third!!/1000 + combatData.instance.getTime() <= System.currentTimeMillis()/1000){
|
|
||||||
list.remove(it.key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Bukkit.getOnlinePlayers().forEach{
|
|
||||||
if(list[it.uniqueId] == null) return@forEach
|
|
||||||
if(!list[it.uniqueId]!!.first) return@forEach
|
|
||||||
if(list[it.uniqueId]!!.second == null) return@forEach
|
|
||||||
if(list[it.uniqueId]!!.third == null) return@forEach
|
|
||||||
it.isGliding = false
|
|
||||||
if(combatData.getOtherHit(it.world.name)){
|
|
||||||
it.sendActionBar(Component.text("${ChatColor.RESET}${ChatColor.WHITE}${list[it.uniqueId]!!.third!! /1000 + combatData.instance.getTime() - System.currentTimeMillis()/1000}${ChatColor.RED}${ChatColor.BOLD}초 뒤 전투모드가 끝납니다!"))
|
|
||||||
}else {
|
|
||||||
it.sendActionBar(Component.text("${ChatColor.WHITE}${Bukkit.getPlayer(list[it.uniqueId]!!.second!!)!!.name}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다! ${ChatColor.RESET}${ChatColor.WHITE}${list[it.uniqueId]!!.third!! / 1000 + combatData.instance.getTime() - System.currentTimeMillis() / 1000}${ChatColor.RED}${ChatColor.BOLD}초 뒤 전투모드가 끝납니다!"))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
},1L,1L)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package group.pvpconnect.combat_f.cmd
|
|
||||||
|
|
||||||
import group.pvpconnect.combat_f.Main
|
|
||||||
import group.pvpconnect.combat_f.data.CombatData
|
|
||||||
import io.github.monun.kommand.getValue
|
|
||||||
import io.github.monun.kommand.kommand
|
|
||||||
import org.bukkit.Bukkit
|
|
||||||
import org.bukkit.ChatColor
|
|
||||||
import org.bukkit.World
|
|
||||||
|
|
||||||
class CombatCmd(plugin:Main, private val cd:CombatData) {
|
|
||||||
init {
|
|
||||||
plugin.apply {
|
|
||||||
kommand {
|
|
||||||
register("combat"){
|
|
||||||
requires { isOp }
|
|
||||||
then("toggle"){
|
|
||||||
then("world" to dimension()){
|
|
||||||
executes {
|
|
||||||
val world: World by it
|
|
||||||
val bool = cd.instance.getUseWorld(world.name)
|
|
||||||
cd.instance.setUseWorld(world.name,!bool)
|
|
||||||
sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.BOLD}${ChatColor.GREEN}✓${ChatColor.RESET}${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃 모드 사용이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
then("visiable"){
|
|
||||||
then("world" to dimension()){
|
|
||||||
executes {
|
|
||||||
val world:World by it
|
|
||||||
val bool = cd.instance.getCanSeeWorld(world.name)
|
|
||||||
cd.instance.setCanSeeWorld(world.name,!bool)
|
|
||||||
sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람 볼수있음이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
then("hitother"){
|
|
||||||
then("world" to dimension()){
|
|
||||||
executes {
|
|
||||||
val world:World by it
|
|
||||||
val bool = cd.instance.getOtherHit(world.name)
|
|
||||||
cd.instance.setOtherHit(world.name,!bool)
|
|
||||||
sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람의 공격 가능이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
then("time"){
|
|
||||||
then("int" to int()){
|
|
||||||
executes {
|
|
||||||
val int:Int by it
|
|
||||||
val otime = cd.instance.getTime()
|
|
||||||
val ctime = int
|
|
||||||
cd.instance.setTime(ctime)
|
|
||||||
sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.BOLD}${ChatColor.GREEN}✓${ChatColor.RESET}${ChatColor.GOLD}] ${ChatColor.WHITE}컴뱃타임이 ${otime}초에서 ${ctime}초으로 변경되었습니다!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package group.pvpconnect.combat_f.data
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration
|
|
||||||
import org.bukkit.plugin.Plugin
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
class CombatData(private val plugin:Plugin) {
|
|
||||||
var instance:CombatData = this
|
|
||||||
|
|
||||||
private val file get() = File(plugin.dataFolder, "data.yml")
|
|
||||||
private val yaml = YamlConfiguration.loadConfiguration(file)
|
|
||||||
|
|
||||||
/** Return use that World CombatSystem.
|
|
||||||
* @return return use that World CombatSystem.
|
|
||||||
* @param world get world name
|
|
||||||
*/
|
|
||||||
fun getUseWorld(world:String):Boolean{
|
|
||||||
return yaml.getBoolean("${world}.use")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set use CombatSystem that World.
|
|
||||||
* @param world world name
|
|
||||||
* @param use use Boolean
|
|
||||||
*/
|
|
||||||
fun setUseWorld(world:String,use:Boolean){
|
|
||||||
yaml.set("${world}.use",use)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCanSeeWorld(world:String):Boolean{
|
|
||||||
return yaml.getBoolean("${world}.see")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setCanSeeWorld(world:String,see:Boolean){
|
|
||||||
yaml.set("${world}.see",see)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setTime(time:Int){
|
|
||||||
yaml.set("time",time)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getTime():Int{
|
|
||||||
return yaml.getInt("time")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOtherHit(world:String,hitable:Boolean){
|
|
||||||
yaml.set("${world}.otherhitable",hitable)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getOtherHit(world:String):Boolean{
|
|
||||||
return yaml.getBoolean("${world}.otherhitable")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun save(){
|
|
||||||
yaml.save(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,169 +0,0 @@
|
|||||||
package group.pvpconnect.combat_f.event
|
|
||||||
|
|
||||||
import group.pvpconnect.combat_f.Main
|
|
||||||
import group.pvpconnect.combat_f.data.CombatData
|
|
||||||
import org.bukkit.Bukkit
|
|
||||||
import org.bukkit.ChatColor
|
|
||||||
import org.bukkit.command.CommandSender
|
|
||||||
import org.bukkit.entity.EntityType
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import org.bukkit.event.EventHandler
|
|
||||||
import org.bukkit.event.Listener
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent
|
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent
|
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent
|
|
||||||
import org.bukkit.scoreboard.Team
|
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
class CombatEvent(private val plugin:Main, private val combatData: CombatData):Listener {
|
|
||||||
|
|
||||||
init {
|
|
||||||
Bukkit.getPluginManager().registerEvents(this,plugin)
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
fun onOtherDamage(e:EntityDamageByEntityEvent){
|
|
||||||
if(e.entityType != EntityType.PLAYER) return
|
|
||||||
if(e.damager.type != EntityType.PLAYER) return
|
|
||||||
if(!combatData.instance.getUseWorld(e.entity.world.name)) return
|
|
||||||
val team = Bukkit.getServer().scoreboardManager.mainScoreboard.teams
|
|
||||||
lateinit var plteam: Team
|
|
||||||
team.forEach { if(it.hasPlayer(Bukkit.getOfflinePlayer(e.entity.name))) plteam = it }
|
|
||||||
if(plteam.hasPlayer(Bukkit.getOfflinePlayer(e.damager.name))){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val list = plugin.instance.list[e.entity.uniqueId]
|
|
||||||
val dlist = plugin.instance.list[e.damager.uniqueId]
|
|
||||||
if((dlist?.second != null) && (dlist.second != e.entity.uniqueId)&& !combatData.instance.getOtherHit(e.entity.world.name)){ e.isCancelled = true;return}
|
|
||||||
if(list?.second != null && list.second != e.damager.uniqueId && !combatData.instance.getOtherHit(e.entity.world.name)) {
|
|
||||||
e.damager.sendMessage(
|
|
||||||
"${ChatColor.RED}${ChatColor.BOLD}해당 플레이어는 ${ChatColor.RESET}${ChatColor.WHITE}${
|
|
||||||
Bukkit.getPlayer(
|
|
||||||
list.second!!
|
|
||||||
)!!.name
|
|
||||||
}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다!"
|
|
||||||
)
|
|
||||||
e.isCancelled = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
plugin.instance.list[e.entity.uniqueId] = Triple(true,e.damager.uniqueId,System.currentTimeMillis())
|
|
||||||
plugin.instance.list[e.damager.uniqueId] = Triple(true,e.entity.uniqueId,System.currentTimeMillis())
|
|
||||||
if(combatData.instance.getCanSeeWorld(e.entity.world.name) && !plugin.instance.list[e.entity.uniqueId]!!.first){
|
|
||||||
Bukkit.getOnlinePlayers().forEach {
|
|
||||||
if(it.name != e.entity.name && it.name != e.damager.name){
|
|
||||||
it.hidePlayer(plugin,e.entity as Player)
|
|
||||||
it.hidePlayer(plugin,e.damager as Player)
|
|
||||||
(e.entity as Player).hidePlayer(plugin,it)
|
|
||||||
(e.damager as Player).hidePlayer(plugin, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
fun onArrow(e:ProjectileHitEvent){
|
|
||||||
if(e.hitEntity == null) return
|
|
||||||
if(e.hitEntity!!.type != EntityType.PLAYER) return
|
|
||||||
if(e.entity.shooter !is Player) return
|
|
||||||
if(!combatData.instance.getUseWorld(e.entity.world.name)) return
|
|
||||||
val team = Bukkit.getServer().scoreboardManager.mainScoreboard.teams
|
|
||||||
lateinit var plteam: Team
|
|
||||||
team.forEach { if(it.hasPlayer(Bukkit.getOfflinePlayer(e.entity.name))) plteam = it }
|
|
||||||
if(plteam.hasPlayer(Bukkit.getOfflinePlayer((e.entity.shooter as Player).name))){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val player = e.hitEntity as Player
|
|
||||||
val shooter = e.entity.shooter as Player
|
|
||||||
val list = plugin.instance.list[player.uniqueId]
|
|
||||||
val dlist = plugin.instance.list[shooter.uniqueId]
|
|
||||||
if((dlist?.second != null) && (dlist.second != player.uniqueId)&&!combatData.instance.getOtherHit(shooter.world.name)){ e.isCancelled = true;return}
|
|
||||||
if(list?.second != null && list.second != shooter.uniqueId && !combatData.instance.getOtherHit(shooter.world.name)) {
|
|
||||||
shooter.sendMessage("${ChatColor.RED}${ChatColor.BOLD}해당 플레이어는 ${ChatColor.RESET}${ChatColor.WHITE}${Bukkit.getPlayer(
|
|
||||||
list.second!!)!!.name}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다!")
|
|
||||||
e.isCancelled = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if(player.uniqueId == shooter.uniqueId) return
|
|
||||||
if(combatData.instance.getCanSeeWorld(player.world.name) && !plugin.instance.list[player.uniqueId]!!.first){
|
|
||||||
Bukkit.getOnlinePlayers().forEach {
|
|
||||||
if(it.name != player.name && it.name != shooter.name){
|
|
||||||
it.hidePlayer(plugin, player)
|
|
||||||
it.hidePlayer(plugin,shooter)
|
|
||||||
player.hidePlayer(plugin,it)
|
|
||||||
shooter.hidePlayer(plugin, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.instance.list[player.uniqueId] = Triple(true,shooter.uniqueId,System.currentTimeMillis())
|
|
||||||
plugin.instance.list[shooter.uniqueId] = Triple(true,player.uniqueId,System.currentTimeMillis())
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
fun onCommand(e:PlayerCommandPreprocessEvent){
|
|
||||||
if(listOf("/l","/lobby","/home","/spawn").any { e.message == it }){
|
|
||||||
val list = plugin.instance.list[e.player.uniqueId] ?: return
|
|
||||||
if(!list.first) return
|
|
||||||
e.isCancelled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
fun onQuit(e:PlayerQuitEvent){
|
|
||||||
val list = plugin.instance.list[e.player.uniqueId] ?: return
|
|
||||||
if(!list.first) return
|
|
||||||
e.player.killer = Bukkit.getPlayer(list.second!!)
|
|
||||||
Bukkit.dispatchCommand(,)
|
|
||||||
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
|
||||||
Bukkit.getOnlinePlayers().forEach {
|
|
||||||
val player = e.player
|
|
||||||
val killer = e.player.killer!!
|
|
||||||
if(it.name != player.name && it.name != killer.name){
|
|
||||||
it.showPlayer(plugin, player)
|
|
||||||
it.showPlayer(plugin,killer)
|
|
||||||
player.showPlayer(plugin,it)
|
|
||||||
killer.showPlayer(plugin, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.instance.list.remove(e.player.uniqueId)
|
|
||||||
plugin.instance.list.remove(list.second!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
fun onDeath(e:PlayerDeathEvent){
|
|
||||||
val list = plugin.instance.list[e.player.uniqueId] ?: return
|
|
||||||
if(!list.first) return
|
|
||||||
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
|
||||||
Bukkit.getOnlinePlayers().forEach {
|
|
||||||
val player = e.player
|
|
||||||
val killer = e.player.killer!!
|
|
||||||
if(it.name != player.name && it.name != killer.name){
|
|
||||||
it.showPlayer(plugin, player)
|
|
||||||
it.showPlayer(plugin,killer)
|
|
||||||
player.showPlayer(plugin,it)
|
|
||||||
killer.showPlayer(plugin, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.instance.list.remove(e.player.uniqueId)
|
|
||||||
plugin.instance.list.remove(list.second!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
fun onChangeWorld(e:PlayerChangedWorldEvent){
|
|
||||||
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
|
||||||
Bukkit.getOnlinePlayers().forEach{
|
|
||||||
if(it.world.name != e.player.world.name) return@forEach
|
|
||||||
if(plugin.instance.list[it.uniqueId]?.first == true){
|
|
||||||
it.hidePlayer(plugin,e.player)
|
|
||||||
e.player.hidePlayer(plugin,it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
27
src/main/kotlin/me/faiz/combat_f/Main.kt
Normal file
27
src/main/kotlin/me/faiz/combat_f/Main.kt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package me.faiz.combat_f
|
||||||
|
|
||||||
|
import me.faiz.combat_f.cmd.MainCommand
|
||||||
|
import me.faiz.combat_f.data.MainData
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
|
||||||
|
class Main:JavaPlugin() {
|
||||||
|
|
||||||
|
init{
|
||||||
|
instance = this
|
||||||
|
}
|
||||||
|
|
||||||
|
private val maindata by lazy { MainData(this) }
|
||||||
|
|
||||||
|
override fun onDisable() {
|
||||||
|
maindata.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEnable() {
|
||||||
|
MainCommand(this,maindata)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
lateinit var instance: Main
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
src/main/kotlin/me/faiz/combat_f/cmd/MainCommand.kt
Normal file
27
src/main/kotlin/me/faiz/combat_f/cmd/MainCommand.kt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package me.faiz.combat_f.cmd
|
||||||
|
|
||||||
|
import io.github.monun.kommand.kommand
|
||||||
|
import me.faiz.combat_f.Main
|
||||||
|
import me.faiz.combat_f.data.MainData
|
||||||
|
import me.faiz.combat_f.handler.MainHandler
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
class MainCommand(private val main: Main,private val data: MainData) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
main.apply {
|
||||||
|
kommand {
|
||||||
|
register("combat") {
|
||||||
|
requires { isOp }
|
||||||
|
executes {
|
||||||
|
if(sender !is Player) {
|
||||||
|
sender.sendMessage("This command can use Player! \n Please use another command!")
|
||||||
|
return@executes
|
||||||
|
}else MainHandler(sender as Player,data,main)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
src/main/kotlin/me/faiz/combat_f/data/MainData.kt
Normal file
33
src/main/kotlin/me/faiz/combat_f/data/MainData.kt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package me.faiz.combat_f.data
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration
|
||||||
|
import org.bukkit.plugin.Plugin
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class MainData(private val plugin:Plugin) {
|
||||||
|
private val file get() = File(plugin.dataFolder,"data.yml")
|
||||||
|
private val yaml = YamlConfiguration.loadConfiguration(file)
|
||||||
|
|
||||||
|
fun getUseWorld(uid:String):Boolean{
|
||||||
|
return yaml.getBoolean("$uid.use")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setUseWorld(uid:String,boolean: Boolean){
|
||||||
|
yaml.set("$uid.use",boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTimeWorld(uid:String):Int{
|
||||||
|
return if(yaml.getInt("$uid.time") == 0) -1 else yaml.getInt("$uid.time")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setTimeWorld(uid:String,time:Int){
|
||||||
|
yaml.set("$uid.time",time)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun save(){
|
||||||
|
yaml.save(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
120
src/main/kotlin/me/faiz/combat_f/handler/MainHandler.kt
Normal file
120
src/main/kotlin/me/faiz/combat_f/handler/MainHandler.kt
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
package me.faiz.combat_f.handler
|
||||||
|
|
||||||
|
import io.github.monun.invfx.InvFX
|
||||||
|
import io.github.monun.invfx.openFrame
|
||||||
|
import me.faiz.combat_f.Main
|
||||||
|
import me.faiz.combat_f.data.MainData
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.format.TextColor
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta
|
||||||
|
import org.bukkit.potion.PotionEffect
|
||||||
|
import org.bukkit.potion.PotionEffectType
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable
|
||||||
|
|
||||||
|
class MainHandler(pl: Player, private val data: MainData, main: Main) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
// 메인 프레임 설정
|
||||||
|
val mFr = InvFX.frame(3, Component.text("컴뱃 GUI").decorate(TextDecoration.BOLD)){
|
||||||
|
// 기초 아이템 설정
|
||||||
|
val useCombat = makeItem(Material.GRASS_BLOCK,"맵 선택").apply {
|
||||||
|
editMeta {
|
||||||
|
it.lore(listOf(Component.text("월드마다 컴뱃 사용 여부를 선택할 수 있습니다.")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val setTime = makeItem(Material.CLOCK,"시간 지정").apply {
|
||||||
|
editMeta{
|
||||||
|
it.lore(listOf(Component.text("월드마다 컴뱃 시간을 지정할 수 있습니다.")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val hitOther = makeItem(Material.DIAMOND_SWORD,"다중 공격").apply {
|
||||||
|
editMeta{
|
||||||
|
it.lore(listOf(Component.text("컴뱃 중 다른사람의 개입을 허용/비허용을 지정할 수 있습니다.")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150)),
|
||||||
|
Component.text("월드 마다 지정 할 수 있습니다.")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val visible = makeItem(Material.POTION,"전투 투시성").apply{
|
||||||
|
editMeta{
|
||||||
|
it.lore(listOf(Component.text("컴뱃 중 다른 사람 숨김/표시를 지정할 수 있습니다.")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150)),
|
||||||
|
Component.text("월드 마다 지정 할 수 있습니다.")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))))
|
||||||
|
(it as PotionMeta).addCustomEffect(PotionEffect(PotionEffectType.INVISIBILITY,-1,0,false,false,true),true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 아이템 설정
|
||||||
|
item(1,1,useCombat)
|
||||||
|
item(3,1,setTime)
|
||||||
|
item(5,1,hitOther)
|
||||||
|
item(7,1,visible)
|
||||||
|
|
||||||
|
// 이벤트 설정
|
||||||
|
slot(1,1){
|
||||||
|
onClick {
|
||||||
|
it.whoClicked.closeInventory()
|
||||||
|
object: BukkitRunnable() {
|
||||||
|
override fun run() {
|
||||||
|
UseHandler(it.whoClicked as Player,data)
|
||||||
|
}
|
||||||
|
}.runTaskLater(main,1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
slot(3,1){
|
||||||
|
onClick {
|
||||||
|
it.whoClicked.closeInventory()
|
||||||
|
object: BukkitRunnable(){
|
||||||
|
override fun run() {
|
||||||
|
TimeHandler(it.whoClicked as Player,data,main)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
pl.openFrame(mFr)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 아이템 생성 함수
|
||||||
|
private fun makeItem(material:Material,name:String,color:TextColor = TextColor.color(255,255,255)):ItemStack{
|
||||||
|
val item = ItemStack(material)
|
||||||
|
val itemMeta = item.itemMeta
|
||||||
|
itemMeta.displayName(Component.text(name)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(color)
|
||||||
|
)
|
||||||
|
item.itemMeta = itemMeta
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
//private fun makeItem(item:ItemStack,name:String,color:TextColor = TextColor.color(255,255,255)):ItemStack {
|
||||||
|
// val itemMeta = item.itemMeta
|
||||||
|
// itemMeta.displayName(
|
||||||
|
// Component.text(name)
|
||||||
|
// .decorate(TextDecoration.BOLD)
|
||||||
|
// .decoration(TextDecoration.ITALIC, false)
|
||||||
|
// .color(color)
|
||||||
|
// )
|
||||||
|
// item.itemMeta = itemMeta
|
||||||
|
// return item
|
||||||
|
//}
|
32
src/main/kotlin/me/faiz/combat_f/handler/TimeHandler.kt
Normal file
32
src/main/kotlin/me/faiz/combat_f/handler/TimeHandler.kt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package me.faiz.combat_f.handler
|
||||||
|
|
||||||
|
import io.github.monun.invfx.InvFX
|
||||||
|
import me.faiz.combat_f.Main
|
||||||
|
import me.faiz.combat_f.data.MainData
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.World
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
|
class TimeHandler(pl: Player, data: MainData, main: Main) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
val tFr = InvFX.frame(6, Component.text("컴뱃 GUI - 시간 설정")){
|
||||||
|
var count = 0
|
||||||
|
Bukkit.getWorlds().forEach {
|
||||||
|
val worldTime = data.getTimeWorld(it.uid.toString())
|
||||||
|
val item = ItemStack(Material.AIR)
|
||||||
|
when(it.environment){
|
||||||
|
World.Environment.NORMAL -> item.type = Material.GRASS_BLOCK
|
||||||
|
World.Environment.NETHER -> item.type = Material.NETHERRACK
|
||||||
|
World.Environment.THE_END -> item.type = Material.END_STONE
|
||||||
|
World.Environment.CUSTOM -> item.type = Material.NETHER_PORTAL
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
105
src/main/kotlin/me/faiz/combat_f/handler/UseHandler.kt
Normal file
105
src/main/kotlin/me/faiz/combat_f/handler/UseHandler.kt
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package me.faiz.combat_f.handler
|
||||||
|
|
||||||
|
import io.github.monun.invfx.InvFX
|
||||||
|
import io.github.monun.invfx.openFrame
|
||||||
|
import me.faiz.combat_f.Main
|
||||||
|
import me.faiz.combat_f.data.MainData
|
||||||
|
import net.kyori.adventure.key.Key
|
||||||
|
import net.kyori.adventure.sound.Sound
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.format.TextColor
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
|
class UseHandler(pl: Player, data: MainData) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
val uFr = InvFX.frame(6, Component.text("컴뱃 GUI - 맵 선택").decorate(TextDecoration.BOLD)){
|
||||||
|
var count = 0
|
||||||
|
Bukkit.getWorlds().forEach {
|
||||||
|
val useWorld = data.getUseWorld(it.uid.toString())
|
||||||
|
val item = ItemStack(Material.AIR)
|
||||||
|
when(it.environment.name){
|
||||||
|
"NORMAL" -> item.type = Material.GRASS_BLOCK
|
||||||
|
"NETHER" -> item.type = Material.NETHERRACK
|
||||||
|
"THE_END" -> item.type = Material.END_STONE
|
||||||
|
}
|
||||||
|
item.apply {
|
||||||
|
editMeta {item ->
|
||||||
|
item.displayName(Component.text(it.name).decoration(TextDecoration.ITALIC,false))
|
||||||
|
item.lore(listOf(Component.text("컴뱃 : ")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))
|
||||||
|
.append(if(useWorld) Component.text("사용중")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.color(TextColor.color(0,255,0))
|
||||||
|
else Component.text("사용안함")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.color(TextColor.color(255,0,0))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count == 0){
|
||||||
|
item(0,0,item)
|
||||||
|
slot(0,0){
|
||||||
|
onClick {e ->
|
||||||
|
e.whoClicked.playSound(Sound.sound(Key.key("entity.experience_orb.pickup"),Sound.Source.MASTER,1f,1f))
|
||||||
|
data.setUseWorld(it.uid.toString(),!data.getUseWorld(it.uid.toString()))
|
||||||
|
// main.logger.info(data.getUseWorld(it.uid.toString()).toString())
|
||||||
|
item.editMeta{item ->
|
||||||
|
item.lore(listOf(Component.text("컴뱃 : ")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))
|
||||||
|
.append(if(data.getUseWorld(it.uid.toString())) Component.text("사용중")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.color(TextColor.color(0,255,0))
|
||||||
|
else Component.text("사용안함")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.color(TextColor.color(255,0,0))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
this.item = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
item(count%9, (count/9),item)
|
||||||
|
slot(count%9,count/9){
|
||||||
|
onClick { e ->
|
||||||
|
e.whoClicked.playSound(Sound.sound(Key.key("entity.experience_orb.pickup"),Sound.Source.MASTER,1f,1f))
|
||||||
|
data.setUseWorld(it.uid.toString(),!data.getUseWorld(it.uid.toString()))
|
||||||
|
// main.logger.info(data.getUseWorld(it.uid.toString()).toString())
|
||||||
|
item.editMeta{item ->
|
||||||
|
item.lore(listOf(Component.text("컴뱃 : ")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.color(TextColor.color(150,150,150))
|
||||||
|
.append(if(data.getUseWorld(it.uid.toString())) Component.text("사용중")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.color(TextColor.color(0,255,0))
|
||||||
|
else Component.text("사용안함")
|
||||||
|
.decoration(TextDecoration.ITALIC,false)
|
||||||
|
.decorate(TextDecoration.BOLD)
|
||||||
|
.color(TextColor.color(255,0,0))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
this.item = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pl.openFrame(uFr)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
name: Combat
|
name: Combat
|
||||||
version: 1.0.2
|
version: 2.0.0
|
||||||
main: group.pvpconnect.combat_f.Main
|
main: me.faiz.combat_f.Main
|
||||||
api-version: 1.19
|
api-version: "1.20"
|
||||||
author: faiz
|
author: faiz
|
||||||
libraries:
|
libraries:
|
||||||
|
- org.jetbrains.kotlin:kotlin-stdlib:2.0.0-Beta4
|
||||||
- io.github.monun:kommand-core:3.1.7
|
- io.github.monun:kommand-core:3.1.7
|
||||||
|
- io.github.monun:invfx-core:3.3.2
|
Loading…
Reference in New Issue
Block a user