mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 13:49:05 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import noppes.npcs.api.handler.data.ISlot;
|
||||
import kamkeel.npcs.controllers.data.profile.Profile;
|
||||
import kamkeel.npcs.network.packets.data.QuestCompletionPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -25,148 +24,149 @@ import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
public class Quest implements ICompatibilty, IQuest {
|
||||
public int version = VersionCompatibility.ModRev;
|
||||
public int id = -1;
|
||||
public EnumQuestType type = EnumQuestType.Item;
|
||||
public EnumQuestRepeat repeat = EnumQuestRepeat.NONE;
|
||||
public EnumQuestCompletion completion = EnumQuestCompletion.Npc;
|
||||
public String title = "default";
|
||||
public QuestCategory category;
|
||||
public String logText = "";
|
||||
public String completeText = "";
|
||||
public String completerNpc = "";
|
||||
public int nextQuestid = -1;
|
||||
public String nextQuestTitle = "";
|
||||
public PlayerMail mail = new PlayerMail();
|
||||
public String command = "";
|
||||
public int version = VersionCompatibility.ModRev;
|
||||
public int id = -1;
|
||||
public EnumQuestType type = EnumQuestType.Item;
|
||||
public EnumQuestRepeat repeat = EnumQuestRepeat.NONE;
|
||||
public EnumQuestCompletion completion = EnumQuestCompletion.Npc;
|
||||
public String title = "default";
|
||||
public QuestCategory category;
|
||||
public String logText = "";
|
||||
public String completeText = "";
|
||||
public String completerNpc = "";
|
||||
public int nextQuestid = -1;
|
||||
public String nextQuestTitle = "";
|
||||
public PlayerMail mail = new PlayerMail();
|
||||
public String command = "";
|
||||
|
||||
public QuestInterface questInterface = new QuestItem();
|
||||
public QuestInterface questInterface = new QuestItem();
|
||||
public long customCooldown = 0;
|
||||
|
||||
public int rewardExp = 0;
|
||||
public NpcMiscInventory rewardItems = new NpcMiscInventory(9);
|
||||
public boolean randomReward = false;
|
||||
public FactionOptions factionOptions = new FactionOptions();
|
||||
public PartyOptions partyOptions = new PartyOptions();
|
||||
public int rewardExp = 0;
|
||||
public NpcMiscInventory rewardItems = new NpcMiscInventory(9);
|
||||
public boolean randomReward = false;
|
||||
public FactionOptions factionOptions = new FactionOptions();
|
||||
public PartyOptions partyOptions = new PartyOptions();
|
||||
public ProfileOptions profileOptions = new ProfileOptions();
|
||||
|
||||
public void readNBT(NBTTagCompound compound) {
|
||||
id = compound.getInteger("Id");
|
||||
readNBTPartial(compound);
|
||||
}
|
||||
public void readNBTPartial(NBTTagCompound compound) {
|
||||
version = compound.getInteger("ModRev");
|
||||
VersionCompatibility.CheckAvailabilityCompatibility(this, compound);
|
||||
public void readNBT(NBTTagCompound compound) {
|
||||
id = compound.getInteger("Id");
|
||||
readNBTPartial(compound);
|
||||
}
|
||||
|
||||
setType(EnumQuestType.values()[compound.getInteger("Type")]);
|
||||
title = compound.getString("Title");
|
||||
logText = compound.getString("Text");
|
||||
completeText = compound.getString("CompleteText");
|
||||
completerNpc = compound.getString("CompleterNpc");
|
||||
command = compound.getString("QuestCommand");
|
||||
nextQuestid = compound.getInteger("NextQuestId");
|
||||
nextQuestTitle = compound.getString("NextQuestTitle");
|
||||
if(hasNewQuest())
|
||||
nextQuestTitle = getNextQuest().title;
|
||||
else
|
||||
nextQuestTitle = "";
|
||||
randomReward = compound.getBoolean("RandomReward");
|
||||
rewardExp = compound.getInteger("RewardExp");
|
||||
rewardItems.setFromNBT(compound.getCompoundTag("Rewards"));
|
||||
public void readNBTPartial(NBTTagCompound compound) {
|
||||
version = compound.getInteger("ModRev");
|
||||
VersionCompatibility.CheckAvailabilityCompatibility(this, compound);
|
||||
|
||||
completion = EnumQuestCompletion.values()[compound.getInteger("QuestCompletion")];
|
||||
repeat = EnumQuestRepeat.values()[compound.getInteger("QuestRepeat")];
|
||||
setType(EnumQuestType.values()[compound.getInteger("Type")]);
|
||||
title = compound.getString("Title");
|
||||
logText = compound.getString("Text");
|
||||
completeText = compound.getString("CompleteText");
|
||||
completerNpc = compound.getString("CompleterNpc");
|
||||
command = compound.getString("QuestCommand");
|
||||
nextQuestid = compound.getInteger("NextQuestId");
|
||||
nextQuestTitle = compound.getString("NextQuestTitle");
|
||||
if (hasNewQuest())
|
||||
nextQuestTitle = getNextQuest().title;
|
||||
else
|
||||
nextQuestTitle = "";
|
||||
randomReward = compound.getBoolean("RandomReward");
|
||||
rewardExp = compound.getInteger("RewardExp");
|
||||
rewardItems.setFromNBT(compound.getCompoundTag("Rewards"));
|
||||
|
||||
completion = EnumQuestCompletion.values()[compound.getInteger("QuestCompletion")];
|
||||
repeat = EnumQuestRepeat.values()[compound.getInteger("QuestRepeat")];
|
||||
customCooldown = compound.getLong("CustomCooldown");
|
||||
questInterface.readEntityFromNBT(compound);
|
||||
questInterface.readEntityFromNBT(compound);
|
||||
|
||||
factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints"));
|
||||
partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions"));
|
||||
factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints"));
|
||||
partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions"));
|
||||
profileOptions.readFromNBT(compound.getCompoundTag("ProfileOptions"));
|
||||
|
||||
mail.readNBT(compound.getCompoundTag("QuestMail"));
|
||||
}
|
||||
mail.readNBT(compound.getCompoundTag("QuestMail"));
|
||||
}
|
||||
|
||||
public void setType(EnumQuestType questType) {
|
||||
type = questType;
|
||||
if(type == EnumQuestType.Item)
|
||||
questInterface = new QuestItem();
|
||||
else if(type == EnumQuestType.Dialog)
|
||||
questInterface = new QuestDialog();
|
||||
else if(type == EnumQuestType.Kill || type == EnumQuestType.AreaKill)
|
||||
questInterface = new QuestKill();
|
||||
else if(type == EnumQuestType.Location)
|
||||
questInterface = new QuestLocation();
|
||||
else if(type == EnumQuestType.Manual)
|
||||
public void setType(EnumQuestType questType) {
|
||||
type = questType;
|
||||
if (type == EnumQuestType.Item)
|
||||
questInterface = new QuestItem();
|
||||
else if (type == EnumQuestType.Dialog)
|
||||
questInterface = new QuestDialog();
|
||||
else if (type == EnumQuestType.Kill || type == EnumQuestType.AreaKill)
|
||||
questInterface = new QuestKill();
|
||||
else if (type == EnumQuestType.Location)
|
||||
questInterface = new QuestLocation();
|
||||
else if (type == EnumQuestType.Manual)
|
||||
questInterface = new QuestManual();
|
||||
|
||||
if(questInterface != null)
|
||||
questInterface.questId = id;
|
||||
}
|
||||
if (questInterface != null)
|
||||
questInterface.questId = id;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("Id", id);
|
||||
return writeToNBTPartial(compound);
|
||||
}
|
||||
public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) {
|
||||
compound.setInteger("ModRev", version);
|
||||
compound.setInteger("Type", type.ordinal());
|
||||
compound.setString("Title", title);
|
||||
compound.setString("Text", logText);
|
||||
compound.setString("CompleteText", completeText);
|
||||
compound.setString("CompleterNpc", completerNpc);
|
||||
compound.setInteger("NextQuestId", nextQuestid);
|
||||
compound.setString("NextQuestTitle", nextQuestTitle);
|
||||
compound.setInteger("RewardExp", rewardExp);
|
||||
compound.setTag("Rewards", rewardItems.getToNBT());
|
||||
compound.setString("QuestCommand", command);
|
||||
compound.setBoolean("RandomReward", randomReward);
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("Id", id);
|
||||
return writeToNBTPartial(compound);
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBTPartial(NBTTagCompound compound) {
|
||||
compound.setInteger("ModRev", version);
|
||||
compound.setInteger("Type", type.ordinal());
|
||||
compound.setString("Title", title);
|
||||
compound.setString("Text", logText);
|
||||
compound.setString("CompleteText", completeText);
|
||||
compound.setString("CompleterNpc", completerNpc);
|
||||
compound.setInteger("NextQuestId", nextQuestid);
|
||||
compound.setString("NextQuestTitle", nextQuestTitle);
|
||||
compound.setInteger("RewardExp", rewardExp);
|
||||
compound.setTag("Rewards", rewardItems.getToNBT());
|
||||
compound.setString("QuestCommand", command);
|
||||
compound.setBoolean("RandomReward", randomReward);
|
||||
compound.setLong("CustomCooldown", customCooldown);
|
||||
|
||||
compound.setInteger("QuestCompletion", completion.ordinal());
|
||||
compound.setInteger("QuestRepeat", repeat.ordinal());
|
||||
compound.setInteger("QuestCompletion", completion.ordinal());
|
||||
compound.setInteger("QuestRepeat", repeat.ordinal());
|
||||
|
||||
this.questInterface.writeEntityToNBT(compound);
|
||||
compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound()));
|
||||
compound.setTag("PartyOptions", partyOptions.writeToNBT());
|
||||
this.questInterface.writeEntityToNBT(compound);
|
||||
compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound()));
|
||||
compound.setTag("PartyOptions", partyOptions.writeToNBT());
|
||||
compound.setTag("ProfileOptions", profileOptions.writeToNBT());
|
||||
compound.setTag("QuestMail", mail.writeNBT());
|
||||
compound.setTag("QuestMail", mail.writeNBT());
|
||||
|
||||
return compound;
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
public boolean hasNewQuest()
|
||||
{
|
||||
return getNextQuest() != null;
|
||||
}
|
||||
public Quest getNextQuest()
|
||||
{
|
||||
return QuestController.Instance == null?null:QuestController.Instance.quests.get(nextQuestid);
|
||||
}
|
||||
public boolean hasNewQuest() {
|
||||
return getNextQuest() != null;
|
||||
}
|
||||
|
||||
public boolean instantComplete(EntityPlayer player, QuestData data) {
|
||||
if(completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)){
|
||||
QuestCompletionPacket.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Quest getNextQuest() {
|
||||
return QuestController.Instance == null ? null : QuestController.Instance.quests.get(nextQuestid);
|
||||
}
|
||||
|
||||
public boolean instantComplete(EntityPlayer player, QuestData data) {
|
||||
if (completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)) {
|
||||
QuestCompletionPacket.sendQuestComplete((EntityPlayerMP) player, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean instantPartyComplete(Party party) {
|
||||
return completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questPartyCompletion(party);
|
||||
}
|
||||
|
||||
public Quest copy(){
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(this.writeToNBT(new NBTTagCompound()));
|
||||
return quest;
|
||||
}
|
||||
public Quest copy() {
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(this.writeToNBT(new NBTTagCompound()));
|
||||
return quest;
|
||||
}
|
||||
|
||||
public long getTimeUntilRepeat(EntityPlayer player) {
|
||||
if(ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared){
|
||||
if (ConfigMain.ProfilesEnabled && profileOptions.enableOptions && profileOptions.cooldownControl == EnumProfileSync.Shared) {
|
||||
Profile profile = ProfileController.Instance.getProfile(player);
|
||||
IPlayer iPlayer = NoppesUtilServer.getIPlayer(player);
|
||||
long timeRemaining = 0L;
|
||||
for(ISlot slot : profile.getSlots().values()){
|
||||
for (ISlot slot : profile.getSlots().values()) {
|
||||
IPlayerData playerData = ProfileController.Instance.getSlotPlayerData(iPlayer, slot.getId());
|
||||
IPlayerQuestData iPlayerQuestData = playerData.getQuestData();
|
||||
timeRemaining = Math.max(timeRemaining, getTimeUntilRepeatQuestData(player, iPlayerQuestData));
|
||||
@@ -177,7 +177,7 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
return getTimeUntilRepeatQuestData(player, questData);
|
||||
}
|
||||
|
||||
public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData){
|
||||
public long getTimeUntilRepeatQuestData(EntityPlayer player, IPlayerQuestData questData) {
|
||||
long questTime = questData.getLastCompletedTime(this.id);
|
||||
|
||||
switch (repeat) {
|
||||
@@ -251,123 +251,124 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
@Override
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
@Override
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.title;
|
||||
}
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type.ordinal();
|
||||
}
|
||||
public String getName() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setType(int questType) {
|
||||
if(questType < 0 || questType >= EnumQuestType.values().length)
|
||||
return;
|
||||
public int getType() {
|
||||
return this.type.ordinal();
|
||||
}
|
||||
|
||||
EnumQuestType type = EnumQuestType.values()[questType];
|
||||
setType(type);
|
||||
}
|
||||
public void setType(int questType) {
|
||||
if (questType < 0 || questType >= EnumQuestType.values().length)
|
||||
return;
|
||||
|
||||
public IQuestCategory getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
EnumQuestType type = EnumQuestType.values()[questType];
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
QuestController.Instance.saveQuest(this.category.id, this);
|
||||
}
|
||||
public IQuestCategory getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.title = name;
|
||||
}
|
||||
public void save() {
|
||||
QuestController.Instance.saveQuest(this.category.id, this);
|
||||
}
|
||||
|
||||
public String getLogText() {
|
||||
return this.logText;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.title = name;
|
||||
}
|
||||
|
||||
public void setLogText(String text) {
|
||||
this.logText = text;
|
||||
}
|
||||
public String getLogText() {
|
||||
return this.logText;
|
||||
}
|
||||
|
||||
public String getCompleteText() {
|
||||
return this.completeText;
|
||||
}
|
||||
public void setLogText(String text) {
|
||||
this.logText = text;
|
||||
}
|
||||
|
||||
public void setCompleteText(String text) {
|
||||
this.completeText = text;
|
||||
}
|
||||
public String getCompleteText() {
|
||||
return this.completeText;
|
||||
}
|
||||
|
||||
public void setNextQuest(IQuest quest) {
|
||||
if (quest == null) {
|
||||
this.nextQuestid = -1;
|
||||
this.nextQuestTitle = "";
|
||||
} else {
|
||||
if (quest.getId() < 0) {
|
||||
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
|
||||
}
|
||||
public void setCompleteText(String text) {
|
||||
this.completeText = text;
|
||||
}
|
||||
|
||||
this.nextQuestid = quest.getId();
|
||||
this.nextQuestTitle = quest.getName();
|
||||
}
|
||||
public void setNextQuest(IQuest quest) {
|
||||
if (quest == null) {
|
||||
this.nextQuestid = -1;
|
||||
this.nextQuestTitle = "";
|
||||
} else {
|
||||
if (quest.getId() < 0) {
|
||||
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
|
||||
}
|
||||
|
||||
}
|
||||
this.nextQuestid = quest.getId();
|
||||
this.nextQuestTitle = quest.getName();
|
||||
}
|
||||
|
||||
public String getNpcName() {
|
||||
return this.completerNpc;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNpcName(String name) {
|
||||
this.completerNpc = name;
|
||||
}
|
||||
public String getNpcName() {
|
||||
return this.completerNpc;
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(IPlayer player) {
|
||||
if (!player.hasActiveQuest(this.id)) {
|
||||
throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]);
|
||||
} else {
|
||||
return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
}
|
||||
public void setNpcName(String name) {
|
||||
this.completerNpc = name;
|
||||
}
|
||||
|
||||
public boolean getIsRepeatable() {
|
||||
return this.repeat != EnumQuestRepeat.NONE;
|
||||
}
|
||||
public IQuestObjective[] getObjectives(IPlayer player) {
|
||||
if (!player.hasActiveQuest(this.id)) {
|
||||
throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]);
|
||||
} else {
|
||||
return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
}
|
||||
|
||||
public long getTimeUntilRepeat(IPlayer player) {
|
||||
return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
public boolean getIsRepeatable() {
|
||||
return this.repeat != EnumQuestRepeat.NONE;
|
||||
}
|
||||
|
||||
public void setRepeatType(int type) {
|
||||
if (type < 0 || type >= EnumQuestRepeat.values().length) {
|
||||
return;
|
||||
}
|
||||
this.repeat = EnumQuestRepeat.values()[type];
|
||||
}
|
||||
public long getTimeUntilRepeat(IPlayer player) {
|
||||
return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
|
||||
public int getRepeatType() {
|
||||
return this.repeat.ordinal();
|
||||
}
|
||||
public void setRepeatType(int type) {
|
||||
if (type < 0 || type >= EnumQuestRepeat.values().length) {
|
||||
return;
|
||||
}
|
||||
this.repeat = EnumQuestRepeat.values()[type];
|
||||
}
|
||||
|
||||
public IContainer getRewards() {
|
||||
return NpcAPI.Instance().getIContainer(this.rewardItems);
|
||||
}
|
||||
public int getRepeatType() {
|
||||
return this.repeat.ordinal();
|
||||
}
|
||||
|
||||
public IQuestInterface getQuestInterface(){
|
||||
return this.questInterface;
|
||||
}
|
||||
public IContainer getRewards() {
|
||||
return NpcAPI.Instance().getIContainer(this.rewardItems);
|
||||
}
|
||||
|
||||
public IPartyOptions getPartyOptions() {
|
||||
return this.partyOptions;
|
||||
}
|
||||
public IQuestInterface getQuestInterface() {
|
||||
return this.questInterface;
|
||||
}
|
||||
|
||||
public IPartyOptions getPartyOptions() {
|
||||
return this.partyOptions;
|
||||
}
|
||||
|
||||
public IProfileOptions getProfileOptions() {
|
||||
return this.profileOptions;
|
||||
|
||||
Reference in new issue
Block a user