本文整理匯總了Java中com.google.common.io.ByteArrayDataInput.readUTF方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataInput.readUTF方法的具體用法?Java ByteArrayDataInput.readUTF怎麽用?Java ByteArrayDataInput.readUTF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteArrayDataInput
的用法示例。
在下文中一共展示了ByteArrayDataInput.readUTF方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("SkyWarsReloadedRequest")) {
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
Game game = gc.getGame(1);
if (game != null) {
BungeeUtil.sendSignUpdateRequest(game);
} else {
System.out.println("Game " + game + " couldn't be found, please fix your setup.");
}
}
}
示例2: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
final ByteArrayDataInput in = ByteStreams.newDataInput(message);
final String type = in.readUTF();
if (type.equals("ServerIP")) {
final String serverName = in.readUTF();
final String ip = in.readUTF();
final short port = in.readShort();
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, () -> {
final String data = BungeeCordProvider.this.receiveResultFromServer(serverName, ip, port);
BungeeCordProvider.this.parseData(serverName, data);
});
}
}
示例3: onPluginMessage
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@EventHandler
public void onPluginMessage(PluginMessageEvent e) {
if (!e.getTag().equals(CHANNEL)) {
return;
}
e.setCancelled(true);
if (e.getSender() instanceof ProxiedPlayer) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
String msg = in.readUTF();
onMessage(msg, u -> {
// Forward to other servers
this.plugin.getScheduler().doAsync(() -> sendMessage(u));
});
}
示例4: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
if (channel.equals(incomingChannel)) {
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("AutoLogin")) {
Player player = Bukkit.getPlayer(in.readUTF());
if (player != null) {
if (!xauth.getPlayerManager().getPlayer(player.getName()).isAuthenticated()) {
xauth.getPlayerManager().doLogin(xauth.getPlayerManager().getPlayer(player));
if (!autoLoginMessage.isEmpty())
player.sendMessage(autoLoginMessage);
}
}
}
}
}
示例5: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void onPluginMessageReceived(String channel, Player p, byte[] message) {
if (channel.equals(incomingChannel)) {
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("AutoLogin")) {
Player player = Bukkit.getPlayer(in.readUTF());
if (player != null) {
if (!fr.xephi.authme.api.NewAPI.getInstance().isAuthenticated(player)) {
fr.xephi.authme.api.NewAPI.getInstance().forceLogin(player);
if (!autoLoginMessage.isEmpty())
player.sendMessage(autoLoginMessage);
}
}
}
}
}
示例6: readPermissionRequest
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* Reads a permission request.
*/
public static PermissionRequest readPermissionRequest(
Player player, byte[] data) {
ByteArrayDataInput input = ByteStreams.newDataInput(data);
String requestReason = input.readUTF();
Map<String, String> requestedPerms = new HashMap<>();
int numRequests = input.readInt();
for (int i = 0; i < numRequests; i++) {
String key = input.readUTF();
String value = input.readUTF();
requestedPerms.put(key, value);
}
List<ProtectionRange> rangeRequests = new ArrayList<>();
int numRangeRequests = input.readInt();
for (int i = 0; i < numRangeRequests; i++) {
rangeRequests.add(readProtectionRange(input));
}
return new PermissionRequest(player, requestReason, requestedPerms,
rangeRequests);
}
示例7: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
/**
* Calls when the plugin received a message from a bungee-server
*/
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if(!channel.equals(Main.BUNGEE_CHANNEL_NAME)) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals(Subchannel.UPDATE_RECEIVE)) {
String game = in.readUTF();
String serverName = in.readUTF();
String firstLine = in.readUTF();
String secondLine = in.readUTF();
String thirdLine = in.readUTF();
String fourthLine = in.readUTF();
SignUpdateInformation info = new SignUpdateInformation(firstLine, secondLine, thirdLine, fourthLine);
this.signManager.updateJoinSign(game, serverName, info);
}
}
示例8: read
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void read(ByteArrayDataInput in) throws ProtocolException
{
// ------
// CLIENT
// ------
particleName = in.readUTF();
particlePosX = in.readDouble();
particlePosY = in.readDouble();
particlePosZ = in.readDouble();
velX = in.readDouble();
velY = in.readDouble();
velZ = in.readDouble();
}
示例9: handleNetworkMessage
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void handleNetworkMessage(NetHandler source, boolean isClient, ByteArrayDataInput data) {
if (isClient) return;
int x = data.readInt();
int y = data.readInt();
int z = data.readInt();
String sound = data.readUTF();
World world = MiscPeripherals.proxy.getClientWorld();
for (int i = 0; i < 50; i++) {
MiscPeripherals.proxy.spawnSmoke(x + 0.5D + world.rand.nextFloat() - world.rand.nextFloat(), y + world.rand.nextFloat() - world.rand.nextFloat(), z + 0.5D + world.rand.nextFloat() - world.rand.nextFloat(), 0.0D, 0.0D, 0.0D);
}
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, sound, 0.8F, world.rand.nextFloat() * 0.2F + 0.9F);
}
示例10: read
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void read(ByteArrayDataInput in)
{
super.read(in);
orientation = in.readInt();
validMultiblock = in.readBoolean();
selectedModule = in.readUTF();
selectedChipset = in.readUTF();
armorId = in.readInt();
progressing = in.readBoolean();
progress = in.readInt();
if (in.readBoolean())
{
energyPos = new Vector3(in.readInt(), in.readInt(), in.readInt());
}
}
示例11: readPatch
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
private ClassPatch readPatch(JarEntry entry, JarInputStream jis){
ByteArrayDataInput input;
try{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}catch(IOException e){
logger.warn("Unable to read binpatch file {}. Ignoring it", entry.getName());
return null;
}
String name = input.readUTF();
String sourceName = input.readUTF();
String targetName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = exists ? input.readInt() : 0;
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceName, targetName, exists, inputChecksum, patchBytes);
}
示例12: consumePacket
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public FMLPacket consumePacket(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
int versionListSize = dat.readInt();
modVersions = Maps.newHashMapWithExpectedSize(versionListSize);
for (int i = 0; i < versionListSize; i++)
{
String modName = dat.readUTF();
String modVersion = dat.readUTF();
modVersions.put(modName, modVersion);
}
int missingModSize = dat.readInt();
missingMods = Lists.newArrayListWithExpectedSize(missingModSize);
for (int i = 0; i < missingModSize; i++)
{
missingMods.add(dat.readUTF());
}
return this;
}
示例13: accept
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public boolean accept(Player receiver, ByteArrayDataInput in) {
String ip = in.readUTF();
int port = in.readInt();
callback.accept(Maps.immutableEntry(ip, port));
return true;
}
示例14: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals(CHANNEL_BUNGEE)) return;
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (!subchannel.equals(GET_SERVERS)) return;
this.plugin.setServers(in.readUTF().split(", "));
}
示例15: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals(BungeeSayNoToMcLeaks.CHANNEL)) return;
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals(BungeeSayNoToMcLeaks.SUBCHANNEL)) {
final String name = in.readUTF();
final boolean result = in.readBoolean();
// S'il est déjà connu
if (this.caches.getIfPresent(name) != null) return;
this.caches.put(name, result);
// Si les 2 IP correspondent
if (result) {
this.plugin.debug("The player " + name + " doesn't use alt account.");
// Les 2 IP ne correspondent pas
} else {
// Si le joueur est déjà connecté
if (this.plugin.getServer().getPlayer(name) != null) {
this.executeCommands(name, 100);
}
}
}
}