Skip to content

Commit

Permalink
Make the /check list show the number of notes.
Browse files Browse the repository at this point in the history
The number of notes is shown as a red indicator before the [OPEN]
indicator. The indicator is not displayed if there aren't any
notes for the request.
  • Loading branch information
timovv committed Jan 10, 2015
1 parent af85a76 commit 2fa2f56
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ messages:
deleted: "&ARequest {request_id} has been closed by you."
list:
header: "&B---- {num_requests} Mod Requests ----"
item: "&6{request_id}.{admin}&6 [&A{mod}{status}&6] {time} {player} -&7 {request_message}"
item: "&6{request_id}.{note_count}{admin}&6 [&A{mod}{status}&6] {time} {player} -&7 {request_message}"
footer: "&B---- Page {page} of {num_pages} ----"
item:
header-unclaimed: "&BMod Request {request_id} - &E{status}"
Expand Down
3 changes: 3 additions & 0 deletions src/nu/nerd/modreq/ModReq.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ private void messageRequestListToPlayer(CommandSender sender, List<Request> reqs
for (Request r : reqs) {
ChatColor onlineStatus = ChatColor.RED;
String message = "";
int noteCount = noteTable.getNoteCount(r);
if (r.getRequest().length() > 20) {
message = r.getRequest().substring(0, 17) + "...";
} else {
Expand All @@ -678,6 +679,7 @@ private void messageRequestListToPlayer(CommandSender sender, List<Request> reqs
}
try {
environment.put("request_id", String.valueOf(r.getId()));
environment.put("note_count", noteCount>0?ChatColor.RED+" ["+Integer.toString(noteCount)+"]":"");
environment.put("admin", (r.isFlagForAdmin()?(ChatColor.AQUA + " [ADMIN]"):""));
environment.put("mod", (r.getStatus()==RequestStatus.CLAIMED?(r.getAssignedMod()):""));
environment.put("status", (r.getStatus()!=RequestStatus.CLAIMED?(r.getStatus().toString()):""));
Expand All @@ -686,6 +688,7 @@ private void messageRequestListToPlayer(CommandSender sender, List<Request> reqs
environment.put("request_message", r.getRequest());
messages.add(buildMessage(config.GENERAL__LIST__ITEM));
environment.remove("request_id");
environment.remove("note_count");
environment.remove("admin");
environment.remove("mod");
environment.remove("status");
Expand Down
6 changes: 6 additions & 0 deletions src/nu/nerd/modreq/database/NoteTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public List<Note> getRequestNotes(Request request) {

return requestNotes;
}

public int getNoteCount(Request request) {

return parent.getDatabase().find(Note.class).where()
.eq("requestId", request.getId()).findRowCount();
}

public void remove(Note note) {
parent.getDatabase().delete(note);
Expand Down

0 comments on commit 2fa2f56

Please sign in to comment.