示例#1
0
 /**
  * Converts the components to a string that uses the old formatting codes ({@link
  * net.md_5.bungee.api.ChatColor#COLOR_CHAR}
  *
  * @param components the components to convert
  * @return the string in the old format
  */
 public static String toLegacyText(BaseComponent... components) {
   StringBuilder builder = new StringBuilder();
   for (BaseComponent msg : components) {
     builder.append(msg.toLegacyText());
   }
   return builder.toString();
 }
示例#2
0
 void toLegacyText(StringBuilder builder) {
   if (extra != null) {
     for (BaseComponent e : extra) {
       e.toLegacyText(builder);
     }
   }
 }
示例#3
0
 public synchronized void disconnect0(BaseComponent... reason) {
   if (ch.getHandle().isActive()) {
     bungee
         .getLogger()
         .log(
             Level.INFO,
             "[" + getName() + "] disconnected with: " + BaseComponent.toLegacyText(reason));
     unsafe().sendPacket(new Kick(ComponentSerializer.toString(reason)));
     ch.close();
     if (server != null) {
       server.disconnect("Quitting");
     }
   }
 }
示例#4
0
  public void disconnect0(final BaseComponent... reason) {
    if (!ch.isClosed()) {
      bungee
          .getLogger()
          .log(
              Level.INFO,
              "[{0}] disconnected with: {1}",
              new Object[] {getName(), BaseComponent.toLegacyText(reason)});

      // Why do we have to delay this you might ask? Well the simple reason is MOJANG.
      // Despite many a bug report posted, ever since the 1.7 protocol rewrite, the client STILL has
      // a race condition upon switching protocols.
      // As such, despite the protocol switch packets already having been sent, there is the
      // possibility of a client side exception
      // To help combat this we will wait half a second before actually sending the disconnected
      // packet so that whoever is on the other
      // end has a somewhat better chance of receiving the proper packet.
      ch.getHandle()
          .eventLoop()
          .schedule(
              new Runnable() {

                @Override
                public void run() {
                  unsafe().sendPacket(new Kick(ComponentSerializer.toString(reason)));
                  ch.close();
                }
              },
              500,
              TimeUnit.MILLISECONDS);

      if (server != null) {
        server.disconnect("Quitting");
      }
    }
  }
示例#5
0
 /**
  * Converts the component to a string that uses the old formatting codes ({@link
  * net.md_5.bungee.api.ChatColor#COLOR_CHAR}
  *
  * @return the string in the old format
  */
 public String toLegacyText() {
   StringBuilder builder = new StringBuilder();
   toLegacyText(builder);
   return builder.toString();
 }