Skip to content

Commit

Permalink
Change some worldscript contexts into Elements. 'On … Command' <conte…
Browse files Browse the repository at this point in the history
…xt.command> and <context.raw_args> now return Elements for use with the new tagging system.
  • Loading branch information
aufdemrand committed Jul 6, 2013
1 parent 5451f43 commit 7deae06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/main/java/net/aufdemrand/denizen/objects/Element.java
Expand Up @@ -217,16 +217,21 @@ else if (element.toLowerCase().contains(contains.toLowerCase()))
String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : " ");
Integer limit = (attribute.hasContext(2) ? attribute.getIntContext(2) : 1);
if (split_string.toLowerCase().startsWith("regex:"))
return new dList(Arrays.asList(element.split(split_string.split(":", 2)[1], limit))).getAttribute(attribute.fulfill(1));
return new dList(Arrays.asList(element.split(split_string.split(":", 2)[1], limit)))
.getAttribute(attribute.fulfill(1));
else
return new dList(Arrays.asList(StringUtils.split(element, split_string, limit))).getAttribute(attribute.fulfill(1)); }
return new dList(Arrays.asList(StringUtils.split(element, split_string, limit)))
.getAttribute(attribute.fulfill(1));
}

if (attribute.startsWith("split")) {
String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : " ");
if (split_string.toLowerCase().startsWith("regex:"))
return new dList(Arrays.asList(element.split(split_string.split(":", 2)[1]))).getAttribute(attribute.fulfill(1));
return new dList(Arrays.asList(element.split(split_string.split(":", 2)[1])))
.getAttribute(attribute.fulfill(1));
else
return new dList(Arrays.asList(StringUtils.split(element, split_string))).getAttribute(attribute.fulfill(1));
return new dList(Arrays.asList(StringUtils.split(element, split_string)))
.getAttribute(attribute.fulfill(1));
}

if (attribute.startsWith("sqrt")) {
Expand Down
Expand Up @@ -836,8 +836,8 @@ public void playerCommandEvent(PlayerCommandPreprocessEvent event) {

// Fill context
context.put("args", args_list);
context.put("command", command);
context.put("raw_args", (event.getMessage().split(" ").length > 1 ? event.getMessage().split(" ", 2)[1] : ""));
context.put("command", new Element(command));
context.put("raw_args", new Element((event.getMessage().split(" ").length > 1 ? event.getMessage().split(" ", 2)[1] : "")));
String determination;

// Run any event scripts and get the determination.
Expand All @@ -855,7 +855,7 @@ public void playerCommandEvent(PlayerCommandPreprocessEvent event) {
public void playerDeath(PlayerDeathEvent event) {

Map<String, Object> context = new HashMap<String, Object>();
context.put("message", event.getDeathMessage());
context.put("message", new Element(event.getDeathMessage()));

String determination = doEvents(Arrays.asList
("player dies"),
Expand All @@ -870,7 +870,7 @@ public void playerDeath(PlayerDeathEvent event) {
public void playerGameModeChange(PlayerGameModeChangeEvent event) {

Map<String, Object> context = new HashMap<String, Object>();
context.put("gamemode", event.getNewGameMode().name());
context.put("gamemode", new Element(event.getNewGameMode().name()));

String determination = doEvents(Arrays.asList
("player changes gamemode",
Expand Down

0 comments on commit 7deae06

Please sign in to comment.