Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[LATEST] Icarus Emulator [Java, Netty, MySQL, Plugins, Camera]

Status
Not open for further replies.
Developer
Developer
Joined
Dec 11, 2010
Messages
2,955
Reaction score
2,683
Icarus

Icarus is a server which is emulating the most recent version of Habbo. It's programmed in Java 1.8. The server aims at minimising memory leaks, easy to maintain and expand upon and to maximise the server uptime/stability.

All files which access and query the database are called data access objects (DAO) and they have been completely separated from the rest of the server, and the only calls to the database are forced through the data access objects.

This server is created by me and built from the ground up, it is not based on any previous servers

Example of the database access separated from the main project.

Code:
package org.alexdev.icarus.dao.mysql.item;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import org.alexdev.icarus.dao.mysql.Dao;
import org.alexdev.icarus.dao.mysql.Storage;

public class TeleporterDao {

    /**
     * Gets the pair id.
     *
     *           [USER=2000183830]para[/USER]m id the id
     *           [USER=850422]return[/USER] the pair id
     */
    public static int getPairId(int id) {
        
        Connection sqlConnection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            sqlConnection = Dao.getStorage().getConnection();

            preparedStatement = Dao.getStorage().prepare("SELECT * FROM item_teleporter_links WHERE item_one = ? OR item_two = ? LIMIT 1;", sqlConnection);
            preparedStatement.setInt(1, id);
            preparedStatement.setInt(2, id);
            resultSet = preparedStatement.executeQuery();

            if (resultSet.next()) {

                if (resultSet.getInt("item_two") != id) {
                    return resultSet.getInt("item_two");
                } else {
                    return resultSet.getInt("item_one");
                }
                
            }
        } catch (Exception e) {
            Storage.logError(e);
        } finally {
            Storage.closeSilently(resultSet);
            Storage.closeSilently(preparedStatement);
            Storage.closeSilently(sqlConnection);
        }

        return 0;
    }

    /**
     * Save pair.
     *
     *           [USER=2000183830]para[/USER]m item1 the item 1
     *           [USER=2000183830]para[/USER]m item2 the item 2
     */
    public static void savePair(int item1, int item2) {
        
        Connection sqlConnection = null;
        PreparedStatement preparedStatement = null;

        try {
            sqlConnection = Dao.getStorage().getConnection();

            preparedStatement = Dao.getStorage().prepare("INSERT into item_teleporter_links (item_one, item_two) VALUES(?, ?);", sqlConnection);
            preparedStatement.setInt(1, item1);
            preparedStatement.setInt(2, item2);
            preparedStatement.execute();
            
        } catch (Exception e) {
            Storage.logError(e);
        } finally {
            Storage.closeSilently(preparedStatement);
            Storage.closeSilently(sqlConnection);
        }
    }
}

Open-source

Yes, this project is open source, the stable source can code can be located at:



(All pull requests will be rejected while this project is in alpha and beta stage).

Features

The current client version it's using is called PRODUCTION-201710172204-432325793 this includes the new loader and the new navigator which gives more customisation on how you want your navigator displayed.

  • User
    • Login with SSO (single sign on) ticket
    • Show targeted offers (special deals)
    • Show Habbo Club susbcription (can expire)
  • Navigator
    • View public spaces
    • View most popular rooms
    • View own rooms
    • View promoted events
  • Messenger
    • Search for users
    • Send a friend request
    • Accept friend request
    • Reject friend request
    • Send friend a message
    • Delete friend
    • Invite friend
    • Follow friend
  • Rooms
    • Create own room
    • Edit room details
    • Room entry
    • Delete room
    • Walking/pathfinding around items and users (if walking through people is ticked)
    • Give rights
    • Take away rights
    • Remove all rights
      • Edit floor plan
      • Save floor plan
  • Items
    • Take photo
    • Purchase photo
    • Place items
    • Rotate and move items
    • Pickup items
    • Sit on items
    • Interact with items
    [*]Camera
    • Take photo
    • Purchase photo
    • Take photo for room thumbail
  • Inventory
    • Load floor items
    • Load wall items
    • Load pets
    • Update inventory when a new item is purchased/picked up
    • Show new item in inventory once item is purchased/picked up
    • Update inventory when a pet is purchased/picked up
    • Show new item when a pet is purchased/picked up
  • Catalogue
    • Catalogue tabs
    • Catalogue pages, visible depending on rank
    • Catalogue item discount
    • Purchase items
    • Buy Habbo Club subscription
  • Promotions
    • Buy promotion
    • Edit promotion
    • Show promotion in the special promotions part of the navigator
  • Pets
    • Purchase pet
    • Load pet races
    • Verify pet name
    • Place pet
    • Pick up pet
  • Groups
    • Purchase grpup
    • Set group homeroom
    • Delete group
    • Group furni
    • Edit group settings
    • Manage group users
    • Group decorative rights

