本文整理匯總了Java中com.google.common.io.ByteArrayDataOutput.writeBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataOutput.writeBoolean方法的具體用法?Java ByteArrayDataOutput.writeBoolean怎麽用?Java ByteArrayDataOutput.writeBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteArrayDataOutput
的用法示例。
在下文中一共展示了ByteArrayDataOutput.writeBoolean方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: updateData
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
private <T> void updateData(UUID uuid, DataKey<T> key, T value) {
try {
ByteArrayDataOutput data = ByteStreams.newDataOutput();
DataStreamUtils.writeUUID(data, uuid);
DataStreamUtils.writeDataKey(data, key);
data.writeBoolean(value == null);
if (value != null) {
typeRegistry.getTypeAdapter(key.getType()).write(data, value);
}
RedisBungee.getApi().sendChannelMessage(CHANNEL_DATA_UPDATE, Base64.getEncoder().encodeToString(data.toByteArray()));
} catch (RuntimeException ex) {
BungeeTabListPlus.getInstance().getLogger().log(Level.WARNING, "RedisBungee Error", ex);
} catch (Throwable th) {
BungeeTabListPlus.getInstance().getLogger().log(Level.SEVERE, "Failed to send data", th);
}
}
示例3: 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);
}
}
示例4: send
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public void send(String name, boolean value) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(BungeeSayNoToMcLeaks.SUBCHANNEL);
out.writeUTF(name);
out.writeBoolean(value);
for (Entry<String, ServerInfo> server : this.plugin.getProxy().getServers().entrySet()) {
server.getValue().sendData(BungeeSayNoToMcLeaks.CHANNEL, out.toByteArray());
}
}
示例5: map
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
protected void map(final Key key, final Value value, final Context context) throws IOException, InterruptedException {
try {
final RyaStatement statement = ryaContext.deserializeTriple(tableLayout, new TripleRow(key.getRow().getBytes(), key.getColumnFamily().getBytes(), key.getColumnQualifier().getBytes()));
//count each piece subject, pred, object
final String subj = statement.getSubject().getData();
final String pred = statement.getPredicate().getData();
// byte[] objBytes = tripleFormat.getValueFormat().serialize(statement.getObject());
final RyaURI scontext = statement.getContext();
final boolean includesContext = scontext != null;
final String scontext_str = (includesContext) ? scontext.getData() : null;
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF(subj);
output.writeUTF(RdfCloudTripleStoreConstants.SUBJECT_CF);
output.writeBoolean(includesContext);
if (includesContext) {
output.writeUTF(scontext_str);
}
keyOut.set(output.toByteArray());
context.write(keyOut, valOut);
output = ByteStreams.newDataOutput();
output.writeUTF(pred);
output.writeUTF(RdfCloudTripleStoreConstants.PRED_CF);
output.writeBoolean(includesContext);
if (includesContext) {
output.writeUTF(scontext_str);
}
keyOut.set(output.toByteArray());
context.write(keyOut, valOut);
} catch (final TripleRowResolverException e) {
throw new IOException(e);
}
}
示例6: write
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public void write(ByteArrayDataOutput out) {
out.writeInt(windowId);
out.writeInt(marketId);
out.writeInt(cartIndex);
int itemId = Item.getIdFromItem(itemToAddOrUpdate.getItem());
out.writeInt(itemId);
out.writeInt(itemToAddOrUpdate.stackSize);
out.writeInt(itemToAddOrUpdate.getItemDamage());
out.writeBoolean(addIfUnlocated);
}
示例7: write
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public void write(ByteArrayDataOutput out)
{
super.write(out);
out.writeInt(energy);
out.writeInt(currentRate);
out.writeBoolean(controllerPos != null);
if (controllerPos != null)
{
out.writeInt((int) controllerPos.x);
out.writeInt((int) controllerPos.y);
out.writeInt((int) controllerPos.z);
}
}
示例8: main
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException
{
String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
String deobfData = args[2]; //Path to FML's deobfusication_data.lzma
String outputDir = args[3]; //Path to place generated .binpatch
String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch
LogManager.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
Delta delta = new Delta();
FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
remapper.setupLoadOnly(deobfData, false);
JarFile sourceZip = new JarFile(sourceJar);
boolean kill = killTarget.equalsIgnoreCase("true");
File f = new File(outputDir);
f.mkdirs();
for (String name : remapper.getObfedClasses())
{
// Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
String fileName = name;
String jarName = name;
if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH)))
{
fileName = "_"+name;
}
File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class");
jarName = jarName+".class";
if (targetFile.exists())
{
String sourceClassName = name.replace('/', '.');
String targetClassName = remapper.map(name).replace('/', '.');
JarEntry entry = sourceZip.getJarEntry(jarName);
byte[] vanillaBytes = toByteArray(sourceZip, entry);
byte[] patchedBytes = Files.toByteArray(targetFile);
byte[] diff = delta.compute(vanillaBytes, patchedBytes);
ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50);
// Original name
diffOut.writeUTF(name);
// Source name
diffOut.writeUTF(sourceClassName);
// Target name
diffOut.writeUTF(targetClassName);
// exists at original
diffOut.writeBoolean(entry != null);
if (entry != null)
{
diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt());
}
// length of patch
diffOut.writeInt(diff.length);
// patch
diffOut.write(diff);
File target = new File(outputDir, targetClassName+".binpatch");
target.getParentFile().mkdirs();
Files.write(diffOut.toByteArray(), target);
Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath()));
if (kill)
{
targetFile.delete();
Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString()));
}
}
}
sourceZip.close();
}
示例9: main
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException
{
String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
String deobfData = args[2]; //Path to FML's deobfusication_data.lzma
String outputDir = args[3]; //Path to place generated .binpatch
String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch
LogManager.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
Delta delta = new Delta();
FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
remapper.setupLoadOnly(deobfData, false);
JarFile sourceZip = new JarFile(sourceJar);
boolean kill = killTarget.equalsIgnoreCase("true");
File f = new File(outputDir);
f.mkdirs();
for (String name : remapper.getObfedClasses())
{
// Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
String fileName = name;
String jarName = name;
if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH)))
{
fileName = "_"+name;
}
File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class");
jarName = jarName+".class";
if (targetFile.exists())
{
String sourceClassName = name.replace('/', '.');
String targetClassName = remapper.map(name).replace('/', '.');
JarEntry entry = sourceZip.getJarEntry(jarName);
byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0];
byte[] patchedBytes = Files.toByteArray(targetFile);
byte[] diff = delta.compute(vanillaBytes, patchedBytes);
ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50);
// Original name
diffOut.writeUTF(name);
// Source name
diffOut.writeUTF(sourceClassName);
// Target name
diffOut.writeUTF(targetClassName);
// exists at original
diffOut.writeBoolean(entry != null);
if (entry != null)
{
diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt());
}
// length of patch
diffOut.writeInt(diff.length);
// patch
diffOut.write(diff);
File target = new File(outputDir, targetClassName+".binpatch");
target.getParentFile().mkdirs();
Files.write(diffOut.toByteArray(), target);
Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath()));
if (kill)
{
targetFile.delete();
Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString()));
}
}
}
sourceZip.close();
}
示例10: createWDLPacket1
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Creates a byte array for the WDL control packet #1.
*
* @param globalIsEnabled
* Whether or not all of WDL is enabled.
* @param saveRadius
* The distance of chunks that WDL can download from the player's
* position.
* @param cacheChunks
* Whether or not chunks that the player previously entered but
* since exited are to be saved. If <code>false</code>, only the
* currently loaded chunks will be saved; if <code>true</code>,
* the player will download terrain as they move.
* @param saveEntities
* Whether or not entities and their appearance are to be saved.
* This includes Minecart Chest contents.
* @param saveTileEntities
* Whether or not tile entities (General ones that are reloaded
* such as signs and banners, as well as chests) are to be saved.
* If <code>false</code>, no tile entities will be saved. If
* <code>true</code>, they will be saved.)
* @param saveContainers
* Whether or not container tile entities are to be saved. If
* <code>saveTileEntities</code> is <code>false</code>, this
* value is ignored and treated as false. If this value is
* <code>false</code>, then container tile entities (ones that
* players need to open to save) will not be opened. If this
* value is <code>true</code>, then said tile entities can be
* saved by players as they are opened.
* @return The byte array used for creating that plugin channel message.
*/
public static byte[] createWDLPacket1(boolean globalIsEnabled, int saveRadius,
boolean cacheChunks, boolean saveEntities,
boolean saveTileEntities, boolean saveContainers) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(1);
output.writeBoolean(globalIsEnabled);
output.writeInt(saveRadius);
output.writeBoolean(cacheChunks && globalIsEnabled);
output.writeBoolean(saveEntities && globalIsEnabled);
output.writeBoolean(saveTileEntities && globalIsEnabled);
output.writeBoolean(saveContainers && saveTileEntities
&& globalIsEnabled);
return output.toByteArray();
}
示例11: main
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException
{
String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
String deobfData = args[2]; //Path to FML's deobfusication_data.lzma
String outputDir = args[3]; //Path to place generated .binpatch
String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch
Logger.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
Delta delta = new Delta();
FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
remapper.setupLoadOnly(deobfData, false);
JarFile sourceZip = new JarFile(sourceJar);
boolean kill = killTarget.equalsIgnoreCase("true");
File f = new File(outputDir);
f.mkdirs();
for (String name : remapper.getObfedClasses())
{
// Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
String fileName = name;
String jarName = name;
if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH)))
{
fileName = "_"+name;
}
File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class");
jarName = jarName+".class";
if (targetFile.exists())
{
String sourceClassName = name.replace('/', '.');
String targetClassName = remapper.map(name).replace('/', '.');
JarEntry entry = sourceZip.getJarEntry(jarName);
byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0];
byte[] patchedBytes = Files.toByteArray(targetFile);
byte[] diff = delta.compute(vanillaBytes, patchedBytes);
ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50);
// Original name
diffOut.writeUTF(name);
// Source name
diffOut.writeUTF(sourceClassName);
// Target name
diffOut.writeUTF(targetClassName);
// exists at original
diffOut.writeBoolean(entry != null);
if (entry != null)
{
diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt());
}
// length of patch
diffOut.writeInt(diff.length);
// patch
diffOut.write(diff);
File target = new File(outputDir, targetClassName+".binpatch");
target.getParentFile().mkdirs();
Files.write(diffOut.toByteArray(), target);
Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath()));
if (kill)
{
targetFile.delete();
Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString()));
}
}
}
sourceZip.close();
}
示例12: createWDLPacket0
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Creates a byte array for the WDL control packet #0.
*
* @param canDoNewThings
* Whether players can use new functions that aren't known to
* this plugin.
* @return
*/
public static byte[] createWDLPacket0(boolean canDoNewThings) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(0);
output.writeBoolean(canDoNewThings);
return output.toByteArray();
}
示例13: createWDLPacket3
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
/**
* Creates the WDL packet #3.
*
* This packet gives information to display when requesting permissions.
*
* The structure is a boolean (which controls whether requests are enabled,
* but <b>will always be true</b>), followed by a UTF-string to display
* to the player.
*
* @return
*/
public static byte[] createWDLPacket3(String message) {
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeInt(3);
output.writeBoolean(true);
output.writeUTF(message);
return output.toByteArray();
}