Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Add-on] [All versions] Faster Cash Shop

Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
This is just a mini release. I found that whenever you start the server and enters cash shop to buy an item, it takes a while before you can buy that item. So, what i'm posting below is a method to load all cash items when you start the channel server. By doing this, you'll have a faster cash shop when you buy items. I found this method by browsing through CelinoSRC, wonder why nobody is using this.

Ok, I assume most of them is using LocalMs source. So this method is basically for LocalMS source but it will also work others. As for Moople, you'll have to edit a bit as the cash shop part is different.

If you didn't edit anything to your CashItemFactory, then you can just replace your old CashItemFactory.java with this. Else, just check the difference and edit it.
Code:
public class CashItemFactory {

	private static CashItemFactory instance = new CashItemFactory();
	private Map<Integer, CashItemInfo> itemStats = new HashMap<Integer, CashItemInfo>();
	private MapleDataProvider data = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Etc.wz"));

	public static CashItemFactory getInstance() {
		return instance;
	}

	protected CashItemFactory() {
		System.out.println("Loading CashItemFactory :::");

		for (MapleData field : data.getData("Commodity.img").getChildren()) {
			boolean onSale = MapleDataTool.getIntConvert("OnSale", field, 0) > 0;
			if (onSale) {
				final CashItemInfo stats = new CashItemInfo(
				MapleDataTool.getIntConvert("ItemId", field),
				MapleDataTool.getIntConvert("Count", field, 1),
				MapleDataTool.getIntConvert("Price", field, 0),
				MapleDataTool.getIntConvert("SN", field, 0));

				itemStats.put(MapleDataTool.getIntConvert("SN", field, 0), stats);
			}
		}
	}

	public CashItemInfo getItem(int sn) {
		CashItemInfo stats = itemStats.get(sn);
		if (stats == null) {
			return null;
		}
		return stats;
	}

	public List<Integer> getPackageItems(int itemId) {
		List<Integer> packageItems = new ArrayList<Integer>();

		for (MapleData b : data.getData("CashPackage.img").getChildren()) {
			if (itemId == Integer.parseInt(b.getName())) {
				for (MapleData c : b.getChildren()) {
					for (MapleData d : c.getChildren()) {
						packageItems.add(getItem(MapleDataTool.getIntConvert("" + Integer.parseInt(d.getName()), c)).getId());
					}
				}
				break;
			}
		}
		return packageItems;
	}
}

Then, Go to ChannelServer.java, find
Code:
tMan.start();

Add this under it,
Code:
CashItemFactory.getInstance();

Compile and you're done. :wink: You'll buy items from Cash Shop faster after this.

Credits: CelinoSRC, I just took out the method from there.

PS* To LightPepsi, If you see this and want this down, let me know, I'll remove it.
 
Last edited:
Junior Spellweaver
Joined
Nov 23, 2010
Messages
173
Reaction score
9
Re: [All versions] Faster Cash Shop

the different is the
private static CashItemFactory instance = new CashItemFactory();

and

public static CashItemFactory getInstance() {
return instance;
}
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Re: [All versions] Faster Cash Shop

Then I guess just replace it with the one I posted above if you didn't edited it.

EDIT* Oh and, if you're using Moople, you'll have to use another way as you can't reference a non-static object from a static object.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Re: [All versions] Faster Cash Shop

Pretty cool!
Would this increase the starting time by heaps?
 
Last edited:
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Re: [All versions] Faster Cash Shop

This is loading from the xml files is it not? o_O

Yea, you're right. This allows cash items to be loaded from XMLs when you start the channel server.
 
Elite Diviner
Loyal Member
Joined
Sep 25, 2008
Messages
457
Reaction score
37
Re: [All versions] Faster Cash Shop

Since when is loading by MySQL faster?

Since when is not knowing what you're talking about, then posting poop which blatantly shows that you don't know poop good?
 
Joined
Aug 10, 2008
Messages
858
Reaction score
516
Re: [All versions] Faster Cash Shop

Then I guess just replace it with the one I posted above if you didn't edited it.

EDIT* Oh and, if you're using Moople, you'll have to use another way as you can't reference a non-static object from a static object.

You mean a non-static member from a static method? You just make the member static.
 
Newbie Spellweaver
Joined
Nov 23, 2010
Messages
16
Reaction score
0
Re: [All versions] Faster Cash Shop

Very Useful
 
I'm sexy and I know it :)
Joined
Oct 21, 2008
Messages
811
Reaction score
350
Re: [All versions] Faster Cash Shop

Okay, these yenpooh releases are starting to bother me.

#1, he has no clue what this does. He didnt't make this.
#2, the release WAS ALREADY RELEASED.
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
Re: [All versions] Faster Cash Shop

Okay, these yenpooh releases are starting to bother me.

#1, he has no clue what this does. He didnt't make this.
#2, the release WAS ALREADY RELEASED.

1) I stated everything in the first post. What's the difference if I did gave the credits? And, I also stated if Lai doesn't want this, he can let me know. i'll just delete it.

2) It was released in Celino, just that no one is bothering to use it. I figured out that it takes a long time to buy an item from CS so i posted this fix.
 
Back
Top