mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-10 18:38:18 +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,6 +581,8 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) {
|
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) {
|
||||||
final User user = ess.getUser(event.getPlayer());
|
final User user = ess.getUser(event.getPlayer());
|
||||||
|
|
||||||
|
if (ess.getSettings().isWorldChangeFlyResetEnabled()) {
|
||||||
if (user.getBase().getGameMode() != GameMode.CREATIVE
|
if (user.getBase().getGameMode() != GameMode.CREATIVE
|
||||||
// COMPAT: String compare for 1.7.10
|
// COMPAT: String compare for 1.7.10
|
||||||
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
||||||
@ -588,6 +590,9 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
user.getBase().setFallDistance(0f);
|
user.getBase().setFallDistance(0f);
|
||||||
user.getBase().setAllowFlight(false);
|
user.getBase().setAllowFlight(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ess.getSettings().isWorldChangeSpeedResetEnabled()) {
|
||||||
if (!user.isAuthorized("essentials.speed")) {
|
if (!user.isAuthorized("essentials.speed")) {
|
||||||
user.getBase().setFlySpeed(0.1f);
|
user.getBase().setFlySpeed(0.1f);
|
||||||
user.getBase().setWalkSpeed(0.2f);
|
user.getBase().setWalkSpeed(0.2f);
|
||||||
@ -600,8 +605,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||||||
|
|
||||||
if (user.getBase().getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass")) {
|
if (user.getBase().getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass")) {
|
||||||
user.getBase().setWalkSpeed((float) ess.getSettings().getMaxWalkSpeed());
|
user.getBase().setWalkSpeed((float) ess.getSettings().getMaxWalkSpeed());
|
||||||
} else {
|
}
|
||||||
user.getBase().setWalkSpeed(user.getBase().getWalkSpeed() * 0.99999f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,6 +294,10 @@ public interface ISettings extends IConf {
|
|||||||
|
|
||||||
boolean isCommandCooldownsEnabled();
|
boolean isCommandCooldownsEnabled();
|
||||||
|
|
||||||
|
boolean isWorldChangeFlyResetEnabled();
|
||||||
|
|
||||||
|
boolean isWorldChangeSpeedResetEnabled();
|
||||||
|
|
||||||
long getCommandCooldownMs(String label);
|
long getCommandCooldownMs(String label);
|
||||||
|
|
||||||
Entry<Pattern, Long> getCommandCooldownEntry(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);
|
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> defaultEnabledConfirmCommands;
|
||||||
|
|
||||||
private List<String> _getDefaultEnabledConfirmCommands() {
|
private List<String> _getDefaultEnabledConfirmCommands() {
|
||||||
|
@ -196,6 +196,18 @@ socialspy-commands:
|
|||||||
# If so, they will be differentiated from those sent by normal players.
|
# If so, they will be differentiated from those sent by normal players.
|
||||||
socialspy-listen-muted-players: true
|
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
|
# Mute Commands
|
||||||
# These commands will be disabled when a player is muted.
|
# These commands will be disabled when a player is muted.
|
||||||
# Use '*' to disable every command.
|
# Use '*' to disable every command.
|
||||||
|
Loading…
Reference in New Issue
Block a user