mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2025-12-04 01:48:46 +01:00
Finishes the reward tab completer
This commit is contained in:
@@ -27,8 +27,7 @@ public class CommandReward implements Reward {
|
||||
|
||||
@Override
|
||||
public boolean grant(@NotNull Player player) {
|
||||
return Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
command.replaceAll("[<%(\\[]player(_|-name)?[>%)\\]]", player.getName()));
|
||||
return Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), replaceNamePlaceholder(player, command));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +44,17 @@ public class CommandReward implements Reward {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the name placeholder in the given input with the given player's name
|
||||
*
|
||||
* @param player <p>The player whose name should be used</p>
|
||||
* @param input <p>The input containing a name placeholder</p>
|
||||
* @return <p>The input with the placeholder replaced</p>
|
||||
*/
|
||||
private String replaceNamePlaceholder(@NotNull Player player, @NotNull String input) {
|
||||
return input.replaceAll("[<%(\\[{]player[_\\-]?(name)?[>%)\\]}]", player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the command reward defined in the given data
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user