forked from 2009Scape/Server
Fixed exception occurring when an NPC has no jobs that can be assigned to the player
Fixed an issue that caused killing jobs not to work without relogging first
This commit is contained in:
parent
6dd30896f0
commit
931409ba97
2 changed files with 16 additions and 10 deletions
|
|
@ -178,13 +178,7 @@ public abstract class Entity extends Node {
|
|||
*/
|
||||
public void unhook(EventHook hook)
|
||||
{
|
||||
GameWorld.getPulser().submit(new Pulse() {
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
for(ArrayList<EventHook> s : hooks.values()) s.remove(hook);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
for(ArrayList<EventHook> s : hooks.values()) s.remove(hook);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import SlayingJob
|
|||
import api.*
|
||||
import api.events.EventHook
|
||||
import api.events.NPCKillEvent
|
||||
import core.game.content.dialogue.FacialExpression
|
||||
import core.game.node.entity.Entity
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
|
|
@ -85,9 +86,20 @@ class WorkForInteractionListener : InteractionListener, LoginListener {
|
|||
|
||||
val type = typeMap[node.id] ?: return@on false
|
||||
jobId = if(type == 0) {
|
||||
var job = gatheringMap[node.id]?.filter { checkRequirement(player, it) }?.random()
|
||||
amount = job?.getAmount() ?: 0
|
||||
job?.ordinal ?: 0
|
||||
val job = gatheringMap[node.id]?.filter { checkRequirement(player, it) }?.randomOrNull()
|
||||
|
||||
if (job == null) {
|
||||
sendNPCDialogue(
|
||||
player,
|
||||
node.id,
|
||||
"I'm sorry, I don't currently have any jobs that you're qualified for.",
|
||||
FacialExpression.HALF_THINKING
|
||||
)
|
||||
return@on true
|
||||
}
|
||||
|
||||
amount = job.getAmount()
|
||||
job.ordinal
|
||||
} else {
|
||||
SlayingJob.values().random().ordinal.also { amount = SlayingJob.values()[it].getAmount() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue