Skip to content

Commit

Permalink
Improve output formatting of /beast-loot info.
Browse files Browse the repository at this point in the history
  • Loading branch information
totemo committed Sep 19, 2019
1 parent 0e181dd commit cebf0ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/nu/nerd/beastmaster/DropSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ public void save(ConfigurationSection parentSection, Logger logger) {
}
}

// --------------------------------------------------------------------------
/**
* Return a short description of this set of drops that can be presented to
* the user.
*
* @return a short description of this set of drops that can be presented to
* the user.
*/
public String getShortDescription() {
StringBuilder s = new StringBuilder();
s.append(ChatColor.YELLOW).append(_id);
s.append(ChatColor.WHITE).append(": ");
s.append(ChatColor.YELLOW).append(isSingle() ? "single" : "multiple");
return s.toString();
}

// --------------------------------------------------------------------------
/**
* Return a description of this set of drops that can be presented to the
Expand All @@ -256,9 +272,7 @@ public void save(ConfigurationSection parentSection, Logger logger) {
*/
public String getDescription() {
StringBuilder s = new StringBuilder();
s.append(ChatColor.YELLOW).append(_id);
s.append(ChatColor.WHITE).append(": ");
s.append(ChatColor.YELLOW).append(isSingle() ? "single" : "multiple");
s.append(getShortDescription());
s.append(ChatColor.WHITE).append(" {");
s.append(getAllDrops().stream().map(drop -> drop.getShortDescription())
.collect(Collectors.joining(ChatColor.WHITE + ", ")));
Expand Down
2 changes: 1 addition & 1 deletion src/nu/nerd/beastmaster/commands/BeastLootExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}

sender.sendMessage(ChatColor.GOLD + "Loot table: " + dropSet.getDescription());
sender.sendMessage(ChatColor.GOLD + "Loot table: " + dropSet.getShortDescription());
Collection<Drop> allDrops = dropSet.getAllDrops();
sender.sendMessage(ChatColor.GOLD + (allDrops.isEmpty() ? "No drops defined." : "Drops:"));
for (Drop drop : allDrops) {
Expand Down

0 comments on commit cebf0ae

Please sign in to comment.