Thread: [718] Wealthiest players

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 34
  1. #1 [718] Wealthiest players 
    Donator


    Join Date
    Sep 2015
    Age
    24
    Posts
    532
    Thanks given
    68
    Thanks received
    115
    Rep Power
    414
    Uhm it's my first time I release something on here, Well I know maybe wealth evaluate has been released 10000x times before but I don't think this has been released; anyways here you go

    it's something cool to have as well as it's not that hard to make

    What you adding
    Attached image

    First if you don't have wealth evaluate

    Bank class
    add this method
    Code:
    	public long getBankValue() {
    		long value = 0;
    		for (Item bank : player.getBank().getContainerCopy()) {
    			if (bank == null)
    				continue;
    			long amount = bank.getAmount();
    			value += bank.getDefinitions().getValue() * amount;
    		}
    		return value;
    	}
    Inventory class
    add this method
    Code:
    	public long getInventoryValue() {
    		long value = 0;
    		for (Item inventory : player.getInventory().getItems().toArray()) {
    			if (inventory == null)
    				continue;
    			long amount = inventory.getAmount();
    			value += inventory.getDefinitions().getValue() * amount;
    		}
    		return value;
    	}
    Equipment class
    add this method as well
    Code:
    public long getEquipmentValue(Player player) {
    		long value = 0;
    		for (Item equipment : player.getInventory().getItems().toArray()) {
    			if (equipment == null)
    				continue;
    			long amount = equipment.getAmount();
    			value += equipment.getDefinitions().getValue() * amount;
    		}
    		return value;
    	}
    Now in player class
    Add this
    Code:
    	public long getTotalWealth() {
    		long bank = getBank().getBankValue();
    		long inventory = getInventory().getInventoryValue();
    		long equipment = getEquipment().getEquipmentValue();
    		long moneypouch = getMoneyPouch().getCoinsAmount();
    		long total = bank + inventory + equipment + moneypouch;
    		return total;
    	}

    Utils class; add this method
    Code:
    	    	public static String getFormattedWealth(long amount) {
    	    		return new DecimalFormat("#,###,###,###").format(amount);
    	    	}
    Okay now you have added it all; you may let players check the top wealth by using a command ?

    Code:
    	if (cmd[0].equalsIgnoreCase("topwealth")) {
    				TopWealth.displayTopWealth(player);
    				return true;
    			}
    or
    Code:
    case "TopWealth":
    TopWealth.displayTopWealth(player);
    return true;
    Post below if you need anyhelp.
    Last edited by Oldrspsown; 07-19-2021 at 05:01 PM.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    May 2016
    Posts
    5
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    looks nice, well written and thread looks clean and not all thrown together. Good job!
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Jan 2011
    Posts
    334
    Thanks given
    20
    Thanks received
    88
    Rep Power
    0
    You should use a SortedSet with a comparator instead

    When you add a player to it, it determines where in the set the player should be added depending on their total wealth.

    EDIT: And you should also take advantage of the Stream#sum method that Java 8 introduced to calculate wealth!
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Registered Member Bite's Avatar
    Join Date
    Jun 2016
    Posts
    240
    Thanks given
    52
    Thanks received
    40
    Rep Power
    4
    Thank you for the release
    Reply With Quote  
     

  6. #5  
    Member [718] Wealthiest players Market Banned
    Mr Joopz's Avatar
    Join Date
    Aug 2012
    Age
    26
    Posts
    1,410
    Thanks given
    259
    Thanks received
    96
    Rep Power
    14
    Cool release. Nothing special coding wise, but unique and cool. Well done buddy.

    P-S

    I had a button that displayed your wealth in chat rather than an interface, this may be a bit easier for you rather than multiple methods;

    Code:
    public long calculateNetworth() {
    		long value = 0;
    		for (int i = 0; i < equipment.getItems().getSize(); i++) {
    			Item item = equipment.getItems().get(i);
    			if (item == null)
    				continue;
    			long price = item.getDefinitions().getValue() * item.getAmount();
    			value += price;
    		}
    		for (int i = 0; i < inventory.getItems().getSize(); i++) {
    			Item item = inventory.getItems().get(i);
    			if (item == null)
    				continue;
    			long price = item.getDefinitions().getValue() * item.getAmount();
    			value += price;
    		}
    		// for () {
    		// Item item = coinamount;
    		// if (item == null)
    		// continue;
    		{
    			long price = coinamount;
    			value += price;
    		}
    		for (int i = 0; i < bank.getBankSize(); i++) {
    			Item item = bank.getItem(bank.getRealSlot(i));
    			long price = item.getDefinitions().getValue() * item.getAmount();
    			value += price;
    		}
    		return value;
    	}
    Also i'd save it to a file, rather than just do it via who is online.
    Reply With Quote  
     

  7. #6  
    Registered Member
    Join Date
    Feb 2016
    Posts
    11
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Looks cool, thanks for release
    Reply With Quote  
     

  8. #7  
    Donator
    Chappie's Avatar
    Join Date
    Jun 2016
    Posts
    175
    Thanks given
    65
    Thanks received
    6
    Rep Power
    32
    Good work might use.
    Reply With Quote  
     

  9. #8  
    Donator


    Join Date
    Sep 2015
    Age
    24
    Posts
    532
    Thanks given
    68
    Thanks received
    115
    Rep Power
    414
    Quote Originally Posted by ExecutionX View Post
    Wasn't this in Hyperion I ? well im sure it was you've just used there idea and changed the interface.....
    Did you even read the thread well...? I said Wealth evaluate has been released before and other servers has it and that's what I said the TopWealth wasn't released before thanks.
    Reply With Quote  
     

  10. #9  
    Banned
    Join Date
    Mar 2016
    Posts
    238
    Thanks given
    0
    Thanks received
    71
    Rep Power
    0
    thanks
    Reply With Quote  
     

  11. #10  
    Donator


    Join Date
    Sep 2015
    Age
    24
    Posts
    532
    Thanks given
    68
    Thanks received
    115
    Rep Power
    414
    Quote Originally Posted by Rsps Page View Post
    thanks
    Quote Originally Posted by Doxy View Post
    Looks cool, thanks for release
    Quote Originally Posted by AlphaV2 View Post
    looks nice, well written and thread looks clean and not all thrown together. Good job!
    Quote Originally Posted by BiteRSPS View Post
    Thank you for the release
    You're welcome, thank you too for the kind words

    Quote Originally Posted by Mr Joopz View Post
    Cool release. Nothing special coding wise, but unique and cool. Well done buddy.

    P-S

    I had a button that displayed your wealth in chat rather than an interface, this may be a bit easier for you rather than multiple methods;

    Code:
    public long calculateNetworth() {
    		long value = 0;
    		for (int i = 0; i < equipment.getItems().getSize(); i++) {
    			Item item = equipment.getItems().get(i);
    			if (item == null)
    				continue;
    			long price = item.getDefinitions().getValue() * item.getAmount();
    			value += price;
    		}
    		for (int i = 0; i < inventory.getItems().getSize(); i++) {
    			Item item = inventory.getItems().get(i);
    			if (item == null)
    				continue;
    			long price = item.getDefinitions().getValue() * item.getAmount();
    			value += price;
    		}
    		// for () {
    		// Item item = coinamount;
    		// if (item == null)
    		// continue;
    		{
    			long price = coinamount;
    			value += price;
    		}
    		for (int i = 0; i < bank.getBankSize(); i++) {
    			Item item = bank.getItem(bank.getRealSlot(i));
    			long price = item.getDefinitions().getValue() * item.getAmount();
    			value += price;
    		}
    		return value;
    	}
    Also i'd save it to a file, rather than just do it via who is online.
    Thanks, This may also works but I think my way is a bit more accurate. Also it's true you would save it to a file but I just felt Online players will be better because once you exceed the limit of the interface lines no more players will be added or at least the wealth inter will be 24/7 filled with player names which something we don't want to happen.

    Quote Originally Posted by Wrecked... View Post
    You should use a SortedSet with a comparator instead

    When you add a player to it, it determines where in the set the player should be added depending on their total wealth.

    EDIT: And you should also take advantage of the Stream#sum method that Java 8 introduced to calculate wealth!
    Oh didn't know about that since I'm used to do it that way, even in other leader boards.. Thank you by the way .
    Reply With Quote  
     

Page 1 of 4 123 ... 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. 718+ Custom Player Rights + Crowns (Images)
    By MisterTorva in forum Help
    Replies: 5
    Last Post: 01-07-2013, 02:32 PM
  2. [718] saving player location
    By Monum3ntal in forum Snippets
    Replies: 27
    Last Post: 12-11-2012, 11:10 PM
  3. 718 New Player put in Friends Chat
    By CamperScape in forum Help
    Replies: 7
    Last Post: 12-09-2012, 11:58 PM
  4. Replies: 5
    Last Post: 09-28-2012, 11:58 AM
  5. 667/718 Client Player X & Y?
    By TaterMater in forum Help
    Replies: 0
    Last Post: 09-26-2012, 01:43 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
  •