Пример #1
0
public class Players implements CommandExecutor {
  private Hungergames hg = HungergamesApi.getHungergames();
  private ChatManager cm = HungergamesApi.getChatManager();
  private PlayerManager pm = HungergamesApi.getPlayerManager();

  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    List<Gamer> gamers = pm.getAliveGamers();
    ArrayList<String> gamerNames = new ArrayList<String>();
    for (Gamer game : gamers) gamerNames.add(game.getPlayer().getDisplayName());
    Collections.sort(gamerNames);
    String gamersName = "No gamers";
    if (gamerNames.size() > 0)
      gamersName = StringUtils.join(gamerNames, ChatColor.GRAY + ", " + ChatColor.GRAY);
    sender.sendMessage(
        String.format(
            cm.getCommandPlayers(),
            gamers.size(),
            (pm.getGamers().size() - gamers.size()),
            gamersName));
    if (hg.currentTime >= 0)
      sender.sendMessage(
          String.format(cm.getCommandPlayersTimeStatusStarted(), hg.returnTime(hg.currentTime)));
    else
      sender.sendMessage(
          String.format(cm.getCommandPlayersTimeStatusStarting(), hg.returnTime(hg.currentTime)));
    return true;
  }
}
Пример #2
0
public class Invis implements CommandExecutor {
  private PlayerManager pm = HungergamesApi.getPlayerManager();
  private ChatManager cm = HungergamesApi.getChatManager();

  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if (sender.hasPermission("hungergames.invis")) {
      Gamer gamer = pm.getGamer(sender.getName());
      Player p = gamer.getPlayer();
      if (args.length > 0) {
        if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfShow())) {
          p.sendMessage(cm.getCommandInvisShow());
          gamer.seeInvis(true);
          gamer.updateOthersToSelf();
        } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfHide())) {
          gamer.seeInvis(false);
          gamer.updateOthersToSelf();
          p.sendMessage(cm.getCommandInvisHide());
        } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfShowAll())) {
          for (Gamer game : pm.getGamers()) {
            game.seeInvis(true);
            game.updateSelfToOthers();
          }
          p.sendMessage(cm.getCommandInvisShowAll());
        } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfHideAll())) {
          for (Gamer game : pm.getGamers()) {
            game.seeInvis(false);
            game.updateSelfToOthers();
          }
          p.sendMessage(cm.getCommandInvisHideAll());
        } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfHidePlayer())) {
          if (args.length > 1) {
            if (Bukkit.getPlayer(args[1]) != null) {
              pm.getGamer(Bukkit.getPlayer(args[1])).hide();
              p.sendMessage(
                  String.format(
                      cm.getCommandInvisHidePlayerSuccess(), Bukkit.getPlayer(args[1]).getName()));
            } else p.sendMessage(String.format(cm.getCommandInvisHidePlayerFail(), args[1]));
          } else p.sendMessage(cm.getCommandInvisHidePlayerNoArgs());
        } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfShowPlayer())) {
          if (args.length > 1) {
            Player player = Bukkit.getPlayer(args[1]);
            if (player != null) {
              pm.getGamer(player).show();
              p.sendMessage(String.format(cm.getCommandInvisShowPlayerSuccess(), player.getName()));
            } else p.sendMessage(String.format(cm.getCommandInvisShowPlayerFail(), args[1]));
          } else p.sendMessage(cm.getCommandInvisShowPlayerNoArgs());
        } else p.sendMessage(cm.getCommandInvisNotEnoughArguments());
      } else p.sendMessage(cm.getCommandInvisNotEnoughArguments());
    } else sender.sendMessage(cm.getCommandInvisNoPermission());
    return true;
  }
}
Пример #3
0
public class MessageCommand implements CommandExecutor {

  public String[] aliases =
      new String[] {"msg", "mail", "tell", "pm", "whisper", "w", "privatemessage"};
  private transient ChatManager chat = HungergamesApi.getChatManager();
  public String description = "Message a player your secret plans";
  private transient TranslationConfig tm =
      HungergamesApi.getConfigManager().getTranslationsConfig();

  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if (args.length == 0) sender.sendMessage(tm.getCommandMessageNoArgs());
    else if (args.length > 1) {
      Player player = Bukkit.getPlayer(args[0]);
      if (player == null) {
        sender.sendMessage(tm.getCommandMessageNoReceiver());
        return true;
      }
      chat.sendMessage(sender, player, StringUtils.join(args, " ").substring(args[0].length() + 1));
    } else sender.sendMessage(tm.getCommandMessagePlayerNoArgs());
    return true;
  }
}
Пример #4
0
 public Chameleon() throws Exception {
   if (Bukkit.getPluginManager().getPlugin("iDisguise") == null)
     throw new Exception(
         String.format(
             HungergamesApi.getChatManager().getLoggerDependencyNotFound(), "Plugin iDiguise"));
 }