Skip to content

Commit

Permalink
Add "on block moves" world event, so you can now have sand that does …
Browse files Browse the repository at this point in the history
…not fall or rails that go through thin air, with "determine cancelled."
  • Loading branch information
davidcernat committed Jul 12, 2013
1 parent 138386d commit 6d383b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Expand Up @@ -128,7 +128,7 @@ public void registerCoreMembers() {
"EXPERIENCE", "experience [{set}/give/take] (level) [<#>]", 2);

registerCoreMember(ExplodeCommand.class,
"EXPLODE", "explode (power:<#>) (<location>) (fire) (breakblocks)", 0);
"EXPLODE", "explode (power:<#.#>) (<location>) (fire) (breakblocks)", 0);

registerCoreMember(FailCommand.class,
"FAIL", "fail (script:<name>)", 0);
Expand Down Expand Up @@ -197,7 +197,7 @@ public void registerCoreMembers() {
"LOOKCLOSE", "lookclose [state:true/false]", 1);

registerCoreMember(MidiCommand.class,
"MIDI", "midi [file:<name>] [<location>/listeners:<player>|...] (tempo:<#>)", 1);
"MIDI", "midi [file:<name>] [<location>/listeners:<player>|...] (tempo:<#.#>)", 1);

registerCoreMember(MountCommand.class,
"MOUNT", "mount (cancel) [entities:<entity>|...] (<location>)", 0);
Expand All @@ -221,7 +221,7 @@ public void registerCoreMembers() {
"PLAYEFFECT", "playeffect [<location>] [effect:<name>] (qty:<#>) (radius:<#.#>) (data:<#.#>) (offset:<#.#>)", 2);

registerCoreMember(PlaySoundCommand.class,
"PLAYSOUND", "playsound [<location>] [sound:<name>] (volume:<#>) (pitch:<#>)", 2);
"PLAYSOUND", "playsound [<location>] [sound:<name>] (volume:<#.#>) (pitch:<#.#>)", 2);

registerCoreMember(PermissionCommand.class,
"PERMISSION", "permission [add|remove] [permission] (player:<name>) (group:<name>) (world:<name>)", 2);
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.SignChangeEvent;
Expand Down Expand Up @@ -195,6 +196,23 @@ public void blockIgnite(BlockIgniteEvent event) {
event.setCancelled(true);
}

@EventHandler
public void blockPhysicsEvent(BlockPhysicsEvent event) {

Map<String, Object> context = new HashMap<String, Object>();

context.put("location", new dLocation(event.getBlock().getLocation()));
context.put("type", new Element(event.getBlock().getType().name()));

String determination = doEvents(Arrays.asList
("block moves",
event.getBlock().getType().name() + " moves"),
null, null, context);

if (determination.toUpperCase().startsWith("CANCELLED"))
event.setCancelled(true);
}

@EventHandler
public void blockPlace(BlockPlaceEvent event) {

Expand Down
Expand Up @@ -38,7 +38,7 @@ public void mathTags(ReplaceableTagEvent event) {

@EventHandler
public void serverTags(ReplaceableTagEvent event) {
if (!event.matches("server, svr")) return;
if (!event.matches("server, svr, global")) return;
Attribute attribute = new Attribute(event.raw_tag, event.getScriptEntry()).fulfill(1);

if (attribute.startsWith("flag")) {
Expand Down

0 comments on commit 6d383b6

Please sign in to comment.