Changelog
Fixes
- Fixed bug where user could walk about of teleporter while it was teleporting.
- Fixed bug where it wasn't possible to teleport into a locked, or password protected room if the owner of that room was offline (weird bug I know).
- Fixed bug where if multiple purchases of HC was performed, they wouldn't stack.
- Fixed room deletion where the user who deletes their own room now has all their items saved back into their inventory.
- Fixed bug where if an item was picked up or removed underneath the player which raises the players height, the player would be considered floating. Now the player's height adjusts to the next item down when the item has been removed/picked up.
Additions
- Added permission system, along with the ability for permissions to be inherited.
- Added feature to save custom room floor plans.
- Added Lua integration which is now a plugin management system with event handling
Lua Plugin System
So with the Lua plugin system it's possible to change the functionality of the server without requiring any extensive Java knowledge, or without the need to download a Java IDE for the ability to create the plugin .jar files.
What is required is a Notepad program, which is what is used to write these plugins, and the methods/class names within Icarus too.
I've written an example called "BotPlugin" which will load 200 bots into a single room. Here is how it's handled, first with bot_plugin.lua
These method names have been inspired by Bukkit plugins for Minecraft I used to write. When the server first starts up, the "onEnable" is called if the plugin wishes to perform anything while the server loads.
And then it loads all the .lua files that have their paths stored in an array.
Code:
plugin_details = {
name = "BotPlugin",
author = "Quackster",
path = "plugins/BotPlugin"
}
event_register = {
"ROOM_ENTER_EVENT"
}
event_files = {
"room_events.lua"
}
--[[
Called when the plugin first starts up, so the plugin can load data if needed
so when the event is called the plugin is ready
param: plugin instance
return: none
--]]
function onEnable(plugin)
-- If you want, use log.println() to show everyone this method being called
log:println(string.format('[Lua] Initialising plugin %s by %s', plugin:getName(), plugin:getAuthor()))
end
-- Load all event .lua files
-- If you delete this code, ABSOLUTELY NO events will work
for i, file in ipairs(event_files) do
dofile (string.format('%s/events/%s', plugin_details.path, file))
end
Here is the room event handler (room_events.lua):
Code:
--[[
Room enter event called when the user has entered a room
Called when a user has truly entered the room
param:
Player - person who entered room
Room - the room they entered
return: Boolean - event cancelled state
--]]
function onRoomEnterEvent(player, room)
log:println("Room enter event called")
for i = 0, 200 - 1 do
local bot = createBot(room)
randomWalkEntity(bot)
end
return false
end
function createBot(room)
local bot = luajava.newInstance("org.alexdev.icarus.game.bot.Bot");
bot:getDetails():setName("RandomAlexBot")
bot:getDetails():setMotto("")
room:addEntity(bot)
return bot
end
function randomWalkEntity(entity)
local randomX = math.random(0, 25)
local randomY = math.random(0, 25)
entity:getRoomUser():walkTo(randomX, randomY)
plugin:runTaskLater(1, randomWalkEntity, { entity })
end
This will send a repeat call to randomWalkEntity(entity) every 1 second using the command I wrote called plugin:runTaskLater which will call a Lua function in a specified amount of seconds, along with using the function name and the array of parameters supplied.
I will be writing documentation on the plugin system in the future, for now I have created these events. Documentation is required for these events to know what parameters all of them require.
Player events
- PLAYER_LOGIN_EVENT("onPlayerLoginEvent")
- PLAYER_DISCONNECT_EVENT("onPlayerDisconnectEvent")
Console messenger events
- MESSENGER_TALK_EVENT("onMessengerTalkEvent")
Room events
- ROOM_REQUEST_ENTER_EVENT("onRoomRequestEvent")
- ROOM_ENTER_EVENT("onRoomEnterEvent")
- ROOM_LEAVE_EVENT("onRoomLeaveEvent")
- ROOM_PLAYER_CHAT_EVENT("onPlayerChatEvent")
- ROOM_PLAYER_SHOUT_EVENT("onPlayerShoutEvent")
- ROOM_WALK_REQUEST_EVENT("onPlayerWalkRequestEvent")
- ROOM_STOP_WALKING_EVENT("onPlayerStopWalkingEvent")
Item events
- PLACE_FLOOR_ITEM_EVENT("onPlaceFloorItemEvent")
- PLACE_WALL_ITEM_EVENT("onPlaceFloorItemEvent")
- FLOOR_ITEM_INTERACT_EVENT("onInteractFloorItemEvent")
- WALL_ITEM_INTERACT_EVENT("onInteractWallItemEvent")