Here are the examples of the java api org.bukkit.EntityEffect taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
19
View Complete Implementation : CombatLoggerState.java
Copyright GNU General Public License v3.0
Author : AustinLMayes
Copyright GNU General Public License v3.0
Author : AustinLMayes
@Override
public void playEffect(EnreplacedyEffect enreplacedyEffect) {
throw new UnsupportedOperationException();
}
19
View Complete Implementation : EffectPlayer.java
Copyright MIT License
Author : elBukkit
Copyright MIT License
Author : elBukkit
public void setEnreplacedyEffect(EnreplacedyEffect enreplacedyEffect) {
this.enreplacedyEffect = enreplacedyEffect;
}
19
View Complete Implementation : CraftNMSArmorStand.java
Copyright GNU General Public License v3.0
Author : filoghost
Copyright GNU General Public License v3.0
Author : filoghost
@Override
public void playEffect(EnreplacedyEffect effect) {
}
19
View Complete Implementation : CraftEntity.java
Copyright GNU General Public License v2.0
Author : GelandiAssociation
Copyright GNU General Public License v2.0
Author : GelandiAssociation
@Override
public void playEffect(EnreplacedyEffect type) {
Preconditions.checkArgument(type != null, "type");
if (type.getApplicable().isInstance(this)) {
this.getHandle().world.broadcastEnreplacedyEffect(getHandle(), type.getData());
}
}
19
View Complete Implementation : CraftEntity.java
Copyright GNU Lesser General Public License v3.0
Author : GMatrixGames
Copyright GNU Lesser General Public License v3.0
Author : GMatrixGames
@Override
public void playEffect(EnreplacedyEffect type) {
Preconditions.checkArgument(type != null, "type");
if (type.getApplicable().isInstance(this)) {
this.getHandle().world.setEnreplacedyState(getHandle(), type.getData());
}
}
19
View Complete Implementation : EntityMock.java
Copyright MIT License
Author : seeseemelk
Copyright MIT License
Author : seeseemelk
@Override
public void playEffect(EnreplacedyEffect type) {
// TODO Auto-generated constructor stub
throw new UnimplementedOperationException();
}
19
View Complete Implementation : BridgeEntity.java
Copyright GNU General Public License v3.0
Author : SpoutDev
Copyright GNU General Public License v3.0
Author : SpoutDev
@Override
public void playEffect(EnreplacedyEffect effect) {
throw new UnsupportedOperationException();
}
18
View Complete Implementation : PlayerWrapper.java
Copyright GNU General Public License v3.0
Author : CoolLord22
Copyright GNU General Public License v3.0
Author : CoolLord22
@Override
public void playEffect(EnreplacedyEffect arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
17
View Complete Implementation : EffectPlayer.java
Copyright MIT License
Author : elBukkit
Copyright MIT License
Author : elBukkit
public abstract clreplaced EffectPlayer implements com.elmakers.mine.bukkit.api.effect.EffectPlayer {
private static final String EFFECT_BUILTIN_CLreplacedPATH = "com.elmakers.mine.bukkit.effect.builtin";
public static int PARTICLE_RANGE = 32;
public static boolean initialize(Plugin plugin) {
effectLib = EffectLibManager.initialize(plugin);
return effectLib != null;
}
public static void debugEffects(boolean debug) {
if (effectLib != null) {
effectLib.enableDebug(debug);
}
}
public static void setParticleRange(int range) {
PARTICLE_RANGE = range;
if (effectLib != null) {
effectLib.setParticleRange(range);
}
}
private static Map<String, Clreplaced<?>> effectClreplacedes = new HashMap<>();
private static EffectLibManager effectLib = null;
private ConfigurationSection effectLibConfig = null;
private Collection<EffectPlay> currentEffects = null;
public static boolean SOUNDS_ENABLED = true;
protected Plugin plugin;
private DynamicLocation origin;
private DynamicLocation target;
private Vector originOffset;
private Vector targetOffset;
private Vector originRelativeOffset;
private Vector targetRelativeOffset;
private Visibility visibility = Visibility.ALL;
// These are ignored by the Trail type, need multi-inheritance :\
protected boolean playAtOrigin = true;
protected boolean playAtTarget = false;
protected boolean playAtAllTargets = false;
protected Color color = null;
protected MaterialAndData material;
protected int delayTicks = 0;
protected MaterialAndData material1;
protected Color color1 = null;
protected Color color2 = null;
protected boolean useColor = true;
protected EnreplacedyEffect enreplacedyEffect = null;
protected Effect effect = null;
protected Integer effectData = null;
protected SoundEffect sound = null;
protected boolean broadcastSound = true;
protected boolean hasFirework = false;
protected FireworkEffect.Type fireworkType;
protected int fireworkPower = 1;
protected Boolean fireworkFlicker;
protected boolean fireworkSilent;
protected FireworkEffect fireworkEffect;
protected Particle particleType = null;
protected Particle particleOverride = null;
protected String useParticleOverride = null;
protected String useColorOverride = null;
protected float particleData = 0f;
protected float particleXOffset = 0.3f;
protected float particleYOffset = 0.3f;
protected float particleZOffset = 0.3f;
protected int particleCount = 1;
protected float particleSize = 1;
protected boolean requireEnreplacedy = false;
protected boolean requireTargetEnreplacedy = false;
protected boolean sampleTarget = false;
protected SourceLocation sourceLocation = null;
protected SourceLocation targetLocation = null;
protected float scale = 1.0f;
protected ConfigurationSection parameterMap = null;
public EffectPlayer() {
}
public EffectPlayer(Plugin plugin) {
this.plugin = plugin;
}
private void warn(String warning) {
if (plugin != null) {
plugin.getLogger().warning(warning);
}
}
public void load(Plugin plugin, ConfigurationSection configuration) {
this.plugin = plugin;
if (effectLib != null && configuration.contains("effectlib")) {
effectLibConfig = ConfigurationUtils.getConfigurationSection(configuration, "effectlib");
if (effectLibConfig == null) {
Object rawConfig = configuration.get("effectlib");
warn("Could not load effectlib node of type " + rawConfig.getClreplaced());
}
} else {
effectLibConfig = null;
}
broadcastSound = configuration.getBoolean("sound_broadcast", true);
useParticleOverride = configuration.getString("particle_override", null);
useColorOverride = configuration.getString("color_override", null);
originOffset = ConfigurationUtils.getVector(configuration, "origin_offset", ConfigurationUtils.getVector(configuration, "offset"));
targetOffset = ConfigurationUtils.getVector(configuration, "target_offset");
originRelativeOffset = ConfigurationUtils.getVector(configuration, "relative_offset");
targetRelativeOffset = ConfigurationUtils.getVector(configuration, "relative_target_offset");
delayTicks = configuration.getInt("delay", delayTicks) * 20 / 1000;
material1 = ConfigurationUtils.getMaterialAndData(configuration, "material");
if (configuration.isBoolean("color") && !configuration.getBoolean("color")) {
useColor = false;
} else {
color1 = ConfigurationUtils.getColor(configuration, "color", null);
color2 = ConfigurationUtils.getColor(configuration, "color2", null);
}
if (configuration.contains("effect")) {
String effectName = configuration.getString("effect");
try {
effect = Effect.valueOf(effectName.toUpperCase());
} catch (Exception ignored) {
}
if (effect == null) {
warn("Unknown effect type " + effectName);
} else {
effectData = ConfigurationUtils.getInteger(configuration, "effect_data", effectData);
}
}
if (configuration.contains("enreplacedy_effect")) {
String effectName = configuration.getString("enreplacedy_effect");
try {
enreplacedyEffect = EnreplacedyEffect.valueOf(effectName.toUpperCase());
} catch (Exception ignored) {
}
if (enreplacedyEffect == null) {
warn("Unknown enreplacedy effect type " + effectName);
}
}
if (configuration.contains("sound")) {
sound = new SoundEffect(configuration.getString("sound"));
} else if (configuration.contains("custom_sound")) {
sound = new SoundEffect(configuration.getString("custom_sound"));
}
if (sound != null) {
sound.setVolume((float) configuration.getDouble("sound_volume", sound.getVolume()));
sound.setPitch((float) configuration.getDouble("sound_pitch", sound.getPitch()));
sound.setRange(configuration.getInt("sound_range", sound.getRange()));
}
if (configuration.contains("firework") || configuration.contains("firework_power")) {
hasFirework = true;
fireworkType = null;
if (configuration.contains("firework")) {
String typeName = configuration.getString("firework");
try {
fireworkType = FireworkEffect.Type.valueOf(typeName.toUpperCase());
} catch (Exception ignored) {
}
if (fireworkType == null) {
warn("Unknown firework type " + typeName);
}
}
fireworkPower = configuration.getInt("firework_power", fireworkPower);
fireworkFlicker = ConfigurationUtils.getBoolean(configuration, "firework_flicker", fireworkFlicker);
fireworkSilent = configuration.getBoolean("firework_silent", true);
}
if (configuration.contains("particle")) {
String typeName = configuration.getString("particle");
try {
particleType = Particle.valueOf(typeName.toUpperCase());
} catch (Exception ignored) {
}
if (particleType == null) {
warn("Unknown particle type " + typeName);
} else {
particleData = (float) configuration.getDouble("particle_data", particleData);
particleData = (float) configuration.getDouble("particle_speed", particleData);
particleXOffset = (float) configuration.getDouble("particle_offset_x", particleXOffset);
particleYOffset = (float) configuration.getDouble("particle_offset_y", particleYOffset);
particleZOffset = (float) configuration.getDouble("particle_offset_z", particleZOffset);
particleCount = configuration.getInt("particle_count", particleCount);
particleSize = (float) configuration.getDouble("particle_size", particleSize);
}
}
String visibilityType = configuration.getString("visibility");
if (visibilityType != null) {
try {
visibility = Visibility.valueOf(visibilityType.toUpperCase());
} catch (Exception ex) {
warn("Invalid visibility type: " + visibilityType);
}
}
setLocationType(configuration.getString("location", "origin"));
requireEnreplacedy = configuration.getBoolean("requires_enreplacedy", false);
requireTargetEnreplacedy = configuration.getBoolean("requires_enreplacedy_target", false);
sourceLocation = new SourceLocation(configuration);
targetLocation = new SourceLocation(configuration, "target_location", false);
sampleTarget = configuration.getString("sample", "").equalsIgnoreCase("target");
}
public void setLocationType(String locationType) {
if (locationType.equals("target")) {
playAtOrigin = false;
playAtTarget = true;
playAtAllTargets = false;
} else if (locationType.equals("origin")) {
playAtTarget = false;
playAtOrigin = true;
playAtAllTargets = false;
} else if (locationType.equals("both")) {
playAtTarget = true;
playAtOrigin = true;
playAtAllTargets = false;
} else if (locationType.equals("targets")) {
playAtTarget = true;
playAtOrigin = false;
playAtAllTargets = true;
}
}
public FireworkEffect getFireworkEffect(Color color1, Color color2, org.bukkit.FireworkEffect.Type fireworkType) {
return getFireworkEffect(color1, color2, fireworkType, null, null);
}
public FireworkEffect getFireworkEffect(Color color1, Color color2, org.bukkit.FireworkEffect.Type fireworkType, Boolean flicker, Boolean trail) {
Random rand = new Random();
if (color1 == null) {
color1 = Color.fromRGB(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255));
}
if (color2 == null) {
color2 = Color.fromRGB(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255));
}
if (fireworkType == null) {
fireworkType = org.bukkit.FireworkEffect.Type.values()[rand.nextInt(org.bukkit.FireworkEffect.Type.values().length)];
}
if (flicker == null) {
flicker = rand.nextBoolean();
}
if (trail == null) {
trail = rand.nextBoolean();
}
return FireworkEffect.builder().flicker(flicker).withColor(color1).withFade(color2).with(fireworkType).trail(trail).build();
}
@Override
public void setEffect(Effect effect) {
this.effect = effect;
}
public void setEnreplacedyEffect(EnreplacedyEffect enreplacedyEffect) {
this.enreplacedyEffect = enreplacedyEffect;
}
public void setParticleType(Particle particleType) {
this.particleType = particleType;
}
@Override
public void setParticleOverride(String particleType) {
if (particleType == null || particleType.isEmpty()) {
this.particleOverride = null;
return;
}
try {
this.particleOverride = Particle.valueOf(particleType.toUpperCase());
} catch (Exception ex) {
warn("Error setting particle override: " + ex.getMessage());
this.particleOverride = null;
}
}
@Override
public void setEffectData(int data) {
this.effectData = data;
}
@SuppressWarnings("deprecation")
protected MaterialAndData getWorkingMaterial() {
Location target = getTarget();
if (sampleTarget && target != null) {
return new MaterialAndData(target.getBlock().getType(), target.getBlock().getData());
}
if (material1 != null)
return material1;
MaterialAndData result = material;
Location origin = getOrigin();
if (result == null && target != null) {
result = new MaterialAndData(target.getBlock().getType(), target.getBlock().getData());
} else if (result == null && origin != null) {
result = new MaterialAndData(origin.getBlock().getType(), origin.getBlock().getData());
} else if (result == null) {
result = new MaterialAndData(Material.AIR);
}
return result;
}
protected void playEffect() {
playEffect(origin, target);
}
protected void playEffect(DynamicLocation origin, DynamicLocation target) {
if (requireTargetEnreplacedy && (target == null || target.getEnreplacedy() == null)) {
return;
}
if (playAtOrigin && origin != null) {
performEffects(origin, target);
}
if (playAtTarget && target != null) {
performEffects(target, origin);
}
}
@SuppressWarnings("deprecation")
protected void performEffects(DynamicLocation source, DynamicLocation target) {
Location sourceLocation = source == null ? null : source.getLocation();
if (sourceLocation == null)
return;
Enreplacedy sourceEnreplacedy = source == null ? null : source.getEnreplacedy();
if (requireEnreplacedy && sourceEnreplacedy == null)
return;
if (effectLib != null && effectLibConfig != null) {
EffectLibPlay play = effectLib.play(effectLibConfig, this, source, target, parameterMap);
if (currentEffects != null && play != null) {
currentEffects.add(play);
}
}
if (effect != null) {
int data = effectData == null ? 0 : effectData;
if ((effect == Effect.STEP_SOUND) && effectData == null) {
Material material = getWorkingMaterial().getMaterial();
// Check for potential bad materials, this can get really hairy (client crashes)
if (!material.isSolid()) {
return;
}
sourceLocation.getWorld().playEffect(sourceLocation, effect, material);
} else {
sourceLocation.getWorld().playEffect(sourceLocation, effect, data);
}
}
if (enreplacedyEffect != null && sourceEnreplacedy != null) {
sourceEnreplacedy.playEffect(enreplacedyEffect);
}
if (sound != null) {
if (broadcastSound) {
sound.play(plugin, sourceLocation);
} else if (sourceEnreplacedy != null) {
sound.play(plugin, sourceEnreplacedy);
}
}
if (fireworkEffect != null) {
EffectUtils.spawnFireworkEffect(plugin.getServer(), sourceLocation, fireworkEffect, fireworkPower, fireworkSilent);
}
if (particleType != null) {
Particle useEffect = overrideParticle(particleType);
Material material = getWorkingMaterial().getMaterial();
Short data = getWorkingMaterial().getData();
displayParticle(useEffect, sourceLocation, particleXOffset, particleYOffset, particleZOffset, particleData, particleCount, particleSize, getColor1(), material, data == null ? 0 : (byte) (short) data, PARTICLE_RANGE);
}
}
public static void displayParticle(Particle particle, Location center, float offsetX, float offsetY, float offsetZ, float speed, int amount, float size, Color color, Material material, byte materialData, double range) {
effectLib.displayParticle(particle, center, offsetX, offsetY, offsetZ, speed, amount, size, color, material, materialData, range);
}
public Particle overrideParticle(Particle particle) {
return useParticleOverride != null && !useParticleOverride.isEmpty() && particleOverride != null ? particleOverride : particle;
}
public String getParticleOverrideName() {
return useParticleOverride;
}
public String getColorOverrideName() {
return useColorOverride;
}
public void setParticleData(float effectData) {
this.particleData = effectData;
}
public void setParticleCount(int particleCount) {
this.particleCount = particleCount;
}
public void setParticleOffset(float xOffset, float yOffset, float zOffset) {
this.particleXOffset = xOffset;
this.particleYOffset = yOffset;
this.particleZOffset = zOffset;
}
@Override
public void setScale(float scale) {
this.scale = scale;
}
@Override
public void setSound(Sound sound) {
this.sound = new SoundEffect(sound);
}
@Override
public void setSound(Sound sound, float volume, float pitch) {
this.sound = new SoundEffect(sound);
this.sound.setVolume(volume);
this.sound.setPitch(pitch);
}
@Override
public void setDelayTicks(int ticks) {
delayTicks = ticks;
}
@Override
public void start(Enreplacedy originEnreplacedy, Enreplacedy targetEnreplacedy) {
startEffects(new DynamicLocation(originEnreplacedy), new DynamicLocation(targetEnreplacedy));
}
@Override
public void start(Location origin, Enreplacedy originEnreplacedy, Location target, Enreplacedy targetEnreplacedy) {
startEffects(new DynamicLocation(origin, originEnreplacedy), new DynamicLocation(target, targetEnreplacedy));
}
@Override
public void start(Location origin, Enreplacedy originEnreplacedy, Location target, Enreplacedy targetEnreplacedy, Collection<Enreplacedy> targets) {
if (playsAtAllTargets()) {
start(origin, originEnreplacedy, targets);
} else {
start(origin, originEnreplacedy, target, targetEnreplacedy);
}
}
public void start(Location origin, Enreplacedy originEnreplacedy, Collection<Enreplacedy> targets) {
if (targets == null || targets.size() == 0)
return;
DynamicLocation source = new DynamicLocation(origin, originEnreplacedy);
for (Enreplacedy targetEnreplacedy : targets) {
if (targetEnreplacedy == null)
continue;
// This is not really going to work out well for any Effect type but Single!
// TODO : Perhaps re-visit?
DynamicLocation target = new DynamicLocation(targetEnreplacedy);
startEffects(source, target);
}
}
@Override
public void start(Location origin, Location target) {
startEffects(new DynamicLocation(origin), new DynamicLocation(target));
}
@Override
public void start(EffectContext context) {
context.trackEffects(this);
Location source = getSourceLocation(context);
Location target = getSourceLocation(context);
setColor(context.getEffectColor());
setParticleOverride(context.getEffectParticle());
start(source, context.getEnreplacedy(), target, context.getTargetEnreplacedy());
}
public void startEffects(DynamicLocation origin, DynamicLocation target) {
// Kinda hacky, but makes cross-world trails (e.g. Repair, Backup) work
Location targetLocation = target == null ? null : target.getLocation();
Location originLocation = origin == null ? null : origin.getLocation();
if (targetLocation != null && originLocation != null && !originLocation.getWorld().equals(targetLocation.getWorld())) {
targetLocation.setWorld(originLocation.getWorld());
}
this.origin = origin;
this.target = target;
if (originRelativeOffset != null && this.origin != null) {
this.origin.addRelativeOffset(originRelativeOffset);
}
if (targetRelativeOffset != null && this.target != null) {
this.target.addRelativeOffset(targetRelativeOffset);
}
if (hasFirework) {
fireworkEffect = getFireworkEffect(getColor1(), getColor2(), fireworkType, fireworkFlicker, false);
} else {
fireworkEffect = null;
}
// Should I let EffectLib handle delay?
if (delayTicks > 0 && plugin != null) {
final EffectPlayer player = this;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.startPlay();
}
}, delayTicks);
} else {
startPlay();
}
}
protected void checkLocations() {
if (origin != null) {
if (originOffset != null) {
origin.addOffset(originOffset);
}
}
if (target != null) {
if (targetOffset != null) {
target.addOffset(targetOffset);
}
}
}
protected void startPlay() {
// Generate a target location for compatibility if none exists.
checkLocations();
play();
}
protected Vector getDirection() {
Location origin = this.getOrigin();
Location target = this.getTarget();
if (origin == null)
return new Vector(0, 1, 0);
Vector direction = target == null ? origin.getDirection() : target.toVector().subtract(origin.toVector());
return direction.normalize();
}
@Override
public void setMaterial(com.elmakers.mine.bukkit.api.block.MaterialAndData material) {
this.material = material == null ? null : new MaterialAndData(material);
}
@Override
public void setMaterial(Block block) {
if (block == null) {
this.material = null;
} else {
this.material = new MaterialAndData(block);
}
}
@Override
public void setColor(Color color) {
this.color = color;
}
@Nullable
public Color getColor1() {
return useColor ? (color1 != null ? color1 : color) : null;
}
@Nullable
public Color getColor2() {
return useColor ? (color2 != null ? color2 : color) : null;
}
public abstract void play();
@Nullable
public Location getOrigin() {
return origin == null ? null : origin.getLocation();
}
@Nullable
public Location getTarget() {
return target == null ? null : target.getLocation();
}
public void setOrigin(Location location) {
if (origin == null) {
origin = new DynamicLocation(location);
} else {
Location originLocation = origin.getLocation();
originLocation.setX(location.getX());
originLocation.setY(location.getY());
originLocation.setZ(location.getZ());
}
}
public void setTarget(Location location) {
if (target == null) {
target = new DynamicLocation(location);
} else {
Location targetLocation = target.getLocation();
targetLocation.setX(location.getX());
targetLocation.setY(location.getY());
targetLocation.setZ(location.getZ());
}
}
@Nullable
public Enreplacedy getOriginEnreplacedy() {
return origin == null ? null : origin.getEnreplacedy();
}
@Nullable
public Enreplacedy getTargetEnreplacedy() {
return target == null ? null : target.getEnreplacedy();
}
@Override
public void cancel() {
if (currentEffects != null) {
for (EffectPlay effect : currentEffects) {
effect.cancel();
}
currentEffects.clear();
}
}
public static Collection<com.elmakers.mine.bukkit.api.effect.EffectPlayer> loadEffects(Plugin plugin, ConfigurationSection root, String key) {
List<com.elmakers.mine.bukkit.api.effect.EffectPlayer> players = new ArrayList<>();
Collection<ConfigurationSection> effectNodes = ConfigurationUtils.getNodeList(root, key);
if (effectNodes != null) {
for (ConfigurationSection effectValues : effectNodes) {
String effectClreplaced = effectValues.getString("clreplaced", "EffectSingle");
try {
if (!effectClreplaced.contains(".")) {
effectClreplaced = EFFECT_BUILTIN_CLreplacedPATH + "." + effectClreplaced;
}
Clreplaced<?> genericClreplaced = effectClreplacedes.get(effectClreplaced);
if (genericClreplaced == null) {
genericClreplaced = Clreplaced.forName(effectClreplaced);
effectClreplacedes.put(effectClreplaced, genericClreplaced);
}
if (!EffectPlayer.clreplaced.isreplacedignableFrom(genericClreplaced)) {
throw new Exception("Must extend EffectPlayer");
}
@SuppressWarnings("unchecked")
Clreplaced<? extends EffectPlayer> playerClreplaced = (Clreplaced<? extends EffectPlayer>) genericClreplaced;
EffectPlayer player = playerClreplaced.getDeclaredConstructor().newInstance();
player.load(plugin, effectValues);
players.add(player);
} catch (ClreplacedNotFoundException unknown) {
if (plugin != null) {
plugin.getLogger().warning("Unknown effect clreplaced: " + effectClreplaced);
}
} catch (Exception ex) {
ex.printStackTrace();
if (plugin != null) {
plugin.getLogger().warning("Error creating effect clreplaced: " + effectClreplaced + " " + ex.getMessage());
}
}
}
}
return players;
}
@Override
public void setEffectPlayList(Collection<EffectPlay> plays) {
this.currentEffects = plays;
}
@Nullable
@Override
public Location getSourceLocation(@Nonnull EffectContext context) {
return sourceLocation.getLocation(context);
}
@Nullable
@Override
public Location getTargetLocation(@Nonnull EffectContext context) {
return targetLocation.getLocation(context);
}
@Override
@Deprecated
public void setParameterMap(Map<String, String> map) {
this.parameterMap = ConfigurationUtils.toStringConfiguration(map);
}
@Override
public void setParameterMap(ConfigurationSection map) {
this.parameterMap = map;
}
@Override
public boolean playsAtOrigin() {
return playAtOrigin;
}
@Override
public boolean playsAtTarget() {
return playAtTarget;
}
@Override
public boolean playsAtAllTargets() {
return playAtAllTargets;
}
public Visibility getVisibility() {
return visibility;
}
@Override
@Deprecated
public boolean shouldUseBlockLocation() {
return targetLocation.shouldUseBlockLocation();
}
@Override
@Deprecated
public boolean shouldUseHitLocation() {
return targetLocation.shouldUseHitLocation();
}
@Override
@Deprecated
public boolean shouldUseWandLocation() {
return sourceLocation.shouldUseWandLocation();
}
@Override
@Deprecated
public boolean shouldUseCastLocation() {
return sourceLocation.shouldUseCastLocation();
}
@Override
@Deprecated
public boolean shouldUseEyeLocation() {
return sourceLocation.shouldUseEyeLocation();
}
}
16
View Complete Implementation : AnimateCommand.java
Copyright MIT License
Author : DenizenScript
Copyright MIT License
Author : DenizenScript
@SuppressWarnings("unchecked")
@Override
public void execute(final ScriptEntry scriptEntry) {
// Get objects
List<EnreplacedyTag> enreplacedies = (List<EnreplacedyTag>) scriptEntry.getObject("enreplacedies");
PlayerAnimation animation = scriptEntry.hasObject("animation") ? (PlayerAnimation) scriptEntry.getObject("animation") : null;
EnreplacedyEffect effect = scriptEntry.hasObject("effect") ? (EnreplacedyEffect) scriptEntry.getObject("effect") : null;
String nmsAnimation = scriptEntry.hasObject("nms_animation") ? (String) scriptEntry.getObject("nms_animation") : null;
// Report to dB
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (animation != null ? ArgumentHelper.debugObj("animation", animation.name()) : effect != null ? ArgumentHelper.debugObj("effect", effect.name()) : ArgumentHelper.debugObj("animation", nmsAnimation)) + ArgumentHelper.debugObj("enreplacedies", enreplacedies.toString()));
}
// Go through all the enreplacedies and animate them
for (EnreplacedyTag enreplacedy : enreplacedies) {
if (enreplacedy.isSpawned()) {
try {
if (animation != null && enreplacedy.getBukkitEnreplacedy() instanceof Player) {
Player player = (Player) enreplacedy.getBukkitEnreplacedy();
animation.play(player);
} else if (effect != null) {
enreplacedy.getBukkitEnreplacedy().playEffect(effect);
} else {
EnreplacedyAnimation enreplacedyAnimation = NMSHandler.getAnimationHelper().getEnreplacedyAnimation(nmsAnimation);
enreplacedyAnimation.play(enreplacedy.getBukkitEnreplacedy());
}
} catch (Exception e) {
Debug.ecreplacedror(scriptEntry.getResidingQueue(), "Error playing that animation!");
}
// We tried!
}
}
}