EventMassiveCoreEditorEdit

This commit is contained in:
Olof Larsson 2016-01-15 16:00:34 +01:00
parent c37feb469e
commit 2d4bfdcbf8
2 changed files with 53 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementEditorUse; import com.massivecraft.massivecore.command.requirement.RequirementEditorUse;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.type.Type; import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.event.EventMassiveCoreEditorEdit;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.PermUtil; import com.massivecraft.massivecore.util.PermUtil;
@ -95,6 +96,12 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
O source = inherited.getKey(); O source = inherited.getKey();
V before = inherited.getValue(); V before = inherited.getValue();
// Event
EventMassiveCoreEditorEdit<O, V> event = new EventMassiveCoreEditorEdit<O, V>(this, source, before, after);
event.run();
if (event.isCancelled()) return;
after = event.getAfter();
// Setup // Setup
String descProperty = this.getProperty().getDisplayName(); String descProperty = this.getProperty().getDisplayName();
String descObject = this.getObjectVisual(); String descObject = this.getObjectVisual();

View File

@ -0,0 +1,46 @@
package com.massivecraft.massivecore.event;
import org.bukkit.event.HandlerList;
import com.massivecraft.massivecore.command.editor.CommandEditAbstract;
public class EventMassiveCoreEditorEdit<O, V> 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<O, V> command;
public CommandEditAbstract<O, V> 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<O, V> command, O source, V before, V after)
{
this.command = command;
this.source = source;
this.before = before;
this.after = after;
}
}