Bugfixes / Copy over plugins to mod folder
This commit is contained in:
@@ -29,6 +29,7 @@ load.mod = Mods
|
|||||||
schematic = Schematic
|
schematic = Schematic
|
||||||
schematic.add = Save Schematic...
|
schematic.add = Save Schematic...
|
||||||
schematics = Schematics
|
schematics = Schematics
|
||||||
|
schematic.replace = A schematic by that name already exists. Replace it?
|
||||||
schematic.import = Import Schematic...
|
schematic.import = Import Schematic...
|
||||||
schematic.exportfile = Export File
|
schematic.exportfile = Export File
|
||||||
schematic.importfile = Import File
|
schematic.importfile = Import 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){
|
private void loadFile(FileHandle file){
|
||||||
if(!file.extension().equals(schematicExtension)) return;
|
if(!file.extension().equals(schematicExtension)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public class DesktopInput extends InputHandler{
|
|||||||
t.visible(() -> lastSchematic != null && !selectRequests.isEmpty());
|
t.visible(() -> lastSchematic != null && !selectRequests.isEmpty());
|
||||||
t.bottom();
|
t.bottom();
|
||||||
t.table(Styles.black6, b -> {
|
t.table(Styles.black6, b -> {
|
||||||
//b.touchable(Touchable.enabled);
|
|
||||||
b.defaults().left();
|
b.defaults().left();
|
||||||
b.add(Core.bundle.format("schematic.flip",
|
b.add(Core.bundle.format("schematic.flip",
|
||||||
Core.keybinds.get(Binding.schematic_flip_x).key.name(),
|
Core.keybinds.get(Binding.schematic_flip_x).key.name(),
|
||||||
@@ -69,10 +68,19 @@ public class DesktopInput extends InputHandler{
|
|||||||
b.table(a -> {
|
b.table(a -> {
|
||||||
a.addImageTextButton("$schematic.add", Icon.saveSmall, () -> {
|
a.addImageTextButton("$schematic.add", Icon.saveSmall, () -> {
|
||||||
ui.showTextInput("$schematic.add", "$name", "", text -> {
|
ui.showTextInput("$schematic.add", "$name", "", text -> {
|
||||||
lastSchematic.tags.put("name", text);
|
Schematic replacement = schematics.all().find(s -> s.name().equals(text));
|
||||||
schematics.add(lastSchematic);
|
if(replacement != null){
|
||||||
ui.showInfoFade("$schematic.saved");
|
ui.showConfirm("$confirm", "$schematic.replace", () -> {
|
||||||
ui.schematics.showInfo(lastSchematic);
|
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);
|
}).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.mod;
|
|||||||
|
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.audio.*;
|
import io.anuke.arc.audio.*;
|
||||||
|
import io.anuke.arc.audio.mock.*;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
@@ -52,6 +53,7 @@ public class ContentParser{
|
|||||||
});
|
});
|
||||||
put(Sound.class, (type, data) -> {
|
put(Sound.class, (type, data) -> {
|
||||||
if(fieldOpt(Sounds.class, data) != null) return fieldOpt(Sounds.class, 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");
|
String path = "sounds/" + data.asString() + (Vars.ios ? ".mp3" : ".ogg");
|
||||||
ModLoadingSound sound = new ModLoadingSound();
|
ModLoadingSound sound = new ModLoadingSound();
|
||||||
|
|||||||
@@ -169,9 +169,11 @@ public class Mods implements Loadable{
|
|||||||
for(FileHandle file : modDirectory.list()){
|
for(FileHandle file : modDirectory.list()){
|
||||||
if(!file.extension().equals("jar") && !file.extension().equals("zip") && !(file.isDirectory() && file.child("mod.json").exists())) continue;
|
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{
|
try{
|
||||||
LoadedMod mod = loadMod(file, false);
|
LoadedMod mod = loadMod(file, false);
|
||||||
if(mod.enabled()){
|
if(mod.enabled() || headless){
|
||||||
loaded.add(mod);
|
loaded.add(mod);
|
||||||
}else{
|
}else{
|
||||||
disabled.add(mod);
|
disabled.add(mod);
|
||||||
@@ -286,7 +288,7 @@ public class Mods implements Loadable{
|
|||||||
try{
|
try{
|
||||||
//this binds the content but does not load it entirely
|
//this binds the content but does not load it entirely
|
||||||
Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString("UTF-8"), file, type);
|
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));
|
(loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e);
|
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e);
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package io.anuke.mindustry.server;
|
package io.anuke.mindustry.server;
|
||||||
|
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
|
import io.anuke.arc.files.*;
|
||||||
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.*;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.core.*;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.mod.*;
|
import io.anuke.mindustry.mod.*;
|
||||||
@@ -20,6 +22,15 @@ public class MindustryServer implements ApplicationListener{
|
|||||||
loadLocales = false;
|
loadLocales = false;
|
||||||
headless = true;
|
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.loadSettings();
|
||||||
Vars.init();
|
Vars.init();
|
||||||
content.createContent();
|
content.createContent();
|
||||||
|
|||||||
@@ -751,8 +751,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
mods.each(p -> p.registerServerCommands(handler));
|
mods.each(p -> p.registerServerCommands(handler));
|
||||||
//TODO
|
mods.each(p -> p.registerClientCommands(netServer.clientCommands));
|
||||||
//plugins.each(p -> p.registerClientCommands(netServer.clientCommands));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCommands(){
|
private void readCommands(){
|
||||||
|
|||||||
Reference in New Issue
Block a user