Jump to content

Interlude Auction Shop


An4rchy

Recommended Posts

Hello.

 

This is an auction shop I made some time ago for aCis.

 

How it works: Players can add items for sale at the auction shop at the price they want. Then, even if they are offline other players can buy the items and they will get the rewards(the price they put). Enchant of items stays, augmented items are not sellable.

There is a searching system(case sensitive) and a paging system.

 

I have NOT tested this code on a live server (only local testing), but I remember adding a shittone of checks to avoid any exploits. I recommend you test it out well before using it.

 

You need to make an npc with id 65529 and type L2AuctionManager.

 

Code: http://pastebin.com/QqY6LGWV

Update - Replace AuctionTable and L2AuctionManagerInstance with these:

AuctionTable (update: the bug mentioned in the replies fixed): http://pastebin.com/vVPhiXKY

L2AuctionManagerInstance: http://pastebin.com/h8LFuesV

 

Some pictures:

 

(Please excuse my html designs..)

 

2ikpbbm.jpgk9c9bk.jpgsdfx4l.jpg2qsb5ab.jpg

 

24n35s2.jpg2cmniwg.jpgrqwuq1.jpg

Edited by An4rchy
  • Upvote 3
Link to comment
Share on other sites

- You will end with instant ConcurrentException on multiplayer scenario. items list should be stored on a concurrenthashmap (avoid copyonwritearraylist, terrible performance).

- string concat in a for loop is the devil (while regular concat is transformed into StringBuilder, in a for loop it doesn't), use StringUtil.append and a StringBuilder.

- all your paging systems can be replaced for existing and cleaner scenarios, such as Bookmark and SchemeBuffer (using MathUtil.countPagesNumber).

- Use try-with-ressources statement (jdk 7) to avoid to bother with ressource close (eliminate an eventual miss and drop the finally block).

- HTM on htm side, to make code more readable/maintainable.

- There could have a bid system, if price is 0 (or you add a checking case).

- Adena should be formatted using StringUtil.formatNumber

- If an item is listed for a very long time, it should be moved back on player inventory (to avoid the list being longer and longer) - One week default.

- server should take a fee, both to set an item (avoid to flood the market with single soulshots) and once the item is sold (to recycle some adena, economy lesson).

- Some items shouldn't be able to be sold, or at least not with low amount (I think about soulshots, arrows) to limit the number of objects (idiots can easily make your server a burden spamming 1 soulshot selling, making the whole system lag if they find a way to automatize it)

- Writting "Cost:" and "Item:" is a waste of space.

Edited by Tryskell
Link to comment
Share on other sites

- You will end with instant ConcurrentException on multiplayer scenario. items list should be stored on a concurrenthashmap (avoid copyonwritearraylist, terrible performance).

- string concat in a for loop is the devil (while regular concat is transformed into StringBuilder, in a for loop it doesn't), use StringUtil.append and a StringBuilder.

- all your paging systems can be replaced for existing and cleaner scenarios, such as Bookmark and SchemeBuffer (using MathUtil.countPagesNumber).

- Use try-with-ressources statement (jdk 7) to avoid to bother with ressource close (eliminate an eventual miss and drop the finally block).

- HTM on htm side, to make code more readable/maintainable.

- There could have a bid system, if price is 0 (or you add a checking case).

- Adena should be formatted using StringUtil.formatNumber

- If an item is listed for a very long time, it should be moved back on player inventory (to avoid the list being longer and longer)

- server should take a fee, both to set an item (avoid to flood the market) and once the item is sold (to recycle some adena, economy lesson)

- I thought about that to be honest when I was uploading this share, but it's been 2+ years since I made it. Gonna update it.

- I don't see what could go wrong with that to be honest..

- The paging system was added after the original npc was created(since I ended with critical errors on many items) so it's really messy and to be honest I can't be bothered to update it.

- I know, idk why I did it that way when I was making it to be honest. Gonna be on next update.

- I always prefer htmls on htm side but in this case most of the htm is generated server-side so it would be pointless having 5 lines of htm code in htm side when the htm is way longer.

- Extra feature, can't be bothered to add it.

- Gonna be on next update, thanks.

- Extra feature, can't be bothered to add it.

- Extra feature, can't be bothered to add it.

 

Thanks for the feedback.

Link to comment
Share on other sites

Just wait the update. To be honest was looking for something like this tho :D
Had an auction system before but no idea where it vanished.

+1 for your recent shares.

Edited by big man bill
Link to comment
Share on other sites

update

  • L2AuctionManagerInstance.java
        ArrayList<ItemInstance> temp = new ArrayList<>();
        for (ItemInstance item : player.getInventory().getItems())
        {
-           if (item.getItemId() != 57 && item.isTradable())
+           if (item.getItemId() != 57 && item.isTradable() && !item.isEquipped())
Link to comment
Share on other sites

Yeah this bug was caused because I changed from a list to a map, I forgot to change items.remove(item); to items.remove(item.getAuctionId()); on removeItem() method.

 

Thanks for the report, fixed and topic updated.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

Its interesting because this code works perfectly but when im trying it in game everything working exclude method "showAuction" do not show any items but in block "My Items" or "Add Items" its working normally any suggestion? THX :)

 

// edit

 

I only delete Icons because i dont have table in DB with items icon that cant be a problem I'm sure :)

Edited by TheMark147
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...