-Added millisToTime(long) and ticksToTime(long) functions to return time formatted strings from long values.

IPlayerQuestData:
-Added last completed time functions for repeating quests.

IQuest:
-Added repeat functions for repeating quests.

ServerCloneController:
-Fixed cloned NPCs having identical UUIDs.
This commit is contained in:
Luis C.M committed 2022-12-20 09:21:39 -06:00
1 parent 73ceeab907
commit a895c8bd24
7 files changed
+105 -1

No files matched your search

@@ -8,6 +8,7 @@ import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.quests.QuestDialog;
import noppes.npcs.quests.QuestInterface;
@@ -146,6 +147,22 @@ public class Quest implements ICompatibilty, IQuest {
quest.readNBT(this.writeToNBT(new NBTTagCompound()));
return quest;
}
public long getTimeUntilRepeat(EntityPlayer player) {
long questTime = PlayerDataController.instance.getPlayerData(player).getQuestData().getLastCompletedTime(this.id);
switch (repeat) {
case MCDAILY:
return Math.max(0, questTime + 24000 - player.worldObj.getTotalWorldTime());
case MCWEEKLY:
return Math.max(0, questTime + 168000 - player.worldObj.getTotalWorldTime());
case RLDAILY:
return Math.max(0, questTime + 86400000 - System.currentTimeMillis());
case RLWEEKLY:
return Math.max(0, questTime + 604800000 - System.currentTimeMillis());
}
return 0L;
}
@Override
public int getVersion() {
@@ -239,6 +256,21 @@ public class Quest implements ICompatibilty, IQuest {
return this.repeat != EnumQuestRepeat.NONE;
}
public long getTimeUntilRepeat(IPlayer player) {
return this.getTimeUntilRepeat((EntityPlayer) player.getMCEntity());
}
public void setRepeatType(int type) {
if (type < 0 || type >= EnumQuestRepeat.values().length) {
return;
}
this.repeat = EnumQuestRepeat.values()[type];
}
public int getRepeatType() {
return this.repeat.ordinal();
}
public IContainer getRewards() {
return NpcAPI.Instance().getIContainer(this.rewardItems);
}