-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting to be happy with the feature set provided.
- Loading branch information
1 parent
15897c4
commit 6ae248b
Showing
11 changed files
with
964 additions
and
101 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.
Large diffs are not rendered by default.
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
52 changes: 52 additions & 0 deletions
52
src/main/java/io/github/minus1over12/quadwars/FloodgateIntegration.java
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,52 @@ | ||
package io.github.minus1over12.quadwars; | ||
|
||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.scoreboard.Scoreboard; | ||
import org.geysermc.cumulus.form.SimpleForm; | ||
import org.geysermc.floodgate.api.FloodgateApi; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Utilities that require Floodgate. | ||
* | ||
* @author War Pigeon | ||
*/ | ||
public enum FloodgateIntegration { | ||
; | ||
|
||
/** | ||
* Sends a team join form to the player. | ||
* | ||
* @param player the player to send the form to | ||
*/ | ||
static void sendTeamForm(Entity player) { | ||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); | ||
if (scoreboard.getEntityTeam(player) == null && | ||
player.hasPermission("quadwars.player.join")) { | ||
FloodgateApi instance = FloodgateApi.getInstance(); | ||
UUID uniqueId = player.getUniqueId(); | ||
if (instance.isFloodgatePlayer(uniqueId)) { | ||
instance.sendForm(uniqueId, SimpleForm.builder().title("Select a Team") | ||
.button(PlainTextComponentSerializer.plainText().serialize( | ||
Objects.requireNonNull(scoreboard.getTeam("quadwars_NE")) | ||
.displayName())) | ||
.button(PlainTextComponentSerializer.plainText().serialize( | ||
Objects.requireNonNull(scoreboard.getTeam("quadwars_SE")) | ||
.displayName())) | ||
.button(PlainTextComponentSerializer.plainText().serialize( | ||
Objects.requireNonNull(scoreboard.getTeam("quadwars_SW")) | ||
.displayName())) | ||
.button(PlainTextComponentSerializer.plainText().serialize( | ||
Objects.requireNonNull(scoreboard.getTeam("quadwars_NW")) | ||
.displayName())).validResultHandler( | ||
response -> Bukkit.dispatchCommand(player, | ||
"jointeam " + response.clickedButton().text())) | ||
.closedOrInvalidResultHandler(() -> sendTeamForm(player)).build()); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.