Sign up
Login
New paste
Home
Archive
English
English
Sign up
Login
New Paste
Browse
### Eclipse Workspace Patch 1.0 #P aCis_datapack Index: data/html/admin/main_menu.htm =================================================================== --- data/html/admin/main_menu.htm (revision 30) +++ data/html/admin/main_menu.htm (working copy) @@ -43,7 +43,7 @@ <td><button value="Set Name" action="bypass -h admin_setname $menu_command" width=55 height=15 back="sek.cbui94" fore="sek.cbui92"></td> <td><button value="Set Title" action="bypass -h admin_settitle $menu_command" width=55 height=15 back="sek.cbui94" fore="sek.cbui92"></td> <td><button value="Get Buffs" action="bypass -h admin_getbuffs $menu_command" width=55 height=15 back="sek.cbui94" fore="sek.cbui92"></td> - <td></td> + <td><button value="Search" action="bypass -h admin_search" width=55 height=15 back="sek.cbui94" fore="sek.cbui92"></td> </tr> </table> <br><img src="L2UI_CH3.herotower_deco" width=256 height=32><br> Index: data/html/admin/search.htm =================================================================== --- data/html/admin/search.htm (revision 0) +++ data/html/admin/search.htm (working copy) @@ -0,0 +1,19 @@ +<html><title>Search menu</title><body><center> +<table width=260> + <tr> + <td><button value="Main" action="bypass -h admin_admin" width=65 height=19 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td> + <td><button value="Game" action="bypass -h admin_admin 2" width=65 height=19 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td> + <td><button value="Effects" action="bypass -h admin_admin 3" width=65 height=19 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td> + <td><button value="Server" action="bypass -h admin_admin 4" width=65 height=19 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td> + </tr> +</table> +<img src="l2ui.SquareWhite" width=275 height=1><br> +<table width=274> + <tr> + <td width=204><multiedit var="search" width=204 height=15></td> + <td width=70><button value="Search" action="bypass -h admin_search 1 $search" width=65 height=19 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td> + </tr> +</table><br> +<img src=L2UI.SquareGray width=280 height=1> +%list% +</body></html> \ No newline at end of file Index: data/xml/adminCommands.xml =================================================================== --- data/xml/adminCommands.xml (revision 30) +++ data/xml/adminCommands.xml (working copy) @@ -251,6 +251,9 @@ <aCar name="admin_ride" accessLevel="7"/> <aCar name="admin_unride" accessLevel="7"/> + <!-- SEARCH --> + <aCar name="admin_search" accessLevel="7"/> + <!-- SHOP --> <aCar name="admin_buy" accessLevel="7"/> <aCar name="admin_gmshop" accessLevel="7"/> #P aCis_gameserver Index: java/net/sf/l2j/gameserver/data/xml/ItemData.java =================================================================== --- java/net/sf/l2j/gameserver/data/xml/ItemData.java (revision 30) +++ java/net/sf/l2j/gameserver/data/xml/ItemData.java (working copy) @@ -75,6 +75,14 @@ } /** + * @return the list of all {@link Item} templates. + */ + public Item[] getTemplates() + { + return _templates; + } + + /** * @param id : the item id to check. * @return the {@link Item} corresponding to the item id. */ Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java =================================================================== --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 30) +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy) @@ -38,6 +38,7 @@ import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminPolymorph; import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminRes; import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminRideWyvern; +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSearch; import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminShop; import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSiege; import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSkill; @@ -87,6 +88,7 @@ registerHandler(new AdminPolymorph()); registerHandler(new AdminRes()); registerHandler(new AdminRideWyvern()); + registerHandler(new AdminSearch()); registerHandler(new AdminShop()); registerHandler(new AdminSiege()); registerHandler(new AdminSkill()); Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSearch.java =================================================================== --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSearch.java (revision 0) +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSearch.java (working copy) @@ -0,0 +1,101 @@ +package net.sf.l2j.gameserver.handler.admincommandhandlers; + +import java.util.Arrays; +import java.util.List; +import java.util.StringTokenizer; +import java.util.stream.Collectors; + +import net.sf.l2j.commons.math.MathUtil; + +import net.sf.l2j.gameserver.data.xml.ItemData; +import net.sf.l2j.gameserver.handler.IAdminCommandHandler; +import net.sf.l2j.gameserver.model.actor.Player; +import net.sf.l2j.gameserver.model.item.kind.Item; +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; + +public class AdminSearch implements IAdminCommandHandler +{ + private static final int PAGE_LIMIT = 6; + + private static final String[] ADMIN_COMMANDS = + { + "admin_search" + }; + + @Override + public boolean useAdminCommand(String command, Player activeChar) + { + final NpcHtmlMessage html = new NpcHtmlMessage(0); + html.setFile("data/html/admin/search.htm"); + + if (command.equals("admin_search")) + html.replace("%list%", "<center><br><br><br>Set first an key word</center>"); + else if (command.startsWith("admin_search")) + { + StringTokenizer st = new StringTokenizer(command, " "); + st.nextToken(); + + int page = Integer.valueOf(st.nextToken()); + if (st.hasMoreTokens()) + { + StringBuilder sb = new StringBuilder(String.valueOf(page)); + StringBuilder list = getList(activeChar, page, command.substring(14 + sb.length())); + html.replace("%list%", list == null ? "" : list.toString()); + } + else + html.replace("%list%", "<center><br><br><br>Set first an key word</center>"); + } + activeChar.sendPacket(html); + return true; + } + + public StringBuilder getList(Player activeChar, int page, String search) + { + List<Item> items = Arrays.asList(ItemData.getInstance().getTemplates()).stream().filter(item -> item != null && matches(item.getName(), search)).collect(Collectors.toList()); + + if (items == null || items.isEmpty()) + return new StringBuilder("<center><br><br><br>There its no item : <font color=LEVEL>" + search + "</font></center>"); + + final int max = Math.min(100, MathUtil.countPagesNumber(items.size(), PAGE_LIMIT)); + items = items.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, items.size())); + + final StringBuilder sb = new StringBuilder(); + + int row = 0; + for (Item item : items) + { + String name = item.getName(); + + if (name.length() >= 43) + name = name.substring(0, 40) + "..."; + + sb.append("<table width=280 bgcolor=000000><tr>"); + sb.append("<td width=44 height=41 align=center><table bgcolor=FFFFFF cellpadding=6 cellspacing=\"-5\"><tr><td><button width=32 height=32 back=" + item.getIcon() + " fore=" + item.getIcon() + "></td></tr></table></td>"); + sb.append("<td width=236>" + name + "<br1><font color=B09878>Item ID : " + item.getItemId() + " " + (item.isQuestItem() ? "(Quest Item)" : "") + "</font></td>"); + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>"); + row++; + } + + for (int i = PAGE_LIMIT; i > row; i--) + sb.append("<img height=42>"); + + // Build page footer. + sb.append("<img height=2><img src=L2UI.SquareGray width=280 height=1><table width=280 bgcolor=000000><tr>"); + sb.append("<td align=right width=70>" + (page > 1 ? "<button value=\"< PREV\" action=\"bypass admin_search " + (page - 1) + " " + search + "\" width=65 height=19 back=L2UI_ch3.smallbutton2_over fore=L2UI_ch3.smallbutton2>" : "") + "</td>"); + sb.append("<td align=center width=100>Page " + page + "</td>"); + sb.append("<td align=left width=70>" + (page < max ? "<button value=\"NEXT >\" action=\"bypass admin_search " + (page + 1) + " " + search + "\" width=65 height=19 back=L2UI_ch3.smallbutton2_over fore=L2UI_ch3.smallbutton2>" : "") + "</td>"); + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>"); + return sb; + } + + public static boolean matches(String name, String search) + { + return Arrays.stream(search.toLowerCase().split(" ")).allMatch(result -> name.toLowerCase().contains(result)); + } + + @Override + public String[] getAdminCommandList() + { + return ADMIN_COMMANDS; + } +}
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Do you like cookies?
🍪 We use cookies to ensure you get the best experience on our website.
Learn more
I agree