Skip to content

Commit

Permalink
Merge pull request #555 from Shynixn/development
Browse files Browse the repository at this point in the history
Merge changes to master --release
  • Loading branch information
Shynixn authored Sep 17, 2024
2 parents 5811772 + ecf709e commit 26e8ed9
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 24 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.github.shynixn"
version = "7.3.0"
version = "7.3.1"

repositories {
mavenLocal()
Expand All @@ -26,7 +26,7 @@ tasks.register("printVersion") {

dependencies {
// Compile Only
compileOnly("me.clip:placeholderapi:2.9.2")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")

// Library dependencies with legacy compatibility, we can use more up-to-date version in the plugin.yml
Expand All @@ -42,7 +42,7 @@ dependencies {

// Custom dependencies
implementation("com.github.shynixn.mcutils:common:2024.23")
implementation("com.github.shynixn.mcutils:packet:2024.33")
implementation("com.github.shynixn.mcutils:packet:2024.38")
implementation("com.github.shynixn.mcutils:database:2024.2")
implementation("com.github.shynixn.mcutils:sign:2024.3")
implementation("com.github.shynixn.mcutils:guice:2024.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class SoccerMiniGameImpl constructor(
playing = true
status = GameState.RUNNING
matchTimeIndex = -1
ballEnabled = true
switchToNextMatchTime()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import org.bukkit.plugin.Plugin
import java.awt.Color
import java.util.*
import java.util.logging.Level
import kotlin.collections.ArrayList
import kotlin.math.floor
import kotlin.math.max
import kotlin.math.min

class BlockBallCommandExecutor @Inject constructor(
private val arenaRepository: CacheRepository<SoccerArena>,
Expand Down Expand Up @@ -549,21 +551,48 @@ class BlockBallCommandExecutor @Inject constructor(
}

if (selectionType == SelectionType.FIELD) {
arena.lowerCorner = selectionLeft.toVector3d()
arena.upperCorner = selectionRight.toVector3d()
arena.lowerCorner = convertToOuterLowerCorner(selectionLeft.toVector3d(), selectionRight.toVector3d())
arena.upperCorner = convertToOuterUpperCorner(selectionLeft.toVector3d(), selectionRight.toVector3d())
} else if (selectionType == SelectionType.RED_GOAL) {
arena.meta.redTeamMeta.goal.lowerCorner = selectionLeft.toVector3d()
arena.meta.redTeamMeta.goal.upperCorner = selectionRight.toVector3d()
arena.meta.redTeamMeta.goal.lowerCorner =
convertToOuterLowerCorner(selectionLeft.toVector3d(), selectionRight.toVector3d())
arena.meta.redTeamMeta.goal.upperCorner =
convertToOuterUpperCorner(selectionLeft.toVector3d(), selectionRight.toVector3d())
} else if (selectionType == SelectionType.BLUE_GOAL) {
arena.meta.blueTeamMeta.goal.lowerCorner = selectionLeft.toVector3d()
arena.meta.blueTeamMeta.goal.upperCorner = selectionRight.toVector3d()
arena.meta.blueTeamMeta.goal.lowerCorner =
convertToOuterLowerCorner(selectionLeft.toVector3d(), selectionRight.toVector3d())
arena.meta.blueTeamMeta.goal.upperCorner =
convertToOuterUpperCorner(selectionLeft.toVector3d(), selectionRight.toVector3d())
}
}

arenaRepository.save(arena)
player.sendMessage(language.selectionSetMessage.format(selectionType.name.lowercase()))
}

/**
* The block selection is not precise enough, we want to exact corner location.
*/
private fun convertToOuterUpperCorner(selection1: Vector3d, selection2: Vector3d): Vector3d {
return Vector3d(
selection1.world,
max(selection1.x + 0.99, selection2.x + 0.99),
max(selection1.y + 0.99, selection2.y + 0.99),
max(selection1.z + 0.99, selection2.z + 0.99)
)
}

/**
* The block selection is not precise enough, we want to exact corner location.
*/
private fun convertToOuterLowerCorner(selection1: Vector3d, selection2: Vector3d): Vector3d {
return Vector3d(
selection1.world,
min(selection1.x, selection2.x),
min(selection1.y, selection2.y),
min(selection1.z, selection2.z)
)
}

private suspend fun setSign(sender: Player, arena: SoccerArena, signType: SignType) {
if (signType == SignType.JOIN) {
Expand Down Expand Up @@ -678,8 +707,8 @@ class BlockBallCommandExecutor @Inject constructor(
if (arena.lowerCorner != null && arena.upperCorner != null) {
highLights.add(
AreaHighlight(
arena.lowerCorner!!,
arena.upperCorner!!,
roundLocation(arena.lowerCorner!!),
roundLocation(arena.upperCorner!!),
Color.BLACK.rgb,
"Field",
true
Expand All @@ -689,8 +718,8 @@ class BlockBallCommandExecutor @Inject constructor(
if (arena.meta.redTeamMeta.goal.lowerCorner != null && arena.meta.redTeamMeta.goal.upperCorner != null) {
highLights.add(
AreaHighlight(
arena.meta.redTeamMeta.goal.lowerCorner!!,
arena.meta.redTeamMeta.goal.upperCorner!!,
roundLocation(arena.meta.redTeamMeta.goal.lowerCorner!!),
roundLocation(arena.meta.redTeamMeta.goal.upperCorner!!),
Color.RED.rgb,
"Red"
)
Expand All @@ -699,8 +728,8 @@ class BlockBallCommandExecutor @Inject constructor(
if (arena.meta.blueTeamMeta.goal.lowerCorner != null && arena.meta.blueTeamMeta.goal.upperCorner != null) {
highLights.add(
AreaHighlight(
arena.meta.blueTeamMeta.goal.lowerCorner!!,
arena.meta.blueTeamMeta.goal.upperCorner!!,
roundLocation(arena.meta.blueTeamMeta.goal.lowerCorner!!),
roundLocation(arena.meta.blueTeamMeta.goal.upperCorner!!),
Color.BLUE.rgb,
"Blue"
)
Expand Down Expand Up @@ -776,4 +805,13 @@ class BlockBallCommandExecutor @Inject constructor(
}
}
}

private fun roundLocation(vector3d: Vector3d): Vector3d {
return Vector3d(
vector3d.world,
floor(vector3d.x),
floor(vector3d.y),
floor(vector3d.z)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UselessCallOnNotNull")

package com.github.shynixn.blockball.impl.service

import com.github.shynixn.blockball.contract.SoccerGame
Expand Down Expand Up @@ -58,8 +60,8 @@ class DependencyPlaceHolderServiceImpl @Inject constructor(
return "blockball"
}

override fun onPlaceholderRequest(player: Player?, params: String?): String? {
if (params == null) {
override fun onPlaceholderRequest(player: Player?, params: String): String? {
if (params.isNullOrBlank()) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ class GameServiceImpl @Inject constructor(
scoreboardService,
commandService,
soccerBallFactory
)
).also {
it.ballEnabled = false
}
}

games.add(game)
Expand Down Expand Up @@ -248,19 +250,19 @@ class GameServiceImpl @Inject constructor(
}

private fun validateGoalSize(arena: SoccerArena, team: Team, teamMeta: TeamMeta) {
if (abs(teamMeta.goal.upperCorner!!.x - teamMeta.goal.lowerCorner!!.x) < 2) {
if (abs(teamMeta.goal.upperCorner!!.x - teamMeta.goal.lowerCorner!!.x) < 1.8) {
throw SoccerGameException(
arena,
"The goal for team ${team.name} should be at least 2x2x2 for ${arena.name}!"
)
}
if (abs(teamMeta.goal.upperCorner!!.y - teamMeta.goal.lowerCorner!!.y) < 2) {
if (abs(teamMeta.goal.upperCorner!!.y - teamMeta.goal.lowerCorner!!.y) < 1.8) {
throw SoccerGameException(
arena,
"The goal for team ${team.name} should be at least 2x2x2 for ${arena.name}!"
)
}
if (abs(teamMeta.goal.upperCorner!!.z - teamMeta.goal.lowerCorner!!.z) < 2) {
if (abs(teamMeta.goal.upperCorner!!.z - teamMeta.goal.lowerCorner!!.z) < 1.8) {
throw SoccerGameException(
arena,
"The goal for team ${team.name} should be at least 2x2x2 for ${arena.name}!"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin-legacy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: BlockBall
version: 7.3.0
version: 7.3.1
author: Shynixn
website: https://www.spigotmc.org/members/shynixn.63455/
main: com.github.shynixn.blockball.BlockBallPlugin
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: BlockBall
version: 7.3.0
version: 7.3.1
author: Shynixn
website: https://www.spigotmc.org/members/shynixn.63455/
main: com.github.shynixn.blockball.BlockBallPlugin
Expand Down

0 comments on commit 26e8ed9

Please sign in to comment.