Ejemplo n.º 1
0
 @Override
 public void execute(CommandSender arg0, String[] arg1) {
   // TODO Auto-generated method stub
   if (getPermission(arg0) == Permission.ADMIN || getPermission(arg0) == Permission.MODERATOR) {
     if (arg1.length < 1) {
       arg0.sendMessage(StringFormatter.error("You need to specify a player to kick."));
       return;
     }
     String partialPlayer = arg1[0];
     String fullPlayer = null;
     for (String u : BungeeCord.instance.connections.keySet()) {
       if (u.startsWith(partialPlayer)) {
         fullPlayer = u;
         break;
       }
     }
     if (fullPlayer == null) {
       arg0.sendMessage(StringFormatter.error("Player does not exist, or is not online"));
       return;
     }
     if (fullPlayer.equals(arg0.getName())) {
       arg0.sendMessage(StringFormatter.error("You can't kick yourself!"));
       return;
     }
     String reason = "Kicked: ";
     if (arg1.length > 1) {
       boolean first = true;
       for (String partArg : arg1) {
         if (first) {
           first = false;
           continue;
         }
         reason = reason + partArg + " ";
       }
       reason = reason.substring(0, reason.length() - 1);
     }
     reason = ChatColor.RED + ((arg1.length > 1) ? reason : reason + "You have been kicked!");
     PlayerKicker.kickPlayer(fullPlayer, reason);
     for (UserConnection uc : BungeeCord.instance.connections.values()) {
       if (BungeeCord.instance.config.admins.contains(uc.getName())
           || BungeeCord.instance.config.moderators.contains(uc.getName())) {
         uc.sendMessage(
             ChatColor.RED
                 + "The Player "
                 + ChatColor.AQUA
                 + fullPlayer
                 + ChatColor.RED
                 + " has been kicked for "
                 + ChatColor.AQUA
                 + reason
                 + ChatColor.RED
                 + " by "
                 + ChatColor.AQUA
                 + arg0.getName());
       }
     }
   } else {
     arg0.sendMessage(StringFormatter.error("No Permission"));
   }
 }
Ejemplo n.º 2
0
    @CompilerDirectives.SlowPath
    private RubyString formatSlow(RubyString format, Object[] args) {
      final RubyContext context = getContext();

      if (args.length == 1 && args[0] instanceof RubyArray) {
        singleArrayProfile.enter();
        return context.makeString(
            StringFormatter.format(format.toString(), ((RubyArray) args[0]).asList()));
      } else {
        multipleArgumentsProfile.enter();
        return context.makeString(StringFormatter.format(format.toString(), Arrays.asList(args)));
      }
    }
  public StringFormatter create(String... extensionClassNames) throws FormatterException {
    StringFormatter strFormatter = new StringFormatter();
    try {
      for (String className : extensionClassNames) {

        strFormatter.addExtension(
            (StringFormatterExtension) Class.forName(className).newInstance());
      }
    } catch (Exception e) {
      throw new FormatterException("Bad extension", e);
    }
    return strFormatter;
  }
Ejemplo n.º 4
0
  /**
   * update the display to show the current flashcard. Either the entire flashcard is shown or just
   * the first half depending on the value of the {@link #_showEntireCard} variable.
   */
  private void updateDisplay() {
    Flashcard fc = FlashcardApp.getInstance().getCurrentFlashcard();
    if (fc == null) {
      return;
    }

    String lang1Text = fc.getLang1Str();
    String lang2Text = "";
    if (FlashcardApp.getInstance().isShowEntireCard()) {
      lang2Text = fc.getLang2Str();
    }

    _topText.setText(StringFormatter.formatEnglishString(lang1Text));
    _bottomText.setText(StringFormatter.formatSpanishString(lang2Text));
    _statusText.setText(
        "id: "
            + fc.getID()
            + "   level: "
            + fc.getLevel()
            + "   count: "
            + fc.getRightGuessCount());
  }
 public StringFormatter create(String... classNames) throws FormatterException {
   if (classNames == null) {
     throw new FormatterException("No extention class names");
   }
   StringFormatter newFormatter = new StringFormatter();
   Collections.sort(Arrays.asList(classNames));
   for (int i = 0; i < classNames.length; ++i) {
     if (classNames[i] == null) {
       throw new FormatterException("Null class name");
     }
     if ((i > 0) && (classNames[i].equals(classNames[i - 1]))) {
       throw new FormatterException("Two class names are equal: " + classNames[i]);
     }
     try {
       newFormatter.addNewExtension(
           (StringFormatterExtension) Class.forName(classNames[i]).newInstance());
     } catch (Throwable e) {
       throw new FormatterException(e.toString());
     }
   }
   return newFormatter;
 }
Ejemplo n.º 6
0
  static void checkForFall(
      StringFormatter formatter, String correct, String input, Object... args) {

    try {
      formatter.format(input, args);
      System.err.println("No exception thrown.");
      System.exit(1);
    } catch (FormatterException fex) {
      if (!fex.getMessage().equals(correct)) {
        System.err.println("Mine   : " + fex.getMessage());
        System.err.println("Correct: " + correct);
        System.exit(1);
      }
    }
  }
Ejemplo n.º 7
0
  static void check(StringFormatter formatter, String correct, String input, Object... args) {

    try {
      String result = formatter.format(input, args);
      if (!result.equals(correct)) {
        System.err.println("Mine   : " + result);
        System.err.println("Correct: " + correct);
        System.exit(1);
      }
    } catch (Exception ex) {
      System.err.println("Unexpected exception: " + ex.getMessage());
      System.err.println(ex.getMessage());
      System.exit(1);
    }
  }