mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 10:19:08 +00:00
API Changes:
-Implemented interfaces for all jobs & roles. ScriptPlayer: -Added getData() function, which returns player data objects. IPlayerData: New class that holds all player data for modification. -Holds dialog, bank, quest, transport, faction, item giver, and mail data. -Also holds companion data, with functions has/set/getCompanion, and a getCompanionID function to differentiate companions.
This commit is contained in:
1 parent
587f63396f
commit
63a1525ee2
66 files changed
+1418
-207
No files matched your search
@@ -1,15 +1,25 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.controllers.GlobalDataController;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerItemGiverData;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobItemGiver;
|
||||
import noppes.npcs.scripted.roles.ScriptJobItemGiver;
|
||||
|
||||
public class PlayerItemGiverData{
|
||||
public class PlayerItemGiverData implements IPlayerItemGiverData {
|
||||
private final PlayerData parent;
|
||||
private HashMap<Integer, Long> itemgivers = new HashMap<Integer,Long>();
|
||||
private HashMap<Integer, Integer> chained = new HashMap<Integer,Integer>();
|
||||
|
||||
|
||||
public PlayerItemGiverData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
chained = NBTTags.getIntegerIntegerMap(compound.getTagList("ItemGiverChained", 10));
|
||||
itemgivers = NBTTags.getIntegerLongMap(compound.getTagList("ItemGiversList", 10));
|
||||
@@ -37,4 +47,29 @@ public class PlayerItemGiverData{
|
||||
public void setItemIndex(JobItemGiver jobItemGiver, int i) {
|
||||
chained.put(jobItemGiver.itemGiverId, i);
|
||||
}
|
||||
|
||||
public long getTime(IJobItemGiver jobItemGiver){
|
||||
return itemgivers.get(((JobItemGiver) jobItemGiver.getJobInterface()).itemGiverId);
|
||||
}
|
||||
|
||||
public void setTime(IJobItemGiver jobItemGiver, long day) {
|
||||
itemgivers.put(((JobItemGiver) jobItemGiver.getJobInterface()).itemGiverId, day);
|
||||
}
|
||||
|
||||
public boolean hasInteractedBefore(IJobItemGiver jobItemGiver) {
|
||||
return itemgivers.containsKey(((JobItemGiver) jobItemGiver.getJobInterface()).itemGiverId);
|
||||
}
|
||||
|
||||
public IJobItemGiver[] getItemGivers() {
|
||||
ArrayList<IJobItemGiver> list = new ArrayList<>();
|
||||
for (JobItemGiver jobItemGiver : GlobalDataController.instance.itemGivers.values()) {
|
||||
if (jobItemGiver.npc != null) {
|
||||
list.add(new ScriptJobItemGiver(jobItemGiver.npc));
|
||||
} else {
|
||||
list.add(new ScriptJobItemGiver(jobItemGiver));
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new IJobItemGiver[0]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user