Java Code Examples for org.spongepowered.api.event.cause.Cause#of()
The following examples show how to use
org.spongepowered.api.event.cause.Cause#of() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
/** * @return True if cancelled, false if not */ public static boolean runFactionChestEvent(final Player player, final Faction faction) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, player) .add(EventContextKeys.PLAYER, player) .add(EventContextKeys.CREATOR, player) .build(); final Cause eventCause = Cause.of(eventContext, player, faction); final FactionChestEvent event = new FactionChestEventImpl(player, faction, eventCause); return Sponge.getEventManager().post(event); }
Example 2
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
/** * @return True if cancelled, false if not */ public static boolean runFactionClaimEvent(final Player player, final Faction faction, final World world, final Vector3i chunkPosition) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, player) .add(EventContextKeys.PLAYER, player) .add(EventContextKeys.CREATOR, player) .build(); final Cause eventCause = Cause.of(eventContext, player, faction); final FactionClaimEvent event = new FactionClaimEventImpl(player, faction, world, chunkPosition, eventCause); return Sponge.getEventManager().post(event); }
Example 3
Source File: VersionHelper7.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public Cause getCause(CommandSource p) { if (p instanceof Player) return Cause.of(EventContext.builder().add(EventContextKeys.PLAYER, (Player) p).build(), p); else return Cause.of(EventContext.builder().add(EventContextKeys.PLUGIN, RedProtect.get().container).build(), p); }
Example 4
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
/** * @return True if cancelled, false if not */ public static boolean runFactionKickEvent(final FactionPlayer kickedPlayer, final Player kickedBy, final Faction faction) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, kickedBy) .add(EventContextKeys.PLAYER, kickedBy) .add(EventContextKeys.CREATOR, kickedBy) .build(); final Cause eventCause = Cause.of(eventContext, kickedBy, faction); final FactionKickEvent event = new FactionKickEventImpl(kickedPlayer, kickedBy, faction, eventCause); return Sponge.getEventManager().post(event); }
Example 5
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
/** * @return True if cancelled, false if not */ public static boolean runFactionUnclaimEvent(final Player player, final Faction faction, final World world, final Vector3i chunkPosition) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, player) .add(EventContextKeys.PLAYER, player) .add(EventContextKeys.CREATOR, player) .build(); final Cause eventCause = Cause.of(eventContext, player, faction); final FactionClaimEvent.Unclaim event = new FactionUnclaimEventImpl(player, faction, world, chunkPosition, eventCause); return Sponge.getEventManager().post(event); }
Example 6
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
/** * @return True if cancelled, false if not */ public static boolean runFactionAreaEnterEvent(final MoveEntityEvent moveEntityEvent, final Player player, final Optional<Faction> enteredFaction, final Optional<Faction> leftFaction) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, player) .add(EventContextKeys.PLAYER, player) .add(EventContextKeys.CREATOR, player) .build(); final Cause eventCause = Cause.of(eventContext, player, enteredFaction, leftFaction); final FactionAreaEnterEvent event = new FactionAreaEnterEventImpl(moveEntityEvent, player, enteredFaction, leftFaction, eventCause); return Sponge.getEventManager().post(event); }
Example 7
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
public static boolean runFactionDisbandEvent(final Player player, final Faction playerFaction) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, player) .add(EventContextKeys.PLAYER, player) .add(EventContextKeys.CREATOR, player) .build(); final Cause cause = Cause.of(eventContext, player, playerFaction); final FactionDisbandEvent event = new FactionAreaEnterEventImp(player, playerFaction, cause); return Sponge.getEventManager().post(event); }
Example 8
Source File: VersionHelper8.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public Cause getCause(CommandSource p) { if (p instanceof Player) return Cause.of(EventContext.builder().add(EventContextKeys.PLAYER, (Player) p).build(), p); else return Cause.of(EventContext.builder().add(EventContextKeys.PLUGIN, RedProtect.get().container).build(), p); }
Example 9
Source File: EventRunner.java From EagleFactions with MIT License | 5 votes |
/** * @return True if cancelled, false if not */ public static boolean runFactionLeaveEvent(final Player player, final Faction faction) { final EventContext eventContext = EventContext.builder() .add(EventContextKeys.OWNER, player) .add(EventContextKeys.PLAYER, player) .add(EventContextKeys.CREATOR, player) .build(); final Cause eventCause = Cause.of(eventContext, player, faction); final FactionLeaveEvent event = new FactionLeaveEventImpl(player, faction, eventCause); return Sponge.getEventManager().post(event); }
Example 10
Source File: RecordingQueueManager.java From Prism with MIT License | 5 votes |
@Override public synchronized void run() { List<DataContainer> eventsSaveBatch = new ArrayList<>(); // Assume we're iterating everything in the queue while (!RecordingQueue.getQueue().isEmpty()) { // Poll the next event, append to list PrismRecord record = RecordingQueue.getQueue().poll(); if (record != null) { // Prepare PrismRecord for sending to a PrismRecordEvent PluginContainer plugin = Prism.getInstance().getPluginContainer(); EventContext eventContext = EventContext.builder().add(EventContextKeys.PLUGIN, plugin).build(); PrismRecordPreSaveEvent preSaveEvent = new PrismRecordPreSaveEvent(record, Cause.of(eventContext, plugin)); // Tell Sponge that this PrismRecordEvent has occurred Sponge.getEventManager().post(preSaveEvent); if (!preSaveEvent.isCancelled()) { eventsSaveBatch.add(record.getDataContainer()); } } } if (eventsSaveBatch.size() > 0) { try { Prism.getInstance().getStorageAdapter().records().write(eventsSaveBatch); } catch (Exception e) { // @todo handle failures e.printStackTrace(); } } }
Example 11
Source File: BlockOperation.java From Web-API with MIT License | 5 votes |
public BlockOperation(CachedWorld world, Vector3i min, Vector3i max) { super(null); this.blockService = WebAPI.getBlockService(); this.uuid = UUID.randomUUID(); this.world = world; this.min = min; this.max = max; this.size = max.sub(min).add(1, 1, 1); this.cause = Cause.of(EventContext.empty(), WebAPI.getContainer()); this.totalBlocks = size.getX() * size.getY() * size.getZ(); }
Example 12
Source File: UCVHelper8.java From UltimateChat with GNU General Public License v3.0 | 4 votes |
@Override public Cause getCause(CommandSource src) { return Cause.of(EventContext.empty(), src); }
Example 13
Source File: TPAHereEvent.java From EssentialCmds with MIT License | 4 votes |
@Override public Cause getCause() { return Cause.of(NamedCause.source(this.sender)); }
Example 14
Source File: TPAAcceptEvent.java From EssentialCmds with MIT License | 4 votes |
@Override public Cause getCause() { return Cause.of(NamedCause.source(this.sender)); }
Example 15
Source File: MailSendEvent.java From EssentialCmds with MIT License | 4 votes |
@Override public Cause getCause() { return Cause.of(NamedCause.source(this.sender)); }
Example 16
Source File: TPAEvent.java From EssentialCmds with MIT License | 4 votes |
@Override public Cause getCause() { return Cause.of(NamedCause.source(this.sender)); }
Example 17
Source File: UCVHelper7.java From UltimateChat with GNU General Public License v3.0 | 4 votes |
@Override public Cause getCause(PluginContainer instance) { return Cause.of(EventContext.empty(), instance); }
Example 18
Source File: LiteEconomyTransactionEvent.java From EconomyLite with MIT License | 4 votes |
public LiteEconomyTransactionEvent(TransactionResult result, UUID user, Cause cause) { this.result = result; this.cause = Cause.of(EventContext.empty(), user); }
Example 19
Source File: LoanBalanceChangeEvent.java From EconomyLite with MIT License | 4 votes |
@Override public Cause getCause() { return Cause.of(EventContext.empty(), EconomyLite.getInstance().getPluginContainer()); }
Example 20
Source File: CauseFactory.java From EconomyLite with MIT License | 4 votes |
public static Cause stringCause(String reason) { return Cause.of(EventContext.empty(),("economylite:" + reason.toLowerCase().replaceAll(" ", "_"))); }