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


Java Platform.Type方法代码示例

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


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

示例1: register

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
private <M extends Message> void register(Class<M> messageClass, int messageId, @Nullable Platform.Type side,
        @Nullable MessageHandler<M> handler) {
    checkNotNull(messageClass, "messageClass");
    checkArgument(messageId >= 0 && messageId <= 255, "MessageId (%s) must scale between 0 and 255", messageId);
    final byte messageId0 = (byte) messageId;
    if (side == null) {
        validate(messageClass, messageId0, Platform.Type.CLIENT);
        validate(messageClass, messageId0, Platform.Type.SERVER);
    } else {
        checkArgument(side.isKnown(), "Platform side must be known");
        validate(messageClass, messageId0, side);
    }
    final IndexedMessageRegistration registration = new IndexedMessageRegistration(messageClass);
    registration.opcode = messageId0;
    if (handler != null) {
        registration.handlers.add(handler);
    }
    if (side == null) {
        applyRegistration(getRegistrations(Platform.Type.CLIENT), messageClass, messageId0, handler);
        applyRegistration(getRegistrations(Platform.Type.SERVER), messageClass, messageId0, handler);
    } else {
        applyRegistration(getRegistrations(side), messageClass, messageId0, handler);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:LanternIndexedMessageChannel.java

示例2: validate

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
private void validate(Class<? extends Message> messageClass, byte messageId, Platform.Type side) {
    Constructor<?> constructor = null;
    try {
        constructor = messageClass.getConstructor();
    } catch (NoSuchMethodException ignored) {
    } catch (SecurityException e) {
        throw new RuntimeException(e);
    }
    checkState(constructor != null, "%s is missing a empty public constructor", messageClass.getName());
    final RegistrationLookup registrations = getRegistrations(Platform.Type.CLIENT);
    checkState(!registrations.classToRegistration.containsKey(messageClass) ||
            registrations.classToRegistration.get(messageClass).opcode == null,
            "MessageClass (%s) is already registered on the %s side!",
            messageClass.getName(), side.name().toLowerCase());
    checkState(!registrations.opcodeToRegistration.containsKey(messageId),
            "MessageId (%s) is already registered on the %s side! For %s",
            messageId, side.name().toLowerCase(), registrations.opcodeToRegistration.get(messageId).messageType.getName());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:19,代码来源:LanternIndexedMessageChannel.java

示例3: handlePayload

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public void handlePayload(ChannelBuf data, RemoteConnection connection, Platform.Type side) {
    for (Map.Entry<Predicate<ChannelBuf>, Consumer<ChannelBuf>> entry : map.entrySet()) {
       if (entry.getKey().test(data)) {
           entry.getValue().accept(data);
           map.remove(entry.getKey());
           return;
       }
    }
}
 
开发者ID:pie-flavor,项目名称:SpongyCord,代码行数:11,代码来源:SpongyCord.java

示例4: addListener

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public void addListener(Platform.Type side, RawDataListener listener) {
    checkNotNull(listener, "listener");
    checkNotNull(side, "side");
    if (side == Platform.Type.SERVER) {
        this.serverDataListeners.add(listener);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:LanternRawDataChannel.java

示例5: getRegistrations

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
private RegistrationLookup getRegistrations(Platform.Type side) {
    final RegistrationLookup registrations;
    if (this.registrations.containsKey(side)) {
        registrations = this.registrations.get(side);
    } else {
        this.registrations.put(side, registrations = new RegistrationLookup());
    }
    return registrations;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:LanternIndexedMessageChannel.java

示例6: handlePayload

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public void handlePayload(ChannelBuf channelBuf, RemoteConnection remoteConnection, Platform.Type type) {
    try {
        String message = new String(channelBuf.array(), StandardCharsets.UTF_8);
        JSONObject jsonObject = new JSONObject(message);
        Vote v = new Vote(jsonObject);
        listener.onForward(v);
    } catch (Exception e) {
        p.getLogger().error("There was an unknown error when processing a forwarded vote.", e);
    }
}
 
开发者ID:NuVotifier,项目名称:NuVotifier,代码行数:12,代码来源:SpongePluginMessagingForwardingSink.java

示例7: handlePayload

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public void handlePayload(@Nonnull ChannelBuf buf, @Nonnull RemoteConnection connection, @Nonnull Platform.Type type) {
    String msg = buf.readUTF();
    onMessage(msg, null);
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:6,代码来源:BungeeMessagingService.java

示例8: registerMessage

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public <M extends Message> void registerMessage(Class<M> messageClass, int messageId, Platform.Type side, MessageHandler<M> handler) {
    register(messageClass, messageId, checkNotNull(side, "side"), checkNotNull(handler, "handler"));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternIndexedMessageChannel.java

示例9: addHandler

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public <M extends Message> void addHandler(Class<M> messageClass, Platform.Type side, MessageHandler<M> handler) {
    applyHandler(getRegistrations(checkNotNull(side, "side")), messageClass, checkNotNull(handler, "handler"));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternIndexedMessageChannel.java

示例10: validateRegistration

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
private void validateRegistration(Class<? extends Message> messageClass, Platform.Type side) {
    final IndexedMessageRegistration registration = getRegistrations(side).classToRegistration.get(messageClass);
    checkArgument(registration != null && registration.opcode != null,
            "%s is not registered on the side: %s", messageClass.getName(), side.name().toLowerCase());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:LanternIndexedMessageChannel.java

示例11: getRegisteredChannels

import org.spongepowered.api.Platform; //导入方法依赖的package包/类
@Override
public Set<String> getRegisteredChannels(Platform.Type side) {
    return ImmutableSet.copyOf(this.bindings.keySet());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternChannelRegistrar.java


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