org.spongepowered.api.event.Event Java Examples
The following examples show how to use
org.spongepowered.api.event.Event.
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: GPPermissionHandler.java From GriefPrevention with MIT License | 6 votes |
public static void addEventLogEntry(Event event, Location<World> location, Object source, Object target, Subject permissionSubject, String permission, String trust, Tristate result) { if (GriefPreventionPlugin.debugActive) { String sourceId = getPermissionIdentifier(source, true); String targetPermission = permission; String targetId = getPermissionIdentifier(target); if (!targetId.isEmpty()) { // move target meta to end of permission Matcher m = PATTERN_META.matcher(targetId); String targetMeta = ""; if (!permission.contains("command-execute")) { if (m.find()) { targetMeta = m.group(0); targetId = StringUtils.replace(targetId, targetMeta, ""); } } targetPermission += "." + targetId + targetMeta; } if (permissionSubject == null) { permissionSubject = GriefPreventionPlugin.GLOBAL_SUBJECT; } GriefPreventionPlugin.addEventLogEntry(event, location, sourceId, targetId, permissionSubject, targetPermission, trust, result); } }
Example #2
Source File: GDPermissionManager.java From GriefDefender with MIT License | 6 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, GDPermissionHolder subject, TrustType type, boolean checkOverride) { final Set<Context> contexts = new HashSet<>(); for (Map.Entry<EventContextKey<?>, Object> mapEntry : event.getContext().asMap().entrySet()) { if (IGNORED_EVENT_CONTEXTS.contains(mapEntry.getKey())) { continue; } final String[] parts = mapEntry.getKey().getId().split(":"); String contextId = getPermissionIdentifier(mapEntry.getValue(), false); final int index = contextId.indexOf("."); if (index > -1) { contextId = contextId.substring(0, index); } if (contextId.isEmpty()) { continue; } final Context context = new Context(parts[1], contextId); contexts.add(context); } return getFinalPermission(event, location, contexts, claim, flag, source, target, subject, type, checkOverride); }
Example #3
Source File: GDPermissionManager.java From GriefDefender with MIT License | 5 votes |
public void processEventLog(Event event, Location<World> location, Claim claim, String permission, Object source, Object target, GDPermissionHolder user, String trust, Tristate value) { final String sourceId = this.getPermissionIdentifier(source, true); final String targetId = this.getPermissionIdentifier(target); final Set<Context> sourceContexts = this.getPermissionContexts((GDClaim) claim, source, true); if (sourceContexts == null) { return; } final Set<Context> targetContexts = this.getPermissionContexts((GDClaim) claim, target, false); if (targetContexts == null) { return; } final Set<Context> contexts = new HashSet<>(); contexts.addAll(sourceContexts); contexts.addAll(targetContexts); contexts.add(((GDClaim) claim).getWorldContext()); if (GriefDefenderPlugin.debugActive) { if (user == null) { final Object root = GDCauseStackManager.getInstance().getCurrentCause().root(); if (source instanceof GDPermissionUser) { user = (GDPermissionUser) root; } else { user = GriefDefenderPlugin.DEFAULT_HOLDER; } } GriefDefenderPlugin.addEventLogEntry(event, claim, location, sourceId, targetId, user, permission, trust.toLowerCase(), value, contexts); } }
Example #4
Source File: CauseContextHelper.java From GriefDefender with MIT License | 5 votes |
public static Object getEventFakePlayerSource(Event event) { Object source = event.getSource(); if (NMSUtil.getInstance().isFakePlayer(source)) { final Object actualSource = event.getCause().last(Object.class).orElse(null); if (actualSource != source && (actualSource instanceof TileEntity || actualSource instanceof Entity)) { return actualSource; } } return source; }
Example #5
Source File: SpongeListenerSystem.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void callEnableEvent(PlanPlugin plugin) { try { Event event = new PlanSpongeEnableEvent((PlanSponge) plugin); Sponge.getEventManager().post(event); } catch (IllegalStateException ignore) { /* Ignore, Sponge is not initialized */ } CapabilitySvc.notifyAboutEnable(plugin.isSystemEnabled()); }
Example #6
Source File: GriefPreventionPlugin.java From GriefPrevention with MIT License | 4 votes |
public static void addEventLogEntry(Event event, Location<World> location, String sourceId, String targetId, Subject permissionSubject, String permission, String trust, Tristate result) { final String eventName = event.getClass().getSimpleName().replace('$', '.').replace(".Impl", ""); final String eventLocation = location == null ? "none" : location.getBlockPosition().toString(); for (GPDebugData debugEntry : GriefPreventionPlugin.instance.getDebugUserMap().values()) { final CommandSource debugSource = debugEntry.getSource(); final User debugUser = debugEntry.getTarget(); if (debugUser != null) { if (permissionSubject == null) { continue; } // Check event source user if (!permissionSubject.getIdentifier().equals(debugUser.getUniqueId().toString())) { continue; } } String messageUser = permissionSubject.getIdentifier(); if (permissionSubject instanceof User) { messageUser = ((User) permissionSubject).getName(); } // record if (debugEntry.isRecording()) { String messageFlag = permission; permission = permission.replace("griefprevention.flag.", ""); messageFlag = GPPermissionHandler.getFlagFromPermission(permission).toString(); final String messageSource = sourceId == null ? "none" : sourceId; String messageTarget = targetId == null ? "none" : targetId; if (messageTarget.endsWith(".0")) { messageTarget = messageTarget.substring(0, messageTarget.length() - 2); } if (trust == null) { trust = "none"; } debugEntry.addRecord(messageFlag, trust, messageSource, messageTarget, eventLocation, messageUser, result); continue; } final Text textEvent = Text.of(GP_TEXT, TextColors.GRAY, "Event: ", TextColors.GREEN, eventName, "\n"); final Text textCause = Text.of(GP_TEXT, TextColors.GRAY, "Cause: ", TextColors.LIGHT_PURPLE, sourceId, "\n"); final Text textLocation = Text.of(GP_TEXT, TextColors.GRAY, "Location: ", TextColors.WHITE, eventLocation == null ? "NONE" : eventLocation); final Text textUser = Text.of(TextColors.GRAY, "User: ", TextColors.GOLD, messageUser, "\n"); final Text textLocationAndUser = Text.of(textLocation, " ", textUser); Text textContext = null; Text textPermission = null; if (targetId != null) { textContext = Text.of(GP_TEXT, TextColors.GRAY, "Target: ", TextColors.YELLOW, GPPermissionHandler.getPermissionIdentifier(targetId), "\n"); } if (permission != null) { textPermission = Text.of(GP_TEXT, TextColors.GRAY, "Permission: ", TextColors.RED, permission, "\n"); } Text.Builder textBuilder = Text.builder().append(textEvent); if (textContext != null) { textBuilder.append(textContext); } else { textBuilder.append(textCause); } if (textPermission != null) { textBuilder.append(textPermission); } textBuilder.append(textLocationAndUser); debugSource.sendMessage(textBuilder.build()); } }
Example #7
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, GDPermissionHolder permissionHolder) { return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, null, false); }
Example #8
Source File: GPPermissionHandler.java From GriefPrevention with MIT License | 4 votes |
public static Tristate getClaimPermission(Event event, Location<World> location, GPClaim claim, String flagPermission, Object source, Object target, User user, boolean checkOverride) { return getClaimPermission(event, location, claim, flagPermission, source, target, user, null, checkOverride); }
Example #9
Source File: GPPermissionHandler.java From GriefPrevention with MIT License | 4 votes |
public static Tristate getClaimPermission(Event event, Location<World> location, GPClaim claim, String flagPermission, Object source, Object target, User user) { return getClaimPermission(event, location, claim, flagPermission, source, target, user, null, false); }
Example #10
Source File: WebHookEventListener.java From Web-API with MIT License | 4 votes |
@Override public void handle(Event event) throws Exception { WebAPI.getWebHookService().notifyHooks(clazz, event); }
Example #11
Source File: WebHookEventListener.java From Web-API with MIT License | 4 votes |
public WebHookEventListener(Class<? extends Event> clazz) { this.clazz = clazz; }
Example #12
Source File: Utils.java From Nations with MIT License | 4 votes |
public static User getUser(Event event) { return event.getCause().first(User.class).orElse(null); }
Example #13
Source File: Utils.java From Nations with MIT License | 4 votes |
public static boolean isFakePlayer(Event event) { return event.getCause().containsNamed(NamedCause.FAKE_PLAYER); }
Example #14
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public void processEventLog(Event event, Location<World> location, Claim claim, String permission, Object source, Object target, User user, String trust, Tristate value) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(user); this.processEventLog(event, location, claim, permission, source, target, permissionHolder, trust, value); }
Example #15
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, User user, TrustType type, boolean checkOverride) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(user); return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, type, checkOverride); }
Example #16
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, Player player, TrustType type, boolean checkOverride) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(player); return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, type, checkOverride); }
Example #17
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, User user, boolean checkOverride) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(user); return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, null, checkOverride); }
Example #18
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, User user) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(user); return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, null, false); }
Example #19
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, GDPermissionHolder permissionHolder, boolean checkOverride) { return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, null, checkOverride); }
Example #20
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, Player player, boolean checkOverride) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(player); return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, null, checkOverride); }
Example #21
Source File: GDPermissionManager.java From GriefDefender with MIT License | 4 votes |
public Tristate getFinalPermission(Event event, Location<World> location, Claim claim, Flag flag, Object source, Object target, Player player) { final GDPermissionHolder permissionHolder = PermissionHolderCache.getInstance().getOrCreateUser(player); return getFinalPermission(event, location, claim, flag, source, target, permissionHolder, null, false); }