Makes ActionStartEvent give duration in ticks instead of end time
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user