39 lines
980 B
Java
39 lines
980 B
Java
package io.reisub.dreambot.util;
|
|
|
|
import org.dreambot.api.methods.interactive.NPCs;
|
|
import org.dreambot.api.methods.interactive.Players;
|
|
import org.dreambot.api.wrappers.interactive.Character;
|
|
import org.dreambot.api.wrappers.interactive.NPC;
|
|
|
|
import javax.annotation.Nullable;
|
|
import java.util.List;
|
|
|
|
@SuppressWarnings("unused")
|
|
public class CNPC {
|
|
@Nullable
|
|
public static NPC getNPCInteractingWithPlayer(String name) {
|
|
List<NPC> npcs;
|
|
|
|
if (name.equals("")) {
|
|
npcs = NPCs.all();
|
|
} else {
|
|
npcs = NPCs.all(name);
|
|
}
|
|
|
|
for (NPC npc : npcs) {
|
|
Character c = npc.getInteractingCharacter();
|
|
|
|
if (c != null && c.getName() != null && c.getName().equals(Players.localPlayer().getName())) {
|
|
return npc;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
@Nullable
|
|
public static NPC getNPCInteractingWithPlayer() {
|
|
return getNPCInteractingWithPlayer("");
|
|
}
|
|
}
|