mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Merge pull request #2304 from poma123/develop/machine-process-complete-event
MachineProcessCompleteEvent
This commit is contained in:
commit
6c7af43574
@ -17,7 +17,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||
|
||||
/**
|
||||
* This {@link Event} is fired whenever a {@link GEOResource} is being freshly generated.
|
||||
* This only ocurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource}
|
||||
* This only occurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource}
|
||||
* but cannot find it.
|
||||
*
|
||||
* You can modify this {@link Event} by listening to it.
|
||||
|
@ -0,0 +1,61 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
/**
|
||||
* This {@link Event} is fired whenever an {@link AContainer} has completed its process.
|
||||
*
|
||||
* @author poma123
|
||||
*
|
||||
*/
|
||||
public class MachineProcessCompleteEvent extends Event {
|
||||
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
private final Block block;
|
||||
private final MachineRecipe machineRecipe;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public MachineProcessCompleteEvent(Block block, MachineRecipe machineRecipe) {
|
||||
this.block = block;
|
||||
this.machineRecipe = machineRecipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the {@link Block} of the machine.
|
||||
*
|
||||
* @return the {@link Block} of the machine
|
||||
*/
|
||||
@Nonnull
|
||||
public Block getMachine() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the used {@link MachineRecipe} in the process.
|
||||
*
|
||||
* @return the {@link MachineRecipe} of the process.
|
||||
*/
|
||||
@Nonnull
|
||||
public MachineRecipe getMachineRecipe() {
|
||||
return machineRecipe;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.MachineProcessCompleteEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -241,12 +243,9 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
|
||||
}
|
||||
|
||||
removeCharge(b.getLocation(), getEnergyConsumption());
|
||||
progress.put(b, timeleft - 1);
|
||||
}
|
||||
else {
|
||||
progress.put(b, timeleft - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
||||
|
||||
@ -254,6 +253,8 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
|
||||
inv.pushItem(output.clone(), getOutputSlots());
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new MachineProcessCompleteEvent(b, getProcessing(b)));
|
||||
|
||||
progress.remove(b);
|
||||
processing.remove(b);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user