Lukkit
Search…
Toggle Fly
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

main.lua
plugin.yml
1
-- Imports
2
color = newInstance("#.wrappers.ChatColorWrapper", {plugin.getPlugin()})
3
4
-- A simple fly command
5
local flyCommand = plugin.addCommand({name="fly", permission="lukkit.command.fly"}, function(cmd)
6
local sender = cmd.getSender()
7
-- Make sure it's a player sending the command
8
if not cmd.isPlayerSender() then
9
sender:sendMessage(color.DARK_RED .. "Only players can fly, silly!")
10
return
11
end
12
13
-- If the player is flying the make them fly, otherwise make them fall
14
if sender:isFlying() then
15
sender:setFlying(false)
16
sender:setAllowFlight(false)
17
sender:sendMessage(color.RED .. "Fly off")
18
else
19
-- This allows the player to fly
20
sender:setAllowFlight(true)
21
sender:setFlying(true)
22
-- The player won't fly if it is on the ground, so we need to move them up a little
23
sender:teleport(sender:getLocation():add(0, 0.000001, 0))
24
sender:sendMessage(color.GREEN .. "Fly on")
25
end
26
end)
Copied!
1
name: Fly-Plugin
2
author: AL_1
3
version: "1.3"
4
description: A plugin to let players fly!
5
main: main.lua
Copied!
Last modified 3yr ago
Copy link
Contents
Code