Make parent folders before saving

This commit is contained in:
fullwall 2012-10-05 20:15:06 +08:00
parent 236b6e52c3
commit 03bcb9f4cf
3 changed files with 5 additions and 4 deletions

View File

@ -46,8 +46,8 @@ public class CitizensNPCRegistry implements NPCRegistry {
private final Map<EntityType, Class<? extends CitizensNPC>> types = new EnumMap<EntityType, Class<? extends CitizensNPC>>( private final Map<EntityType, Class<? extends CitizensNPC>> types = new EnumMap<EntityType, Class<? extends CitizensNPC>>(
EntityType.class); EntityType.class);
public CitizensNPCRegistry(NPCDataStore saves) { public CitizensNPCRegistry(NPCDataStore store) {
this.saves = saves; saves = store;
types.put(EntityType.BLAZE, CitizensBlazeNPC.class); types.put(EntityType.BLAZE, CitizensBlazeNPC.class);
types.put(EntityType.CAVE_SPIDER, CitizensCaveSpiderNPC.class); types.put(EntityType.CAVE_SPIDER, CitizensCaveSpiderNPC.class);
@ -143,7 +143,7 @@ public class CitizensNPCRegistry implements NPCRegistry {
if (entity == null) if (entity == null)
return null; return null;
net.minecraft.server.Entity handle = ((CraftEntity) entity).getHandle(); net.minecraft.server.Entity handle = ((CraftEntity) entity).getHandle();
return handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null; return handle != null && handle instanceof NPCHolder ? ((NPCHolder) handle).getNPC() : null;
} }
@Override @Override

View File

@ -85,6 +85,7 @@ public class Messages {
public static final String METRICS_ERROR_NOTIFICATION = "citizens.notifications.metrics-load-error"; public static final String METRICS_ERROR_NOTIFICATION = "citizens.notifications.metrics-load-error";
public static final String METRICS_NOTIFICATION = "citizens.notifications.metrics-started"; public static final String METRICS_NOTIFICATION = "citizens.notifications.metrics-started";
public static final String MINIMUM_COST_REQUIRED = "citizens.economy.minimum-cost-required"; public static final String MINIMUM_COST_REQUIRED = "citizens.economy.minimum-cost-required";
public static final String MISSING_TRANSLATIONS = "citizens.notifications.missing-translations";
public static final String MOBTYPE_CANNOT_BE_AGED = "citizens.commands.npc.age.cannot-be-aged"; public static final String MOBTYPE_CANNOT_BE_AGED = "citizens.commands.npc.age.cannot-be-aged";
public static final String MONEY_WITHDRAWN = "citizens.economy.money-withdrawn"; public static final String MONEY_WITHDRAWN = "citizens.economy.money-withdrawn";
public static final String NO_NPC_WITH_ID_FOUND = "citizens.commands.npc.spawn.missing-npc-id"; public static final String NO_NPC_WITH_ID_FOUND = "citizens.commands.npc.spawn.missing-npc-id";
@ -152,7 +153,6 @@ public class Messages {
public static final String VULNERABLE_STOPPED = "citizens.commands.npc.vulnerable.stopped"; public static final String VULNERABLE_STOPPED = "citizens.commands.npc.vulnerable.stopped";
public static final String WAYPOINT_PROVIDER_SET = "citizens.waypoints.set-provider"; public static final String WAYPOINT_PROVIDER_SET = "citizens.waypoints.set-provider";
public static final String WRITING_DEFAULT_SETTING = "citizens.settings.writing-default"; public static final String WRITING_DEFAULT_SETTING = "citizens.settings.writing-default";
public static final String MISSING_TRANSLATIONS = "citizens.notifications.missing-translations";
private static Properties getDefaultBundleProperties() { private static Properties getDefaultBundleProperties() {
Properties defaults = new Properties(); Properties defaults = new Properties();

View File

@ -146,6 +146,7 @@ public class Translator {
} }
}; };
try { try {
rootFolder.mkdirs();
File to = File.createTempFile(fileName, null, rootFolder); File to = File.createTempFile(fileName, null, rootFolder);
to.deleteOnExit(); to.deleteOnExit();
Files.copy(in, to); Files.copy(in, to);