Skip to content

Commit

Permalink
add tag world.gamerule[...]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 21, 2019
1 parent 5c440db commit 1a688cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -917,6 +917,23 @@ public ObjectTag run(Attribute attribute, ObjectTag object) {
}
});

// <--[tag]
// @attribute <WorldTag.gamerule[<gamerule>]>
// @returns ElementTag
// @description
// returns the current value of the specified gamerule in the world.
// Note that the name is case-sensitive... so "doFireTick" is correct, but "dofiretick" is not.
// -->
registerTag("gamerule", new TagRunnable.ObjectForm() {
@Override
public ObjectTag run(Attribute attribute, ObjectTag object) {
GameRule rule = GameRule.getByName(attribute.getContext(1));
Object result = ((WorldTag) object).getWorld().getGameRuleValue(rule);
return new ElementTag(result == null ? "null" : result.toString())
.getObjectAttribute(attribute.fulfill(1));
}
});

}

public static ObjectTagProcessor tagProcessor = new ObjectTagProcessor();
Expand Down
Expand Up @@ -23,7 +23,7 @@ public class GameRuleCommand extends AbstractCommand {
// Note: Be careful, gamerules are CASE SENSITIVE.
//
// @Tags
// TODO: Add tags and then document them!
// <WorldTag.gamerule[<gamerule>]>
//
// @Usage
// Use to disable fire spreading in world "Adventure".
Expand Down

0 comments on commit 1a688cc

Please sign in to comment.