Gaila bet ne, ismeta man errorus kad netinka argumentai, galiu visa koda imest bet bus makalyne :D
package com.l2jfrozen.gameserver.model.actor.instance;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringTokenizer;
import java.util.logging.Level;
import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jfrozen.gameserver.model.entity.Announcements;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.gameserver.network.clientpackets.Say2;
import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
import com.l2jfrozen.gameserver.network.serverpackets.ItemList;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;
import com.l2jfrozen.gameserver.network.serverpackets.StatusUpdate;
import javolution.text.TextBuilder;
import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.managers.GrandBossManager;
import com.l2jfrozen.gameserver.managers.RaidBossPointsManager;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2Summon;
import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
import com.l2jfrozen.gameserver.network.SystemMessageId;
import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.CloseUtil;
import com.l2jfrozen.util.database.L2DatabaseFactory;
import com.l2jfrozen.util.random.Rnd;
public class L2NewbieInstance extends L2NpcInstance{
@Override
public String getHtmlPath(int npcId, int val)
{
String pom = "";
if(val == 0)
{
pom = "" + npcId;
}
else
{
pom = npcId + "-" + val;
}
return "data/html/mano/" + pom + ".htm";
}
@Override
public void showChatWindow(L2PcInstance player)
{
String filename = "data/html/npcdefault.htm";
filename = getHtmlPath(getNpcId(), 0); // Owner message window
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcname%", getName());
player.sendPacket(html);
filename = null;
html = null;
}
SystemMessage sm;
/**
* @param objectId
* @param template
*/
@Override
public void onBypassFeedback(L2PcInstance player, String command){
StringTokenizer st = new StringTokenizer(command, " ");
String actualCommand = st.nextToken(); // Get actual command
if(actualCommand.equalsIgnoreCase("reward1")){
//player.addItem("Consume", 57, 11000, null, false);
// pavyzdys player.sendPacket(new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1).addNumber(110000).addItemName(57));
//player.sendMessage("You have gained 11000 Adena");
player.getInventory().addItem("Extract", 57, 110000, player,null);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_PICKED_UP_S1).addItemName(57));
// Inventory update
StatusUpdate su = new StatusUpdate(player.getObjectId());
su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
player.sendPacket(su);
player.sendPacket(new ItemList(player, true));
//mysql
updateDatabase(player);
}
if(updateDatabase(player) ){
}
}
public L2NewbieInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
// TODO Auto-generated constructor stub
}
@Override
public void onSpawn(){
Announcements.getInstance().announceToAll("Reward manager spawned in world.");
}
public int updateDatabase(String player){
{
Connection con = null;
int number = 0;
try
{
con = L2DatabaseFactory.getInstance().getConnection(false);
final PreparedStatement statement = con.prepareStatement("SELECT rew1 FROM rewards WHERE obj_Id=?");
statement.setString(1, player);
final ResultSet rset = statement.executeQuery();
while(rset.next())
{
number = rset.getInt(1);
}
statement.close();
rset.close();
}
catch(SQLException e)
{
_log.severe("could not check existing char number");
e.printStackTrace();
}
finally
{
CloseUtil.close(con);
}
return number;
}
}
String MANO1="update rewards set rew1= ? where obj_Id = ?";
String MANO2="INSERT INTO rewards VALUES (?,0,0,0,0,0,0,0,0);";
}
Paskutinį kartą redagavo: 30 Gruodžio 2013 - 20:23