-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow bedrock clients to accept tracking requests
- Loading branch information
Showing
21 changed files
with
191 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Run Paper Plugin Directory | ||
run | ||
run* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
waypoints/src/main/kotlin/de/md5lukas/waypoints/config/integrations/GeyserConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.md5lukas.waypoints.config.integrations | ||
|
||
import de.md5lukas.konfig.ConfigPath | ||
import de.md5lukas.konfig.Configurable | ||
|
||
@Configurable | ||
class GeyserConfiguration { | ||
|
||
var enabled: Boolean = false | ||
private set | ||
|
||
@ConfigPath("icon.accept") | ||
var acceptIcon: String = "" | ||
private set | ||
|
||
@ConfigPath("icon.decline") | ||
var declineIcon: String = "" | ||
private set | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
waypoints/src/main/kotlin/de/md5lukas/waypoints/integrations/GeyserIntegration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package de.md5lukas.waypoints.integrations | ||
|
||
import de.md5lukas.commons.paper.placeholder | ||
import de.md5lukas.waypoints.WaypointsPlugin | ||
import de.md5lukas.waypoints.config.integrations.GeyserConfiguration | ||
import de.md5lukas.waypoints.lang.Translations | ||
import de.md5lukas.waypoints.util.asPlainText | ||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver | ||
import org.bukkit.entity.Player | ||
import org.geysermc.cumulus.form.SimpleForm | ||
import org.geysermc.cumulus.util.FormImage | ||
import org.geysermc.geyser.api.GeyserApi | ||
|
||
class GeyserIntegration(private val plugin: WaypointsPlugin) { | ||
|
||
private val translations: Translations | ||
get() = plugin.translations | ||
|
||
private val config: GeyserConfiguration | ||
get() = plugin.waypointsConfig.integrations.geyser | ||
|
||
fun setupGeyser(): Boolean { | ||
return plugin.server.pluginManager.getPlugin("Geyser-Spigot") !== null | ||
} | ||
|
||
fun isBedrockPlayer(player: Player): Boolean { | ||
return GeyserApi.api().isBedrockPlayer(player.uniqueId) | ||
} | ||
|
||
fun sendTrackingRequest( | ||
player: Player, | ||
from: Player, | ||
validForResolver: TagResolver, | ||
onAccept: () -> Unit | ||
) { | ||
GeyserApi.api() | ||
.sendForm( | ||
player.uniqueId, | ||
SimpleForm.builder() | ||
.title(translations.MESSAGE_TRACKING_REQUEST_GEYSER_TITLE.text.asPlainText()) | ||
.content( | ||
translations.MESSAGE_TRACKING_REQUEST_GEYSER_MESSAGE.withReplacements( | ||
"from" placeholder from.displayName(), | ||
validForResolver, | ||
) | ||
.asPlainText()) | ||
.button( | ||
translations.MESSAGE_TRACKING_REQUEST_GEYSER_ACCEPT.text.asPlainText(), | ||
FormImage.Type.PATH, | ||
config.acceptIcon) | ||
.button( | ||
translations.MESSAGE_TRACKING_REQUEST_GEYSER_DECLINE.text.asPlainText(), | ||
FormImage.Type.PATH, | ||
config.declineIcon) | ||
.validResultHandler { response -> | ||
@Suppress( | ||
"KotlinConstantConditions") // Annotation is messed up. The id is 0 based | ||
if (response.clickedButtonId() == 0) { | ||
onAccept() | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters