Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CreeperIgniteScriptEvent (#2323)
- Loading branch information
1 parent
b9a0361
commit ac1e26f
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
paper/src/main/java/com/denizenscript/denizen/paper/events/CreeperIgnitesScriptEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.denizenscript.denizen.paper.events; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import com.destroystokyo.paper.event.entity.CreeperIgniteEvent; | ||
|
||
public class CreeperIgnitesScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// creeper ignites | ||
// | ||
// @Plugin Paper | ||
// | ||
// @Group Paper | ||
// | ||
// @Location true | ||
// | ||
// @Cancellable true | ||
// | ||
// @Triggers when a creeper is ignited by flint and steel. | ||
// | ||
// @Context | ||
// <context.entity> returns the EntityTag of the creeper. | ||
// <context.ignited> returns true if the creeper is ignited, or false if not. NOTE: In most cases, this will return true. | ||
// | ||
// --> | ||
|
||
public CreeperIgnitesScriptEvent() { | ||
instance = this; | ||
registerCouldMatcher("creeper ignites"); | ||
} | ||
|
||
public static CreeperIgnitesScriptEvent instance; | ||
public EntityTag entity; | ||
public CreeperIgniteEvent event; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if (!runInCheck(path, entity.getLocation())) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "CreeperIgnites"; | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
switch (name) { | ||
case "entity": | ||
return entity; | ||
case "ignited": | ||
return new ElementTag(event.isIgnited()); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onCreeperIgnites(CreeperIgniteEvent event) { | ||
entity = new EntityTag(event.getEntity()); | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |