Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nite の発光色をチームの色にする #122

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation("org.jetbrains.exposed:exposed-core:0.58.0")
implementation("org.jetbrains.exposed:exposed-dao:0.58.0")
implementation("org.jetbrains.exposed:exposed-jdbc:0.58.0")
implementation("fr.skytasul:glowingentities:1.4.3")
}

kotlin {
Expand Down Expand Up @@ -57,14 +58,13 @@ tasks.register("createServer") {

doLast {
File(rootDir, "server/plugins").mkdirs()
URI("https://api.papermc.io/v2/projects/paper/versions/1.21.4/builds/118/downloads/paper-1.21.4-118.jar")
.toURL().openStream().use { input ->
URI("https://api.papermc.io/v2/projects/paper/versions/1.21.4/builds/118/downloads/paper-1.21.4-118.jar").toURL()
.openStream().use { input ->
File("server/paper.jar").outputStream().use { output ->
input.copyTo(output)
}
}
File(rootDir, "build/libs/conQest.jar")
.copyTo(File(rootDir, "server/plugins/conQest.jar"), overwrite = true)
File(rootDir, "build/libs/conQest.jar").copyTo(File(rootDir, "server/plugins/conQest.jar"), overwrite = true)
File("server/eula.txt").writeText("eula=true")
}
}
9 changes: 9 additions & 0 deletions src/main/kotlin/jp/trap/conqest/Main.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jp.trap.conqest

import fr.skytasul.glowingentities.GlowingEntities
import jp.trap.conqest.commands.Commands
import jp.trap.conqest.game.Environment
import jp.trap.conqest.game.GameManager
Expand Down Expand Up @@ -30,6 +31,7 @@ class Main : JavaPlugin() {
private lateinit var tickTask: BukkitTask
private lateinit var gameTimerManager: GameTimerManager
lateinit var gameManager: GameManager
lateinit var glowingEntities: GlowingEntities
private val dbPath = dataPath.resolve("sqlite.db")

companion object {
Expand Down Expand Up @@ -83,6 +85,13 @@ class Main : JavaPlugin() {
tickTask.cancel()
Result.success(Unit)
}),
FlowTask({
glowingEntities = GlowingEntities(this)
Result.success(Unit)
}, {
glowingEntities.disable()
Result.success(Unit)
})
)
)
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/jp/trap/conqest/game/Nite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ abstract class Nite<T>(

init {
entity.customName(Component.text(name))
entity.addPotionEffect(PotionEffect(PotionEffectType.GLOWING, Int.MAX_VALUE, 1))
if (entity.getAttribute(Attribute.ATTACK_DAMAGE) == null) {
entity.registerAttribute(Attribute.ATTACK_DAMAGE)
entity.getAttribute(Attribute.ATTACK_DAMAGE)?.baseValue = damage
master.sendMessage(damage.toString())
master.sendMessage("setDamage to ${entity.getAttribute(Attribute.ATTACK_DAMAGE)?.baseValue}")
}
updateTask = plugin.server.scheduler.runTaskTimer(plugin, Runnable { state.update() }, 0, 1)
updateTask = plugin.server.scheduler.runTaskTimer(plugin, Runnable {
state.update()
team.addGlow(entity)
}, 0, 1)
}


Expand Down
38 changes: 25 additions & 13 deletions src/main/kotlin/jp/trap/conqest/game/Team.kt
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
package jp.trap.conqest.game

import jp.trap.conqest.Main
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.Material
import org.bukkit.entity.Entity
import java.util.*


class Team(val color: TeamColor) {
companion object {
val emptyTeam: Team = Team(TeamColor.GRAY)
}

private val players = mutableListOf<UUID>()

fun addPlayer(player: UUID) {
this.players.add(player)
}

fun getPlayers(): List<UUID> {
return players
}

fun addGlow(entity: Entity) {
players.forEach {
Main.instance.glowingEntities.setGlowing(entity, Bukkit.getPlayer(it), color.getChatColor())
}
}
}

enum class TeamColor {
GRAY, RED, BLUE;

fun getGlassMaterial(): Material {
return when (this) {
GRAY -> Material.GRAY_STAINED_GLASS_PANE
RED -> Material.RED_STAINED_GLASS_PANE
BLUE -> Material.BLUE_STAINED_GLASS_PANE
}
fun getGlassMaterial(): Material = when (this) {
GRAY -> Material.GRAY_STAINED_GLASS_PANE
RED -> Material.RED_STAINED_GLASS_PANE
BLUE -> Material.BLUE_STAINED_GLASS_PANE
}

fun getRGB(): Int {
return when (this) {
GRAY -> 0x7D7D73
RED -> 0x8E2121
BLUE -> 0x2D2F8F
}
fun getRGB(): Int = when (this) {
GRAY -> 0x7D7D73
RED -> 0x8E2121
BLUE -> 0x2D2F8F
}

fun getChatColor(): ChatColor = when (this) {
GRAY -> ChatColor.GRAY
RED -> ChatColor.RED
BLUE -> ChatColor.BLUE
}
}
3 changes: 2 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ description: ${description}
author: ${author}
api-version: ${apiVersion}
libraries:
- org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}
- org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}
- fr.skytasul:glowingentities:1.4.3