Skip to content

Commit

Permalink
Allow no fly in liquid
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Jul 13, 2024
1 parent f099d08 commit 23b64dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/main/java/xiamomc/morph/abilities/impl/FlyAbility.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public boolean applyToPlayer(Player player, DisguiseState state)
}

private final BindableList<String> noFlyWorlds = new BindableList<>();
private final Bindable<Boolean> noFlyInLuquid = new Bindable<>(true);

@Initializer
private void load(MorphConfigManager configManager)
Expand All @@ -74,6 +75,7 @@ private void load(MorphConfigManager configManager)
idleConsumption = n ? 0.1D : 0D, true);

configManager.bind(allowFlight, ConfigOption.ALLOW_FLIGHT);
configManager.bind(noFlyInLuquid, ConfigOption.FLYABILITY_NO_LIQUID);
}

private final Bindable<Boolean> allowFlight = new Bindable<>(true);
Expand All @@ -98,7 +100,8 @@ public boolean handle(Player player, DisguiseState state)
var allowFlightConditions = player.getFoodLevel() > option.getMinimumHunger()
&& !noFlyWorlds.contains(player.getWorld().getName())
&& !playerBlocked(player)
&& playerHasCommonFlyPerm(player);
&& playerHasCommonFlyPerm(player)
&& (!noFlyInLuquid.get() || (!player.isInLava() && !player.isInWaterOrBubbleColumn()));

var allowFlight = this.allowFlight.get() && (allowFlightConditions || player.hasPermission(CommonPermissions.ALWAYS_CAN_FLY));

Expand Down
1 change: 1 addition & 0 deletions src/main/java/xiamomc/morph/config/ConfigOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public enum ConfigOption

FLYABILITY_EXHAUSTION_BASE(flyAbilityNode().append("exhaustion_base"), 200d),
FLYABILITY_IDLE_CONSUME(flyAbilityNode().append("idle_consumption"), true),
FLYABILITY_NO_LIQUID(flyAbilityNode().append("no_fly_in_liquid"), true),

LANGUAGE_CODE(languageNode().append("code"), "en_us"),
SINGLE_LANGUAGE(languageNode().append("single_language"), true),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xiamomc/morph/config/MorphConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void reload()
});

//更新配置
int targetVersion = 30;
int targetVersion = 31;

var configVersion = getOrDefault(Integer.class, ConfigOption.VERSION);

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ root:
# Add a minimal consumption limit (20% of the configured consumption speed) as an "Idle consumption" for players per tick.
idle_consumption: true

# Should we disallow players flying in liquid?
no_fly_in_liquid: true

# Disable Fly Ability in the following worlds
#
# Example:
Expand Down Expand Up @@ -287,4 +290,4 @@ root:
- SelectedItem

# Do not touch unless you know what you're doing!
version: 30
version: 31

0 comments on commit 23b64dc

Please sign in to comment.