Created
October 26, 2015 15:27
-
-
Save SirEdvin/64a1cd2d70aa42eb18a5 to your computer and use it in GitHub Desktop.
Custom Events Gist
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.github.siredvin.events; | |
import org.bukkit.event.Cancellable; | |
import org.bukkit.event.Event; | |
/** | |
* Created by siredvin on 24.10.15. | |
* | |
* @author siredvin | |
*/ | |
public abstract class AbstractCancellableEvent extends Event implements Cancellable { | |
private boolean canceled; | |
public AbstractCancellableEvent(){ | |
canceled = false; | |
} | |
@Override | |
public boolean isCancelled() { | |
return canceled; | |
} | |
@Override | |
public void setCancelled(boolean b) { | |
canceled = b; | |
} | |
} |
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.github.siredvin.events; | |
import org.bukkit.event.HandlerList; | |
import java.util.UUID; | |
/** | |
* Created by siredvin on 24.10.15. | |
* | |
* @author siredvin | |
*/ | |
public class BlockBlockInteractionEvent extends AbstractCancellableEvent { | |
private static final HandlerList handlers = new HandlerList(); | |
public int blockX,blockY,blockZ; | |
public int x,y,z; | |
public String world; | |
public BlockBlockInteractionEvent() { | |
} | |
@Override | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public BlockBlockInteractionEvent(int blockX, int blockY, int blockZ, int x, int y, int z, String world) { | |
this.blockZ = blockZ; | |
this.blockX = blockX; | |
this.blockY = blockY; | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
this.world = world; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
} |
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.github.siredvin; | |
import cpw.mods.fml.common.Mod; | |
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | |
/** | |
* Created by siredvin on 24.10.15. | |
* | |
* @author siredvin | |
*/ | |
@Mod(modid = CustomEvents.MODID, version = CustomEvents.VERSION, name = "Custom Events" ,acceptableRemoteVersions = "*") | |
public class CustomEvents { | |
public static final String MODID = "customevents"; | |
public static final String VERSION = "0.1-prealpha"; | |
@Mod.Instance("customevents") | |
public static CustomEvents instance; | |
@Mod.EventHandler | |
public void postInit(FMLPostInitializationEvent event){ | |
} | |
} |
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.github.siredvin.events; | |
import cpw.mods.fml.common.eventhandler.Cancelable; | |
import cpw.mods.fml.common.eventhandler.Event; | |
import net.minecraft.entity.player.EntityPlayer; | |
import org.bukkit.event.HandlerList; | |
import java.util.UUID; | |
/** | |
* Created by siredvin on 24.10.15. | |
* | |
* @author siredvin | |
*/ | |
@Cancelable | |
public class PlayerBlockInteractionEvent extends AbstractCancellableEvent { | |
private static final HandlerList handlers = new HandlerList(); | |
public UUID player; | |
public int x,y,z; | |
public PlayerBlockInteractionEvent() { | |
} | |
@Override | |
public HandlerList getHandlers() { | |
return handlers; | |
} | |
public PlayerBlockInteractionEvent(UUID player, int x, int y, int z) { | |
this.player = player; | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
} | |
public static HandlerList getHandlerList() { | |
return handlers; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment