#How would i save the chunk to config.yml onDisable and restore it onEnable?

1 messages · Page 1 of 1 (latest)

crisp cobalt
verbal pecan
#

what's the question?

crisp cobalt
#

how would i save the claimed chunks to the config.yml onDisable and restore them onEnable

verbal pecan
#

yeah but what's the code for?

crisp cobalt
#

a chunk claim command

verbal pecan
#

does it have a bug or what?

#

oh true

crisp cobalt
#

it works. i have a thing that will store the chunks but it doesnt restore them from the config file

verbal pecan
#

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

verbal pecan
crisp cobalt
#

is there a format the x and z coords need to be in for get() to work?

verbal pecan
#

oh, you are saving directly the chunk object?

#

or what?

crisp cobalt
#
    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

verbal pecan
#

i mean the object

crisp cobalt
#

a hashmap

#

storing <String, String>

verbal pecan
#

X,Y?

crisp cobalt
#

chunk.getX() + "," + chunk.getZ()

verbal pecan
crisp cobalt