Permalink
Browse files

Implemented support for flight checks on world change

The permission "commandbook.flight.<world name>" is needed to keep the current flight mode when changing worlds if this setting is enabled
  • Loading branch information...
DarkArc committed Jul 17, 2014
1 parent 49544b6 commit 936973fc4898d7c4f434c19e5e8c0df4a4ceff84
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/main/java/com/sk89q/commandbook/FlightComponent.java
@@ -19,6 +19,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@@ -37,6 +38,7 @@ public void enable() {
private static class LocalConfiguration extends ConfigurationBase {
@Setting("auto-enable") public boolean autoEnable = false;
+ @Setting("check-world-change") public boolean checkWorldChange = true;
}
public static class FlightSession extends PersistentSession {
@@ -208,4 +210,15 @@ public void onPlayerChangeGameMode(PlayerGameModeChangeEvent event) {
player.setAllowFlight(session.canFly);
}
}
+
+ @EventHandler
+ public void onPlayerworldChange(PlayerChangedWorldEvent event) {
+ Player player = event.getPlayer();
+ FlightSession session = sessions.getSession(FlightSession.class, player);
+ if (config.checkWorldChange
+ && player.getGameMode() != GameMode.CREATIVE
+ && !CommandBook.inst().hasPermission(player, "commandbook.flight." + player.getWorld().getName())) {
+ player.setAllowFlight(session.canFly = false);
+ }
+ }
}

0 comments on commit 936973f

Please sign in to comment.