@Override public Boolean get() { return config.getSystem().isDebugEnabled(); } });
private void scheduleNextAutoSave() { long msBetweenAutoSave = (long) config.getSystem().getMaxSecondsBetweenSaves() * 1000; nextAutoSave = System.currentTimeMillis() + msBetweenAutoSave; }
private boolean isSavingNecessary() { ChunkProvider chunkProvider = CoreRegistry.get(ChunkProvider.class); int unloadedChunkCount = unloadedAndUnsavedChunkMap.size(); int loadedChunkCount = chunkProvider.getAllChunks().size(); double totalChunkCount = unloadedChunkCount + loadedChunkCount; double percentageUnloaded = 100.0 * unloadedChunkCount / totalChunkCount; if (percentageUnloaded >= config.getSystem().getMaxUnloadedChunksPercentageTillSave()) { return true; } long currentTime = System.currentTimeMillis(); if (nextAutoSave == null) { scheduleNextAutoSave(); return false; } return currentTime >= nextAutoSave; }
/** * @param context the context to use */ public TranslationSystemImpl(Context context) { config = context.get(Config.class).getSystem(); assetManager = context.get(AssetManager.class); refresh(); }
private void fetchConfig() { Config config = context.get(Config.class); language = config.getSystem().getLocale().toString(); PlayerConfig playerConfig = config.getPlayer(); playerHeight = playerConfig.getHeight(); playerEyeHeight = playerConfig.getEyeHeight(); } }
@Override public void initialise(GameEngine engine, Context rootContext) { if (rootContext.get(Config.class).getSystem().isMonitoringEnabled()) { advancedMonitor = new AdvancedMonitor(); advancedMonitor.setVisible(true); } }
/** * Change the UI language * * @param langTag String containing language code to change * @return String containing language or if not recognized error message */ @Command(shortDescription = "Changes the UI language") public String setLanguage(@CommandParam("language-tag") String langTag) { Locale locale = Locale.forLanguageTag(langTag); TranslationProject proj = translationSystem.getProject(new SimpleUri("engine:menu")); // Try if language exists if (proj.getAvailableLocales().contains(locale)) { config.getSystem().setLocale(locale); nuiManager.invalidate(); String nat = translationSystem.translate("${engine:menu#this-language-native}", locale); String eng = translationSystem.translate("${engine:menu#this-language-English}", locale); return String.format("Language set to %s (%s)", nat, eng); } else { return "Unrecognized locale! Try one of: " + proj.getAvailableLocales(); } }
@Command(shortDescription = "Invalidates the specified chunk and recreates it (requires storage manager disabled)", runOnServer = true) public String reloadChunk(@CommandParam("x") int x, @CommandParam("y") int y, @CommandParam("z") int z) { Vector3i pos = new Vector3i(x, y, z); if (config.getSystem().isWriteSaveGamesEnabled()) { return "Writing save games is enabled! Invalidating chunk has no effect"; } boolean success = chunkProvider.reloadChunk(pos); return success ? "Cleared chunk " + pos + " from cache and triggered reload" : "Chunk " + pos + " did not exist in the cache"; }
@Override public void initialise() { WidgetUtil.tryBindCheckbox(this, "disableAutosave", BindHelper.bindBeanProperty("disableAutosave", config.getNuiEditor(), Boolean.TYPE)); WidgetUtil.tryBindCheckbox(this, "disableIcons", BindHelper.bindBeanProperty("disableIcons", config.getNuiEditor(), Boolean.TYPE)); WidgetUtil.trySubscribe(this, "close", button -> getManager().closeScreen(ASSET_URI)); alternativeLocale = find("alternativeLocale", UIDropdownScrollable.class); if (alternativeLocale != null) { // Build the list of available locales and set the dropdown's options to them. TranslationProject menuProject = translationSystem.getProject(new SimpleUri("engine:menu")); List<Locale> locales = new ArrayList<>(menuProject.getAvailableLocales()); Collections.sort(locales, ((Object o1, Object o2) -> (o1.toString().compareTo(o2.toString())))); alternativeLocale.setOptions(Lists.newArrayList(locales)); alternativeLocale.setVisibleOptions(5); alternativeLocale.setOptionRenderer(new LocaleRenderer(translationSystem)); // If an alternative locale has been previously selected, select it; otherwise select the system locale. if (config.getNuiEditor().getAlternativeLocale() != null) { alternativeLocale.setSelection(config.getNuiEditor().getAlternativeLocale()); } else { alternativeLocale.setSelection(config.getSystem().getLocale()); } } }
private void savePlayerSettings() { Color color = getColor(); config.getPlayer().setColor(color); Float height = getHeight(); config.getPlayer().setHeight(height); Float eyeHeight = getEyeHeight(); config.getPlayer().setEyeHeight(eyeHeight); config.getPlayer().setDiscordPresence(discordPresence.isChecked()); if (nametext != null) { config.getPlayer().setName(nametext.getText().trim()); config.getPlayer().setHasEnteredUsername(true); DiscordRPCSubSystem.updateState(); } if (!config.getSystem().getLocale().equals(language.getSelection())) { config.getSystem().setLocale(language.getSelection()); getManager().invalidate(); } }
@ReceiveEvent(components = ClientComponent.class) public void onKeyDown(KeyDownEvent event, EntityRef entity) { boolean debugEnabled = config.getSystem().isDebugEnabled(); break; case Keyboard.KeyId.F3: config.getSystem().setDebugEnabled(!config.getSystem().isDebugEnabled()); event.consume(); break;
@Override public void onOpened() { super.onOpened(); if (nametext != null) { nametext.setText(config.getPlayer().getName()); } if (slider != null) { Color color = config.getPlayer().getColor(); slider.bindValue(new NotifyingBinding(findClosestIndex(color))); } if (heightSlider != null) { heightSlider.bindValue(new NotifyingBinding(config.getPlayer().getHeight())); } if (eyeHeightSlider != null) { eyeHeightSlider.bindValue(new NotifyingBinding(config.getPlayer().getEyeHeight())); } if (discordPresence != null) { discordPresence.setChecked(config.getPlayer().isDiscordPresence()); } if (language != null) { language.setSelection(config.getSystem().getLocale()); } updateImage(); }
boolean debugEnabled = config.getSystem().isDebugEnabled();
boolean writeSaveGamesEnabled = context.get(Config.class).getSystem().isWriteSaveGamesEnabled();