😭 Tcoww -> Tcoww.instance
All checks were successful
Auto Build / Build (push) Successful in 4m26s

This commit is contained in:
2025-11-30 19:04:28 +01:00
parent 25804f76e0
commit d6103b078b
13 changed files with 37 additions and 27 deletions

View File

@@ -52,8 +52,8 @@ tasks {
runServer { runServer {
downloadPlugins { downloadPlugins {
modrinth("skinsrestorer", skinRestorerVersion) modrinth("skinsrestorer", skinRestorerVersion)
modrinth("luckperms", luckPermsVersion) modrinth("luckperms", "v$luckPermsVersion-bukkit")
modrinth("simple-voice-chat", voiceChatVersion) modrinth("simple-voice-chat", "bukkit-$voiceChatVersion")
} }
minecraftVersion(minecraftVersion) minecraftVersion(minecraftVersion)
} }

View File

@@ -19,7 +19,11 @@ import org.bukkit.configuration.serialization.ConfigurationSerialization
import org.bukkit.plugin.java.JavaPlugin import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.scoreboard.Team import org.bukkit.scoreboard.Team
object Tcoww : JavaPlugin() { class Tcoww : JavaPlugin() {
init {
instance = this
}
override fun onEnable() { override fun onEnable() {
ConfigurationSerialization.registerClass(WerewolfSkin::class.java) ConfigurationSerialization.registerClass(WerewolfSkin::class.java)
@@ -61,4 +65,8 @@ object Tcoww : JavaPlugin() {
Role.registerRole(Hunter) Role.registerRole(Hunter)
Role.registerRole(Witch) Role.registerRole(Witch)
} }
companion object {
lateinit var instance: Tcoww
}
} }

View File

@@ -1,15 +1,17 @@
package fr.azur.tcoww.commands package fr.azur.tcoww.commands
import com.mojang.brigadier.Command import com.mojang.brigadier.Command
import com.mojang.brigadier.tree.LiteralCommandNode
import fr.azur.tcoww.game.Game import fr.azur.tcoww.game.Game
import fr.azur.tcoww.utils.Players.kill import fr.azur.tcoww.utils.Players.kill
import io.papermc.paper.command.brigadier.CommandSourceStack
import io.papermc.paper.command.brigadier.Commands import io.papermc.paper.command.brigadier.Commands
import io.papermc.paper.command.brigadier.argument.ArgumentTypes import io.papermc.paper.command.brigadier.argument.ArgumentTypes
import io.papermc.paper.command.brigadier.argument.resolvers.PlayerProfileListResolver import io.papermc.paper.command.brigadier.argument.resolvers.PlayerProfileListResolver
import org.bukkit.Bukkit import org.bukkit.Bukkit
object Exclude { object Exclude {
val root = val root: LiteralCommandNode<CommandSourceStack> =
Commands Commands
.literal("exclude") .literal("exclude")
.requires { sender -> .requires { sender ->

View File

@@ -75,7 +75,7 @@ object GameCommand {
val menu = GameConfig(players.size) val menu = GameConfig(players.size)
executor.openInventory(menu.inventory) executor.openInventory(menu.inventory)
menu.future.thenAccept { menu.future.thenAccept {
val dialog = createDialog(Tcoww, executor.world, players, it) val dialog = createDialog(Tcoww.instance, executor.world, players, it)
executor.showDialog(dialog) executor.showDialog(dialog)
} }
} }

View File

@@ -48,9 +48,9 @@ object GameEvents : Listener {
if (current.timeGestion.phase == NightLightCycle.Phase.NIGHT) { if (current.timeGestion.phase == NightLightCycle.Phase.NIGHT) {
backLocation[player.uniqueId] = player.location backLocation[player.uniqueId] = player.location
val lobby = Tcoww.config.getLocation("lobby-location") val lobby = Tcoww.instance.config.getLocation("lobby-location")
Bukkit.getScheduler().runTaskLater( Bukkit.getScheduler().runTaskLater(
Tcoww, Tcoww.instance,
Runnable { Runnable {
if (lobby != null) { if (lobby != null) {
player.teleport(lobby) player.teleport(lobby)

View File

@@ -85,7 +85,7 @@ object PhaseEvents : Listener {
Bukkit.getPlayer(uuid)?.let { votedPlayer -> Bukkit.getPlayer(uuid)?.let { votedPlayer ->
votedPlayer.fireTicks = 1200 votedPlayer.fireTicks = 1200
Bukkit.getScheduler().runTaskLater( Bukkit.getScheduler().runTaskLater(
Tcoww, Tcoww.instance,
Runnable { Runnable {
votedPlayer.health = 0.0 votedPlayer.health = 0.0
}, },
@@ -118,7 +118,7 @@ object PhaseEvents : Listener {
} }
Bukkit.getScheduler().runTaskLater( Bukkit.getScheduler().runTaskLater(
Tcoww, Tcoww.instance,
Runnable { Runnable {
val openBed = val openBed =
current.beds current.beds
@@ -148,7 +148,7 @@ object PhaseEvents : Listener {
} }
} }
}, },
Tcoww.config.getLong("player-sleep"), Tcoww.instance.config.getLong("player-sleep"),
) )
} }

View File

@@ -28,7 +28,7 @@ object ToolsEvents : Listener {
if (interactLoc != null) { if (interactLoc != null) {
if (interactLoc.block.isBed()) { if (interactLoc.block.isBed()) {
val list = val list =
Tcoww.config Tcoww.instance.config
.getList("bed-locations") .getList("bed-locations")
.orEmpty() .orEmpty()
.mapNotNull { it as? Location } .mapNotNull { it as? Location }
@@ -38,8 +38,8 @@ object ToolsEvents : Listener {
if (!list.contains(block.location)) { if (!list.contains(block.location)) {
list.add(block.location) list.add(block.location)
Tcoww.config.set("bed-locations", list) Tcoww.instance.config.set("bed-locations", list)
Tcoww.saveConfig() Tcoww.instance.saveConfig()
event.player.sendMessage( event.player.sendMessage(
Component.text("Bed location add.", NamedTextColor.LIGHT_PURPLE), Component.text("Bed location add.", NamedTextColor.LIGHT_PURPLE),
) )
@@ -63,8 +63,8 @@ object ToolsEvents : Listener {
interactLoc.x = interactLoc.blockX.toDouble() interactLoc.x = interactLoc.blockX.toDouble()
interactLoc.y = interactLoc.blockY.toDouble() + 1 interactLoc.y = interactLoc.blockY.toDouble() + 1
interactLoc.z = interactLoc.blockZ.toDouble() interactLoc.z = interactLoc.blockZ.toDouble()
Tcoww.config.set("spawn-location", interactLoc) Tcoww.instance.config.set("spawn-location", interactLoc)
Tcoww.saveConfig() Tcoww.instance.saveConfig()
event.player.sendMessage(Component.text("Spawn location set.", NamedTextColor.LIGHT_PURPLE)) event.player.sendMessage(Component.text("Spawn location set.", NamedTextColor.LIGHT_PURPLE))
} }
} }
@@ -76,8 +76,8 @@ object ToolsEvents : Listener {
interactLoc.x = interactLoc.blockX.toDouble() interactLoc.x = interactLoc.blockX.toDouble()
interactLoc.y = interactLoc.blockY.toDouble() + 1 interactLoc.y = interactLoc.blockY.toDouble() + 1
interactLoc.z = interactLoc.blockZ.toDouble() interactLoc.z = interactLoc.blockZ.toDouble()
Tcoww.config.set("lobby-location", interactLoc) Tcoww.instance.config.set("lobby-location", interactLoc)
Tcoww.saveConfig() Tcoww.instance.saveConfig()
event.player.sendMessage(Component.text("Lobby location set.", NamedTextColor.LIGHT_PURPLE)) event.player.sendMessage(Component.text("Lobby location set.", NamedTextColor.LIGHT_PURPLE))
} }
} }

View File

@@ -25,7 +25,7 @@ class Game(
val timeGestion: NightLightCycle val timeGestion: NightLightCycle
val remainingPlayer = players.toMutableList() val remainingPlayer = players.toMutableList()
val beds = val beds =
Tcoww.config Tcoww.instance.config
.getList("bed-locations") .getList("bed-locations")
.orEmpty() .orEmpty()
.mapNotNull { it as? Location } .mapNotNull { it as? Location }

View File

@@ -27,6 +27,6 @@ object Werewolf : Role {
override fun handle(player: Player) { override fun handle(player: Player) {
val tfItem = CustomItems.WereWolfTransformItem.item val tfItem = CustomItems.WereWolfTransformItem.item
player.inventory.addItem(tfItem) player.inventory.addItem(tfItem)
player.setCooldown(tfItem, ((Tcoww.config.getInt("duration.day") + Tcoww.config.getInt("duration.day")) * 20)) player.setCooldown(tfItem, ((Tcoww.instance.config.getInt("duration.day") + Tcoww.instance.config.getInt("duration.day")) * 20))
} }
} }

View File

@@ -22,14 +22,14 @@ class GameConfig(
val future = CompletableFuture<Map<NamespacedKey, Int>>() val future = CompletableFuture<Map<NamespacedKey, Int>>()
private val inventory = private val inventory =
Tcoww.server.createInventory(this, size, Component.text("Game Config.", NamedTextColor.GREEN)).apply { Tcoww.instance.server.createInventory(this, size, Component.text("Game Config.", NamedTextColor.GREEN)).apply {
Role.registerRoles.values.sortedBy { it.order }.onEachIndexed { index, role -> Role.registerRoles.values.sortedBy { it.order }.onEachIndexed { index, role ->
setItem(index, createItem(index, role)) setItem(index, createItem(index, role))
} }
} }
init { init {
val werewolfCount = ceil((playerCount * (Tcoww.config.getInt("werewolf-default-percentage") / 100f))).toInt() val werewolfCount = ceil((playerCount * (Tcoww.instance.config.getInt("werewolf-default-percentage") / 100f))).toInt()
editItem(0, playerCount - werewolfCount) editItem(0, playerCount - werewolfCount)
editItem(1, werewolfCount) editItem(1, werewolfCount)
} }

View File

@@ -19,7 +19,7 @@ class PlayerSelectMenu(
val future = CompletableFuture<Player?>() val future = CompletableFuture<Player?>()
private val inventory = private val inventory =
Tcoww.server.createInventory(this, size, Component.text("Select a player.", NamedTextColor.GREEN)).apply { Tcoww.instance.server.createInventory(this, size, Component.text("Select a player.", NamedTextColor.GREEN)).apply {
players.forEachIndexed { index, player -> players.forEachIndexed { index, player ->
val item = val item =
ItemStack.of(Material.PLAYER_HEAD).apply { ItemStack.of(Material.PLAYER_HEAD).apply {

View File

@@ -4,8 +4,8 @@ import fr.azur.tcoww.Tcoww
import org.bukkit.NamespacedKey import org.bukkit.NamespacedKey
data object DataKeys { data object DataKeys {
val PlayerDead = NamespacedKey(Tcoww, "dead") val PlayerDead = NamespacedKey(Tcoww.instance, "dead")
val PowerItems = NamespacedKey(Tcoww, "power") val PowerItems = NamespacedKey(Tcoww.instance, "power")
val Insomnia = NamespacedKey(Tcoww, "insomnia") val Insomnia = NamespacedKey(Tcoww.instance, "insomnia")
val ToolsItems = NamespacedKey(Tcoww, "tools") val ToolsItems = NamespacedKey(Tcoww.instance, "tools")
} }

View File

@@ -23,7 +23,7 @@ object Manager {
fun reloadSkin() { fun reloadSkin() {
val skinsValue = val skinsValue =
Tcoww.config Tcoww.instance.config
.getList("werewolf-skins") .getList("werewolf-skins")
.orEmpty() .orEmpty()
.mapNotNull { it as? WerewolfSkin } .mapNotNull { it as? WerewolfSkin }