Completed Interaction Types

  • Default
  • Vending
  • Gate
  • Rollers
  • Teleporters
  • Moodlights
  • Bed
  • Chair
  • One way gates
  • Mannequins
  • ads_background
  • Background Toner

Libraries

- Netty 4.1.16
- HikariCP 2.7.1
- Gson 2.8.0
- ini4j 0.5.4
- Luaj 3.0-beta2
- MySQL Connector Java 6.0.6
- slf4j 1.7.25
- log4j 1.2.17

The source code is built using the Gradle (which is like Maven, except doesn't require XML configuration). So once imported, all libraries will be downloaded automatically without the need to maintain third-party Jar files.

Plugin System

Icarus has a plugin system, completely in Lua. Using Luaj it's possible to extend the functionality of the server without writing any Java or recompiling the server.

The following events coded right now are listed below, and the name next to them indicates the event function name will be called.

Player Events
  • PLAYER_LOGIN_EVENT
  • PLAYER_DISCONNECT_EVENT

Messenger Events
  • MESSENGER_TALK_EVENT

Room Events
  • ROOM_REQUEST_ENTER_EVENT
  • ROOM_FIRST_ENTRY_EVENT
  • ROOM_ENTER_EVENT
  • ROOM_LEAVE_EVENT
  • ROOM_PLAYER_CHAT_EVENT
  • ROOM_PLAYER_SHOUT_EVENT
  • ROOM_PLAYER_WHISPER_EVENT
  • ROOM_WALK_REQUEST_EVENT
  • ROOM_STOP_WALKING_EVENT

Item Events
  • PLACE_FLOOR_ITEM_EVENT
  • PLACE_WALL_ITEM_EVENT
  • FLOOR_ITEM_INTERACT_EVENT
  • WALL_ITEM_INTERACT_EVENT

More will be added as more development time passes, and each event will be documentated on what event does what, and what parameters each event takes.

For example, this will create 200 bots that will walk around when a user enters a room.

Code:
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

Screenshots

Server

dIXdHnQ - [LATEST] Icarus Emulator [Java, Netty, MySQL, Plugins, Camera] - RaGEZONE Forums


jD0xrCv - [LATEST] Icarus Emulator [Java, Netty, MySQL, Plugins, Camera] - RaGEZONE Forums


H5aXlt - [LATEST] Icarus Emulator [Java, Netty, MySQL, Plugins, Camera] - RaGEZONE Forums


OfhSkGu - [LATEST] Icarus Emulator [Java, Netty, MySQL, Plugins, Camera] - RaGEZONE Forums


Credits

- Leon, giving me some help for fixing structures, etc.
- Glaceon, guidance on fixing client crash when item quantity is enabled on the catalogue.
 

Attachments

You must be registered for see attachments list
Last edited:
Master Summoner
Joined
Aug 5, 2014
Messages
597
Reaction score
199
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Approved. Good luck with your development.
 

Jax

C# Programmer
Joined
Dec 11, 2009
Messages
881
Reaction score
431
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Good luck my friend - this will be your magnum opus :D:
 
Banned
Banned
Joined
May 6, 2009
Messages
531
Reaction score
165
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Good Luck man! Good to see you back :D
 
☮TAKU????
Member
Joined
Nov 16, 2009
Messages
866
Reaction score
580
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Interesting.

But didn't you receive a C&D?
 
Elite Diviner
Joined
Nov 28, 2014
Messages
450
Reaction score
113
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Good luck with this! :):
 
Joined
Aug 10, 2011
Messages
7,401
Reaction score
3,299
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Teach us master! Where is these memory leaks?

Not spoonfeeding. I've done (most) things all by myself with little suggestions. He'll figure it out if he ever gets to the point where he runs out of memory which, if he continues to work like this, is pretty soon.
 
Joined
Aug 24, 2012
Messages
603
Reaction score
300
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Not spoonfeeding. I've done (most) things all by myself with little suggestions. He'll figure it out if he ever gets to the point where he runs out of memory which, if he continues to work like this, is pretty soon.
Not even close to spoonfeeding, but suit yourself :):
 
☮TAKU????
Member
Joined
Nov 16, 2009
Messages
866
Reaction score
580
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Not spoonfeeding. I've done (most) things all by myself with little suggestions. He'll figure it out if he ever gets to the point where he runs out of memory which, if he continues to work like this, is pretty soon.

You can not argue with no arguments.

Says itself.
 

Jax

C# Programmer
Joined
Dec 11, 2009
Messages
881
Reaction score
431
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

First line says minimizing memory leaks, first example given already has 3 memory leaks.

I don't have much hope for this.

PS: John broke his neck.

Is it due to the fact that he isn't disposing the memory after use?
 
Joined
Aug 10, 2011
Messages
7,401
Reaction score
3,299
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

He's releasing objects after use, the GC handles disposal afterwards. This code is fine.

Except there are still resources allocated in the libraries being used in the example which have to be manually free'd before the GC handles them.

I'm not telling shenanigans, he's gonna figure it out eventually.
 

Jax

C# Programmer
Joined
Dec 11, 2009
Messages
881
Reaction score
431
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Except there are still resources allocated in the libraries being used in the example which have to be manually free'd before the GC handles them.

I'm not telling shenanigans, he's gonna figure it out eventually.

Ah yeah, the PreparedStatement instances need to be closed (as far as I can see?).
 
Developer
Developer
Joined
Dec 11, 2010
Messages
2,955
Reaction score
2,683
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

Except there are still resources allocated in the libraries being used in the example which have to be manually free'd before the GC handles them.

I'm not telling shenanigans, he's gonna figure it out eventually.

I've done my research.

Code:
	public static void releaseObject(ResultSet row) {
		
		try {
			row.close();
		} catch (Exception e) {
			
		}
		
		try {
			row.getStatement().close();
		} catch (Exception e) {
			
		}
		
		try {
			row.getStatement().getConnection().close();
		} catch (Exception e) {
			
		}
	}
 

Jax

C# Programmer
Joined
Dec 11, 2009
Messages
881
Reaction score
431
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

I've done my research.

Code:
	public static void releaseObject(ResultSet row) {
		
		try {
			row.close();
		} catch (Exception e) {
			
		}
		
		try {
			row.getStatement().close();
		} catch (Exception e) {
			
		}
		
		try {
			row.getStatement().getConnection().close();
		} catch (Exception e) {
			
		}
	}

Not surprised at all. I knew it was hidden in that function. :D:
 
Joined
Aug 10, 2011
Messages
7,401
Reaction score
3,299
re: Icarus Server (Production) - [Python, Multi-DB/MySQL]

I've done my research.

Code:
	public static void releaseObject(ResultSet row) {
		
		try {
			row.close();
		} catch (Exception e) {
			
		}
		
		try {
			row.getStatement().close();
		} catch (Exception e) {
			
		}
		
		try {
			row.getStatement().getConnection().close();
		} catch (Exception e) {
			
		}
	}

Good, now you abuse the fact you cannot re-use the prepared statement which is exactly what it was ment for.

And what if an exception occurs, your connection would still stay open ;)

Cos if I do a select:


Code:
PreparedStatement stmt = whatever().prepare("SELECT * FROM users WHERE id = ?");
stmt.setInt(1, userIdOne);
ResultSet set = stmt.executeQuery();

if(set.next())
{
do something(set);
releaseObject(set);
}

set.setInt(1, userIdTwo);
stmt.executeQuery();

That won't work as you've already closed the connection in releaseObject.
 
Status
Not open for further replies.
Back
Top