-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConfigurationManager.java
More file actions
42 lines (33 loc) · 1.31 KB
/
ConfigurationManager.java
File metadata and controls
42 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.eternalcode.example.config;
import com.eternalcode.multification.cdn.MultificationNoticeCdnComposer;
import com.eternalcode.multification.notice.Notice;
import com.eternalcode.multification.notice.resolver.NoticeResolverRegistry;
import net.dzikoysk.cdn.Cdn;
import net.dzikoysk.cdn.CdnFactory;
import net.dzikoysk.cdn.source.Source;
import java.io.File;
public class ConfigurationManager {
private final File dataFolder;
private final Cdn cdn;
private MessagesConfig messagesConfig;
public ConfigurationManager(File dataFolder, NoticeResolverRegistry noticeRegistry) {
this.dataFolder = dataFolder;
this.cdn = CdnFactory.createYamlLike()
.getSettings()
.withComposer(Notice.class, new MultificationNoticeCdnComposer(noticeRegistry))
.build();
}
public void load(MessagesConfig config, String fileName) {
this.messagesConfig = config;
File file = new File(this.dataFolder, fileName);
this.cdn.load(Source.of(file), config)
.orThrow(cause -> cause);
this.cdn.render(config, Source.of(file))
.orThrow(cause -> cause);
}
public void reload() {
if (this.messagesConfig != null) {
load(this.messagesConfig, "messages.yml");
}
}
}