Skip to content

Commit

Permalink
#44 Fixed bedrock detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Aug 24, 2024
1 parent e5ef0e9 commit 2245995
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ dependencies {
implementation("com.google.code.gson:gson:2.8.6")

// Custom dependencies
implementation("com.github.shynixn.mcutils:common:2024.21")
implementation("com.github.shynixn.mcutils:guice:2024.2")
implementation("com.github.shynixn.mcutils:common:2024.23")
implementation("com.github.shynixn.mcutils:packet:2024.33")
implementation("com.github.shynixn.mcutils:sign:2024.3")
implementation("com.github.shynixn.mcutils:guice:2024.2")

// Test
testImplementation(kotlin("test"))
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ nav:
- 'MCTennis Wiki':
- Introduction: README.md
- Permission: permission.md
- Commands: commands.md
- Creating the game: game.md
- Interactions: interaction.md
- Commands: commands.md
- PlaceHolders: placeholders.md
- Developer Api: api.md
theme:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import org.bukkit.event.EventHandler
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerQuitEvent
import org.bukkit.plugin.Plugin
import java.util.logging.Level

class BedrockServiceImpl @Inject constructor(private val plugin: Plugin, private val physicDispatcher: PhysicObjectDispatcher) :
class BedrockServiceImpl @Inject constructor(
private val plugin: Plugin,
private val physicDispatcher: PhysicObjectDispatcher
) :
BedrockService {
/**
* All bedrock players.
Expand All @@ -29,16 +33,21 @@ class BedrockServiceImpl @Inject constructor(private val plugin: Plugin, private
private var geyserSpigotPlugin: DependencyGeyserSpigotServiceImpl? = null

init {
Bukkit.getPluginManager().registerEvents(this, plugin)

try {
if (Bukkit.getPluginManager().getPlugin("Geyser-Spigot") != null) {
geyserSpigotPlugin = DependencyGeyserSpigotServiceImpl()
}
} catch (e: Exception) {
plugin.logger.log(Level.WARNING, "Cannot load Geyser-Spigot integration.")
}

Bukkit.getOnlinePlayers().forEach { e ->
plugin.launch(physicDispatcher) {
applyPlayerToGroup(e)
}
}

Bukkit.getPluginManager().registerEvents(this, plugin)
if (Bukkit.getPluginManager().getPlugin("Geyser-Spigot") != null) {
geyserSpigotPlugin = DependencyGeyserSpigotServiceImpl()
}
}

@EventHandler
Expand Down Expand Up @@ -73,8 +82,12 @@ class BedrockServiceImpl @Inject constructor(private val plugin: Plugin, private
* Gets if the given player is playing on a bedrock client.
*/
private fun isBedRockPlayer(player: Player): Boolean {
if (geyserSpigotPlugin != null) {
return geyserSpigotPlugin!!.isBedrockPlayer(player)
try {
if (geyserSpigotPlugin != null) {
return geyserSpigotPlugin!!.isBedrockPlayer(player)
}
} catch (e: Exception) {
// Sometimes the integration fails. Ignore in this case.
}

return false
Expand Down

0 comments on commit 2245995

Please sign in to comment.