mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 12:15:11 +00:00
First Working Version of Party Kill Quest Completion
This commit is contained in:
1 parent
607b3f54d8
commit
2328b0dadf
16 files changed
+508
-104
No files matched your search
@@ -39,12 +39,12 @@ public class NoppesUtilPlayer {
|
||||
public static void changeFollowerState(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
if(npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
|
||||
|
||||
RoleFollower role = (RoleFollower) npc.roleInterface;
|
||||
EntityPlayer owner = role.owner;
|
||||
if(owner == null || !owner.getCommandSenderName().equals(player.getCommandSenderName()))
|
||||
return;
|
||||
|
||||
|
||||
role.isFollowing = !role.isFollowing;
|
||||
}
|
||||
public static void hireFollower(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
@@ -53,7 +53,7 @@ public class NoppesUtilPlayer {
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCFollowerHire))
|
||||
return;
|
||||
|
||||
|
||||
ContainerNPCFollowerHire container = (ContainerNPCFollowerHire) con;
|
||||
RoleFollower role = (RoleFollower) npc.roleInterface;
|
||||
followerBuy(role, container.currencyMatrix, player, npc);
|
||||
@@ -64,7 +64,7 @@ public class NoppesUtilPlayer {
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCFollower))
|
||||
return;
|
||||
|
||||
|
||||
ContainerNPCFollower container = (ContainerNPCFollower) con;
|
||||
RoleFollower role = (RoleFollower) npc.roleInterface;
|
||||
followerBuy(role, container.currencyMatrix, player, npc);
|
||||
@@ -75,10 +75,10 @@ public class NoppesUtilPlayer {
|
||||
|
||||
if(loc == null || !loc.isDefault() && !playerdata.transports.contains(loc.id))
|
||||
return;
|
||||
|
||||
|
||||
teleportPlayer(player, loc.posX, loc.posY, loc.posZ, loc.dimension);
|
||||
}
|
||||
|
||||
|
||||
public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, int dimension){
|
||||
if(player.dimension != dimension){
|
||||
int dim = player.dimension;
|
||||
@@ -138,7 +138,7 @@ public class NoppesUtilPlayer {
|
||||
public static void swingPlayerArm(EntityPlayerMP player){
|
||||
Server.sendData(player, EnumPacketClient.SWING_PLAYER_ARM);
|
||||
}
|
||||
|
||||
|
||||
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
||||
ItemStack currency = currencyInv.getStackInSlot(0);
|
||||
if(currency == null)
|
||||
@@ -151,14 +151,14 @@ public class NoppesUtilPlayer {
|
||||
int days = 1;
|
||||
if(role.rates.containsKey(i))
|
||||
days = role.rates.get(i);
|
||||
|
||||
|
||||
cd.put(is,days);
|
||||
}
|
||||
if(cd.size() == 0)
|
||||
return;
|
||||
int stackSize = currency.stackSize;
|
||||
int days = 0;
|
||||
|
||||
|
||||
int possibleDays = 0;
|
||||
int possibleSize = stackSize;
|
||||
while(true){
|
||||
@@ -187,7 +187,7 @@ public class NoppesUtilPlayer {
|
||||
currencyInv.setInventorySlotContents(0, null);
|
||||
else
|
||||
currency = currency.splitStack(stackSize);
|
||||
|
||||
|
||||
npc.say(player, new Line(NoppesStringUtils.formatText(role.dialogHire.replace("{days}", days+""), player, npc)));
|
||||
role.setOwner(player);
|
||||
role.addDays(days);
|
||||
@@ -199,7 +199,7 @@ public class NoppesUtilPlayer {
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCBankInterface))
|
||||
return;
|
||||
|
||||
|
||||
ContainerNPCBankInterface container = (ContainerNPCBankInterface) con;
|
||||
Bank bank = BankController.getInstance().getBank(container.bankid);
|
||||
ItemStack item = bank.upgradeInventory.getStackInSlot(container.slot);
|
||||
@@ -229,11 +229,11 @@ public class NoppesUtilPlayer {
|
||||
return;
|
||||
ContainerNPCBankInterface container = (ContainerNPCBankInterface) con;
|
||||
Bank bank = BankController.getInstance().getBank(container.bankid);
|
||||
|
||||
|
||||
ItemStack item = bank.currencyInventory.getStackInSlot(container.slot);
|
||||
if(item == null)
|
||||
return;
|
||||
|
||||
|
||||
int price = item.stackSize;
|
||||
ItemStack currency = container.currencyMatrix.getStackInSlot(0);
|
||||
if(currency == null || price > currency.stackSize)
|
||||
@@ -247,7 +247,7 @@ public class NoppesUtilPlayer {
|
||||
BankData bankData = data.getBank(bank.id);
|
||||
if(bankData.unlockedSlots + 1 <= bank.maxSlots)
|
||||
bankData.unlockedSlots++;
|
||||
|
||||
|
||||
bankData.openBankGui(player, npc, bank.id, container.slot);
|
||||
}
|
||||
public static void sendData(EnumPlayerPacket enu, Object... obs) {
|
||||
@@ -450,7 +450,133 @@ public class NoppesUtilPlayer {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean questPartyCompletion(Party party) {
|
||||
if(party == null)
|
||||
return false;
|
||||
|
||||
QuestData data = party.getQuestData();
|
||||
if (data == null)
|
||||
return false;
|
||||
|
||||
if (!data.quest.questInterface.isPartyCompleted(party))
|
||||
return false;
|
||||
|
||||
|
||||
Quest quest = data.quest;
|
||||
if(quest == null)
|
||||
return false;
|
||||
|
||||
PartyOptions partyOptions = quest.partyOptions;
|
||||
EnumPartyExchange complete = partyOptions.completeFor;
|
||||
EnumPartyExchange reward = partyOptions.rewardControl;
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer player = NoppesUtilServer.getPlayerByName(name);
|
||||
if(player == null)
|
||||
continue;
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if(playerData == null)
|
||||
continue;
|
||||
|
||||
|
||||
boolean isLeader = party.getLeaderUUID().equals(player.getUniqueID());
|
||||
boolean hasActiveQuest = playerData.questData.hasActiveQuest(quest.getId());
|
||||
boolean hasFinishedQuest = playerData.questData.hasFinishedQuest(quest.getId());
|
||||
|
||||
boolean meetsComplete = meetsPartyExchange(complete, hasActiveQuest, hasFinishedQuest, isLeader);
|
||||
boolean meetsReward = meetsPartyExchange(reward, hasActiveQuest, hasFinishedQuest, isLeader);
|
||||
|
||||
if(meetsComplete){
|
||||
if (data.quest.completion == EnumQuestCompletion.Instant) {
|
||||
EventHooks.onQuestFinished(player, data.quest);
|
||||
}
|
||||
}
|
||||
|
||||
if(meetsReward){
|
||||
QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest);
|
||||
|
||||
event.expReward = data.quest.rewardExp;
|
||||
List<IItemStack> list = new ArrayList();
|
||||
Iterator var8 = data.quest.rewardItems.items.values().iterator();
|
||||
|
||||
while(var8.hasNext()) {
|
||||
ItemStack item = (ItemStack)var8.next();
|
||||
if (item != null && item.stackSize > 0) {
|
||||
IItemStack iStack = NpcAPI.Instance().getIItemStack(item);
|
||||
if (iStack != null){
|
||||
list.add(iStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.quest.randomReward) {
|
||||
event.itemRewards = (IItemStack[])list.toArray(new IItemStack[list.size()]);
|
||||
} else if (!list.isEmpty()) {
|
||||
event.itemRewards = new IItemStack[]{(IItemStack)list.get(player.getRNG().nextInt(list.size()))};
|
||||
}
|
||||
|
||||
EventHooks.onQuestTurnedIn(event);
|
||||
if (event.isCancelled())
|
||||
return false;
|
||||
|
||||
IItemStack[] var12 = event.itemRewards;
|
||||
int var14 = var12.length;
|
||||
for(int var10 = 0; var10 < var14; ++var10) {
|
||||
IItemStack item = var12[var10];
|
||||
if (item != null) {
|
||||
NoppesUtilServer.GivePlayerItem(player, player, item.getMCItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(meetsComplete){
|
||||
data.quest.questInterface.handleComplete(player);
|
||||
}
|
||||
|
||||
if(meetsReward){
|
||||
if(data.quest.rewardExp > 0){
|
||||
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F));
|
||||
player.addExperience(data.quest.rewardExp);
|
||||
}
|
||||
|
||||
data.quest.factionOptions.addPoints(player);
|
||||
if(data.quest.mail.isValid()){
|
||||
PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
|
||||
}
|
||||
}
|
||||
|
||||
if(meetsComplete){
|
||||
if(!data.quest.command.isEmpty()){
|
||||
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
|
||||
}
|
||||
PlayerQuestController.setQuestPartyFinished(data.quest, player, data);
|
||||
}
|
||||
|
||||
if (data.quest.hasNewQuest()) {
|
||||
QuestData nextQuest = new QuestData(data.quest.getNextQuest());
|
||||
nextQuest.sendAlerts = data.quest.id != data.quest.getNextQuest().id || data.sendAlerts;
|
||||
PlayerQuestController.addActiveQuest(nextQuest, player);
|
||||
// questData.trackQuest(nextQuest.quest);
|
||||
}
|
||||
playerData.save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean meetsPartyExchange(EnumPartyExchange exchange, boolean hasActive, boolean hasFinished, boolean isLeader){
|
||||
if(exchange == EnumPartyExchange.All){
|
||||
return true;
|
||||
} else if (isLeader){
|
||||
return true;
|
||||
} else if(exchange == EnumPartyExchange.Enrolled && hasActive){
|
||||
return true;
|
||||
} else return exchange == EnumPartyExchange.Valid && (hasActive || hasFinished);
|
||||
}
|
||||
|
||||
|
||||
public static boolean compareItems(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){
|
||||
if (item2 == null || item == null){
|
||||
return false;
|
||||
@@ -493,7 +619,7 @@ public class NoppesUtilPlayer {
|
||||
public static boolean compareItems(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT){
|
||||
int size = 0;
|
||||
for(ItemStack is : player.inventory.mainInventory){
|
||||
if(is != null && compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
if(is != null && compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
size += is.stackSize;
|
||||
}
|
||||
return size >= item.stackSize;
|
||||
|
||||
@@ -204,25 +204,33 @@ public class PacketHandlerServer{
|
||||
}
|
||||
} else if (type == EnumPacketServer.SetPartyQuest) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
if (party != null) {
|
||||
if (party.getPartyLeader() != player) {
|
||||
return;
|
||||
}
|
||||
if(playerData.partyUUID != null){
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
if (party != null) {
|
||||
if (party.getPartyLeader() != player) {
|
||||
return;
|
||||
}
|
||||
|
||||
String questCategory = Server.readString(buffer);
|
||||
String questName = Server.readString(buffer);
|
||||
party.setQuest(null);
|
||||
for (Quest quest : QuestController.Instance.quests.values()) {
|
||||
if (quest.partyOptions.allowParty && quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
|
||||
party.setQuest(quest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
String questCategory = Server.readString(buffer);
|
||||
String questName = Server.readString(buffer);
|
||||
party.setQuest(null);
|
||||
for (Quest quest : QuestController.Instance.quests.values()) {
|
||||
if (quest.partyOptions.allowParty && quest.getCategory().getName().equals(questCategory) && quest.getName().equals(questName)) {
|
||||
|
||||
Server.sendData(player, EnumPacketClient.PARTY_DATA, party.writeToNBT());
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
}
|
||||
if(playerData.questData.hasActiveQuest(quest.getId())){
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerData.questData.activeQuests.put(quest.getId(), questdata);
|
||||
}
|
||||
|
||||
party.setQuest(quest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Server.sendData(player, EnumPacketClient.PARTY_DATA, party.writeToNBT());
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(type.needsNpc && npc == null){
|
||||
|
||||
@@ -37,6 +37,7 @@ import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
@@ -323,9 +324,19 @@ public class ServerEventsHandler {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
boolean checkCompletion = false;
|
||||
String entityName = EntityList.getEntityString(entity);
|
||||
String entityName = EntityList.getEntityString(entity);
|
||||
|
||||
|
||||
Party party = null;
|
||||
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
|
||||
if(playerData.partyUUID != null){
|
||||
Party findParty = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
if(findParty != null && findParty.getQuestData() != null){
|
||||
party = findParty;
|
||||
activeQuestValues.add(0, findParty.getQuestData());
|
||||
}
|
||||
}
|
||||
|
||||
for(QuestData data : activeQuestValues){
|
||||
if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
|
||||
continue;
|
||||
@@ -373,6 +384,9 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
|
||||
questData.checkQuestCompletion(playerData,EnumQuestType.Kill);
|
||||
|
||||
if(party != null)
|
||||
party.checkQuestCompletion(EnumQuestType.Kill);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -202,6 +202,10 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
// Leave Party
|
||||
Client.sendData(EnumPacketServer.LeavePlayer, this.player.getCommandSenderName());
|
||||
break;
|
||||
case 4:
|
||||
// Drop Party Quest
|
||||
Client.sendData(EnumPacketServer.SetPartyQuest, "", "");
|
||||
break;
|
||||
}
|
||||
receivedData = false;
|
||||
initGui();
|
||||
@@ -273,7 +277,10 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
this.showQuestText = true;
|
||||
break;
|
||||
case 410:
|
||||
Client.sendData(EnumPacketServer.SetPartyQuest, "", "");
|
||||
if (this.isLeader) {
|
||||
GuiYesNo yesnoDisband = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.disbandConfirm"), 4);
|
||||
displayGuiScreen(yesnoDisband);
|
||||
}
|
||||
break;
|
||||
}
|
||||
initGui();
|
||||
|
||||
@@ -2,6 +2,8 @@ package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -21,7 +23,7 @@ import tconstruct.client.tabs.TabRegistry;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,ICustomScrollListener, IGuiData, IPartyData {
|
||||
public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,ICustomScrollListener, IGuiData, IPartyData, GuiYesNoCallback {
|
||||
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
|
||||
|
||||
@@ -117,6 +119,18 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
getButton(3).visible = getButton(4).visible;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean flag, int i) {
|
||||
if (flag) {
|
||||
if (i == 0) {
|
||||
Client.sendData(EnumPacketServer.SetPartyQuest, data.selectedCategory, data.selectedQuest);
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
displayGuiScreen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
if(guibutton.id == 1){
|
||||
@@ -130,7 +144,8 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
if (Objects.equals(ClientCacheHandler.party.getCurrentQuestName(), data.selectedQuest)) {
|
||||
Client.sendData(EnumPacketServer.SetPartyQuest, "", "");
|
||||
} else {
|
||||
Client.sendData(EnumPacketServer.SetPartyQuest, data.selectedCategory, data.selectedQuest);
|
||||
GuiYesNo yesnoDisband = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.setQuestConfirm"), 0);
|
||||
displayGuiScreen(yesnoDisband);
|
||||
}
|
||||
}
|
||||
if(guibutton.id == 4){
|
||||
|
||||
@@ -6,7 +6,7 @@ public enum EnumPartyExchange {
|
||||
Leader("party.leader"),
|
||||
All("party.all"),
|
||||
Enrolled("party.enrolled"),
|
||||
Completer("party.completer");
|
||||
Valid("party.valid");
|
||||
|
||||
String name;
|
||||
|
||||
@@ -17,7 +17,7 @@ public enum EnumPartyExchange {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for(EnumPartyExchange e : values())
|
||||
list.add(e.name);
|
||||
|
||||
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
public enum EnumPartyRequirements {
|
||||
Leader("party.leader"),
|
||||
All("party.all"),
|
||||
Enrolled("party.enrolled"),
|
||||
Valid("party.valid");
|
||||
|
||||
String name;
|
||||
@@ -16,7 +17,7 @@ public enum EnumPartyRequirements {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for(EnumPartyRequirements e : values())
|
||||
list.add(e.name);
|
||||
|
||||
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,7 @@ import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.quests.QuestDialog;
|
||||
|
||||
import java.util.Vector;
|
||||
@@ -24,12 +21,12 @@ public class PlayerQuestController {
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return !data.activeQuests.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public static boolean isQuestActive(EntityPlayer player, int quest){
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return data.activeQuests.containsKey(quest);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isQuestFinished(EntityPlayer player, int questid){
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return data.finishedQuests.containsKey(questid);
|
||||
@@ -56,7 +53,7 @@ public class PlayerQuestController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void setQuestFinished(Quest quest, EntityPlayer player){
|
||||
PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
@@ -73,12 +70,33 @@ public class PlayerQuestController {
|
||||
playerdata.dialogData.dialogsRead.remove(dialog);
|
||||
}
|
||||
}
|
||||
if (questData.sendAlerts) {
|
||||
if (questData != null && questData.sendAlerts) {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.completed", questData.quest.title);
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.completed", ": ", questData.quest.title);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setQuestPartyFinished(Quest quest, EntityPlayer player, QuestData questData ){
|
||||
PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
data.activeQuests.remove(quest.id);
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
data.finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
else
|
||||
data.finishedQuests.put(quest.id,player.worldObj.getTotalWorldTime());
|
||||
|
||||
if(quest.repeat != EnumQuestRepeat.NONE && quest.type == EnumQuestType.Dialog){
|
||||
QuestDialog questdialog = (QuestDialog) quest.questInterface;
|
||||
for(int dialog : questdialog.dialogs.values()){
|
||||
playerdata.dialogData.dialogsRead.remove(dialog);
|
||||
}
|
||||
}
|
||||
if (questData != null && questData.sendAlerts) {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.completed", questData.quest.title);
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.completed", ": ", questData.quest.title);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player){
|
||||
if(quest == null)
|
||||
return false;
|
||||
@@ -86,14 +104,14 @@ public class PlayerQuestController {
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
if(data.activeQuests.containsKey(quest.id))
|
||||
return false;
|
||||
|
||||
|
||||
if(!data.finishedQuests.containsKey(quest.id) || quest.repeat == EnumQuestRepeat.REPEATABLE)
|
||||
return true;
|
||||
if(quest.repeat == EnumQuestRepeat.NONE)
|
||||
return false;
|
||||
|
||||
|
||||
long questTime = data.finishedQuests.get(quest.id);
|
||||
|
||||
|
||||
if(quest.repeat == EnumQuestRepeat.MCDAILY){
|
||||
return player.worldObj.getTotalWorldTime() - questTime >= 24000;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,22 @@ import com.google.gson.JsonParser;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.api.handler.IPlayerQuestData;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.constants.EnumPartyRequirements;
|
||||
import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.quests.QuestInterface;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -175,6 +182,10 @@ public class Party {
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID getLeaderUUID() {
|
||||
return partyLeader;
|
||||
}
|
||||
|
||||
public Collection<String> getPlayerNames() {
|
||||
return this.getPlayerNames(false);
|
||||
}
|
||||
@@ -372,4 +383,32 @@ public class Party {
|
||||
compound.setBoolean("FriendlyFire", this.friendlyFire);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public boolean checkQuestCompletion(EnumQuestType type) {
|
||||
boolean bo = false;
|
||||
if(questData == null)
|
||||
return bo;
|
||||
|
||||
if(questData.quest.type != type && type != null)
|
||||
return bo;
|
||||
|
||||
QuestInterface inter = questData.quest.questInterface;
|
||||
if(inter.isPartyCompleted(this)){
|
||||
if((!questData.isCompleted && questData.quest.completion == EnumQuestCompletion.Npc) || questData.quest.instantPartyComplete(this)){
|
||||
questData.isCompleted = true;
|
||||
if (questData.quest.completion == EnumQuestCompletion.Npc) {
|
||||
// EventHooks.onQuestFinished(player, data.quest);
|
||||
}
|
||||
bo = true;
|
||||
}
|
||||
} else {
|
||||
questData.isCompleted = false;
|
||||
}
|
||||
// if (this.trackedQuest != null && questData.quest.getId() == this.trackedQuest.getId()) {
|
||||
// NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
|
||||
// }
|
||||
QuestItem.pickedUp = null;
|
||||
return bo;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,15 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean instantPartyComplete(Party party) {
|
||||
if(completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questPartyCompletion(party)){
|
||||
// Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Quest copy(){
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(this.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
@@ -81,6 +81,22 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IQuestObjective[] getPartyObjectives(Party party) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
|
||||
for(int i = 0; i < 3; ++i) {
|
||||
if (this.dialogs.containsKey(i)) {
|
||||
Dialog dialog = (Dialog)DialogController.Instance.dialogs.get(this.dialogs.get(i));
|
||||
if (dialog != null) {
|
||||
list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, party, dialog));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
@@ -156,14 +172,23 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
class QuestDialogObjective implements IQuestObjective {
|
||||
private final QuestDialog parent;
|
||||
private final EntityPlayer player;
|
||||
private final Party party;
|
||||
private final Dialog dialog;
|
||||
|
||||
public QuestDialogObjective(QuestDialog this$0, EntityPlayer player, Dialog dialog) {
|
||||
this.parent = this$0;
|
||||
this.player = player;
|
||||
this.dialog = dialog;
|
||||
this.party = null;
|
||||
}
|
||||
|
||||
public QuestDialogObjective(QuestDialog this$0, Party party, Dialog dialog) {
|
||||
this.parent = this$0;
|
||||
this.party = party;
|
||||
this.dialog = dialog;
|
||||
this.player = null;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return this.isCompleted() ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -27,15 +27,8 @@ public abstract class QuestInterface implements IQuestInterface {
|
||||
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
|
||||
public abstract IQuestObjective[] getObjectives(EntityPlayer var1);
|
||||
|
||||
public abstract IQuestObjective[] getPartyObjectives(Party party);
|
||||
|
||||
public abstract Vector<String> getPartyQuestLogStatus(Party party);
|
||||
public abstract boolean isPartyCompleted(Party party);
|
||||
|
||||
public void handlePartyComplete(Party party) {
|
||||
// PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
// if(questData != null && questData.getTrackedQuest() != null){
|
||||
// if (this.questId == PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest().getId()) {
|
||||
// PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.NpcMiscInventory;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.data.IQuestItem;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
@@ -145,6 +149,20 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
return list.toArray(new IQuestObjective[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IQuestObjective[] getPartyObjectives(Party party) {
|
||||
List<IQuestObjective> list = new ArrayList<>();
|
||||
List<ItemStack> questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT);
|
||||
|
||||
for (ItemStack stack : questItems) {
|
||||
if (stack.stackSize > 0) {
|
||||
list.add(new QuestItemObjective(this, party, stack));
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new IQuestObjective[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
@@ -214,13 +232,21 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
class QuestItemObjective implements IQuestObjective {
|
||||
private final QuestItem parent;
|
||||
private final EntityPlayer player;
|
||||
private final Party party;
|
||||
private final ItemStack questItem;
|
||||
|
||||
public QuestItemObjective(QuestItem this$0, EntityPlayer player, ItemStack item) {
|
||||
this.parent = this$0;
|
||||
this.player = player;
|
||||
this.questItem = item;
|
||||
this.party = null;
|
||||
}
|
||||
public QuestItemObjective(QuestItem this$0, Party party, ItemStack item) {
|
||||
this.parent = this$0;
|
||||
this.player = null;
|
||||
this.questItem = item;
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
int count = 0;
|
||||
@@ -230,12 +256,27 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
count += item.stackSize;
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
|
||||
item = this.player.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
}
|
||||
if(player != null){
|
||||
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
|
||||
item = this.player.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
}
|
||||
} else if (party != null){
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP == null)
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < playerMP.inventory.getSizeInventory(); ++i) {
|
||||
item = playerMP.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ValueUtil.clamp(count, 0, this.questItem.stackSize);
|
||||
}
|
||||
@@ -249,9 +290,28 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return NoppesUtilPlayer.compareItems(this.player, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT);
|
||||
if(player != null)
|
||||
return NoppesUtilPlayer.compareItems(this.player, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT);
|
||||
else if(party != null)
|
||||
return comparePartyItems(this.party, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean comparePartyItems(Party party, ItemStack item, boolean ignoreDamage, boolean ignoreNBT){
|
||||
int size = 0;
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP == null)
|
||||
continue;
|
||||
for(ItemStack is : playerMP.inventory.mainInventory){
|
||||
if(is != null && NoppesUtilPlayer.compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
size += is.stackSize;
|
||||
}
|
||||
}
|
||||
return size >= item.stackSize;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.questItem.getDisplayName() + ": " + this.getProgress() + "/" + this.getMaxProgress();
|
||||
}
|
||||
|
||||
@@ -118,6 +118,18 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
public IQuestObjective[] getPartyObjectives(Party party) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
Iterator var3 = this.targets.entrySet().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = (Map.Entry)var3.next();
|
||||
list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, party, (String)entry.getKey(), (Integer)entry.getValue()));
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
@@ -181,6 +193,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
class QuestKillObjective implements IQuestObjective {
|
||||
private final QuestKill parent;
|
||||
private final EntityPlayer player;
|
||||
private final Party party;
|
||||
private final String entity;
|
||||
private final int amount;
|
||||
|
||||
@@ -189,34 +202,66 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
this.player = player;
|
||||
this.entity = entity;
|
||||
this.amount = amount;
|
||||
this.party = null;
|
||||
}
|
||||
|
||||
public QuestKillObjective(QuestKill parent, Party party, String entity, int amount) {
|
||||
this.parent = parent;
|
||||
this.party = party;
|
||||
this.entity = entity;
|
||||
this.amount = amount;
|
||||
this.player = null;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
|
||||
}
|
||||
if(player != null){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
|
||||
}
|
||||
}
|
||||
else if(party != null) {
|
||||
QuestData questdata = party.getQuestData();
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= this.amount) {
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
|
||||
killed.put(this.entity, progress);
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
if(player != null){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
|
||||
killed.put(this.entity, progress);
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
} else if(party != null){
|
||||
QuestData questdata = party.getQuestData();
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
|
||||
killed.put(this.entity, progress);
|
||||
this.parent.setKilled(questdata, killed);
|
||||
party.checkQuestCompletion(EnumQuestType.values()[2]);
|
||||
party.checkQuestCompletion(EnumQuestType.values()[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,23 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
public IQuestObjective[] getPartyObjectives(Party party) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
if (!this.location.isEmpty()) {
|
||||
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, party, this.location, "LocationFound"));
|
||||
}
|
||||
|
||||
if (!this.location2.isEmpty()) {
|
||||
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, party, this.location2, "Location2Found"));
|
||||
}
|
||||
|
||||
if (!this.location3.isEmpty()) {
|
||||
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, party, this.location3, "Location3Found"));
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
@@ -172,6 +189,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
class QuestLocationObjective implements IQuestObjective {
|
||||
private final QuestLocation parent;
|
||||
private final EntityPlayer player;
|
||||
private final Party party;
|
||||
private final String location;
|
||||
private final String nbtName;
|
||||
|
||||
@@ -180,22 +198,40 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
this.player = player;
|
||||
this.location = location;
|
||||
this.nbtName = nbtName;
|
||||
this.party = null;
|
||||
}
|
||||
|
||||
public QuestLocationObjective(QuestLocation this$0, Party party, String location, String nbtName) {
|
||||
this.parent = this$0;
|
||||
this.player = null;
|
||||
this.location = location;
|
||||
this.nbtName = nbtName;
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return this.isCompleted() ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= 1) {
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
|
||||
boolean completed = questData.extraData.getBoolean (this.nbtName);
|
||||
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
|
||||
data.save();
|
||||
}
|
||||
if(player != null){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
|
||||
boolean completed = questData.extraData.getBoolean (this.nbtName);
|
||||
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
|
||||
data.save();
|
||||
}
|
||||
} else if (party != null){
|
||||
QuestData questData = party.getQuestData();
|
||||
boolean completed = questData.extraData.getBoolean (this.nbtName);
|
||||
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||
party.checkQuestCompletion(EnumQuestType.values()[3]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
||||
}
|
||||
@@ -206,15 +242,21 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerQuestData = data.questData;
|
||||
if(playerQuestData != null){
|
||||
QuestData questData = playerQuestData.activeQuests.get(this.parent.questId);
|
||||
if(questData != null){
|
||||
return questData.extraData.getBoolean(this.nbtName);
|
||||
}
|
||||
}
|
||||
QuestData questData = null;
|
||||
|
||||
if(player != null){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerQuestData = data.questData;
|
||||
if(playerQuestData != null){
|
||||
questData = playerQuestData.activeQuests.get(this.parent.questId);
|
||||
}
|
||||
} else if(party != null){
|
||||
questData = party.getQuestData();
|
||||
}
|
||||
|
||||
if(questData != null){
|
||||
return questData.extraData.getBoolean(this.nbtName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user