This commit is contained in:
@@ -19,7 +19,11 @@ import org.bukkit.configuration.serialization.ConfigurationSerialization
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
import org.bukkit.scoreboard.Team
|
||||
|
||||
object Tcoww : JavaPlugin() {
|
||||
class Tcoww : JavaPlugin() {
|
||||
init {
|
||||
instance = this
|
||||
}
|
||||
|
||||
override fun onEnable() {
|
||||
ConfigurationSerialization.registerClass(WerewolfSkin::class.java)
|
||||
|
||||
@@ -61,4 +65,8 @@ object Tcoww : JavaPlugin() {
|
||||
Role.registerRole(Hunter)
|
||||
Role.registerRole(Witch)
|
||||
}
|
||||
|
||||
companion object {
|
||||
lateinit var instance: Tcoww
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package fr.azur.tcoww.commands
|
||||
|
||||
import com.mojang.brigadier.Command
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode
|
||||
import fr.azur.tcoww.game.Game
|
||||
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.argument.ArgumentTypes
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.PlayerProfileListResolver
|
||||
import org.bukkit.Bukkit
|
||||
|
||||
object Exclude {
|
||||
val root =
|
||||
val root: LiteralCommandNode<CommandSourceStack> =
|
||||
Commands
|
||||
.literal("exclude")
|
||||
.requires { sender ->
|
||||
|
||||
@@ -75,7 +75,7 @@ object GameCommand {
|
||||
val menu = GameConfig(players.size)
|
||||
executor.openInventory(menu.inventory)
|
||||
menu.future.thenAccept {
|
||||
val dialog = createDialog(Tcoww, executor.world, players, it)
|
||||
val dialog = createDialog(Tcoww.instance, executor.world, players, it)
|
||||
executor.showDialog(dialog)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ object GameEvents : Listener {
|
||||
|
||||
if (current.timeGestion.phase == NightLightCycle.Phase.NIGHT) {
|
||||
backLocation[player.uniqueId] = player.location
|
||||
val lobby = Tcoww.config.getLocation("lobby-location")
|
||||
val lobby = Tcoww.instance.config.getLocation("lobby-location")
|
||||
Bukkit.getScheduler().runTaskLater(
|
||||
Tcoww,
|
||||
Tcoww.instance,
|
||||
Runnable {
|
||||
if (lobby != null) {
|
||||
player.teleport(lobby)
|
||||
|
||||
@@ -85,7 +85,7 @@ object PhaseEvents : Listener {
|
||||
Bukkit.getPlayer(uuid)?.let { votedPlayer ->
|
||||
votedPlayer.fireTicks = 1200
|
||||
Bukkit.getScheduler().runTaskLater(
|
||||
Tcoww,
|
||||
Tcoww.instance,
|
||||
Runnable {
|
||||
votedPlayer.health = 0.0
|
||||
},
|
||||
@@ -118,7 +118,7 @@ object PhaseEvents : Listener {
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(
|
||||
Tcoww,
|
||||
Tcoww.instance,
|
||||
Runnable {
|
||||
val openBed =
|
||||
current.beds
|
||||
@@ -148,7 +148,7 @@ object PhaseEvents : Listener {
|
||||
}
|
||||
}
|
||||
},
|
||||
Tcoww.config.getLong("player-sleep"),
|
||||
Tcoww.instance.config.getLong("player-sleep"),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ object ToolsEvents : Listener {
|
||||
if (interactLoc != null) {
|
||||
if (interactLoc.block.isBed()) {
|
||||
val list =
|
||||
Tcoww.config
|
||||
Tcoww.instance.config
|
||||
.getList("bed-locations")
|
||||
.orEmpty()
|
||||
.mapNotNull { it as? Location }
|
||||
@@ -38,8 +38,8 @@ object ToolsEvents : Listener {
|
||||
|
||||
if (!list.contains(block.location)) {
|
||||
list.add(block.location)
|
||||
Tcoww.config.set("bed-locations", list)
|
||||
Tcoww.saveConfig()
|
||||
Tcoww.instance.config.set("bed-locations", list)
|
||||
Tcoww.instance.saveConfig()
|
||||
event.player.sendMessage(
|
||||
Component.text("Bed location add.", NamedTextColor.LIGHT_PURPLE),
|
||||
)
|
||||
@@ -63,8 +63,8 @@ object ToolsEvents : Listener {
|
||||
interactLoc.x = interactLoc.blockX.toDouble()
|
||||
interactLoc.y = interactLoc.blockY.toDouble() + 1
|
||||
interactLoc.z = interactLoc.blockZ.toDouble()
|
||||
Tcoww.config.set("spawn-location", interactLoc)
|
||||
Tcoww.saveConfig()
|
||||
Tcoww.instance.config.set("spawn-location", interactLoc)
|
||||
Tcoww.instance.saveConfig()
|
||||
event.player.sendMessage(Component.text("Spawn location set.", NamedTextColor.LIGHT_PURPLE))
|
||||
}
|
||||
}
|
||||
@@ -76,8 +76,8 @@ object ToolsEvents : Listener {
|
||||
interactLoc.x = interactLoc.blockX.toDouble()
|
||||
interactLoc.y = interactLoc.blockY.toDouble() + 1
|
||||
interactLoc.z = interactLoc.blockZ.toDouble()
|
||||
Tcoww.config.set("lobby-location", interactLoc)
|
||||
Tcoww.saveConfig()
|
||||
Tcoww.instance.config.set("lobby-location", interactLoc)
|
||||
Tcoww.instance.saveConfig()
|
||||
event.player.sendMessage(Component.text("Lobby location set.", NamedTextColor.LIGHT_PURPLE))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Game(
|
||||
val timeGestion: NightLightCycle
|
||||
val remainingPlayer = players.toMutableList()
|
||||
val beds =
|
||||
Tcoww.config
|
||||
Tcoww.instance.config
|
||||
.getList("bed-locations")
|
||||
.orEmpty()
|
||||
.mapNotNull { it as? Location }
|
||||
|
||||
@@ -27,6 +27,6 @@ object Werewolf : Role {
|
||||
override fun handle(player: Player) {
|
||||
val tfItem = CustomItems.WereWolfTransformItem.item
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ class GameConfig(
|
||||
val future = CompletableFuture<Map<NamespacedKey, Int>>()
|
||||
|
||||
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 ->
|
||||
setItem(index, createItem(index, role))
|
||||
}
|
||||
}
|
||||
|
||||
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(1, werewolfCount)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class PlayerSelectMenu(
|
||||
val future = CompletableFuture<Player?>()
|
||||
|
||||
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 ->
|
||||
val item =
|
||||
ItemStack.of(Material.PLAYER_HEAD).apply {
|
||||
|
||||
@@ -4,8 +4,8 @@ import fr.azur.tcoww.Tcoww
|
||||
import org.bukkit.NamespacedKey
|
||||
|
||||
data object DataKeys {
|
||||
val PlayerDead = NamespacedKey(Tcoww, "dead")
|
||||
val PowerItems = NamespacedKey(Tcoww, "power")
|
||||
val Insomnia = NamespacedKey(Tcoww, "insomnia")
|
||||
val ToolsItems = NamespacedKey(Tcoww, "tools")
|
||||
val PlayerDead = NamespacedKey(Tcoww.instance, "dead")
|
||||
val PowerItems = NamespacedKey(Tcoww.instance, "power")
|
||||
val Insomnia = NamespacedKey(Tcoww.instance, "insomnia")
|
||||
val ToolsItems = NamespacedKey(Tcoww.instance, "tools")
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ object Manager {
|
||||
|
||||
fun reloadSkin() {
|
||||
val skinsValue =
|
||||
Tcoww.config
|
||||
Tcoww.instance.config
|
||||
.getList("werewolf-skins")
|
||||
.orEmpty()
|
||||
.mapNotNull { it as? WerewolfSkin }
|
||||
|
||||
Reference in New Issue
Block a user