Skip to content

Commit

Permalink
Custom Placeholders: A custom placeholder is identified with the pref…
Browse files Browse the repository at this point in the history
…ix of 'prison__' but one of the functions that cleans the placeholder fragments sent to prison, was removing one of those underscore characters. This preserves the needed underscore and allows for proper matching and identification.
  • Loading branch information
rbluer committed Sep 20, 2024
1 parent ee2e7fd commit 58de84a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
28 changes: 19 additions & 9 deletions prison-core/src/main/java/tech/mcprison/prison/PrisonCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,21 +826,31 @@ public void placeholdersStatsCommand(CommandSender sender,
display.send(sender);
}

@Command(identifier = "prison reload placeholders",
description = "Placeholder reload: Regenerates all placeholders and reregisters them.",
onlyPlayers = false, permissions = "prison.placeholder")
public void placeholdersReloadCommandAlias(CommandSender sender ) {
placeholdersReloadCommand( sender );
}
// @Command(identifier = "prison reload placeholders",
// description = "Placeholder reload: Regenerates all placeholders and reregisters them.",
// onlyPlayers = false,
// permissions = "prison.placeholder",
// aliases = { "prison reload configyml" })
// public void placeholdersReloadCommandAlias(CommandSender sender ) {
// placeholdersReloadCommand( sender );
// }

@Command(identifier = "prison placeholders reload",
description = "Placeholder reload: Regenerates all placeholders and reregisters them.",
onlyPlayers = false, permissions = "prison.placeholder")
description = "Placeholder reload: Regenerates all placeholders and reregisters them. "
+ "&dThis also forces the config.yml properties to be reloaded too, but be warned, "
+ "it will not force anything that uses config.yml to be reloaded and you may "
+ "still have to restart the server.",
onlyPlayers = false,
permissions = "prison.placeholder",
aliases = {
"prison reload configyml",
"prison reload placeholders"
} )
public void placeholdersReloadCommand(CommandSender sender ) {

Prison.get().getPlatform().getPlaceholders().reloadPlaceholders();

String message = "Placeholder reload was attempted. " +
String message = "Placeholder and config.yml reload was attempted. " +
"No guarentees that it worked 100%. Restart server if any doubts.";

sender.sendMessage( message );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ else if ( pIdentifier.getIdentifierRaw().startsWith( "{" ) ) {
}
}

else {
else if ( !pIdentifier.getIdentifierRaw().startsWith( "_" ) ) {
Matcher matcher = PlaceholderManager.PLACEHOLDER_ESCAPE_CHARACTER_LEFT_PATTERN.matcher( pIdentifier.getIdentifierRaw() );

if ( matcher.find() ) {
Expand Down
3 changes: 3 additions & 0 deletions prison-spigot/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ placeholder:
prison__player_stats: "{prison_rank_tag_default} -> {prison_rankup_rank_tag_default}
{prison_rankup_cost_remaining_bar_default::bar:50:&a:|:&d:|}
{prison_rankup_cost_remaining_formatted_default} needed to rankup"

# Pre-spigot 1.14: Cannot do RGB colors:
# prison__branding: "&2P&3r&4o &5M&6i&an&be&cs"
prison__branding: "&#e81416P&#ffa500r&#faeb36o
&#79c314M&#487de7i&#4b369dn&#70369de&#ac7ad1s"

Expand Down

0 comments on commit 58de84a

Please sign in to comment.