本文整理匯總了Java中com.comphenix.protocol.ProtocolManager.createPacket方法的典型用法代碼示例。如果您正苦於以下問題:Java ProtocolManager.createPacket方法的具體用法?Java ProtocolManager.createPacket怎麽用?Java ProtocolManager.createPacket使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.comphenix.protocol.ProtocolManager
的用法示例。
在下文中一共展示了ProtocolManager.createPacket方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendBlankInventoryPacket
import com.comphenix.protocol.ProtocolManager; //導入方法依賴的package包/類
public void sendBlankInventoryPacket(Player player) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
inventoryPacket.getIntegers().write(0, PLAYER_INVENTORY);
int inventorySize = CRAFTING_SIZE + ARMOR_SIZE + MAIN_SIZE + HOTBAR_SIZE;
ItemStack[] blankInventory = new ItemStack[inventorySize];
Arrays.fill(blankInventory, new ItemStack(Material.AIR));
//old minecraft versions
StructureModifier<ItemStack[]> itemArrayModifier = inventoryPacket.getItemArrayModifier();
if (itemArrayModifier.size() > 0) {
itemArrayModifier.write(0, blankInventory);
} else {
//minecraft versions above 1.11
StructureModifier<List<ItemStack>> itemListModifier = inventoryPacket.getItemListModifier();
itemListModifier.write(0, Arrays.asList(blankInventory));
}
try {
protocolManager.sendServerPacket(player, inventoryPacket, false);
} catch (InvocationTargetException invocationExc) {
ConsoleLogger.logException("Error during sending blank inventory", invocationExc);
}
}
示例2: handleHF
import com.comphenix.protocol.ProtocolManager; //導入方法依賴的package包/類
public static void handleHF() {
if (!active
&& !(Variables.tablist_header_inparty.isEmpty() && Variables.tablist_header_outparty.isEmpty()
&& Variables.tablist_footer_inparty.isEmpty() && Variables.tablist_footer_outparty.isEmpty())) {
Parties plugin = Parties.getInstance();
ProtocolManager proto = ProtocolLibrary.getProtocolManager();
PacketContainer pc = proto.createPacket(PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
for (Player pl : plugin.getServer().getOnlinePlayers()) {
String header = "", footer = "";
ThePlayer tp = plugin.getPlayerHandler().getPlayer(pl.getUniqueId());
Party party = plugin.getPartyHandler().getParty(tp.getPartyName());
if (party != null) {
header = party.convertText(Variables.tablist_header_inparty, pl);
footer = party.convertText(Variables.tablist_footer_inparty, pl);
} else {
header = plugin.getPlayerHandler().setTabText(Variables.tablist_header_outparty, pl);
footer = plugin.getPlayerHandler().setTabText(Variables.tablist_footer_outparty, pl);
}
if (!header.isEmpty())
pc.getChatComponents().write(0, WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', header)));
if (!footer.isEmpty())
pc.getChatComponents().write(1, WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', footer)));
try {
proto.sendServerPacket(pl, pc);
} catch (InvocationTargetException ex) {
LogHandler.printError("ProtocolHandler error at handleHF(): " + ex.getMessage());
}
}
}
}
示例3: sendMetadataUpdatePacket
import com.comphenix.protocol.ProtocolManager; //導入方法依賴的package包/類
/**
*
*/
public void sendMetadataUpdatePacket(Horse horse) {
if (hookedProtocolLib) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, horse.getEntityId());
List<WrappedWatchableObject> watchables = new ArrayList<WrappedWatchableObject>();
watchables.add(new WrappedWatchableObject(ARMOR_INDEX, getArmorMetadataValue(horse)));
packet.getWatchableCollectionModifier().write(WATCHABLE_INDEX, watchables);
manager.broadcastServerPacket(packet, horse, true);
}
}
示例4: sendTeamPackets
import com.comphenix.protocol.ProtocolManager; //導入方法依賴的package包/類
public static void sendTeamPackets(TagTeamData data) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = manager
.createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
String UUID = Bukkit.getPlayer(data.members.get(0)).getUniqueId().toString();
packet.getStrings().write(0, data.members.get(0));
packet.getStrings().write(1, UUID);
packet.getStrings().write(2, data.teamPrefix);
packet.getStrings().write(2, data.teamSuffix);
packet.getIntegers().write(0, 5);
// 沒做完!
manager.broadcastServerPacket(packet);
// P A N!!!!!!!!!!!
// P A C K!!!!!!!!!
// P A C K E T!!!!!
// P A N C A K E!!!
// Prologue, canyon sunset calm after the storm, conversation
// interrupted.
// Hidden away, an unfortunate discovery shoshone overlook,
// thorofare hike catching up, see you soon.
// The house, part 2, original dedication life moves on,
// in the attic I said yes, I'll see you again.
// Just Gone, Daniel.
// A very long phase, getting lonnie the nunnery.
// The house, part 1, original stic with the group,
// default friends ship date, hanging out with girls dealing with roots,
// at the new house, first day of school void.
// Viewpoint, world -C; C main theme reset then revived shibuya,
// points taken fairy's dance capacity, revived shibuya.
// A ray of light, clear color girlish vacitita,
// AH Tokyo general hospital sumo seal count down,
// AH Tokyo general hospital rorschach test.
// An interferer in white, neutrals fairy's dance rorschach test.
// The air of terror sumo seal chaotic world, dusk lacrimosa,
// midnight tea time, girlish neutrals sorrowfulness.
// The air of terror, the third melt dark corner silence in the corner.
// Mapping mode flashback far days.
// What was lost?
// True Qualia.
// Re: start dark hollow, did you enjoy?
// More grief, silent world stille nacht keitus silent wind bell.
// Heart beat.
// invrohlvs, invrevinv,
// lvslitthn, htbbllmon,
// invvaninv, invsiginv,
// fitprcpst, invbtfvan,
// invqutsvg, durlitvar.
// Invention last part.
// Until the ray casa.
// Resonance between the trees sphere,
// kaleidoscope of happiness inside rivers,
// shadow dedicated to laura palmer, moving snowy sky.
// Spark innocence, the cycle of nature stillness of the holy place,
// in the dark woods, letter from a distance memoria.
// Kosemura resonance, you april dream nowhere call arne.
// Living in the present, buddhists starry night ein lied.
//
}