コード例 #1
1
  @EventHandler
  public static void onPing(ServerListPingEvent event) {

    if (ServerMode.mode.contains("Online")) {

      event.setMotd(
          ChatColor.GRAY
              + ""
              + ChatColor.STRIKETHROUGH
              + "----------["
              + ChatColor.RED
              + "Rusty"
              + ChatColor.GRAY
              + "Craft"
              + ChatColor.GRAY
              + ChatColor.STRIKETHROUGH
              + "]----------"
              + "\n"
              + ChatColor.GREEN
              + "Were Online, come join us!");
    }

    if (ServerMode.mode.contains("Maintenance")) {

      event.setMotd(
          ChatColor.GRAY
              + ""
              + ChatColor.STRIKETHROUGH
              + "----------["
              + ChatColor.RED
              + "Rusty"
              + ChatColor.GRAY
              + "Craft"
              + ChatColor.GRAY
              + ChatColor.STRIKETHROUGH
              + "]----------"
              + "\n"
              + ChatColor.RED
              + "Maintencance Mode, try again later.");
    }
  }
コード例 #2
1
ファイル: ServerManager.java プロジェクト: kodyhusky/KodyMC
 @EventHandler
 public void onServerPing(ServerListPingEvent event) {
   if (plugin.getConfigMan().randomIconEnabled()) {
     try {
       event.setServerIcon(Bukkit.loadServerIcon(plugin.getConfigMan().getServerIcon()));
     } catch (Exception ex) {
       plugin.getLogger().warning("An error occurred applying a server icon!");
       plugin.getLogger().warning(ex.getLocalizedMessage());
     }
   }
   if (plugin.getConfigMan().randomMOTDEnabled()) {
     event.setMotd(plugin.getConfigMan().getServerMOTD());
   }
 }
コード例 #3
1
  @EventHandler
  public void onPingServList(ServerListPingEvent e) {
    if (this.pl.aguardando) {
      // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §6§oAguardando os jogadores \n§a§o Entre em nosso
      // site: (Em breve)");

      e.setMotd("§a[Entrar]");
    }
    if (this.pl.comecando) {
      int millis = this.pl.startingCounter * 1000;
      SimpleDateFormat df = new SimpleDateFormat("m:ss");
      String time = df.format(Integer.valueOf(millis));
      // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §6§oPartida inicia em: " + time + "\n§a§oEntre em
      // nosso site: (Em breve)");
      e.setMotd("§a[Entrar]");
    }
    if ((this.pl.invencibilidade) && (Join.getOnlinePlayers() == 0)) {
      // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em nosso
      // site: (Em breve)");
      Bukkit.getServer().shutdown();

      e.setMotd("§c[Reiniciando]");
    }

    if ((this.pl.comecou) && (Join.getOnlinePlayers() == 0)) {
      // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em nosso
      // site: (Em breve)");
      Bukkit.getServer().shutdown();
      e.setMotd("§c[Reiniciando]");
    }
    if (this.pl.invencibilidade) {
      int millis = this.pl.invicCounter * 1000;
      SimpleDateFormat df = new SimpleDateFormat("m:ss");
      String time = df.format(Integer.valueOf(millis));
      // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §6§oInvencibilidade acaba em: " + time + "\n§a§o
      // Entre em nosso site: (Em breve)");
      e.setMaxPlayers(Integer.valueOf(this.pl.vivos.size()));
      e.setMotd("§5[Em Jogo]");
    }
    if (this.pl.comecou) {
      int millis = this.pl.partidaCounter * 1000;
      SimpleDateFormat df = new SimpleDateFormat("m:ss");
      String time = df.format(Integer.valueOf(millis));
      // e.setMotd("§a§l §b§o§lCooler - HG §a§l « §c§oJogo em progresso: " + time + "\n§a§o Entre em
      // nosso site: (Em breve)");
      e.setMaxPlayers(Integer.valueOf(this.pl.vivos.size()));
      e.setMotd("§5[Em Jogo]");
    }
    if (this.pl.acabou) {
      // e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em nosso
      // site: (Em breve)");
      e.setMaxPlayers(Integer.valueOf(this.pl.vivos.size()));
      e.setMotd("§c[Reiniciando]");
    }
    if ((this.pl.acabou) && (Join.getOnlinePlayers() == 0)) {
      //    e.setMotd("§a§l» §b§o§lCooler - HG §a§l « §c§oServidor vai reiniciar \n§a§o Entre em
      // nosso site: (Em breve)");
      Bukkit.getServer().shutdown();
      e.setMotd("§c[Reiniciando]");
    }
  }
コード例 #4
0
ファイル: PingEvent.java プロジェクト: GloryCraft/Rush
 @EventHandler(priority = EventPriority.HIGH)
 public void onPingEvent(ServerListPingEvent event) {
   if (plugin.status.equals(Main.etat.INGAME)) {
     event.setMotd(ChatColor.RED + "En jeux");
   }
   if (plugin.status.equals(Main.etat.WAITING)) {
     event.setMotd(ChatColor.GREEN + "Disponible - Attente");
   }
   if (plugin.status.equals(Main.etat.TIMER)) {
     event.setMotd(ChatColor.YELLOW + "Début :" + this.plugin.timeleft);
   }
   event.setMaxPlayers(plugin.getConfig().getInt("game.maxPlayerByTeam") * plugin.Team.size());
 }
コード例 #5
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onServerPing(ServerListPingEvent event) {
    final String ip = event.getAddress().getHostAddress();

    if (TFM_BanManager.isIpBanned(ip)) {
      event.setMotd(ChatColor.RED + TFM_Util.getPlayerFromIp(ip) + ", you are banned.");
      return;
    }

    if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) {
      event.setMotd(ChatColor.RED + "KrazyOP is currently closed.");
      return;
    }

    if (TFM_ConfigEntry.TRAINING_SESSION.getBoolean()) {
      event.setMotd(ChatColor.RED + "KrazyOP is currently in a training session.");
      return;
    }

    if (Bukkit.hasWhitelist()) {
      event.setMotd(ChatColor.RED + "Whitelist is currently enabled.");
      return;
    }

    if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers()) {
      event.setMotd(ChatColor.RED + "KrazyOP is currently full.");
      return;
    }

    // Colorful MOTD
    String message =
        String.format(
            "Welcome to "
                + TFM_Util.randomChatColor()
                + TFM_ConfigEntry.SERVER_NAME.getString()
                + TFM_Util.randomChatColor()
                + "%s"
                + TFM_Util.randomChatColor()
                + "!"
                + TFM_Util.randomChatColor()
                + " - Fun, Free and Easy! \nRunning on Spigot for Minecraft 1.8.7!",
            TFM_Util.getPlayerFromIp(ip));

    final StringBuilder motd = new StringBuilder();

    for (String word : message.split(" ")) {
      motd.append(TFM_Util.randomChatColor()).append(word).append(" ");
    }

    event.setMotd(motd.toString());
  }
コード例 #6
0
 // Check ServerListPingEvent for the purpose of auto-updating the ServerMOTD.
 @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
 public void onServerPing(ServerListPingEvent event) {
   event.setMotd(MessageManager.getServerMOTDMessage());
 }
コード例 #7
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onServerListPing(final ServerListPingEvent event) {
   final String message = this.trimMessage(this.messageList.getMOTD());
   event.setMotd(message);
 }