diff --git a/build.gradle.kts b/build.gradle.kts index f0027bf65..70fa17e99 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "com.github.shynixn" -version = "6.46.0" +version = "6.46.1" repositories { mavenLocal() @@ -42,7 +42,7 @@ dependencies { // Custom dependencies implementation("com.github.shynixn.mcutils:common:2024.19") - implementation("com.github.shynixn.mcutils:packet:2024.30") + implementation("com.github.shynixn.mcutils:packet:2024.32") implementation("com.github.shynixn.mcutils:database:2024.2") implementation("com.github.shynixn.mcutils:sign:2024.2") implementation("com.github.shynixn.mcutils:guice:2024.2") diff --git a/docs/source/conf.py b/docs/source/conf.py index 694ec3268..71281aaad 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -55,9 +55,9 @@ # built documents. # # The short X.Y version. -version = '6.46.0' +version = '6.46.1' # The full version, including alpha/beta/rc tags. -release = '6.46.0' +release = '6.46.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt b/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt index 0c1f59a8e..80663fed2 100644 --- a/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt +++ b/src/main/java/com/github/shynixn/blockball/entity/TeamMeta.kt @@ -61,10 +61,8 @@ class TeamMeta( "%blockball_lang_teamSignLine4%", ) - @JsonProperty("armor") var armor: Array = arrayOfNulls(4) - @JsonProperty("inventory") var inventory: Array = arrayOfNulls(36) var scoreMessageFadeIn: Int = 20 diff --git a/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt b/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt index 1ce2c5c37..6f8d85c19 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt @@ -33,6 +33,7 @@ import kotlin.math.sin */ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) { private var stuckCounter = 0 + private var cachedLength = 0.5 /** * Origin coordinate to make relative rotations in the world. @@ -200,6 +201,7 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) { if (rayTraceEvent.hitBlock) { if (rayTraceEvent.blockDirection == BlockDirection.UP) { this.stuckCounter = 0 + this.cachedLength = this.motion.length() calculateBallOnGround(players, targetPosition) return } else { @@ -207,7 +209,7 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) { this.motion = calculateWallBounce(this.motion, rayTraceEvent.blockDirection) // Fix ball getting stuck in wall by moving back in the direction of its spawnpoint. if (stuckCounter > 4) { - val velocity = this.spawnpoint.copy().subtract(this.position).normalize().multiply(0.5) + val velocity = this.spawnpoint.copy().subtract(this.position).normalize().multiply(cachedLength) this.motion = velocity this.motion.y = 0.1 this.position = this.position.add(this.motion.x, this.motion.y, this.motion.z) @@ -220,6 +222,7 @@ class BallHitboxEntity(val entityId: Int, val spawnpoint: Vector3d) { } this.stuckCounter = 0 + this.cachedLength = this.motion.length() calculateBallOnAir(players, targetPosition) } diff --git a/src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt b/src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt index 2938cc49e..d6eee89c0 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/BlockBallMiniGameImpl.kt @@ -172,55 +172,20 @@ class BlockBallMiniGameImpl constructor( return JoinResult.GAME_FULL } - if (ingamePlayersStorage.containsKey(player) && team != null) { - var targetTeam = team - val amount = getAmountOfQueuedPlayersInThisTeam(targetTeam) - - if (arena.meta.lobbyMeta.onlyAllowEventTeams) { - val blueTeamAmount = getAmountOfQueuedPlayersInThisTeam(Team.BLUE) - val redTeamAmount = getAmountOfQueuedPlayersInThisTeam(Team.RED) - - if (blueTeamAmount > redTeamAmount) { - targetTeam = Team.RED - } else if (blueTeamAmount < redTeamAmount) { - targetTeam = Team.BLUE - } - } - - if (targetTeam == Team.RED) { - if (amount >= arena.meta.redTeamMeta.maxAmount) { - return JoinResult.TEAM_FULL - } - - joinTeam(player, Team.RED, arena.meta.redTeamMeta) - } else if (targetTeam == Team.BLUE) { - if (amount >= arena.meta.blueTeamMeta.maxAmount) { - return JoinResult.TEAM_FULL - } - - joinTeam(player, Team.BLUE, arena.meta.blueTeamMeta) - } - - ingamePlayersStorage[player]!!.team = targetTeam - ingamePlayersStorage[player]!!.goalTeam = targetTeam - - if (targetTeam == Team.BLUE) { - executeCommandsWithPlaceHolder(listOf(player), arena.meta.blueTeamMeta.joinCommands) - return JoinResult.SUCCESS_BLUE - } else { - executeCommandsWithPlaceHolder(listOf(player), arena.meta.redTeamMeta.joinCommands) - return JoinResult.SUCCESS_RED - } - } - + var joinResult = JoinResult.SUCCESS_QUEUED val storage = this.createPlayerStorage(player) ingamePlayersStorage[player] = storage player.teleport(arena.meta.minigameMeta.lobbySpawnpoint!!.toLocation()) if (team != null) { - val innerResult = join(player, team) - if (innerResult != JoinResult.SUCCESS_BLUE && innerResult != JoinResult.SUCCESS_RED) { - return innerResult + if (team == Team.RED && redTeam.size < arena.meta.redTeamMeta.maxAmount) { + joinTeam(player, team, arena.meta.redTeamMeta) + storage.team = team + joinResult = JoinResult.SUCCESS_RED + } else if (team == Team.BLUE && blueTeam.size < arena.meta.blueTeamMeta.maxAmount) { + joinTeam(player, team, arena.meta.blueTeamMeta) + storage.team = team + joinResult = JoinResult.SUCCESS_BLUE } } @@ -231,7 +196,7 @@ class BlockBallMiniGameImpl constructor( } } - return JoinResult.SUCCESS_QUEUED + return joinResult } /** @@ -657,21 +622,6 @@ class BlockBallMiniGameImpl constructor( } } - /** - * Returns the amount of queues players. - */ - private fun getAmountOfQueuedPlayersInThisTeam(team: Team): Int { - var amount = 0 - - ingamePlayersStorage.values.forEach { p -> - if (p.team != null && p.team == team) { - amount++ - } - } - - return amount - } - /** * Gets called when the game ends. */ diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt index 50f7e465b..dc340c133 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/commandexecutor/JoinCommandExecutor.kt @@ -56,17 +56,10 @@ class JoinCommandExecutor @Inject constructor( .equals(args[0], true) ) { var team: Team? = null - if (args[1].equals( - g.arena.meta.redTeamMeta.displayName.translateChatColors().stripChatColors(), - true - ) - ) { + // TODO: Work around will be removed with the command rework + if (args[1].equals("team red", true) || args[1].equals("red", true)) { team = Team.RED - } else if (args[1].equals( - g.arena.meta.blueTeamMeta.displayName.translateChatColors().stripChatColors(), - true - ) - ) { + } else if (args[1].equals("team blue", true) || args[1].equals("blue", true)) { team = Team.BLUE } diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt index 72d43f9bf..47e8a17ff 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/OpenPage.kt @@ -96,9 +96,13 @@ class OpenPage @Inject constructor( return@runBlocking MenuCommandResult.CANCEL_MESSAGE } } else if (command == MenuCommand.OPEN_CREATE_ARENA) { - var idGen = 1 + var idGen: Int + runBlocking { - for (arena in arenaRepository.getAll()) { + val arenas = arenaRepository.getAll() + idGen = arenas.size + 1 + + for (arena in arenas) { if (arena.name == "arena_$idGen") { idGen++ } diff --git a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt index d6bc25fad..b8b8d4e1d 100644 --- a/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt +++ b/src/main/java/com/github/shynixn/blockball/impl/commandmenu/TeamSettingsPage.kt @@ -105,7 +105,7 @@ class TeamSettingsPage @Inject constructor() : }.toTypedArray() } else if (command == MenuCommand.TEAM_INVENTORY) { val teamMeta = getTeamMeta(cache) - teamMeta.armor = player.inventory.contents.clone().map { e -> + teamMeta.inventory = player.inventory.contents.clone().map { e -> val yamlConfiguration = YamlConfiguration() yamlConfiguration.set("item", e) yamlConfiguration.saveToString() diff --git a/src/main/resources/plugin-legacy.yml b/src/main/resources/plugin-legacy.yml index f87ad891e..44318b82c 100644 --- a/src/main/resources/plugin-legacy.yml +++ b/src/main/resources/plugin-legacy.yml @@ -1,5 +1,5 @@ name: BlockBall -version: 6.46.0 +version: 6.46.1 author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.blockball.BlockBallPlugin diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a75b43159..31710df6f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: BlockBall -version: 6.46.0 +version: 6.46.1 author: Shynixn website: https://www.spigotmc.org/members/shynixn.63455/ main: com.github.shynixn.blockball.BlockBallPlugin