Skip to content

Commit

Permalink
Night 5 work
Browse files Browse the repository at this point in the history
Starting to be happy with the feature set provided.
  • Loading branch information
minus1over12 committed Jun 17, 2024
1 parent 15897c4 commit 6ae248b
Show file tree
Hide file tree
Showing 11 changed files with 964 additions and 101 deletions.
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

675 changes: 675 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

65 changes: 58 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,66 @@ The plugin has three main phases:

# Things players should know

* Players can send messages to just their team using Vanilla's `/teammsg` command.
* Players can send messages to just their team using Vanilla's `/teammsg` (aliased to `/tm`)
command.
* Avoid building nether portals near the inner edges of the world border. It is possible for the
game to place the destination portal outside the team's world border, causing a potentially
deadly scenario where getting your items back can be near impossible.
* Vanilla allows players to see their teammates when using invisibility potions.
*
* Vanilla allows players to see their teammates when using invisibility potions and prevents
friendly fire.
* Players can join a team using `/jointeam`. Players connected using Floodgate+Geyser will get a
popup to select a team. Once a team is selected, they can not change it themselves.

# Suggestions for resolving a stalemate
# Admin Usage

## Permissions

Admin functions of the plugin are gated by `quadwars.gamemaser`. This gives access to all admin
commands. The player command provided by the plugin, `/jointeam`, is gated by `quadwars.player.
join`, which is granted by default.

## Commands

### `/qwtransition`

This moves the game to the next phase.

### `/qwsetphase <phase>`

This sets the game to a specific phase. The phase can be `PREGAME`, `PREP`, `BATTLE`,
or `POST_GAME`.

### `/worldborder`

QuadWars overrides the built in `/worldborder` command, because it conflicts with the world
borders used for players during the prep phase. Usage is nearly identical to the [vanilla
command](https://minecraft.wiki/w/Commands/worldborder),
but the QuadWars version will sync across dimensions and take coordinate scaling into account.

If you are trying to set the world border during the prep phase, change the config option
`worldBorderSize`, and restart the server.

### Useful Vanilla Commands

#### `/team`

This allows admin management of
teams. [See the Minecraft wiki for usage](https://minecraft.wiki/w/Commands/team).

**Do not use
the add or remove commands, they will break the plugin.** Removing a team not managed by the
plugin is ok and encouraged, since Minecraft only allows entities to be in one team.

If changing a player's team during the prep phase, teleport them to the lobby world first,
change their team, and then teleport them to the new team's quadrant. If you don't, the player
will start taking world border damage when you change their team.

## Suggestions for resolving a stalemate

If you get to the battle phase and decide it is taking too long, here are some recommendations
to encourage teams to make a move:

## Use the world border
### Use the world border

Once you are in battle mode, the plugin unlocks its `/worldborder` command. It is a
reimplementation of the vanilla one, but has the advantage of being synced across dimensions.
Expand All @@ -41,14 +88,14 @@ You mainly would want to use `/worldborder set <size> <time>` or `/worldborder a
calculator to make sure you don't exceed a velocity of 5.612 m/s**. This is the maximum sprint
speed of a player, and you will butcher your players if you exceed it.

## Use the glowing effect
### Use the glowing effect

If teams are having trouble finding each other, you can use the glowing effect to make players
much more visible. Players will even be colored with their team color set in the config. To do
this, run `/effect give @a minecraft:glowing <time>`, where time is how long you want the effect
to last, or `infinite` if you want it to last for the rest of the game.

## Make a bonus chest
### Make a bonus chest

If you want to give players a reason to move, you can create a bonus chest with valuable items
and give out the location to everyone. This may encourage players to move to the location and
Expand All @@ -61,6 +108,10 @@ forks. Other versions of Minecraft may work, but are untested. (If a newer versi
please let me know how it goes!). Upstreams of Paper (Bukkit & Spigot) will *not* work, as this
plugin utilizes the expanded API provided by Paper.

QuadWars should integrate well with any plugin that also utilizes the Scoreboard Team API, as
long as none of them create new teams. Minecraft only allows entities to be in one team,
so any other plugin that adds entities to a team will not work with QuadWars.

# bStats

This plugin uses [bStats](https://bstats.org/), the common service used by most plugins and server
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ tasks {
hangar("Geyser", "Geyser")
hangar("Floodgate", "Floodgate")
modrinth("FastAsyncWorldEdit", "2.10.0")
hangar("ViaBackwards", "4.10.2")
hangar("ViaVersion", "4.10.2")
hangar("ViaBackwards", "5.0.0")
hangar("ViaVersion", "5.0.0")
github("PaperMC", "Debuggery", "v1.5.1", "debuggery-bukkit-1.5.1.jar")
modrinth("ctfbuddy", "1.0.1") // Might as well test my other stuff at the same time.
}
Expand Down
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());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.minus1over12.quadwars;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.util.TriState;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
Expand All @@ -10,16 +11,12 @@
import org.bukkit.WorldBorder;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.geysermc.cumulus.form.SimpleForm;
import org.geysermc.floodgate.api.FloodgateApi;

import java.util.Objects;
import java.util.UUID;

/**
* Controls the lobby world.
Expand Down Expand Up @@ -59,25 +56,6 @@ public class LobbyWorldController implements Listener {
worldBorder.setSize(16);
}

/**
* Sends a team join form to the player.
*
* @param player the player to send the form to
*/
private static void sendTeamForm(Entity player) {
//todo this is untested and unfinished.
FloodgateApi instance = FloodgateApi.getInstance();
UUID uniqueId = player.getUniqueId();
if (instance.isFloodgatePlayer(uniqueId)) {
instance.sendForm(uniqueId,
SimpleForm.builder().title("Select a Team").button("NE").button("SE")
.button("SW").button("NW").validResultHandler(response -> {
Bukkit.dispatchCommand(player,
"jointeam " + response.clickedButton().text());
}).build());
}
}

/**
* Teleports players to the lobby world when they join if needed.
*
Expand All @@ -96,12 +74,18 @@ public void onPlayerJoin(PlayerJoinEvent event) {
switch (gameState) {
case PREGAME -> {
player.sendMessage(Component.text(
"The game has not started yet, but you can " + "pick a team."));
sendTeamForm(player);
"The game has not started yet, but you can pick a team with " +
"/jointeam.")
.clickEvent(ClickEvent.suggestCommand("/jointeam ")));
if (Bukkit.getPluginManager().isPluginEnabled("floodgate")) {
FloodgateIntegration.sendTeamForm(player);
}
}
case PREP -> {
player.sendMessage(Component.text(
"The game is in the prep phase, but you " + "can still join a team."));
"The game is in the prep phase, but you " + "can still join a" +
" team with /jointeam.")
.clickEvent(ClickEvent.suggestCommand("/jointeam ")));
}
case BATTLE, POST_GAME -> player.sendMessage(
Component.text("The battle has started, new players may not join."));
Expand All @@ -121,6 +105,9 @@ public void onGameStateChange(GameStateChangeEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.teleportAsync(lobbyWorld.getSpawnLocation())
.thenRun(() -> player.setGameMode(GameMode.ADVENTURE));
if (Bukkit.getPluginManager().isPluginEnabled("floodgate")) {
FloodgateIntegration.sendTeamForm(player);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ public static void onGameStateChange(GameStateChangeEvent event) {
Sound.sound(Key.key("event.raid.horn"), Sound.Source.MASTER,
Float.MAX_VALUE, 1), 0, 256, 0);
for (Player player : Bukkit.getOnlinePlayers()) {
player.setGameMode(GameMode.SURVIVAL);
if (Bukkit.getScoreboardManager().getMainScoreboard().getPlayerTeam(player) !=
null) {
player.setGameMode(GameMode.SURVIVAL);
}
}
}
case POST_GAME -> {
Bukkit.getServer().stopSound(SoundStop.source(Sound.Source.MUSIC));
Bukkit.getServer()
.playSound(Sound.sound(Key.key("music.credits"), Sound.Source.MUSIC, 1, 1));
.playSound(Sound.sound(Key.key("music.credits"), Sound.Source.MUSIC, 1, 1),
Sound.Emitter.self());
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.getGameMode().equals(GameMode.SURVIVAL)) {
player.setGameMode(GameMode.ADVENTURE);
Expand Down
Loading

0 comments on commit 6ae248b

Please sign in to comment.