当前位置: 首页>>代码示例>>Java>>正文


Java Tristate.UNDEFINED属性代码示例

本文整理汇总了Java中org.spongepowered.api.util.Tristate.UNDEFINED属性的典型用法代码示例。如果您正苦于以下问题:Java Tristate.UNDEFINED属性的具体用法?Java Tristate.UNDEFINED怎么用?Java Tristate.UNDEFINED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.spongepowered.api.util.Tristate的用法示例。


在下文中一共展示了Tristate.UNDEFINED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onClientAuthMonitor

@Listener(order = Order.LAST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuthMonitor(ClientConnectionEvent.Auth e) {
    /* Listen to see if the event was cancelled after we initially handled the connection
       If the connection was cancelled here, we need to do something to clean up the data that was loaded. */

    // Check to see if this connection was denied at LOW.
    if (this.deniedAsyncLogin.remove(e.getProfile().getUniqueId())) {

        // This is a problem, as they were denied at low priority, but are now being allowed.
        if (e.isCancelled()) {
            this.plugin.getLog().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId());
            e.setCancelled(true);
        }
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:16,代码来源:SpongeConnectionListener.java

示例2: onClientLogin

@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
       At this point, the users data should be present and loaded.
       Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */

    final GameProfile player = e.getProfile();

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName());
    }

    final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));

    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(player.getUniqueId());

        this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:26,代码来源:SpongeConnectionListener.java

示例3: onChangeBlock

@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onChangeBlock(ChangeBlockEvent.Place event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	event.getTransactions().forEach(transaction -> {
		player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getState().getId()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getCreator()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getNotifier()));
	});
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:18,代码来源:EAInfo.java

示例4: onInteractBlock

