List of usage examples for com.google.common.io ByteArrayDataInput readLine
@Override String readLine();
From source file:de.bl4ckskull666.afkbukkit.AFKBukkit.java
public void sendPluginMessage(Player p) { if ((_lastFire.containsKey(p.getUniqueId()) && ((System.currentTimeMillis() - _lastFire.get(p.getUniqueId())) / 1000) < 30) && !_isAFK.contains(p.getUniqueId())) return;/*from w w w .java 2 s . c om*/ _lastFire.put(p.getUniqueId(), System.currentTimeMillis()); ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("AFKB"); out.writeUTF("Player"); out.writeUTF(p.getUniqueId().toString()); ByteArrayDataInput in = ByteStreams.newDataInput(out.toByteArray()); debugMe("Send PluginMessage with " + in.readLine()); p.sendPluginMessage(this, "BungeeCord", out.toByteArray()); }
From source file:xyz.monotalk.dropwizard.cli.ls.LsCommand.java
@Override protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception { // -------------------------------------------- // AnsiConsole.systemInstall() // ----------------- AnsiConsole.systemInstall();/*from w ww . jav a 2s . co m*/ Boolean hasLOptinon = namespace.getBoolean("l"); if (hasLOptinon == null) { hasLOptinon = false; } Set<CommandString> commandStrings = newCommandStrings(bootstrap.getCommands()); stdOut.println(); stdOut.println("available commands:"); String previousCategory = null; for (CommandString elem : commandStrings) { if (!elem.getCategory().equals(previousCategory)) { String currentCategory = elem.getCategory(); stdOut.println(); stdOut.println(ansi().fg(RED).a("[" + currentCategory + "]").reset()); previousCategory = currentCategory; } stdOut.println( INDENT_ASTAH + elem.getName() + " : " + ansi().fg(BLUE).a(elem.getDescription()).reset()); if (hasLOptinon) { ByteArrayOutputStream bosOut = new ByteArrayOutputStream(); PrintStream psOut = new PrintStream(bosOut); ByteArrayOutputStream bosErr = new ByteArrayOutputStream(); PrintStream psErr = new PrintStream(bosErr); // execute Cli#run() final Cli cli = new Cli(new JarLocation(getClass()), bootstrap, psOut, psErr); cli.run(elem.getName(), "-h"); ByteArrayDataInput input = ByteStreams.newDataInput(bosOut.toString("UTF-8").getBytes()); stdOut.println(); stdOut.println(INDENT + "======================================================:/"); String line = input.readLine(); while (line != null) { stdOut.println(INDENT + INDENT + line); line = input.readLine(); } stdOut.println(INDENT + "======================================================:/"); stdOut.println(); } } stdOut.println(); // -------------------------------------------- // AnsiConsole.systemUninstall() // ----------------- AnsiConsole.systemUninstall(); }