Skip to content

Commit

Permalink
Configurable tag timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 30, 2015
1 parent 579f78e commit 29b6258
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -1284,6 +1284,7 @@ public void refreshScriptContainers() {
ItemScriptHelper.item_scripts.clear();
ItemScriptHelper.item_scripts_by_hash_id.clear();
InventoryScriptHelper.inventory_scripts.clear();
tT = Integer.MAX_VALUE;
}

@Override
Expand Down Expand Up @@ -1382,6 +1383,16 @@ public TagContext getTagContext(ScriptEntry scriptEntry) {
public ScriptEntryData getEmptyScriptEntryData() {
return new BukkitScriptEntryData(null, null);
}

int tT = Integer.MAX_VALUE;

@Override
public int getTagTimeout() {
if (tT == Integer.MAX_VALUE) {
tT = Settings.tagTimeout();
}
return tT;
}
}


5 changes: 5 additions & 0 deletions src/main/java/net/aufdemrand/denizen/Settings.java
Expand Up @@ -377,4 +377,9 @@ public static int chatHistoryMaxMessages() {
return DenizenAPI.getCurrentInstance().getConfig()
.getInt("Tags.Chat history.Max messages", 10);
}

public static int tagTimeout() {
return DenizenAPI.getCurrentInstance().getConfig()
.getInt("Tags.Timeout", 10);
}
}
Expand Up @@ -102,7 +102,7 @@ public boolean applyDetermination(ScriptContainer container, String determinatio
// finish this
String lower = CoreUtilities.toLowerCase(determination);

// Deprecated?? This isn't listed in the meta
// Deprecated
if (lower.startsWith("drops ")) {
lower = lower.substring(6);
}
Expand Down Expand Up @@ -138,10 +138,8 @@ else if (aH.Argument.valueOf(lower).matchesArgumentList(dItem.class)) {
}

// String containing new Death Message
else if (!lower.equals("none")) {
if (event instanceof PlayerDeathEvent) {
message = new Element(determination);
}
else if (event instanceof PlayerDeathEvent) {
message = new Element(determination);
}
else {
return super.applyDetermination(container, determination);
Expand Down Expand Up @@ -237,7 +235,7 @@ public void onEntityDeath(EntityDeathEvent event) {
}
}
}
if (message != null) {
if (message != null && subEvent != null) {
subEvent.setDeathMessage(message.asString());
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Expand Up @@ -106,6 +106,8 @@ Commands:
# ALSO: Always read scripts you download for anything suspicious looking, EG the log command, the file_delete mechanism, ...

Tags:
# How long a tag can parse before force-closing the tag parser engine. Set to 0 to disable tag parse timing entirely.
Timeout: 10
# Settings for tags like cuboid.get_blocks, location.find.blocks, ...
Block tags:
# How many blocks can be read, max, before stopping the tag in place
Expand Down

0 comments on commit 29b6258

Please sign in to comment.