Created
October 30, 2017 18:50
-
-
Save TheMasteredPanda/9b7697ba98657ea3afd0982f15aba781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.pucman.server.conversation.action.block; | |
import io.pucman.common.generic.GenericUtil; | |
import io.pucman.server.conversation.action.Action; | |
import io.pucman.server.conversation.conversable.Conversable; | |
import org.bukkit.block.Block; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.block.BlockEvent; | |
public abstract class BlockAction<E extends BlockEvent> extends Action<Block> implements Listener | |
{ | |
private Conversable conversable = this.getContext().getForWhom(); | |
private Class<E> blockEvent; | |
public BlockAction(Class<E> blockEvent) | |
{ | |
this.blockEvent = blockEvent; | |
} | |
@EventHandler | |
public final void onBlockEvent(BlockEvent e) | |
{ | |
if (!e.getEventName().equals(blockEvent.getName())) { | |
return; | |
} | |
if (!this.hasStarted() || !this.isAwaitingInput()) { | |
return; | |
} | |
this.on(GenericUtil.cast(e, blockEvent)); | |
} | |
public abstract void on(E event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment