ShyNoShy & Quackster your work on the emulator is good so far, but I would like to point a bug out with stacking, when your on a tile and you place a stackable item you go on top of the item...
P.S: If people make something like a code for wired/horses or what ever... can we post them to other users? cos sharing is caring... but if not don't worry :P
Hey should I remove my plugin system or keep it?
EDIT: Nevermind, removing it anyway.
C-c-c-c-c-combo breaker!
Yet another, C-c-c-c-c-combo breaker!
Fixed a memory leak, instead of calling the remove function for sessions it would return the session thus not removing it, ever.
And added a constant loop for Sessions with a success or a fail ping, it fails it will dispose your data and disconnect you.
Code:package sierra.habbo; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import org.jboss.netty.channel.Channel; public class SessionManager implements Runnable { private Thread connectionThread; private ConcurrentMap<Integer, Session> Sessions; public SessionManager() { Sessions = new ConcurrentHashMap<Integer, Session>(); connectionThread = new Thread(this); /* * Start ping event to check if the user is still connected. */ connectionThread.setPriority(Thread.NORM_PRIORITY); connectionThread.start(); } /* * Add session if the same session doesn't already exist */ public boolean addSession(Channel channel) { return Sessions.putIfAbsent(channel.getId(), new Session(channel)) == null; } /* * Remove the session. */ public void removeSession(Channel channel) { try { Sessions.remove(channel.getId()); } catch (Exception e) { } } /* * Grab user by channel id. */ public Session GetUserByChannel(Channel channel) { return Sessions.get(channel.getId()); } /* * Return a collection of sessions */ public ConcurrentMap<Integer, Session> getSessions() { return Sessions; } /* * Return a true/false if the session exists in the collection */ public boolean hasSession(Channel channel) { return Sessions.containsKey(channel.getId()); } public boolean UserByIdOnline(int id) { for (Session Session : Sessions.values()) if (Session.getHabbo() != null) if (Session.getHabbo().Id == id) return true; return false; } public Session GetUserByName(String Name) { for (Session Session : Sessions.values()) if (Session.getHabbo() != null) if (Session.getHabbo().Username.equals(Name)) return Session; return null; } public Session GetUserById(int UserId) { for (Session Session : Sessions.values()) if (Session.getHabbo() != null) if (Session.getHabbo().Id == UserId) return Session; return null; } /* * Thread loop for checking if Sessions have disconnected. */ @Override public void run() { while (true) { for (Session Session : Sessions.values()) { if (!Session.PingOK) { Session.dispose(); removeSession(Session.getChannel()); } } } } }
Coded fuse rights, instead of rank checking, this allows you to customize the permissions even more!
Code:package sierra.habbohotel.fuserights; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import sierra.Sierra; public class FuserightEngine { private static Map<Integer, List<String>> Fuserights = new HashMap<Integer, List<String>>(); public static void LoadAll() { try { PreparedStatement Statement = Sierra.getDatabase().ExecuteQuery("SELECT * FROM `fuserights`"); ResultSet Row = Statement.executeQuery(); while (Row.next()) { Integer Rank = Row.getInt("rank"); if (Fuserights.containsKey(Rank) == false) { Fuserights.put(Rank, new ArrayList<String>()); fillFuses(Rank); } } } catch (Exception e) { e.printStackTrace(); } } public static void fillFuses(int Rank) { try { ResultSet Row = Sierra.getDatabase().ReadTable("SELECT * FROM fuserights WHERE rank = '" + Rank + "'"); while (Row.next()) { Fuserights.get(Rank).add(Row.getString("fuse")); } } catch (Exception e) { e.printStackTrace(); } } public static List<String> getFusesrightsByRank(int Rank) { List<String> LoadedFuses = new ArrayList<String>(); for (Entry<Integer, List<String>> KeyValue : Fuserights.entrySet()) { if (KeyValue.getKey().equals(Rank) || KeyValue.getKey() < Rank) { for (String fuse : KeyValue.getValue()) { LoadedFuses.add(fuse); } } } return LoadedFuses; } }Code:public Boolean hasStaffPermission(String Fuse) { return FuserightEngine.getFusesrightsByRank(Rank).contains(Fuse); }