Java源码示例:cn.nukkit.network.protocol.ProtocolInfo
示例1
private DataPacket getPacket(byte[] buffer) {
int start = 0;
if (buffer[0] == (byte) 0xfe) {
start++;
}
DataPacket data = this.network.getPacket(ProtocolInfo.BATCH_PACKET);
if (data == null) {
return null;
}
data.setBuffer(buffer, start);
return data;
}
示例2
private DataPacket getPacket(byte[] buffer) {
int start = 0;
if (buffer[0] == (byte) 0xfe) {
start++;
}
DataPacket data = this.network.getPacket(ProtocolInfo.BATCH_PACKET);
if (data == null) {
return null;
}
data.setBuffer(buffer, start);
return data;
}
示例3
public static void broadcastPacket(Player[] players, DataPacket packet) {
packet.encode();
packet.isEncoded = true;
if (packet.pid() == ProtocolInfo.BATCH_PACKET) {
for (Player player : players) {
player.dataPacket(packet);
}
} else {
getInstance().batchPackets(players, new DataPacket[]{packet}, true);
}
if (packet.encapsulatedPacket != null) {
packet.encapsulatedPacket = null;
}
}
示例4
private DataPacket getPacket(byte[] buffer) {
int start = 0;
if (buffer[0] == (byte) 0xfe) {
start++;
}
DataPacket data = this.network.getPacket(ProtocolInfo.BATCH_PACKET);
if (data == null) {
return null;
}
data.setBuffer(buffer, start);
return data;
}
示例5
public static void broadcastPacket(Player[] players, DataPacket packet) {
packet.encode();
packet.isEncoded = true;
if (packet.pid() == ProtocolInfo.BATCH_PACKET) {
for (Player player : players) {
player.dataPacket(packet);
}
} else {
getInstance().batchPackets(players, new DataPacket[]{packet}, true);
}
if (packet.encapsulatedPacket != null) {
packet.encapsulatedPacket = null;
}
}
示例6
@Override
public void setName(String name) {
QueryRegenerateEvent info = this.server.getQueryInformation();
String[] names = name.split("[email protected]#"); //Split double names within the program
this.handler.sendOption("name",
"MCPE;" + Utils.rtrim(names[0].replace(";", "\\;"), '\\') + ";" +
ProtocolInfo.CURRENT_PROTOCOL + ";" +
ProtocolInfo.MINECRAFT_VERSION_NETWORK + ";" +
info.getPlayerCount() + ";" +
info.getMaxPlayerCount() + ";" +
this.server.getServerUniqueId().toString() + ";" +
(names.length > 1 ? Utils.rtrim(names[1].replace(";", "\\;"), '\\') : "") + ";" +
Server.getGamemodeString(this.server.getDefaultGamemode(), true) + ";");
}
示例7
@Override
public void setName(String name) {
QueryRegenerateEvent info = this.server.getQueryInformation();
String[] names = name.split("[email protected]#"); //Split double names within the program
this.handler.sendOption("name",
"MCPE;" + Utils.rtrim(names[0].replace(";", "\\;"), '\\') + ";" +
ProtocolInfo.CURRENT_PROTOCOL + ";" +
ProtocolInfo.MINECRAFT_VERSION_NETWORK + ";" +
info.getPlayerCount() + ";" +
info.getMaxPlayerCount() + ";" +
this.server.getServerUniqueId().toString() + ";" +
(names.length > 1 ? Utils.rtrim(names[1].replace(";", "\\;"), '\\') : "") + ";" +
Server.getGamemodeString(this.server.getDefaultGamemode(), true) + ";");
}
示例8
@Override
public void onEnable() {
this.getServer().getNetwork().registerPacket(ProtocolInfo.SET_HEALTH_PACKET, SetHealthPacket.class);
this.messenger = new StandardMessenger();
loadEntries();
this.getServer().getPluginManager().registerEvents(this, this);
}
示例9
@Override
public void setName(String name) {
QueryRegenerateEvent info = this.server.getQueryInformation();
String[] names = name.split("[email protected]#"); //Split double names within the program
this.handler.sendOption("name",
"MCPE;" + Utils.rtrim(names[0].replace(";", "\\;"), '\\') + ";" +
ProtocolInfo.CURRENT_PROTOCOL + ";;" +
info.getPlayerCount() + ";" +
info.getMaxPlayerCount() + ";" +
this.server.getServerUniqueId().toString() + ";" +
(names.length > 1 ? Utils.rtrim(names[1].replace(";", "\\;"), '\\') : "") + ";" +
Server.getGamemodeString(this.server.getDefaultGamemode(), true) + ";");
}
示例10
private void registerPackets() {
this.packetPool = new Class[256];
this.registerPacket(ProtocolInfo.ADD_BEHAVIOR_TREE_PACKET, AddBehaviorTreePacket.class);//new
this.registerPacket(ProtocolInfo.ADD_ENTITY_PACKET, AddEntityPacket.class);
this.registerPacket(ProtocolInfo.ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket.class);
this.registerPacket(ProtocolInfo.ADD_PAINTING_PACKET, AddPaintingPacket.class);
this.registerPacket(ProtocolInfo.ADD_PLAYER_PACKET, AddPlayerPacket.class);
this.registerPacket(ProtocolInfo.ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket.class);
this.registerPacket(ProtocolInfo.ANIMATE_PACKET, AnimatePacket.class);
this.registerPacket(ProtocolInfo.AVAILABLE_COMMANDS_PACKET, AvailableCommandsPacket.class);
this.registerPacket(ProtocolInfo.BATCH_PACKET, BatchPacket.class);
this.registerPacket(ProtocolInfo.BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket.class);
this.registerPacket(ProtocolInfo.BLOCK_EVENT_PACKET, BlockEventPacket.class);
this.registerPacket(ProtocolInfo.BLOCK_PICK_REQUEST_PACKET, BlockPickRequestPacket.class);
this.registerPacket(ProtocolInfo.BOOK_EDIT_PACKET, BookEditPacket.class);//new
this.registerPacket(ProtocolInfo.BOSS_EVENT_PACKET, BossEventPacket.class);
this.registerPacket(ProtocolInfo.CAMERA_PACKET, CameraPacket.class);//new
this.registerPacket(ProtocolInfo.CHANGE_DIMENSION_PACKET, ChangeDimensionPacket.class);
this.registerPacket(ProtocolInfo.CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket.class);
this.registerPacket(ProtocolInfo.CLIENTBOUND_MAP_ITEM_DATA_PACKET, ClientboundMapItemDataPacket.class);
this.registerPacket(ProtocolInfo.COMMAND_BLOCK_UPDATE_PACKET, CommandBlockUpdatePacket.class);//new
this.registerPacket(ProtocolInfo.COMMAND_REQUEST_PACKET, CommandRequestPacket.class);
this.registerPacket(ProtocolInfo.CONTAINER_CLOSE_PACKET, ContainerClosePacket.class);
this.registerPacket(ProtocolInfo.CONTAINER_OPEN_PACKET, ContainerOpenPacket.class);
this.registerPacket(ProtocolInfo.CONTAINER_SET_DATA_PACKET, ContainerSetDataPacket.class);
this.registerPacket(ProtocolInfo.CRAFTING_DATA_PACKET, CraftingDataPacket.class);
this.registerPacket(ProtocolInfo.CRAFTING_EVENT_PACKET, CraftingEventPacket.class);
this.registerPacket(ProtocolInfo.DISCONNECT_PACKET, DisconnectPacket.class);
this.registerPacket(ProtocolInfo.ENTITY_EVENT_PACKET, EntityEventPacket.class);
this.registerPacket(ProtocolInfo.ENTITY_FALL_PACKET, EntityFallPacket.class);
this.registerPacket(ProtocolInfo.EXPLODE_PACKET, ExplodePacket.class);
this.registerPacket(ProtocolInfo.FULL_CHUNK_DATA_PACKET, FullChunkDataPacket.class);
this.registerPacket(ProtocolInfo.GAME_RULES_CHANGED_PACKET, GameRulesChangedPacket.class);
this.registerPacket(ProtocolInfo.GUI_DATA_PICK_ITEM_PACKET, GUIDataPickItemPacket.class);//new
this.registerPacket(ProtocolInfo.HURT_ARMOR_PACKET, HurtArmorPacket.class);
this.registerPacket(ProtocolInfo.INTERACT_PACKET, InteractPacket.class);
this.registerPacket(ProtocolInfo.INVENTORY_CONTENT_PACKET, InventoryContentPacket.class);
this.registerPacket(ProtocolInfo.INVENTORY_SLOT_PACKET, InventorySlotPacket.class);
this.registerPacket(ProtocolInfo.INVENTORY_TRANSACTION_PACKET, InventoryTransactionPacket.class);
this.registerPacket(ProtocolInfo.ITEM_FRAME_DROP_ITEM_PACKET, ItemFrameDropItemPacket.class);
this.registerPacket(ProtocolInfo.LEVEL_EVENT_PACKET, LevelEventPacket.class);
this.registerPacket(ProtocolInfo.LEVEL_SOUND_EVENT_PACKET, LevelSoundEventPacket.class);
this.registerPacket(ProtocolInfo.LOGIN_PACKET, LoginPacket.class);
this.registerPacket(ProtocolInfo.MAP_INFO_REQUEST_PACKET, MapInfoRequestPacket.class);
this.registerPacket(ProtocolInfo.MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket.class);
this.registerPacket(ProtocolInfo.MOB_EQUIPMENT_PACKET, MobEquipmentPacket.class);
this.registerPacket(ProtocolInfo.MODAL_FORM_REQUEST_PACKET, ModalFormRequestPacket.class);//new
this.registerPacket(ProtocolInfo.MODAL_FORM_RESPONSE_PACKET, ModalFormResponsePacket.class);//new
this.registerPacket(ProtocolInfo.MOVE_ENTITY_PACKET, MoveEntityPacket.class);
this.registerPacket(ProtocolInfo.MOVE_PLAYER_PACKET, MovePlayerPacket.class);
this.registerPacket(ProtocolInfo.NPC_REQUEST_PACKET, NPCRequestPacket.class);//new
this.registerPacket(ProtocolInfo.PLAYER_ACTION_PACKET, PlayerActionPacket.class);
this.registerPacket(ProtocolInfo.PLAYER_HOTBAR_PACKET, PlayerListPacket.class);
this.registerPacket(ProtocolInfo.PLAYER_INPUT_PACKET, PlayerInputPacket.class);
this.registerPacket(ProtocolInfo.PLAYER_LIST_PACKET, PlayerListPacket.class);
this.registerPacket(ProtocolInfo.PLAYER_SKIN_PACKET, PlayerSkinPacket.class);//new
this.registerPacket(ProtocolInfo.PLAY_SOUND_PACKET, PlaySoundPacket.class);
this.registerPacket(ProtocolInfo.PLAY_STATUS_PACKET, PlayStatusPacket.class);
this.registerPacket(ProtocolInfo.REMOVE_ENTITY_PACKET, RemoveEntityPacket.class);
this.registerPacket(ProtocolInfo.REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket.class);
this.registerPacket(ProtocolInfo.RESOURCE_PACK_CHUNK_DATA_PACKET, ResourcePackChunkDataPacket.class);
this.registerPacket(ProtocolInfo.RESOURCE_PACK_CHUNK_REQUEST_PACKET, ResourcePackChunkRequestPacket.class);
this.registerPacket(ProtocolInfo.RESOURCE_PACK_CLIENT_RESPONSE_PACKET, ResourcePackClientResponsePacket.class);
this.registerPacket(ProtocolInfo.RESOURCE_PACK_DATA_INFO_PACKET, ResourcePackDataInfoPacket.class);
this.registerPacket(ProtocolInfo.RESOURCE_PACKS_INFO_PACKET, ResourcePacksInfoPacket.class);
this.registerPacket(ProtocolInfo.RESOURCE_PACK_STACK_PACKET, ResourcePackStackPacket.class);
this.registerPacket(ProtocolInfo.RESPAWN_PACKET, RespawnPacket.class);
this.registerPacket(ProtocolInfo.RIDER_JUMP_PACKET, RiderJumpPacket.class);
this.registerPacket(ProtocolInfo.SERVER_SETTINGS_REQUEST_PACKET, ServerSettingsRequestPacket.class);//new
this.registerPacket(ProtocolInfo.SERVER_SETTINGS_RESPONSE_PACKET, ServerSettingsResponsePacket.class);//new
this.registerPacket(ProtocolInfo.SERVER_TO_CLIENT_HANDSHAKE_PACKET, ServerToClientHandshakePacket.class);//new
this.registerPacket(ProtocolInfo.SET_COMMANDS_ENABLED_PACKET, SetCommandsEnabledPacket.class);
this.registerPacket(ProtocolInfo.SET_DEFAULT_GAME_TYPE_PACKET, SetDefaultGameTypePacket.class);
this.registerPacket(ProtocolInfo.SET_DIFFICULTY_PACKET, SetDifficultyPacket.class);
this.registerPacket(ProtocolInfo.SET_ENTITY_DATA_PACKET, SetEntityDataPacket.class);
this.registerPacket(ProtocolInfo.SET_ENTITY_LINK_PACKET, SetEntityLinkPacket.class);
this.registerPacket(ProtocolInfo.SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket.class);
this.registerPacket(ProtocolInfo.SET_HEALTH_PACKET, SetHealthPacket.class);
this.registerPacket(ProtocolInfo.SET_PLAYER_GAME_TYPE_PACKET, SetPlayerGameTypePacket.class);
this.registerPacket(ProtocolInfo.SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket.class);
this.registerPacket(ProtocolInfo.SET_TITLE_PACKET, SetTitlePacket.class);
this.registerPacket(ProtocolInfo.SET_TIME_PACKET, SetTimePacket.class);
this.registerPacket(ProtocolInfo.SHOW_CREDITS_PACKET, ShowCreditsPacket.class);
this.registerPacket(ProtocolInfo.SHOW_PROFILE_PACKET, ShowProfilePacket.class);
this.registerPacket(ProtocolInfo.SPAWN_EXPERIENCE_ORB_PACKET, SpawnExperienceOrbPacket.class);
this.registerPacket(ProtocolInfo.START_GAME_PACKET, StartGamePacket.class);
this.registerPacket(ProtocolInfo.STOP_SOUND_PACKET, StopSoundPacket.class);//new
this.registerPacket(ProtocolInfo.STRUCTURE_BLOCK_UPDATE_PACKET, StructureBlockUpdatePacket.class);//new
this.registerPacket(ProtocolInfo.SUB_CLIENT_LOGIN_PACKET, SubClientLoginPacket.class);//new
this.registerPacket(ProtocolInfo.TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket.class);
this.registerPacket(ProtocolInfo.TELEMETRY_EVENT_PACKET, TelemetryEventPacket.class);//new
this.registerPacket(ProtocolInfo.TEXT_PACKET, TextPacket.class);
this.registerPacket(ProtocolInfo.TRANSFER_PACKET, TransferPacket.class);//new
this.registerPacket(ProtocolInfo.UPDATE_ATTRIBUTES_PACKET, UpdateAttributesPacket.class);//new
this.registerPacket(ProtocolInfo.UPDATE_BLOCK_PACKET, UpdateBlockPacket.class);
this.registerPacket(ProtocolInfo.UPDATE_EQUIPMENT_PACKET, UpdateEquipmentPacket.class);//new
this.registerPacket(ProtocolInfo.UPDATE_TRADE_PACKET, UpdateTradePacket.class);
}
示例11
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(sender.getServer().getLanguage().translateString("nukkit.server.info.extended", new String[]{
sender.getServer().getName(),
sender.getServer().getNukkitVersion(),
sender.getServer().getCodename(),
sender.getServer().getApiVersion(),
sender.getServer().getVersion(),
String.valueOf(ProtocolInfo.CURRENT_PROTOCOL)
}) + "使用しているJupiterのバージョンは" + sender.getServer().getJupiterVersion() + "です。");
} else {
String pluginName = "";
for (String arg : args) pluginName += arg + " ";
pluginName = pluginName.trim();
final boolean[] found = {false};
final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName)};
if (exactPlugin[0] == null) {
pluginName = pluginName.toLowerCase();
final String finalPluginName = pluginName;
sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> {
if (s.toLowerCase().contains(finalPluginName)) {
exactPlugin[0] = p;
found[0] = true;
}
});
} else {
found[0] = true;
}
if (found[0]) {
PluginDescription desc = exactPlugin[0].getDescription();
sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion());
if (desc.getDescription() != null) {
sender.sendMessage(desc.getDescription());
}
if (desc.getWebsite() != null) {
sender.sendMessage("Website: " + desc.getWebsite());
}
List<String> authors = desc.getAuthors();
final String[] authorsString = {""};
authors.forEach((s) -> authorsString[0] += s);
if (authors.size() == 1) {
sender.sendMessage("Author: " + authorsString[0]);
} else if (authors.size() >= 2) {
sender.sendMessage("Authors: " + authorsString[0]);
}
} else {
sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin"));
}
}
return true;
}
示例12
public String getVersion() {
return ProtocolInfo.MINECRAFT_VERSION;
}
示例13
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("nukkit.server.info.extended", sender.getServer().getName(),
sender.getServer().getNukkitVersion(),
sender.getServer().getCodename(),
sender.getServer().getApiVersion(),
sender.getServer().getVersion(),
String.valueOf(ProtocolInfo.CURRENT_PROTOCOL)));
} else {
String pluginName = "";
for (String arg : args) pluginName += arg + " ";
pluginName = pluginName.trim();
final boolean[] found = {false};
final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName)};
if (exactPlugin[0] == null) {
pluginName = pluginName.toLowerCase();
final String finalPluginName = pluginName;
sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> {
if (s.toLowerCase().contains(finalPluginName)) {
exactPlugin[0] = p;
found[0] = true;
}
});
} else {
found[0] = true;
}
if (found[0]) {
PluginDescription desc = exactPlugin[0].getDescription();
sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion());
if (desc.getDescription() != null) {
sender.sendMessage(desc.getDescription());
}
if (desc.getWebsite() != null) {
sender.sendMessage("Website: " + desc.getWebsite());
}
List<String> authors = desc.getAuthors();
final String[] authorsString = {""};
authors.forEach((s) -> authorsString[0] += s);
if (authors.size() == 1) {
sender.sendMessage("Author: " + authorsString[0]);
} else if (authors.size() >= 2) {
sender.sendMessage("Authors: " + authorsString[0]);
}
} else {
sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin"));
}
}
return true;
}
示例14
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Server server = Server.getInstance();
server.getScheduler().scheduleAsyncTask(new AsyncTask() {
@Override
public void onRun() {
try {
new StatusCommand("status").execute(server.getConsoleSender(), "status", new String[]{});
String dataPath = server.getDataPath();
String nukkitYML = HastebinUtility.upload(new File(dataPath, "nukkit.yml"));
String serverProperties = HastebinUtility.upload(new File(dataPath, "server.properties"));
String latestLog = HastebinUtility.upload(new File(dataPath, "/logs/server.log"));
String threadDump = HastebinUtility.upload(Utils.getAllThreadDumps());
StringBuilder b = new StringBuilder();
b.append("# Files\n");
b.append("links.nukkit_yml: ").append(nukkitYML).append('\n');
b.append("links.server_properties: ").append(serverProperties).append('\n');
b.append("links.server_log: ").append(latestLog).append('\n');
b.append("links.thread_dump: ").append(threadDump).append('\n');
b.append("\n# Server Information\n");
b.append("version.api: ").append(server.getApiVersion()).append('\n');
b.append("version.nukkit: ").append(server.getNukkitVersion()).append('\n');
b.append("version.minecraft: ").append(server.getVersion()).append('\n');
b.append("version.protocol: ").append(ProtocolInfo.CURRENT_PROTOCOL).append('\n');
b.append("plugins:");
for (Plugin plugin : server.getPluginManager().getPlugins().values()) {
boolean enabled = plugin.isEnabled();
String name = plugin.getName();
PluginDescription desc = plugin.getDescription();
String version = desc.getVersion();
b.append("\n ")
.append(name)
.append(":\n ")
.append("version: '")
.append(version)
.append('\'')
.append("\n enabled: ")
.append(enabled);
}
b.append("\n\n# Java Details\n");
Runtime runtime = Runtime.getRuntime();
b.append("memory.free: ").append(runtime.freeMemory()).append('\n');
b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
b.append("cpu.runtime: ").append(ManagementFactory.getRuntimeMXBean().getUptime()).append('\n');
b.append("cpu.processors: ").append(runtime.availableProcessors()).append('\n');
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
b.append("java.version: '").append(System.getProperty("java.version")).append("'\n");
b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n");
b.append("os.name: '").append(System.getProperty("os.name")).append("'\n");
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
b.append("\n# Create a ticket: https://github.com/NukkitX/Nukkit/issues/new");
String link = HastebinUtility.upload(b.toString());
sender.sendMessage(link);
} catch (IOException e) {
MainLogger.getLogger().logException(e);
}
}
});
return true;
}
示例15
public void handleDataPacket(SynapseDataPacket pk) {
this.handleDataPacketTiming.startTiming();
//this.getSynapse().getLogger().warning("Received packet " + pk.pid() + "(" + pk.getClass().getSimpleName() + ") from " + this.serverIp + ":" + this.port);
switch (pk.pid()) {
case SynapseInfo.DISCONNECT_PACKET:
DisconnectPacket disconnectPacket = (DisconnectPacket) pk;
this.verified = false;
switch (disconnectPacket.type) {
case DisconnectPacket.TYPE_GENERIC:
this.getSynapse().getLogger().notice("Synapse Client has disconnected due to " + disconnectPacket.message);
this.synapseInterface.reconnect();
break;
case DisconnectPacket.TYPE_WRONG_PROTOCOL:
this.getSynapse().getLogger().error(disconnectPacket.message);
break;
}
break;
case SynapseInfo.INFORMATION_PACKET:
InformationPacket informationPacket = (InformationPacket) pk;
switch (informationPacket.type) {
case InformationPacket.TYPE_LOGIN:
if (informationPacket.message.equals(InformationPacket.INFO_LOGIN_SUCCESS)) {
this.getSynapse().getLogger().notice("Login success to " + this.serverIp + ":" + this.port);
this.verified = true;
} else if (informationPacket.message.equals(InformationPacket.INFO_LOGIN_FAILED)) {
this.getSynapse().getLogger().notice("Login failed to " + this.serverIp + ":" + this.port);
}
break;
case InformationPacket.TYPE_CLIENT_DATA:
this.clientData = new Gson().fromJson(informationPacket.message, ClientData.class);
this.lastRecvInfo = System.currentTimeMillis();
//this.getSynapse().getLogger().debug("Received ClientData from " + this.serverIp + ":" + this.port);
break;
}
break;
case SynapseInfo.PLAYER_LOGIN_PACKET:
this.playerLoginQueue.offer((PlayerLoginPacket) pk);
break;
case SynapseInfo.REDIRECT_PACKET:
RedirectPacket redirectPacket = (RedirectPacket) pk;
UUID uuid = redirectPacket.uuid;
if (this.players.containsKey(uuid)) {
DataPacket pk0 = this.getSynapse().getPacket(redirectPacket.mcpeBuffer);
if (pk0 != null) {
this.handleRedirectPacketTiming.startTiming();
if (pk0.pid() == ProtocolInfo.BATCH_PACKET) pk0.setOffset(1);
pk0.decode();
SynapsePlayer player = this.players.get(uuid);
if (pk0.pid() == ProtocolInfo.BATCH_PACKET) {
this.processBatch((BatchPacket) pk0).forEach(subPacket -> {
this.redirectPacketQueue.offer(new RedirectPacketEntry(player, subPacket));
//Server.getInstance().getLogger().info("C => S " + subPacket.getClass().getSimpleName());
});
} else {
this.redirectPacketQueue.offer(new RedirectPacketEntry(player, pk0));
}
this.handleRedirectPacketTiming.stopTiming();
}
}
break;
case SynapseInfo.PLAYER_LOGOUT_PACKET:
this.playerLogoutQueue.offer((PlayerLogoutPacket) pk);
break;
case SynapseInfo.PLUGIN_MESSAGE_PACKET:
PluginMessagePacket messagePacket = (PluginMessagePacket) pk;
this.synapse.getMessenger().dispatchIncomingMessage(this, messagePacket.channel, messagePacket.data);
break;
}
//this.handleDataPacketTiming.stopTiming();
}
示例16
public String getVersion() {
return ProtocolInfo.MINECRAFT_VERSION;
}
示例17
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("nukkit.server.info.extended", new String[]{
sender.getServer().getName(),
sender.getServer().getNukkitVersion(),
sender.getServer().getCodename(),
sender.getServer().getApiVersion(),
sender.getServer().getVersion(),
String.valueOf(ProtocolInfo.CURRENT_PROTOCOL)
}));
} else {
String pluginName = "";
for (String arg : args) pluginName += arg + " ";
pluginName = pluginName.trim();
final boolean[] found = {false};
final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName)};
if (exactPlugin[0] == null) {
pluginName = pluginName.toLowerCase();
final String finalPluginName = pluginName;
sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> {
if (s.toLowerCase().contains(finalPluginName)) {
exactPlugin[0] = p;
found[0] = true;
}
});
} else {
found[0] = true;
}
if (found[0]) {
PluginDescription desc = exactPlugin[0].getDescription();
sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion());
if (desc.getDescription() != null) {
sender.sendMessage(desc.getDescription());
}
if (desc.getWebsite() != null) {
sender.sendMessage("Website: " + desc.getWebsite());
}
List<String> authors = desc.getAuthors();
final String[] authorsString = {""};
authors.forEach((s) -> authorsString[0] += s);
if (authors.size() == 1) {
sender.sendMessage("Author: " + authorsString[0]);
} else if (authors.size() >= 2) {
sender.sendMessage("Authors: " + authorsString[0]);
}
} else {
sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin"));
}
}
return true;
}
示例18
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Server server = Server.getInstance();
server.getScheduler().scheduleAsyncTask(new AsyncTask() {
@Override
public void onRun() {
try {
new StatusCommand("status").execute(server.getConsoleSender(), "status", new String[]{});
String dataPath = server.getDataPath();
String nukkitYML = HastebinUtility.upload(new File(dataPath, "nukkit.yml"));
String serverProperties = HastebinUtility.upload(new File(dataPath, "server.properties"));
String latestLog = HastebinUtility.upload(new File(dataPath, "server.log"));
String threadDump = HastebinUtility.upload(Utils.getAllThreadDumps());
StringBuilder b = new StringBuilder();
b.append("# Files\n");
b.append("links.nukkit_yml: ").append(nukkitYML).append('\n');
b.append("links.server_properties: ").append(serverProperties).append('\n');
b.append("links.server_log: ").append(latestLog).append('\n');
b.append("links.thread_dump: ").append(threadDump).append('\n');
b.append("\n# Server Information\n");
b.append("version.api: ").append(server.getApiVersion()).append('\n');
b.append("version.nukkit: ").append(server.getNukkitVersion()).append('\n');
b.append("version.minecraft: ").append(server.getVersion()).append('\n');
b.append("version.protocol: ").append(ProtocolInfo.CURRENT_PROTOCOL).append('\n');
b.append("plugins:");
for (Plugin plugin : server.getPluginManager().getPlugins().values()) {
boolean enabled = plugin.isEnabled();
String name = plugin.getName();
PluginDescription desc = plugin.getDescription();
String version = desc.getVersion();
b.append("\n ")
.append(name)
.append(":\n ")
.append("version: '")
.append(version)
.append('\'')
.append("\n enabled: ")
.append(enabled);
}
b.append("\n\n# Java Details\n");
Runtime runtime = Runtime.getRuntime();
b.append("memory.free: ").append(runtime.freeMemory()).append('\n');
b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
b.append("cpu.runtime: ").append(ManagementFactory.getRuntimeMXBean().getUptime()).append('\n');
b.append("cpu.processors: ").append(runtime.availableProcessors()).append('\n');
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
b.append("java.version: '").append(System.getProperty("java.version")).append("'\n");
b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n");
b.append("os.name: '").append(System.getProperty("os.name")).append("'\n");
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
b.append("\n# Create a ticket: https://github.com/NukkitX/Nukkit/issues/new");
String link = HastebinUtility.upload(b.toString());
sender.sendMessage(link);
} catch (IOException e) {
MainLogger.getLogger().logException(e);
}
}
});
return true;
}
示例19
/**
* マインクラフトPEのバージョンを取得します。
* @return String Minecraftバージョン
*/
public String getVersion() {
return ProtocolInfo.MINECRAFT_VERSION;
}