Adds information about the appropriate crafting station in ActionStartEvent
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2024-08-03 16:32:44 +02:00
parent 5efba6687c
commit 81c15b6600
9 changed files with 72 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ import net.knarcraft.blacksmith.event.BlacksmithReforgeStartEvent;
import net.knarcraft.blacksmith.event.NPCSoundEvent;
import net.knarcraft.blacksmith.event.ScrapperSalvageStartEvent;
import net.knarcraft.blacksmith.util.ItemHelper;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.World;
@@ -100,10 +101,11 @@ public abstract class Session implements Runnable {
this.finishTime = System.currentTimeMillis() + (actionDelay * 1000L);
long actionDelayTicks = actionDelay * 20L;
BlacksmithPlugin instance = BlacksmithPlugin.getInstance();
if (this instanceof ReforgeSession) {
BlacksmithPlugin.getInstance().callEvent(new BlacksmithReforgeStartEvent(npc, player, actionDelayTicks));
instance.callEvent(new BlacksmithReforgeStartEvent(npc, player, actionDelayTicks, getCraftingStation()));
} else if (this instanceof SalvageSession) {
BlacksmithPlugin.getInstance().callEvent(new ScrapperSalvageStartEvent(npc, player, actionDelayTicks));
instance.callEvent(new ScrapperSalvageStartEvent(npc, player, actionDelayTicks, getCraftingStation()));
}
taskId = scheduler.scheduleSyncDelayedTask(BlacksmithPlugin.getInstance(), this, actionDelayTicks);
@@ -157,6 +159,13 @@ public abstract class Session implements Runnable {
*/
protected abstract int getActionDelay();
/**
* Gets the appropriate crafting station for this session
*
* @return <p>The appropriate crafting station</p>
*/
protected abstract @NotNull Material getCraftingStation();
/**
* Plays an NPC sound
*