RoleFollowers will not despawn if they have an owner

RoleFollowers canDespawn field will be changed back to the value set by the player in the gui/api if they stop following a player
This commit is contained in:
1whohears committed 2022-05-26 03:00:49 -05:00
1 parent 6698e8619c
commit 77ee403720
4 files changed
+9 -2

No files matched your search

+5 -2
View File
@@ -27,6 +27,7 @@ public class DataStats {
public int spawnCycle = 0;
public boolean hideKilledBody = false;
public boolean canDespawn = false;
public boolean playerSetCanDespawn = false;
public Resistances resistances = new Resistances();
@@ -110,8 +111,9 @@ public class DataStats {
compound.setBoolean("CanDrown", canDrown);
compound.setBoolean("BurnInSun", burnInSun);
compound.setBoolean("NoFallDamage", noFallDamage);
compound.setBoolean("CanDespawn", canDespawn);
compound.setBoolean("AttackInvisible", attackInvisible);
compound.setBoolean("CanDespawn", canDespawn);
compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn);
return compound;
}
@@ -169,8 +171,9 @@ public class DataStats {
canDrown = compound.getBoolean("CanDrown");
burnInSun = compound.getBoolean("BurnInSun");
noFallDamage = compound.getBoolean("NoFallDamage");
canDespawn = compound.getBoolean("CanDespawn");
attackInvisible = compound.getBoolean("AttackInvisible");
canDespawn = compound.getBoolean("CanDespawn");
playerSetCanDespawn = compound.getBoolean("PlayerSetCanDespawn");
npc.setImmuneToFire(immuneToFire);
}
@@ -55,6 +55,7 @@ public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListe
}
else if(button.id == 1){
stats.canDespawn = button.getValue() == 1;
stats.playerSetCanDespawn = stats.canDespawn;
}
else if(button.id == 4){
stats.hideKilledBody = button.getValue() == 1;
@@ -104,6 +104,7 @@ public class RoleFollower extends RoleInterface{
daysHired = 0;
hiredTime = 0;
isFollowing = true;
npc.stats.canDespawn = npc.stats.playerSetCanDespawn;
}
public int getDaysLeft(){
@@ -150,6 +151,7 @@ public class RoleFollower extends RoleInterface{
if(ownerUUID == null || id == null || !ownerUUID.equals(id))
killed();
ownerUUID = id.toString();
npc.stats.canDespawn = false;
}
@@ -867,6 +867,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public void setNaturallyDespawns(boolean canDespawn) {
npc.stats.canDespawn = canDespawn;
npc.stats.playerSetCanDespawn = canDespawn;
}
public void giveItem(ScriptPlayer player, ScriptItemStack item){