本文整理匯總了Java中com.google.common.io.ByteArrayDataOutput.writeUTF方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataOutput.writeUTF方法的具體用法?Java ByteArrayDataOutput.writeUTF怎麽用?Java ByteArrayDataOutput.writeUTF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteArrayDataOutput
的用法示例。
在下文中一共展示了ByteArrayDataOutput.writeUTF方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendSignUpdateRequest
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public static void sendSignUpdateRequest(Game game) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
String name = SkyWarsReloaded.getCfg().getBungeeServer();
try {
out.writeUTF("Forward");
out.writeUTF("ALL");
out.writeUTF("SkyWarsReloaded");
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
msgout.writeUTF(name + ":" + game.getState().toString() + ":" + Integer.toString(game.getPlayers().size()) + ":" + Integer.toString(game.getNumberOfSpawns()) + ":" + game.getMapName());
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
Bukkit.getServer().sendPluginMessage(SkyWarsReloaded.get(), "BungeeCord", out.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: update
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public void update() {
Player player = Bukkit.getPlayer(playerData.getPlayerID());
try {
//Update SQL
gameServiceManager.setPlayerSettings(playerData.getPlayerBean(), this);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
//Comamnd type
out.writeUTF("settingsChanges");
//The player to refresh settings on bungee
out.writeUTF(player.getUniqueId().toString());
//Send data on network channel
player.sendPluginMessage(APIPlugin.getInstance(), "Network", out.toByteArray());
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: sendVaultBalance
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public void sendVaultBalance(String playerName, double playerBalance)
{
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(ServerSync.vault.vaultSubchannel); //Vault Subchannel
out.writeUTF(ServerSync.vault.economySubchannel); //Vault Economy Subchannel
out.writeUTF("Balance"); //Operation
out.writeUTF(ServerSync.bungeeServerName); //Server Name
out.writeUTF(ServerSync.pluginVersion); //Client Version
out.writeUTF(playerName); //Player name
if (ServerSync.encryption.isEnabled())
{
out.writeUTF(ServerSync.encryption.encrypt(String.valueOf(playerBalance)));
}
else
{
out.writeUTF(Double.toString(playerBalance)+""); //Player balance
}
ServerSync.bungeeOutgoing.sendMessage(out, ServerSync.bungeePluginChannel);
if (ServerSync.verbose)
{
Log.info(ServerSync.consolePrefix + "Vault - Balance update sent for " + ChatColor.YELLOW + playerName + " for $" + playerBalance);
}
}
示例4: sendPlayerGroups
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
protected void sendPlayerGroups(OfflinePlayer player, String world, String groups)
{
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(ServerSync.vault.vaultSubchannel);
out.writeUTF(ServerSync.vault.permissionSubchannel); //Vault Permission sub channel
out.writeUTF("PlayerGroups"); //Operation
out.writeUTF(ServerSync.bungeeServerName); //Server Name
out.writeUTF(ServerSync.pluginVersion); //Client Version
out.writeUTF(player.getUniqueId().toString()); //Player UUID
out.writeUTF(world); //World
out.writeUTF(groups); //Groups
ServerSync.bungeeOutgoing.sendMessage(out, ServerSync.bungeePluginChannel);
if (ServerSync.verbose)
{
Log.info(ServerSync.consolePrefix + "Vault - Permission group update sent for " + ChatColor.YELLOW + player.getName());
}
}
示例5: createWDLPacket4
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Creates the WDL packet #4.
*
* This packet specifies the initial overrides for what chunks can and
* cannot be saved.
*
* This packet starts with an int stating the number of keys, and then a
* series of values for 1 range group. The range group starts with its name
* (the key in ranges), then an int (the number of ranges) and then each of
* the ranges as generated by
* {@link #writeProtectionRange(ProtectionRange, ByteArrayDataOutput)}.
*/
public static byte[] createWDLPacket4(
Map<String, List<ProtectionRange>> ranges) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(4);
output.writeInt(ranges.size());
for (String key : ranges.keySet()) {
output.writeUTF(key);
List<ProtectionRange> rangeGroup = ranges.get(key);
output.writeInt(rangeGroup.size());
for (ProtectionRange range : rangeGroup) {
writeProtectionRange(range, output);
}
}
return output.toByteArray();
}
示例6: createWDLPacket5
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Creates the WDL packet #5.
*
* This packet specifies adds additional overrides to or sets all of the
* overrides in a single group.
*
* This packet starts with a String stating the group, then a boolean that
* specifies whether it is setting (true) or adding (false) the ranges, and
* then an int (the number of ranges that will be added). Then, each range,
* formated by
* {@link #writeProtectionRange(ProtectionRange, ByteArrayDataOutput)}.
*/
public static byte[] createWDLPacket5(String group,
boolean replace, List<ProtectionRange> ranges) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(5);
output.writeUTF(group);
output.writeBoolean(replace);
output.writeInt(ranges.size());
for (ProtectionRange range : ranges) {
writeProtectionRange(range, output);
}
return output.toByteArray();
}
示例7: createWDLPacket7
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Creates the WDL packet #7.
*
* This packet replaces all of the ranges with the given tag with a new set
* of ranges.
*
* This packet starts with a String stating the group, then a second string
* that specifies the tag to replace. After that, there is an int stating
* the number of ranges, and then each range as formated by
* {@link #writeProtectionRange(ProtectionRange, ByteArrayDataOutput)}.
*/
public static byte[] createWDLPacket7(String group,
String tag, List<ProtectionRange> newRanges) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(7);
output.writeUTF(group);
output.writeUTF(tag);
output.writeInt(newRanges.size());
for (ProtectionRange range : newRanges) {
writeProtectionRange(range, output);
}
return output.toByteArray();
}
示例8: writeProtectionRange
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Writes a protection range to the given output stream.
*
* This is a string with the range's tag, then 4 integers for the
* coordinates (x1, z1, x2, z2). This method also swaps x1 and x2 if x1 is
* greater than x2.
*/
private static void writeProtectionRange(ProtectionRange range,
ByteArrayDataOutput output) {
output.writeUTF(range.tag);
int x1 = range.x1, z1 = range.z1;
int x2 = range.x2, z2 = range.z2;
if (x1 > x2) {
x2 = range.x1;
x1 = range.x2;
}
if (z1 > z2) {
z2 = range.z1;
z1 = range.z2;
}
output.writeInt(x1);
output.writeInt(z1);
output.writeInt(x2);
output.writeInt(z2);
}
示例9: sendUpdateRequest
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public void sendUpdateRequest() {
Player player = Iterables.getFirst(Bukkit.getOnlinePlayers(), null);
if(player == null) return;
try {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF(Subchannel.UPDATE_REQUEST.toString());
out.writeUTF(this.gameName);
out.writeUTF(this.serverName);
Main.getInstance().getServer().getMessenger()
.dispatchIncomingMessage(player, Main.BUNGEE_CHANNEL_NAME, out.toByteArray());
} catch(Exception ex) {
if(Main.DEBUGGING) {
Main.getInstance().getLogger().info("Error on sending update request for sign: " + ex.getMessage());
}
}
}
示例10: write
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public void write(ByteArrayDataOutput out)
{
// ------
// SERVER
// ------
out.writeUTF( particleName );
out.writeDouble( particlePosX );
out.writeDouble( particlePosY );
out.writeDouble( particlePosZ );
out.writeDouble( velX );
out.writeDouble( velY );
out.writeDouble( velZ );
}
示例11: generatePacket
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public byte[] generatePacket(Object... data)
{
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
Collection<NetworkModHandler >networkMods = FMLNetworkHandler.instance().getNetworkIdMap().values();
dat.writeInt(networkMods.size());
for (NetworkModHandler handler : networkMods)
{
dat.writeUTF(handler.getContainer().getModId());
dat.writeInt(handler.getNetworkId());
}
// TODO send the other id maps as well
return dat.toByteArray();
}
示例12: getPlayers
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Gets the array of players currently online on a server.
* @param serverName The name of the server.
* @param resultHandler The function to invoke upon receiving the result. The source parameter is the server name, the result is the player list.
* @see ResultReceived
*/
public void getPlayers(String serverName, ResultReceived<String, String[]> resultHandler){
Validate.notNull(resultHandler, "The result handler must not be null.");
Validate.notEmpty(serverName, "The server name must not be empty.");
if(!_playerListReceivers.containsKey(serverName.toLowerCase().trim())){
_playerListReceivers.put(serverName.toLowerCase().trim(), new ArrayList<ResultReceived<String, String[]>>(1));
}
_playerListReceivers.get(serverName.toLowerCase().trim()).add(resultHandler);
final ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PlayerList");
out.writeUTF(serverName);
schedulePlayerTask(new SendPluginMessageToPlayer(out));
}
示例13: writeMarket
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
private void writeMarket(StockList market, ByteArrayDataOutput out) {
out.writeInt(market.getCategoryCount());
for (int i = 0; i < market.getCategoryCount(); i++) {
StockCategory category = market.getCategory(i);
out.writeUTF(category.getCategoryName());
out.writeInt(Item.itemRegistry.getIDForObject(category.getIconItem().getItem()));
out.writeInt(category.getIconItem().getItemDamage());
out.writeInt(category.getItemCount());
for (int j = 0; j < category.getItemCount(); j ++) {
StockItem item = category.get(j);
out.writeInt(Item.itemRegistry.getIDForObject(item.getItem().getItem()));
out.writeInt(item.getItem().getItemDamage());
out.writeInt((item.getValue()));
}
}
}
示例14: write
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public void write(ByteArrayDataOutput out)
{
super.write(out);
out.writeInt(orientation);
out.writeBoolean(validMultiblock);
out.writeUTF(selectedModule);
out.writeUTF(selectedChipset);
out.writeInt(armorId);
out.writeBoolean(progressing);
out.writeInt(progress);
out.writeBoolean(energyPos != null);
if (energyPos != null)
{
out.writeInt((int) energyPos.x);
out.writeInt((int) energyPos.y);
out.writeInt((int) energyPos.z);
}
}
示例15: generatePacket
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public byte[] generatePacket(Object... data)
{
Map<String,String> modVersions = (Map<String, String>) data[0];
List<String> missingMods = (List<String>) data[1];
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
dat.writeInt(modVersions.size());
for (Entry<String, String> version : modVersions.entrySet())
{
dat.writeUTF(version.getKey());
dat.writeUTF(version.getValue());
}
dat.writeInt(missingMods.size());
for (String missing : missingMods)
{
dat.writeUTF(missing);
}
return dat.toByteArray();
}