Permalink
Browse files

Added ability to fly without a vehicle!

  • Loading branch information...
1 parent 75f9cbb commit 923b5e0678f5c3675192ebc7bcd988eef41b7376 @brad811 committed Apr 16, 2011
@@ -37,6 +37,7 @@ public void onEnable()
PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.VEHICLE_DAMAGE, vehicleListener, Priority.Normal, this);
+ pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
setupPermissions();
@@ -1,7 +1,11 @@
package com.bradsproject.BradleyJewell.bFlight;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerLoginEvent;
+import org.bukkit.util.Vector;
/**
* Handle events for all Player related events
@@ -26,4 +30,21 @@ public void onPlayerLogin(PlayerLoginEvent event)
plugin.active.put(event.getPlayer(), true);
}
}
+
+ @Override
+ public void onPlayerInteract(PlayerInteractEvent event)
+ {
+ Player player = event.getPlayer();
+ if(bFlight.Permissions == null
+ || bFlight.Permissions.has(event.getPlayer(), "bflight.bfly"))
+ {
+ if(plugin.isFlying(player) && player.getItemInHand().getType() == Material.FEATHER)
+ {
+ Vector dir = player.getLocation().getDirection();
+ Vector vec = new Vector(dir.getX()*0.8, 0.8, dir.getZ()*0.8);
+ player.setVelocity(vec);
+ player.setFallDistance(-100);
+ }
+ }
+ }
}

0 comments on commit 923b5e0

Please sign in to comment.