use of com.denizenscript.denizen.objects.LocationTag 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.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class BlockBuiltScriptEvent method onBlockBuilt.
@EventHandler
public void onBlockBuilt(BlockCanBuildEvent event) {
location = new LocationTag(event.getBlock().getLocation());
old_material = new MaterialTag(event.getBlock());
new_material = new MaterialTag(event.getBlockData());
cancelled = !event.isBuildable();
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class BlockDispensesScriptEvent method applyDetermination.
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj.canBeType(LocationTag.class)) {
LocationTag vel = determinationObj.asType(LocationTag.class, getTagContext(path));
if (vel != null) {
event.setVelocity(vel.toVector());
return true;
}
}
if (determinationObj.canBeType(ItemTag.class)) {
ItemTag it = determinationObj.asType(ItemTag.class, getTagContext(path));
if (it != null) {
item = it;
event.setItem(item.getItemStack());
return true;
}
}
if (ArgumentHelper.matchesDouble(determinationObj.toString())) {
Deprecations.blockDispensesItemDetermination.warn();
event.setVelocity(event.getVelocity().multiply(Double.parseDouble(determinationObj.toString())));
return true;
}
return super.applyDetermination(path, determinationObj);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class BlockDispensesScriptEvent method onBlockDispenses.
@EventHandler
public void onBlockDispenses(BlockDispenseEvent event) {
location = new LocationTag(event.getBlock().getLocation());
material = new MaterialTag(event.getBlock());
item = new ItemTag(event.getItem());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerJumpsScriptEventPaperImpl method onPlayerJumps.
@EventHandler
public void onPlayerJumps(PlayerJumpEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
location = new LocationTag(event.getFrom());
player = new PlayerTag(event.getPlayer());
fire(event);
}
Aggregations