mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 07:35:11 +00:00
Apply Universal QuestData to Party
This commit is contained in:
1 parent
3e0a2d29a3
commit
607b3f54d8
8 files changed
+253
-33
No files matched your search
@@ -279,13 +279,13 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = party.writeToNBT();
|
||||
if (party.getQuest() != null) {
|
||||
Quest quest = (Quest) party.getQuest();
|
||||
Vector<String> vector = quest.questInterface.getQuestLogStatus(player);
|
||||
Vector<String> vector = quest.questInterface.getPartyQuestLogStatus(party);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (String s : vector) {
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
compound.setTag("QuestProgress", list);
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData)) {
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) {
|
||||
compound.setString("QuestCompleteWith", quest.completerNpc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,23 +104,24 @@ public class PartyController {
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = party.writeToNBT();
|
||||
if (party.getQuest() != null) {
|
||||
Quest quest = (Quest) party.getQuest();
|
||||
Vector<String> vector = quest.questInterface.getPartyQuestLogStatus(party);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (String s : vector) {
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
compound.setTag("QuestProgress", list);
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) {
|
||||
compound.setString("QuestCompleteWith", quest.completerNpc);
|
||||
}
|
||||
}
|
||||
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP != null){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP);
|
||||
if(playerData != null){
|
||||
if (party.getQuest() != null) {
|
||||
Quest quest = (Quest) party.getQuest();
|
||||
Vector<String> vector = quest.questInterface.getQuestLogStatus(playerMP);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (String s : vector) {
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
compound.setTag("QuestProgress", list);
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData)) {
|
||||
compound.setString("QuestCompleteWith", quest.completerNpc);
|
||||
}
|
||||
}
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.PARTY_DATA, compound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.UUID;
|
||||
public class Party {
|
||||
private final UUID partyUUID;
|
||||
private UUID partyLeader;
|
||||
private QuestData questData;
|
||||
|
||||
private final HashMap<UUID, String> partyMembers = new HashMap<>();
|
||||
private final ArrayList<UUID> partyOrder = new ArrayList<>();
|
||||
@@ -60,11 +61,12 @@ public class Party {
|
||||
if (quest != null) {
|
||||
this.currentQuestID = quest.getId();
|
||||
this.currentQuestName = quest.getName();
|
||||
this.questData = new QuestData((Quest) quest);
|
||||
} else {
|
||||
this.currentQuestID = -1;
|
||||
this.currentQuestName = "";
|
||||
this.questData = null;
|
||||
}
|
||||
|
||||
this.partyLocked = quest != null;
|
||||
}
|
||||
|
||||
@@ -76,6 +78,10 @@ public class Party {
|
||||
}
|
||||
}
|
||||
|
||||
public QuestData getQuestData() {
|
||||
return questData;
|
||||
}
|
||||
|
||||
public int getCurrentQuestID() {
|
||||
return currentQuestID;
|
||||
}
|
||||
@@ -220,7 +226,7 @@ public class Party {
|
||||
sendInfoMessage(leader, "\u00A7aQuest set to party!");
|
||||
}
|
||||
else {
|
||||
sendInfoMessage(leader, "You are invalid for this quest");
|
||||
sendInfoMessage(leader, "\u00A7cYou are invalid for this quest");
|
||||
}
|
||||
return leaderBool;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.data.IQuestDialog;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.*;
|
||||
|
||||
import static noppes.npcs.PacketHandlerServer.sendInviteData;
|
||||
|
||||
public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
|
||||
@@ -58,7 +62,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
title += " (unread)";
|
||||
vec.add(title);
|
||||
}
|
||||
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -77,7 +81,79 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
class QuestDialogObjective implements IQuestObjective {
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
for(int dialogId : dialogs.values()){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
|
||||
ArrayList<String> unread = new ArrayList<>();
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData playerData;
|
||||
if(player != null){
|
||||
playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
else {
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(playerData != null){
|
||||
if(!playerData.dialogData.dialogsRead.contains(dialogId))
|
||||
unread.add(playerData.playername);
|
||||
}
|
||||
}
|
||||
|
||||
String title = dialog.title;
|
||||
if(!unread.isEmpty()){
|
||||
title += " (unread)";
|
||||
}
|
||||
else {
|
||||
title += " (read)";
|
||||
}
|
||||
vec.add(title);
|
||||
|
||||
if(!unread.isEmpty()){
|
||||
StringBuilder unreaders = new StringBuilder("> ");
|
||||
for(String name : unread){
|
||||
unreaders.append(" ").append(name);
|
||||
}
|
||||
vec.add(unreaders.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
if(party == null)
|
||||
return false;
|
||||
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData playerData;
|
||||
if(player != null){
|
||||
playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
else {
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(playerData != null){
|
||||
for(int dialogId : dialogs.values()){
|
||||
if(!playerData.dialogData.dialogsRead.contains(dialogId)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class QuestDialogObjective implements IQuestObjective {
|
||||
private final QuestDialog parent;
|
||||
private final EntityPlayer player;
|
||||
private final Dialog dialog;
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.api.handler.data.IQuestInterface;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
|
||||
@@ -25,4 +26,16 @@ public abstract class QuestInterface implements IQuestInterface {
|
||||
}
|
||||
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
|
||||
public abstract IQuestObjective[] getObjectives(EntityPlayer var1);
|
||||
|
||||
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();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.NpcMiscInventory;
|
||||
import noppes.npcs.api.handler.data.IQuestItem;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
@@ -51,8 +52,8 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
if(!done)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
public HashMap<Integer,ItemStack> getProcessSet(EntityPlayer player){
|
||||
@@ -80,6 +81,7 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleComplete(EntityPlayer player) {
|
||||
super.handleComplete(player);
|
||||
@@ -143,7 +145,52 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
return list.toArray(new IQuestObjective[0]);
|
||||
}
|
||||
|
||||
public void setLeaveItems(boolean leaveItems){
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
HashMap<Integer,ItemStack> map = getProcessSetParty(party);
|
||||
for(int slot : map.keySet()){
|
||||
ItemStack item = map.get(slot);
|
||||
ItemStack quest = items.items.get(slot);
|
||||
if(item == null)
|
||||
continue;
|
||||
String process = item.stackSize + "";
|
||||
if(item.stackSize > quest.stackSize)
|
||||
process = quest.stackSize + "";
|
||||
process += "/" + quest.stackSize + "";
|
||||
if(item.hasDisplayName())
|
||||
vec.add(item.getDisplayName() + ": " + process);
|
||||
else
|
||||
vec.add(item.getUnlocalizedName() + ".name" + ": " + process);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
HashMap<Integer,ItemStack> map = getProcessSetParty(party);
|
||||
for(ItemStack reqItem : items.items.values()){
|
||||
boolean done = false;
|
||||
for(ItemStack item : map.values()){
|
||||
if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize){
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!done)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<Integer,ItemStack> getProcessSetParty(Party party){
|
||||
HashMap<Integer,ItemStack> map = new HashMap<Integer,ItemStack>();
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setLeaveItems(boolean leaveItems){
|
||||
this.leaveItems = leaveItems;
|
||||
}
|
||||
public boolean getLeaveItems(){
|
||||
|
||||
@@ -7,6 +7,7 @@ import noppes.npcs.api.handler.data.IQuestKill;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
@@ -68,7 +69,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
if(!targets.containsKey(entity) || targets.get(entity) > killed.get(entity))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -91,10 +92,10 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
if(killed.containsKey(entityName))
|
||||
amount = killed.get(entityName);
|
||||
String state = amount + "/" + targets.get(entityName);
|
||||
|
||||
|
||||
vec.add(entityName + ": " + state);
|
||||
}
|
||||
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -117,7 +118,55 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
public void setTargetType(int type) {
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return vec;
|
||||
HashMap<String,Integer> killed = getKilled(data);
|
||||
for(String entityName : targets.keySet()){
|
||||
int amount = 0;
|
||||
if(killed.containsKey(entityName))
|
||||
amount = killed.get(entityName);
|
||||
String state = amount + "/" + targets.get(entityName);
|
||||
|
||||
vec.add(entityName + ": " + state);
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return false;
|
||||
|
||||
HashMap<String,Integer> killed = getKilled(data);
|
||||
int completed = 0;
|
||||
for(String entityName : targets.keySet()){
|
||||
int amount = 0;
|
||||
if(killed.containsKey(entityName))
|
||||
amount = killed.get(entityName);
|
||||
if(amount >= targets.get(entityName)){
|
||||
completed++;
|
||||
}
|
||||
}
|
||||
if(completed >= targets.keySet().size())
|
||||
return true;
|
||||
|
||||
if(killed.size() != targets.size())
|
||||
return false;
|
||||
for(String entity : killed.keySet()){
|
||||
if(!targets.containsKey(entity) || targets.get(entity) > killed.get(entity))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setTargetType(int type) {
|
||||
if(type < 0)
|
||||
type = 0;
|
||||
if(type > 2)
|
||||
|
||||
@@ -7,6 +7,7 @@ import noppes.npcs.api.handler.data.IQuestLocation;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
@@ -26,7 +27,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
location = compound.getString("QuestLocation");
|
||||
location2 = compound.getString("QuestLocation2");
|
||||
location3 = compound.getString("QuestLocation3");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,7 +67,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
vec.add(location2 + ": " + (getFound(data,2)?found:notfound));
|
||||
if(!location3.isEmpty())
|
||||
vec.add(location3 + ": " + (getFound(data,3)?found:notfound));
|
||||
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
data.extraData.setBoolean("Location3Found", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -120,7 +121,34 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
public void setLocation1(String loc1){
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return vec;
|
||||
String found = StatCollector.translateToLocal("quest.found");
|
||||
String notfound = StatCollector.translateToLocal("quest.notfound");
|
||||
|
||||
if(!location.isEmpty())
|
||||
vec.add(location + ": " + (getFound(data,1)?found:notfound));
|
||||
if(!location2.isEmpty())
|
||||
vec.add(location2 + ": " + (getFound(data,2)?found:notfound));
|
||||
if(!location3.isEmpty())
|
||||
vec.add(location3 + ": " + (getFound(data,3)?found:notfound));
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return false;
|
||||
return getFound(data, 0);
|
||||
}
|
||||
|
||||
public void setLocation1(String loc1){
|
||||
this.location = loc1;
|
||||
}
|
||||
public String getLocation1(){
|
||||
|
||||
Reference in new issue
Block a user