#How would i save the chunk to config.yml onDisable and restore it onEnable?
1 messages · Page 1 of 1 (latest)
what's the question?
how would i save the claimed chunks to the config.yml onDisable and restore them onEnable
yeah but what's the code for?
a chunk claim command
it works. i have a thing that will store the chunks but it doesnt restore them from the config file
well first of all, saving the claimed chunks into your config.yml would be an awful way of doing it, you should use a database imo
just use the get from the config on onEnable
is there a format the x and z coords need to be in for get() to work?
public void saveClaims() {
for (Map.Entry<String, String> claims : claimedChunks.entrySet()) {
this.getConfig().set("claimedChunks." + claims.getKey(), claims.getValue());
}
this.saveConfig();
}
public void restoreClaims() {
this.getConfig().getConfigurationSection("claimedChunks").getKeys(false).forEach(key -> {
String claims = (String) this.getConfig().get("claimedChunks." + key);
this.canClaim.put(key, claims);
});
}```
like that
and what is claimedChunks?
i mean the object
chunk.getX() + "," + chunk.getZ()
oh then yeah, what's wrong? it's not loading?
ye. when i reload the server (as an example) itll save it as 5, 8: <clanName> but itll still say that the chunk can be claimed again