Add missing CommandFlagReset registration.

* Add support for migrating existing Sponge claim data.
* Fix 'en_US' lang error on startup.
This commit is contained in:
bloodshot 2019-07-24 23:18:46 -04:00
parent 25beb3aafb
commit 54ab8f4fbc
2 changed files with 19 additions and 2 deletions

View File

@ -62,6 +62,7 @@
import com.griefdefender.command.CommandClaimFlagDebug;
import com.griefdefender.command.CommandClaimFlagGroup;
import com.griefdefender.command.CommandClaimFlagPlayer;
import com.griefdefender.command.CommandClaimFlagReset;
import com.griefdefender.command.CommandClaimGreeting;
import com.griefdefender.command.CommandClaimIgnore;
import com.griefdefender.command.CommandClaimInfo;
@ -531,6 +532,7 @@ public void registerBaseCommands() {
manager.registerCommand(new CommandClaimFlagDebug());
manager.registerCommand(new CommandClaimFlagGroup());
manager.registerCommand(new CommandClaimFlagPlayer());
manager.registerCommand(new CommandClaimFlagReset());
manager.registerCommand(new CommandClaimGreeting());
manager.registerCommand(new CommandClaimIgnore());
manager.registerCommand(new CommandClaimInfo());
@ -658,7 +660,7 @@ public void loadConfig() {
localeString = "en_US";
}
final Path localePath = this.getConfigPath().resolve("lang").resolve(localeString + ".conf");
if (!localePath.toFile().exists()) {
if (!localeString.equalsIgnoreCase("en_US") && !localePath.toFile().exists()) {
// Check for a default locale asset and copy to lang folder
try {
final InputStream in = getClass().getResourceAsStream("/assets/lang/" + localeString + ".conf");

View File

@ -161,7 +161,22 @@ public ClaimStorageData(Path path, UUID worldUniqueId) {
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(ClaimDataConfig.class).bindToNew();
}
this.configMapper.getInstance().setClaimStorageData(this);
reload();
try {
this.root = this.loader.load(ConfigurationOptions.defaults());
CommentedConfigurationNode rootNode = this.root.getNode(GriefDefenderPlugin.MOD_ID);
// Check if server is using existing Sponge GP data
if (rootNode.isVirtual()) {
// check GriefPrevention
CommentedConfigurationNode gpRootNode = this.root.getNode("GriefPrevention");
if (!gpRootNode.isVirtual()) {
rootNode.setValue(gpRootNode.getValue());
gpRootNode.setValue(null);
}
}
this.configBase = this.configMapper.populate(rootNode);
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to load configuration", e);
}
((EconomyDataConfig) this.configMapper.getInstance().getEconomyData()).activeConfig = GriefDefenderPlugin.getActiveConfig(worldUniqueId);
} catch (Exception e) {
GriefDefenderPlugin.getInstance().getLogger().log(Level.SEVERE, "Failed to initialize configuration", e);