All pastes #624750 Raw Edit

Miscellany

public java v1 · immutable
·published 2007-07-18 14:27 UTC
rendered paste body
....    public void sendMessage( int color, int effect, String text ) {        try {            ByteBuffer buffer = ByteBuffer.allocateDirect( 3 + text.length() );            buffer.put( ( byte ) ( 4 + encryption.getNextKey() ) );            buffer.put( ( byte ) ( 128 - color ) );            buffer.put( ( byte ) ( 128 - effect ) );            for ( int i = text.length() - 1; i >= 0; i-- )                buffer.put( ( byte ) text.charAt( i ) );            buffer.flip();            channel.write( buffer );        } catch ( IOException e ) {            System.err.println( "Error at '" + name + "':  " + e.getMessage() );        }    }    public void sendCommand( String command ) {        try {            ByteBuffer buffer = ByteBuffer.allocateDirect( 2 + command.length() );            buffer.put( ( byte ) ( 103 + encryption.getNextKey() ) );            buffer.put( ( byte ) ( command.length() - 1 ) ).put( command.getBytes() );            buffer.flip();            channel.write( buffer );        } catch ( IOException e ) {            System.err.println( "Error at '" + name + "':  " + e.getMessage() );        }    }....