mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-29 06:07:54 +07:00
@ -394,6 +394,7 @@ public class Logic implements ApplicationListener{
|
||||
@Override
|
||||
public void dispose(){
|
||||
//save the settings before quitting
|
||||
netServer.admins.forceSave();
|
||||
Core.settings.manualSave();
|
||||
}
|
||||
|
||||
@ -403,6 +404,7 @@ public class Logic implements ApplicationListener{
|
||||
universe.updateGlobal();
|
||||
|
||||
if(Core.settings.modified() && !state.isPlaying()){
|
||||
netServer.admins.forceSave();
|
||||
Core.settings.forceSave();
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,8 @@ public class Map implements Comparable<Map>, Publishable{
|
||||
|
||||
@Override
|
||||
public Fi createSteamPreview(String id){
|
||||
return previewFile();
|
||||
//I have no idea what the hell I was even thinking with this preview stuff
|
||||
return Vars.mapPreviewDirectory.child((workshop && file.parent().exists() && file.parent().extEquals(".png") ? file.parent().name() : file.nameWithoutExtension()) + "_v2.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,6 +24,8 @@ public class Administration{
|
||||
public ObjectSet<String> dosBlacklist = new ObjectSet<>();
|
||||
public ObjectMap<String, Long> kickedIPs = new ObjectMap<>();
|
||||
|
||||
|
||||
private boolean modified, loaded;
|
||||
/** All player info. Maps UUIDs to info. This persists throughout restarts. Do not access directly. */
|
||||
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
|
||||
|
||||
@ -448,15 +450,23 @@ public class Administration{
|
||||
}
|
||||
|
||||
public void save(){
|
||||
Core.settings.putJson("player-data", playerInfo);
|
||||
Core.settings.putJson("ip-kicks", kickedIPs);
|
||||
Core.settings.putJson("ip-bans", String.class, bannedIPs);
|
||||
Core.settings.putJson("whitelist-ids", String.class, whitelist);
|
||||
Core.settings.putJson("banned-subnets", String.class, subnetBans);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
public void forceSave(){
|
||||
if(modified && loaded){
|
||||
Core.settings.putJson("player-data", playerInfo);
|
||||
Core.settings.putJson("ip-kicks", kickedIPs);
|
||||
Core.settings.putJson("ip-bans", String.class, bannedIPs);
|
||||
Core.settings.putJson("whitelist-ids", String.class, whitelist);
|
||||
Core.settings.putJson("banned-subnets", String.class, subnetBans);
|
||||
modified = false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void load(){
|
||||
loaded = true;
|
||||
//load default data
|
||||
playerInfo = Core.settings.getJson("player-data", ObjectMap.class, ObjectMap::new);
|
||||
kickedIPs = Core.settings.getJson("ip-kicks", ObjectMap.class, ObjectMap::new);
|
||||
|
@ -227,13 +227,11 @@ public class MapsDialog extends BaseDialog{
|
||||
t.button("@custom", Styles.flatTogglet, () -> {
|
||||
showCustom = !showCustom;
|
||||
Core.settings.put("editorshowcustommaps", showCustom);
|
||||
Core.settings.forceSave();
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(showCustom);
|
||||
t.button("@builtin", Styles.flatTogglet, () -> {
|
||||
showBuiltIn = !showBuiltIn;
|
||||
Core.settings.put("editorshowbuiltinmaps", showBuiltIn);
|
||||
Core.settings.forceSave();
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(showBuiltIn);
|
||||
}).padBottom(10f);
|
||||
@ -244,13 +242,11 @@ public class MapsDialog extends BaseDialog{
|
||||
t.button("@editor.filters.author", Styles.flatTogglet, () -> {
|
||||
searchAuthor = !searchAuthor;
|
||||
Core.settings.put("editorsearchauthor", searchAuthor);
|
||||
Core.settings.forceSave();
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(searchAuthor);
|
||||
t.button("@editor.filters.description", Styles.flatTogglet, () -> {
|
||||
searchDescription = !searchDescription;
|
||||
Core.settings.put("editorsearchdescription", searchDescription);
|
||||
Core.settings.forceSave();
|
||||
rebuildMaps();
|
||||
}).size(150f, 60f).checked(searchDescription);
|
||||
});
|
||||
|
@ -164,7 +164,10 @@ public class SWorkshop implements SteamUGCCallback{
|
||||
tags.add(p.steamTag());
|
||||
|
||||
ugc.setItemTags(h, tags.toArray(String.class));
|
||||
ugc.setItemPreview(h, p.createSteamPreview(sid).absolutePath());
|
||||
String path = p.createSteamPreview(sid).absolutePath();
|
||||
|
||||
Log.info("PREVIEW @ @ @", ugc.setItemPreview(h, path), path, Fi.get(path).exists());
|
||||
|
||||
ugc.setItemContent(h, p.createSteamFolder(sid).absolutePath());
|
||||
if(changelog == null){
|
||||
ugc.setItemVisibility(h, PublishedFileVisibility.Private);
|
||||
|
@ -116,6 +116,8 @@ public class ServerControl implements ApplicationListener{
|
||||
|
||||
registerCommands();
|
||||
|
||||
|
||||
|
||||
Core.app.post(() -> {
|
||||
//try to load auto-update save if possible
|
||||
if(Config.autoUpdate.bool()){
|
||||
@ -255,7 +257,10 @@ public class ServerControl implements ApplicationListener{
|
||||
|
||||
//autosave settings once a minute
|
||||
float saveInterval = 60;
|
||||
Timer.schedule(() -> Core.settings.forceSave(), saveInterval, saveInterval);
|
||||
Timer.schedule(() -> {
|
||||
netServer.admins.forceSave();
|
||||
Core.settings.forceSave();
|
||||
}, saveInterval, saveInterval);
|
||||
|
||||
if(!mods.list().isEmpty()){
|
||||
info("@ mods loaded.", mods.list().size);
|
||||
|
Reference in New Issue
Block a user