Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P L2JServer
- Index: java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java
- ===================================================================
- --- java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java (revision 51)
- +++ java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
- @@ -33,7 +34,11 @@
- import com.l2jserver.gameserver.model.actor.instance.L2MerchantSummonInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.entity.Hero;
- import com.l2jserver.gameserver.model.entity.L2Event;
- +import com.l2jserver.gameserver.model.entity.PvpPkList;
- import com.l2jserver.gameserver.network.SystemMessageId;
- import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
- import com.l2jserver.gameserver.network.communityserver.writepackets.RequestShowCommunityBoard;
- @@ -169,6 +180,10 @@
- }
- catch (NumberFormatException nfe) {}
- }
- + else if (_command.startsWith("pvpItem")){
- + PvpPkList list = new PvpPkList();
- + list.convert(activeChar,_command.substring(8));
- + }
- // Navigate through Manor windows
- else if (_command.startsWith("manor_menu_select"))
- {
- Index: java/com/l2jserver/gameserver/model/entity/PvpPkList.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/PvpPkList.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/PvpPkList.java (revision 0)
- @@ -0,0 +1,154 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.StringTokenizer;
- +
- +import com.l2jserver.L2DatabaseFactory;
- +import com.l2jserver.gameserver.model.L2World;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jserver.util.StringUtil;
- +
- +/**
- + * @author FighterBoss
- + *
- + */
- +public class PvpPkList
- +{
- + private int allPages = 1;
- + private int howMayPerPage = 2;
- + public void showUsTheFuture(L2PcInstance activeChar, boolean pvp, int page, String name){
- + String bad = "Pk";
- + String good = "Pk";
- + if(!pvp)
- + bad = "Pvp";
- + else
- + good = "Pvp";
- + NpcHtmlMessage adminReply = new NpcHtmlMessage(10);
- + final StringBuilder replyMSG = StringUtil.startAppend(
- + 1000,
- + "<html><head><title>PvP/PK List</title></head><body>",
- + "<center>Top "+ good +" List<br>",
- + "<button value=\""+ bad +" List\" action=\"bypass -h pvpItem "+ bad.subSequence(0, 2) +" \" width=65 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">",
- + "</center><br><table width=300><tr><td>Nr.</td><td width=80>Name</td><td>"+ good +" Points</td><td>Online</td></tr>",
- + getList(pvp,page,name),
- + "</table>",
- + "<br><table><tr><td><edit var=\"name\" width=120 height=15></td><td>",
- + "<button value=\"Search\" action=\"bypass -h pvpItem "+ bad.subSequence(0, 2) +" 1 $name \" width=65 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">",
- + "</td></tr></table><br><center>",
- + getPages(page,pvp),
- + "</center></html></body>"
- + );
- +
- + adminReply.setHtml(replyMSG.toString());
- + activeChar.sendPacket(adminReply);
- + }
- +
- + public void convert(L2PcInstance activeChar, String text)
- + {
- + boolean pvp = true;
- + int page = 1;
- + String name = "";
- + StringTokenizer st = new StringTokenizer(text);
- + if(st.nextToken().equals("Pk"))
- + pvp = false;
- + if(st.hasMoreTokens())
- + page = Integer.parseInt(st.nextToken());
- + if(st.hasMoreTokens())
- + name = st.nextToken();;
- + showUsTheFuture(activeChar,pvp,page,name);
- + }
- +
- + private String getPages(int page, boolean pvp)
- + {
- + String text = "<table><tr>";
- + String pvpx = "Pv";
- + if(!pvp)
- + pvpx = "Pk";
- + if(page>1){
- + if(page>4)
- + text += "<td width=30><a action=\"bypass -h pvpItem "+ pvpx +" "+ 1 +"\">First</a></td>";
- + for(int i = page-3;i<=page-1;i++)
- + if(i>0)
- + text += "<td><a action=\"bypass -h pvpItem "+ pvpx +" "+ i +"\">"+ i +"</a> </td>";
- + }
- + text += "<td>"+ page + " </td>";
- + for(int i = page+1;i<=page+3;i++)
- + if(i<=allPages)
- + text += "<td><a action=\"bypass -h pvpItem "+ pvpx +" "+ i +"\">"+ i +"</a> </td>";
- + if(page<(allPages-3))
- + text += "<td width=30><a action=\"bypass -h pvpItem "+ pvpx +" "+ allPages +"\">Last</a></td>";
- + return text;
- + }
- + private String getList(boolean pvp, int page, String name){
- + String text = "";
- + int number = 0;
- + String orderBy = "pvpkills";
- + if(!pvp)
- + orderBy = "pkkills";
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = con.prepareStatement("SELECT char_name, pvpkills, pkkills FROM characters WHERE char_name like '%"+ name +"%' ORDER BY "+ orderBy +" DESC");
- + ResultSet rset = statement.executeQuery();
- + while(rset.next())
- + {
- + number ++;
- + if(number >= (page*howMayPerPage-(howMayPerPage-1)) && number <= (page*howMayPerPage)){
- + text += "<tr><td>"+number+"</td><td>"+rset.getString("char_name")+"</td><td>";
- + if(pvp)
- + text += rset.getString("pvpkills");
- + else
- + text += rset.getString("pkkills");
- + text += "</td><td>";
- + boolean online = false;
- + for(L2PcInstance player : L2World.getInstance().getAllPlayers().values())
- + if(player.getName().equals(rset.getString("char_name")))
- + online = true;
- + if(online)
- + text += "<font color=\"66FF00\">Online</font>";
- + else
- + text += "<font color=\"CC0000\">Offline</font>";
- + text += "</td></tr>";
- + }
- + if(number % howMayPerPage == 0)
- + allPages ++;
- + }
- + rset.close();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + System.out.println(e);
- + }
- + finally
- + {
- + L2DatabaseFactory.close(con);
- + }
- + return text;
- + }
- +}
- #P L2J_DataPack
- Index: data/scripts/handlers/itemhandlers/PvpPkItem.java
- ===================================================================
- --- data/scripts/handlers/itemhandlers/PvpPkItem.java (revision 0)
- +++ data/scripts/handlers/itemhandlers/PvpPkItem.java (revision 0)
- @@ -0,0 +1,35 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package handlers.itemhandlers;
- +
- +import com.l2jserver.gameserver.handler.IItemHandler;
- +import com.l2jserver.gameserver.model.L2ItemInstance;
- +import com.l2jserver.gameserver.model.actor.L2Playable;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.PvpPkList;
- +
- +public class PvpPkItem implements IItemHandler
- +{
- + /**
- + *
- + * @see com.l2jserver.gameserver.handler.IItemHandler#useItem(com.l2jserver.gameserver.model.actor.L2Playable, com.l2jserver.gameserver.model.L2ItemInstance, boolean)
- + */
- + public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
- + {
- + L2PcInstance activeChar = (L2PcInstance) playable;
- + PvpPkList x = new PvpPkList();
- + x.showUsTheFuture(activeChar, true, 1, "");
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment