Thread: (Elvarg) Cleaner Starter

Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1 (Elvarg) Cleaner Starter 


    RS Wiki's Avatar
    Join Date
    Mar 2011
    Age
    29
    Posts
    9,688
    Thanks given
    1,752
    Thanks received
    3,103
    Rep Power
    5000
    In your Player #onLogin() method.

    Replace the add item garbage lines with this
    Code:
    for (int[] item : GameConstants.startKit) {
    				getInventory().add((item[0]), item[1]);
    			}
    Then declare this in the GameConstants class.
    Code:
    	public static final int[][] startKit = { { 995, 500000000 }, { 4151, 1 }, { 4153, 1 }, { 1215, 1 }, { 9185, 1 },
    			{ 11235, 1 }, { 9244, 5000 }, { 11212, 1000 }, { 386, 500 }, { 2441, 100 }, { 2437, 100 }, { 2443, 100 },
    			{ 2445, 100 }, { 2435, 100 }, { 3041, 100 }, { 2431, 100 }, { 1163, 1 }, { 1127, 1 }, { 1079, 1 },
    			{ 12954, 1 }, { 4089, 1 }, { 4091, 1 }, { 4093, 1 }, { 4095, 1 }, { 4097, 1 }, { 2503, 1 }, { 2497, 1 },
    			{ 2491, 1 } };
    Adjust your starter kid to whatever your eco/pvp preferences are (item, amount).

    Simple shit, just trying to help newcomers out to the source/java functions.
    All the best,
    Wiki




    coming soon
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    'Slutty McFur'

    Owain's Avatar
    Join Date
    Sep 2014
    Age
    26
    Posts
    2,894
    Thanks given
    2,360
    Thanks received
    2,200
    Rep Power
    5000
    Nice contribution, simple but effective.


    Spoiler for wat:
    Attached image
    Attached image

    Attached image


    Reply With Quote  
     

  4. #3  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    974
    Thanks given
    688
    Thanks received
    455
    Rep Power
    727
    startKit is constant and should therefore be STARTER_KIT.

    Also why isn't the array Item[] instead of int[]? Does this source not have a constructor class for items?
    Reply With Quote  
     

  5. #4  


    RS Wiki's Avatar
    Join Date
    Mar 2011
    Age
    29
    Posts
    9,688
    Thanks given
    1,752
    Thanks received
    3,103
    Rep Power
    5000
    Quote Originally Posted by Andys1814 View Post
    startKit is constant and should therefore be STARTER_KIT.

    Also why isn't the array Item[] instead of int[]? Does this source not have a constructor class for items?
    No to the constructor, cbf to convert all that shit then release. No performance changes just preferences but I'll eventually get to it later.
    Yeah that's fair enough, I had this all done in a class prior I just ported the constant over to the GameConstants and forgot to uppercase the constant.
    All the best,
    Wiki




    coming soon
    Reply With Quote  
     

  6. #5  
    Extreme Donator


    Join Date
    Oct 2010
    Posts
    2,853
    Thanks given
    1,213
    Thanks received
    1,622
    Rep Power
    5000
    Quote Originally Posted by Andys1814 View Post
    startKit is constant and should therefore be STARTER_KIT.

    Also why isn't the array Item[] instead of int[]? Does this source not have a constructor class for items?
    Code:
    	/**
    	 * Adds an item to the item container.
    	 * @param id		The id of the item.
    	 * @param amount	The amount of the item.
    	 * @return			The ItemContainer instance.
    	 */
    	public ItemContainer add(int id, int amount) {
    		return add(new Item(id, amount));
    	}
    Using int[][] is fine, it will create a new item from the data anyway and use that method instead.

    Thanks for this, it's much cleaner than the old code which was added there 10 minutes before the beta haha.
    Reply With Quote  
     

  7. Thankful users:


  8. #6  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    974
    Thanks given
    688
    Thanks received
    455
    Rep Power
    727
    Could probs do this:

    Code:
    	public static final ImmutableSet<Item> STATER_KIT = ImmutableSet.of(new Item(995, 500000000), new Item(4151, 1),
    			new Item(4153, 1), new Item(1215, 1), new Item(9185, 1), new Item(11235, 1), new Item(9244, 5000),
    			new Item(11212, 1000), new Item(386, 500), new Item(2441, 100), new Item(2437, 100), new Item(2443, 100),
    			new Item(2445, 100), new Item(2435, 100), new Item(3041, 100), new Item(2431, 100), new Item(1163, 1),
    			new Item(1127, 1), new Item(1079, 1), new Item(12954, 1), new Item(4089, 1), new Item(4091, 1),
    			new Item(4093, 1), new Item(4095, 1), new Item(4097, 1), new Item(2503, 1), new Item(2497, 1),
    			new Item(2491, 1));
    Code:
    		STATER_KIT.forEach(player.getInventory()::add);
    Not sure about efficiency tho -- wont matter tho
    Reply With Quote  
     

  9. Thankful users:


  10. #7  
    Registered Member

    Join Date
    Dec 2016
    Posts
    132
    Thanks given
    39
    Thanks received
    54
    Rep Power
    100
    Quote Originally Posted by Andys1814 View Post
    startKit is constant and should therefore be STARTER_KIT.

    Also why isn't the array Item[] instead of int[]? Does this source not have a constructor class for items?
    Seems like a bad habit hes carried over from PI based servers since they do not make use of an Item or ItemContainer system.

    ImmutableSet works here but the Item[] array would work just as fine. Either way you are iterating through the array or set of items and then giving them to the player.
    Nando Studios
    Reply With Quote  
     

  11. #8  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Andys1814 View Post
    startKit is constant and should therefore be STARTER_KIT.
    Incorrect. Arrays are mutable, regardless of the usage of the final modifier.

    Code:
    class Foo {
    
        static final int[] items = { 1 };
    
        @Test
        public void mutableArrayTest() {
            System.out.printf("value=%s\n", items[0]);
            items[0] = 2;
            System.out.printf("modified value=%s", items[0]);
        }
    }
    If you run that you will notice that it is possible to modify the array. As stated, a common work around to this is to use an ImmutableCollection implementation.
    Reply With Quote  
     

  12. Thankful users:


  13. #9  
    Registered Member
    Andys1814's Avatar
    Join Date
    Feb 2013
    Posts
    974
    Thanks given
    688
    Thanks received
    455
    Rep Power
    727
    Quote Originally Posted by Jason View Post
    Incorrect. Arrays are mutable, regardless of the usage of the final modifier.

    Code:
    class Foo {
    
        static final int[] items = { 1 };
    
        @Test
        public void mutableArrayTest() {
            System.out.printf("value=%s\n", items[0]);
            items[0] = 2;
            System.out.printf("modified value=%s", items[0]);
        }
    }
    If you run that you will notice that it is possible to modify the array. As stated, a common work around to this is to use an ImmutableCollection implementation.
    Okay I'm sure you could agree though, for clarity sake if nothing else, it should follow constant declaration..
    Reply With Quote  
     

  14. Thankful users:


  15. #10  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by Andys1814 View Post
    Okay I'm sure you could agree though, for clarity sake if nothing else, it should follow constant declaration..
    I completely disagree, it absolutely should not be treated as an immutable reference because it is not. This is literally the reason why we have a global standard called convention. If the object cannot be mutated during runtime and is defined static and final, it is permitted to follow the constant naming convention. Otherwise, it is not immutable, and shouldn't be treated as such.
    Reply With Quote  
     

  16. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. ==== Sever Starter Pack V2 ====
    By Icepkz in forum Tools
    Replies: 90
    Last Post: 10-19-2013, 10:45 PM
  2. === Awesome Starter Pack ===
    By Icepkz in forum Tools
    Replies: 24
    Last Post: 01-26-2008, 03:38 AM
  3. Starter Command (with logs)
    By Systəx in forum Tutorials
    Replies: 11
    Last Post: 07-23-2007, 08:57 PM
  4. Replies: 6
    Last Post: 04-19-2007, 12:09 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
  •