From 2d4bfdcbf8b9e2e0619e44549e2ed9ae9cc2efe5 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 15 Jan 2016 16:00:34 +0100 Subject: [PATCH] EventMassiveCoreEditorEdit --- .../command/editor/CommandEditAbstract.java | 7 +++ .../event/EventMassiveCoreEditorEdit.java | 46 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/com/massivecraft/massivecore/event/EventMassiveCoreEditorEdit.java diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java b/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java index 0af87bcf..b3e46e65 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java @@ -11,6 +11,7 @@ import com.massivecraft.massivecore.command.MassiveCommand; import com.massivecraft.massivecore.command.requirement.RequirementEditorUse; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.type.Type; +import com.massivecraft.massivecore.event.EventMassiveCoreEditorEdit; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.PermUtil; @@ -95,6 +96,12 @@ public class CommandEditAbstract extends MassiveCommand O source = inherited.getKey(); V before = inherited.getValue(); + // Event + EventMassiveCoreEditorEdit event = new EventMassiveCoreEditorEdit(this, source, before, after); + event.run(); + if (event.isCancelled()) return; + after = event.getAfter(); + // Setup String descProperty = this.getProperty().getDisplayName(); String descObject = this.getObjectVisual(); diff --git a/src/com/massivecraft/massivecore/event/EventMassiveCoreEditorEdit.java b/src/com/massivecraft/massivecore/event/EventMassiveCoreEditorEdit.java new file mode 100644 index 00000000..be33d911 --- /dev/null +++ b/src/com/massivecraft/massivecore/event/EventMassiveCoreEditorEdit.java @@ -0,0 +1,46 @@ +package com.massivecraft.massivecore.event; + +import org.bukkit.event.HandlerList; + +import com.massivecraft.massivecore.command.editor.CommandEditAbstract; + +public class EventMassiveCoreEditorEdit extends EventMassiveCore +{ + // -------------------------------------------- // + // REQUIRED EVENT CODE + // -------------------------------------------- // + + private static final HandlerList handlers = new HandlerList(); + @Override public HandlerList getHandlers() { return handlers; } + public static HandlerList getHandlerList() { return handlers; } + + // -------------------------------------------- // + // FIELD + // -------------------------------------------- // + + protected final CommandEditAbstract command; + public CommandEditAbstract getCommand() { return this.command; } + + protected final O source; + public O getSource() { return this.source; } + + protected final V before; + public V getBefore() { return this.before; } + + protected V after; + public V getAfter() { return this.after; } + public void setAfter(V after) { this.after = after; } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public EventMassiveCoreEditorEdit(CommandEditAbstract command, O source, V before, V after) + { + this.command = command; + this.source = source; + this.before = before; + this.after = after; + } + +}