本文整理汇总了Java中org.spacehq.packetlib.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于org.spacehq.packetlib包,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onStatusRequest
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@PacketHandler
public void onStatusRequest(PCSession session, StatusQueryPacket packet) {
final List<Session> sessions = SpongeGame.instance.getServer().getNetwork().getSessions();
final List<GameProfile> profiles = new ArrayList<>();
sessions.stream().filter(activeSession -> activeSession.isConnected() && activeSession instanceof PCSession
&& ((PCSession) activeSession).getPacketProtocol()
.getProtocolPhase() == ProtocolPhase.INGAME).forEach(activeSession -> profiles.add(activeSession.getFlag(MinecraftConstants.
PROFILE_KEY)));
final VersionInfo versionInfo = new VersionInfo("1.9.x", MinecraftConstants.PROTOCOL_VERSION);
final PlayerInfo playerInfo = new PlayerInfo(SpongeGame.instance.getServer().getMaxPlayers(), profiles.size(), profiles.toArray(new
GameProfile[profiles.size()]));
final ServerStatusInfo info = new ServerStatusInfo(versionInfo, playerInfo, new TextMessage(SpongeGame.instance.getConfiguration().getMotd
()), null);
session.send(new StatusResponsePacket(info));
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:18,代码来源:StatusHandlers.java
示例2: onServerChat
import org.spacehq.packetlib.Session; //导入依赖的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: run
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public void run() {
while (true) {
SpongeGame.instance.getServer().getNetwork().getSessions().stream().filter(Session::isConnected).forEach
(session -> {
final PCSession pcSession = (PCSession) session;
if (pcSession.getPacketProtocol().getProtocolPhase() == ProtocolPhase.INGAME) {
pcSession.setLastPingId(pcSession.getLastPingTime());
pcSession.setLastPingTime(System.currentTimeMillis());
pcSession.send(new ServerKeepAlivePacket((int) pcSession.getLastPingId()));
}
});
try {
Thread.sleep(2000);
continue;
} catch (InterruptedException ignored) {}
return;
}
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:22,代码来源:KeepAliveThread.java
示例4: handleConsole
import org.spacehq.packetlib.Session; //导入依赖的package包/类
private void handleConsole() {
this.log.info("Console enabled!");
Scanner scanner = new Scanner(System.in);
String line = "";
while ((line = scanner.nextLine()) != null) {
if (line.equalsIgnoreCase("stop")) {
this.log.info("Stopping server...");
for (Session s : this.server.getSessions()) {
s.disconnect("Server closed");
}
this.server.close();
}
else if (line.equalsIgnoreCase("help")) {
this.log.info("Valid commands: stop, help");
}
else {
this.log.info("Unknown command!");
}
}
scanner.close();
}
开发者ID:dobrakmato,项目名称:StaticMC,代码行数:23,代码来源:StaticMC.java
示例5: ServerPlayer
import org.spacehq.packetlib.Session; //导入依赖的package包/类
public ServerPlayer(Session session) {
super();
this.session = session;
this.setHealth(20.0);
this.loadedColumns = new HashSet<Column>();
this.loadedEntities = new HashSet<ServerEntity>();
this.clientDimension = null;
}
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:10,代码来源:ServerPlayer.java
示例6: buildInfo
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public ServerStatusInfo buildInfo(Session session) {
return new ServerStatusInfo(
new VersionInfo(MinecraftConstants.GAME_VERSION, MinecraftConstants.PROTOCOL_VERSION),
new PlayerInfo(Integer.valueOf(MainMain.config.getProperty("max-players")), Integer.valueOf(MainMain.server.getSessions().size()), new GameProfile[0]), new TextMessage(MainMain.config.getProperty("motd"))
.setStyle(new MessageStyle().setColor(ChatColor.RESET)),
null);
}
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:9,代码来源:PingHandler.java
示例7: loggedIn
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public void loggedIn(Session session) {
try {
onLogin(session);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:10,代码来源:LoginHandler.java
示例8: onLogin
import org.spacehq.packetlib.Session; //导入依赖的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
示例9: buildInfo
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public ServerStatusInfo buildInfo(Session session) {
// a server status builder to respond to pings, TODO! make this
// configureable
return new ServerStatusInfo(
new VersionInfo(MinecraftConstants.GAME_VERSION, MinecraftConstants.PROTOCOL_VERSION),
new PlayerInfo(20, 0, new GameProfile[0]),
new TextMessage(NetherServer.config.getProperty("motd")).setStyle(new MessageStyle().setColor(ChatColor.RESET)), null);
}
开发者ID:netherrack,项目名称:netherrack,代码行数:10,代码来源:PingHandler.java
示例10: loggedIn
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public void loggedIn(Session session){
try{
onLogin(session);
}catch(Exception e){
e.printStackTrace();
throw e;
}
}
开发者ID:netherrack,项目名称:netherrack,代码行数:10,代码来源:LoginHandler.java
示例11: NetherPlayer
import org.spacehq.packetlib.Session; //导入依赖的package包/类
public NetherPlayer(Session session) {
super();
this.session = session;
this.setHealth(20.0);
this.loadedColumns = new HashSet<Column>();
this.loadedEntities = new HashSet<NetherEntity>();
this.clientDimension = null;
}
开发者ID:netherrack,项目名称:netherrack,代码行数:10,代码来源:NetherPlayer.java
示例12: MinecraftProtocolMock
import org.spacehq.packetlib.Session; //导入依赖的package包/类
public MinecraftProtocolMock(Session session, boolean client,
Function<Class<? extends Packet>, Class<? extends Packet>> incoming,
Function<Class<? extends Packet>, Class<? extends Packet>> outgoing) {
super(SubProtocol.LOGIN);
this.incoming = incoming;
this.outgoing = outgoing;
init(session, client, SubProtocol.GAME);
}
开发者ID:ReplayMod,项目名称:ReplayStudio,代码行数:11,代码来源:MinecraftProtocolMock.java
示例13: getNameCaptcha
import org.spacehq.packetlib.Session; //导入依赖的package包/类
public static String getNameCaptcha(String playerName)
{
for (Session s : server.getSessions())
{
GameProfile profile = s.getFlag("profile");
if (profile.getName().equals(playerName))
{
return s.getFlag("cap");
}
}
return "0";
}
开发者ID:irootdev,项目名称:AnBot,代码行数:13,代码来源:Main.java
示例14: stopServer
import org.spacehq.packetlib.Session; //导入依赖的package包/类
public static void stopServer()
{
for (Session s : server.getSessions())
{
s.disconnect("Капча сервер остановлен!");
}
server.close();
}
开发者ID:irootdev,项目名称:AnBot,代码行数:9,代码来源:Main.java
示例15: buildInfo
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public ServerStatusInfo buildInfo(Session session) {
VersionInfo version = new VersionInfo(ProtocolConstants.GAME_VERSION, ProtocolConstants.PROTOCOL_VERSION);
PlayerInfo player = new PlayerInfo(server.getConfiguration().getMaxPlayers(), server.getPlayers().size(), new GameProfile[0]);
Message message = new TextMessage(server.getConfiguration().getMotd());
BufferedImage icon = server.getIcon();
return new ServerStatusInfo(version, player, message, icon);
}
开发者ID:BeYkeRYkt,项目名称:CyanWool,代码行数:10,代码来源:ServerInfo.java
示例16: disconnected
import org.spacehq.packetlib.Session; //导入依赖的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
示例17: SessionAuthenticatorThread
import org.spacehq.packetlib.Session; //导入依赖的package包/类
public SessionAuthenticatorThread(Session session, SecretKey secretKey, KeyPair keyPair, String serverId) {
checkNotNull(session);
checkNotNull(secretKey);
checkNotNull(keyPair);
checkNotNull(serverId);
this.session = session;
this.secretKey = secretKey;
this.keyPair = keyPair;
this.serverId = serverId;
setDaemon(true);
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:12,代码来源:SessionAuthenticatorThread.java
示例18: newClientSession
import org.spacehq.packetlib.Session; //导入依赖的package包/类
@Override
public void newClientSession(final Client client, final Session session) {
if (this.profile != null) {
session.setFlag(ProtocolConstants.PROFILE_KEY, this.profile);
session.setFlag(ProtocolConstants.ACCESS_TOKEN_KEY, this.accessToken);
}
this.setMode(this.mode, true, session);
session.addListener(this.clientListener);
}
开发者ID:dobrakmato,项目名称:StaticMC,代码行数:11,代码来源:MinecraftProtocol_18.java
示例19: initClientLogin
import org.spacehq.packetlib.Session; //导入依赖的package包/类
private void initClientLogin(final Session session) {
this.registerIncoming(0, LoginDisconnectPacket.class);
this.registerIncoming(1, EncryptionRequestPacket.class);
this.registerIncoming(2, LoginSuccessPacket.class);
this.registerIncoming(3, LoginSetCompressionPacket.class);
this.registerOutgoing(0, LoginStartPacket.class);
this.registerOutgoing(1, EncryptionResponsePacket.class);
}
开发者ID:dobrakmato,项目名称:StaticMC,代码行数:10,代码来源:MinecraftProtocol_18.java
示例20: initServerLogin
import org.spacehq.packetlib.Session; //导入依赖的package包/类
private void initServerLogin(final Session session) {
this.registerIncoming(0, LoginStartPacket.class);
this.registerIncoming(1, EncryptionResponsePacket.class);
this.registerOutgoing(0, LoginDisconnectPacket.class);
this.registerOutgoing(1, EncryptionRequestPacket.class);
this.registerOutgoing(2, LoginSuccessPacket.class);
this.registerOutgoing(3, LoginSetCompressionPacket.class);
}
开发者ID:dobrakmato,项目名称:StaticMC,代码行数:10,代码来源:MinecraftProtocol_18.java
注:本文中的org.spacehq.packetlib.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论