Skip to content

Commit

Permalink
More command examples
Browse files Browse the repository at this point in the history
  • Loading branch information
A5H73Y committed Aug 9, 2023
1 parent 96c549c commit b5f19a8
Show file tree
Hide file tree
Showing 8 changed files with 584 additions and 161 deletions.
4 changes: 4 additions & 0 deletions docs/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ summary.deprecated {
padding-top: 0;
}

.markdown-section ol, .markdown-section ul {
margin: 0;
}


354 changes: 280 additions & 74 deletions docs/files/parkourCommands.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ function appendData(data, elementId, markupCallback) {
}

function createCommandSummary(command) {
const yoyo = group[command.commandGroup];
const group = group[command.commandGroup];
const styleClass = command.deprecated ? 'deprecated' : '';
let result = `<details>
<summary class="${styleClass}">
<strong>${command.command}</strong> - ${command.title} <em>${yoyo}</em>
<strong>${command.command}</strong> - ${command.title} <em>${group || ''}</em>
</summary>
<div>
<table>
Expand All @@ -66,8 +66,8 @@ function createCommandSummary(command) {
<td><code>/pa ${command.command} ${command.arguments || ''}</code></td>
</tr>
<tr>
<th scope="row">Example</th>
<td><code>${command.example}</code></td>
<th scope="row">Examples</th>
<td><ul>${command.examples.map(example => `<li><code>${example}</code></li>`).join(' ')}</ul></td>
</tr>
<tr>
<th scope="row">Permission</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static io.github.a5h73y.parkour.other.ParkourConstants.COMMAND_PLACEHOLDER;
import static io.github.a5h73y.parkour.utility.permission.PermissionUtils.WILDCARD;

import java.util.List;

import io.github.a5h73y.parkour.utility.StringUtils;
import io.github.a5h73y.parkour.utility.TranslationUtils;
import org.bukkit.command.CommandSender;
Expand All @@ -24,7 +26,7 @@ public class CommandUsage {
private String command;
private String title;
private String arguments;
private String example;
private List<String> examples;
private String description;
private String permission;
private String commandGroup;
Expand All @@ -49,7 +51,10 @@ public void displayHelpInformation(CommandSender commandSender) {
String commandSyntax = arguments != null ? command + SPACE + arguments : command;
TranslationUtils.sendValueTranslation("Help.CommandSyntax", commandSyntax, false, commandSender);
}
TranslationUtils.sendValueTranslation("Help.CommandExample", example, false, commandSender);
if (getExamples() != null && !getExamples().isEmpty()) {
TranslationUtils.sendTranslation("Help.CommandExamples", false, commandSender);
getExamples().forEach(example -> commandSender.sendMessage(" " + example));
}
TranslationUtils.sendHeading("Description", commandSender);
commandSender.sendMessage(description);
}
Expand Down Expand Up @@ -97,8 +102,8 @@ public String getArguments() {
return arguments;
}

public String getExample() {
return example;
public List<String> getExamples() {
return examples;
}

public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private List<String> populateMainCommands(Player player) {
}

return parkour.getParkourCommands().getCommandUsages().stream()
.filter(commandUsage -> commandUsage.getExample() != null)
.filter(commandUsage -> commandUsage.getExamples() != null)
.filter(commandUsage -> commandUsage.getPermission() == null
|| player.hasPermission(commandUsage.getPermission()))
.map(CommandUsage::getCommand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public StringsConfig(File file) {
this.setDefault("Help.SignCommands", "To display the sign commands menu, enter &b/pa cmds signs");
this.setDefault("Help.CommandSyntax", "&7Syntax: &f/pa %VALUE%");
this.setDefault("Help.ConsoleCommandSyntax", "&7Syntax: &f%VALUE%");
this.setDefault("Help.CommandExample", "&7Example: &f%VALUE%");
this.setDefault("Help.CommandExamples", "&7Examples:");
this.setDefault("Help.CommandUsage", "&3/pa &b%COMMAND%&e%ARGUMENTS% &0: &f%TITLE%");
this.setDefault("Help.SignUsage", "&b%COMMAND% &e%SHORTCUT% &0: &f%DESCRIPTION%");
this.setDefault("Help.DisplayValue", "%TITLE%: &b%VALUE%");
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/io/github/a5h73y/parkour/plugin/EconomyApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static org.bukkit.Bukkit.getServer;

import io.github.a5h73y.parkour.Parkour;
import io.github.a5h73y.parkour.type.course.CourseConfig;
import io.github.a5h73y.parkour.utility.PluginUtils;
import io.github.a5h73y.parkour.utility.TranslationUtils;
import io.github.a5h73y.parkour.utility.ValidationUtils;
Expand Down Expand Up @@ -278,9 +279,10 @@ private void processSetFeeCommand(CommandSender commandSender, String... args) {
return;
}

boolean value = args.length == 5 && args[4].equalsIgnoreCase("true") ? true : false;
parkour.getConfigManager().getCourseConfig(args[2]).setEconomyJoiningFee(Double.parseDouble(args[3]));
parkour.getConfigManager().getCourseConfig(args[2]).setEconomyOneTimeFee(value);
boolean oneTimeFee = args.length == 5 && args[4].equalsIgnoreCase("true");
CourseConfig config = parkour.getConfigManager().getCourseConfig(args[2]);
config.setEconomyJoiningFee(Double.parseDouble(args[3]));
config.setEconomyOneTimeFee(oneTimeFee);
TranslationUtils.sendPropertySet(commandSender, "Join Fee", args[2], args[3]);
}

Expand Down
Loading

0 comments on commit b5f19a8

Please sign in to comment.