Skip to content

Commit

Permalink
Implement onRespawnCommands() option from BentoBox 1.14.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Mar 15, 2021
1 parent 9006a5f commit c12310a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
67 changes: 63 additions & 4 deletions src/main/java/world/bentobox/caveblock/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.eclipse.jdt.annotation.NonNull;

import com.google.common.base.Enums;

Expand Down Expand Up @@ -882,6 +883,16 @@ public boolean isMakeEndPortals()
}


/**
* {@inheritDoc}
*/
@Override
public @NonNull List<String> getOnRespawnCommands()
{
return this.onRespawnCommands;
}


// ---------------------------------------------------------------------
// Section: Setters
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -2043,6 +2054,17 @@ public void setMakeEndPortals(boolean makeEndPortals)
}


/**
* Sets on respawn commands.
*
* @param onRespawnCommands the on respawn commands
*/
public void setOnRespawnCommands(List<String> onRespawnCommands)
{
this.onRespawnCommands = onRespawnCommands;
}


// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -2493,14 +2515,51 @@ public void setMakeEndPortals(boolean makeEndPortals)
private boolean pasteMissingIslands = false;

// Commands
@ConfigComment("List of commands to run when a player joins.")
@ConfigEntry(path = "cave.commands.on-join")
@ConfigComment("List of commands to run when a player joins an cave or creates one.")
@ConfigComment("These commands are run by the console, unless otherwise stated using the [SUDO] prefix,")
@ConfigComment("in which case they are executed by the player.")
@ConfigComment("")
@ConfigComment("Available placeholders for the commands are the following:")
@ConfigComment(" * [name]: name of the player")
@ConfigComment("")
@ConfigComment("Here are some examples of valid commands to execute:")
@ConfigComment(" * '[SUDO] bbox version'")
@ConfigComment(" * 'bsbadmin deaths set [player] 0'")
@ConfigComment("")
@ConfigComment("Note that player-executed commands might not work, as these commands can be run with said player being offline.")
@ConfigEntry(path = "cave.commands.on-join", since = "1.8.0")
private List<String> onJoinCommands = new ArrayList<>();

@ConfigComment("list of commands to run when a player leaves.")
@ConfigEntry(path = "cave.commands.on-leave")
@ConfigComment("List of commands to run when a player leaves a cave, resets his cave or gets kicked from it.")
@ConfigComment("These commands are run by the console, unless otherwise stated using the [SUDO] prefix,")
@ConfigComment("in which case they are executed by the player.")
@ConfigComment("")
@ConfigComment("Available placeholders for the commands are the following:")
@ConfigComment(" * [name]: name of the player")
@ConfigComment("")
@ConfigComment("Here are some examples of valid commands to execute:")
@ConfigComment(" * '[SUDO] bbox version'")
@ConfigComment(" * 'bsbadmin deaths set [player] 0'")
@ConfigComment("")
@ConfigComment("Note that player-executed commands might not work, as these commands can be run with said player being offline.")
@ConfigEntry(path = "cave.commands.on-leave", since = "1.8.0")
private List<String> onLeaveCommands = new ArrayList<>();

@ConfigComment("Returns a list of commands that should be executed when the player respawns after death if Flags.ISLAND_RESPAWN is true.")
@ConfigComment("These commands are run by the console, unless otherwise stated using the [SUDO] prefix,")
@ConfigComment("in which case they are executed by the player.")
@ConfigComment("")
@ConfigComment("Available placeholders for the commands are the following:")
@ConfigComment(" * [name]: name of the player")
@ConfigComment("")
@ConfigComment("Here are some examples of valid commands to execute:")
@ConfigComment(" * '[SUDO] bbox version'")
@ConfigComment(" * 'bsbadmin deaths set [player] 0'")
@ConfigComment("")
@ConfigComment("Note that player-executed commands might not work, as these commands can be run with said player being offline.")
@ConfigEntry(path = "cave.commands.on-respawn", since = "1.14.0")
private List<String> onRespawnCommands = new ArrayList<>();

// Sethome
@ConfigComment("Allow setting home in the nether. Only available on nether islands, not vanilla nether.")
@ConfigEntry(path = "cave.sethome.nether.allow")
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,12 @@ cave:
# Added since 1.10.0.
create-missing-nether-end-caves: false
commands:
# List of commands to run when a player joins.
# List of commands to run when a player joins an cave or creates one.
on-join: []
# list of commands to run when a player leaves.
# List of commands to run when a player leaves a cave, resets his cave or gets kicked from it.
on-leave: []
# Returns a list of commands that should be executed when the player respawns after death if Flags.ISLAND_RESPAWN is true.
on-respawn: []
sethome:
nether:
# Allow setting home in the nether. Only available on nether islands, not vanilla nether.
Expand Down

0 comments on commit c12310a

Please sign in to comment.