mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 05:15:11 +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
@@ -296,6 +296,7 @@ public class CustomNpcs {
|
||||
@EventHandler
|
||||
public void stopped(FMLServerStoppedEvent event){
|
||||
ServerCloneController.Instance = null;
|
||||
GlobalDataController.instance.saveData();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.GlobalDataController;
|
||||
import noppes.npcs.controllers.data.DialogOption;
|
||||
import noppes.npcs.controllers.data.FactionOptions;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
@@ -195,8 +196,25 @@ public class DataAdvanced {
|
||||
npc.jobInterface = new JobHealer(npc);
|
||||
else if (job == EnumJobType.Guard && !(npc.jobInterface instanceof JobGuard))
|
||||
npc.jobInterface = new JobGuard(npc);
|
||||
else if (job == EnumJobType.ItemGiver && !(npc.jobInterface instanceof JobItemGiver))
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
else if (job == EnumJobType.ItemGiver && !(npc.jobInterface instanceof JobItemGiver)) {
|
||||
if (!npc.isRemote()) {
|
||||
if (npc.itemGiverId > 0 && GlobalDataController.instance.itemGivers.containsKey(npc.itemGiverId)) {
|
||||
GlobalDataController.instance.itemGivers.get(npc.itemGiverId).npc = npc;
|
||||
npc.jobInterface = GlobalDataController.instance.itemGivers.get(npc.itemGiverId);
|
||||
} else {
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
if (npc.itemGiverId == -1) {
|
||||
((JobItemGiver) npc.jobInterface).itemGiverId = GlobalDataController.instance.incrementItemGiverId();
|
||||
} else {
|
||||
((JobItemGiver) npc.jobInterface).itemGiverId = npc.itemGiverId;
|
||||
}
|
||||
GlobalDataController.instance.itemGivers.put(((JobItemGiver) npc.jobInterface).itemGiverId, (JobItemGiver) npc.jobInterface);
|
||||
npc.itemGiverId = ((JobItemGiver) npc.jobInterface).itemGiverId;
|
||||
}
|
||||
} else {
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
}
|
||||
}
|
||||
else if (job == EnumJobType.Follower && !(npc.jobInterface instanceof JobFollower))
|
||||
npc.jobInterface = new JobFollower(npc);
|
||||
else if (job == EnumJobType.Spawner && !(npc.jobInterface instanceof JobSpawner))
|
||||
|
||||
@@ -629,7 +629,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportSave){
|
||||
int cat = buffer.readInt();
|
||||
TransportLocation location = TransportController.getInstance().saveLocation(cat,Server.readNBT(buffer),player, npc);
|
||||
TransportLocation location = TransportController.getInstance().saveLocation(cat,Server.readNBT(buffer), npc);
|
||||
if(location != null){
|
||||
if(npc.advanced.role != EnumRoleType.Transporter)
|
||||
return;
|
||||
|
||||
@@ -3,15 +3,19 @@ package noppes.npcs.controllers;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
|
||||
public class GlobalDataController {
|
||||
public static GlobalDataController instance;
|
||||
|
||||
private int itemGiverId = 0;
|
||||
public HashMap<Integer, JobItemGiver> itemGivers = new HashMap<>();
|
||||
|
||||
public GlobalDataController(){
|
||||
instance = this;
|
||||
@@ -37,9 +41,17 @@ public class GlobalDataController {
|
||||
}
|
||||
}
|
||||
}
|
||||
private void loadData(File file) throws Exception{
|
||||
private void loadData(File file) throws Exception {
|
||||
NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
itemGiverId = nbttagcompound1.getInteger("itemGiverId");
|
||||
|
||||
NBTTagList jobList = nbttagcompound1.getTagList("ItemGivers", 10);
|
||||
for (int i = 0; i < jobList.tagCount(); i++) {
|
||||
NBTTagCompound compound = jobList.getCompoundTagAt(i);
|
||||
JobItemGiver jobItemGiver = new JobItemGiver();
|
||||
jobItemGiver.readFromNBT(compound);
|
||||
itemGivers.put(jobItemGiver.itemGiverId, jobItemGiver);
|
||||
}
|
||||
}
|
||||
public void saveData(){
|
||||
try {
|
||||
@@ -47,6 +59,14 @@ public class GlobalDataController {
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("itemGiverId", itemGiverId);
|
||||
|
||||
NBTTagList jobList = new NBTTagList();
|
||||
for (JobItemGiver jobItemGiver : itemGivers.values()) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
jobItemGiver.writeToNBT(compound);
|
||||
jobList.appendTag(compound);
|
||||
}
|
||||
nbttagcompound.setTag("ItemGivers", jobList);
|
||||
|
||||
File file = new File(saveDir, "global.dat_new");
|
||||
File file1 = new File(saveDir, "global.dat_old");
|
||||
@@ -72,7 +92,6 @@ public class GlobalDataController {
|
||||
}
|
||||
public int incrementItemGiverId(){
|
||||
itemGiverId++;
|
||||
saveData();
|
||||
return itemGiverId;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,10 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
@@ -17,8 +20,11 @@ import noppes.npcs.controllers.data.TransportCategory;
|
||||
import noppes.npcs.controllers.data.TransportLocation;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.interfaces.handler.ITransportHandler;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportCategory;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
|
||||
|
||||
public class TransportController {
|
||||
public class TransportController implements ITransportHandler {
|
||||
private HashMap<Integer,TransportLocation> locations = new HashMap<Integer, TransportLocation>();
|
||||
public HashMap<Integer,TransportCategory> categories = new HashMap<Integer, TransportCategory>();
|
||||
|
||||
@@ -131,7 +137,7 @@ public class TransportController {
|
||||
|
||||
return null;
|
||||
}
|
||||
private int getUniqueIdLocation() {
|
||||
public int getUniqueIdLocation() {
|
||||
if(lastUsedID == 0){
|
||||
for(int catid : locations.keySet())
|
||||
if(catid > lastUsedID)
|
||||
@@ -219,7 +225,27 @@ public class TransportController {
|
||||
public static TransportController getInstance(){
|
||||
return instance;
|
||||
}
|
||||
public TransportLocation saveLocation(int categoryId, NBTTagCompound compound, EntityPlayerMP player, EntityNPCInterface npc){
|
||||
|
||||
public TransportLocation saveLocation(int categoryId, TransportLocation location){
|
||||
TransportCategory category = categories.get(categoryId);
|
||||
if(category == null)
|
||||
return null;
|
||||
location.category = category;
|
||||
if(location.id < 0 || !locations.get(location.id).name.equals(location.name)){
|
||||
while(containsLocationName(location.name))
|
||||
location.name += "_";
|
||||
}
|
||||
if(location.id < 0)
|
||||
location.id = getUniqueIdLocation();
|
||||
|
||||
category.locations.put(location.id, location);
|
||||
locations.put(location.id, location);
|
||||
saveCategories();
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public TransportLocation saveLocation(int categoryId, NBTTagCompound compound, EntityNPCInterface npc){
|
||||
TransportCategory category = categories.get(categoryId);
|
||||
if(category == null || npc.advanced.role != EnumRoleType.Transporter)
|
||||
return null;
|
||||
@@ -243,4 +269,32 @@ public class TransportController {
|
||||
return location;
|
||||
}
|
||||
|
||||
public ITransportCategory[] categories() {
|
||||
return (new ArrayList<>(categories.values())).toArray(new ITransportCategory[0]);
|
||||
}
|
||||
|
||||
public void createCategory(String title) {
|
||||
this.saveCategory(title, -1);
|
||||
}
|
||||
|
||||
public ITransportCategory getCategory(String title) {
|
||||
TransportCategory category = null;
|
||||
for (TransportCategory c : categories.values()) {
|
||||
if (c.title.equals(title)) {
|
||||
category = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
public void removeCategory(String title) {
|
||||
for (Map.Entry<Integer,TransportCategory> entry : categories.entrySet()) {
|
||||
if (entry.getValue().title.equals(title)) {
|
||||
categories.remove(entry.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,15 @@ import java.util.HashMap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerBankData;
|
||||
|
||||
public class PlayerBankData{
|
||||
public class PlayerBankData implements IPlayerBankData {
|
||||
private final PlayerData parent;
|
||||
public HashMap<Integer,BankData> banks;
|
||||
public PlayerBankData(){
|
||||
|
||||
public PlayerBankData(PlayerData parent){
|
||||
banks = new HashMap<Integer,BankData>();
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
|
||||
@@ -15,19 +15,23 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
import noppes.npcs.entity.data.DataTimers;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.handler.*;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class PlayerData implements IExtendedEntityProperties{
|
||||
public PlayerDialogData dialogData = new PlayerDialogData();
|
||||
public PlayerBankData bankData = new PlayerBankData();
|
||||
public PlayerQuestData questData = new PlayerQuestData();
|
||||
public PlayerTransportData transportData = new PlayerTransportData();
|
||||
public PlayerFactionData factionData = new PlayerFactionData();
|
||||
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData();
|
||||
public PlayerMailData mailData = new PlayerMailData();
|
||||
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
public PlayerDialogData dialogData = new PlayerDialogData(this);
|
||||
public PlayerBankData bankData = new PlayerBankData(this);
|
||||
public PlayerQuestData questData = new PlayerQuestData(this);
|
||||
public PlayerTransportData transportData = new PlayerTransportData(this);
|
||||
public PlayerFactionData factionData = new PlayerFactionData(this);
|
||||
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(this);
|
||||
public PlayerMailData mailData = new PlayerMailData(this);
|
||||
|
||||
public DataTimers timers = new DataTimers(this);
|
||||
public DataSkinOverlays skinOverlays = new DataSkinOverlays(this);
|
||||
|
||||
@@ -245,4 +249,48 @@ public class PlayerData implements IExtendedEntityProperties{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompanion(ICustomNpc npc) {
|
||||
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
|
||||
}
|
||||
|
||||
public ICustomNpc getCompanion() {
|
||||
return (ICustomNpc) NpcAPI.Instance().getIEntity(activeCompanion);
|
||||
}
|
||||
|
||||
public int getCompanionID() {
|
||||
return companionID;
|
||||
}
|
||||
|
||||
public IPlayerDialogData getDialogData() {
|
||||
return dialogData;
|
||||
}
|
||||
|
||||
public IPlayerBankData getBankData() {
|
||||
return bankData;
|
||||
}
|
||||
|
||||
public IPlayerQuestData getQuestData() {
|
||||
return questData;
|
||||
}
|
||||
|
||||
public IPlayerTransportData getTransportData() {
|
||||
return transportData;
|
||||
}
|
||||
|
||||
public IPlayerFactionData getFactionData() {
|
||||
return factionData;
|
||||
}
|
||||
|
||||
public IPlayerItemGiverData getItemGiverData() {
|
||||
return itemgiverData;
|
||||
}
|
||||
|
||||
public IPlayerMailData getMailData() {
|
||||
return mailData;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
PlayerDataController.instance.savePlayerData(this);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,15 @@ import java.util.HashSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerDialogData;
|
||||
|
||||
public class PlayerDialogData{
|
||||
public class PlayerDialogData implements IPlayerDialogData {
|
||||
private final PlayerData parent;
|
||||
public HashSet<Integer> dialogsRead = new HashSet<Integer>();
|
||||
|
||||
public PlayerDialogData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
HashSet<Integer> dialogsRead = new HashSet<Integer>();
|
||||
@@ -35,5 +41,16 @@ public class PlayerDialogData{
|
||||
|
||||
compound.setTag("DialogData", list);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,20 @@ import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.FactionEvent;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerFactionData;
|
||||
|
||||
public class PlayerFactionData {
|
||||
public class PlayerFactionData implements IPlayerFactionData {
|
||||
private final PlayerData parent;
|
||||
public HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
|
||||
|
||||
|
||||
public PlayerFactionData() {
|
||||
parent = null;
|
||||
}
|
||||
|
||||
public PlayerFactionData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
|
||||
if(compound == null)
|
||||
@@ -79,4 +89,19 @@ public class PlayerFactionData {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public int getPoints(int id) {
|
||||
return this.getFactionPoints(id);
|
||||
}
|
||||
|
||||
public void addPoints(int id, int points) {
|
||||
if (parent != null) {
|
||||
this.increasePoints(id, points, parent.player);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPoints(int id, int points) {
|
||||
if (parent != null) {
|
||||
increasePoints(id, points-getFactionPoints(id), parent.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,17 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IPlayerMail;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public class PlayerMail implements IInventory{
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlayerMail implements IInventory, IPlayerMail {
|
||||
public String subject = "";
|
||||
public String sender = "";
|
||||
public NBTTagCompound message = new NBTTagCompound();
|
||||
@@ -202,4 +209,99 @@ public class PlayerMail implements IInventory{
|
||||
mail.readNBT(writeNBT());
|
||||
return mail;
|
||||
}
|
||||
|
||||
public void setPageText(String[] pages) {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
for (String text : pages) {
|
||||
bookPages.appendTag(new NBTTagString(text));
|
||||
}
|
||||
|
||||
message.setTag("pages", bookPages);
|
||||
}
|
||||
|
||||
public String[] getPageText() {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
|
||||
if(message.hasKey("pages"))
|
||||
bookPages = message.getTagList("pages", 8);
|
||||
|
||||
if (bookPages != null)
|
||||
{
|
||||
bookPages = (NBTTagList)bookPages.copy();
|
||||
ArrayList<String> pageStrings = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < bookPages.tagCount(); i++) {
|
||||
pageStrings.add(bookPages.getStringTagAt(i));
|
||||
}
|
||||
|
||||
return pageStrings.toArray(new String[0]);
|
||||
} else {
|
||||
return new String[]{""};
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
|
||||
if(message.hasKey("pages"))
|
||||
bookPages = message.getTagList("pages", 8);
|
||||
|
||||
int bookTotalPages = 0;
|
||||
if (bookPages != null)
|
||||
{
|
||||
bookPages = (NBTTagList)bookPages.copy();
|
||||
bookTotalPages = bookPages.tagCount();
|
||||
|
||||
if (bookTotalPages < 1)
|
||||
{
|
||||
bookTotalPages = 1;
|
||||
}
|
||||
|
||||
return bookTotalPages;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public long getTimePast() {
|
||||
return timePast;
|
||||
}
|
||||
|
||||
public long getTimeSent() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public IItemStack[] getItems() {
|
||||
ArrayList<IItemStack> list = new ArrayList<>();
|
||||
for (ItemStack itemStack : items) {
|
||||
list.add(NpcAPI.Instance().getIItemStack(itemStack));
|
||||
}
|
||||
|
||||
return list.toArray(new IItemStack[0]);
|
||||
}
|
||||
|
||||
public void setItems(IItemStack[] items) {
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
for (IItemStack itemStack : items) {
|
||||
list.add(itemStack.getMCItemStack());
|
||||
}
|
||||
|
||||
this.items = list.toArray(new ItemStack[0]);
|
||||
}
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -16,14 +18,20 @@ import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.quests.QuestInterface;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerQuestData;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
|
||||
public class PlayerQuestData {
|
||||
public class PlayerQuestData implements IPlayerQuestData {
|
||||
private final PlayerData parent;
|
||||
public IQuest trackedQuest = null;
|
||||
|
||||
public HashMap<Integer,QuestData> activeQuests = new HashMap<Integer,QuestData>();
|
||||
public HashMap<Integer,Long> finishedQuests = new HashMap<Integer,Long>();
|
||||
|
||||
|
||||
public PlayerQuestData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound mainCompound) {
|
||||
if(mainCompound == null)
|
||||
return;
|
||||
@@ -129,5 +137,76 @@ public class PlayerQuestData {
|
||||
return bo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IQuest getTrackedQuest() {
|
||||
return trackedQuest;
|
||||
}
|
||||
|
||||
public void startQuest(int id) {
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
if(activeQuests.containsKey(id))
|
||||
return;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
activeQuests.put(id, questdata);
|
||||
Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
|
||||
public void finishQuest(int id) {
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
finishedQuests.put(id, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void stopQuest(int id) {
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
activeQuests.remove(id);
|
||||
}
|
||||
|
||||
public void removeQuest(int id) {
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
activeQuests.remove(id);
|
||||
finishedQuests.remove(id);
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(int id){
|
||||
return finishedQuests.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean hasActiveQuest(int id){
|
||||
return activeQuests.containsKey(id);
|
||||
}
|
||||
|
||||
public IQuest[] getActiveQuests() {
|
||||
List<IQuest> quests = new ArrayList<>();
|
||||
|
||||
for (int id : activeQuests.keySet()) {
|
||||
IQuest quest = (IQuest) QuestController.instance.quests.get(id);
|
||||
if (quest != null) {
|
||||
quests.add(quest);
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuest[])quests.toArray(new IQuest[0]);
|
||||
}
|
||||
|
||||
public IQuest[] getFinishedQuests() {
|
||||
List<IQuest> quests = new ArrayList<>();
|
||||
|
||||
for (int id : finishedQuests.keySet()) {
|
||||
IQuest quest = (IQuest) QuestController.instance.quests.get(id);
|
||||
if (quest != null) {
|
||||
quests.add(quest);
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuest[])quests.toArray(new IQuest[0]);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,22 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerTransportData;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
|
||||
|
||||
public class PlayerTransportData{
|
||||
public class PlayerTransportData implements IPlayerTransportData {
|
||||
private final PlayerData parent;
|
||||
public HashSet<Integer> transports = new HashSet<Integer>();
|
||||
|
||||
public PlayerTransportData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
HashSet<Integer> dialogsRead = new HashSet<Integer>();
|
||||
if(compound == null)
|
||||
@@ -35,5 +44,34 @@ public class PlayerTransportData{
|
||||
|
||||
compound.setTag("TransportData", list);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasTransport(int id) {
|
||||
return transports.contains(id);
|
||||
}
|
||||
|
||||
public void addTransport(int id) {
|
||||
transports.add(id);
|
||||
}
|
||||
|
||||
public void addTransport(ITransportLocation location) {
|
||||
transports.add(location.getId());
|
||||
}
|
||||
|
||||
public ITransportLocation getTransport(int id) {
|
||||
return TransportController.getInstance().getTransport(id);
|
||||
}
|
||||
|
||||
public ITransportLocation[] getTransports() {
|
||||
ArrayList<ITransportLocation> list = new ArrayList<>();
|
||||
for (int id : transports) {
|
||||
ITransportLocation location = TransportController.getInstance().getTransport(id);
|
||||
list.add(location);
|
||||
}
|
||||
|
||||
return list.toArray(new ITransportLocation[0]);
|
||||
}
|
||||
|
||||
public void removeTransport(int id) {
|
||||
transports.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,24 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportCategory;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
|
||||
|
||||
public class TransportCategory {
|
||||
public class TransportCategory implements ITransportCategory {
|
||||
public int id = -1;
|
||||
public String title = "";
|
||||
public HashMap<Integer,TransportLocation> locations;
|
||||
|
||||
public TransportCategory(){
|
||||
locations = new HashMap<Integer, TransportLocation>();
|
||||
}
|
||||
|
||||
public Vector<TransportLocation> getDefaultLocations() {
|
||||
Vector<TransportLocation> list = new Vector<TransportLocation>();
|
||||
for(TransportLocation loc : locations.values())
|
||||
@@ -47,4 +53,53 @@ public class TransportCategory {
|
||||
}
|
||||
compound.setTag("CategoryLocations", locs);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void addLocation(String name) {
|
||||
int id = TransportController.getInstance().getUniqueIdLocation();
|
||||
TransportLocation location = new TransportLocation();
|
||||
location.id = id;
|
||||
location.name = name;
|
||||
location.category = this;
|
||||
|
||||
TransportController.getInstance().setLocation(location);
|
||||
}
|
||||
|
||||
public ITransportLocation getLocation(String name) {
|
||||
TransportLocation location = null;
|
||||
for (TransportLocation l : locations.values()) {
|
||||
if (l.getName().equals(name)) {
|
||||
location = l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public void removeLocation(String name) {
|
||||
int id = -1;
|
||||
for (Map.Entry<Integer,TransportLocation> entry : locations.entrySet()) {
|
||||
if (entry.getValue().getName().equals(name)) {
|
||||
id = entry.getKey();;
|
||||
locations.remove(entry.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id >= 0) {
|
||||
TransportController.getInstance().removeLocation(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
|
||||
|
||||
public class TransportLocation {
|
||||
public class TransportLocation implements ITransportLocation {
|
||||
public int id = -1;
|
||||
public String name = "default name";
|
||||
public double posX;
|
||||
@@ -41,4 +43,54 @@ public class TransportLocation {
|
||||
public boolean isDefault() {
|
||||
return type == 1;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setDimension(int dimension) {
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public int getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y, int z) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return posX;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return posY;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return posZ;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
TransportController.getInstance().saveLocation(this.category.id, this);
|
||||
}
|
||||
}
|
||||
@@ -62,18 +62,14 @@ import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPotionType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.constants.EnumStandingType;
|
||||
import noppes.npcs.controllers.GlobalDataController;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.LinkedNpcController;
|
||||
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.entity.data.DataTimers;
|
||||
import noppes.npcs.roles.JobBard;
|
||||
import noppes.npcs.roles.JobFollower;
|
||||
import noppes.npcs.roles.JobInterface;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
import noppes.npcs.roles.RoleInterface;
|
||||
import noppes.npcs.roles.*;
|
||||
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||
import noppes.npcs.scripted.event.*;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
@@ -111,6 +107,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
public long totalTicksAlive = 0;
|
||||
private int taskCount = 1;
|
||||
public int lastInteract = 0;
|
||||
public int itemGiverId = 0;
|
||||
|
||||
public Faction faction; //should only be used server side
|
||||
|
||||
@@ -936,6 +933,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
ai.readToNBT(compound);
|
||||
script.readFromNBT(compound);
|
||||
timers.readFromNBT(compound);
|
||||
if (compound.hasKey("ItemGiverId")) {
|
||||
itemGiverId = compound.getInteger("ItemGiverId");
|
||||
} else {
|
||||
itemGiverId = -1;
|
||||
}
|
||||
advanced.readToNBT(compound);
|
||||
if (advanced.role != EnumRoleType.None && roleInterface != null)
|
||||
roleInterface.readFromNBT(compound);
|
||||
|
||||
@@ -35,6 +35,11 @@ public class JobItemGiver extends JobInterface{
|
||||
private List<EntityPlayer> toCheck;
|
||||
public Availability availability = new Availability();
|
||||
|
||||
public JobItemGiver() {
|
||||
super(null);
|
||||
inventory = new NpcMiscInventory(9);
|
||||
}
|
||||
|
||||
public JobItemGiver(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
inventory = new NpcMiscInventory(9);
|
||||
@@ -61,10 +66,6 @@ public class JobItemGiver extends JobInterface{
|
||||
cooldown = nbttagcompound.getInteger("igCooldown");
|
||||
lines = NBTTags.getStringList(nbttagcompound.getTagList("igLines", 10));
|
||||
inventory.setFromNBT(nbttagcompound.getCompoundTag("igJobInventory"));
|
||||
|
||||
if(itemGiverId == 0 && GlobalDataController.instance != null)
|
||||
itemGiverId = GlobalDataController.instance.incrementItemGiverId();
|
||||
|
||||
availability.readFromNBT(nbttagcompound.getCompoundTag("igAvailability"));
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ public class JobItemGiver extends JobInterface{
|
||||
return map;
|
||||
}
|
||||
|
||||
private boolean giveItems(EntityPlayer player){
|
||||
public boolean giveItems(EntityPlayer player){
|
||||
PlayerItemGiverData data = PlayerDataController.instance.getPlayerData(player).itemgiverData;
|
||||
if(!canPlayerInteract(data)){
|
||||
return false;
|
||||
@@ -162,7 +163,7 @@ public class JobItemGiver extends JobInterface{
|
||||
private int getDay(){
|
||||
return (int) (npc.worldObj.getTotalWorldTime() / 24000L);
|
||||
}
|
||||
private boolean canPlayerInteract(PlayerItemGiverData data) {
|
||||
public boolean canPlayerInteract(PlayerItemGiverData data) {
|
||||
if(inventory.items.isEmpty())
|
||||
return false;
|
||||
if(isOnTimer()){
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -93,6 +94,10 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return ServerCloneController.Instance;
|
||||
}
|
||||
|
||||
public ITransportHandler getLocations() {
|
||||
return TransportController.getInstance();
|
||||
}
|
||||
|
||||
public IEntity getIEntity(Entity entity) {
|
||||
if(entity == null)
|
||||
return null;
|
||||
@@ -121,6 +126,18 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity[] getLoadedEntities() {
|
||||
ArrayList<IEntity> list = new ArrayList<>();
|
||||
|
||||
for (IWorld world : worldCache.values()) {
|
||||
for (Object obj : world.getMCWorld().loadedEntityList) {
|
||||
list.add(NpcAPI.Instance().getIEntity((Entity) obj));
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
public IBlock getIBlock(World world, BlockPos pos) {
|
||||
return new ScriptBlock(world, world.getBlock(pos.getX(),pos.getY(),pos.getZ()), pos);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -181,6 +178,15 @@ public class ScriptWorld implements IWorld {
|
||||
return world.countEntities(entity.getMCEntity().getClass());
|
||||
}
|
||||
|
||||
public IEntity[] getLoadedEntities() {
|
||||
ArrayList<IEntity> list = new ArrayList<>();
|
||||
for (Object obj : world.loadedEntityList) {
|
||||
list.add(NpcAPI.Instance().getIEntity((Entity) obj));
|
||||
}
|
||||
|
||||
return list.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
public void setTileEntity(int x, int y, int z, ITileEntity tileEntity){
|
||||
world.setTileEntity(x,y,z,tileEntity.getMCTileEntity());
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.interfaces.IParticle;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerData;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IContainer;
|
||||
@@ -557,7 +558,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return player.isBlocking();
|
||||
}
|
||||
|
||||
private PlayerData getData() {
|
||||
public PlayerData getData() {
|
||||
if (this.data == null) {
|
||||
this.data = PlayerDataController.instance.getPlayerData(player);
|
||||
}
|
||||
@@ -566,7 +567,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
}
|
||||
|
||||
public IQuest[] getActiveQuests() {
|
||||
PlayerQuestData data = this.getData().questData;
|
||||
PlayerQuestData data = (PlayerQuestData) this.getData().getQuestData();
|
||||
List<IQuest> quests = new ArrayList();
|
||||
Iterator var3 = data.activeQuests.keySet().iterator();
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ public abstract class AbstractNpcAPI {
|
||||
|
||||
public abstract ICloneHandler getClones();
|
||||
|
||||
public abstract ITransportHandler getLocations();
|
||||
|
||||
public abstract ICustomNpc createNPC(World var1);
|
||||
|
||||
/**
|
||||
@@ -65,6 +67,8 @@ public abstract class AbstractNpcAPI {
|
||||
|
||||
public abstract IEntity getIEntity(Entity var1);
|
||||
|
||||
public abstract IEntity[] getLoadedEntities();
|
||||
|
||||
public abstract IBlock getIBlock(World var1, BlockPos var2);
|
||||
|
||||
public abstract IBlock getIBlock(World world, Block block, BlockPos pos);
|
||||
@@ -85,6 +89,8 @@ public abstract class AbstractNpcAPI {
|
||||
|
||||
public abstract IDamageSource getIDamageSource(DamageSource var1);
|
||||
|
||||
public abstract IDamageSource getIDamageSource(IEntity entity);
|
||||
|
||||
public abstract EventBus events();
|
||||
|
||||
public abstract File getGlobalDir();
|
||||
@@ -137,6 +143,8 @@ public abstract class AbstractNpcAPI {
|
||||
|
||||
public abstract INbt getINbt(NBTTagCompound nbtTagCompound);
|
||||
|
||||
public abstract INbt stringToNbt(String str);
|
||||
|
||||
public abstract IPlayer[] getAllServerPlayers();
|
||||
|
||||
public abstract IItemStack createItem(String id, int damage, int size);
|
||||
|
||||
@@ -98,6 +98,8 @@ public interface IWorld {
|
||||
*/
|
||||
int countEntities(IEntity entity);
|
||||
|
||||
IEntity[] getLoadedEntities();
|
||||
|
||||
/**
|
||||
* Sets the block's tile entity at the given position.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import noppes.npcs.scripted.entity.ScriptDBCPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerData;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
@@ -228,6 +229,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
|
||||
boolean blocking();
|
||||
|
||||
public IPlayerData getData();
|
||||
|
||||
IQuest[] getActiveQuests();
|
||||
|
||||
IContainer getOpenContainer();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
public interface IPlayerBankData {
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
|
||||
public interface IPlayerData {
|
||||
|
||||
void setCompanion(ICustomNpc npc);
|
||||
|
||||
ICustomNpc getCompanion();
|
||||
|
||||
boolean hasCompanion();
|
||||
|
||||
int getCompanionID();
|
||||
|
||||
IPlayerDialogData getDialogData();
|
||||
|
||||
IPlayerBankData getBankData();
|
||||
|
||||
IPlayerQuestData getQuestData();
|
||||
|
||||
IPlayerTransportData getTransportData();
|
||||
|
||||
IPlayerFactionData getFactionData();
|
||||
|
||||
IPlayerItemGiverData getItemGiverData();
|
||||
|
||||
IPlayerMailData getMailData();
|
||||
|
||||
void save();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
public interface IPlayerDialogData {
|
||||
|
||||
boolean hasReadDialog(int id);
|
||||
|
||||
void readDialog(int id);
|
||||
|
||||
void unreadDialog(int id);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
public interface IPlayerFactionData {
|
||||
|
||||
int getPoints(int id);
|
||||
|
||||
void addPoints(int id, int points);
|
||||
|
||||
void setPoints(int id, int points);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobItemGiver;
|
||||
|
||||
public interface IPlayerItemGiverData {
|
||||
|
||||
long getTime(IJobItemGiver jobItemGiver);
|
||||
|
||||
void setTime(IJobItemGiver jobItemGiver, long day);
|
||||
|
||||
boolean hasInteractedBefore(IJobItemGiver jobItemGiver);
|
||||
|
||||
IJobItemGiver[] getItemGivers();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IPlayerMail;
|
||||
|
||||
public interface IPlayerMailData {
|
||||
|
||||
boolean hasMail();
|
||||
|
||||
void addMail(IPlayerMail mail);
|
||||
|
||||
void removeMail(IPlayerMail mail);
|
||||
|
||||
boolean hasMail(IPlayerMail mail);
|
||||
|
||||
IPlayerMail[] getAllMail();
|
||||
|
||||
IPlayerMail[] getUnreadMail();
|
||||
|
||||
IPlayerMail[] getReadMail();
|
||||
|
||||
IPlayerMail[] getMailFrom(String sender);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
|
||||
public interface IPlayerQuestData {
|
||||
|
||||
IQuest getTrackedQuest();
|
||||
|
||||
void startQuest(int id);
|
||||
|
||||
void finishQuest(int id);
|
||||
|
||||
void stopQuest(int id);
|
||||
|
||||
void removeQuest(int id);
|
||||
|
||||
boolean hasFinishedQuest(int id);
|
||||
|
||||
public boolean hasActiveQuest(int id);
|
||||
|
||||
IQuest[] getActiveQuests();
|
||||
|
||||
IQuest[] getFinishedQuests();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
|
||||
|
||||
public interface IPlayerTransportData {
|
||||
|
||||
boolean hasTransport(int id);
|
||||
|
||||
void addTransport(int id);
|
||||
|
||||
void addTransport(ITransportLocation location);
|
||||
|
||||
ITransportLocation getTransport(int id);
|
||||
|
||||
ITransportLocation[] getTransports();
|
||||
|
||||
void removeTransport(int id);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package noppes.npcs.scripted.interfaces.handler;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ITransportCategory;
|
||||
|
||||
public interface ITransportHandler {
|
||||
|
||||
ITransportCategory[] categories();
|
||||
|
||||
void createCategory(String title);
|
||||
|
||||
ITransportCategory getCategory(String title);
|
||||
|
||||
void removeCategory(String title);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package noppes.npcs.scripted.interfaces.handler.data;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public interface IPlayerMail {
|
||||
|
||||
void setPageText(String[] pages);
|
||||
|
||||
String[] getPageText();
|
||||
|
||||
int getPageCount();
|
||||
|
||||
void setSender(String sender);
|
||||
|
||||
String getSender();
|
||||
|
||||
void setSubject(String subject);
|
||||
|
||||
String getSubject();
|
||||
|
||||
long getTimePast();
|
||||
|
||||
long getTimeSent();
|
||||
|
||||
boolean hasQuest();
|
||||
|
||||
IQuest getQuest();
|
||||
|
||||
IItemStack[] getItems();
|
||||
|
||||
void setItems(IItemStack[] items);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package noppes.npcs.scripted.interfaces.handler.data;
|
||||
|
||||
public interface ITransportCategory {
|
||||
|
||||
int getId();
|
||||
|
||||
void setTitle(String title);
|
||||
|
||||
String getTitle();
|
||||
|
||||
void addLocation(String name);
|
||||
|
||||
ITransportLocation getLocation(String name);
|
||||
|
||||
void removeLocation(String name);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package noppes.npcs.scripted.interfaces.handler.data;
|
||||
|
||||
public interface ITransportLocation {
|
||||
|
||||
int getId();
|
||||
|
||||
void setName(String name);
|
||||
|
||||
String getName();
|
||||
|
||||
void setDimension(int dimension);
|
||||
|
||||
int getDimension();
|
||||
|
||||
void setType(int type);
|
||||
|
||||
int getType();
|
||||
|
||||
void setPosition(int x, int y, int z);
|
||||
|
||||
double getX();
|
||||
|
||||
double getY();
|
||||
|
||||
double getZ();
|
||||
|
||||
void save();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
import noppes.npcs.roles.JobInterface;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
|
||||
public interface IJob {
|
||||
|
||||
int getType();
|
||||
|
||||
JobInterface getJobInterface();
|
||||
|
||||
ICustomNpc getNpc();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
public interface IJobBard extends IJob {
|
||||
|
||||
String getSong();
|
||||
|
||||
void setSong(String song);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
public interface IJobConversation extends IJob {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
|
||||
public interface IJobFollower extends IJob {
|
||||
|
||||
String getFollowingName();
|
||||
|
||||
void setFollowingName(String name);
|
||||
|
||||
ICustomNpc getFollowingNpc();
|
||||
|
||||
boolean isFollowing();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
public interface IJobGuard extends IJob {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public interface IJobHealer extends IJob {
|
||||
|
||||
void heal(IEntityLivingBase entity, float amount);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IAvailability;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public interface IJobItemGiver extends IJob {
|
||||
|
||||
void setCooldown(int cooldown);
|
||||
|
||||
void setCooldownType(int type);
|
||||
|
||||
int getCooldownType();
|
||||
|
||||
void setGivingMethod(int method);
|
||||
|
||||
int getGivingMethod();
|
||||
|
||||
void setLines(String[] lines);
|
||||
|
||||
String[] getLines();
|
||||
|
||||
void setAvailability(IAvailability availability);
|
||||
|
||||
IAvailability getAvailability();
|
||||
|
||||
void setItem(int slot, IItemStack item);
|
||||
|
||||
IItemStack[] getItems();
|
||||
|
||||
boolean giveItems(IPlayer player);
|
||||
|
||||
boolean canPlayerInteract(IPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
public interface IJobPuppet extends IJob {
|
||||
|
||||
int getRotationX(int part);
|
||||
|
||||
int getRotationY(int part);
|
||||
|
||||
int getRotationZ(int part);
|
||||
|
||||
void setRotationX(int part, int rotation);
|
||||
|
||||
void setRotationY(int part, int rotation);
|
||||
|
||||
void setRotationZ(int part, int rotation);
|
||||
|
||||
boolean isEnabled(int part);
|
||||
|
||||
void setEnabled(int part, boolean bo);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.scripted.interfaces.jobs;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
|
||||
public interface IJobSpawner extends IJob {
|
||||
|
||||
IEntityLivingBase spawnEntity(int number);
|
||||
|
||||
void removeAllSpawned();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package noppes.npcs.scripted.interfaces.roles;
|
||||
|
||||
public interface IRole {
|
||||
|
||||
int getType();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces.roles;
|
||||
|
||||
public interface IRoleBank extends IRole {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package noppes.npcs.scripted.interfaces.roles;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
public interface IRoleFollower extends IRole {
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param player Player who is set as the owner. If null given everything resets
|
||||
*/
|
||||
void setOwner(IPlayer player);
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
|
||||
*/
|
||||
IPlayer getOwner();
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not the follower has an owner
|
||||
*/
|
||||
boolean hasOwner();
|
||||
|
||||
boolean isFollowing();
|
||||
|
||||
void setIsFollowing(boolean following);
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns days left
|
||||
*/
|
||||
int getDaysLeft();
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param days The days you want to add to the days remaining
|
||||
*/
|
||||
void addDaysLeft(int days);
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not the follower is set to infinite days
|
||||
*/
|
||||
boolean getInfiniteDays();
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param infinite Sets whether the days hired are infinite
|
||||
*/
|
||||
void setInfiniteDays(boolean infinite);
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Return whether the gui is disabled
|
||||
*/
|
||||
boolean getGuiDisabled();
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param disabled Set the gui to be disabled or not
|
||||
*/
|
||||
void setGuiDisabled(boolean disabled);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces.roles;
|
||||
|
||||
public interface IRoleMailman extends IRole {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package noppes.npcs.scripted.interfaces.roles;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public interface IRoleTrader extends IRole {
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
* @param currency Currency item
|
||||
* @param currency2 Currency item number two
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold);
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
* @param currency Currency item
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
void setSellOption(int slot, IItemStack currency, IItemStack sold);
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return The item being sold in this slot.
|
||||
*/
|
||||
IItemStack getSellOption(int slot);
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return a ScriptItemStack array of size 2 which contains the currency of this trade
|
||||
*/
|
||||
IItemStack[] getCurrency(int slot);
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
*/
|
||||
void removeSellOption(int slot);
|
||||
|
||||
/**
|
||||
* @param name The trader Linked Market name
|
||||
*/
|
||||
void setMarket(String name);
|
||||
|
||||
/**
|
||||
* @return Get the currently set Linked Market name
|
||||
*/
|
||||
String getMarket();
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return the number of times an item has been sold on that slot
|
||||
*/
|
||||
int getPurchaseNum(int slot);
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param player
|
||||
* @return the number of times this player has purchased from this trader
|
||||
*/
|
||||
int getPurchaseNum(int slot, IPlayer player);
|
||||
|
||||
/**
|
||||
* Sets the purchase count of all slots to 0
|
||||
*/
|
||||
void resetPurchaseNum();
|
||||
|
||||
/**
|
||||
* sets the purchase num for that slot to 0
|
||||
* @param slot
|
||||
*/
|
||||
void resetPurchaseNum(int slot);
|
||||
|
||||
/**
|
||||
* sets the purchase num for that slot and player to 0
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
void resetPurchaseNum(int slot, IPlayer player);
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return if this slot is enabled
|
||||
*/
|
||||
boolean isSlotEnabled(int slot);
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param player
|
||||
* @return if this slot is enabled for this player
|
||||
*/
|
||||
boolean isSlotEnabled(int slot, IPlayer player);
|
||||
|
||||
/**
|
||||
* prevent an item from being sold on that slot
|
||||
* @param slot
|
||||
*/
|
||||
void disableSlot(int slot);
|
||||
|
||||
/**
|
||||
* disables the slot for this player
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
void disableSlot(int slot, IPlayer player);
|
||||
|
||||
/**
|
||||
* allow an item to be sold on that slot
|
||||
* @param slot
|
||||
*/
|
||||
void enableSlot(int slot);
|
||||
|
||||
/**
|
||||
* enables the slot for this player
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
void enableSlot(int slot, IPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces.roles;
|
||||
|
||||
public interface IRoleTransporter extends IRole {
|
||||
|
||||
}
|
||||
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobBard;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobBard;
|
||||
|
||||
public class ScriptJobBard extends ScriptJobInterface{
|
||||
public class ScriptJobBard extends ScriptJobInterface implements IJobBard {
|
||||
private JobBard job;
|
||||
public ScriptJobBard(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
|
||||
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobConversation;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobConversation;
|
||||
|
||||
public class ScriptJobConversation extends ScriptJobInterface{
|
||||
public class ScriptJobConversation extends ScriptJobInterface implements IJobConversation {
|
||||
private JobConversation job;
|
||||
public ScriptJobConversation(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
|
||||
@@ -4,8 +4,9 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobFollower;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobFollower;
|
||||
|
||||
public class ScriptJobFollower extends ScriptJobInterface{
|
||||
public class ScriptJobFollower extends ScriptJobInterface implements IJobFollower {
|
||||
private JobFollower job;
|
||||
public ScriptJobFollower(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
@@ -20,7 +21,7 @@ public class ScriptJobFollower extends ScriptJobInterface{
|
||||
job.name = name;
|
||||
}
|
||||
|
||||
public ICustomNpc getFollowingNpc(){
|
||||
public ICustomNpc getFollowingNpc() {
|
||||
if(!isFollowing())
|
||||
return null;
|
||||
return job.following.script.dummyNpc;
|
||||
|
||||
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobGuard;
|
||||
|
||||
public class ScriptJobGuard extends ScriptJobInterface{
|
||||
public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard {
|
||||
private JobGuard job;
|
||||
public ScriptJobGuard(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
|
||||
@@ -4,8 +4,9 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobHealer;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobHealer;
|
||||
|
||||
public class ScriptJobHealer extends ScriptJobInterface{
|
||||
public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer {
|
||||
private JobHealer job;
|
||||
public ScriptJobHealer(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobInterface;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJob;
|
||||
|
||||
public class ScriptJobInterface {
|
||||
protected EntityNPCInterface npc;
|
||||
public class ScriptJobInterface implements IJob {
|
||||
public final EntityNPCInterface npc;
|
||||
public final JobInterface jobInterface;
|
||||
|
||||
public ScriptJobInterface(JobInterface jobInterface) {
|
||||
this.npc = null;
|
||||
this.jobInterface = jobInterface;
|
||||
}
|
||||
|
||||
public ScriptJobInterface(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
this.jobInterface = npc.jobInterface;
|
||||
}
|
||||
/**
|
||||
* @see noppes.npcs.scripted.constants.JobType
|
||||
@@ -16,4 +27,13 @@ public class ScriptJobInterface {
|
||||
public int getType(){
|
||||
return JobType.UNKNOWN;
|
||||
}
|
||||
|
||||
public JobInterface getJobInterface() {
|
||||
return jobInterface;
|
||||
}
|
||||
|
||||
public ICustomNpc getNpc() {
|
||||
return (ICustomNpc) NpcAPI.Instance().getIEntity(npc);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,29 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.controllers.data.Availability;
|
||||
import noppes.npcs.controllers.data.PlayerItemGiverData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IAvailability;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobItemGiver;
|
||||
|
||||
public class ScriptJobItemGiver extends ScriptJobInterface{
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ScriptJobItemGiver extends ScriptJobInterface implements IJobItemGiver {
|
||||
private JobItemGiver job;
|
||||
|
||||
public ScriptJobItemGiver(JobItemGiver job) {
|
||||
super(job);
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
public ScriptJobItemGiver(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobItemGiver) npc.jobInterface;
|
||||
@@ -15,5 +33,81 @@ public class ScriptJobItemGiver extends ScriptJobInterface{
|
||||
public int getType(){
|
||||
return JobType.ITEMGIVER;
|
||||
}
|
||||
|
||||
|
||||
public void setCooldown(int cooldown) {
|
||||
if (cooldown < 0)
|
||||
cooldown = 0;
|
||||
|
||||
job.cooldown = cooldown;
|
||||
}
|
||||
|
||||
public void setCooldownType(int type) {
|
||||
if (type < 0) {
|
||||
type = 0;
|
||||
} else if (type > 2) {
|
||||
type = 2;
|
||||
}
|
||||
job.cooldownType = type;
|
||||
}
|
||||
|
||||
public int getCooldownType() {
|
||||
return job.cooldownType;
|
||||
}
|
||||
|
||||
public void setGivingMethod(int method) {
|
||||
if (method < 0) {
|
||||
method = 0;
|
||||
} else if (method > 4) {
|
||||
method = 4;
|
||||
}
|
||||
job.givingMethod = method;
|
||||
}
|
||||
|
||||
public int getGivingMethod() {
|
||||
return job.givingMethod;
|
||||
}
|
||||
|
||||
public void setLines(String[] lines) {
|
||||
job.lines = new ArrayList<>(Arrays.asList(lines));
|
||||
}
|
||||
|
||||
public String[] getLines() {
|
||||
return job.lines.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public void setAvailability(IAvailability availability) {
|
||||
job.availability = (Availability) availability;
|
||||
}
|
||||
|
||||
public IAvailability getAvailability() {
|
||||
return job.availability;
|
||||
}
|
||||
|
||||
public void setItem(int slot, IItemStack item) {
|
||||
if (slot < 0) {
|
||||
slot = 0;
|
||||
} else if (slot > 8) {
|
||||
slot = 8;
|
||||
}
|
||||
|
||||
job.inventory.items.put(slot, item.getMCItemStack());
|
||||
}
|
||||
|
||||
public IItemStack[] getItems() {
|
||||
ArrayList<IItemStack> items = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < job.inventory.getSizeInventory(); i++) {
|
||||
items.add(NpcAPI.Instance().getIItemStack(job.inventory.getStackInSlot(i)));
|
||||
}
|
||||
|
||||
return items.toArray(new IItemStack[0]);
|
||||
}
|
||||
|
||||
public boolean giveItems(IPlayer player) {
|
||||
return job.giveItems((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean canPlayerInteract(IPlayer player) {
|
||||
return job.canPlayerInteract((PlayerItemGiverData) player.getData().getItemGiverData());
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,9 @@ package noppes.npcs.scripted.roles;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobPuppet;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobPuppet;
|
||||
|
||||
public class ScriptJobPuppet extends ScriptJobInterface{
|
||||
public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet {
|
||||
private JobPuppet job;
|
||||
public ScriptJobPuppet(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
@@ -100,7 +101,7 @@ public class ScriptJobPuppet extends ScriptJobInterface{
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param type Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @param rotation Rotation the of the body part
|
||||
*/
|
||||
public void setRotationY(int part, int rotation){
|
||||
|
||||
@@ -8,8 +8,9 @@ import noppes.npcs.roles.JobSpawner;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.jobs.IJobSpawner;
|
||||
|
||||
public class ScriptJobSpawner extends ScriptJobInterface{
|
||||
public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner {
|
||||
private JobSpawner job;
|
||||
public ScriptJobSpawner(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
|
||||
@@ -2,8 +2,9 @@ package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRoleBank;
|
||||
|
||||
public class ScriptRoleBank extends ScriptRoleInterface{
|
||||
public class ScriptRoleBank extends ScriptRoleInterface implements IRoleBank {
|
||||
|
||||
public ScriptRoleBank(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
|
||||
@@ -6,18 +6,15 @@ import noppes.npcs.roles.RoleFollower;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRoleFollower;
|
||||
|
||||
public class ScriptRoleFollower extends ScriptRoleInterface{
|
||||
public class ScriptRoleFollower extends ScriptRoleInterface implements IRoleFollower {
|
||||
private RoleFollower role;
|
||||
public ScriptRoleFollower(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
role = (RoleFollower) npc.roleInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param player Player who is set as the owner. If null given everything resets
|
||||
*/
|
||||
|
||||
public void setOwner(IPlayer player){
|
||||
if(player == null || player.getMCEntity() == null){
|
||||
role.setOwner(null);
|
||||
@@ -26,22 +23,14 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
|
||||
EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity();
|
||||
role.setOwner(mcplayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
|
||||
*/
|
||||
|
||||
public IPlayer getOwner(){
|
||||
if(role.owner == null)
|
||||
return null;
|
||||
|
||||
return (IPlayer) NpcAPI.Instance().getIEntity(role.owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not the follower has an owner
|
||||
*/
|
||||
|
||||
public boolean hasOwner(){
|
||||
return role.owner != null;
|
||||
}
|
||||
@@ -53,51 +42,27 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
|
||||
public void setIsFollowing(boolean following) {
|
||||
if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns days left
|
||||
*/
|
||||
|
||||
public int getDaysLeft(){
|
||||
return role.getDaysLeft();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param days The days you want to add to the days remaining
|
||||
*/
|
||||
|
||||
public void addDaysLeft(int days){
|
||||
role.addDays(days);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not the follower is set to infinite days
|
||||
*/
|
||||
|
||||
public boolean getInfiniteDays(){
|
||||
return role.infiniteDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param infinite Sets whether the days hired are infinite
|
||||
*/
|
||||
|
||||
public void setInfiniteDays(boolean infinite){
|
||||
role.infiniteDays = infinite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Return whether the gui is disabled
|
||||
*/
|
||||
|
||||
public boolean getGuiDisabled(){
|
||||
return role.disableGui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param disabled Set the gui to be disabled or not
|
||||
*/
|
||||
|
||||
public void setGuiDisabled(boolean disabled){
|
||||
role.disableGui = disabled;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRole;
|
||||
|
||||
public class ScriptRoleInterface {
|
||||
protected EntityNPCInterface npc;
|
||||
public class ScriptRoleInterface implements IRole {
|
||||
public final EntityNPCInterface npc;
|
||||
public final RoleInterface role;
|
||||
|
||||
public ScriptRoleInterface(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
this.role = npc.roleInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,9 @@ package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRoleMailman;
|
||||
|
||||
public class ScriptRoleMailman extends ScriptRoleInterface{
|
||||
public class ScriptRoleMailman extends ScriptRoleInterface implements IRoleMailman {
|
||||
|
||||
public ScriptRoleMailman(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
|
||||
@@ -8,20 +8,15 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRoleTrader;
|
||||
|
||||
public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader {
|
||||
private RoleTrader role;
|
||||
public ScriptRoleTrader(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
role = (RoleTrader) npc.roleInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
* @param currency Currency item
|
||||
* @param currency2 Currency item number two
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
|
||||
public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){
|
||||
if(sold == null || slot >= 18 || slot < 0)
|
||||
return;
|
||||
@@ -40,29 +35,16 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
role.inventorySold.items.put(slot, sold.getMCItemStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
* @param currency Currency item
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
public void setSellOption(int slot, IItemStack currency, IItemStack sold){
|
||||
setSellOption(slot, currency, null, sold);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return The item being sold in this slot.
|
||||
*/
|
||||
|
||||
public IItemStack getSellOption(int slot) {
|
||||
if (slot >= 18 || slot < 0) return null;
|
||||
if (role.inventorySold.items.get(slot) == null) return null;
|
||||
return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return a ScriptItemStack array of size 2 which contains the currency of this trade
|
||||
*/
|
||||
|
||||
public IItemStack[] getCurrency(int slot) {
|
||||
if (slot >= 18 || slot < 0) return null;
|
||||
IItemStack[] currency = new IItemStack[2];
|
||||
@@ -75,127 +57,72 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
return currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
*/
|
||||
|
||||
public void removeSellOption(int slot){
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.inventoryCurrency.items.remove(slot);
|
||||
role.inventoryCurrency.items.remove(slot + 18);
|
||||
role.inventorySold.items.remove(slot);
|
||||
}
|
||||
/**
|
||||
* @param name The trader Linked Market name
|
||||
*/
|
||||
|
||||
public void setMarket(String name){
|
||||
role.marketName = name;
|
||||
Market.load(role, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Get the currently set Linked Market name
|
||||
*/
|
||||
|
||||
public String getMarket(){
|
||||
return role.marketName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return the number of times an item has been sold on that slot
|
||||
*/
|
||||
|
||||
public int getPurchaseNum(int slot) {
|
||||
if(slot >= 18 || slot < 0) return -1;
|
||||
return role.purchases[slot];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param player
|
||||
* @return the number of times this player has purchased from this trader
|
||||
*/
|
||||
|
||||
public int getPurchaseNum(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return -1;
|
||||
return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the purchase count of all slots to 0
|
||||
*/
|
||||
|
||||
public void resetPurchaseNum() {
|
||||
for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the purchase num for that slot to 0
|
||||
* @param slot
|
||||
*/
|
||||
|
||||
public void resetPurchaseNum(int slot) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.purchases[slot] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the purchase num for that slot and player to 0
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
|
||||
public void resetPurchaseNum(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return if this slot is enabled
|
||||
*/
|
||||
|
||||
public boolean isSlotEnabled(int slot) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
return role.disableSlot[slot] > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param player
|
||||
* @return if this slot is enabled for this player
|
||||
*/
|
||||
|
||||
public boolean isSlotEnabled(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
return role.isSlotEnabled(slot, (EntityPlayer)player.getMCEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* prevent an item from being sold on that slot
|
||||
* @param slot
|
||||
*/
|
||||
|
||||
public void disableSlot(int slot) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.disableSlot[slot] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* disables the slot for this player
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
|
||||
public void disableSlot(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* allow an item to be sold on that slot
|
||||
* @param slot
|
||||
*/
|
||||
|
||||
public void enableSlot(int slot) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.disableSlot[slot] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* enables the slot for this player
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
|
||||
public void enableSlot(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 0;
|
||||
|
||||
@@ -2,8 +2,9 @@ package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.roles.IRoleTransporter;
|
||||
|
||||
public class ScriptRoleTransporter extends ScriptRoleInterface{
|
||||
public class ScriptRoleTransporter extends ScriptRoleInterface implements IRoleTransporter {
|
||||
|
||||
public ScriptRoleTransporter(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
|
||||
Reference in new issue
Block a user