1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-21 13:28:12 +03:00

Bugfixes / Copy over plugins to mod folder

This commit is contained in:
Anuken 2019-10-24 18:04:39 -04:00
parent cbfcb5de2c
commit 955dc5f48d
7 changed files with 51 additions and 9 deletions

View File

@ -29,6 +29,7 @@ load.mod = Mods
schematic = Schematic
schematic.add = Save Schematic...
schematics = Schematics
schematic.replace = A schematic by that name already exists. Replace it?
schematic.import = Import Schematic...
schematic.exportfile = Export File
schematic.importfile = Import File

View File

@ -68,6 +68,25 @@ public class Schematics implements Loadable{
});
}
public void overwrite(Schematic target, Schematic newSchematic){
if(previews.containsKey(target)){
previews.get(target).dispose();
previews.remove(target);
}
target.tiles.clear();
target.tiles.addAll(newSchematic.tiles);
newSchematic.tags.putAll(target.tags);
newSchematic.file = target.file;
try{
write(newSchematic, target.file);
}catch(Exception e){
Log.err(e);
ui.showException(e);
}
}
private void loadFile(FileHandle file){
if(!file.extension().equals(schematicExtension)) return;

View File

@ -60,7 +60,6 @@ public class DesktopInput extends InputHandler{
t.visible(() -> lastSchematic != null && !selectRequests.isEmpty());
t.bottom();
t.table(Styles.black6, b -> {
//b.touchable(Touchable.enabled);
b.defaults().left();
b.add(Core.bundle.format("schematic.flip",
Core.keybinds.get(Binding.schematic_flip_x).key.name(),
@ -69,10 +68,19 @@ public class DesktopInput extends InputHandler{
b.table(a -> {
a.addImageTextButton("$schematic.add", Icon.saveSmall, () -> {
ui.showTextInput("$schematic.add", "$name", "", text -> {
lastSchematic.tags.put("name", text);
schematics.add(lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(lastSchematic);
Schematic replacement = schematics.all().find(s -> s.name().equals(text));
if(replacement != null){
ui.showConfirm("$confirm", "$schematic.replace", () -> {
schematics.overwrite(replacement, lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(replacement);
});
}else{
lastSchematic.tags.put("name", text);
schematics.add(lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(lastSchematic);
}
});
}).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
});

View File

@ -2,6 +2,7 @@ package io.anuke.mindustry.mod;
import io.anuke.arc.*;
import io.anuke.arc.audio.*;
import io.anuke.arc.audio.mock.*;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
@ -52,6 +53,7 @@ public class ContentParser{
});
put(Sound.class, (type, data) -> {
if(fieldOpt(Sounds.class, data) != null) return fieldOpt(Sounds.class, data);
if(Vars.headless) return new MockSound();
String path = "sounds/" + data.asString() + (Vars.ios ? ".mp3" : ".ogg");
ModLoadingSound sound = new ModLoadingSound();

View File

@ -169,9 +169,11 @@ public class Mods implements Loadable{
for(FileHandle file : modDirectory.list()){
if(!file.extension().equals("jar") && !file.extension().equals("zip") && !(file.isDirectory() && file.child("mod.json").exists())) continue;
Log.debug("[Mods] Loading mod {0}", file);
try{
LoadedMod mod = loadMod(file, false);
if(mod.enabled()){
if(mod.enabled() || headless){
loaded.add(mod);
}else{
disabled.add(mod);
@ -286,7 +288,7 @@ public class Mods implements Loadable{
try{
//this binds the content but does not load it entirely
Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString("UTF-8"), file, type);
Log.info("[{0}] Loaded '{1}'.", mod.meta.name,
Log.debug("[{0}] Loaded '{1}'.", mod.meta.name,
(loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
}catch(Exception e){
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e);

View File

@ -1,6 +1,8 @@
package io.anuke.mindustry.server;
import io.anuke.arc.*;
import io.anuke.arc.files.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.core.*;
import io.anuke.mindustry.mod.*;
@ -20,6 +22,15 @@ public class MindustryServer implements ApplicationListener{
loadLocales = false;
headless = true;
FileHandle plugins = Core.settings.getDataDirectory().child("plugins");
if(plugins.isDirectory() && plugins.list().length > 0 && !plugins.sibling("mods").exists()){
Log.warn("[IMPORTANT NOTICE] &lrPlugins have been detected.&ly Automatically moving all contents of the plugin folder into the 'mods' folder. The original folder will not be removed; please do so manually.");
plugins.sibling("mods").mkdirs();
for(FileHandle file : plugins.list()){
file.copyTo(plugins.sibling("mods"));
}
}
Vars.loadSettings();
Vars.init();
content.createContent();

View File

@ -751,8 +751,7 @@ public class ServerControl implements ApplicationListener{
});
mods.each(p -> p.registerServerCommands(handler));
//TODO
//plugins.each(p -> p.registerClientCommands(netServer.clientCommands));
mods.each(p -> p.registerClientCommands(netServer.clientCommands));
}
private void readCommands(){