An4rchy Posted January 24, 2017 Share Posted January 24, 2017 (edited) 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..) Edited January 26, 2017 by An4rchy 3 Quote Link to comment Share on other sites More sharing options...
Tryskell Posted January 25, 2017 Share Posted January 25, 2017 (edited) - 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 January 25, 2017 by Tryskell Quote Link to comment Share on other sites More sharing options...
An4rchy Posted January 25, 2017 Author Share Posted January 25, 2017 - 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. Quote Link to comment Share on other sites More sharing options...
Tryskell Posted January 25, 2017 Share Posted January 25, 2017 I edited my message ^^. Quote Link to comment Share on other sites More sharing options...
An4rchy Posted January 25, 2017 Author Share Posted January 25, 2017 I edited my message ^^. Damn I was too fast ;p On the next update tomorrow maybe, can't be arsed now ;p Quote Link to comment Share on other sites More sharing options...
GLO Posted January 25, 2017 Share Posted January 25, 2017 (edited) Just wait the update. To be honest was looking for something like this tho :DHad an auction system before but no idea where it vanished. +1 for your recent shares. Edited January 25, 2017 by big man bill Quote Link to comment Share on other sites More sharing options...
protoftw Posted January 25, 2017 Share Posted January 25, 2017 Thanks for sharing it mate, keep up :) Quote Link to comment Share on other sites More sharing options...
An4rchy Posted January 25, 2017 Author Share Posted January 25, 2017 Thank you. Quote Link to comment Share on other sites More sharing options...
StinkyMadness Posted January 26, 2017 Share Posted January 26, 2017 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()) Quote Link to comment Share on other sites More sharing options...
StinkyMadness Posted January 26, 2017 Share Posted January 26, 2017 (edited) This bug working with any items "Weacpon/Armor/Jewel/etc.." Edited January 26, 2017 by StinkyMadness Quote Link to comment Share on other sites More sharing options...
An4rchy Posted January 26, 2017 Author Share Posted January 26, 2017 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. Quote Link to comment Share on other sites More sharing options...
MarGaZeaS Posted April 7, 2017 Share Posted April 7, 2017 any info for bugs? code working? i need to add in my project Quote Link to comment Share on other sites More sharing options...
TheMark147 Posted April 17, 2017 Share Posted April 17, 2017 (edited) 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 April 17, 2017 by TheMark147 Quote Link to comment Share on other sites More sharing options...
SweeTs Posted April 17, 2017 Share Posted April 17, 2017 Your own auctions are not listed. Quote Link to comment Share on other sites More sharing options...
TheMark147 Posted April 17, 2017 Share Posted April 17, 2017 Your own auctions are not listed. Ohhh you have right I'm idiot (I'm trying this NPC only with one character there was fault) THX bro :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.