mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2024-12-05 00:43:15 +01:00
Adds a hardcore game-mode ignoring checkpoints
This commit is contained in:
parent
701cdd81eb
commit
e039840e89
13
README.md
13
README.md
@ -50,7 +50,7 @@ The only permission normal players will need is `minigames.join` which is set to
|
|||||||
| /dropperGroupList | /dglist | \[group] | Lists groups, or the stages of a group if a group is specified. |
|
| /dropperGroupList | /dglist | \[group] | Lists groups, or the stages of a group if a group is specified. |
|
||||||
| [/dropperGroupSwap](#droppergroupswap) | /dgswap | \<arena1> \<arena2> | Swaps the two arenas in the group's ordered list. |
|
| [/dropperGroupSwap](#droppergroupswap) | /dgswap | \<arena1> \<arena2> | Swaps the two arenas in the group's ordered list. |
|
||||||
| /parkourList | /plist | | Lists available parkour arenas. |
|
| /parkourList | /plist | | Lists available parkour arenas. |
|
||||||
| /parkourJoin | /pjoin | \<arena> | Joins the selected arena. |
|
| [/parkourJoin](#parkourjoin) | /pjoin | \<arena> \[mode] | Joins the selected arena. |
|
||||||
| /parkourCreate | /pcreate | \<name> | Creates a new parkour arena with the given name. The spawn is set to your location. |
|
| /parkourCreate | /pcreate | \<name> | Creates a new parkour arena with the given name. The spawn is set to your location. |
|
||||||
| /parkourRemove | /premove | \<arena> | Removes the specified parkour arena. |
|
| /parkourRemove | /premove | \<arena> | Removes the specified parkour arena. |
|
||||||
| [/parkourEdit](#parkouredit) | /pedit | \<arena> \<option> \[value] | Gets or sets a parkour arena option. |
|
| [/parkourEdit](#parkouredit) | /pedit | \<arena> \<option> \[value] | Gets or sets a parkour arena option. |
|
||||||
@ -128,6 +128,17 @@ You could use `/droppergroupswap Sea Savanna` to change the order to:
|
|||||||
|
|
||||||
### Command explanation parkour
|
### Command explanation parkour
|
||||||
|
|
||||||
|
#### /parkourJoin
|
||||||
|
|
||||||
|
This command is used for joining a dropper arena.
|
||||||
|
|
||||||
|
`/parkourjoin <arena> [mode]`
|
||||||
|
|
||||||
|
| Argument | Usage |
|
||||||
|
|----------|-----------------------------------------------------------------------------------------------------------|
|
||||||
|
| arena | The name of the arena to join. |
|
||||||
|
| mode | Additional challenge modes can be played after an arena has been cleared once. Available modes: hardcore. |
|
||||||
|
|
||||||
#### /parkourEdit
|
#### /parkourEdit
|
||||||
|
|
||||||
This command allows editing the specified property for the specified parkour arena.
|
This command allows editing the specified property for the specified parkour arena.
|
||||||
|
@ -16,6 +16,11 @@ public enum ParkourArenaGameMode implements ConfigurationSerializable, ArenaGame
|
|||||||
* The default game-mode. Failing once throws the player out.
|
* The default game-mode. Failing once throws the player out.
|
||||||
*/
|
*/
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hard-core game mode where no checkpoints are allowed
|
||||||
|
*/
|
||||||
|
HARDCORE,
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,15 @@ public class ParkourArenaSession extends AbstractArenaSession {
|
|||||||
this.entryState.setArenaState();
|
this.entryState.setArenaState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the game-mode the player is playing in this session
|
||||||
|
*
|
||||||
|
* @return <p>The game-mode for this session</p>
|
||||||
|
*/
|
||||||
|
public @NotNull ParkourArenaGameMode getGameMode() {
|
||||||
|
return this.gameMode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the checkpoint this session's player has reached
|
* Registers the checkpoint this session's player has reached
|
||||||
*
|
*
|
||||||
@ -118,6 +127,7 @@ public class ParkourArenaSession extends AbstractArenaSession {
|
|||||||
protected String getGameModeString() {
|
protected String getGameModeString() {
|
||||||
return switch (this.gameMode) {
|
return switch (this.gameMode) {
|
||||||
case DEFAULT -> "default";
|
case DEFAULT -> "default";
|
||||||
|
case HARDCORE -> "hardcore";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import net.knarcraft.minigames.arena.ArenaSession;
|
|||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaGameMode;
|
import net.knarcraft.minigames.arena.dropper.DropperArenaGameMode;
|
||||||
import net.knarcraft.minigames.arena.dropper.DropperArenaSession;
|
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.ParkourArenaGameMode;
|
||||||
import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
|
import net.knarcraft.minigames.arena.parkour.ParkourArenaSession;
|
||||||
import net.knarcraft.minigames.config.DropperConfiguration;
|
import net.knarcraft.minigames.config.DropperConfiguration;
|
||||||
import net.knarcraft.minigames.config.Message;
|
import net.knarcraft.minigames.config.Message;
|
||||||
@ -76,14 +77,30 @@ public class MoveListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip checkpoint registration if playing on hardcore
|
||||||
|
if (arenaSession.getGameMode() == ParkourArenaGameMode.HARDCORE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the player reached one of the checkpoints for the arena
|
// Check if the player reached one of the checkpoints for the arena
|
||||||
|
updateCheckpoint(arenaSession, event.getTo().getBlock(), event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the checkpoint of a player if reached
|
||||||
|
*
|
||||||
|
* @param arenaSession <p>The session of the player</p>
|
||||||
|
* @param targetBlock <p>The block the player is moving to</p>
|
||||||
|
* @param player <p>The player moving</p>
|
||||||
|
*/
|
||||||
|
private void updateCheckpoint(ParkourArenaSession arenaSession, Block targetBlock, Player player) {
|
||||||
ParkourArena arena = arenaSession.getArena();
|
ParkourArena arena = arenaSession.getArena();
|
||||||
List<Location> checkpoints = arena.getCheckpoints();
|
List<Location> checkpoints = arena.getCheckpoints();
|
||||||
for (Location checkpoint : checkpoints) {
|
for (Location checkpoint : checkpoints) {
|
||||||
Location previousCheckpoint = arenaSession.getRegisteredCheckpoint();
|
Location previousCheckpoint = arenaSession.getRegisteredCheckpoint();
|
||||||
|
|
||||||
// Skip if checkpoint has not been reached
|
// Skip if checkpoint has not been reached
|
||||||
if (!checkpoint.getBlock().equals(event.getTo().getBlock())) {
|
if (!checkpoint.getBlock().equals(targetBlock)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +120,7 @@ public class MoveListener implements Listener {
|
|||||||
|
|
||||||
// Register the checkpoint
|
// Register the checkpoint
|
||||||
arenaSession.registerCheckpoint(checkpoint.clone());
|
arenaSession.registerCheckpoint(checkpoint.clone());
|
||||||
event.getPlayer().sendMessage(Message.SUCCESS_CHECKPOINT_REACHED.getMessage());
|
player.sendMessage(Message.SUCCESS_CHECKPOINT_REACHED.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,9 @@ commands:
|
|||||||
- pjoin
|
- pjoin
|
||||||
permission: minigames.join
|
permission: minigames.join
|
||||||
usage: |
|
usage: |
|
||||||
/<command> <arena>
|
/<command> <arena> [mode]
|
||||||
|
- Mode can be used to select challenge modes which can be played after beating the arena.
|
||||||
|
- hardcore = A game-mode where checkpoints cannot be triggered
|
||||||
description: Used to join a parkour arena
|
description: Used to join a parkour arena
|
||||||
parkourCreate:
|
parkourCreate:
|
||||||
aliases:
|
aliases:
|
||||||
|
Loading…
Reference in New Issue
Block a user