Ejemplo n.º 1
0
  public static boolean sendTitle(
      Player player, int ticksIn, int ticksStay, int ticksOut, String titleMain, String titleSub) {
    if (!get().isAvailable()) return false;

    try {
      // Fadein, stay, fadeout
      Object timesPacket =
          titlePacketConstructorTimes.newInstance(
              titleTimesEnum, null, ticksIn, ticksStay, ticksOut);
      sendPacket(player, timesPacket);

      if (titleMain != null) {
        // Title
        Object titleMainChat = toChatBaseComponent(titleMain);
        Object titleMainPacket = titlePacketConstructor.newInstance(titleMainEnum, titleMainChat);
        sendPacket(player, titleMainPacket);
      }

      if (titleSub != null) {
        // SubTitle
        Object titleSubChat = toChatBaseComponent(titleSub);
        Object titleSubPacket = titlePacketConstructor.newInstance(titleSubEnum, titleSubChat);
        sendPacket(player, titleSubPacket);
      }

    } catch (Exception ex) {
      MassiveCore.get().log(Txt.parse("<b>Sending title failed!"));
      ex.printStackTrace();
      // So we failed, didn't work.
      return false;
    }

    // It worked.
    return true;
  }
Ejemplo n.º 2
0
 public static void updateSoon(final HumanEntity human) {
   Bukkit.getScheduler()
       .scheduleSyncDelayedTask(
           MassiveCore.get(),
           new Runnable() {
             @Override
             public void run() {
               update(human);
             }
           });
 }
Ejemplo n.º 3
0
  public static boolean sendActionbar(Player player, String string) {
    if (!get().isAvailable()) return false;

    try {
      Object actionbar = toChatBaseComponent(string);
      Object chatPacket = chatPacketActionbarConstructor.newInstance(actionbar, (byte) 2);

      sendPacket(player, chatPacket);
    } catch (Exception ex) {
      MassiveCore.get().log(Txt.parse("<b>Sending actionbar failed!"));
      ex.printStackTrace();
      // So we failed and it didn't work.
      return false;
    }

    return true;
  }