use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.
the class QuestInstance method readFromJson_Progress.
private void readFromJson_Progress(NBTTagCompound json) {
completeUsers.clear();
NBTTagList comList = json.getTagList("completed", 10);
for (int i = 0; i < comList.tagCount(); i++) {
NBTBase entry = comList.get(i);
if (entry == null || entry.getId() != 10) {
continue;
}
try {
NBTTagCompound eTag = (NBTTagCompound) entry;
UUID uuid = UUID.fromString(eTag.getString("uuid"));
UserEntry user = new UserEntry(uuid);
user.readFromJson(eTag);
completeUsers.add(user);
} catch (Exception e) {
BetterQuesting.logger.log(Level.ERROR, "Unable to load UUID for quest", e);
}
}
tasks.readFromNBT(json.getTagList("tasks", 10), EnumSaveType.PROGRESS);
}
use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.
the class QuestInstance method update.
/**
* Quest specific living update event. Do not use for item submissions
*/
@Override
public void update(EntityPlayer player) {
UUID playerID = QuestingAPI.getQuestingUUID(player);
if (isComplete(playerID)) {
UserEntry entry = GetUserEntry(playerID);
if (!hasClaimed(playerID)) {
if (canClaim(player)) {
// Task logic is not required to run.
if (qInfo.getProperty(NativeProps.AUTO_CLAIM) && player.ticksExisted % 20 == 0) {
claimReward(player);
}
return;
} else if (qInfo.getProperty(NativeProps.REPEAT_TIME).intValue() < 0 || rewards.size() <= 0) {
// Task is non repeatable or has no rewards to claim
return;
} else {
// Task logic will now run for repeat quest
}
} else if (rewards.size() > 0 && qInfo.getProperty(NativeProps.REPEAT_TIME).intValue() >= 0 && player.world.getTotalWorldTime() - entry.getTimestamp() >= qInfo.getProperty(NativeProps.REPEAT_TIME).intValue()) {
// Task is scheduled to reset
if (qInfo.getProperty(NativeProps.GLOBAL)) {
resetAll(false);
} else {
resetUser(playerID, false);
}
if (!QuestSettings.INSTANCE.getProperty(NativeProps.EDIT_MODE) && !qInfo.getProperty(NativeProps.SILENT)) {
postPresetNotice(player, 1);
}
PacketSender.INSTANCE.sendToAll(getSyncPacket());
return;
} else {
// No reset or reset is pending
return;
}
}
if (isUnlocked(playerID) || qInfo.getProperty(NativeProps.LOCKED_PROGRESS)) {
int done = 0;
for (ITask tsk : tasks.getAllValues()) {
if (tsk.isComplete(playerID)) {
IParty party = PartyManager.INSTANCE.getUserParty(playerID);
if (// Ensures task is marked as complete for all team members
party != null) {
for (UUID mem : party.getMembers()) {
tsk.setComplete(mem);
}
}
done += 1;
}
}
if (!isUnlocked(playerID)) {
return;
} else if ((tasks.size() > 0 || !QuestSettings.INSTANCE.getProperty(NativeProps.EDIT_MODE)) && qInfo.getProperty(NativeProps.LOGIC_TASK).getResult(done, tasks.size())) {
setComplete(playerID, player.world.getTotalWorldTime());
PacketSender.INSTANCE.sendToAll(getSyncPacket());
if (!QuestSettings.INSTANCE.getProperty(NativeProps.EDIT_MODE) && !qInfo.getProperty(NativeProps.SILENT)) {
postPresetNotice(player, 2);
}
} else if (done > 0 && qInfo.getProperty(NativeProps.SIMULTANEOUS)) {
resetUser(playerID, false);
PacketSender.INSTANCE.sendToAll(getSyncPacket());
}
}
}
Aggregations