Skip to content

Commit

Permalink
Fix Out of Bounds Exception in chat_history tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fortifier42 committed Nov 26, 2015
1 parent f9d26c6 commit 684fe0e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/net/aufdemrand/denizen/objects/dPlayer.java
Expand Up @@ -599,11 +599,15 @@ public String getAttribute(Attribute attribute) {
if (attribute.hasContext(1) && aH.matchesInteger(attribute.getContext(1)))
x = attribute.getIntContext(1);
// No playerchathistory? Return null.
if (!PlayerTags.playerChatHistory.containsKey(getName())) // TODO: UUID?
if (!PlayerTags.playerChatHistory.containsKey(getName())) { // TODO: UUID?
return null;
else
return new Element(PlayerTags.playerChatHistory.get(getName()).get(x - 1)) // TODO: UUID?
.getAttribute(attribute.fulfill(1));
}
List<String> messages = PlayerTags.playerChatHistory.get(getName()); // TODO: UUID?
if (messages.size() < x || x < 1) {
return null;
}
return new Element(messages.get(x - 1))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
Expand Down

0 comments on commit 684fe0e

Please sign in to comment.