use of com.elmakers.mine.bukkit.magic.SourceLocation in project MagicPlugin by elBukkit.
the class CustomProjectileAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
// Parameters that can be modified by a flight plan need
// to be reset here.
gravity = 0;
drag = 0;
reorient = false;
trackEntity = false;
trackCursorRange = 0;
trackSpeed = 0;
velocityTransform = null;
speed = 1;
tickSize = 0.5;
ignoreTargeting = false;
returnToCaster = false;
resetTimeOnPathChange = false;
updateLaunchLocation = false;
projectileFollowPlayer = false;
modifyParameters(parameters);
// These parameters can't be changed mid-flight
targeting.processParameters(parameters);
interval = parameters.getInt("interval", 30);
lifetime = parameters.getInt("lifetime", 8000);
attachDuration = parameters.getInt("attach_duration", 0);
reverseDirection = parameters.getBoolean("reverse", false);
startDistance = parameters.getInt("start", 0);
range = parameters.getInt("range", 0);
minEntityRange = parameters.getDouble("min_entity_range", 0);
minBlockRange = parameters.getDouble("min_block_range", 0);
minRange = parameters.getDouble("min_entity_range", Math.max(minEntityRange, minBlockRange));
if (minRange < Math.max(minEntityRange, minBlockRange)) {
minRange = Math.max(minEntityRange, minBlockRange);
}
projectileEffectKey = parameters.getString("projectile_effects", "projectile");
headshotEffectKey = parameters.getString("headshot_effects", "headshot");
hitEffectKey = parameters.getString("hit_effects", "hit");
missEffectKey = parameters.getString("miss_effects", "miss");
tickEffectKey = parameters.getString("tick_effects", "tick");
sourceLocation = new SourceLocation(parameters);
targetSelfTimeout = parameters.getInt("target_self_timeout", 0);
targetSelf = parameters.contains("target_self") ? parameters.getBoolean("target_self") : null;
breaksBlocks = parameters.getBoolean("break_blocks", true);
hitRequiresEntity = parameters.getBoolean("hit_requires_entity", false);
targetBreakables = parameters.getDouble("target_breakables", 1);
targetBreakableSize = parameters.getInt("breakable_size", 1);
bypassBackfire = parameters.getBoolean("bypass_backfire", false);
spread = parameters.getDouble("spread", 0);
maxMovementSpread = parameters.getDouble("spread_movement_max", 0);
movementSpread = parameters.getDouble("spread_movement", 0);
int hitLimit = parameters.getInt("hit_count", 1);
entityHitLimit = parameters.getInt("entity_hit_count", hitLimit);
blockHitLimit = parameters.getInt("block_hit_count", hitLimit);
reflectLimit = parameters.getInt("reflect_count", -1);
pitchMin = parameters.getInt("pitch_min", 90);
pitchMax = parameters.getInt("pitch_max", -90);
reflectReorient = parameters.getBoolean("reflect_reorient", false);
reflectResetDistanceTraveled = parameters.getBoolean("reflect_reset_distance_traveled", true);
reflectTargetCaster = parameters.getBoolean("reflect_target_caster", true);
reflectTrackEntity = parameters.getBoolean("reflect_track_target", false);
reflectTrackCursorRange = parameters.getDouble("reflect_track_range", 0D);
hitOnMiss = parameters.getBoolean("hit_on_miss", false);
returnOffset = ConfigurationUtils.getVector(parameters, "return_offset");
returnRelativeOffset = ConfigurationUtils.getVector(parameters, "return_relative_offset");
range = (int) (range * context.getMage().getRangeMultiplier());
// Some parameter tweaks to make sure things are sane
TargetType targetType = targeting.getTargetType();
if (targetType == TargetType.NONE) {
targeting.setTargetType(TargetType.OTHER);
}
// Flags to optimize FX calls
hasTickEffects = context.getEffects(tickEffectKey).size() > 0;
hasBlockMissEffects = context.getEffects("blockmiss").size() > 0;
hasStepEffects = context.getEffects("step").size() > 0;
hasPreHitEffects = context.getEffects("prehit").size() > 0;
ActionHandler handler = getHandler("tick");
hasTickActions = handler != null && handler.size() > 0;
planConfiguration = ConfigurationUtils.getNodeList(parameters, "plan");
}
use of com.elmakers.mine.bukkit.magic.SourceLocation in project MagicPlugin by elBukkit.
the class ThrowItemAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
double itemSpeed = parameters.getDouble("speed", 1);
itemSpeedMin = parameters.getDouble("speed_min", itemSpeed);
itemSpeedMax = parameters.getDouble("speed_max", itemSpeed);
ageItems = parameters.getInt("age_items", 5500);
unbreakable = parameters.getBoolean("unbreakable", false);
sourceLocation = new SourceLocation(parameters);
String itemName = parameters.getString("item");
if (itemName != null && !itemName.isEmpty()) {
item = context.getController().getItem(itemName);
}
}
use of com.elmakers.mine.bukkit.magic.SourceLocation in project MagicPlugin by elBukkit.
the class ProjectileAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
track = true;
super.prepare(context, parameters);
count = parameters.getInt("count", 1);
size = parameters.getInt("size", defaultSize);
damage = parameters.getDouble("damage", 0);
speed = (float) parameters.getDouble("speed", 0.6f);
spread = (float) parameters.getDouble("spread", 12);
useFire = parameters.getBoolean("fire", false);
tickIncrease = parameters.getInt("tick_increase", 1180);
projectileTypeName = parameters.getString("projectile", "TippedArrow");
breakBlocks = parameters.getBoolean("break_blocks", false);
startDistance = parameters.getInt("start", 0);
pickupStatus = parameters.getString("pickup");
sourceLocation = new SourceLocation(parameters);
}
use of com.elmakers.mine.bukkit.magic.SourceLocation in project MagicPlugin by elBukkit.
the class ThrowBlockAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
double itemSpeed = parameters.getDouble("speed", 0.6f);
speedMin = parameters.getDouble("speed_min", itemSpeed);
speedMax = parameters.getDouble("speed_max", itemSpeed);
int damage = parameters.getInt("damage", 0);
fallDamage = (float) parameters.getDouble("fall_damage", damage);
maxDamage = parameters.getInt("max_damage", damage);
consumeBlocks = parameters.getBoolean("consume", false);
hurts = parameters.getBoolean("hurts", true);
consumeVariants = parameters.getBoolean("consume_variants", true);
sourceLocation = new SourceLocation(parameters);
}
use of com.elmakers.mine.bukkit.magic.SourceLocation in project MagicPlugin by elBukkit.
the class EffectPlayer method load.
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.getClass());
}
} 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("entity_effect")) {
String effectName = configuration.getString("entity_effect");
try {
entityEffect = EntityEffect.valueOf(effectName.toUpperCase());
} catch (Exception ignored) {
}
if (entityEffect == null) {
warn("Unknown entity 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()));
}
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 = ParticleEffect.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);
}
}
setLocationType(configuration.getString("location", "origin"));
requireEntity = configuration.getBoolean("requires_entity", false);
requireTargetEntity = configuration.getBoolean("requires_entity_target", false);
sourceLocation = new SourceLocation(configuration);
targetLocation = new SourceLocation(configuration, "target_location", false);
sampleTarget = configuration.getString("sample", "").equalsIgnoreCase("target");
}
Aggregations