• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ServerChatPacket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket的典型用法代码示例。如果您正苦于以下问题:Java ServerChatPacket类的具体用法?Java ServerChatPacket怎么用?Java ServerChatPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerChatPacket类属于org.spacehq.mc.protocol.packet.ingame.server包,在下文中一共展示了ServerChatPacket类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onPacket

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
public void onPacket(PacketReceivedEvent event) {
	// if the packet is a chat packet, handle it!
	if (event.getPacket() instanceof ClientChatPacket) {
		ClientChatPacket packet = event.getPacket();
		String message = packet.getMessage();

		GameProfile profile = event.getSession().getFlag(MinecraftConstants.PROFILE_KEY);
		System.out.println("<" + profile.getName() + "> " + packet.getMessage());

		// Check if it was a command or a chat message
		if (message.substring(0, 1).equals("/")) {
			NetherPlayer player = NetherServer.players.get(event.getSession());
			NetherServer.commandHandler.runCommand(player, message);
		} else {
			// let every other user on the server know that someone has just
			// chatted
			NetherServer.server.getSessions().forEach((session) -> session
					.send(new ServerChatPacket("<" + profile.getName() + "> " + packet.getMessage())));
		}
	}
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:22,代码来源:ChatHandler.java


示例2: onServerChat

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@PacketHandler
public void onServerChat(PCSession session, ClientChatPacket packet) {
    final String mesaage = packet.getMessage();
    final GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
    boolean command = mesaage.startsWith("/");
    final String outgoing = "<" + profile.getName() + "> " + mesaage;
    if (!command) {
        for (Session activeSession : SpongeGame.instance.getServer().getNetwork().getSessions()) {
            activeSession.send(new ServerChatPacket(outgoing, MessageType.CHAT));
        }
    } else {
        session.send(new ServerChatPacket(outgoing, MessageType.CHAT));
    }

    if (command) {
        SpongeGame.logger.info("{} issued command: {}", profile.getName(), mesaage);
    } else {
        SpongeGame.logger.info(outgoing);
    }
}
 
开发者ID:InspireNXE,项目名称:Pulse,代码行数:21,代码来源:IngameHandlers.java


示例3: onPacket

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
public void onPacket(PacketReceivedEvent event) {
	if (event.getPacket() instanceof ClientChatPacket) {
		ClientChatPacket packet = event.getPacket();
		GameProfile profile = event.getSession().getFlag(MinecraftConstants.PROFILE_KEY);
		System.out.println("<" + profile.getName() + "> " + packet.getMessage());
		MainMain.server.getSessions().forEach((session) -> session
				.send(new ServerChatPacket("<" + profile.getName() + "> " + packet.getMessage())));

	}
}
 
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:11,代码来源:ChatHandler.java


示例4: onLogin

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
public void onLogin(Session session) {
	ServerPlayer newPlayer = new ServerPlayer(session);
	MainMain.players.put(session, newPlayer);
	newPlayer.setWorld(MainMain.defaultWorld);
	session.send(new ServerJoinGamePacket((int) newPlayer.getUEID(), false, GameMode.CREATIVE,
			newPlayer.getWorld().getDimension().toInt(), Difficulty.PEACEFUL, 10, WorldType.DEFAULT, false));

	List<PlayerListEntry> playerList = new ArrayList<PlayerListEntry>();

	MainMain.players.forEach((otherPlayer) -> {
		playerList.add(new PlayerListEntry(otherPlayer.getProfile(), GameMode.CREATIVE, 1,
				new TextMessage(otherPlayer.getName())));
	});

	PlayerListEntry[] playerListPck = new PlayerListEntry[playerList.size()];
	playerList.toArray(playerListPck);

	session.send(new ServerPlayerListEntryPacket(PlayerListEntryAction.ADD_PLAYER, playerListPck));
	MainMain.players.forEach((otherPlayer) -> {
		if (otherPlayer == newPlayer)
			return;
		PlayerListEntry[] newPlayerListing = new PlayerListEntry[1];

		newPlayerListing[0] = new PlayerListEntry(newPlayer.getProfile(), GameMode.CREATIVE, 1,
				new TextMessage(newPlayer.getName()));

		otherPlayer.sendPacket(new ServerPlayerListEntryPacket(PlayerListEntryAction.ADD_PLAYER, newPlayerListing));
	});
	session.send(new ServerPlayerPositionRotationPacket(0, 120, 0, 0, 0, 0));
	MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
	if (protocol.getSubProtocol() == SubProtocol.GAME) {
		GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
		logger.info(profile.getName() + " has joined the game");
		MainMain.server.getSessions()
				.forEach((sessions) -> sessions
						.send(new ServerChatPacket(new TextMessage(profile.getName() + " has joined the game")
								.setStyle(new MessageStyle().setColor(ChatColor.YELLOW)))));
	}
}
 
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:40,代码来源:LoginHandler.java


示例5: chat

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@Override
public void chat(String message) {
    String name = "UNKNOWN";
    if (getComponentManager().hasComponent("displayName")) {
        name = ((DisplayNameComponent) getComponentManager().getComponent("displayName")).getDisplayName();
    }
    String format = name + ": " + message; // TODO Event's
    ServerChatPacket packet = new ServerChatPacket(format);
    // getPlayerNetwork().sendPacket(packet);
    for (Player player : getWorld().getPlayers()) {
        ((CyanPlayer) player).getPlayerNetwork().sendPacket(packet);
    }

    server.getConsoleCommandSender().sendMessage(format);
}
 
开发者ID:BeYkeRYkt,项目名称:CyanWool,代码行数:16,代码来源:CyanPlayer.java


示例6: disconnected

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@Override
public void disconnected(DisconnectedEvent event) {
    if (((PCSession) event.getSession()).getPacketProtocol().getProtocolPhase() == ProtocolPhase.INGAME) {
        final GameProfile profile = event.getSession().getFlag(MinecraftConstants.PROFILE_KEY);
        final String message = profile.getName() + " has left the game.";

        SpongeGame.logger.info(message);

        this.listener.getSessions().stream().filter(Session::isConnected).forEach(session -> {
            session.send(new ServerChatPacket(message, MessageType.SYSTEM));
        });
    }
}
 
开发者ID:InspireNXE,项目名称:Pulse,代码行数:14,代码来源:Network.java


示例7: sendMessage

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@Override
public void sendMessage(TextMessage message) {
	this.session.send(new ServerChatPacket(message));
}
 
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:5,代码来源:ServerPlayer.java


示例8: onLogin

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
public void onLogin(Session session) {
	NetherPlayer newPlayer = new NetherPlayer(session);

	NetherServer.players.put(session, newPlayer);

	// spawn the player in the world
	newPlayer.setWorld(NetherServer.defaultWorld);

	// send the join game packet
	session.send(new ServerJoinGamePacket((int) newPlayer.getUEID(),
			false, // Hardcore
			GameMode.CREATIVE, // Player gamemode
			newPlayer.getWorld().getDimension().toInt(), // Dimension (-1, 0, 1)
			Difficulty.PEACEFUL, // Difficulty
			10, // Max players
			WorldType.DEFAULT, 
			false // Less debug info
	));
       
       // Send the logging in player the player list
       
       List<PlayerListEntry> playerList = new ArrayList<PlayerListEntry>();
       
       NetherServer.players.forEach((otherPlayer) -> {
           playerList.add(new PlayerListEntry(
                           otherPlayer.getProfile(),
                           GameMode.CREATIVE,        //TODO: game mode
                           1,                        //TODO: ping
                           new TextMessage(otherPlayer.getName())
           ));
       });
       
       PlayerListEntry[] playerListPck = new PlayerListEntry[playerList.size()];
       playerList.toArray(playerListPck);
       
       session.send(new ServerPlayerListEntryPacket(
           PlayerListEntryAction.ADD_PLAYER,
           playerListPck
       ));
       
       // Send the other players the new player listing.
       
       NetherServer.players.forEach((otherPlayer) -> {
           if(otherPlayer == newPlayer) return;
           
           PlayerListEntry[] newPlayerListing = new PlayerListEntry[1];
           
           newPlayerListing[0] = new PlayerListEntry(newPlayer.getProfile(), GameMode.CREATIVE, 1, new TextMessage(newPlayer.getName()));
           
           otherPlayer.sendPacket(new ServerPlayerListEntryPacket(PlayerListEntryAction.ADD_PLAYER, newPlayerListing));
       });

	// send the player position packet to get the player to spawn
	session.send(new ServerPlayerPositionRotationPacket(0, 81.62, 0, 0, 0, 0));

	// send a message to the console and to all players that a new person
	// has joined the game
	MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
	if (protocol.getSubProtocol() == SubProtocol.GAME) {
		GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
		logger.info(profile.getName() + " has joined the game");
		NetherServer.server.getSessions()
				.forEach((sessions) -> sessions
						.send(new ServerChatPacket(new TextMessage(profile.getName() + " has joined the game")
								.setStyle(new MessageStyle().setColor(ChatColor.YELLOW)))));
	}
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:68,代码来源:LoginHandler.java


示例9: sendMessage

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@Override
public void sendMessage(TextMessage message){
    this.session.send(new ServerChatPacket(message));
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:5,代码来源:NetherPlayer.java


示例10: handle

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@Override
public void handle(ServerChatPacket packet) {
    for(ChatMessageListener listener : listeners) {
        listener.onChatMessage(packet.getMessage());
    }
}
 
开发者ID:mstojcevich,项目名称:Radix,代码行数:7,代码来源:ChatHandler.java


示例11: sendMessage

import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; //导入依赖的package包/类
@Override
public void sendMessage(String message) {
    ServerChatPacket packet = new ServerChatPacket(message);
    getPlayerNetwork().sendPacket(packet);
}
 
开发者ID:BeYkeRYkt,项目名称:CyanWool,代码行数:6,代码来源:CyanPlayer.java



注:本文中的org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GTRenderer类代码示例发布时间:2022-05-22
下一篇:
Java JTATransactionController类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap