Exemplo n.º 1
0
 /**
  * Gets the channel mode. If mode is simple (no arguments), this will return immediately. If its
  * not (mode with arguments, eg channel key), then asks the server for the correct mode, waiting
  * until it gets a response
  *
  * <p><b>WARNING:</b> Because of the last checking, a threaded listener manager like {@link
  * ThreadedListenerManager} is required. Using a single threaded listener manager like {@link
  * GenericListenerManager} will mean this method <i>never returns</i>!
  *
  * @return A known good mode, either immediatly or soon.
  */
 public String getMode() {
   if (!modeStale) return mode;
   // Mode is stale, get new mode from server
   try {
     bot.sendRawLine("MODE " + getName());
     if (modeLatch == null || modeLatch.getCount() == 0) modeLatch = new CountDownLatch(1);
     // Wait for setMode to be called
     modeLatch.await();
     // Mode is no longer stale since we have a good mode
     modeStale = false;
     // We have known good mode from server, now return
     return mode;
   } catch (InterruptedException e) {
     // bot.logException(e);
     throw new RuntimeException("Waiting for mode response interrupted", e);
   }
 }