Jump to content
  • 0

java Null Pointer exception


Question

Posted

Hello,

 

I've an error with the BossRespawn.java (NPc that display if the RB is alive/dead.)

 

java.lang.NullPointerException
at custom.BossRespawn.BossRespawn.sendInfo(BossRespawn.java:59)
at custom.BossRespawn.BossRespawn.onFirstTalk(BossRespawn.java:45)
at com.l2jserver.gameserver.model.quest.Quest.notifyFirstTalk(Quest.java:526)
at handlers.actionhandlers.L2NpcAction.action(L2NpcAction.java:141)
at com.l2jserver.gameserver.model.L2Object.onAction(L2Object.java:280)
at com.l2jserver.gameserver.model.L2Object.onAction(L2Object.java:273)
at com.l2jserver.gameserver.network.clientpackets.Action.runImpl(Action.java:121)
at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:62)
at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1095)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

 

and the code

 

long delay = GrandBossManager.getInstance().getStatsSet(boss).getLong("respawn_time");

 

That's the line 59...

3 answers to this question

Recommended Posts

  • 0
Posted

!fr

 

Postes la classe complète, il manque un (== null), peut-être check d'abord si

GrandBossManager.getInstance().getStatsSet(boss)

est bien différent de null. Ca peut etre aussi "boss", voir autre chose...

  • 0
Posted

/*
* 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 custom.BossRespawn;


import javolution.text.TextBuilder;

import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.datatables.NpcTable;

public class BossRespawn extends Quest
{
private static final int NPC_ID = 65000;
private static final int[] BOSSES = {29001, 29006, 29014, 29019, 29020, 29022, 29028, 29045};

public BossRespawn(int questid, String name, String descr)
{
	super(questid, name, descr);
	addFirstTalkId(NPC_ID);
}

public String onFirstTalk(L2Npc npc, L2PcInstance pc)
{
	if(npc == null || pc == null)
		return null;

	if(npc.getNpcId() == NPC_ID)
	{
		sendInfo(pc);
	}
		return null;
}

private void sendInfo(L2PcInstance activeChar)
{
	TextBuilder tb = new TextBuilder();
	tb.append("<html><title>Grand Boss Info By Dleogr</title><body><br><center>");
	tb.append("<img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>");

	for(int boss : BOSSES)
	{
		String name = NpcTable.getInstance().getTemplate(boss).getName();
		long delay = GrandBossManager.getInstance().getStatsSet(boss).getLong("respawn_time");
		if (delay <= System.currentTimeMillis())
		{
			tb.append("<font color=\"00C3FF\">" + name + "</color>: " + "<font color=\"9CC300\">Is Alive</color>"+"<br1>");
		}
		else
		{
			int hours = (int) ((delay - System.currentTimeMillis()) / 1000 / 60 / 60);
			int mins = (int) (((delay - (hours * 60 * 60 * 1000)) - System.currentTimeMillis()) / 1000 / 60);
			int seconts = (int) (((delay - ((hours * 60 * 60 * 1000) + (mins * 60 * 1000))) - System.currentTimeMillis()) / 1000);
			tb.append("<font color=\"00C3FF\">" + name + "</color>" + "<font color=\"FFFFFF\">" +" " + "Respawn in :</color>" + " " + " <font color=\"32C332\">" + hours + " : " + mins + " : " + seconts + "</color><br1>");
		}
	}

	tb.append("<br><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>");
	tb.append("</center></body></html>");

	NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
	msg.setHtml(tb.toString());
	activeChar.sendPacket(msg);
}

public static void main(String[] args)
{
	new BossRespawn(-1, "BossRespawn", "custom");
}
}

 

[fr]J'ai changer le For method, en remplacant par de l'itératif

for (int i = 0; i < BOSSES.length; i++)
	{
		int boss = BOSSES[i];

 

En pensant que cela pouvait venir du fait qu'il sache pas dans quel case du tableau chercher, mais non x) [/fr]

  • 0
Posted

!fr

 

Ta liste de bosses, c'est bien TOUS des GrandBoss ?

29001, 29006, 29014, 29019, 29020, 29022, 29028, 29045

 

Comme tu peux voir, ça essaye de prendre le delay des Grand bosses.

long delay = GrandBossManager.getInstance().getStatsSet(boss).getLong("respawn_time");

 

Une autre possibilité, c'est que tu t'es planté d'ID et t'as rajouté une ID foireuse qui n'a rien à voir avec les GBs. Vérifies le type de mob dans npc.sql.

 

Finalement si ton but c'était de voir des boss NORMAUX, tu dois faire d'abord un check pour voir si boss instanceof grandboss / raidboss, et faire en fonction.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   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...