mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 00:35:06 +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
@@ -4,10 +4,21 @@ import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerMailData;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IPlayerMail;
|
||||
|
||||
public class PlayerMailData{
|
||||
public class PlayerMailData implements IPlayerMailData {
|
||||
private final PlayerData parent;
|
||||
public ArrayList<PlayerMail> playermail = new ArrayList<PlayerMail>();
|
||||
|
||||
public PlayerMailData() {
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
public PlayerMailData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
ArrayList<PlayerMail> newmail = new ArrayList<PlayerMail>();
|
||||
NBTTagList list = compound.getTagList("MailData", 10);
|
||||
@@ -39,4 +50,56 @@ public class PlayerMailData{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addMail(IPlayerMail mail) {
|
||||
playermail.add((PlayerMail) mail);
|
||||
}
|
||||
|
||||
public void removeMail(IPlayerMail mail) {
|
||||
playermail.remove((PlayerMail) mail);
|
||||
}
|
||||
|
||||
public boolean hasMail(IPlayerMail mail) {
|
||||
return playermail.contains((PlayerMail) mail);
|
||||
}
|
||||
|
||||
public IPlayerMail[] getAllMail() {
|
||||
return playermail.toArray(new IPlayerMail[0]);
|
||||
}
|
||||
|
||||
public IPlayerMail[] getUnreadMail() {
|
||||
ArrayList<IPlayerMail> mails = new ArrayList<>();
|
||||
|
||||
for (PlayerMail mail : playermail) {
|
||||
if (!mail.beenRead) {
|
||||
mails.add(mail);
|
||||
}
|
||||
}
|
||||
|
||||
return mails.toArray(new IPlayerMail[0]);
|
||||
}
|
||||
|
||||
public IPlayerMail[] getReadMail() {
|
||||
ArrayList<IPlayerMail> mails = new ArrayList<>();
|
||||
|
||||
for (PlayerMail mail : playermail) {
|
||||
if (mail.beenRead) {
|
||||
mails.add(mail);
|
||||
}
|
||||
}
|
||||
|
||||
return mails.toArray(new IPlayerMail[0]);
|
||||
}
|
||||
|
||||
public IPlayerMail[] getMailFrom(String sender) {
|
||||
ArrayList<IPlayerMail> mails = new ArrayList<>();
|
||||
|
||||
for (PlayerMail mail : playermail) {
|
||||
if (mail.sender.equals(sender)) {
|
||||
mails.add(mail);
|
||||
}
|
||||
}
|
||||
|
||||
return mails.toArray(new IPlayerMail[0]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user