Skip to content

Commit f257802

Browse files
committed
Adding the README.md
1 parent ddd2719 commit f257802

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

README.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# DNConfigManagerAPI
2+
3+
---
4+
5+
Configuration File's Type:
6+
-
7+
- Non-Encoded
8+
- Encoded (In Base64)
9+
10+
Configuration File's class Managers:
11+
-
12+
- ConfigManager
13+
- EncodedConfigManager
14+
15+
Configuration File's class Managers' Methods:
16+
-
17+
- `loadContent()` - Load the Config File content
18+
- `getName()` - Return the Config File Name
19+
- `read()` - Return the Config File content (Non-Encoded)
20+
- `save()` - Save the File (After changing values)
21+
- `writeDefault()` - Write "{}" in the file and erase all others data
22+
- `set(String key, Object value)` - Write a value in the File (it doesn't save)
23+
- `remove(String key)` - Remove a values from the File (it doesn't save)
24+
- `getHashMap(String key)` - Return an HashMap<Object,Object> from a key
25+
- `getString(String key)` - Return a String from a key
26+
- `getList(String key)` - Return a List\<Object> from a key
27+
- `getInt(String key)` - Return an Integer from a key
28+
- `getFloat(String key)` - Return a Float from a key
29+
- `getBoolean(String key)` - Return a Boolean from a key
30+
31+
---
32+
33+
---
34+
35+
## 1 - Initializing
36+
37+
To Initialize the API, you just have to create a new instance of the Config Class (`fr.benjimania74.configmanager.Config`)
38+
39+
```java
40+
new Config(String addonName); // Initialize the API
41+
```
42+
43+
---
44+
45+
## 2 - Create a Config File
46+
47+
You can create Encoded Config's Files and non Encoded Config's Files by getting the `Config()` instance
48+
49+
#### Non-Encoded Config File Creation
50+
51+
```java
52+
Config.getInstance().createConfig(String name); // name = Config File's Name
53+
// THAT RETURN a ConfigManager Instance
54+
```
55+
56+
#### Encoded Config File Creation
57+
58+
```java
59+
Config.getInstance().createEncodedConfig(String name); // name = Config File's Name
60+
// THAT RETURN an EncodedConfigManager Instance
61+
```
62+
63+
If the Config File is already existing, you will get an instance of it.
64+
65+
---
66+
67+
## 3 - Get a Config File
68+
69+
You can get Encoded and Non-Encoded Config File by getting the `Config()` instance.
70+
You can use the name of the file or the File to get it (use the name is recommended)
71+
72+
#### Get a Non-Encoded Config File
73+
74+
```java
75+
Config.getInstance().getConfig(String name);
76+
Config.getInstance().getConfig(File file);
77+
```
78+
79+
#### Get an Encoded Config File
80+
81+
```java
82+
Config.getInstance().getEncodedConfig(String name);
83+
Config.getInstance().getEncodedConfig(File file);
84+
```
85+
86+
---
87+
88+
## 4 - Example
89+
90+
```java
91+
import be.alexandre01.dreamnetwork.api.DNClientAPI;
92+
import be.alexandre01.dreamnetwork.api.addons.Addon;
93+
import be.alexandre01.dreamnetwork.api.addons.DreamExtension;
94+
import fr.benjimania74.configmanager.Config;
95+
import fr.benjimania74.configmanager.ConfigManager;
96+
import fr.benjimania74.configmanager.EncodedConfigManager;
97+
98+
public class Example extends DreamExtension {
99+
public static DNClientAPI clientAPI;
100+
101+
@Override
102+
public void onLoad() {
103+
super.onLoad();
104+
105+
new Config(getAddon().getDreamyName()); // Initialize the API
106+
}
107+
108+
@Override
109+
public void start() {
110+
super.start();
111+
clientAPI = getDnClientAPI();
112+
113+
// Non-Encoded Config
114+
115+
ConfigManager cm = Config.getInstance().createConfig("hello"); // Create "hello" Config File
116+
cm.writeDefault(); // Write "{}"
117+
cm.save(); // Save "{}"
118+
119+
120+
// Encoded Config
121+
122+
EncodedConfigManager ecm = Config.getInstance().getEncodedConfig("encoded"); // Get "encoded" Encoded Config File
123+
ecm.set("isEncoded", true); // Set a boolean value in the file
124+
System.out.println(ecm.getString("hello")); // Print a String value
125+
ecm.save(); // Save the content
126+
}
127+
128+
@Override
129+
public void stop() {
130+
super.stop();
131+
}
132+
133+
public Main(Addon addon) {
134+
super(addon);
135+
}
136+
}
137+
```

0 commit comments

Comments
 (0)