This plugin allows users with the permission node lukkit.command.fly to fly when they run the /fly command. The plugin starts off by importing the chat color wrapper so that it can use colors in messages. Then it creates the fly command. In the command, it first checks if the sender is a player because only players are able to fly, then checks if they are already flying. If so then fly is turned off, otherwise, it is turned on. More info is explained in the code.
Code
-- Importscolor =newInstance("#.wrappers.ChatColorWrapper", {plugin.getPlugin()})-- A simple fly commandlocal flyCommand = plugin.addCommand({name="fly", permission="lukkit.command.fly"}, function(cmd)local sender = cmd.getSender()-- Make sure it's a player sending the commandifnot cmd.isPlayerSender() then sender:sendMessage(color.DARK_RED .."Only players can fly, silly!")returnend-- If the player is flying the make them fly, otherwise make them fallif sender:isFlying() then sender:setFlying(false) sender:setAllowFlight(false) sender:sendMessage(color.RED .."Fly off")else-- This allows the player to fly sender:setAllowFlight(true) sender:setFlying(true)-- The player won't fly if it is on the ground, so we need to move them up a little sender:teleport(sender:getLocation():add(0, 0.000001, 0)) sender:sendMessage(color.GREEN .."Fly on")endend)
name:Fly-Pluginauthor:AL_1version:"1.3"description:A plugin to let players fly!main:main.lua