mirror of
				https://github.com/SunNetservers/MiniGames.git
				synced 2025-11-04 03:33:47 +01:00 
			
		
		
		
	Removes some redundancy between various classes
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
				
			|||||||
package net.knarcraft.minigames;
 | 
					package net.knarcraft.minigames;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaSession;
 | 
					import net.knarcraft.minigames.arena.ArenaSession;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArena;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArena;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaData;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaData;
 | 
				
			||||||
@@ -8,7 +9,6 @@ import net.knarcraft.minigames.arena.dropper.DropperArenaGroup;
 | 
				
			|||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaHandler;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaHandler;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaPlayerRegistry;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaPlayerRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaRecordsRegistry;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaRecordsRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaSession;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArena;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArena;
 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaData;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArenaData;
 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaGameMode;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArenaGameMode;
 | 
				
			||||||
@@ -77,11 +77,11 @@ public final class MiniGames extends JavaPlugin {
 | 
				
			|||||||
    private DropperConfiguration dropperConfiguration;
 | 
					    private DropperConfiguration dropperConfiguration;
 | 
				
			||||||
    private ParkourConfiguration parkourConfiguration;
 | 
					    private ParkourConfiguration parkourConfiguration;
 | 
				
			||||||
    private DropperArenaHandler dropperArenaHandler;
 | 
					    private DropperArenaHandler dropperArenaHandler;
 | 
				
			||||||
    private DropperArenaPlayerRegistry dropperArenaPlayerRegistry;
 | 
					    private ArenaPlayerRegistry<DropperArena> dropperArenaPlayerRegistry;
 | 
				
			||||||
    private DropperRecordExpansion dropperRecordExpansion;
 | 
					    private DropperRecordExpansion dropperRecordExpansion;
 | 
				
			||||||
    private ParkourRecordExpansion parkourRecordExpansion;
 | 
					    private ParkourRecordExpansion parkourRecordExpansion;
 | 
				
			||||||
    private ParkourArenaHandler parkourArenaHandler;
 | 
					    private ParkourArenaHandler parkourArenaHandler;
 | 
				
			||||||
    private ParkourArenaPlayerRegistry parkourArenaPlayerRegistry;
 | 
					    private ArenaPlayerRegistry<ParkourArena> parkourArenaPlayerRegistry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets an instance of this plugin
 | 
					     * Gets an instance of this plugin
 | 
				
			||||||
@@ -115,7 +115,7 @@ public final class MiniGames extends JavaPlugin {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return <p>A dropper arena player registry</p>
 | 
					     * @return <p>A dropper arena player registry</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public DropperArenaPlayerRegistry getDropperArenaPlayerRegistry() {
 | 
					    public ArenaPlayerRegistry<DropperArena> getDropperArenaPlayerRegistry() {
 | 
				
			||||||
        return this.dropperArenaPlayerRegistry;
 | 
					        return this.dropperArenaPlayerRegistry;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -124,7 +124,7 @@ public final class MiniGames extends JavaPlugin {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return <p>A parkour arena player registry</p>
 | 
					     * @return <p>A parkour arena player registry</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public ParkourArenaPlayerRegistry getParkourArenaPlayerRegistry() {
 | 
					    public ArenaPlayerRegistry<ParkourArena> getParkourArenaPlayerRegistry() {
 | 
				
			||||||
        return this.parkourArenaPlayerRegistry;
 | 
					        return this.parkourArenaPlayerRegistry;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -164,7 +164,7 @@ public final class MiniGames extends JavaPlugin {
 | 
				
			|||||||
     * @return <p>The player's current session, or null if not found</p>
 | 
					     * @return <p>The player's current session, or null if not found</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public @Nullable ArenaSession getSession(@NotNull UUID playerId) {
 | 
					    public @Nullable ArenaSession getSession(@NotNull UUID playerId) {
 | 
				
			||||||
        DropperArenaSession dropperArenaSession = dropperArenaPlayerRegistry.getArenaSession(playerId);
 | 
					        ArenaSession dropperArenaSession = dropperArenaPlayerRegistry.getArenaSession(playerId);
 | 
				
			||||||
        if (dropperArenaSession != null) {
 | 
					        if (dropperArenaSession != null) {
 | 
				
			||||||
            return dropperArenaSession;
 | 
					            return dropperArenaSession;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					package net.knarcraft.minigames.arena;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * A player registry to keep track of currently playing players
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param <K> <p>The type of arena stored</p>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public abstract class AbstractArenaPlayerRegistry<K extends Arena> implements ArenaPlayerRegistry<K> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final Map<UUID, ArenaSession> arenaPlayers = new HashMap<>();
 | 
				
			||||||
 | 
					    private final Map<UUID, PlayerEntryState> entryStates = new HashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //TODO: Save all entry states each time the map changes
 | 
				
			||||||
 | 
					    //TODO: If a player joins, and their entry state exists, restore the state
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void registerPlayer(@NotNull UUID playerId, @NotNull ArenaSession arenaSession) {
 | 
				
			||||||
 | 
					        this.arenaPlayers.put(playerId, arenaSession);
 | 
				
			||||||
 | 
					        this.entryStates.put(playerId, arenaSession.getEntryState());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean removePlayer(@NotNull UUID playerId) {
 | 
				
			||||||
 | 
					        this.entryStates.remove(playerId);
 | 
				
			||||||
 | 
					        return this.arenaPlayers.remove(playerId) != null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public @Nullable ArenaSession getArenaSession(@NotNull UUID playerId) {
 | 
				
			||||||
 | 
					        return this.arenaPlayers.getOrDefault(playerId, null);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void removeForArena(K arena, boolean immediately) {
 | 
				
			||||||
 | 
					        for (Map.Entry<UUID, ArenaSession> entry : this.arenaPlayers.entrySet()) {
 | 
				
			||||||
 | 
					            if (entry.getValue().getArena() == arena) {
 | 
				
			||||||
 | 
					                // Kick the player gracefully
 | 
				
			||||||
 | 
					                entry.getValue().triggerQuit(immediately);
 | 
				
			||||||
 | 
					                this.arenaPlayers.remove(entry.getKey());
 | 
				
			||||||
 | 
					                this.entryStates.remove(entry.getKey());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,118 @@
 | 
				
			|||||||
 | 
					package net.knarcraft.minigames.arena;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.container.PlaceholderContainer;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.property.RecordResult;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.util.PlayerTeleporter;
 | 
				
			||||||
 | 
					import org.bukkit.Location;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class AbstractArenaSession implements ArenaSession {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final @NotNull Arena arena;
 | 
				
			||||||
 | 
					    private final @NotNull ArenaGameMode gameMode;
 | 
				
			||||||
 | 
					    private final @NotNull Player player;
 | 
				
			||||||
 | 
					    protected int deaths;
 | 
				
			||||||
 | 
					    protected final long startTime;
 | 
				
			||||||
 | 
					    protected PlayerEntryState entryState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Instantiates a new abstract arena session
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param arena    <p>The arena that's being played in</p>
 | 
				
			||||||
 | 
					     * @param player   <p>The player playing the arena</p>
 | 
				
			||||||
 | 
					     * @param gameMode <p>The game-mode</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public AbstractArenaSession(@NotNull Arena arena, @NotNull Player player, @NotNull ArenaGameMode gameMode) {
 | 
				
			||||||
 | 
					        this.arena = arena;
 | 
				
			||||||
 | 
					        this.player = player;
 | 
				
			||||||
 | 
					        this.gameMode = gameMode;
 | 
				
			||||||
 | 
					        this.deaths = 0;
 | 
				
			||||||
 | 
					        this.startTime = System.currentTimeMillis();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void triggerQuit(boolean immediately) {
 | 
				
			||||||
 | 
					        // Stop this session
 | 
				
			||||||
 | 
					        stopSession();
 | 
				
			||||||
 | 
					        // Teleport the player out of the arena
 | 
				
			||||||
 | 
					        teleportToExit(immediately);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        player.sendMessage(Message.SUCCESS_ARENA_QUIT.getMessage());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Announces a record set by this player
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param recordResult <p>The result of the record</p>
 | 
				
			||||||
 | 
					     * @param type         <p>The type of record set (time or deaths)</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected void announceRecord(@NotNull RecordResult recordResult, @NotNull String type) {
 | 
				
			||||||
 | 
					        if (recordResult == RecordResult.NONE) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Gets a string representation of the played game-mode
 | 
				
			||||||
 | 
					        String gameModeString = getGameModeString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Message recordInfoMessage = switch (recordResult) {
 | 
				
			||||||
 | 
					            case WORLD_RECORD -> Message.RECORD_ACHIEVED_GLOBAL;
 | 
				
			||||||
 | 
					            case PERSONAL_BEST -> Message.RECORD_ACHIEVED_PERSONAL;
 | 
				
			||||||
 | 
					            default -> throw new IllegalStateException("Unexpected value: " + recordResult);
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        String recordInfo = recordInfoMessage.getMessage("{recordType}", type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        PlaceholderContainer placeholderContainer = new PlaceholderContainer().add("{gameMode}", gameModeString);
 | 
				
			||||||
 | 
					        placeholderContainer.add("{recordInfo}", recordInfo);
 | 
				
			||||||
 | 
					        player.sendMessage(Message.SUCCESS_RECORD_ACHIEVED.getMessage(placeholderContainer));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Registers the player's record if necessary, and prints record information to the player
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected void registerRecord() {
 | 
				
			||||||
 | 
					        ArenaRecordsRegistry recordsRegistry = this.arena.getData().getRecordRegistries().get(this.gameMode);
 | 
				
			||||||
 | 
					        long timeElapsed = System.currentTimeMillis() - this.startTime;
 | 
				
			||||||
 | 
					        announceRecord(recordsRegistry.registerTimeRecord(this.player.getUniqueId(), timeElapsed), "time");
 | 
				
			||||||
 | 
					        announceRecord(recordsRegistry.registerDeathRecord(this.player.getUniqueId(), this.deaths), "least deaths");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Teleports the playing player out of the arena
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected void teleportToExit(boolean immediately) {
 | 
				
			||||||
 | 
					        // Teleport the player out of the arena
 | 
				
			||||||
 | 
					        Location exitLocation;
 | 
				
			||||||
 | 
					        if (this.arena.getExitLocation() != null) {
 | 
				
			||||||
 | 
					            exitLocation = this.arena.getExitLocation();
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            exitLocation = this.entryState.getEntryLocation();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        PlayerTeleporter.teleportPlayer(this.player, exitLocation, true, immediately);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Stops this session, and disables flight mode
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected void stopSession() {
 | 
				
			||||||
 | 
					        // Remove this session from game sessions to stop listeners from fiddling more with the player
 | 
				
			||||||
 | 
					        removeSession();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Remove flight mode
 | 
				
			||||||
 | 
					        entryState.restore();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the string representation of the session's game-mode
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return <p>The string representation</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected abstract String getGameModeString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Removes this session from current sessions
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected abstract void removeSession();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -3,6 +3,7 @@ package net.knarcraft.minigames.arena;
 | 
				
			|||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.block.Block;
 | 
					import org.bukkit.block.Block;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -83,4 +84,11 @@ public interface Arena {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull Location getSpawnLocation();
 | 
					    @NotNull Location getSpawnLocation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets this arena's exit location
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return <p>This arena's exit location, or null if no such location is set.</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Nullable Location getExitLocation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,10 @@
 | 
				
			|||||||
package net.knarcraft.minigames.arena;
 | 
					package net.knarcraft.minigames.arena;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					import org.jetbrains.annotations.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * A registry keeping track of all player sessions for some arenas
 | 
					 * A registry keeping track of all player sessions for some arenas
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -7,6 +12,29 @@ package net.knarcraft.minigames.arena;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public interface ArenaPlayerRegistry<K extends Arena> {
 | 
					public interface ArenaPlayerRegistry<K extends Arena> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Registers that the given player has started playing the given dropper arena session
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param playerId     <p>The id of the player that started playing</p>
 | 
				
			||||||
 | 
					     * @param arenaSession <p>The arena session to register</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    void registerPlayer(@NotNull UUID playerId, @NotNull ArenaSession arenaSession);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Removes this player from players currently playing
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param playerId <p>The id of the player to remove</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    boolean removePlayer(@NotNull UUID playerId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the player's active dropper arena session
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param playerId <p>The id of the player to get arena for</p>
 | 
				
			||||||
 | 
					     * @return <p>The player's active arena session, or null if not currently playing</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Nullable ArenaSession getArenaSession(@NotNull UUID playerId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Removes all active sessions for the given arena
 | 
					     * Removes all active sessions for the given arena
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,5 @@
 | 
				
			|||||||
package net.knarcraft.minigames.arena;
 | 
					package net.knarcraft.minigames.arena;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -8,13 +7,6 @@ import org.jetbrains.annotations.NotNull;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public interface ArenaSession {
 | 
					public interface ArenaSession {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the game-mode the player is playing in this session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>The game-mode for this session</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @NotNull ArenaGameMode getGameMode();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets the state of the player when they joined the session
 | 
					     * Gets the state of the player when they joined the session
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -46,11 +38,4 @@ public interface ArenaSession {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @NotNull Arena getArena();
 | 
					    @NotNull Arena getArena();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the player playing in this session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>This session's player</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    @NotNull Player getPlayer();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -150,11 +150,7 @@ public class DropperArena implements Arena {
 | 
				
			|||||||
        return this.spawnLocation.clone();
 | 
					        return this.spawnLocation.clone();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Gets this arena's exit location
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>This arena's exit location, or null if no such location is set.</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @Nullable Location getExitLocation() {
 | 
					    public @Nullable Location getExitLocation() {
 | 
				
			||||||
        return this.exitLocation != null ? this.exitLocation.clone() : null;
 | 
					        return this.exitLocation != null ? this.exitLocation.clone() : null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package net.knarcraft.minigames.arena.dropper;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.MiniGames;
 | 
					import net.knarcraft.minigames.MiniGames;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaHandler;
 | 
					import net.knarcraft.minigames.arena.ArenaHandler;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.config.Message;
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
import net.knarcraft.minigames.util.DropperArenaStorageHelper;
 | 
					import net.knarcraft.minigames.util.DropperArenaStorageHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,7 +24,7 @@ public class DropperArenaHandler extends ArenaHandler<DropperArena, DropperArena
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param playerRegistry <p>The registry keeping track of player sessions</p>
 | 
					     * @param playerRegistry <p>The registry keeping track of player sessions</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public DropperArenaHandler(DropperArenaPlayerRegistry playerRegistry) {
 | 
					    public DropperArenaHandler(ArenaPlayerRegistry<DropperArena> playerRegistry) {
 | 
				
			||||||
        super(playerRegistry);
 | 
					        super(playerRegistry);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,58 +1,9 @@
 | 
				
			|||||||
package net.knarcraft.minigames.arena.dropper;
 | 
					package net.knarcraft.minigames.arena.dropper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
					import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					 | 
				
			||||||
import org.jetbrains.annotations.Nullable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.HashMap;
 | 
					 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
import java.util.UUID;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * A registry to keep track of which players are playing in which arenas
 | 
					 * A registry to keep track of which players are playing in which arenas
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class DropperArenaPlayerRegistry implements ArenaPlayerRegistry<DropperArena> {
 | 
					public class DropperArenaPlayerRegistry extends AbstractArenaPlayerRegistry<DropperArena> {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final Map<UUID, DropperArenaSession> arenaPlayers = new HashMap<>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Registers that the given player has started playing the given dropper arena session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param playerId <p>The id of the player that started playing</p>
 | 
					 | 
				
			||||||
     * @param arena    <p>The arena session to register</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void registerPlayer(@NotNull UUID playerId, @NotNull DropperArenaSession arena) {
 | 
					 | 
				
			||||||
        this.arenaPlayers.put(playerId, arena);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Removes this player from players currently playing
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param playerId <p>The id of the player to remove</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public boolean removePlayer(@NotNull UUID playerId) {
 | 
					 | 
				
			||||||
        return this.arenaPlayers.remove(playerId) != null;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the player's active dropper arena session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param playerId <p>The id of the player to get arena for</p>
 | 
					 | 
				
			||||||
     * @return <p>The player's active arena session, or null if not currently playing</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @Nullable DropperArenaSession getArenaSession(@NotNull UUID playerId) {
 | 
					 | 
				
			||||||
        return this.arenaPlayers.getOrDefault(playerId, null);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public void removeForArena(DropperArena arena, boolean immediately) {
 | 
					 | 
				
			||||||
        for (Map.Entry<UUID, DropperArenaSession> entry : this.arenaPlayers.entrySet()) {
 | 
					 | 
				
			||||||
            if (entry.getValue().getArena() == arena) {
 | 
					 | 
				
			||||||
                // Kick the player gracefully
 | 
					 | 
				
			||||||
                entry.getValue().triggerQuit(immediately);
 | 
					 | 
				
			||||||
                this.arenaPlayers.remove(entry.getKey());
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,11 @@
 | 
				
			|||||||
package net.knarcraft.minigames.arena.dropper;
 | 
					package net.knarcraft.minigames.arena.dropper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.MiniGames;
 | 
					import net.knarcraft.minigames.MiniGames;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaRecordsRegistry;
 | 
					import net.knarcraft.minigames.arena.AbstractArenaSession;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaSession;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.arena.PlayerEntryState;
 | 
					import net.knarcraft.minigames.arena.PlayerEntryState;
 | 
				
			||||||
import net.knarcraft.minigames.config.DropperConfiguration;
 | 
					import net.knarcraft.minigames.config.DropperConfiguration;
 | 
				
			||||||
import net.knarcraft.minigames.config.Message;
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
import net.knarcraft.minigames.property.RecordResult;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.util.PlayerTeleporter;
 | 
					import net.knarcraft.minigames.util.PlayerTeleporter;
 | 
				
			||||||
import org.bukkit.Location;
 | 
					 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					import org.jetbrains.annotations.NotNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,14 +14,11 @@ import java.util.logging.Level;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * A representation of a player's current session in a dropper arena
 | 
					 * A representation of a player's current session in a dropper arena
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class DropperArenaSession implements ArenaSession {
 | 
					public class DropperArenaSession extends AbstractArenaSession {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final @NotNull DropperArena arena;
 | 
					    private final @NotNull DropperArena arena;
 | 
				
			||||||
    private final @NotNull Player player;
 | 
					    private final @NotNull Player player;
 | 
				
			||||||
    private final @NotNull DropperArenaGameMode gameMode;
 | 
					    private final @NotNull DropperArenaGameMode gameMode;
 | 
				
			||||||
    private int deaths;
 | 
					 | 
				
			||||||
    private final long startTime;
 | 
					 | 
				
			||||||
    private final PlayerEntryState entryState;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Instantiates a new dropper arena session
 | 
					     * Instantiates a new dropper arena session
 | 
				
			||||||
@@ -35,21 +29,28 @@ public class DropperArenaSession implements ArenaSession {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public DropperArenaSession(@NotNull DropperArena dropperArena, @NotNull Player player,
 | 
					    public DropperArenaSession(@NotNull DropperArena dropperArena, @NotNull Player player,
 | 
				
			||||||
                               @NotNull DropperArenaGameMode gameMode) {
 | 
					                               @NotNull DropperArenaGameMode gameMode) {
 | 
				
			||||||
 | 
					        super(dropperArena, player, gameMode);
 | 
				
			||||||
        this.arena = dropperArena;
 | 
					        this.arena = dropperArena;
 | 
				
			||||||
        this.player = player;
 | 
					        this.player = player;
 | 
				
			||||||
        this.gameMode = gameMode;
 | 
					        this.gameMode = gameMode;
 | 
				
			||||||
        this.deaths = 0;
 | 
					 | 
				
			||||||
        this.startTime = System.currentTimeMillis();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DropperConfiguration configuration = MiniGames.getInstance().getDropperConfiguration();
 | 
					        DropperConfiguration configuration = MiniGames.getInstance().getDropperConfiguration();
 | 
				
			||||||
        boolean makeInvisible = configuration.makePlayersInvisible();
 | 
					        boolean makeInvisible = configuration.makePlayersInvisible();
 | 
				
			||||||
        boolean disableCollision = configuration.disableHitCollision();
 | 
					        boolean disableCollision = configuration.disableHitCollision();
 | 
				
			||||||
        this.entryState = new DropperPlayerEntryState(player, gameMode, makeInvisible, disableCollision,
 | 
					        this.entryState = new DropperPlayerEntryState(player, gameMode, makeInvisible, disableCollision,
 | 
				
			||||||
                dropperArena.getPlayerHorizontalVelocity());
 | 
					                dropperArena.getPlayerHorizontalVelocity());
 | 
				
			||||||
        // Make the player fly to improve mobility in the air
 | 
					 | 
				
			||||||
        this.entryState.setArenaState();
 | 
					        this.entryState.setArenaState();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Gets the player playing in this session
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return <p>This session's player</p>
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public @NotNull Player getPlayer() {
 | 
				
			||||||
 | 
					        return this.player;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets the game-mode the player is playing in this session
 | 
					     * Gets the game-mode the player is playing in this session
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -59,18 +60,12 @@ public class DropperArenaSession implements ArenaSession {
 | 
				
			|||||||
        return this.gameMode;
 | 
					        return this.gameMode;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Gets the state of the player when they joined the session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>The player's entry state</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @NotNull PlayerEntryState getEntryState() {
 | 
					    public @NotNull PlayerEntryState getEntryState() {
 | 
				
			||||||
        return this.entryState;
 | 
					        return this.entryState;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Triggers a win for the player playing in this session
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void triggerWin() {
 | 
					    public void triggerWin() {
 | 
				
			||||||
        // Stop this session
 | 
					        // Stop this session
 | 
				
			||||||
        stopSession();
 | 
					        stopSession();
 | 
				
			||||||
@@ -93,26 +88,21 @@ public class DropperArenaSession implements ArenaSession {
 | 
				
			|||||||
        teleportToExit(false);
 | 
					        teleportToExit(false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Teleports the playing player out of the arena
 | 
					    public void triggerLoss() {
 | 
				
			||||||
     *
 | 
					        this.deaths++;
 | 
				
			||||||
     * @param immediately <p>Whether to to the teleportation immediately, not using any timers</p>
 | 
					        //Teleport the player back to the top
 | 
				
			||||||
     */
 | 
					        PlayerTeleporter.teleportPlayer(this.player, this.arena.getSpawnLocation(), true, false);
 | 
				
			||||||
    private void teleportToExit(boolean immediately) {
 | 
					        this.entryState.setArenaState();
 | 
				
			||||||
        // Teleport the player out of the arena
 | 
					 | 
				
			||||||
        Location exitLocation;
 | 
					 | 
				
			||||||
        if (this.arena.getExitLocation() != null) {
 | 
					 | 
				
			||||||
            exitLocation = this.arena.getExitLocation();
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            exitLocation = this.entryState.getEntryLocation();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        PlayerTeleporter.teleportPlayer(this.player, exitLocation, true, immediately);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Removes this session from current sessions
 | 
					    public @NotNull DropperArena getArena() {
 | 
				
			||||||
     */
 | 
					        return this.arena;
 | 
				
			||||||
    private void removeSession() {
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void removeSession() {
 | 
				
			||||||
        // Remove this session for game sessions to stop listeners from fiddling more with the player
 | 
					        // Remove this session for game sessions to stop listeners from fiddling more with the player
 | 
				
			||||||
        boolean removedSession = MiniGames.getInstance().getDropperArenaPlayerRegistry().removePlayer(player.getUniqueId());
 | 
					        boolean removedSession = MiniGames.getInstance().getDropperArenaPlayerRegistry().removePlayer(player.getUniqueId());
 | 
				
			||||||
        if (!removedSession) {
 | 
					        if (!removedSession) {
 | 
				
			||||||
@@ -121,94 +111,13 @@ public class DropperArenaSession implements ArenaSession {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Registers the player's record if necessary, and prints record information to the player
 | 
					    protected String getGameModeString() {
 | 
				
			||||||
     */
 | 
					        return switch (this.gameMode) {
 | 
				
			||||||
    private void registerRecord() {
 | 
					 | 
				
			||||||
        ArenaRecordsRegistry recordsRegistry = this.arena.getData().getRecordRegistries().get(this.gameMode);
 | 
					 | 
				
			||||||
        long timeElapsed = System.currentTimeMillis() - this.startTime;
 | 
					 | 
				
			||||||
        announceRecord(recordsRegistry.registerTimeRecord(this.player.getUniqueId(), timeElapsed), "time");
 | 
					 | 
				
			||||||
        announceRecord(recordsRegistry.registerDeathRecord(this.player.getUniqueId(), this.deaths), "least deaths");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Announces a record set by this player
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param recordResult <p>The result of the record</p>
 | 
					 | 
				
			||||||
     * @param type         <p>The type of record set (time or deaths)</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void announceRecord(@NotNull RecordResult recordResult, @NotNull String type) {
 | 
					 | 
				
			||||||
        if (recordResult == RecordResult.NONE) {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Gets a string representation of the played game-mode
 | 
					 | 
				
			||||||
        String gameModeString = switch (this.gameMode) {
 | 
					 | 
				
			||||||
            case DEFAULT -> "default";
 | 
					            case DEFAULT -> "default";
 | 
				
			||||||
            case INVERTED -> "inverted";
 | 
					            case INVERTED -> "inverted";
 | 
				
			||||||
            case RANDOM_INVERTED -> "random";
 | 
					            case RANDOM_INVERTED -> "random";
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					 | 
				
			||||||
        String recordString = "You just set a %s on the %s game-mode!";
 | 
					 | 
				
			||||||
        recordString = switch (recordResult) {
 | 
					 | 
				
			||||||
            case WORLD_RECORD -> String.format(recordString, "new %s record", gameModeString);
 | 
					 | 
				
			||||||
            case PERSONAL_BEST -> String.format(recordString, "personal %s record", gameModeString);
 | 
					 | 
				
			||||||
            default -> throw new IllegalStateException("Unexpected value: " + recordResult);
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        player.sendMessage(String.format(recordString, type));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Triggers a loss for the player playing in this session
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void triggerLoss() {
 | 
					 | 
				
			||||||
        this.deaths++;
 | 
					 | 
				
			||||||
        //Teleport the player back to the top
 | 
					 | 
				
			||||||
        PlayerTeleporter.teleportPlayer(this.player, this.arena.getSpawnLocation(), true, false);
 | 
					 | 
				
			||||||
        this.entryState.setArenaState();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Triggers a quit for the player playing in this session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param immediately <p>Whether to to the teleportation immediately, not using any timers</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void triggerQuit(boolean immediately) {
 | 
					 | 
				
			||||||
        // Stop this session
 | 
					 | 
				
			||||||
        stopSession();
 | 
					 | 
				
			||||||
        // Teleport the player out of the arena
 | 
					 | 
				
			||||||
        teleportToExit(immediately);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        player.sendMessage(Message.SUCCESS_ARENA_QUIT.getMessage());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Stops this session, and disables flight mode
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void stopSession() {
 | 
					 | 
				
			||||||
        // Remove this session from game sessions to stop listeners from fiddling more with the player
 | 
					 | 
				
			||||||
        removeSession();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Remove flight mode
 | 
					 | 
				
			||||||
        entryState.restore();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the arena this session is being played in
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>The session's arena</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @NotNull DropperArena getArena() {
 | 
					 | 
				
			||||||
        return this.arena;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the player playing in this session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>This session's player</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @NotNull Player getPlayer() {
 | 
					 | 
				
			||||||
        return this.player;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,11 +162,7 @@ public class ParkourArena implements Arena {
 | 
				
			|||||||
        return this.spawnLocation;
 | 
					        return this.spawnLocation;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Gets this arena's exit location
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>This arena's exit location, or null if no such location is set.</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @Nullable Location getExitLocation() {
 | 
					    public @Nullable Location getExitLocation() {
 | 
				
			||||||
        return this.exitLocation;
 | 
					        return this.exitLocation;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package net.knarcraft.minigames.arena.parkour;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.MiniGames;
 | 
					import net.knarcraft.minigames.MiniGames;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaHandler;
 | 
					import net.knarcraft.minigames.arena.ArenaHandler;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.config.Message;
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
import net.knarcraft.minigames.util.ParkourArenaStorageHelper;
 | 
					import net.knarcraft.minigames.util.ParkourArenaStorageHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,7 +24,7 @@ public class ParkourArenaHandler extends ArenaHandler<ParkourArena, ParkourArena
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param playerRegistry <p>The registry keeping track of player sessions</p>
 | 
					     * @param playerRegistry <p>The registry keeping track of player sessions</p>
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public ParkourArenaHandler(ParkourArenaPlayerRegistry playerRegistry) {
 | 
					    public ParkourArenaHandler(ArenaPlayerRegistry<ParkourArena> playerRegistry) {
 | 
				
			||||||
        super(playerRegistry);
 | 
					        super(playerRegistry);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,58 +1,9 @@
 | 
				
			|||||||
package net.knarcraft.minigames.arena.parkour;
 | 
					package net.knarcraft.minigames.arena.parkour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
					import net.knarcraft.minigames.arena.AbstractArenaPlayerRegistry;
 | 
				
			||||||
import org.jetbrains.annotations.NotNull;
 | 
					 | 
				
			||||||
import org.jetbrains.annotations.Nullable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.HashMap;
 | 
					 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
import java.util.UUID;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * A registry to keep track of which players are playing in which arenas
 | 
					 * A registry to keep track of which players are playing in which arenas
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class ParkourArenaPlayerRegistry implements ArenaPlayerRegistry<ParkourArena> {
 | 
					public class ParkourArenaPlayerRegistry extends AbstractArenaPlayerRegistry<ParkourArena> {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final Map<UUID, ParkourArenaSession> arenaPlayers = new HashMap<>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Registers that the given player has started playing the given parkour arena session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param playerId <p>The id of the player that started playing</p>
 | 
					 | 
				
			||||||
     * @param arena    <p>The arena session to register</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void registerPlayer(@NotNull UUID playerId, @NotNull ParkourArenaSession arena) {
 | 
					 | 
				
			||||||
        this.arenaPlayers.put(playerId, arena);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Removes this player from players currently playing
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param playerId <p>The id of the player to remove</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public boolean removePlayer(@NotNull UUID playerId) {
 | 
					 | 
				
			||||||
        return this.arenaPlayers.remove(playerId) != null;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the player's active parkour arena session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param playerId <p>The id of the player to get arena for</p>
 | 
					 | 
				
			||||||
     * @return <p>The player's active arena session, or null if not currently playing</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @Nullable ParkourArenaSession getArenaSession(@NotNull UUID playerId) {
 | 
					 | 
				
			||||||
        return this.arenaPlayers.getOrDefault(playerId, null);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public void removeForArena(ParkourArena arena, boolean immediately) {
 | 
					 | 
				
			||||||
        for (Map.Entry<UUID, ParkourArenaSession> entry : this.arenaPlayers.entrySet()) {
 | 
					 | 
				
			||||||
            if (entry.getValue().getArena() == arena) {
 | 
					 | 
				
			||||||
                // Kick the player gracefully
 | 
					 | 
				
			||||||
                entry.getValue().triggerQuit(immediately);
 | 
					 | 
				
			||||||
                this.arenaPlayers.remove(entry.getKey());
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,10 @@
 | 
				
			|||||||
package net.knarcraft.minigames.arena.parkour;
 | 
					package net.knarcraft.minigames.arena.parkour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.MiniGames;
 | 
					import net.knarcraft.minigames.MiniGames;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaGameMode;
 | 
					import net.knarcraft.minigames.arena.AbstractArenaSession;
 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaRecordsRegistry;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.arena.ArenaSession;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.arena.PlayerEntryState;
 | 
					import net.knarcraft.minigames.arena.PlayerEntryState;
 | 
				
			||||||
import net.knarcraft.minigames.config.Message;
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
import net.knarcraft.minigames.config.ParkourConfiguration;
 | 
					import net.knarcraft.minigames.config.ParkourConfiguration;
 | 
				
			||||||
import net.knarcraft.minigames.property.RecordResult;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.util.PlayerTeleporter;
 | 
					import net.knarcraft.minigames.util.PlayerTeleporter;
 | 
				
			||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
@@ -19,14 +16,11 @@ import java.util.logging.Level;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * A representation of a player's current session in a parkour arena
 | 
					 * A representation of a player's current session in a parkour arena
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class ParkourArenaSession implements ArenaSession {
 | 
					public class ParkourArenaSession extends AbstractArenaSession {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final @NotNull ParkourArena arena;
 | 
					    private final @NotNull ParkourArena arena;
 | 
				
			||||||
    private final @NotNull Player player;
 | 
					    private final @NotNull Player player;
 | 
				
			||||||
    private final @NotNull ParkourArenaGameMode gameMode;
 | 
					    private final @NotNull ParkourArenaGameMode gameMode;
 | 
				
			||||||
    private int deaths;
 | 
					 | 
				
			||||||
    private final long startTime;
 | 
					 | 
				
			||||||
    private final PlayerEntryState entryState;
 | 
					 | 
				
			||||||
    private Location reachedCheckpoint = null;
 | 
					    private Location reachedCheckpoint = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -38,33 +32,17 @@ public class ParkourArenaSession implements ArenaSession {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public ParkourArenaSession(@NotNull ParkourArena parkourArena, @NotNull Player player,
 | 
					    public ParkourArenaSession(@NotNull ParkourArena parkourArena, @NotNull Player player,
 | 
				
			||||||
                               @NotNull ParkourArenaGameMode gameMode) {
 | 
					                               @NotNull ParkourArenaGameMode gameMode) {
 | 
				
			||||||
 | 
					        super(parkourArena, player, gameMode);
 | 
				
			||||||
        this.arena = parkourArena;
 | 
					        this.arena = parkourArena;
 | 
				
			||||||
        this.player = player;
 | 
					        this.player = player;
 | 
				
			||||||
        this.gameMode = gameMode;
 | 
					        this.gameMode = gameMode;
 | 
				
			||||||
        this.deaths = 0;
 | 
					 | 
				
			||||||
        this.startTime = System.currentTimeMillis();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ParkourConfiguration configuration = MiniGames.getInstance().getParkourConfiguration();
 | 
					        ParkourConfiguration configuration = MiniGames.getInstance().getParkourConfiguration();
 | 
				
			||||||
        boolean makeInvisible = configuration.makePlayersInvisible();
 | 
					        boolean makeInvisible = configuration.makePlayersInvisible();
 | 
				
			||||||
        this.entryState = new ParkourPlayerEntryState(player, makeInvisible);
 | 
					        this.entryState = new ParkourPlayerEntryState(player, makeInvisible);
 | 
				
			||||||
        // Make the player fly to improve mobility in the air
 | 
					 | 
				
			||||||
        this.entryState.setArenaState();
 | 
					        this.entryState.setArenaState();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public @NotNull ArenaGameMode getGameMode() {
 | 
					 | 
				
			||||||
        return this.gameMode;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the state of the player when they joined the session
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>The player's entry state</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @NotNull PlayerEntryState getEntryState() {
 | 
					 | 
				
			||||||
        return this.entryState;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Registers the checkpoint this session's player has reached
 | 
					     * Registers the checkpoint this session's player has reached
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -83,9 +61,12 @@ public class ParkourArenaSession implements ArenaSession {
 | 
				
			|||||||
        return this.reachedCheckpoint;
 | 
					        return this.reachedCheckpoint;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Triggers a win for the player playing in this session
 | 
					    public @NotNull PlayerEntryState getEntryState() {
 | 
				
			||||||
     */
 | 
					        return this.entryState;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
    public void triggerWin() {
 | 
					    public void triggerWin() {
 | 
				
			||||||
        // Stop this session
 | 
					        // Stop this session
 | 
				
			||||||
        stopSession();
 | 
					        stopSession();
 | 
				
			||||||
@@ -108,70 +89,7 @@ public class ParkourArenaSession implements ArenaSession {
 | 
				
			|||||||
        teleportToExit(false);
 | 
					        teleportToExit(false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Teleports the playing player out of the arena
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void teleportToExit(boolean immediately) {
 | 
					 | 
				
			||||||
        // Teleport the player out of the arena
 | 
					 | 
				
			||||||
        Location exitLocation;
 | 
					 | 
				
			||||||
        if (this.arena.getExitLocation() != null) {
 | 
					 | 
				
			||||||
            exitLocation = this.arena.getExitLocation();
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            exitLocation = this.entryState.getEntryLocation();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        PlayerTeleporter.teleportPlayer(this.player, exitLocation, true, immediately);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Removes this session from current sessions
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void removeSession() {
 | 
					 | 
				
			||||||
        // Remove this session for game sessions to stop listeners from fiddling more with the player
 | 
					 | 
				
			||||||
        boolean removedSession = MiniGames.getInstance().getParkourArenaPlayerRegistry().removePlayer(player.getUniqueId());
 | 
					 | 
				
			||||||
        if (!removedSession) {
 | 
					 | 
				
			||||||
            MiniGames.log(Level.SEVERE, "Unable to remove parkour arena session for " + player.getName() + ". " +
 | 
					 | 
				
			||||||
                    "This will have unintended consequences.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Registers the player's record if necessary, and prints record information to the player
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void registerRecord() {
 | 
					 | 
				
			||||||
        ArenaRecordsRegistry recordsRegistry = this.arena.getData().getRecordRegistries().get(this.gameMode);
 | 
					 | 
				
			||||||
        long timeElapsed = System.currentTimeMillis() - this.startTime;
 | 
					 | 
				
			||||||
        announceRecord(recordsRegistry.registerTimeRecord(this.player.getUniqueId(), timeElapsed), "time");
 | 
					 | 
				
			||||||
        announceRecord(recordsRegistry.registerDeathRecord(this.player.getUniqueId(), this.deaths), "least deaths");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Announces a record set by this player
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param recordResult <p>The result of the record</p>
 | 
					 | 
				
			||||||
     * @param type         <p>The type of record set (time or deaths)</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void announceRecord(@NotNull RecordResult recordResult, @NotNull String type) {
 | 
					 | 
				
			||||||
        if (recordResult == RecordResult.NONE) {
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Gets a string representation of the played game-mode
 | 
					 | 
				
			||||||
        String gameModeString = switch (this.gameMode) {
 | 
					 | 
				
			||||||
            case DEFAULT -> "default";
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        String recordString = "You just set a %s on the %s game-mode!";
 | 
					 | 
				
			||||||
        recordString = switch (recordResult) {
 | 
					 | 
				
			||||||
            case WORLD_RECORD -> String.format(recordString, "new %s record", gameModeString);
 | 
					 | 
				
			||||||
            case PERSONAL_BEST -> String.format(recordString, "personal %s record", gameModeString);
 | 
					 | 
				
			||||||
            default -> throw new IllegalStateException("Unexpected value: " + recordResult);
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        player.sendMessage(String.format(recordString, type));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Triggers a loss for the player playing in this session
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void triggerLoss() {
 | 
					    public void triggerLoss() {
 | 
				
			||||||
        this.deaths++;
 | 
					        this.deaths++;
 | 
				
			||||||
        //Teleport the player back to the top
 | 
					        //Teleport the player back to the top
 | 
				
			||||||
@@ -180,45 +98,26 @@ public class ParkourArenaSession implements ArenaSession {
 | 
				
			|||||||
        this.entryState.setArenaState();
 | 
					        this.entryState.setArenaState();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Triggers a quit for the player playing in this session
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public void triggerQuit(boolean immediately) {
 | 
					 | 
				
			||||||
        // Stop this session
 | 
					 | 
				
			||||||
        stopSession();
 | 
					 | 
				
			||||||
        // Teleport the player out of the arena
 | 
					 | 
				
			||||||
        teleportToExit(immediately);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        player.sendMessage(Message.SUCCESS_ARENA_QUIT.getMessage());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Stops this session, and disables flight mode
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private void stopSession() {
 | 
					 | 
				
			||||||
        // Remove this session from game sessions to stop listeners from fiddling more with the player
 | 
					 | 
				
			||||||
        removeSession();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Remove flight mode
 | 
					 | 
				
			||||||
        entryState.restore();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Gets the arena this session is being played in
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return <p>The session's arena</p>
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public @NotNull ParkourArena getArena() {
 | 
					    public @NotNull ParkourArena getArena() {
 | 
				
			||||||
        return this.arena;
 | 
					        return this.arena;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    @Override
 | 
				
			||||||
     * Gets the player playing in this session
 | 
					    protected void removeSession() {
 | 
				
			||||||
     *
 | 
					        // Remove this session for game sessions to stop listeners from fiddling more with the player
 | 
				
			||||||
     * @return <p>This session's player</p>
 | 
					        boolean removedSession = MiniGames.getInstance().getParkourArenaPlayerRegistry().removePlayer(player.getUniqueId());
 | 
				
			||||||
     */
 | 
					        if (!removedSession) {
 | 
				
			||||||
    public @NotNull Player getPlayer() {
 | 
					            MiniGames.log(Level.SEVERE, "Unable to remove parkour arena session for " + player.getName() + ". " +
 | 
				
			||||||
        return this.player;
 | 
					                    "This will have unintended consequences.");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected String getGameModeString() {
 | 
				
			||||||
 | 
					        return switch (this.gameMode) {
 | 
				
			||||||
 | 
					            case DEFAULT -> "default";
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
package net.knarcraft.minigames.command.dropper;
 | 
					package net.knarcraft.minigames.command.dropper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.MiniGames;
 | 
					import net.knarcraft.minigames.MiniGames;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArena;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArena;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaGameMode;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaGameMode;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaGroup;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaGroup;
 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaPlayerRegistry;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaSession;
 | 
					import net.knarcraft.minigames.arena.dropper.DropperArenaSession;
 | 
				
			||||||
import net.knarcraft.minigames.config.DropperConfiguration;
 | 
					import net.knarcraft.minigames.config.DropperConfiguration;
 | 
				
			||||||
import net.knarcraft.minigames.config.Message;
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
@@ -87,7 +87,7 @@ public class JoinDropperArenaCommand implements CommandExecutor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Register the player's session
 | 
					        // Register the player's session
 | 
				
			||||||
        DropperArenaSession newSession = new DropperArenaSession(specifiedArena, player, gameMode);
 | 
					        DropperArenaSession newSession = new DropperArenaSession(specifiedArena, player, gameMode);
 | 
				
			||||||
        DropperArenaPlayerRegistry playerRegistry = MiniGames.getInstance().getDropperArenaPlayerRegistry();
 | 
					        ArenaPlayerRegistry<DropperArena> playerRegistry = MiniGames.getInstance().getDropperArenaPlayerRegistry();
 | 
				
			||||||
        playerRegistry.registerPlayer(player.getUniqueId(), newSession);
 | 
					        playerRegistry.registerPlayer(player.getUniqueId(), newSession);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Try to teleport the player to the arena
 | 
					        // Try to teleport the player to the arena
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
package net.knarcraft.minigames.command.parkour;
 | 
					package net.knarcraft.minigames.command.parkour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.knarcraft.minigames.MiniGames;
 | 
					import net.knarcraft.minigames.MiniGames;
 | 
				
			||||||
 | 
					import net.knarcraft.minigames.arena.ArenaPlayerRegistry;
 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArena;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArena;
 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaGameMode;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArenaGameMode;
 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaGroup;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArenaGroup;
 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaPlayerRegistry;
 | 
					 | 
				
			||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
 | 
					import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
 | 
				
			||||||
import net.knarcraft.minigames.config.Message;
 | 
					import net.knarcraft.minigames.config.Message;
 | 
				
			||||||
import net.knarcraft.minigames.config.ParkourConfiguration;
 | 
					import net.knarcraft.minigames.config.ParkourConfiguration;
 | 
				
			||||||
@@ -79,7 +79,7 @@ public class JoinParkourArenaCommand implements CommandExecutor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Register the player's session
 | 
					        // Register the player's session
 | 
				
			||||||
        ParkourArenaSession newSession = new ParkourArenaSession(specifiedArena, player, gameMode);
 | 
					        ParkourArenaSession newSession = new ParkourArenaSession(specifiedArena, player, gameMode);
 | 
				
			||||||
        ParkourArenaPlayerRegistry playerRegistry = MiniGames.getInstance().getParkourArenaPlayerRegistry();
 | 
					        ArenaPlayerRegistry<ParkourArena> playerRegistry = MiniGames.getInstance().getParkourArenaPlayerRegistry();
 | 
				
			||||||
        playerRegistry.registerPlayer(player.getUniqueId(), newSession);
 | 
					        playerRegistry.registerPlayer(player.getUniqueId(), newSession);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Try to teleport the player to the arena
 | 
					        // Try to teleport the player to the arena
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,9 @@ public enum Message {
 | 
				
			|||||||
    SUCCESS_PARKOUR_ARENAS_LIST("&aParkour arenas:&r"),
 | 
					    SUCCESS_PARKOUR_ARENAS_LIST("&aParkour arenas:&r"),
 | 
				
			||||||
    SUCCESS_CHECKPOINT_REACHED("&aCheckpoint reached!"),
 | 
					    SUCCESS_CHECKPOINT_REACHED("&aCheckpoint reached!"),
 | 
				
			||||||
    SUCCESS_GROUP_STAGES("&a{group}'s stages:&r"),
 | 
					    SUCCESS_GROUP_STAGES("&a{group}'s stages:&r"),
 | 
				
			||||||
 | 
					    SUCCESS_RECORD_ACHIEVED("&aYou just set a {recordInfo} on the {gameMode} game-mode!"),
 | 
				
			||||||
 | 
					    RECORD_ACHIEVED_GLOBAL("new {recordType} record"),
 | 
				
			||||||
 | 
					    RECORD_ACHIEVED_PERSONAL("personal {recordType} record"),
 | 
				
			||||||
    ;
 | 
					    ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final @NotNull String defaultMessage;
 | 
					    private final @NotNull String defaultMessage;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user