1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Added AsyncGeneratorProcessCompleteEvent

This commit is contained in:
poma123 2020-09-19 10:36:27 +02:00
parent 8fee7ad07d
commit fa1aad7bf8
2 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,77 @@
package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Event} is fired whenever an {@link AGenerator} has completed its process.
*
* @author poma123
*
*/
public class AsyncGeneratorProcessCompleteEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final Location location;
private final AGenerator generator;
private final MachineFuel machineFuel;
@ParametersAreNonnullByDefault
public AsyncGeneratorProcessCompleteEvent(Location l, AGenerator generator, MachineFuel machineFuel) {
super(true);
this.location = l;
this.generator = generator;
this.machineFuel = machineFuel;
}
/**
* This returns the {@link Location} of the generator.
*
* @return The {@link Location} of the generator
*/
@Nonnull
public Location getLocation() {
return location;
}
/**
* The {@link SlimefunItem} instance of the generator.
*
* @return The {@link SlimefunItem} instance of the generator
*/
@Nonnull
public AGenerator getGenerator() {
return generator;
}
/**
* This returns the used {@link MachineFuel} in the process.
*
* @return The {@link MachineFuel} of the process
*/
@Nonnull
public MachineFuel getMachineFuel() {
return machineFuel;
}
@Nonnull
public static HandlerList getHandlerList() {
return handlers;
}
@Nonnull
@Override
public HandlerList getHandlers() {
return getHandlerList();
}
}

View File

@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -12,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.events.AsyncGeneratorProcessCompleteEvent;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
@ -163,6 +165,8 @@ public abstract class AGenerator extends AbstractEnergyProvider {
inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
Bukkit.getPluginManager().callEvent(new AsyncGeneratorProcessCompleteEvent(l, AGenerator.this, getProcessing(l)));
progress.remove(l);
processing.remove(l);
return 0;