mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 16:55:12 +00:00
get the name of the player who spawned this npc with soulstone
This commit is contained in:
1 parent
b7ad0ce29b
commit
9fef65b194
4 files changed
+26
-2
No files matched your search
@@ -52,6 +52,8 @@ public class DataAdvanced {
|
||||
public boolean attackOtherFactions = false;
|
||||
public boolean defendFaction = false;
|
||||
public boolean disablePitch = false;
|
||||
|
||||
public String soulStonePlayerName;
|
||||
|
||||
public DataAdvanced(EntityNPCInterface npc) {
|
||||
this.npc = npc;
|
||||
@@ -83,6 +85,8 @@ public class DataAdvanced {
|
||||
|
||||
compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs));
|
||||
|
||||
compound.setString("SoulStonePlayerName", soulStonePlayerName);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -113,6 +117,8 @@ public class DataAdvanced {
|
||||
factions.readFromNBT(compound.getCompoundTag("FactionPoints"));
|
||||
|
||||
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
|
||||
|
||||
soulStonePlayerName = compound.getString("SoulStonePlayerName");
|
||||
}
|
||||
|
||||
private HashMap<Integer, DialogOption> getDialogs(NBTTagList tagList) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ItemSoulstoneFilled extends Item {
|
||||
npc.ai.startPos = new int[]{x, y, z};
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
npc.setPosition((float)x + 0.5F, npc.getStartYPos(), (float)z + 0.5F);
|
||||
|
||||
npc.advanced.soulStonePlayerName = player.getDisplayName();
|
||||
if(npc.advanced.role == EnumRoleType.Companion && player != null){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
if(data.hasCompanion())
|
||||
|
||||
@@ -862,6 +862,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
npc.stats.canDespawn = canDespawn;
|
||||
npc.stats.playerSetCanDespawn = canDespawn;
|
||||
}
|
||||
|
||||
public boolean spawnedFromSoulStone() {
|
||||
return npc.advanced.soulStonePlayerName != null;
|
||||
}
|
||||
|
||||
public String getSoulStonePlayerName() {
|
||||
return npc.advanced.soulStonePlayerName;
|
||||
}
|
||||
|
||||
public void giveItem(IPlayer player, IItemStack item){
|
||||
npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack());
|
||||
|
||||
@@ -623,7 +623,17 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
|
||||
* @param canDespawn True if the NPC should naturally despawn. False otherwise.
|
||||
*/
|
||||
void setNaturallyDespawns(boolean canDespawn);
|
||||
|
||||
|
||||
/**
|
||||
* @return true if this npc was spawned by a player using soulstone
|
||||
*/
|
||||
boolean spawnedFromSoulStone();
|
||||
|
||||
/**
|
||||
* @return the name of the player who spawned this npc using soulstone. null if not spawned by soulstone
|
||||
*/
|
||||
String getSoulStonePlayerName();
|
||||
|
||||
/**
|
||||
* @param player The player to give the item to
|
||||
* @param item The item given to the player
|
||||
|
||||
Reference in new issue
Block a user