Implements #27 among other things

It was found that the Spigot API's methods for cancelling player collisions won't work without changing the scoreboard. Because of that, the normal option has been disabled. The invisibility option has also been removed, as that's a bad idea if players can still push each-other.
The toggle player option which is implemented in this commit does disable player collision, so that's the only working way right now.

A potential ConcurrentModificationException has been fixed.
The parkourCheckpoint command has been removed, as the functionality is now available through the API.
This commit is contained in:
2023-05-10 15:14:28 +02:00
parent 00ac0582f4
commit 7848a0a028
23 changed files with 193 additions and 194 deletions

View File

@ -32,7 +32,7 @@ public class LeaveArenaCommand implements TabExecutor {
return false;
}
existingSession.triggerQuit(false);
existingSession.triggerQuit(false, true);
return true;
}

View File

@ -94,11 +94,13 @@ public class JoinDropperArenaCommand implements CommandExecutor {
boolean teleported = PlayerTeleporter.teleportPlayer(player, specifiedArena.getSpawnLocation(), false, false);
if (!teleported) {
player.sendMessage(Message.ERROR_ARENA_TELEPORT_FAILED.getMessage());
newSession.triggerQuit(false);
newSession.triggerQuit(false, true);
return false;
} else {
// Make sure to update the state again in the air to remove a potential swimming state
newSession.getEntryState().setArenaState();
// Update visibility for the player
MiniGames.getInstance().getPlayerVisibilityManager().updateHiddenPlayers(playerRegistry, player);
player.sendMessage(Message.SUCCESS_ARENA_JOINED.getMessage());
return true;
}

View File

@ -92,11 +92,13 @@ public class JoinParkourArenaCommand implements CommandExecutor {
boolean teleported = PlayerTeleporter.teleportPlayer(player, specifiedArena.getSpawnLocation(), false, false);
if (!teleported) {
player.sendMessage(Message.ERROR_ARENA_TELEPORT_FAILED.getMessage());
newSession.triggerQuit(false);
newSession.triggerQuit(false, true);
return false;
} else {
// Make sure to update the state again in the air to remove a potential swimming state
newSession.getEntryState().setArenaState();
// Update visibility for the player
MiniGames.getInstance().getPlayerVisibilityManager().updateHiddenPlayers(playerRegistry, player);
player.sendMessage(Message.SUCCESS_ARENA_JOINED.getMessage());
return true;
}

View File

@ -1,44 +0,0 @@
package net.knarcraft.minigames.command.parkour;
import net.knarcraft.minigames.MiniGames;
import net.knarcraft.minigames.arena.ArenaSession;
import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
import net.knarcraft.minigames.config.Message;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* The command for returning to the previous checkpoint
*/
public class ParkourCheckpointCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] strings) {
if (!(commandSender instanceof Player player)) {
commandSender.sendMessage(Message.ERROR_PLAYER_ONLY.getMessage());
return false;
}
ArenaSession session = MiniGames.getInstance().getSession(player.getUniqueId());
if (session instanceof ParkourArenaSession) {
session.triggerLoss();
}
return true;
}
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] strings) {
return new ArrayList<>();
}
}