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


Java Game.getServer方法代码示例

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


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

示例1: hookChannels

import org.spongepowered.api.Game; //导入方法依赖的package包/类
@Listener
public void hookChannels(GameInitializationEvent event) {
    Game game = event.getGame();
    Server server = game.getServer();
    Method getNetworkSystem = null;
    for (Method m : server.getClass().getMethods()) {
        if ("net.minecraft.network.NetworkSystem".equals(m.getReturnType().getName())) {
            getNetworkSystem = m;
        }
    }
    if (getNetworkSystem == null) {
        throw new RuntimeException("Could not find getNetworkSystem in " + server);
    }
    try {
        Object networkSystem = getNetworkSystem.invoke(server);
        SpongeChannelInitializer channelInitializer = new SpongeChannelInitializer(game);
        @SuppressWarnings("unchecked")
        List<ChannelFuture> endpoints = (List) Reflection.getField(networkSystem.getClass(), "field_151274_e", networkSystem);
        for (ChannelFuture endpoint : endpoints) {
            endpoint.channel().pipeline().addFirst(channelInitializer);
        }
    } catch (IllegalAccessException | NoSuchFieldException | InvocationTargetException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ReplayMod,项目名称:SpongeRecording,代码行数:26,代码来源:SpongeImplementation.java

示例2: execute

import org.spongepowered.api.Game; //导入方法依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
	Game game = EssentialCmds.getEssentialCmds().getGame();
	Server server = game.getServer();
	Player player = ctx.<Player> getOne("player").get();
	Optional<String> reason = ctx.<String> getOne("reason");

	if (server.getPlayer(player.getUniqueId()).isPresent())
	{
		Text finalKickMessage = Text.of(TextColors.GOLD, src.getName() + " kicked " + player.getName());

		if (reason.isPresent())
		{
			Text reas = TextSerializers.formattingCode('&').deserialize(reason.get());
			Text kickMessage = Text.of(TextColors.GOLD, src.getName() + " kicked " + player.getName() + " for ", TextColors.RED);
			finalKickMessage = Text.builder().append(kickMessage).append(reas).build();
			player.kick(reas);
		}
		else
		{
			player.kick();
		}

		MessageChannel.TO_ALL.send(finalKickMessage);
		src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Player kicked."));
	}
	else
	{
		src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Player doesn't appear to be online!"));
	}

	return CommandResult.success();
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:34,代码来源:KickExecutor.java

示例3: executeAsync

import org.spongepowered.api.Game; //导入方法依赖的package包/类
@Override
public void executeAsync(CommandSource src, CommandContext args)
{
	Game game = EssentialCmds.getEssentialCmds().getGame();
	Server server = game.getServer();
	src.sendMessage(Text.of(TextColors.GOLD, "[MOTD]: ", server.getMotd()));
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:8,代码来源:MotdExecutor.java

示例4: NodeClient

import org.spongepowered.api.Game; //导入方法依赖的package包/类
public NodeClient(ConnectionInfo connectionInfo, Game game){
    this.ci = connectionInfo;
    this.game = game;
    this.gsonBaker = new GsonBaker(game.getServer());
    this.service = new EventService(this, game);
}
 
开发者ID:thomas15v,项目名称:CrossEvents,代码行数:7,代码来源:NodeClient.java


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