2022-05-24 01:07:50 -05:00
|
|
|
package noppes.npcs.controllers.data;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
2022-06-12 01:26:23 -05:00
|
|
|
import noppes.npcs.scripted.interfaces.handler.IPlayerDialogData;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2022-06-12 01:26:23 -05:00
|
|
|
public class PlayerDialogData implements IPlayerDialogData {
|
|
|
|
|
private final PlayerData parent;
|
2018-09-13 12:03:28 -04:00
|
|
|
public HashSet<Integer> dialogsRead = new HashSet<Integer>();
|
2022-06-12 01:26:23 -05:00
|
|
|
|
|
|
|
|
public PlayerDialogData(PlayerData parent) {
|
|
|
|
|
this.parent = parent;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public void loadNBTData(NBTTagCompound compound) {
|
|
|
|
|
HashSet<Integer> dialogsRead = new HashSet<Integer>();
|
|
|
|
|
if(compound == null)
|
|
|
|
|
return;
|
|
|
|
|
NBTTagList list = compound.getTagList("DialogData", 10);
|
|
|
|
|
if(list == null){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < list.tagCount(); i++)
|
|
|
|
|
{
|
|
|
|
|
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
|
|
|
|
|
dialogsRead.add(nbttagcompound.getInteger("Dialog"));
|
|
|
|
|
}
|
|
|
|
|
this.dialogsRead = dialogsRead;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void saveNBTData(NBTTagCompound compound) {
|
|
|
|
|
NBTTagList list = new NBTTagList();
|
|
|
|
|
for(int dia : dialogsRead){
|
|
|
|
|
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
|
|
|
|
nbttagcompound.setInteger("Dialog", dia);
|
|
|
|
|
list.appendTag(nbttagcompound);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compound.setTag("DialogData", list);
|
|
|
|
|
}
|
2022-06-12 01:26:23 -05:00
|
|
|
|
|
|
|
|
public boolean hasReadDialog(int id) {
|
|
|
|
|
return dialogsRead.contains(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void readDialog(int id) {
|
|
|
|
|
dialogsRead.add(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void unreadDialog(int id) {
|
|
|
|
|
dialogsRead.remove(id);
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|