use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class PaperEntityProperties method registerTags.
public static void registerTags() {
// <--[tag]
// @attribute <EntityTag.spawn_reason>
// @returns ElementTag
// @group properties
// @Plugin Paper
// @description
// Returns the entity's spawn reason.
// Valid spawn reasons can be found at <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html>
// -->
PropertyParser.<PaperEntityProperties, ElementTag>registerTag(ElementTag.class, "spawn_reason", (attribute, entity) -> {
return new ElementTag(entity.entity.getBukkitEntity().getEntitySpawnReason().name());
});
// <--[tag]
// @attribute <EntityTag.xp_spawn_reason>
// @returns ElementTag
// @group properties
// @Plugin Paper
// @description
// If the entity is an experience orb, returns its spawn reason.
// Valid spawn reasons can be found at <@link url https://papermc.io/javadocs/paper/1.17/org/bukkit/entity/ExperienceOrb.SpawnReason.html>
// -->
PropertyParser.<PaperEntityProperties, ElementTag>registerTag(ElementTag.class, "xp_spawn_reason", (attribute, entity) -> {
if (!(entity.entity.getBukkitEntity() instanceof ExperienceOrb)) {
attribute.echoError("Entity " + entity.entity + " is not an experience orb.");
return null;
}
return new ElementTag(((ExperienceOrb) entity.entity.getBukkitEntity()).getSpawnReason().name());
});
// <--[tag]
// @attribute <EntityTag.xp_trigger>
// @returns EntityTag
// @group properties
// @Plugin Paper
// @description
// If the entity is an experience orb, returns the entity that triggered it spawning (if any).
// For example, if a player killed an entity this would return the player.
// -->
PropertyParser.<PaperEntityProperties, EntityTag>registerTag(EntityTag.class, "xp_trigger", (attribute, entity) -> {
if (!(entity.entity.getBukkitEntity() instanceof ExperienceOrb)) {
attribute.echoError("Entity " + entity.entity + " is not an experience orb.");
return null;
}
UUID uuid = ((ExperienceOrb) entity.entity.getBukkitEntity()).getTriggerEntityId();
if (uuid == null) {
return null;
}
Entity e = EntityTag.getEntityForID(uuid);
if (e == null) {
return null;
}
return new EntityTag(e);
});
// <--[tag]
// @attribute <EntityTag.xp_source>
// @returns EntityTag
// @group properties
// @Plugin Paper
// @description
// If the entity is an experience orb, returns the entity that it was created from (if any).
// For example, if the xp orb was spawned from breeding this would return the baby.
// -->
PropertyParser.<PaperEntityProperties, EntityTag>registerTag(EntityTag.class, "xp_source", (attribute, entity) -> {
if (!(entity.entity.getBukkitEntity() instanceof ExperienceOrb)) {
attribute.echoError("Entity " + entity.entity + " is not an experience orb.");
return null;
}
UUID uuid = ((ExperienceOrb) entity.entity.getBukkitEntity()).getSourceEntityId();
if (uuid == null) {
return null;
}
Entity e = EntityTag.getEntityForID(uuid);
if (e == null) {
return null;
}
return new EntityTag(e);
});
// <--[tag]
// @attribute <EntityTag.spawn_location>
// @returns LocationTag
// @group properties
// @Plugin Paper
// @description
// Returns the initial spawn location of this entity.
// -->
PropertyParser.<PaperEntityProperties, LocationTag>registerTag(LocationTag.class, "spawn_location", (attribute, entity) -> {
Location loc = entity.entity.getBukkitEntity().getOrigin();
return loc != null ? new LocationTag(loc) : null;
});
// <--[tag]
// @attribute <EntityTag.from_spawner>
// @returns ElementTag(Boolean)
// @group properties
// @Plugin Paper
// @description
// Returns whether the entity was spawned from a spawner.
// -->
PropertyParser.<PaperEntityProperties, ElementTag>registerTag(ElementTag.class, "from_spawner", (attribute, entity) -> {
return new ElementTag(entity.entity.getBukkitEntity().fromMobSpawner());
});
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class ProjectileCollideScriptEvent method projectileCollideEvent.
@EventHandler
public void projectileCollideEvent(ProjectileCollideEvent event) {
this.event = event;
collidedWith = new EntityTag(event.getCollidedWith());
projectile = new EntityTag(event.getEntity());
fire(event);
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class PreEntitySpawnScriptEvent method onPreCreatureSpawn.
@EventHandler
public void onPreCreatureSpawn(PreCreatureSpawnEvent event) {
this.entity = new EntityTag(event.getType());
this.location = new LocationTag(event.getSpawnLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityLoadCrossbowScriptEvent method onLoadCrossbow.
@EventHandler
public void onLoadCrossbow(EntityLoadCrossbowEvent event) {
this.event = event;
this.entity = new EntityTag(event.getEntity());
fire(event);
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class CreeperIgnitesScriptEvent method onCreeperIgnites.
@EventHandler
public void onCreeperIgnites(CreeperIgniteEvent event) {
entity = new EntityTag(event.getEntity());
this.event = event;
fire(event);
}
Aggregations