Java - v9 - HSR - FuseServer

Status
Not open for further replies.

Noelle

Someone, somewhere
Nov 9, 2016
4
5
What is FuseServer?
FuseServer is a server written from scratch in Java, written to support the FUSE technology (developed by Sampo Karjalainen and Aapo Kyrölä). The server supports v9 and v9 only. Versions above it will PROBABLY not be supported. The goal of this project is to write a complete v9, including camera, battleball and something secret I have in mind.

Why Java?
Because Java is crossplatform, and since making camera in Java is easier than in C#.

Based on?
Completely written from scratch.

Code snippets:
PHP:
public class UPDATE  implements IMessageHandler {

    @Override
    public void handle(GameSession session) {
        //@l@D@Y8420118001270012900121001@F@Cbla
        TMap<Integer, String> userPacket = session.getRequest().decodeUserPacket();
       
        String newFigure = userPacket.get(4);
        String newGender = userPacket.get(5);
        String newMotto = userPacket.get(6);
       
        if (newFigure == null && newGender == null && newMotto == null) // no updates, useless to continue
            return;
       
        if (newFigure != null) 
            session.getHabbo().setFigure(newFigure);
       
        if (newGender != null) 
            session.getHabbo().setGender(newGender);
       
        if (newMotto != null) 
            session.getHabbo().setMotto(newMotto);
       
        session.getHabbo().updateAppearance();
       
        session.sendMessage(USEROBJECT.compose(session.getHabbo()));
    }

}

PHP:
public class FuseCache<TKey, TValue> {
   
    private final TMap<TKey, TValue> _cache;
    private final Function<TKey, TValue> _func;
   
    public FuseCache(Function<TKey, TValue> func) {
        _cache = new THashMap<>();
        _func = func;
    }
   
    public TValue get(TKey key) {
        if (_cache.containsKey(key)) 
            return _cache.get(key);
       
        TValue value = _func.apply(key);
        _cache.put(key, value);
        return value;
    }
   
    public void set(TKey key, TValue value) {
        _cache.put(key, value);
    }

}

PHP:
public class HabboLoader {
   
    private final FuseCache<Integer, Habbo> _habbosById;
    private final FuseCache<String, Habbo> _habbosByName;
   
    public HabboLoader() {
        _habbosById = new FuseCache<>(id -> getHabboById(id));
        _habbosByName = new FuseCache<>(name -> getHabboByName(name));
    }
   
    public Habbo select(int id) {
        return _habbosById.get(id);
    }
   
    public Habbo select(String name) {
        return _habbosByName.get(name);
    }
   
    private Habbo getHabboByName(String name) {
        try (DatabaseClient client = FuseProgram.getServer().getDatabase().getClient()) {
            client.setQuery("SELECT * FROM `habbos` WHERE `name` = ? LIMIT 1");
            client.setString(1, name);
           
            ResultSet set = client.getResultSet();
           
            if (set.next()) {
                Habbo habbo = new Habbo(set);
                _habbosById.set(habbo.getId(), habbo);
                _habbosByName.set(habbo.getName(), habbo);
                return habbo;
            }
        } catch (Exception ex) {
            Logger.logDebug("Cannot fetch habbo with Name '" + name + "', error: " + ex.getMessage());
        }
       
        return null;
    }
   
    private Habbo getHabboById(int id) {
        try (DatabaseClient client = FuseProgram.getServer().getDatabase().getClient()) {
            client.setQuery("SELECT * FROM `habbos` WHERE `id` = ? LIMIT 1");
            client.setInt(1, id);
           
            ResultSet set = client.getResultSet();
           
            if (set.next()) {
                Habbo habbo = new Habbo(set);
                _habbosById.set(habbo.getId(), habbo);
                _habbosByName.set(habbo.getName(), habbo);
                return habbo;
            }
        } catch (Exception ex) {
            Logger.logDebug("Cannot fetch habbo with ID '" + id + "', error: " + ex.getMessage());
        }
       
        return null;
    }

}

Screenies?
gPQyvbQ.png


Credits?
JoeH - Some examples in Thor/Stockholm and packets
Jordan/Jeax/JoeH/IDK - HabboEncoding (don't remember who made it)
Me - The rest?

Blabla cookies.
 

Noelle

Someone, somewhere
Nov 9, 2016
4
5
Sorry - I actually forgot this, also, exams are a pain in the ass, updates will come once a week or twice if possible. Until Christmas break :)

Also, one big update video:
 

Noelle

Someone, somewhere
Nov 9, 2016
4
5
Sorry for the lack of updates ~ they'll come soon as I'm simply too busy with school exams.
 

Chrobens

Member
Sep 17, 2015
28
2
This is quite possibly one of the best development threads on here, don't give up with this, would love to see some V9 come into the mix!
 
Status
Not open for further replies.

Users who are viewing this thread

Top