mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
Config option to toggle disabling flight / speed on world change (#2546)
Closes #2141. This PR adds the option to toggle whether or not EssentialsX should handle disabling player flight / speed when they switch to a new world, in case server administrators are handling that via a third party plugin.
This commit is contained in:
parent
40fb496052
commit
2bd6ebd2b1
@ -581,27 +581,31 @@ public class EssentialsPlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.getBase().getGameMode() != GameMode.CREATIVE
|
||||
// COMPAT: String compare for 1.7.10
|
||||
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
||||
&& !user.isAuthorized("essentials.fly")) {
|
||||
user.getBase().setFallDistance(0f);
|
||||
user.getBase().setAllowFlight(false);
|
||||
}
|
||||
if (!user.isAuthorized("essentials.speed")) {
|
||||
user.getBase().setFlySpeed(0.1f);
|
||||
user.getBase().setWalkSpeed(0.2f);
|
||||
} else {
|
||||
if (user.getBase().getFlySpeed() > ess.getSettings().getMaxFlySpeed() && !user.isAuthorized("essentials.speed.bypass")) {
|
||||
user.getBase().setFlySpeed((float) ess.getSettings().getMaxFlySpeed());
|
||||
} else {
|
||||
user.getBase().setFlySpeed(user.getBase().getFlySpeed() * 0.99999f);
|
||||
}
|
||||
|
||||
if (user.getBase().getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass")) {
|
||||
user.getBase().setWalkSpeed((float) ess.getSettings().getMaxWalkSpeed());
|
||||
if (ess.getSettings().isWorldChangeFlyResetEnabled()) {
|
||||
if (user.getBase().getGameMode() != GameMode.CREATIVE
|
||||
// COMPAT: String compare for 1.7.10
|
||||
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
||||
&& !user.isAuthorized("essentials.fly")) {
|
||||
user.getBase().setFallDistance(0f);
|
||||
user.getBase().setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().isWorldChangeSpeedResetEnabled()) {
|
||||
if (!user.isAuthorized("essentials.speed")) {
|
||||
user.getBase().setFlySpeed(0.1f);
|
||||
user.getBase().setWalkSpeed(0.2f);
|
||||
} else {
|
||||
user.getBase().setWalkSpeed(user.getBase().getWalkSpeed() * 0.99999f);
|
||||
if (user.getBase().getFlySpeed() > ess.getSettings().getMaxFlySpeed() && !user.isAuthorized("essentials.speed.bypass")) {
|
||||
user.getBase().setFlySpeed((float) ess.getSettings().getMaxFlySpeed());
|
||||
} else {
|
||||
user.getBase().setFlySpeed(user.getBase().getFlySpeed() * 0.99999f);
|
||||
}
|
||||
|
||||
if (user.getBase().getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass")) {
|
||||
user.getBase().setWalkSpeed((float) ess.getSettings().getMaxWalkSpeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +294,10 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isCommandCooldownsEnabled();
|
||||
|
||||
boolean isWorldChangeFlyResetEnabled();
|
||||
|
||||
boolean isWorldChangeSpeedResetEnabled();
|
||||
|
||||
long getCommandCooldownMs(String label);
|
||||
|
||||
Entry<Pattern, Long> getCommandCooldownEntry(String label);
|
||||
|
@ -1498,6 +1498,16 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("allow-direct-hat", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldChangeFlyResetEnabled() {
|
||||
return config.getBoolean("world-change-fly-reset", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldChangeSpeedResetEnabled() {
|
||||
return config.getBoolean("world-change-speed-reset", true);
|
||||
}
|
||||
|
||||
private List<String> defaultEnabledConfirmCommands;
|
||||
|
||||
private List<String> _getDefaultEnabledConfirmCommands() {
|
||||
|
@ -196,6 +196,18 @@ socialspy-commands:
|
||||
# If so, they will be differentiated from those sent by normal players.
|
||||
socialspy-listen-muted-players: true
|
||||
|
||||
# The following settings listen for when a player changes worlds.
|
||||
# If you use another plugin to control speed and flight, you should change these to false.
|
||||
|
||||
# When a player changes world, should EssentialsX reset their flight?
|
||||
# This will disable flight if the player does not have essentials.fly.
|
||||
world-change-fly-reset: true
|
||||
|
||||
# When a player changes world, should we reset their speed according to their permissions?
|
||||
# This resets the player's speed to the default if they don't have essentials.speed.
|
||||
# If the player doesn't have essentials.speed.bypass, this resets their speed to the maximum specified above.
|
||||
world-change-speed-reset: true
|
||||
|
||||
# Mute Commands
|
||||
# These commands will be disabled when a player is muted.
|
||||
# Use '*' to disable every command.
|
||||
|
Loading…
Reference in New Issue
Block a user