Search in sources :

Example 1 with DateTimeFormat

use of com.google.gwt.i18n.shared.DateTimeFormat in project Mindustry by Anuken.

the class HtmlLauncher method createApplicationListener.

@Override
public ApplicationListener createApplicationListener() {
    instance = this;
    setLogLevel(LOG_NONE);
    setLoadingListener(new LoadingListener() {

        @Override
        public void beforeSetup() {
        }

        @Override
        public void afterSetup() {
            scaleCanvas();
            setupResizeHook();
        }
    });
    Net.setClientProvider(new WebsocketClient());
    Platform.instance = new Platform() {

        DateTimeFormat format = DateTimeFormat.getFormat("EEE, dd MMM yyyy HH:mm:ss");

        @Override
        public String format(Date date) {
            return format.format(date);
        }

        @Override
        public String format(int number) {
            return NumberFormat.getDecimalFormat().format(number);
        }

        @Override
        public boolean canJoinGame() {
            String ref = Document.get().getReferrer();
            return !ref.startsWith("https") && !ref.contains("itch.io");
        }

        @Override
        public byte[] getUUID() {
            Settings.defaults("uuid", "");
            String uuid = Settings.getString("uuid");
            if (uuid.isEmpty()) {
                byte[] result = new byte[8];
                new Random().nextBytes(result);
                uuid = new String(Base64Coder.encode(result));
                Settings.putString("uuid", uuid);
                Settings.save();
                return result;
            }
            return Base64Coder.decode(uuid);
        }
    };
    return new Mindustry();
}
Also used : Mindustry(io.anuke.mindustry.Mindustry) Platform(io.anuke.mindustry.io.Platform) Random(java.util.Random) Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.shared.DateTimeFormat)

Aggregations

DateTimeFormat (com.google.gwt.i18n.shared.DateTimeFormat)1 Mindustry (io.anuke.mindustry.Mindustry)1 Platform (io.anuke.mindustry.io.Platform)1 Date (java.util.Date)1 Random (java.util.Random)1