Esempio n. 1
0
  @Override
  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;

    StringBuilder online = new StringBuilder();

    Player[] players = Bukkit.getOnlinePlayers();

    for (Player player : players) {
      // If a player is hidden from the sender don't show them in the list
      if (sender instanceof Player && !((Player) sender).canSee(player)) continue;

      if (online.length() > 0) {
        online.append(", ");
      }

      online.append(player.getDisplayName());
    }

    sender.sendMessage(
        "There are "
            + players.length
            + "/"
            + Bukkit.getMaxPlayers()
            + " players online:\n"
            + online.toString());

    return true;
  }
  @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());
  }
  @Override
  public String getBody() {
    final StringBuilder body = new StringBuilder();

    final Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();

    body.append("<p>There are ")
        .append(onlinePlayers.size())
        .append("/")
        .append(Bukkit.getMaxPlayers())
        .append(" players online:</p>\r\n");

    body.append("<ul>\r\n");

    for (Player player : onlinePlayers) {
      String prefix = "";
      if (TFM_AdminList.isSuperAdmin(player)) {
        if (TFM_AdminList.isSeniorAdmin(player)) {
          prefix = "[SrA]";
        } else {
          prefix = "[SA]";
        }

        if (TFM_Util.DEVELOPERS.contains(player.getName())) {
          prefix = "[Dev]";
        }

        if (player.getName().equals("markbyron")) {
          prefix = "[Owner]";
        }
      } else {
        if (player.isOp()) {
          prefix = "[OP]";
        }
      }

      body.append("<li>").append(prefix).append(player.getName()).append("</li>\r\n");
    }

    body.append("</ul>\r\n");

    return body.toString();
  }
 /*    */ public String getBody() /*    */ {
   /* 19 */ StringBuilder body = new StringBuilder();
   /*    */
   /* 21 */ Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
   /*    */
   /* 23 */ body.append("<p>There are ")
       .append(onlinePlayers.size())
       .append("/")
       .append(Bukkit.getMaxPlayers())
       .append(" players online:</p>\r\n");
   /*    */
   /* 25 */ body.append("<ul>\r\n");
   /* 27 */ for (Player player : onlinePlayers)
   /*    */ {
     /* 29 */ String prefix = "";
     /* 30 */ if (TFM_AdminList.isSuperAdmin(player))
     /*    */ {
       /* 32 */ if (TFM_AdminList.isSeniorAdmin(player)) {
         /* 34 */ prefix = "[SrA]";
         /*    */ } else {
         /* 38 */ prefix = "[SA]";
         /*    */ }
       /* 41 */ if (TFM_Util.DEVELOPERS.contains(player.getName())) {
         /* 43 */ prefix = "[Dev]";
         /*    */ }
       /* 46 */ if (player.getName().equals("markbyron")) {
         /* 48 */ prefix = "[Owner]";
         /*    */ }
       /*    */ }
     /* 53 */ else if (player.isOp())
     /*    */ {
       /* 55 */ prefix = "[OP]";
       /*    */ }
     /* 59 */ body.append("<li>").append(prefix).append(player.getName()).append("</li>\r\n");
     /*    */ }
   /* 62 */ body.append("</ul>\r\n");
   /*    */
   /* 64 */ return body.toString();
   /*    */ }
Esempio n. 5
0
  @EventHandler
  public void on(PlayerJoinEvent e) {

    final Player p = e.getPlayer();

    Tablist tab = new Tablist();
    tab.setFooter("§3OreBattle v1.0");
    tab.setHeader("§a" + Bukkit.getServerName());
    tab.send(p);

    if (Devathlon.Status == GameStatus.Lobby) {

      /*TagManager tm = new TagManager(p);
      tm.changeTag(tm.getTagByPermissions());
      tm.setTag();*/

      e.setJoinMessage(
          "§7> "
              + p.getDisplayName()
              + " §3hat das Spiel betreten. ("
              + Bukkit.getOnlinePlayers().size()
              + "/"
              + Bukkit.getMaxPlayers()
              + ")");

      if (Bukkit.getOnlinePlayers().size() == 5 && Devathlon.Timer > 10) {
        Devathlon.Timer = 10;
      }

      clearupperson(p);
      createPlayerStats(p);

      p.getInventory()
          .setItem(
              0, createItemstack(Material.COMPASS, "§9Teamauswahl §7<Rechtsklick>", 1, (byte) 0));
      p.getInventory()
          .setItem(
              8,
              createItemstack(
                  Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0));
      if (Devathlon.sql == true) {
        p.getInventory()
            .setItem(
                4,
                createItemstack(Material.NETHER_STAR, "§9Kitauswahl §7<Rechtsklick>", 1, (byte) 0));
      }

      p.getInventory().setHeldItemSlot(0);
      p.teleport(OreBattle_Command.getLocation("Lobby", true));
      p.sendMessage(Devathlon.prefix + "§3Willkommen bei OreBattle v1.0");

    } else {

      e.setJoinMessage("");

      p.getInventory().clear();
      p.getInventory()
          .setItem(
              0,
              createItemstack(Material.REDSTONE_BLOCK, "§cTeam Rot §7<Rechtsklick>", 1, (byte) 0));
      p.getInventory()
          .setItem(
              1, createItemstack(Material.LAPIS_BLOCK, "§9Team Blau §7<Rechtsklick>", 1, (byte) 0));
      p.getInventory()
          .setItem(
              8,
              createItemstack(
                  Material.SLIME_BALL, "§9Zurück zur Lobby §7<Rechtsklick>", 1, (byte) 0));

      TagManager tm = new TagManager(p);
      tm.changeTag("7");
      tm.setTag();
      p.setPlayerListName("§7[§cX§7] §8| §7" + p.getName());
      p.setDisplayName("§7[§cX§7] " + p.getName());

      Global.spectator.add(p);

      for (Player all : Bukkit.getOnlinePlayers()) {
        all.hidePlayer(p);
        for (Player spec : Global.spectator) {
          spec.showPlayer(p);
          p.showPlayer(spec);
        }
      }

      p.setAllowFlight(true);
      p.setFlying(true);
      p.sendMessage(Devathlon.prefix + "§3Du bist jetzt Spectator.");
      p.teleport(OreBattle_Command.getLocation("Spectator", true));
    }
  }
Esempio n. 6
0
 private void loadConfig() {
   FileConfiguration conf = getConfig();
   limitStoringStatusOnMemory = conf.getInt("limitStoringStatusOnMemory", Bukkit.getMaxPlayers());
 }