mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-16 15:46:09 +01:00
Almost finished Stage time delay
> Add time delay reading to loadQuests()
This commit is contained in:
parent
ce2aabc98e
commit
028e33f7cf
@ -740,16 +740,12 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
for (String s : quester.completedQuests) {
|
for (String s : quester.completedQuests) {
|
||||||
|
|
||||||
for (Quest q : plugin.quests) {
|
Quest q = plugin.getQuest(s);
|
||||||
|
|
||||||
if (q.name.equalsIgnoreCase(s)) {
|
if (q != null) {
|
||||||
|
|
||||||
if (quester.completedTimes.containsKey(q.name) == false && q.redoDelay > -1) {
|
if (quester.completedTimes.containsKey(q.name) == false && q.redoDelay > -1)
|
||||||
quester.completedTimes.put(q.name, System.currentTimeMillis());
|
quester.completedTimes.put(q.name, System.currentTimeMillis());
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,6 +753,16 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
quester.checkQuest();
|
quester.checkQuest();
|
||||||
|
|
||||||
|
if(quester.currentQuest != null){
|
||||||
|
|
||||||
|
if(quester.currentStage.delay > -1){
|
||||||
|
|
||||||
|
quester.startStageTimer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -767,6 +773,8 @@ public class PlayerListener implements Listener {
|
|||||||
if(plugin.checkQuester(evt.getPlayer().getName()) == false){
|
if(plugin.checkQuester(evt.getPlayer().getName()) == false){
|
||||||
|
|
||||||
Quester quester = plugin.getQuester(evt.getPlayer().getName());
|
Quester quester = plugin.getQuester(evt.getPlayer().getName());
|
||||||
|
if(quester.currentStage.delay > -1)
|
||||||
|
quester.stopStageTimer();
|
||||||
quester.saveData();
|
quester.saveData();
|
||||||
plugin.questers.remove(quester.name);
|
plugin.questers.remove(quester.name);
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ public class Quest {
|
|||||||
//
|
//
|
||||||
public void nextStage(Quester q){
|
public void nextStage(Quester q){
|
||||||
|
|
||||||
|
if(q.currentStage.delay < 0){
|
||||||
|
|
||||||
Player player = plugin.getServer().getPlayerExact(q.name);
|
Player player = plugin.getServer().getPlayerExact(q.name);
|
||||||
|
|
||||||
if(stages.indexOf(q.currentStage) == (stages.size() - 1)){
|
if(stages.indexOf(q.currentStage) == (stages.size() - 1)){
|
||||||
@ -93,6 +95,15 @@ public class Quest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
q.delayStartTime = 0;
|
||||||
|
q.delayTimeLeft = -1;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
q.startStageTimer();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(){
|
public String getName(){
|
||||||
|
@ -1887,11 +1887,8 @@ public class Quester {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(delayStartTime > 0){
|
if(delayTimeLeft > 0)
|
||||||
|
data.set("stage-delay", delayTimeLeft);
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -2575,15 +2572,15 @@ public class Quester {
|
|||||||
public void startStageTimer(){
|
public void startStageTimer(){
|
||||||
|
|
||||||
if(delayTimeLeft > -1)
|
if(delayTimeLeft > -1)
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(this), delayTimeLeft*50);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), delayTimeLeft*50);
|
||||||
else
|
else
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(this), currentStage.delay);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), currentStage.delay);
|
||||||
|
|
||||||
delayStartTime = System.currentTimeMillis();
|
delayStartTime = System.currentTimeMillis();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopTimer(){
|
public void stopStageTimer(){
|
||||||
|
|
||||||
if(delayTimeLeft > -1)
|
if(delayTimeLeft > -1)
|
||||||
delayTimeLeft = delayTimeLeft - (System.currentTimeMillis() - delayStartTime);
|
delayTimeLeft = delayTimeLeft - (System.currentTimeMillis() - delayStartTime);
|
||||||
@ -2594,6 +2591,15 @@ public class Quester {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getStageTime(){
|
||||||
|
|
||||||
|
if(delayTimeLeft > -1)
|
||||||
|
return delayTimeLeft - (System.currentTimeMillis() - delayStartTime);
|
||||||
|
else
|
||||||
|
return currentStage.delay - (System.currentTimeMillis() - delayStartTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void checkQuest() {
|
public void checkQuest() {
|
||||||
|
|
||||||
if (currentQuest != null) {
|
if (currentQuest != null) {
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package me.blackvein.quests;
|
package me.blackvein.quests;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class StageTimer implements Runnable{
|
public class StageTimer implements Runnable{
|
||||||
|
|
||||||
Quester quester;
|
Quester quester;
|
||||||
|
Quests plugin;
|
||||||
|
|
||||||
public StageTimer(Quester q){
|
public StageTimer(Quests quests, Quester q){
|
||||||
|
|
||||||
quester = q;
|
quester = q;
|
||||||
|
plugin = quests;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +19,41 @@ public class StageTimer implements Runnable{
|
|||||||
public void run(){
|
public void run(){
|
||||||
|
|
||||||
if(quester.delayOver){
|
if(quester.delayOver){
|
||||||
quester.currentQuest.nextStage(quester);
|
|
||||||
|
Player player = plugin.getServer().getPlayerExact(quester.name);
|
||||||
|
|
||||||
|
if(quester.currentQuest.stages.indexOf(quester.currentStage) == (quester.currentQuest.stages.size() - 1)){
|
||||||
|
|
||||||
|
if(quester.currentStage.script != null)
|
||||||
|
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
|
||||||
|
if(quester.currentStage.event != null)
|
||||||
|
quester.currentStage.event.happen(player);
|
||||||
|
|
||||||
|
quester.currentQuest.completeQuest(quester);
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
quester.reset();
|
||||||
|
player.sendMessage(plugin.parseString(quester.currentStage.finished, quester.currentQuest));
|
||||||
|
if(quester.currentStage.script != null)
|
||||||
|
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
|
||||||
|
if(quester.currentStage.event != null)
|
||||||
|
quester.currentStage.event.happen(player);
|
||||||
|
quester.currentStage = quester.currentQuest.stages.get(quester.currentQuest.stages.indexOf(quester.currentStage) + 1);
|
||||||
|
quester.addEmpties();
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||||
|
for(String s : quester.getObjectives()){
|
||||||
|
|
||||||
|
player.sendMessage(s);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
quester.delayStartTime = 0;
|
||||||
|
quester.delayTimeLeft = -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quester.delayOver = true;
|
quester.delayOver = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user