use of com.denizenscript.denizen.nms.interfaces.PlayerHelper in project Denizen-For-Bukkit by DenizenScript.
the class ExecuteCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
ElementTag cmd = scriptEntry.getElement("command");
ElementTag type = scriptEntry.getElement("type");
boolean silent = scriptEntry.argAsBoolean("silent");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), type, cmd, db("silent", silent));
}
String command = cmd.asString();
switch(Type.valueOf(type.asString())) {
case AS_PLAYER:
try {
PlayerCommandPreprocessEvent pcpe = new PlayerCommandPreprocessEvent(Utilities.getEntryPlayer(scriptEntry).getPlayerEntity(), "/" + command);
Bukkit.getPluginManager().callEvent(pcpe);
if (!pcpe.isCancelled()) {
Player player = Utilities.getEntryPlayer(scriptEntry).getPlayerEntity();
if (silent) {
NetworkInterceptHelper.enable();
silencedPlayers.add(player.getUniqueId());
}
player.performCommand(pcpe.getMessage().startsWith("/") ? pcpe.getMessage().substring(1) : pcpe.getMessage());
if (silent) {
silencedPlayers.remove(player.getUniqueId());
}
}
} catch (Throwable e) {
Debug.echoError(scriptEntry, "Exception while executing command as player.");
Debug.echoError(scriptEntry, e);
}
break;
case AS_OP:
if (CoreUtilities.equalsIgnoreCase(command, "stop")) {
Debug.echoError("Please use as_server to execute 'stop'.");
return;
}
Player player = Utilities.getEntryPlayer(scriptEntry).getPlayerEntity();
PlayerHelper playerHelper = NMSHandler.getPlayerHelper();
boolean isOp = player.isOp();
if (!isOp) {
playerHelper.setTemporaryOp(player, true);
}
try {
PlayerCommandPreprocessEvent pcpe = new PlayerCommandPreprocessEvent(player, "/" + command);
Bukkit.getPluginManager().callEvent(pcpe);
if (!pcpe.isCancelled()) {
if (silent) {
NetworkInterceptHelper.enable();
silencedPlayers.add(player.getUniqueId());
}
player.performCommand(pcpe.getMessage().startsWith("/") ? pcpe.getMessage().substring(1) : pcpe.getMessage());
if (silent) {
silencedPlayers.remove(player.getUniqueId());
}
}
} catch (Throwable e) {
Debug.echoError(scriptEntry, "Exception while executing command as OP.");
Debug.echoError(scriptEntry, e);
}
if (!isOp) {
playerHelper.setTemporaryOp(player, false);
}
break;
case AS_NPC:
if (!Utilities.getEntryNPC(scriptEntry).isSpawned()) {
Debug.echoError(scriptEntry, "Cannot EXECUTE AS_NPC unless the NPC is Spawned.");
return;
}
if (Utilities.getEntryNPC(scriptEntry).getEntity().getType() != EntityType.PLAYER) {
Debug.echoError(scriptEntry, "Cannot EXECUTE AS_NPC unless the NPC is Player-Type.");
return;
}
Utilities.getEntryNPC(scriptEntry).getEntity().setOp(true);
try {
((Player) Utilities.getEntryNPC(scriptEntry).getEntity()).performCommand(command);
} catch (Throwable e) {
Debug.echoError(scriptEntry, "Exception while executing command as NPC-OP.");
Debug.echoError(scriptEntry, e);
}
Utilities.getEntryNPC(scriptEntry).getEntity().setOp(false);
break;
case AS_SERVER:
dcs.clearOutput();
dcs.silent = silent;
ServerCommandEvent sce = new ServerCommandEvent(dcs, command);
Bukkit.getPluginManager().callEvent(sce);
Denizen.getInstance().getServer().dispatchCommand(dcs, sce.getCommand());
scriptEntry.addObject("output", new ListTag(dcs.getOutput()));
break;
}
}
use of com.denizenscript.denizen.nms.interfaces.PlayerHelper in project Denizen-For-Bukkit by DenizenScript.
the class InventoryScriptHelper method onPlayerLogin.
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
PlayerHelper playerHelper = NMSHandler.getPlayerHelper();
if (ImprovedOfflinePlayer.offlineInventories.containsKey(uuid)) {
playerHelper.getOfflineData(uuid).setInventory(ImprovedOfflinePlayer.offlineInventories.get(uuid));
ImprovedOfflinePlayer.offlineInventories.remove(uuid);
}
if (ImprovedOfflinePlayer.offlineEnderChests.containsKey(uuid)) {
playerHelper.getOfflineData(uuid).setEnderChest(ImprovedOfflinePlayer.offlineEnderChests.get(uuid));
ImprovedOfflinePlayer.offlineEnderChests.remove(uuid);
}
}
use of com.denizenscript.denizen.nms.interfaces.PlayerHelper in project Denizen-For-Bukkit by DenizenScript.
the class EntityTag method adjust.
@Override
public void adjust(Mechanism mechanism) {
if (isGeneric()) {
mechanisms.add(mechanism);
mechanism.fulfill();
return;
}
if (getBukkitEntity() == null) {
if (isCitizensNPC()) {
mechanism.echoError("Cannot adjust not-spawned NPC " + getDenizenNPC());
} else {
mechanism.echoError("Cannot adjust entity " + this);
}
return;
}
if (mechanism.matches("attach_to")) {
Deprecations.attachToMech.warn(mechanism.context);
if (mechanism.hasValue()) {
ListTag list = mechanism.valueAsType(ListTag.class);
Vector offset = null;
boolean rotateWith = true;
if (list.size() > 1) {
offset = LocationTag.valueOf(list.get(1), mechanism.context).toVector();
if (list.size() > 2) {
rotateWith = new ElementTag(list.get(2)).asBoolean();
}
}
EntityAttachmentHelper.forceAttachMove(this, EntityTag.valueOf(list.get(0), mechanism.context), offset, rotateWith);
} else {
EntityAttachmentHelper.forceAttachMove(this, null, null, false);
}
}
// -->
if (mechanism.matches("shooter")) {
setShooter(mechanism.valueAsType(EntityTag.class));
}
// -->
if (mechanism.matches("can_pickup_items") && mechanism.requireBoolean()) {
getLivingEntity().setCanPickupItems(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("fall_distance") && mechanism.requireFloat()) {
entity.setFallDistance(mechanism.getValue().asFloat());
}
// -->
if (mechanism.matches("fallingblock_drop_item") && mechanism.requireBoolean() && entity instanceof FallingBlock) {
((FallingBlock) entity).setDropItem(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("fallingblock_hurt_entities") && mechanism.requireBoolean() && entity instanceof FallingBlock) {
((FallingBlock) entity).setHurtEntities(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("fire_time") && mechanism.requireObject(DurationTag.class)) {
entity.setFireTicks(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("leash_holder") && mechanism.requireObject(EntityTag.class)) {
getLivingEntity().setLeashHolder(mechanism.valueAsType(EntityTag.class).getBukkitEntity());
}
// -->
if (mechanism.matches("can_breed") && mechanism.requireBoolean()) {
((Ageable) getLivingEntity()).setBreed(true);
}
// -->
if (mechanism.matches("breed") && mechanism.requireBoolean()) {
((Animals) getLivingEntity()).setLoveModeTicks(mechanism.getValue().asBoolean() ? 600 : 0);
}
// -->
if (mechanism.matches("passengers")) {
entity.eject();
for (EntityTag ent : mechanism.valueAsType(ListTag.class).filter(EntityTag.class, mechanism.context)) {
if (comparesTo(ent) == 1) {
continue;
}
if (!ent.isSpawned()) {
ent.spawnAt(getLocation());
}
if (ent.isSpawned()) {
entity.addPassenger(ent.getBukkitEntity());
}
}
}
// -->
if (mechanism.matches("passenger") && mechanism.requireObject(EntityTag.class)) {
EntityTag ent = mechanism.valueAsType(EntityTag.class);
if (!ent.isSpawned()) {
ent.spawnAt(getLocation());
}
entity.eject();
if (ent.isSpawned()) {
entity.addPassenger(ent.getBukkitEntity());
}
}
// -->
if (mechanism.matches("time_lived") && mechanism.requireObject(DurationTag.class)) {
NMSHandler.getEntityHelper().setTicksLived(entity, mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("absorption_health") && mechanism.requireFloat()) {
NMSHandler.getEntityHelper().setAbsorption(getLivingEntity(), mechanism.getValue().asDouble());
}
// -->
if (mechanism.matches("oxygen") && mechanism.requireObject(DurationTag.class)) {
getLivingEntity().setRemainingAir(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
if (mechanism.matches("remaining_air") && mechanism.requireInteger()) {
Deprecations.entityRemainingAir.warn(mechanism.context);
getLivingEntity().setRemainingAir(mechanism.getValue().asInt());
}
// -->
if (mechanism.matches("remove_effects")) {
for (PotionEffect potionEffect : this.getLivingEntity().getActivePotionEffects()) {
getLivingEntity().removePotionEffect(potionEffect.getType());
}
}
// -->
if (mechanism.matches("release_left_shoulder") && getLivingEntity() instanceof HumanEntity) {
Entity bukkitEnt = ((HumanEntity) getLivingEntity()).getShoulderEntityLeft();
if (bukkitEnt != null) {
EntityTag ent = new EntityTag(bukkitEnt);
String escript = ent.getEntityScript();
ent = EntityTag.valueOf("e@" + (escript != null && escript.length() > 0 ? escript : ent.getEntityType().getLowercaseName()) + PropertyParser.getPropertiesString(ent), mechanism.context);
ent.spawnAt(getEyeLocation());
((HumanEntity) getLivingEntity()).setShoulderEntityLeft(null);
}
}
// -->
if (mechanism.matches("release_right_shoulder") && getLivingEntity() instanceof HumanEntity) {
Entity bukkitEnt = ((HumanEntity) getLivingEntity()).getShoulderEntityRight();
if (bukkitEnt != null) {
EntityTag ent = new EntityTag(bukkitEnt);
String escript = ent.getEntityScript();
ent = EntityTag.valueOf("e@" + (escript != null && escript.length() > 0 ? escript : ent.getEntityType().getLowercaseName()) + PropertyParser.getPropertiesString(ent), mechanism.context);
ent.spawnAt(getEyeLocation());
((HumanEntity) getLivingEntity()).setShoulderEntityRight(null);
}
}
// -->
if (mechanism.matches("left_shoulder") && getLivingEntity() instanceof HumanEntity) {
if (mechanism.hasValue()) {
if (mechanism.requireObject(EntityTag.class)) {
((HumanEntity) getLivingEntity()).setShoulderEntityLeft(mechanism.valueAsType(EntityTag.class).getBukkitEntity());
}
} else {
((HumanEntity) getLivingEntity()).setShoulderEntityLeft(null);
}
}
// -->
if (mechanism.matches("right_shoulder") && getLivingEntity() instanceof HumanEntity) {
if (mechanism.hasValue()) {
if (mechanism.requireObject(EntityTag.class)) {
((HumanEntity) getLivingEntity()).setShoulderEntityRight(mechanism.valueAsType(EntityTag.class).getBukkitEntity());
}
} else {
((HumanEntity) getLivingEntity()).setShoulderEntityRight(null);
}
}
// -->
if (mechanism.matches("persistent") && mechanism.requireBoolean()) {
getLivingEntity().setRemoveWhenFarAway(!mechanism.getValue().asBoolean());
}
if (mechanism.matches("remove_when_far_away") && mechanism.requireBoolean()) {
Deprecations.entityRemoveWhenFar.warn(mechanism.context);
getLivingEntity().setRemoveWhenFarAway(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("sheared") && mechanism.requireBoolean() && getBukkitEntity() instanceof Sheep) {
((Sheep) getBukkitEntity()).setSheared(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("collidable") && mechanism.requireBoolean()) {
if (isCitizensNPC()) {
getDenizenNPC().getCitizen().data().setPersistent(NPC.COLLIDABLE_METADATA, mechanism.getValue().asBoolean());
} else {
getLivingEntity().setCollidable(mechanism.getValue().asBoolean());
}
}
// -->
if (mechanism.matches("no_damage_duration") && mechanism.requireObject(DurationTag.class)) {
getLivingEntity().setNoDamageTicks(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("max_no_damage_duration") && mechanism.requireObject(DurationTag.class)) {
getLivingEntity().setMaximumNoDamageTicks(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("velocity") && mechanism.requireObject(LocationTag.class)) {
setVelocity(mechanism.valueAsType(LocationTag.class).toVector());
}
// -->
if (mechanism.matches("move") && mechanism.requireObject(LocationTag.class)) {
NMSHandler.getEntityHelper().move(getBukkitEntity(), mechanism.valueAsType(LocationTag.class).toVector());
}
// -->
if (mechanism.matches("interact_with") && mechanism.requireObject(LocationTag.class)) {
LocationTag interactLocation = mechanism.valueAsType(LocationTag.class);
NMSHandler.getEntityHelper().forceInteraction(getPlayer(), interactLocation);
}
if (mechanism.matches("play_death")) {
Deprecations.entityPlayDeath.warn(mechanism.context);
getLivingEntity().playEffect(EntityEffect.DEATH);
}
// -->
if ((mechanism.matches("pickup_delay") || mechanism.matches("pickupdelay")) && getBukkitEntity() instanceof Item && mechanism.requireObject(DurationTag.class)) {
((Item) getBukkitEntity()).setPickupDelay(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("gliding") && mechanism.requireBoolean()) {
getLivingEntity().setGliding(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("glowing") && mechanism.requireBoolean()) {
getBukkitEntity().setGlowing(mechanism.getValue().asBoolean());
if (Depends.citizens != null && CitizensAPI.getNPCRegistry().isNPC(getLivingEntity())) {
CitizensAPI.getNPCRegistry().getNPC(getLivingEntity()).data().setPersistent(NPC.GLOWING_METADATA, mechanism.getValue().asBoolean());
}
}
// -->
if (mechanism.matches("dragon_phase")) {
EnderDragon ed = (EnderDragon) getLivingEntity();
ed.setPhase(EnderDragon.Phase.valueOf(mechanism.getValue().asString().toUpperCase()));
}
// -->
if (mechanism.matches("experience") && getBukkitEntity() instanceof ExperienceOrb && mechanism.requireInteger()) {
((ExperienceOrb) getBukkitEntity()).setExperience(mechanism.getValue().asInt());
}
// -->
if (mechanism.matches("fuse_ticks") && getBukkitEntity() instanceof TNTPrimed && mechanism.requireInteger()) {
((TNTPrimed) getBukkitEntity()).setFuseTicks(mechanism.getValue().asInt());
}
// -->
if (mechanism.matches("show_to_players")) {
HideEntitiesHelper.unhideEntity(null, getBukkitEntity());
}
// -->
if (mechanism.matches("hide_from_players")) {
HideEntitiesHelper.hideEntity(null, getBukkitEntity());
}
// -->
if (mechanism.matches("skin_layers")) {
int flags = 0;
for (String str : mechanism.valueAsType(ListTag.class)) {
String upper = str.toUpperCase();
if (upper.equals("ALL")) {
flags = 0xFF;
} else {
PlayerHelper.SkinLayer layer = PlayerHelper.SkinLayer.valueOf(upper);
flags |= layer.flag;
}
}
NMSHandler.getPlayerHelper().setSkinLayers((Player) getBukkitEntity(), (byte) flags);
}
// -->
if (mechanism.matches("mirror_player") && mechanism.requireBoolean()) {
if (isNPC()) {
NPC npc = getDenizenNPC().getCitizen();
if (!npc.hasTrait(MirrorTrait.class)) {
npc.addTrait(MirrorTrait.class);
}
MirrorTrait mirror = npc.getOrAddTrait(MirrorTrait.class);
if (mechanism.getValue().asBoolean()) {
mirror.enableMirror();
} else {
mirror.disableMirror();
}
} else {
if (mechanism.getValue().asBoolean()) {
ProfileEditor.mirrorUUIDs.add(getUUID());
} else {
ProfileEditor.mirrorUUIDs.remove(getUUID());
}
}
}
// -->
if (mechanism.matches("swimming") && mechanism.requireBoolean()) {
getLivingEntity().setSwimming(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("detonate")) {
if (getBukkitEntity() instanceof Firework) {
((Firework) getBukkitEntity()).detonate();
} else if (getBukkitEntity() instanceof Creeper) {
((Creeper) getBukkitEntity()).explode();
} else {
Debug.echoError("Cannot detonate entity of type '" + getBukkitEntityType().name() + "'.");
}
}
// -->
if (mechanism.matches("ignite")) {
if (getBukkitEntity() instanceof Creeper) {
((Creeper) getBukkitEntity()).ignite();
} else {
Debug.echoError("Cannot ignite entity of type '" + getBukkitEntityType().name() + "'.");
}
}
// -->
if (mechanism.matches("head_angle") && mechanism.requireFloat()) {
NMSHandler.getEntityHelper().setHeadAngle(getBukkitEntity(), mechanism.getValue().asFloat());
}
// -->
if (mechanism.matches("skeleton_arms_raised") && mechanism.requireBoolean()) {
EntityAnimation entityAnimation = NMSHandler.getAnimationHelper().getEntityAnimation(mechanism.getValue().asBoolean() ? "SKELETON_START_SWING_ARM" : "SKELETON_STOP_SWING_ARM");
entityAnimation.play(entity);
}
// -->
if (mechanism.matches("polar_bear_standing") && mechanism.requireBoolean()) {
EntityAnimation entityAnimation = NMSHandler.getAnimationHelper().getEntityAnimation(mechanism.getValue().asBoolean() ? "POLAR_BEAR_START_STANDING" : "POLAR_BEAR_STOP_STANDING");
entityAnimation.play(entity);
}
// -->
if (mechanism.matches("ghast_attacking") && mechanism.requireBoolean()) {
NMSHandler.getEntityHelper().setGhastAttacking(getBukkitEntity(), mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("enderman_angry") && mechanism.requireBoolean()) {
NMSHandler.getEntityHelper().setEndermanAngry(getBukkitEntity(), mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("melee_attack") && mechanism.requireObject(EntityTag.class)) {
Entity target = mechanism.valueAsType(EntityTag.class).getBukkitEntity();
if (getLivingEntity() instanceof Player && NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
NMSHandler.getPlayerHelper().doAttack((Player) getLivingEntity(), target);
} else {
getLivingEntity().attack(target);
}
}
// -->
if (mechanism.matches("last_hurt_by") && mechanism.requireObject(EntityTag.class)) {
NMSHandler.getEntityHelper().setLastHurtBy(getLivingEntity(), mechanism.valueAsType(EntityTag.class).getLivingEntity());
}
// -->
if (mechanism.matches("fish_hook_nibble_time") && mechanism.requireObject(DurationTag.class)) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_nibble_time is only valid for FishHook entities.");
return;
}
NMSHandler.getFishingHelper().setNibble((FishHook) getBukkitEntity(), mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("fish_hook_bite_time") && mechanism.requireObject(DurationTag.class)) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_hook_time is only valid for FishHook entities.");
return;
}
NMSHandler.getFishingHelper().setHookTime((FishHook) getBukkitEntity(), mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("fish_hook_lure_time") && mechanism.requireObject(DurationTag.class)) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_lure_time is only valid for FishHook entities.");
return;
}
NMSHandler.getFishingHelper().setLureTime((FishHook) getBukkitEntity(), mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("fish_hook_pull")) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_pull is only valid for FishHook entities.");
return;
}
((FishHook) getBukkitEntity()).pullHookedEntity();
}
// -->
if (mechanism.matches("fish_hook_apply_lure") && mechanism.requireBoolean()) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_apply_lure is only valid for FishHook entities.");
return;
}
((FishHook) getBukkitEntity()).setApplyLure(mechanism.getValue().asBoolean());
}
// -->
if (mechanism.matches("fish_hook_hooked_entity") && mechanism.requireObject(EntityTag.class)) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_hooked_entity is only valid for FishHook entities.");
return;
}
((FishHook) getBukkitEntity()).setHookedEntity(mechanism.valueAsType(EntityTag.class).getBukkitEntity());
}
// -->
if (mechanism.matches("fish_hook_min_lure_time") && mechanism.requireObject(DurationTag.class)) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_min_lure_time is only valid for FishHook entities.");
return;
}
((FishHook) getBukkitEntity()).setMinWaitTime(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("fish_hook_max_lure_time") && mechanism.requireObject(DurationTag.class)) {
if (!(getBukkitEntity() instanceof FishHook)) {
mechanism.echoError("fish_hook_max_lure_time is only valid for FishHook entities.");
return;
}
((FishHook) getBukkitEntity()).setMaxWaitTime(mechanism.valueAsType(DurationTag.class).getTicksAsInt());
}
// -->
if (mechanism.matches("redo_attack_cooldown")) {
if (!(getLivingEntity() instanceof Player)) {
mechanism.echoError("Only player-type entities can have attack_cooldowns!");
return;
}
NMSHandler.getPlayerHelper().setAttackCooldown((Player) getLivingEntity(), 0);
}
// -->
if (mechanism.matches("reset_attack_cooldown")) {
if (!(getLivingEntity() instanceof Player)) {
mechanism.echoError("Only player-type entities can have attack_cooldowns!");
return;
}
PlayerHelper playerHelper = NMSHandler.getPlayerHelper();
playerHelper.setAttackCooldown((Player) getLivingEntity(), Math.round(playerHelper.getMaxAttackCooldownTicks((Player) getLivingEntity())));
}
// -->
if (mechanism.matches("attack_cooldown_percent") && mechanism.requireFloat()) {
if (!(getLivingEntity() instanceof Player)) {
mechanism.echoError("Only player-type entities can have attack_cooldowns!");
return;
}
float percent = mechanism.getValue().asFloat();
if (percent >= 0 && percent <= 1) {
PlayerHelper playerHelper = NMSHandler.getPlayerHelper();
playerHelper.setAttackCooldown((Player) getLivingEntity(), Math.round(playerHelper.getMaxAttackCooldownTicks((Player) getLivingEntity()) * mechanism.getValue().asFloat()));
} else {
com.denizenscript.denizen.utilities.debugging.Debug.echoError("Invalid percentage! \"" + percent + "\" is not between 0 and 1!");
}
}
// -->
if (mechanism.matches("attack_cooldown") && mechanism.requireObject(DurationTag.class)) {
if (!(getLivingEntity() instanceof Player)) {
mechanism.echoError("Only player-type entities can have attack_cooldowns!");
return;
}
NMSHandler.getPlayerHelper().setAttackCooldown((Player) getLivingEntity(), mechanism.getValue().asType(DurationTag.class, mechanism.context).getTicksAsInt());
}
// -->
if (mechanism.matches("fallingblock_type") && mechanism.requireObject(MaterialTag.class)) {
if (!(getBukkitEntity() instanceof FallingBlock)) {
mechanism.echoError("'fallingblock_type' is only valid for Falling Block entities.");
return;
}
NMSHandler.getEntityHelper().setFallingBlockType((FallingBlock) getBukkitEntity(), mechanism.valueAsType(MaterialTag.class).getModernData());
}
// -->
if (mechanism.matches("tracking_range") && mechanism.requireInteger()) {
NMSHandler.getEntityHelper().setTrackingRange(getBukkitEntity(), mechanism.getValue().asInt());
}
CoreUtilities.autoPropertyMechanism(this, mechanism);
}
Aggregations