当前位置: 首页>>代码示例>>Java>>正文


Java PacketBuffer.readString方法代码示例

本文整理汇总了Java中io.gomint.jraknet.PacketBuffer.readString方法的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer.readString方法的具体用法?Java PacketBuffer.readString怎么用?Java PacketBuffer.readString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.gomint.jraknet.PacketBuffer的用法示例。


在下文中一共展示了PacketBuffer.readString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.type = Type.getById( buffer.readByte() );
    buffer.readBoolean();
    switch ( this.type ) {
        case CLIENT_MESSAGE:
        case TIP_MESSAGE:
        case SYSTEM_MESSAGE:
            this.message = buffer.readString();
            break;

        case PLAYER_CHAT:
            this.sender = buffer.readString();
            this.message = buffer.readString();
            this.xuid = buffer.readString();
            break;

        case LOCALIZABLE_MESSAGE:
            this.message = buffer.readString();
            byte count = buffer.readByte();
            this.arguments = new String[count];
            for ( byte i = 0; i < count; ++i ) {
                this.arguments[i] = buffer.readString();
            }

            break;

        case POPUP_NOTICE:
            this.message = buffer.readString();
            this.sender = buffer.readString();
            break;
    }
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:34,代码来源:PacketText.java

示例2: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.entityId = buffer.readUnsignedVarLong();
    int amountOfAttributes = buffer.readUnsignedVarInt();
    for ( int i = 0; i < amountOfAttributes; i++ ) {
        float minValue = buffer.readLFloat();
        float maxValue = buffer.readLFloat();
        float value = buffer.readLFloat();
        float defaultValue = buffer.readLFloat();
        String key = buffer.readString();

        System.out.println( key + ": min(" + minValue + ") max(" + maxValue + ") value(" + value + ") default(" + defaultValue + ")");
    }
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:15,代码来源:PacketUpdateAttributes.java

示例3: readItemStack

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
/**
 * Read a item stack from the packet buffer
 *
 * @param buffer from the packet
 * @return read item stack
 */
static ItemStack readItemStack( PacketBuffer buffer ) {
    int id = buffer.readSignedVarInt();
    if ( id == 0 ) {
        return ItemAir.create( 0 );
    }

    int temp = buffer.readSignedVarInt();
    byte amount = (byte) ( temp & 0xFF );
    short data = (short) ( temp >> 8 );

    NBTTagCompound nbt = null;
    short extraLen = buffer.readLShort();
    if ( extraLen > 0 ) {
        ByteArrayInputStream bin = new ByteArrayInputStream( buffer.getBuffer(), buffer.getPosition(), extraLen );
        try {
            NBTReader nbtReader = new NBTReader( bin, ByteOrder.LITTLE_ENDIAN );
            // nbtReader.setUseVarint( true );
            nbt = nbtReader.parse();
        } catch ( IOException e ) {
            e.printStackTrace();
        }

        buffer.skip( extraLen );
    }

    // They implemented additional data for item stacks aside from nbt
    int countPlacedOn = buffer.readSignedVarInt();
    for ( int i = 0; i < countPlacedOn; i++ ) {
        buffer.readString();    // TODO: Implement proper support once we know the string values
    }

    int countCanBreak = buffer.readSignedVarInt();
    for ( int i = 0; i < countCanBreak; i++ ) {
        buffer.readString();    // TODO: Implement proper support once we know the string values
    }

    return Items.create( id, data, amount, nbt );
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:45,代码来源:Packet.java

示例4: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.commands = buffer.readString();
    this.unknown = buffer.readString();

    /*LOGGER.debug( "Commands: " );
    LOGGER.debug( this.commands );
    LOGGER.debug( "Unknown: " );
    LOGGER.debug( this.unknown );*/
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:11,代码来源:PacketAvailableCommands.java

示例5: readGamerules

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
public Map<Gamerule, Object> readGamerules( PacketBuffer buffer ) {
	int amount = buffer.readUnsignedVarInt();
	if ( amount == 0 ) {
		return null;
	}

	Map<Gamerule, Object> gamerules = new HashMap<>();
	for ( int i = 0; i < amount; i++ ) {
		String name = buffer.readString();
		byte type = buffer.readByte();

		Object val = null;
		switch ( type ) {
			case 1:
				val = buffer.readBoolean();
				break;
			case 2:
				val = buffer.readUnsignedVarInt();
				break;
			case 3:
				val = buffer.readLFloat();
				break;
		}

		System.out.println( name + " -> " + String.valueOf( val ) );
	}

	return gamerules;
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:30,代码来源:Packet.java

示例6: readItemStack

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
public static ItemStack readItemStack( PacketBuffer buffer ) {
	int id = buffer.readSignedVarInt();
	if ( id == 0 ) {
		return new ItemStack( Material.AIR, (short) 0, 0, null );
	}

	int temp = buffer.readSignedVarInt();
	byte amount = (byte) ( temp & 0xFF );
	short data = (short) ( temp >> 8 );

	NBTTagCompound nbt = null;
	short extraLen = buffer.readLShort();
	if ( extraLen > 0 ) {
		ByteArrayInputStream bin = new ByteArrayInputStream( buffer.getBuffer(), buffer.getPosition(), extraLen );
		try {
			nbt = NBTTagCompound.readFrom( bin, false, ByteOrder.LITTLE_ENDIAN );
		} catch ( IOException e ) {
			e.printStackTrace();
		}

		buffer.skip( extraLen );
	}

	// They implemented additional data for item stacks aside from nbt
	int countPlacedOn = buffer.readSignedVarInt();
	for ( int i = 0; i < countPlacedOn; i++ ) {
		buffer.readString();    // TODO: Implement proper support once we know the string values
	}

	int countCanBreak = buffer.readSignedVarInt();
	for ( int i = 0; i < countCanBreak; i++ ) {
		buffer.readString();    // TODO: Implement proper support once we know the string values
	}

	return new ItemStack( EnumConnectors.MATERIAL_CONNECTOR.revert( MaterialMagicNumbers.valueOfWithId( id ) ), data, amount, nbt );
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:37,代码来源:Packet.java

示例7: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.commandName = buffer.readString();
    this.overloadName = buffer.readString();

    this.unknown1 = buffer.readUnsignedVarInt();
    this.unknown2 = buffer.readUnsignedVarInt();

    this.hasOutput = buffer.readBoolean();

    System.out.println( this.unknown1 );
    System.out.println( this.unknown2 );
    System.out.println( this.hasOutput );

    this.clientGuid = buffer.readUnsignedVarLong();

    this.input = buffer.readString();
    this.output = buffer.readString();

    System.out.println( "GUID: " + this.clientGuid );
    System.out.println( "Commandname: " + this.commandName );
    System.out.println( "Overloadname: " + this.overloadName );
    System.out.println( "Input: " + this.input );
    System.out.println( "Output: " + this.output );

    // String next?

    this.data = new byte[buffer.getRemaining()];
    buffer.readBytes( this.data );

    System.out.println( Util.toHexString( this.data ) );
    System.out.println( new String( this.data ) );
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:34,代码来源:PacketCommandStep.java

示例8: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    // I only care for the entity id long
    this.uuid = buffer.readUUID();
    this.name = buffer.readString();
    this.entityId = buffer.readSignedVarLong().longValue();
    buffer.readUnsignedVarLong();

    this.data = new byte[buffer.getRemaining()];
    buffer.readBytes( this.data );
}
 
开发者ID:GoMint,项目名称:ProxProx,代码行数:12,代码来源:PacketAddPlayer.java

示例9: readItemStack

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
/**
 * Read a item stack from the packet buffer
 *
 * @param buffer from the packet
 * @return read item stack
 */
public ItemStack readItemStack( PacketBuffer buffer ) {
	int id = buffer.readSignedVarInt();
	if ( id == 0 ) {
		return new ItemStack( 0, (short) 0, 0 );
	}

	int temp = buffer.readSignedVarInt();
	byte amount = (byte) ( temp & 0xFF );
	short data = (short) ( temp >> 8 );

	NBTTagCompound nbt = null;
	short extraLen = buffer.readLShort();
	if ( extraLen > 0 ) {
		ByteArrayInputStream bin = new ByteArrayInputStream( buffer.getBuffer(), buffer.getPosition(), extraLen );
		try {
			NBTReader nbtReader = new NBTReader( bin, ByteOrder.LITTLE_ENDIAN );
			// nbtReader.setUseVarint( true );
			nbt = nbtReader.parse();
		} catch ( IOException e ) {
			e.printStackTrace();
		}

		buffer.skip( extraLen );
	}

	// They implemented additional data for item stacks aside from nbt
	int countPlacedOn = buffer.readSignedVarInt();
	for ( int i = 0; i < countPlacedOn; i++ ) {
		buffer.readString();    // TODO: Implement proper support once we know the string values
	}

	int countCanBreak = buffer.readSignedVarInt();
	for ( int i = 0; i < countCanBreak; i++ ) {
		buffer.readString();    // TODO: Implement proper support once we know the string values
	}

	return new ItemStack( id, data, amount, nbt );
}
 
开发者ID:GoMint,项目名称:ProxProx,代码行数:45,代码来源:Packet.java

示例10: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
void deserialize( PacketBuffer buffer ) {
    this.value = buffer.readString();
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:5,代码来源:MetadataString.java

示例11: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.address = buffer.readString();
    this.port = buffer.readLShort();
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:6,代码来源:PacketTransfer.java

示例12: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.inputCommand = buffer.readString();
    this.commandOrigin = readCommandOrigin( buffer );
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:6,代码来源:PacketCommandRequest.java

示例13: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.jwt = buffer.readString();
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:5,代码来源:PacketEncryptionRequest.java

示例14: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
	this.jwtData = buffer.readString();
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:5,代码来源:PacketServerHandshake.java

示例15: deserialize

import io.gomint.jraknet.PacketBuffer; //导入方法依赖的package包/类
@Override
public void deserialize( PacketBuffer buffer ) {
    this.entityId = buffer.readSignedVarLong().longValue();
    this.runtimeEntityId = buffer.readUnsignedVarLong();
    this.gamemode = buffer.readSignedVarInt();

    this.spawn = new Location( buffer.readLFloat(), buffer.readLFloat(), buffer.readLFloat(), buffer.readLFloat(), buffer.readLFloat() );
    this.seed = buffer.readSignedVarInt();
    this.dimension = buffer.readSignedVarInt();
    this.generator = buffer.readSignedVarInt();
    this.worldGamemode = buffer.readSignedVarInt();
    this.difficulty = buffer.readSignedVarInt();

    buffer.readSignedVarInt();
    buffer.readSignedVarInt();
    buffer.readSignedVarInt();

    this.hasAchievementsDisabled = buffer.readBoolean();
    this.dayCycleStopTime = buffer.readSignedVarInt();
    this.eduMode = buffer.readBoolean();
    this.rainLevel = buffer.readLFloat();
    this.lightningLevel = buffer.readLFloat();
    this.isMultiplayerGame = buffer.readBoolean();
    this.hasLANBroadcast = buffer.readBoolean();
    this.hasXboxLiveBroadcast = buffer.readBoolean();
    this.commandsEnabled = buffer.readBoolean();
    this.isTexturePacksRequired = buffer.readBoolean();
    this.gamerules = readGamerules( buffer );
    this.hasBonusChestEnabled = buffer.readBoolean();
    this.hasStartWithMapEnabled = buffer.readBoolean();
    this.hasTrustPlayersEnabled = buffer.readBoolean();

    this.defaultPlayerPermission = buffer.readSignedVarInt();
    this.xboxLiveBroadcastMode = buffer.readSignedVarInt();

    this.levelId = buffer.readString();
    this.worldName = buffer.readString();
    this.templateName = buffer.readString();
    this.unknown1 = buffer.readBoolean();
    this.currentTick = buffer.readLLong();
    this.enchantmentSeed = buffer.readSignedVarInt();

    System.out.println( this );
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:45,代码来源:PacketStartGame.java


注:本文中的io.gomint.jraknet.PacketBuffer.readString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。