Search in sources :

Example 1 with UserEntry

use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.

the class QuestInstance method RemoveUserEntry.

private void RemoveUserEntry(UUID... uuid) {
    boolean flag = false;
    for (int i = completeUsers.size() - 1; i >= 0; i--) {
        UserEntry entry = completeUsers.get(i);
        for (UUID id : uuid) {
            if (entry.getUUID().equals(id)) {
                completeUsers.remove(i);
                flag = true;
                break;
            }
        }
    }
    if (flag) {
        PacketSender.INSTANCE.sendToAll(getSyncPacket());
    }
}
Also used : UserEntry(betterquesting.misc.UserEntry) UUID(java.util.UUID)

Example 2 with UserEntry

use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.

the class QuestInstance method canSubmit.

@Override
public boolean canSubmit(EntityPlayer player) {
    if (player == null) {
        return false;
    }
    UUID playerID = QuestingAPI.getQuestingUUID(player);
    UserEntry entry = this.GetUserEntry(playerID);
    if (// Incomplete
    entry == null) {
        return true;
    } else if (// Complete but repeatable
    !entry.hasClaimed() && getProperties().getProperty(NativeProps.REPEAT_TIME).intValue() >= 0) {
        int done = 0;
        for (ITask tsk : tasks.getAllValues()) {
            if (tsk.isComplete(playerID)) {
                done += 1;
            }
        }
        return !qInfo.getProperty(NativeProps.LOGIC_TASK).getResult(done, tasks.size());
    } else {
        return false;
    }
}
Also used : ITask(betterquesting.api.questing.tasks.ITask) UserEntry(betterquesting.misc.UserEntry) UUID(java.util.UUID)

Example 3 with UserEntry

use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.

the class QuestInstance method writeToJson_Progress.

private NBTTagCompound writeToJson_Progress(NBTTagCompound json) {
    NBTTagList comJson = new NBTTagList();
    for (UserEntry entry : completeUsers) {
        comJson.appendTag(entry.writeToJson(new NBTTagCompound()));
    }
    json.setTag("completed", comJson);
    NBTTagList tskJson = tasks.writeToNBT(new NBTTagList(), EnumSaveType.PROGRESS);
    json.setTag("tasks", tskJson);
    return json;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) UserEntry(betterquesting.misc.UserEntry)

Example 4 with UserEntry

use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.

the class QuestInstance method claimReward.

@Override
public void claimReward(EntityPlayer player) {
    for (IReward rew : rewards.getAllValues()) {
        rew.claimReward(player, this);
    }
    UUID pID = QuestingAPI.getQuestingUUID(player);
    IParty party = PartyManager.INSTANCE.getUserParty(pID);
    if (party != null && this.qInfo.getProperty(NativeProps.PARTY_LOOT)) {
        for (UUID mem : party.getMembers()) {
            EnumPartyStatus pStat = party.getStatus(mem);
            if (pStat == null || pStat == EnumPartyStatus.INVITE) {
                continue;
            }
            UserEntry entry = GetUserEntry(mem);
            if (entry == null) {
                entry = new UserEntry(mem);
                this.completeUsers.add(entry);
            }
            entry.setClaimed(true, player.world.getTotalWorldTime());
        }
    } else {
        UserEntry entry = GetUserEntry(pID);
        if (entry == null) {
            entry = new UserEntry(pID);
            this.completeUsers.add(entry);
        }
        entry.setClaimed(true, player.world.getTotalWorldTime());
    }
    PacketSender.INSTANCE.sendToAll(getSyncPacket());
}
Also used : EnumPartyStatus(betterquesting.api.enums.EnumPartyStatus) IReward(betterquesting.api.questing.rewards.IReward) UserEntry(betterquesting.misc.UserEntry) IParty(betterquesting.api.questing.party.IParty) UUID(java.util.UUID)

Example 5 with UserEntry

use of betterquesting.misc.UserEntry in project BetterQuesting by Funwayguy.

the class QuestInstance method setClaimed.

/**
 * Temporary hack to make this a thing for users
 */
public void setClaimed(UUID uuid, long timestamp) {
    IParty party = PartyManager.INSTANCE.getUserParty(uuid);
    if (party == null) {
        UserEntry entry = this.GetUserEntry(uuid);
        if (entry != null) {
            entry.setClaimed(true, timestamp);
        } else {
            entry = new UserEntry(uuid, timestamp);
            entry.setClaimed(true, timestamp);
            completeUsers.add(entry);
        }
    } else {
        for (UUID mem : party.getMembers()) {
            UserEntry entry = this.GetUserEntry(mem);
            if (entry != null) {
                entry.setClaimed(true, timestamp);
            } else {
                entry = new UserEntry(mem, timestamp);
                entry.setClaimed(true, timestamp);
                completeUsers.add(entry);
            }
        }
    }
}
Also used : UserEntry(betterquesting.misc.UserEntry) IParty(betterquesting.api.questing.party.IParty) UUID(java.util.UUID)

Aggregations

UserEntry (betterquesting.misc.UserEntry)7 UUID (java.util.UUID)6 IParty (betterquesting.api.questing.party.IParty)3 ITask (betterquesting.api.questing.tasks.ITask)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 EnumPartyStatus (betterquesting.api.enums.EnumPartyStatus)1 IReward (betterquesting.api.questing.rewards.IReward)1 NBTBase (net.minecraft.nbt.NBTBase)1