Makes ActionStartEvent give duration in ticks instead of end time
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2024-07-29 01:40:08 +02:00
parent 523e4cb47a
commit afb608b609
5 changed files with 43 additions and 47 deletions

View File

@@ -99,22 +99,15 @@ public abstract class Session implements Runnable {
BukkitScheduler scheduler = BlacksmithPlugin.getInstance().getServer().getScheduler();
int actionDelay = getActionDelay();
this.finishTime = System.currentTimeMillis() + (actionDelay * 1000L);
long actionDelayTicks = actionDelay * 20L;
if (this instanceof ReforgeSession) {
BlacksmithPlugin.getInstance().callEvent(new BlacksmithReforgeStartEvent(npc, player, this.finishTime));
BlacksmithPlugin.getInstance().callEvent(new BlacksmithReforgeStartEvent(npc, player, actionDelayTicks));
} else if (this instanceof SalvageSession) {
BlacksmithPlugin.getInstance().callEvent(new ScrapperSalvageStartEvent(npc, player, this.finishTime));
BlacksmithPlugin.getInstance().callEvent(new ScrapperSalvageStartEvent(npc, player, actionDelayTicks));
}
taskId = scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), this, actionDelay * 20L);
int playWorkSound = scheduler.scheduleSyncRepeatingTask(BlacksmithPlugin.getInstance(),
() -> {
if (random.nextInt(100) < 20) {
this.playWorkSound();
}
}, 20, 5);
scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), () -> scheduler.cancelTask(playWorkSound),
(actionDelay * 20L) - 20);
taskId = scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), this, actionDelayTicks);
}
/**
@@ -174,13 +167,6 @@ public abstract class Session implements Runnable {
playSound(this.npc.getEntity(), sound);
}
/**
* Plays the working NPC sound
*/
protected void playWorkSound() {
playSound(this.npc.getEntity(), Sound.ITEM_ARMOR_EQUIP_NETHERITE);
}
/**
* Plays a npc sound using a cancellable event
*