Skip to content

Commit

Permalink
Add another catch for account loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Sep 17, 2024
1 parent 600fd84 commit b72f43e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Core/src/net/tnemc/core/io/storage/datables/yaml/YAMLAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void store(StorageConnector<?> connector, @NotNull Account account, @Null
accFile.createNewFile();
} catch(IOException ignore) {

PluginCore.log().error("Issue creating account file. Account: " + account.getName());
PluginCore.log().error("Issue creating account file. Account: " + account.getName(), DebugLevel.OFF);
return;
}
}
Expand All @@ -115,7 +115,7 @@ public void store(StorageConnector<?> connector, @NotNull Account account, @Null
yaml = YamlDocument.create(accFile);
} catch(IOException ignore) {

PluginCore.log().error("Issue loading account file. Account: " + account.getName());
PluginCore.log().error("Issue loading account file. Account: " + account.getName(), DebugLevel.OFF);
return;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public Optional<Account> load(StorageConnector<?> connector, @NotNull String ide

final File accFile = new File(PluginCore.directory(), "accounts/" + identifier + ".yml");
if(!accFile.exists()) {
PluginCore.log().error("Null account file passed to YAMLAccount.load. Account: " + identifier);
PluginCore.log().error("Null account file passed to YAMLAccount.load. Account: " + identifier, DebugLevel.OFF);
return Optional.empty();
}
return load(accFile, identifier);
Expand All @@ -193,7 +193,7 @@ public Optional<Account> load(StorageConnector<?> connector, @NotNull String ide
public Optional<Account> load(File accFile, final String identifier) {
if(accFile == null) {

PluginCore.log().error("Null account file passed to YAMLAccount.load. Account: " + identifier);
PluginCore.log().error("Null account file passed to YAMLAccount.load. Account: " + identifier, DebugLevel.OFF);
return Optional.empty();
}

Expand All @@ -202,7 +202,7 @@ public Optional<Account> load(File accFile, final String identifier) {
yaml = YamlDocument.create(accFile);
} catch(Exception ignore) {

PluginCore.log().error("Issue loading account file. Account: " + identifier);
PluginCore.log().error("Issue loading account file. Account: " + identifier + ". You may need to remove this account file! This is due to a previous server crash or improper shutdown and not a bug.", DebugLevel.OFF);
return Optional.empty();
}

Expand All @@ -213,7 +213,7 @@ public Optional<Account> load(File accFile, final String identifier) {
//Validate account file
if(!yaml.contains("Info.Name") || !yaml.contains("Info.Type")) {

PluginCore.log().error("Invalid account file. Account: " + identifier, DebugLevel.OFF);
PluginCore.log().error("Invalid account file. Account: " + identifier + ". You may need to remove this account file! This is due to a previous server crash or improper shutdown and not a bug.", DebugLevel.OFF);
return Optional.empty();
}

Expand Down Expand Up @@ -283,10 +283,14 @@ public Collection<Account> loadAll(StorageConnector<?> connector, @Nullable Stri

for(File file : IOUtil.getYAMLs(new File(PluginCore.directory(), "accounts"))) {

final Optional<Account> loaded = load(file, file.getName().replace(".yml", ""));
if(loaded.isPresent()) {
accounts.add(loaded.get());
TNECore.eco().account().uuidProvider().store(new UUIDPair(loaded.get().getIdentifier(), loaded.get().getName()));
try {
final Optional<Account> loaded = load(file, file.getName().replace(".yml", ""));
if(loaded.isPresent()) {
accounts.add(loaded.get());
TNECore.eco().account().uuidProvider().store(new UUIDPair(loaded.get().getIdentifier(), loaded.get().getName()));
}
} catch(Exception ignore) {
PluginCore.log().error("Issue loading account file. File: " + file.getName() + ". You may need to remove this account file! This is due to a previous server crash or improper shutdown and not a bug.", DebugLevel.OFF);
}
}
return accounts;
Expand Down

0 comments on commit b72f43e

Please sign in to comment.