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());
}
}
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;
}
}
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;
}
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());
}
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);
}
}
}
}
Aggregations