Search in sources :

Example 6 with Trigger

use of me.deecaad.weaponmechanics.weapon.trigger.Trigger in project MechanicsMain by WeaponMechanics.

the class ScopeHandler method validate.

@Override
public void validate(Configuration configuration, File file, ConfigurationSection configurationSection, String path) {
    Trigger trigger = configuration.getObject(path + ".Trigger", Trigger.class);
    if (trigger == null) {
        debug.log(LogLevel.ERROR, "Tried to use scope without defining trigger for it.", "Located at file " + file + " in " + path + ".Trigger in configurations.");
    }
    int zoomAmount = configuration.getInt(path + ".Zoom_Amount");
    if (zoomAmount < 1 || zoomAmount > 32) {
        debug.log(LogLevel.ERROR, "Tried to use scope without defining proper zoom amount for it, or it was missing.", "Zoom amount has to be between 1 and 32.", "Located at file " + file + " in " + path + ".Zoom_Amount in configurations.");
    }
    int maximumStacks = configuration.getInt(path + ".Zoom_Stacking.Maximum_Stacks");
    int increaseZoomPerStack = configuration.getInt(path + ".Zoom_Stacking.Increase_Zoom_Per_Stack");
    int finalValue = maximumStacks * increaseZoomPerStack + zoomAmount;
    if (finalValue > 32 || finalValue < 1) {
        debug.log(LogLevel.ERROR, "Final value of zoom stacking cannot go above 32 or below 1.", "Currently potential final value is " + finalValue + ", make sure its between 1 and 32.", "Located at file " + file + " in " + path + ".Zoom_Stacking in configurations.");
    }
    int shootDelayAfterScope = configuration.getInt(path + ".Shoot_Delay_After_Scope");
    if (shootDelayAfterScope != 0) {
        // Convert to millis
        configuration.set(path + ".Shoot_Delay_After_Scope", shootDelayAfterScope * 50);
    }
}
Also used : Trigger(me.deecaad.weaponmechanics.weapon.trigger.Trigger)

Aggregations

Trigger (me.deecaad.weaponmechanics.weapon.trigger.Trigger)6 Configuration (me.deecaad.core.file.Configuration)2 MCTiming (co.aikar.timings.lib.MCTiming)1 CastData (me.deecaad.weaponmechanics.mechanics.CastData)1 Mechanics (me.deecaad.weaponmechanics.mechanics.Mechanics)1 WeaponInfoDisplay (me.deecaad.weaponmechanics.weapon.info.WeaponInfoDisplay)1 AmmoTypes (me.deecaad.weaponmechanics.weapon.reload.ammo.AmmoTypes)1 PlayerWrapper (me.deecaad.weaponmechanics.wrappers.PlayerWrapper)1 ZoomData (me.deecaad.weaponmechanics.wrappers.ZoomData)1