[BLEEDING] Make improbable check configurable for inventory.instantbow.

feedonly: allow to only feed, instead of check
weight: allow to alter the weight and disable altering improbable (0.0).
This commit is contained in:
asofold 2017-04-18 19:21:22 +02:00
parent ca2d2398e4
commit 563ce080c6
4 changed files with 19 additions and 3 deletions

View File

@ -111,6 +111,8 @@ public class InventoryConfig extends ACheckConfig {
public final boolean instantBowCheck;
public final boolean instantBowStrict;
public final long instantBowDelay;
public final boolean instantBowImprobableFeedOnly;
public final float instantBowImprobableWeight;
public final ActionList instantBowActions;
public final boolean instantEatCheck;
@ -157,6 +159,8 @@ public class InventoryConfig extends ACheckConfig {
instantBowCheck = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_CHECK);
instantBowStrict = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_STRICT);
instantBowDelay = data.getInt(ConfPaths.INVENTORY_INSTANTBOW_DELAY);
instantBowImprobableFeedOnly = data.getBoolean(ConfPaths.INVENTORY_INSTANTBOW_IMPROBABLE_FEEDONLY);
instantBowImprobableWeight = (float) data.getDouble(ConfPaths.INVENTORY_INSTANTBOW_IMPROBABLE_WEIGHT);
instantBowActions = data.getOptimizedActionList(ConfPaths.INVENTORY_INSTANTBOW_ACTIONS, Permissions.INVENTORY_INSTANTBOW);
instantEatCheck = data.getBoolean(ConfPaths.INVENTORY_INSTANTEAT_CHECK);

View File

@ -114,15 +114,21 @@ public class InventoryListener extends CheckListener implements JoinLeaveListen
// No else if with this, could be cancelled due to other checks feeding, does not have actions.
event.setCancelled(true);
}
final InventoryConfig cc = InventoryConfig.getConfig(player);
// Still check instantBow, whatever yawrate says.
if (instantBow.check(player, event.getForce(), now)) {
// The check requested the event to be cancelled.
event.setCancelled(true);
}
else if (Improbable.check(player, 0.6f, now, "inventory.instantbow")) {
else if (cc.instantBowImprobableWeight > 0.0f) {
if (cc.instantBowImprobableFeedOnly) {
Improbable.feed(player, cc.instantBowImprobableWeight, now);
}
else if (Improbable.check(player, cc.instantBowImprobableWeight, now, "inventory.instantbow")) {
// Combined fighting speed (Else if: Matter of taste, preventing extreme cascading and actions spam).
event.setCancelled(true);
}
}
useLoc.setWorld(null);
}
}

View File

@ -542,6 +542,10 @@ public abstract class ConfPaths {
public static final String INVENTORY_INSTANTBOW_CHECK = INVENTORY_INSTANTBOW + "active";
public static final String INVENTORY_INSTANTBOW_STRICT = INVENTORY_INSTANTBOW + "strict";
public static final String INVENTORY_INSTANTBOW_DELAY = INVENTORY_INSTANTBOW + "delay";
private static final String INVENTORY_INSTANTBOW_IMPROBABLE = INVENTORY_INSTANTBOW + "improbable.";
public static final String INVENTORY_INSTANTBOW_IMPROBABLE_FEEDONLY = INVENTORY_INSTANTBOW_IMPROBABLE + "feedonly";
public static final String INVENTORY_INSTANTBOW_IMPROBABLE_WEIGHT = INVENTORY_INSTANTBOW_IMPROBABLE + "weight";
public static final String INVENTORY_INSTANTBOW_ACTIONS = INVENTORY_INSTANTBOW + "actions";
private static final String INVENTORY_INSTANTEAT = INVENTORY + "instanteat.";

View File

@ -339,6 +339,8 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.INVENTORY_INSTANTBOW_CHECK, true, 785);
set(ConfPaths.INVENTORY_INSTANTBOW_STRICT, true, 785);
set(ConfPaths.INVENTORY_INSTANTBOW_DELAY, 130, 785);
set(ConfPaths.INVENTORY_INSTANTBOW_IMPROBABLE_FEEDONLY, false, 1085);
set(ConfPaths.INVENTORY_INSTANTBOW_IMPROBABLE_WEIGHT, 0.6, 1085);
set(ConfPaths.INVENTORY_INSTANTBOW_ACTIONS, "cancel vl>15 log:instantbow:2:5:if cancel", 785);
set(ConfPaths.INVENTORY_INSTANTEAT_CHECK, true, 785);