Last active
May 7, 2017 10:48
-
-
Save raclettes/703091f2710006a6bbb10b43a03bfb5e to your computer and use it in GitHub Desktop.
An example of Spade programming language for Bukkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when :playerJoin do |activity,player| | |
# Unlike Ruby, the `?` turns any datatype to a bool, depending on whether it has content | |
# False -> | |
# # 0, "", false, 0.0, [], {}, nil, undefined | |
# True -> | |
# # Everything else. | |
if player.meta.banned? == true | |
player.kick player.meta.banned | |
activity.cancel | |
else | |
activity.done | |
end | |
end | |
when :chat do |activity,player,message| | |
if player.name == "*" | |
broadcast "[*] #{message}" | |
activity.done | |
elsif player.permission.op == true | |
broadcast "[#{player.name}] #{message}" | |
activity.done | |
else | |
if message.filter.rude? > 0 | |
tell p "Your message contains rude words." | |
activity.cancel | |
else | |
broadcast "[#{player.name}] #{message}" | |
activity.done | |
end | |
end | |
end | |
when :command do |activity,player,command| | |
if command.name == "hello" | |
broadcast "Hello, #{player.name}." | |
elsif command.name == "zap" | |
if player.permission.op == true | |
if command.args < 1 | |
player.tell "Not enough arguments!" | |
help "zap" | |
else | |
target = Player.new(args[0]) | |
if target.online? == false | |
player.tell "#{args[0]} is either offline or has never played on this server before." | |
else | |
world.spawn :lightning target.x target.y target.z | |
target.tell "The gods are angry with you." | |
end | |
end | |
end | |
end | |
end | |
when :start do | |
puts "Activated example plugin." | |
end | |
when :ended do | |
puts "Deactivated example plugin." | |
end | |
when :restart do | |
puts "Reactivated example plugin." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment