Properly set a default value for the `Replacements` option

This commit is contained in:
ME1312 2020-06-20 03:45:45 -04:00
parent 0e8bae4187
commit 0812ff3ade
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
4 changed files with 5 additions and 4 deletions

View File

@ -122,7 +122,7 @@ public class InternalSubCreator extends SubCreator {
if (template.getBuildOptions().getBoolean("Update-Files", false)) updateDirectory(template.getDirectory(), dir);
else Util.copyDirectory(template.getDirectory(), dir);
for (ObjectMapValue<String> replacement : template.getBuildOptions().getMap("Replacements").getValues()) if (!replacement.isNull()) {
for (ObjectMapValue<String> replacement : template.getBuildOptions().getMap("Replacements", new ObjectMap<>()).getValues()) if (!replacement.isNull()) {
replacements.put(replacement.getHandle().toLowerCase().replace('-', '_').replace(' ', '_'), replacement.asRawString());
}

View File

@ -35,7 +35,7 @@ public class PacketExUploadTemplates implements PacketObjectIn<Integer>, PacketO
HashMap<String, SubCreator.ServerTemplate> map = Util.getDespiteException(() -> Util.reflect(ExternalSubCreator.class.getDeclaredField("templates"), ((ExternalHost) client.getHandler()).getCreator()), new HashMap<>());
UniversalFile templatedir = new UniversalFile(plugin.dir, "SubServers:Cache:Remote:Templates");
ObjectMap<String> templates = new ObjectMap<>((Map<String, ?>) data.getObject(0x0000));
templatedir.mkdirs();
map.clear();
for (String name : templates.getKeys()) {
try {
UniversalFile dir = new UniversalFile(templatedir, name);

View File

@ -300,7 +300,7 @@ public class SubCreatorImpl {
if (template.getBuildOptions().getBoolean("Update-Files", false)) updateDirectory(template.getDirectory(), dir);
else Util.copyDirectory(template.getDirectory(), dir);
for (ObjectMapValue<String> replacement : template.getBuildOptions().getMap("Replacements").getValues()) if (!replacement.isNull()) {
for (ObjectMapValue<String> replacement : template.getBuildOptions().getMap("Replacements", new ObjectMap<>()).getValues()) if (!replacement.isNull()) {
replacements.put(replacement.getHandle().toLowerCase().replace('-', '_').replace(' ', '_'), replacement.asRawString());
}

View File

@ -27,8 +27,9 @@ public class PacketExUploadTemplates implements PacketIn, PacketObjectOut<Intege
@Override
public ObjectMap<Integer> send(SubDataSender client) {
host.log.info.println(((first)?"S":"Res") + "ending Local Template Metadata...");
if (!first) host.creator.load(false);
if (!host.templates.isEmpty())
host.log.info.println(((first)?"S":"Res") + "ending Local Template Metadata...");
ObjectMap<Integer> data = new ObjectMap<Integer>();
ObjectMap<String> templates = new ObjectMap<String>();