Thread: Attribute System - Includes Hiscore - Instant save - Display on line

Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12
  1. #11  
    I need some more coffee

    Jason's Avatar
    Join Date
    Aug 2009
    Thanks given
    Thanks received
    Rep Power
    Quote Originally Posted by Dexter Morgan View Post
    I like to learn and I am sure Jason can vouch this, I worked with him in the past and learned a lot from him.
    I'm not entirely sure I can vouch for this, sorry. I'm sure you learned some things, however there is a large amount of code duplications which suggests copying instead of writing, sorry. I wish I had something better to say.
    Reply With Quote  

  2. Thankful users:

  3. #12  

    Kris's Avatar
    Join Date
    Jun 2016
    Thanks given
    Thanks received
    Rep Power
    Stupid petty shit going on around here.

    As for the code itself, you definitely could improve it. On top of what others have said about the #values(), fastutils and other shit..
    return attribute.get(key) == null ? 0 : attribute.get(key);
    I don't know whether you realize or not, but that's double calls to Map#get if attribute isn't null. Avoid that.
    Local variables help plenty in that case, as well as in other cases such as..
    for (Attribute points : Attribute.values()) {
    	if (reader.has( {
    		int value = reader.get(;
    		player.getPoints().set(points, value);
    There's a lot of unnecessary getters being used, I'd suggest dropping the habit of doing that, and instead use local variables, so that block would look more like..
    final var points = player.getPoints();
    for (final Attribute points : Attribute.cachedValuesArrayOrImmutableCollectionOfThem) {
    	final var name =;
    	if (reader.has(name)) {
    		final var value = reader.get(name).getAsInt();
    		points.set(points, value);
    I'd like to emphasize this problem a little more though. Just about everyone in RSPS tends to not write local variables, and instead use getters and whatnot over and over, making the code much lengthier(not in my example - I'm aware, but generally it is true), less readable and less efficient. Please, drop the habit - all of you.
    I encourage you to use the 'final' keyword whenever possible. It's a shame final isn't the default state in java.
    Another thing I do not understand is why you've chosen to go with a HashMap when the key of the map is always an Attribute(enum)? EnumMap is definitely more appropriate in this scenario, as it is much faster for #get/put/remove calls compared to a hashmap.

    [Only registered and activated users can see links. ]
    Discord: Kris#1337
    Reply With Quote  

  4. Thankful users:

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 23
    Last Post: 03-09-2012, 06:13 PM
  2. Replies: 109
    Last Post: 05-22-2009, 04:42 PM
  3. Instant dds hit [ON NPC] [DELTA]
    By Coder Alex in forum Tutorials
    Replies: 8
    Last Post: 04-17-2009, 10:05 PM
  4. Replies: 5
    Last Post: 01-27-2009, 03:01 AM
  5. Replies: 1
    Last Post: 01-03-2009, 11:32 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts