diff --git a/build.gradle.kts b/build.gradle.kts index 56eedf9..b06fdf4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,19 @@ plugins { kotlin("jvm") version "2.2.0-Beta1" - id("com.gradleup.shadow") version "8.3.0" - id("xyz.jpenilla.run-paper") version "2.3.1" - id("io.papermc.paperweight.userdev") version "2.0.0-beta.16" + id("com.gradleup.shadow") version "9.2.2" + id("xyz.jpenilla.run-paper") version "3.0.2" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.19" } group = "fr.azur" version = "1.0-SNAPSHOT" +val minecraftVersion: String by project +val paperVersion: String by project +val skinRestorerVersion: String by project +val voiceChatVersion: String by project +val voiceChatApiVersion: String by project + repositories { mavenCentral() gradlePluginPortal() @@ -20,16 +26,17 @@ repositories { maven("https://repo.codemc.org/repository/maven-public/") { name = "codemc" } - maven("https://repo.plasmoverse.com/releases") - maven("https://repo.plasmoverse.com/snapshots") + maven("https://maven.maxhenkel.de/repository/public") { + name = "svc" + } } dependencies { - paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") + paperweight.paperDevBundle("$minecraftVersion-$paperVersion") - compileOnly("net.skinsrestorer:skinsrestorer-api:15.6.3") - compileOnly("su.plo.voice.api:server:2.1.4") + implementation("net.skinsrestorer:skinsrestorer-api:$skinRestorerVersion") + implementation("de.maxhenkel.voicechat:voicechat-api:$voiceChatApiVersion") implementation(kotlin("stdlib-jdk8")) } @@ -42,10 +49,10 @@ kotlin { tasks { runServer { downloadPlugins { - modrinth("plasmo-voice", "spigot-2.1.4") - modrinth("skinsrestorer", "15.6.3") + modrinth("plasmo-voice", "bukkit-$voiceChatVersion") + modrinth("skinsrestorer", skinRestorerVersion) } - minecraftVersion("1.21.4") + minecraftVersion(minecraftVersion) } build { dependsOn("shadowJar") diff --git a/gradle.properties b/gradle.properties index e69de29..8121979 100644 --- a/gradle.properties +++ b/gradle.properties @@ -0,0 +1,5 @@ +paperVersion=R0.1-SNAPSHOT +minecraftVersion=1.21.8 +skinRestorerVersion=15.8.2 +voiceChatApiVersion=2.6.0 +voiceChatVersion=2.6.6 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f57a814..50fba87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1 +1 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip diff --git a/src/main/kotlin/fr/azur/tcoww/Tcoww.kt b/src/main/kotlin/fr/azur/tcoww/Tcoww.kt index 474ce87..7ea74cc 100644 --- a/src/main/kotlin/fr/azur/tcoww/Tcoww.kt +++ b/src/main/kotlin/fr/azur/tcoww/Tcoww.kt @@ -1,32 +1,32 @@ package fr.azur.tcoww +import de.maxhenkel.voicechat.api.BukkitVoicechatService import fr.azur.tcoww.events.GameEvent import fr.azur.tcoww.events.ToolsEvents -import fr.azur.tcoww.plasmovoice.addon.PlasmoAddon import fr.azur.tcoww.roles.* import fr.azur.tcoww.utils.Skin +import fr.azur.tcoww.voicechat.VoiceChatPlugin import net.skinsrestorer.api.SkinsRestorer import net.skinsrestorer.api.SkinsRestorerProvider import org.bukkit.plugin.java.JavaPlugin -import su.plo.voice.api.server.PlasmoVoiceServer class Tcoww : JavaPlugin() { private lateinit var skinsRestorer: SkinsRestorer private lateinit var skinManager: Skin - val plasmoAddon = PlasmoAddon() override fun onEnable() { saveResource("config.yml", false) saveDefaultConfig() - PlasmoVoiceServer.getAddonsLoader().load(plasmoAddon) - skinsRestorer = SkinsRestorerProvider.get() skinManager = Skin(this, skinsRestorer) server.pluginManager.registerEvents(ToolsEvents(this), this) server.pluginManager.registerEvents(GameEvent(this, skinManager), this) + val vcservice = server.servicesManager.load(BukkitVoicechatService::class.java) + vcservice?.registerPlugin(VoiceChatPlugin()) + registerRoles() } @@ -34,10 +34,9 @@ class Tcoww : JavaPlugin() { } - fun reload(withPlasmoAddon: Boolean) { + fun reload() { this.reloadConfig() skinManager.reloadSkin() - if (withPlasmoAddon) plasmoAddon.onConfigLoaded() } private fun registerRoles() { diff --git a/src/main/kotlin/fr/azur/tcoww/TcowwBootstrap.kt b/src/main/kotlin/fr/azur/tcoww/TcowwBootstrap.kt index 1294470..e05c3c2 100644 --- a/src/main/kotlin/fr/azur/tcoww/TcowwBootstrap.kt +++ b/src/main/kotlin/fr/azur/tcoww/TcowwBootstrap.kt @@ -1,5 +1,6 @@ package fr.azur.tcoww +import fr.azur.tcoww.commands.Exclude import fr.azur.tcoww.commands.Power import fr.azur.tcoww.commands.GameCommand import fr.azur.tcoww.commands.ReloadCommands @@ -19,6 +20,7 @@ class TcowwBootstrap : PluginBootstrap { commands.registrar().register(GameCommand().root.build()) commands.registrar().register(Vote().root.build()) commands.registrar().register(ReloadCommands().root.build()) + commands.registrar().register(Exclude().root.build()) } } } \ No newline at end of file diff --git a/src/main/kotlin/fr/azur/tcoww/commands/Exclude.kt b/src/main/kotlin/fr/azur/tcoww/commands/Exclude.kt new file mode 100644 index 0000000..145b77b --- /dev/null +++ b/src/main/kotlin/fr/azur/tcoww/commands/Exclude.kt @@ -0,0 +1,40 @@ +package fr.azur.tcoww.commands + +import com.mojang.brigadier.Command +import com.mojang.brigadier.builder.LiteralArgumentBuilder +import fr.azur.tcoww.game.Game +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 +import org.bukkit.GameMode + +class Exclude { + val root: LiteralArgumentBuilder = Commands.literal("exclude") + .requires { sender -> + sender.sender.isOp + }.then( + Commands.literal("start") + .then( + Commands.argument("players", ArgumentTypes.playerProfiles()).executes { ctx -> + val targetResolver = ctx.getArgument("players", PlayerProfileListResolver::class.java) + val target = targetResolver.resolve(ctx.source).first() + val uuid = target.id + if (uuid != null) { + val player = Bukkit.getPlayer(uuid) + if (player != null) { + val game = Game.current ?: return@executes Command.SINGLE_SUCCESS + player.gameMode = GameMode.SPECTATOR + player.isInvulnerable = false + game.playersMutable.remove(player) + } + + } + Command.SINGLE_SUCCESS + } + + ) + ) + +} \ No newline at end of file diff --git a/src/main/kotlin/fr/azur/tcoww/commands/Tools.kt b/src/main/kotlin/fr/azur/tcoww/commands/Tools.kt index fc69156..26aec08 100644 --- a/src/main/kotlin/fr/azur/tcoww/commands/Tools.kt +++ b/src/main/kotlin/fr/azur/tcoww/commands/Tools.kt @@ -62,15 +62,15 @@ class Tools { } ) ).then( - Commands.literal("reload").executes { ctx -> + Commands.literal("reload").executes { val plugin = Bukkit.getPluginManager().getPlugin("tcoww") as Tcoww - plugin.reload(true) + plugin.reload() Command.SINGLE_SUCCESS } ).then( Commands.literal("customitem").then( Commands.argument("item", StringArgumentType.greedyString()) - .suggests { ctx, builder -> + .suggests { _, builder -> CustomItems.entries.forEach { builder.suggest(it.name) } diff --git a/src/main/kotlin/fr/azur/tcoww/events/GameEvent.kt b/src/main/kotlin/fr/azur/tcoww/events/GameEvent.kt index a5d4606..968b432 100644 --- a/src/main/kotlin/fr/azur/tcoww/events/GameEvent.kt +++ b/src/main/kotlin/fr/azur/tcoww/events/GameEvent.kt @@ -282,8 +282,7 @@ class GameEvent(val plugin: Plugin, val skinUtils: Skin) : Listener { current.wwcankill ) { current.wwcankill = false - target.addPotionEffect(PotionEffect(PotionEffectType.WITHER, 1200, 10)) - target.addPotionEffect(PotionEffect(PotionEffectType.POISON, 1200, 10)) + target.health = 0.0 target.persistentDataContainer.set(NamespacedKey("tcoww", "insomie"), PersistentDataType.BOOLEAN, true) if (target.isSleeping) target.wakeup(false) } @@ -303,15 +302,6 @@ class GameEvent(val plugin: Plugin, val skinUtils: Skin) : Listener { false ) ) - event.player.addPotionEffect( - PotionEffect( - PotionEffectType.SATURATION, - PotionEffect.INFINITE_DURATION, - 1, - false, - false - ) - ) } @EventHandler( @@ -319,7 +309,6 @@ class GameEvent(val plugin: Plugin, val skinUtils: Skin) : Listener { ignoreCancelled = true ) fun endSleep(event: PlayerBedLeaveEvent) { - event.player.removePotionEffect(PotionEffectType.SATURATION) event.player.removePotionEffect(PotionEffectType.REGENERATION) } @@ -385,7 +374,7 @@ class GameEvent(val plugin: Plugin, val skinUtils: Skin) : Listener { speedatr.addModifier( AttributeModifier( NamespacedKey("tcoww", "wwtranform"), - 0.1, + 0.05, AttributeModifier.Operation.ADD_NUMBER ) ) diff --git a/src/main/kotlin/fr/azur/tcoww/game/Game.kt b/src/main/kotlin/fr/azur/tcoww/game/Game.kt index 9400407..01a5ac4 100644 --- a/src/main/kotlin/fr/azur/tcoww/game/Game.kt +++ b/src/main/kotlin/fr/azur/tcoww/game/Game.kt @@ -12,6 +12,8 @@ import org.bukkit.World import org.bukkit.entity.Player import org.bukkit.persistence.PersistentDataType import org.bukkit.plugin.Plugin +import org.bukkit.potion.PotionEffect +import org.bukkit.potion.PotionEffectType import org.bukkit.scheduler.BukkitTask import kotlin.math.ceil @@ -29,6 +31,15 @@ class Game(var plugin: Plugin, val world: World, val players: Iterable, player.teleport(plugin.config.getLocation("spawnLocation")!!) player.inventory.clear() player.health = 20.0 + player.addPotionEffect( + PotionEffect( + PotionEffectType.SATURATION, + PotionEffect.INFINITE_DURATION, + 1, + false, + false + ) + ) } assignRoles() diff --git a/src/main/kotlin/fr/azur/tcoww/plasmovoice/addon/PlasmoAddon.kt b/src/main/kotlin/fr/azur/tcoww/plasmovoice/addon/PlasmoAddon.kt deleted file mode 100644 index ae8d63e..0000000 --- a/src/main/kotlin/fr/azur/tcoww/plasmovoice/addon/PlasmoAddon.kt +++ /dev/null @@ -1,37 +0,0 @@ -package fr.azur.tcoww.plasmovoice.addon - -import su.plo.voice.api.addon.AddonInitializer -import su.plo.voice.api.addon.InjectPlasmoVoice -import su.plo.voice.api.addon.annotation.Addon -import su.plo.voice.api.event.EventSubscribe -import su.plo.voice.api.server.PlasmoVoiceServer -import su.plo.voice.api.server.event.player.PlayerInfoCreateEvent - - -@Addon( - id = "tcoww", - name = "The court of werewolf", - version = "1.0.0", - authors = ["Azur"] -) -class PlasmoAddon : AddonInitializer { - @InjectPlasmoVoice - private lateinit var voiceServer: PlasmoVoiceServer - - override fun onAddonInitialize() { - onConfigLoaded() - } - - override fun onAddonShutdown() { - - } - - fun onConfigLoaded() { - - } - - @EventSubscribe - fun onPlayerInfoCreate(event: PlayerInfoCreateEvent) { - event.voicePlayerInfo.playerNick = "..." - } -} \ No newline at end of file diff --git a/src/main/kotlin/fr/azur/tcoww/voicechat/VoiceChatPlugin.kt b/src/main/kotlin/fr/azur/tcoww/voicechat/VoiceChatPlugin.kt new file mode 100644 index 0000000..663a5d5 --- /dev/null +++ b/src/main/kotlin/fr/azur/tcoww/voicechat/VoiceChatPlugin.kt @@ -0,0 +1,14 @@ +package fr.azur.tcoww.voicechat + +import de.maxhenkel.voicechat.api.VoicechatPlugin +import de.maxhenkel.voicechat.api.events.EventRegistration + +class VoiceChatPlugin: VoicechatPlugin { + override fun getPluginId(): String { + return "tcow" + } + + override fun registerEvents(registration: EventRegistration) { + + } +} \ No newline at end of file diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml index ca97b60..c179695 100644 --- a/src/main/resources/paper-plugin.yml +++ b/src/main/resources/paper-plugin.yml @@ -11,6 +11,6 @@ dependencies: load: BEFORE required: true join-classpath: true - PlasmoVoice: + voicechat: load: BEFORE required: true \ No newline at end of file