@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractBlock(InteractBlockEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getState().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getNotifier()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:16,代码来源:EAInfo.java

示例5: onInteractEntity

@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractEntity(InteractEntityEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getType().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getNotifier()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:16,代码来源:EAInfo.java

示例6: getTristate

/**
 * Retourne la valeur de la permission
 * @param permission La permission
 * @return La valeur de la permission
 */
public Tristate getTristate(final String permission) {
    Iterable<String> parts = NODE_SPLITTER.split(permission.toLowerCase());
    EPNode currentNode = this;
    Tristate lastUndefinedVal = Tristate.UNDEFINED;
    for (String str : parts) {
        if (!currentNode.containsKey(str)) {
            break;
        }
        currentNode = currentNode.get(str);
        
        if (currentNode.getTristate() != Tristate.UNDEFINED) {
            lastUndefinedVal = currentNode.getTristate();
        }
    }
    return lastUndefinedVal;

}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:22,代码来源:EPNode.java

示例7: setPermissionExecute

public void setPermissionExecute(final String typeWorld, final String permission, final Tristate value) {
	this.write_lock.lock();
	try {
		EPNode oldTree = this.permissions.get(typeWorld);
		if (oldTree == null) {
			if (value != Tristate.UNDEFINED) {
				this.permissions.putIfAbsent(typeWorld, EPNode.of(ImmutableMap.of(permission, value.asBoolean())));
			}
		} else if (value == Tristate.UNDEFINED) {
			if (oldTree.getTristate(permission) != Tristate.UNDEFINED) {
				this.permissions.put(typeWorld, oldTree.withValue(permission, value));
			}
		} else if (!oldTree.asMap().containsKey(permission) || oldTree.asMap().get(permission) != value.asBoolean()) {
			this.permissions.put(typeWorld, oldTree.withValue(permission, value));
		} 
	} finally {
		this.write_lock.unlock();
	}
}
 
开发者ID:EverCraft,项目名称:EverPermissions,代码行数:19,代码来源:EPSubjectData.java

示例8: getClaimFlagPermission

private static Tristate getClaimFlagPermission(GPClaim claim, String permission, String targetModPermission, String targetMetaPermission) {
    Set<Context> contexts = new HashSet<>(GriefPreventionPlugin.GLOBAL_SUBJECT.getActiveContexts());
    contexts.add(claim.getContext());

    Tristate value = GriefPreventionPlugin.GLOBAL_SUBJECT.getPermissionValue(contexts, permission);
    if (value != Tristate.UNDEFINED) {
        return processResult(claim, permission, value, GriefPreventionPlugin.GLOBAL_SUBJECT);
    }
    if (targetMetaPermission != null) {
        value = GriefPreventionPlugin.GLOBAL_SUBJECT.getPermissionValue(contexts, targetMetaPermission);
        if (value != Tristate.UNDEFINED) {
            return processResult(claim, targetMetaPermission, value, GriefPreventionPlugin.GLOBAL_SUBJECT);
        }
    }
    if (targetModPermission != null) {
        value = GriefPreventionPlugin.GLOBAL_SUBJECT.getPermissionValue(contexts, targetModPermission);
        if (value != Tristate.UNDEFINED) {
            return processResult(claim, targetModPermission, value, GriefPreventionPlugin.GLOBAL_SUBJECT);
        }
    }

    return getFlagDefaultPermission(claim, permission);
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:23,代码来源:GPPermissionHandler.java

示例9: getCacheResult

public Tristate getCacheResult(short pos) {
    int currentTick = SpongeImpl.getServer().getTickCounter();
    if (this.lastBlockPos != pos) {
        this.lastBlockPos = pos;
        this.lastTickCounter = currentTick;
        return Tristate.UNDEFINED;
    }

    if ((currentTick - this.lastTickCounter) <= 2) {
        this.lastTickCounter = currentTick;
        return this.lastResult;
    }

    this.lastTickCounter = currentTick;
    return Tristate.UNDEFINED;
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:16,代码来源:BlockPosCache.java

示例10: createFlagConsumer

public static Consumer<CommandSource> createFlagConsumer(CommandSource src, Subject subject, String subjectName, Set<Context> contexts, GPClaim claim, String flagPermission, Tristate flagValue, String source) {
    return consumer -> {
        String target = flagPermission.replace(GPPermissions.FLAG_BASE + ".", "");
        if (target.isEmpty()) {
            target = "any";
        }
        Tristate newValue = Tristate.UNDEFINED;
        if (flagValue == Tristate.TRUE) {
            newValue = Tristate.FALSE;
        } else if (flagValue == Tristate.UNDEFINED) {
            newValue = Tristate.TRUE;
        }

        CommandHelper.applyFlagPermission(src, subject, subjectName, claim, flagPermission, source, target, newValue, null, FlagType.GROUP);
    };
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:16,代码来源:CommandHelper.java

示例11: write

@Override
public int write(String name, ClassWriter cw, MethodVisitor mv, Method method, int locals) {
    if (this.state == Tristate.UNDEFINED) {
        return locals;
    }
    if (!Cancellable.class.isAssignableFrom(method.getParameters()[0].getType())) {
        throw new IllegalStateException("Attempted to filter a non-cancellable event type by its cancellation status");
    }
    mv.visitVarInsn(ALOAD, 1);
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(Cancellable.class));
    mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(Cancellable.class), "isCancelled", "()Z", true);
    Label success = new Label();
    if (this.state == Tristate.TRUE) {
        mv.visitJumpInsn(IFNE, success);
    } else {
        mv.visitJumpInsn(IFEQ, success);
    }
    mv.visitInsn(ACONST_NULL);
    mv.visitInsn(ARETURN);
    mv.visitLabel(success);
    return locals;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:CancellationEventFilterDelegate.java

示例12: parseCommand

public static List<String> parseCommand(String commandSequence)
{
    StringBuilder stringBuilder = new StringBuilder();
    List<String> commands = new LinkedList<>();
    Tristate isCommandFinished = Tristate.TRUE;
    for (char c : commandSequence.toCharArray())
    {
        if (c != SEQUENCE_SPLITTER)
        {
            if (isCommandFinished == Tristate.UNDEFINED)
            {
                commands.add(stringBuilder.toString());
                stringBuilder.setLength(0);
            }
            if (isCommandFinished != Tristate.FALSE && Character.isWhitespace(c))
            {
                isCommandFinished = Tristate.TRUE;
                continue;
            }
        }
        else if (isCommandFinished != Tristate.UNDEFINED)
        {
            isCommandFinished = Tristate.UNDEFINED;
            continue;
        }
        isCommandFinished = Tristate.FALSE;
        stringBuilder.append(c);
    }
    commands.add(stringBuilder.toString());
    return commands;
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:31,代码来源:VirtualChestActionDispatcher.java

示例13: setPermission

@Override
public boolean setPermission(Player player, Subject subject, Set<Context> contexts, String permission, Tristate value) {
    Boolean perm = subject.getSubjectData().getPermissions(contexts).get(permission);
    if ((perm == null && value == Tristate.UNDEFINED)
            || (perm == Boolean.TRUE && value == Tristate.TRUE)
            || (perm == Boolean.FALSE && value == Tristate.FALSE)) {
        return true;
    }
    return subject.getSubjectData().setPermission(contexts, permission, value);
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:10,代码来源:FallbackPermActions.java

示例14: onIncomingMessage

@Listener(order = Order.PRE, beforeModifications = true)
@IsCancelled(Tristate.UNDEFINED)
public void onIncomingMessage(MessageChannelEvent.Chat event, @Root Player player) {
    if (getView(player).handleIncoming(event.getRawMessage())) {
        // No plugins should interpret this as chat
        event.setCancelled(true);
        event.setChannel(MessageChannel.TO_NONE);
    }
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:9,代码来源:ChatUILib.java

示例15: onClientAuth

@Listener(order = Order.EARLY)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuth(ClientConnectionEvent.Auth e) {
    /* Called when the player first attempts a connection with the server.
       Listening on AFTER_PRE priority to allow plugins to modify username / UUID data here. (auth plugins) */

    final GameProfile p = e.getProfile();
    final String username = p.getName().orElseThrow(() -> new RuntimeException("No username present for user " + p.getUniqueId()));

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing auth event for " + p.getUniqueId() + " - " + p.getName());
    }

    this.plugin.getUniqueConnections().add(p.getUniqueId());

    /* Actually process the login for the connection.
       We do this here to delay the login until the data is ready.
       If the login gets cancelled later on, then this will be cleaned up.

       This includes:
       - loading uuid data
       - loading permissions
       - creating a user instance in the UserManager for this connection.
       - setting up cached data. */
    try {
        User user = loadUser(p.getUniqueId(), username);
        this.plugin.getEventFactory().handleUserLoginProcess(p.getUniqueId(), username, user);
    } catch (Exception ex) {
        this.plugin.getLog().severe("Exception occured whilst loading data for " + p.getUniqueId() + " - " + p.getName());
        ex.printStackTrace();

        this.deniedAsyncLogin.add(p.getUniqueId());

        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:39,代码来源:SpongeConnectionListener.java


注:本文中的org.spongepowered.api.util.Tristate.UNDEFINED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。