chunk additions
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
namespace Minecraft.Server.FourKit.Event.World;
|
||||
|
||||
using Minecraft.Server.FourKit.Chunk;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a Chunk related event.
|
||||
/// </summary>
|
||||
public abstract class ChunkEvent : WorldEvent
|
||||
{
|
||||
protected Chunk chunk;
|
||||
|
||||
protected ChunkEvent(Chunk chunk) : base(chunk.getWorld())
|
||||
{
|
||||
this.chunk = chunk;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the chunk being loaded/unloaded.
|
||||
/// </summary>
|
||||
/// <returns>Chunk that triggered this event.</returns>
|
||||
public Chunk getChunk() => chunk;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Minecraft.Server.FourKit.Event.World;
|
||||
|
||||
using Minecraft.Server.FourKit.Chunk;
|
||||
|
||||
/// <summary>
|
||||
/// Called when a chunk is loaded.
|
||||
/// </summary>
|
||||
public class ChunkLoadEvent : ChunkEvent
|
||||
{
|
||||
private readonly bool _newChunk;
|
||||
|
||||
internal ChunkLoadEvent(Chunk chunk, bool newChunk) : base(chunk)
|
||||
{
|
||||
_newChunk = newChunk;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets if this chunk was newly created or not. Note that if this chunk is
|
||||
/// new, it will not be populated at this time.
|
||||
/// </summary>
|
||||
/// <returns>true if the chunk is new, otherwise false.</returns>
|
||||
public bool isNewChunk() => _newChunk;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace Minecraft.Server.FourKit.Event.World;
|
||||
|
||||
using Minecraft.Server.FourKit.Chunk;
|
||||
|
||||
/// <summary>
|
||||
/// Called when a chunk is unloaded.
|
||||
/// </summary>
|
||||
public class ChunkUnloadEvent : ChunkEvent, Cancellable
|
||||
{
|
||||
private bool _cancel;
|
||||
|
||||
internal ChunkUnloadEvent(Chunk chunk) : base(chunk)
|
||||
{
|
||||
_cancel = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cancellation state of this event. A cancelled event will not
|
||||
/// be executed in the server, but will still pass to other plugins.
|
||||
/// </summary>
|
||||
/// <returns>true if this event is cancelled.</returns>
|
||||
public bool isCancelled() => _cancel;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the cancellation state of this event. A cancelled event will not
|
||||
/// be executed in the server, but will still pass to other plugins.
|
||||
/// </summary>
|
||||
/// <param name="cancel">true if you wish to cancel this event.</param>
|
||||
public void setCancelled(bool cancel)
|
||||
{
|
||||
_cancel = cancel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user