mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 23:52:19 +00:00
NpcAPI:
-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:
1 parent
73ceeab907
commit
a895c8bd24
7 files changed
+105
-1
No files matched your search
@@ -11,6 +11,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
@@ -213,4 +214,18 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
|
||||
return (IQuest[])quests.toArray(new IQuest[0]);
|
||||
}
|
||||
|
||||
public long getLastCompletedTime(int id) {
|
||||
if (this.hasFinishedQuest(id)) {
|
||||
return this.finishedQuests.get(id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setLastCompletedTime(int id,long time) {
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
this.finishedQuests.put(id,time);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user