Skip to content

Instantly share code, notes, and snippets.

@steveanton
Created November 9, 2012 21:55
Show Gist options
  • Save steveanton/4048517 to your computer and use it in GitHub Desktop.
Save steveanton/4048517 to your computer and use it in GitHub Desktop.

Primer on the New Filter System

Filters are have results they will return: ALLOW, DENY, and ABSTAIN.

  • ALLOW means that the filter specifically allows the query
  • DENY means that the filter specifically denies the query
  • ABSTAIN means none of the filters queried have any opinion on the subject. Abstain is usually interpreted as ALLOW when casting to a single boolean.

Most consumers of filters will cast the query result to a boolean, where ALLOW and ABSTAIN are both interpreted as ALLOW.

New syntax has been added in map proto v1.3.0:

In addition to the simple filters that much on a single type, there are new three combinative filters:

  • <any>: Returns ALLOW if any of the sub filters return ALLOW, ABSTAIN if none of the sub filters specify a preference on the query, and DENY if none of the sub filters specify ALLOW and at least one sub filter specified DENY.
  • <one>: Returns ALLOW if exactly one of the sub filters returns ALLOW, ABSTAIN if none of the sub filters specify a preference on the query, and DENY if there are more than one sub filter that specifies ALLOW or none specify ALLOW and at least one specifies DENY.
  • <all>: Returns ALLOW if all of the sub filters specify ALLOW, ABSTAIN if none of the sub filters specif a preference on the query, and DENY if one or more of the sub filters specify DENY.

There is also the <not> filter which works as follows:

  • If sub filter is ALLOW, return DENY.
  • If sub filter is DENY, return ALLOW.
  • If sub filter is ABSTAIN, return ABSTAIN.

Now all filters may be named and existing filters can be referenced with the <filter name="<name>"/> tag. By default, a tag is interpreted as a <any> tag if at least one sub filter is specified.

Examples

Allow only gold blocks:

<filter name="only-gold">
	<block>gold block</block>
</filter>

Only allow blazes to spawn from spawners, but allow creepers and silverfish to spawn from everything but spawn eggs.

<filter>
	<all>
		<mob>blaze</mob>
		<spawn>spawner</spawn>
	</all>
	<all>
		<any>
			<mob>creeper</mob>
			<mob>silverfish</mob>
		<any>
		<not><spawn>spawn egg</spawn></not>
	</all>
</filter>

Only allow red team to place blocks:

<filter>
	<team>red</team>
</filter>

Prevent the red team from doing anything:

<filter>
	<not><team>red</team></not>
</filter>

Only allow red team to place blocks, but also deny any blocks that do not have an owner (NOTE: this part of the spec is not stable and is subject to change):

<filter>
	<all>
		<team red>
		<filter name="deny-world"/>
	</all>
</filter>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment