コード例 #1
0
ファイル: RandomEvent.java プロジェクト: YourCoal/Test
  private String getComponentVarsSaveString() {
    String out = "";

    for (String key : this.componentVars.keySet()) {
      String value = this.componentVars.get(key);

      String keyEncoded = new String(Base64Coder.encode(key.getBytes()));
      String valueEncoded = new String(Base64Coder.encode(value.getBytes()));

      out += keyEncoded + ":" + valueEncoded + ",";
    }

    return out;
  }
コード例 #2
0
ファイル: RandomEvent.java プロジェクト: YourCoal/Test
  private void loadSavedMessages(String input) {
    String[] messages = input.split(",");

    for (String encodedMessage : messages) {
      String message = StringUtils.toAsciiString(Base64Coder.decode(encodedMessage));
      this.savedMessages.add(message);
    }
  }
コード例 #3
0
ファイル: RandomEvent.java プロジェクト: YourCoal/Test
  private void loadComponentVars(String input) {
    if (input == null || input.equals("")) {
      return;
    }
    String[] keyValues = input.split(",");

    for (String kvs : keyValues) {
      String[] split = kvs.split(":");
      String keyEncoded = split[0];
      String valueEncoded = split[1];

      String key = StringUtils.toAsciiString(Base64Coder.decode(keyEncoded));
      String value = StringUtils.toAsciiString(Base64Coder.decode(valueEncoded));

      this.componentVars.put(key, value);
    }
  }
コード例 #4
0
ファイル: RandomEvent.java プロジェクト: YourCoal/Test
  private String getSavedMessagesSaveString() {
    String out = "";

    for (String message : this.savedMessages) {

      String msgEncoded = new String(Base64Coder.encode(message.getBytes()));
      out += msgEncoded + ",";
    }

    return out;
  }
コード例 #5
0
  static {
    byte[] testBytes =
        Base64Coder.decode(
            "ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9AQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVpbXF1eX2BhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ent8fX4NCg==");

    Charset defaultCharset = Charset.defaultCharset();
    String resultString = new String(testBytes, defaultCharset);
    boolean trueUTF = defaultCharset.name().contains("UTF");
    UTF8_OVERRIDE =
        (!" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\r\n"
                .equals(resultString))
            || (defaultCharset.equals(Charset.forName("US-ASCII")));
    SYSTEM_UTF = (trueUTF) || (UTF8_OVERRIDE);
    UTF_BIG = (trueUTF) && (UTF8_OVERRIDE);
  }
コード例 #6
0
  @Test
  public void test() throws IOException {
    CompressedImage tux = CompressedImage.fromPng(Resources.getResource("tux.png").openStream());
    byte[] original = tux.getDataCopy();

    WrappedServerPing serverPing = new WrappedServerPing();
    serverPing.setMotD("Hello, this is a test.");
    serverPing.setPlayersOnline(5);
    serverPing.setPlayersMaximum(10);
    serverPing.setVersionName("Minecraft 123");
    serverPing.setVersionProtocol(4);
    serverPing.setFavicon(tux);

    assertEquals(5, serverPing.getPlayersOnline());
    assertEquals(10, serverPing.getPlayersMaximum());
    assertEquals("Minecraft 123", serverPing.getVersionName());
    assertEquals(4, serverPing.getVersionProtocol());

    assertArrayEquals(original, serverPing.getFavicon().getData());

    CompressedImage copy = CompressedImage.fromBase64Png(Base64Coder.encodeLines(tux.getData()));
    assertArrayEquals(copy.getData(), serverPing.getFavicon().getData());
  }