mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 01:05:12 +00:00
Quest Location Party Complete
This commit is contained in:
1 parent
827f78bc97
commit
bf6a77d183
7 files changed
+177
-39
No files matched your search
@@ -19,6 +19,7 @@ import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.containers.ContainerMail;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -199,6 +200,10 @@ public class PacketHandlerPlayer{
|
||||
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, null);
|
||||
|
||||
questData.checkQuestCompletion(playerData, null);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.QuestLog){
|
||||
|
||||
@@ -402,6 +402,11 @@ public class ServerEventsHandler {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
QuestItem.pickedUp = event.item.getEntityItem();
|
||||
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item);
|
||||
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,24 +7,23 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.quests.QuestLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileWaypoint extends TileEntity {
|
||||
|
||||
|
||||
public String name = "";
|
||||
|
||||
private int ticks = 10;
|
||||
private List<EntityPlayer> recentlyChecked = new ArrayList<EntityPlayer>();
|
||||
private List<EntityPlayer> toCheck;
|
||||
public int range = 10;
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
if(worldObj.isRemote || name.isEmpty())
|
||||
@@ -40,21 +39,36 @@ public class TileWaypoint extends TileEntity {
|
||||
List<EntityPlayer> listMax = getPlayerList(range + 10, range + 10, range + 10);
|
||||
recentlyChecked.retainAll(listMax);
|
||||
recentlyChecked.addAll(toCheck);
|
||||
|
||||
|
||||
if(toCheck.isEmpty())
|
||||
return;
|
||||
for(EntityPlayer player : toCheck){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
Party party = playerData.getPlayerParty();
|
||||
Quest partyQuest = null;
|
||||
if(party != null && party.getQuestData() != null && party.getQuestData().quest != null && party.getQuestData().quest.type == EnumQuestType.Location){
|
||||
QuestData partyQuestData = party.getQuestData();
|
||||
partyQuest = partyQuestData.quest;
|
||||
QuestLocation partyQuestLocation = (QuestLocation) partyQuestData.quest.questInterface;
|
||||
boolean isPartyLeader = player.getUniqueID().equals(party.getLeaderUUID());
|
||||
if(partyQuestLocation.setFoundParty(party, player, name, isPartyLeader)){
|
||||
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found")));
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Location);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
|
||||
for(QuestData data : activeQuestValues){
|
||||
if(data.quest.type != EnumQuestType.Location)
|
||||
continue;
|
||||
|
||||
if(partyQuest != null && partyQuest.id == data.quest.getId())
|
||||
continue;
|
||||
|
||||
QuestLocation quest = (QuestLocation) data.quest.questInterface;
|
||||
if(quest.setFound(data, name)){
|
||||
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found")));
|
||||
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Location);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +76,7 @@ public class TileWaypoint extends TileEntity {
|
||||
}
|
||||
|
||||
private List<EntityPlayer> getPlayerList(int x, int y, int z){
|
||||
return worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(x, y, z));
|
||||
return worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1).expand(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@ public class PartyOptions implements IPartyOptions {
|
||||
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
|
||||
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
|
||||
|
||||
public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.All;
|
||||
public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared;
|
||||
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
|
||||
@@ -226,6 +226,13 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
}
|
||||
|
||||
public Party getPlayerParty() {
|
||||
if (partyUUID != null) {
|
||||
return PartyController.Instance().getParty(partyUUID);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashSet<UUID> getPartyInvites() {
|
||||
return (HashSet<UUID>) this.partyInvites.clone();
|
||||
}
|
||||
|
||||
@@ -3,15 +3,14 @@ package noppes.npcs.quests;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.handler.data.IQuestLocation;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumPartyObjectives;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
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;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -23,12 +22,11 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
public String location2 = "";
|
||||
public String location3 = "";
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||
location = compound.getString("QuestLocation");
|
||||
location2 = compound.getString("QuestLocation2");
|
||||
location3 = compound.getString("QuestLocation3");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,21 +71,22 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
}
|
||||
|
||||
public boolean getFound(QuestData data, int i) {
|
||||
if(i == 1)
|
||||
return data.extraData.getBoolean("LocationFound");
|
||||
if(i == 2)
|
||||
return data.extraData.getBoolean("Location2Found");
|
||||
if(i == 3)
|
||||
return data.extraData.getBoolean("Location3Found");
|
||||
if(i == 1)
|
||||
return data.extraData.getBoolean("LocationFound");
|
||||
if(i == 2)
|
||||
return data.extraData.getBoolean("Location2Found");
|
||||
if(i == 3)
|
||||
return data.extraData.getBoolean("Location3Found");
|
||||
|
||||
if(!location.isEmpty() && !data.extraData.getBoolean("LocationFound"))
|
||||
return false;
|
||||
if(!location2.isEmpty() && !data.extraData.getBoolean("Location2Found"))
|
||||
return false;
|
||||
if(!location3.isEmpty() && !data.extraData.getBoolean("Location3Found"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!location.isEmpty() && !data.extraData.getBoolean("LocationFound"))
|
||||
return false;
|
||||
if(!location2.isEmpty() && !data.extraData.getBoolean("Location2Found"))
|
||||
return false;
|
||||
if(!location3.isEmpty() && !data.extraData.getBoolean("Location3Found"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
public boolean setFound(QuestData data, String location) {
|
||||
if(location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")){
|
||||
data.extraData.setBoolean("LocationFound", true);
|
||||
@@ -105,6 +104,92 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setFoundParty(Party party, EntityPlayer player, String location, boolean isLeader) {
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return false;
|
||||
|
||||
if(data.quest == null)
|
||||
return false;
|
||||
|
||||
int memberCount = party.getPlayerNames().size();
|
||||
EnumPartyObjectives objectives = data.quest.partyOptions.objectiveRequirement;
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
if(location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")){
|
||||
return setPartyPlayerFound(data, player, "PlayersLocationFound", "LocationFound", memberCount);
|
||||
}
|
||||
if(location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")){
|
||||
return setPartyPlayerFound(data, player, "PlayersLocationFound2", "Location2Found", memberCount);
|
||||
}
|
||||
if(location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")){
|
||||
return setPartyPlayerFound(data, player, "PlayersLocationFound3", "Location3Found", memberCount);
|
||||
}
|
||||
}
|
||||
else if(objectives == EnumPartyObjectives.Leader && isLeader || objectives == EnumPartyObjectives.Shared){
|
||||
if(location.equalsIgnoreCase(this.location) && !data.extraData.getBoolean("LocationFound")){
|
||||
data.extraData.setBoolean("LocationFound", true);
|
||||
return true;
|
||||
}
|
||||
if(location.equalsIgnoreCase(location2) && !data.extraData.getBoolean("LocationFound2")){
|
||||
data.extraData.setBoolean("Location2Found", true);
|
||||
return true;
|
||||
}
|
||||
if(location.equalsIgnoreCase(location3) && !data.extraData.getBoolean("LocationFound3")){
|
||||
data.extraData.setBoolean("Location3Found", true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> getPartyFound(Party party, int i) {
|
||||
List<String> foundPlayers = new ArrayList<>();
|
||||
if(party == null)
|
||||
return foundPlayers;
|
||||
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return foundPlayers;
|
||||
|
||||
String locationKey;
|
||||
if(i == 1)
|
||||
locationKey = "PlayersLocationFound";
|
||||
else if(i == 2)
|
||||
locationKey = "PlayersLocationFound2";
|
||||
else
|
||||
locationKey = "PlayersLocationFound3";
|
||||
|
||||
if(data.extraData.hasKey(locationKey)){
|
||||
foundPlayers = NBTTags.getStringList(data.extraData.getTagList(locationKey, 10));
|
||||
}
|
||||
|
||||
return foundPlayers;
|
||||
}
|
||||
|
||||
|
||||
public boolean setPartyPlayerFound(QuestData data, EntityPlayer player, String locationKey, String locationFoundKey, int partySize) {
|
||||
boolean newFind = false;
|
||||
List<String> foundPlayers;
|
||||
if(data.extraData.hasKey(locationKey)){
|
||||
foundPlayers = NBTTags.getStringList(data.extraData.getTagList(locationKey, 10));
|
||||
}
|
||||
else {
|
||||
foundPlayers = new ArrayList<>();
|
||||
}
|
||||
|
||||
if(!foundPlayers.contains(player.getCommandSenderName())){
|
||||
foundPlayers.add(player.getCommandSenderName());
|
||||
newFind = true;
|
||||
}
|
||||
|
||||
data.extraData.setTag(locationKey, NBTTags.nbtStringList(foundPlayers));
|
||||
if(foundPlayers.size() == partySize){
|
||||
data.extraData.setBoolean(locationFoundKey, true);
|
||||
}
|
||||
|
||||
return newFind;
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
if (!this.location.isEmpty()) {
|
||||
@@ -148,13 +233,34 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
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));
|
||||
if(data.quest == null)
|
||||
return vec;
|
||||
|
||||
boolean requireAll = data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All;
|
||||
if(!location.isEmpty()){
|
||||
vec.add(location + ": " + (getFound(data,1)?found:notfound));
|
||||
if(requireAll){
|
||||
List<String> playersFound = getPartyFound(party, 1);
|
||||
String playersFoundString = "Found: " + String.join(", ", playersFound);
|
||||
vec.add(playersFoundString);
|
||||
}
|
||||
}
|
||||
if(!location2.isEmpty()){
|
||||
vec.add(location2 + ": " + (getFound(data,2)?found:notfound));
|
||||
if(requireAll){
|
||||
List<String> playersFound = getPartyFound(party, 2);
|
||||
String playersFoundString = "Found: " + String.join(", ", playersFound);
|
||||
vec.add(playersFoundString);
|
||||
}
|
||||
}
|
||||
if(!location3.isEmpty()){
|
||||
vec.add(location3 + ": " + (getFound(data,3)?found:notfound));
|
||||
if(requireAll){
|
||||
List<String> playersFound = getPartyFound(party, 3);
|
||||
String playersFoundString = "Found: " + String.join(", ", playersFound);
|
||||
vec.add(playersFoundString);
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
import noppes.npcs.controllers.CustomGuiController;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
@@ -692,6 +689,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
((EntityPlayerMP)this.entity).inventoryContainer.detectAndSendChanges();
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item);
|
||||
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user