From dca716bf2e0be272cd266de37be2ec10fc9529a6 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 13 May 2022 20:45:11 +0200 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=8E=A8=20fixed=20asMini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inventory/shop/categories/BlocksShopCategory.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/inventory/shop/categories/BlocksShopCategory.kt b/src/main/kotlin/cc/lixou/bedwarsextension/inventory/shop/categories/BlocksShopCategory.kt index 4853432..d46fa49 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/inventory/shop/categories/BlocksShopCategory.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/inventory/shop/categories/BlocksShopCategory.kt @@ -3,12 +3,12 @@ package cc.lixou.bedwarsextension.inventory.shop.categories import cc.lixou.bedwarsextension.inventory.shop.ShopCategory import cc.lixou.stracciatella.item.CustomItem import net.minestom.server.item.Material -import world.cepi.kstom.adventure.formatMini +import world.cepi.kstom.adventure.asMini import world.cepi.kstom.adventure.noItalic class BlocksShopCategory : ShopCategory( CustomItem("bedwars:shopcategory_blocks", Material.LIME_WOOL) { - it.meta { meta -> meta.displayName("» Blöcke".formatMini().noItalic()) } + it.meta { meta -> meta.displayName("» Blöcke".asMini().noItalic()) } }, Array(7) { CustomItem("bedwars:shopcategory_blocks:wool", Material.WHITE_WOOL) } ) \ No newline at end of file From 26bdf70a0b057edfe0d058f4be8466c9af3cc00b Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 13 May 2022 20:45:25 +0200 Subject: [PATCH 02/12] =?UTF-8?q?=E2=9D=93=20fixed=20canJoin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index c35a6ff..4930cb8 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -49,7 +49,7 @@ class BedWarsGame : Game() { var currentState: BedWarsGameState = BedWarsGameState.WAITING - override fun canJoin(newPlayers: Array): Boolean = (this.players.size + newPlayers.size) >= MAX_PLAYERS + override fun canJoin(newPlayers: Array): Boolean = (this.players.size + newPlayers.size) <= MAX_PLAYERS override fun onJoin(joiningPlayer: Player) { joiningPlayer.inventory.setItemStack(0, ItemStack.of(Material.WOODEN_SWORD)) From feedc7d2aac4c7fae68ad26c5b8943213e060ef7 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 13 May 2022 21:29:18 +0200 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=86=99=20Updated=20Stracciatella?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index aaae9cc..8f1c067 100644 --- a/build.gradle +++ b/build.gradle @@ -13,9 +13,9 @@ repositories { } dependencies { - compileOnly 'com.github.TeamSkyBeach:Stracciatella:95f3fcb943' + compileOnly 'com.github.TeamSkyBeach:Stracciatella:430dbb5de7' - testImplementation 'com.github.TeamSkyBeach:Stracciatella:95f3fcb943' + testImplementation 'com.github.TeamSkyBeach:Stracciatella:430dbb5de7' testImplementation 'org.jetbrains.kotlin:kotlin-test' } From f99ff25589c67099d2e3ed6b57de17621b72cb50 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 13 May 2022 21:29:31 +0200 Subject: [PATCH 04/12] =?UTF-8?q?=F0=9F=95=B9=EF=B8=8F=20Basic=20Team=20st?= =?UTF-8?q?uff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bedwarsextension/game/BedWarsGame.kt | 23 +++++++++++-------- .../bedwarsextension/game/BedWarsTeam.kt | 13 +++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index 4930cb8..b430323 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -7,21 +7,23 @@ import net.minestom.server.entity.Player import net.minestom.server.event.item.ItemDropEvent import net.minestom.server.event.item.PickupItemEvent import net.minestom.server.event.player.PlayerChatEvent -import net.minestom.server.item.ItemStack -import net.minestom.server.item.Material import net.minestom.server.utils.time.TimeUnit import world.cepi.kstom.Manager import world.cepi.kstom.event.listenOnly - class BedWarsGame : Game() { - companion object { - val MAX_PLAYERS = 8 - } - val state = initGameState(BedWarsGameState.WAITING) + private val TEAM_AMOUNT = 8 + private val PLAYER_PER_TEAM = 1 + + val teams = mutableListOf().also { + for (i in 0..TEAM_AMOUNT) { + it.add(BedWarsTeam()) + } + } + init { instance = Manager.instance.instances.first() // DEBUG @@ -49,14 +51,15 @@ class BedWarsGame : Game() { var currentState: BedWarsGameState = BedWarsGameState.WAITING - override fun canJoin(newPlayers: Array): Boolean = (this.players.size + newPlayers.size) <= MAX_PLAYERS + override fun canJoin(newPlayers: Array): Boolean = + (this.players.size + newPlayers.size) <= TEAM_AMOUNT * PLAYER_PER_TEAM override fun onJoin(joiningPlayer: Player) { - joiningPlayer.inventory.setItemStack(0, ItemStack.of(Material.WOODEN_SWORD)) + teams.find { it.players.size < PLAYER_PER_TEAM }!!.players.add(joiningPlayer) } override fun onLeave(leavingPlayer: Player) { - leavingPlayer.sendMessage("bye bye") + } } \ No newline at end of file diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt new file mode 100644 index 0000000..aec112e --- /dev/null +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt @@ -0,0 +1,13 @@ +package cc.lixou.bedwarsextension.game + +import cc.lixou.stracciatella.game.GameManager.playingGame +import net.minestom.server.entity.Player + +class BedWarsTeam { + + val players = mutableListOf() + +} + +/* Extensions */ +fun Player.getBedWarsTeam(): BedWarsTeam? = playingGame()?.takeIf { it is BedWarsGame }?.run { return (this as BedWarsGame).teams.find { it.players.contains(this@getBedWarsTeam) } } \ No newline at end of file From 8731fdad58718f074d74be9311cc4c8fb2a30e6b Mon Sep 17 00:00:00 2001 From: DasLixou Date: Thu, 19 May 2022 15:54:55 +0200 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=94=A5=20There=20was=20a=20state=20?= =?UTF-8?q?already=3F=20lol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/lixou/bedwarsextension/game/BedWarsGame.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index b8cf756..549b996 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -15,7 +15,7 @@ import world.cepi.kstom.event.listenOnly class BedWarsGame : Game() { - private var state = BedWarsGameState.WAITING + var currentState: BedWarsGameState = BedWarsGameState.WAITING private val TEAM_AMOUNT = 8 private val PLAYER_PER_TEAM = 1 @@ -31,7 +31,7 @@ class BedWarsGame : Game() { // DEBUG eventNode.listenOnly { if (message.lowercase() == "play") { - state = BedWarsGameState.INGAME + currentState = BedWarsGameState.INGAME } else if (message.lowercase() == "shop") { player.openInventory(ShopInventory()) } else if (message.lowercase() == "generator") { @@ -40,7 +40,7 @@ class BedWarsGame : Game() { } // ENDDEBUG eventNode.listenOnly { - when(state) { + when(currentState) { BedWarsGameState.INGAME -> { val itemEntity = ItemEntity(itemStack) itemEntity.setPickupDelay(40, TimeUnit.SERVER_TICK) @@ -52,7 +52,7 @@ class BedWarsGame : Game() { } } eventNode.listenOnly { - when(state) { + when(currentState) { BedWarsGameState.INGAME -> { if (entity is Player) { ResourceGenerator.mayPickup(itemEntity) @@ -66,8 +66,6 @@ class BedWarsGame : Game() { } } - var currentState: BedWarsGameState = BedWarsGameState.WAITING - override fun canJoin(newPlayers: Array): Boolean = (this.players.size + newPlayers.size) <= TEAM_AMOUNT * PLAYER_PER_TEAM From 69f2b381c9beb009930e104495cb37a3f6e9d5a0 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Thu, 19 May 2022 17:25:35 +0200 Subject: [PATCH 06/12] =?UTF-8?q?=F0=9F=91=95=20Basic=20hitting=20for=20en?= =?UTF-8?q?emies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bedwarsextension/game/BedWarsGame.kt | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index 549b996..557bfa7 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -6,19 +6,23 @@ import cc.lixou.bedwarsextension.inventory.ShopInventory import cc.lixou.stracciatella.game.Game import net.minestom.server.entity.ItemEntity import net.minestom.server.entity.Player +import net.minestom.server.event.entity.EntityAttackEvent import net.minestom.server.event.item.ItemDropEvent import net.minestom.server.event.item.PickupItemEvent import net.minestom.server.event.player.PlayerChatEvent +import net.minestom.server.network.packet.server.play.EntityAnimationPacket import net.minestom.server.utils.time.TimeUnit import world.cepi.kstom.Manager import world.cepi.kstom.event.listenOnly +import kotlin.math.cos +import kotlin.math.sin class BedWarsGame : Game() { var currentState: BedWarsGameState = BedWarsGameState.WAITING - private val TEAM_AMOUNT = 8 - private val PLAYER_PER_TEAM = 1 + private val TEAM_AMOUNT = 4 + private val PLAYER_PER_TEAM = 2 val teams = mutableListOf().also { for (i in 0..TEAM_AMOUNT) { @@ -40,7 +44,7 @@ class BedWarsGame : Game() { } // ENDDEBUG eventNode.listenOnly { - when(currentState) { + when (currentState) { BedWarsGameState.INGAME -> { val itemEntity = ItemEntity(itemStack) itemEntity.setPickupDelay(40, TimeUnit.SERVER_TICK) @@ -52,7 +56,7 @@ class BedWarsGame : Game() { } } eventNode.listenOnly { - when(currentState) { + when (currentState) { BedWarsGameState.INGAME -> { if (entity is Player) { ResourceGenerator.mayPickup(itemEntity) @@ -64,6 +68,23 @@ class BedWarsGame : Game() { else -> isCancelled = true } } + eventNode.listenOnly { + if (currentState != BedWarsGameState.INGAME) return@listenOnly + val attacker = entity + if (attacker !is Player) return@listenOnly + if (attacker.getBedWarsTeam()!!.players.contains(target as Player)) return@listenOnly + target.takeKnockback( + 0.4f, + sin(attacker.position.yaw * (Math.PI / 180)), + -cos(attacker.position.yaw * (Math.PI / 180)) + ) + (target as Player).sendPacketToViewersAndSelf( + EntityAnimationPacket( + target.entityId, + EntityAnimationPacket.Animation.TAKE_DAMAGE + ) + ) + } } override fun canJoin(newPlayers: Array): Boolean = From 472e4d9138fe048e1552e3ea410fb92b33e31fe1 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 20 May 2022 16:42:01 +0200 Subject: [PATCH 07/12] =?UTF-8?q?=F0=9F=91=95=20Basic=20team=20in=20tablis?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/lixou/bedwarsextension/game/BedWarsGame.kt | 5 +++-- .../cc/lixou/bedwarsextension/game/BedWarsTeam.kt | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index 557bfa7..8779dc6 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -13,6 +13,7 @@ import net.minestom.server.event.player.PlayerChatEvent import net.minestom.server.network.packet.server.play.EntityAnimationPacket import net.minestom.server.utils.time.TimeUnit import world.cepi.kstom.Manager +import world.cepi.kstom.adventure.asMini import world.cepi.kstom.event.listenOnly import kotlin.math.cos import kotlin.math.sin @@ -26,7 +27,7 @@ class BedWarsGame : Game() { val teams = mutableListOf().also { for (i in 0..TEAM_AMOUNT) { - it.add(BedWarsTeam()) + it.add(BedWarsTeam("siu", "R ".asMini())) } } @@ -91,7 +92,7 @@ class BedWarsGame : Game() { (this.players.size + newPlayers.size) <= TEAM_AMOUNT * PLAYER_PER_TEAM override fun onJoin(joiningPlayer: Player) { - teams.find { it.players.size < PLAYER_PER_TEAM }!!.players.add(joiningPlayer) + teams.find { it.players.size < PLAYER_PER_TEAM }!!.addPlayer(joiningPlayer) } override fun onLeave(leavingPlayer: Player) { diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt index aec112e..98c4f55 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt @@ -1,13 +1,23 @@ package cc.lixou.bedwarsextension.game import cc.lixou.stracciatella.game.GameManager.playingGame +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.NamedTextColor import net.minestom.server.entity.Player +import world.cepi.kstom.Manager -class BedWarsTeam { +class BedWarsTeam(name: String, prefix: Component) { val players = mutableListOf() + val team = Manager.team.createBuilder(name).prefix(prefix).teamColor(NamedTextColor.RED).build() + + fun addPlayer(player: Player) { + players.add(player) + player.team = team + } } /* Extensions */ -fun Player.getBedWarsTeam(): BedWarsTeam? = playingGame()?.takeIf { it is BedWarsGame }?.run { return (this as BedWarsGame).teams.find { it.players.contains(this@getBedWarsTeam) } } \ No newline at end of file +fun Player.getBedWarsTeam(): BedWarsTeam? = playingGame()?.takeIf { it is BedWarsGame } + ?.run { return (this as BedWarsGame).teams.find { it.players.contains(this@getBedWarsTeam) } } \ No newline at end of file From 552df875acbfe5a509ab76a4ca1c1c2e1c2b3b8a Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 20 May 2022 17:55:47 +0200 Subject: [PATCH 08/12] =?UTF-8?q?=F0=9F=91=95=20Moved=20teams=20classes=20?= =?UTF-8?q?to=20team=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt | 2 ++ .../cc/lixou/bedwarsextension/game/{ => team}/BedWarsTeam.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) rename src/main/kotlin/cc/lixou/bedwarsextension/game/{ => team}/BedWarsTeam.kt (88%) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index 8779dc6..86f89ca 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -2,6 +2,8 @@ package cc.lixou.bedwarsextension.game import cc.lixou.bedwarsextension.game.generator.ResourceGenerator import cc.lixou.bedwarsextension.game.generator.fabric.Generators +import cc.lixou.bedwarsextension.game.team.BedWarsTeam +import cc.lixou.bedwarsextension.game.team.getBedWarsTeam import cc.lixou.bedwarsextension.inventory.ShopInventory import cc.lixou.stracciatella.game.Game import net.minestom.server.entity.ItemEntity diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt similarity index 88% rename from src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt rename to src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt index 98c4f55..45d2692 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsTeam.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt @@ -1,5 +1,6 @@ -package cc.lixou.bedwarsextension.game +package cc.lixou.bedwarsextension.game.team +import cc.lixou.bedwarsextension.game.BedWarsGame import cc.lixou.stracciatella.game.GameManager.playingGame import net.kyori.adventure.text.Component import net.kyori.adventure.text.format.NamedTextColor From 93d5e6710e66e4c9769cad5f2723064fd405d6df Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 20 May 2022 18:15:18 +0200 Subject: [PATCH 09/12] =?UTF-8?q?=F0=9F=91=95=20Added=20different=20team?= =?UTF-8?q?=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bedwarsextension/game/BedWarsGame.kt | 13 +++----- .../bedwarsextension/game/team/BedWarsTeam.kt | 5 +-- .../bedwarsextension/game/team/TeamType.kt | 7 ++++ .../bedwarsextension/game/team/TeamTypes.kt | 33 +++++++++++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamType.kt create mode 100644 src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index 86f89ca..7f814ec 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -3,6 +3,7 @@ package cc.lixou.bedwarsextension.game import cc.lixou.bedwarsextension.game.generator.ResourceGenerator import cc.lixou.bedwarsextension.game.generator.fabric.Generators import cc.lixou.bedwarsextension.game.team.BedWarsTeam +import cc.lixou.bedwarsextension.game.team.TeamTypes import cc.lixou.bedwarsextension.game.team.getBedWarsTeam import cc.lixou.bedwarsextension.inventory.ShopInventory import cc.lixou.stracciatella.game.Game @@ -15,7 +16,6 @@ import net.minestom.server.event.player.PlayerChatEvent import net.minestom.server.network.packet.server.play.EntityAnimationPacket import net.minestom.server.utils.time.TimeUnit import world.cepi.kstom.Manager -import world.cepi.kstom.adventure.asMini import world.cepi.kstom.event.listenOnly import kotlin.math.cos import kotlin.math.sin @@ -24,14 +24,10 @@ class BedWarsGame : Game() { var currentState: BedWarsGameState = BedWarsGameState.WAITING - private val TEAM_AMOUNT = 4 + private val TEAM_AMOUNT = 8 private val PLAYER_PER_TEAM = 2 - val teams = mutableListOf().also { - for (i in 0..TEAM_AMOUNT) { - it.add(BedWarsTeam("siu", "R ".asMini())) - } - } + val teams = mutableListOf() init { instance = Manager.instance.instances.first() @@ -94,7 +90,8 @@ class BedWarsGame : Game() { (this.players.size + newPlayers.size) <= TEAM_AMOUNT * PLAYER_PER_TEAM override fun onJoin(joiningPlayer: Player) { - teams.find { it.players.size < PLAYER_PER_TEAM }!!.addPlayer(joiningPlayer) + teams.find { it.players.size < PLAYER_PER_TEAM }?.addPlayer(joiningPlayer) + ?: teams.add(TeamTypes.createTeam(teams.size, uuid).also { it.addPlayer(joiningPlayer) }) } override fun onLeave(leavingPlayer: Player) { diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt index 45d2692..a4be69c 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt @@ -4,13 +4,14 @@ import cc.lixou.bedwarsextension.game.BedWarsGame import cc.lixou.stracciatella.game.GameManager.playingGame import net.kyori.adventure.text.Component import net.kyori.adventure.text.format.NamedTextColor +import net.minestom.server.color.DyeColor import net.minestom.server.entity.Player import world.cepi.kstom.Manager -class BedWarsTeam(name: String, prefix: Component) { +class BedWarsTeam(name: String, prefix: Component, color: NamedTextColor, private val bedColor: DyeColor) { val players = mutableListOf() - val team = Manager.team.createBuilder(name).prefix(prefix).teamColor(NamedTextColor.RED).build() + val team = Manager.team.createBuilder(name).prefix(prefix).teamColor(color).build() fun addPlayer(player: Player) { players.add(player) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamType.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamType.kt new file mode 100644 index 0000000..9f58af3 --- /dev/null +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamType.kt @@ -0,0 +1,7 @@ +package cc.lixou.bedwarsextension.game.team + +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.NamedTextColor +import net.minestom.server.color.DyeColor + +data class TeamType(val baseName: String, val prefix: Component, val color: NamedTextColor, val bedColor: DyeColor) \ No newline at end of file diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt new file mode 100644 index 0000000..7c7ca60 --- /dev/null +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt @@ -0,0 +1,33 @@ +package cc.lixou.bedwarsextension.game.team + +import net.kyori.adventure.text.format.NamedTextColor +import net.minestom.server.color.DyeColor +import world.cepi.kstom.adventure.asMini +import java.util.UUID + +object TeamTypes { + + val RED = TeamType("red", "R ".asMini(), NamedTextColor.RED, DyeColor.RED) + + val BLUE = TeamType("blue", "B ".asMini(), NamedTextColor.BLUE, DyeColor.BLUE) + + val GREEN = TeamType("green", "G ".asMini(), NamedTextColor.GREEN, DyeColor.GREEN) + + val YELLOW = TeamType("yellow", "Y ".asMini(), NamedTextColor.YELLOW, DyeColor.YELLOW) + + val AQUA = TeamType("aqua", "A ".asMini(), NamedTextColor.AQUA, DyeColor.CYAN) + + val WHITE = TeamType("white", "W ".asMini(), NamedTextColor.WHITE, DyeColor.WHITE) + + val PINK = TeamType("pink", "P ".asMini(), NamedTextColor.LIGHT_PURPLE, DyeColor.PINK) + + val GRAY = TeamType("gray", "S ".asMini(), NamedTextColor.GRAY, DyeColor.GRAY) + + private val entries = listOf(RED, BLUE, GREEN, YELLOW, AQUA, WHITE, PINK, GRAY) + + fun createTeam(nextFree: Int, uuid: UUID): BedWarsTeam { + val next: TeamType = entries[nextFree] + return BedWarsTeam(next.baseName + uuid, next.prefix, next.color, next.bedColor) + } + +} \ No newline at end of file From 2f95db1b62c083e2e825d3397bb22b1f0461a049 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Fri, 20 May 2022 18:18:21 +0200 Subject: [PATCH 10/12] =?UTF-8?q?=F0=9F=91=95=20Removing=20Player=20from?= =?UTF-8?q?=20Team=20on=20leaving?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt | 2 +- .../cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index 7f814ec..1b317ca 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -95,7 +95,7 @@ class BedWarsGame : Game() { } override fun onLeave(leavingPlayer: Player) { - + leavingPlayer.getBedWarsTeam()?.removePlayer(leavingPlayer) } } \ No newline at end of file diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt index a4be69c..abb1f37 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/BedWarsTeam.kt @@ -18,6 +18,11 @@ class BedWarsTeam(name: String, prefix: Component, color: NamedTextColor, privat player.team = team } + fun removePlayer(player: Player) { + players.remove(player) + player.team = null + } + } /* Extensions */ From e2c7af77d9f0af9512407c0acebf4e867f0b6953 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Sat, 21 May 2022 10:36:49 +0200 Subject: [PATCH 11/12] =?UTF-8?q?=F0=9F=91=95=20Sorting=20teams=20in=20tab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt index 7c7ca60..baaa7a6 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/team/TeamTypes.kt @@ -27,7 +27,7 @@ object TeamTypes { fun createTeam(nextFree: Int, uuid: UUID): BedWarsTeam { val next: TeamType = entries[nextFree] - return BedWarsTeam(next.baseName + uuid, next.prefix, next.color, next.bedColor) + return BedWarsTeam(nextFree.toString() + next.baseName + uuid, next.prefix, next.color, next.bedColor) } } \ No newline at end of file From 5b440ac43d6e2bb0fa5e29c26e96a75c848a7037 Mon Sep 17 00:00:00 2001 From: DasLixou Date: Sun, 18 Dec 2022 12:28:20 +0100 Subject: [PATCH 12/12] changes --- .../kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt index d8b0ba6..5a82cb5 100644 --- a/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt +++ b/src/main/kotlin/cc/lixou/bedwarsextension/game/BedWarsGame.kt @@ -2,9 +2,9 @@ package cc.lixou.bedwarsextension.game import cc.lixou.bedwarsextension.game.generator.ResourceGenerator import cc.lixou.bedwarsextension.game.generator.fabric.Generators -import cc.lixou.bedwarsextension.game.team.getBedWarsTeam import cc.lixou.bedwarsextension.game.team.BedWarsTeam import cc.lixou.bedwarsextension.game.team.TeamTypes +import cc.lixou.bedwarsextension.game.team.getBedWarsTeam import cc.lixou.bedwarsextension.inventory.ShopInventory import cc.lixou.stracciatella.game.Game import net.minestom.server.entity.ItemEntity @@ -13,8 +13,6 @@ import net.minestom.server.event.entity.EntityAttackEvent import net.minestom.server.event.item.ItemDropEvent import net.minestom.server.event.item.PickupItemEvent import net.minestom.server.event.player.PlayerChatEvent -import net.minestom.server.item.ItemStack -import net.minestom.server.item.Material import net.minestom.server.network.packet.server.play.EntityAnimationPacket import net.minestom.server.utils.time.TimeUnit import world.cepi.kstom.Manager @@ -103,7 +101,7 @@ class BedWarsGame : Game() { override fun shouldClose(): Boolean = this.players.size == 0 override fun onClose() { - + println("closing..") } } \ No newline at end of file