MCPcopy Create free account
hub / github.com/Bukkit/Bukkit / set

Method set

src/main/java/org/bukkit/configuration/MemorySection.java:166–197  ·  view source on GitHub ↗
(String path, Object value)

Source from the content-addressed store, hash-verified

164 }
165
166 public void set(String path, Object value) {
167 String[] split = path.split(Pattern.quote(Character.toString(getRoot().options().pathSeparator())));
168 ConfigurationSection section = this;
169
170 if (path == null) {
171 throw new IllegalArgumentException("Path cannot be null");
172 } else if (path.length() == 0) {
173 throw new IllegalArgumentException("Cannot set to an empty path");
174 }
175
176 for (int i = 0; i < split.length - 1; i++) {
177 ConfigurationSection last = section;
178
179 section = last.getConfigurationSection(split[i]);
180
181 if (section == null) {
182 section = last.createSection(split[i]);
183 }
184 }
185
186 String key = split[split.length - 1];
187
188 if (section == this) {
189 if (value == null) {
190 map.remove(key);
191 } else {
192 map.put(key, prepForStorage(value));
193 }
194 } else {
195 section.set(key, value);
196 }
197 }
198
199 public Object get(String path) {
200 if (path == null) {

Callers

nothing calls this directly

Calls 10

getRootMethod · 0.95
createSectionMethod · 0.95
prepForStorageMethod · 0.95
setMethod · 0.95
optionsMethod · 0.65
removeMethod · 0.65
toStringMethod · 0.45
pathSeparatorMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected