mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
@@ -1,7 +1,7 @@
|
||||
package org.bukkit.configuration;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void addDefault(@NotNull String path, @Nullable Object value) {
|
||||
Validate.notNull(path, "Path may not be null");
|
||||
Preconditions.checkArgument(path != null, "Path may not be null");
|
||||
|
||||
if (defaults == null) {
|
||||
defaults = new MemoryConfiguration();
|
||||
@@ -43,7 +43,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void addDefaults(@NotNull Map<String, Object> defaults) {
|
||||
Validate.notNull(defaults, "Defaults may not be null");
|
||||
Preconditions.checkArgument(defaults != null, "Defaults may not be null");
|
||||
|
||||
for (Map.Entry<String, Object> entry : defaults.entrySet()) {
|
||||
addDefault(entry.getKey(), entry.getValue());
|
||||
@@ -52,7 +52,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void addDefaults(@NotNull Configuration defaults) {
|
||||
Validate.notNull(defaults, "Defaults may not be null");
|
||||
Preconditions.checkArgument(defaults != null, "Defaults may not be null");
|
||||
|
||||
for (String key : defaults.getKeys(true)) {
|
||||
if (!defaults.isConfigurationSection(key)) {
|
||||
@@ -63,7 +63,7 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void setDefaults(@NotNull Configuration defaults) {
|
||||
Validate.notNull(defaults, "Defaults may not be null");
|
||||
Preconditions.checkArgument(defaults != null, "Defaults may not be null");
|
||||
|
||||
this.defaults = defaults;
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.configuration;
|
||||
|
||||
import static org.bukkit.util.NumberConversions.*;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -8,7 +10,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -60,14 +61,14 @@ public class MemorySection implements ConfigurationSection {
|
||||
* if parent contains no root Configuration.
|
||||
*/
|
||||
protected MemorySection(@NotNull ConfigurationSection parent, @NotNull String path) {
|
||||
Validate.notNull(parent, "Parent cannot be null");
|
||||
Validate.notNull(path, "Path cannot be null");
|
||||
Preconditions.checkArgument(parent != null, "Parent cannot be null");
|
||||
Preconditions.checkArgument(path != null, "Path cannot be null");
|
||||
|
||||
this.path = path;
|
||||
this.parent = parent;
|
||||
this.root = parent.getRoot();
|
||||
|
||||
Validate.notNull(root, "Path cannot be orphaned");
|
||||
Preconditions.checkArgument(root != null, "Path cannot be orphaned");
|
||||
|
||||
this.fullPath = createPath(parent, path);
|
||||
}
|
||||
@@ -158,7 +159,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public void addDefault(@NotNull String path, @Nullable Object value) {
|
||||
Validate.notNull(path, "Path cannot be null");
|
||||
Preconditions.checkArgument(path != null, "Path cannot be null");
|
||||
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
@@ -187,7 +188,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public void set(@NotNull String path, @Nullable Object value) {
|
||||
Validate.notEmpty(path, "Cannot set to an empty path");
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(path), "Cannot set to an empty path");
|
||||
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
@@ -240,7 +241,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Contract("_, !null -> !null")
|
||||
@Nullable
|
||||
public Object get(@NotNull String path, @Nullable Object def) {
|
||||
Validate.notNull(path, "Path cannot be null");
|
||||
Preconditions.checkArgument(path != null, "Path cannot be null");
|
||||
|
||||
if (path.length() == 0) {
|
||||
return this;
|
||||
@@ -278,7 +279,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Override
|
||||
@NotNull
|
||||
public ConfigurationSection createSection(@NotNull String path) {
|
||||
Validate.notEmpty(path, "Cannot create section at empty path");
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(path), "Cannot create section at empty path");
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Cannot create section without a root");
|
||||
@@ -711,7 +712,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends Object> T getObject(@NotNull String path, @NotNull Class<T> clazz) {
|
||||
Validate.notNull(clazz, "Class cannot be null");
|
||||
Preconditions.checkArgument(clazz != null, "Class cannot be null");
|
||||
Object def = getDefault(path);
|
||||
return getObject(path, clazz, (def != null && clazz.isInstance(def)) ? clazz.cast(def) : null);
|
||||
}
|
||||
@@ -720,7 +721,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends Object> T getObject(@NotNull String path, @NotNull Class<T> clazz, @Nullable T def) {
|
||||
Validate.notNull(clazz, "Class cannot be null");
|
||||
Preconditions.checkArgument(clazz != null, "Class cannot be null");
|
||||
Object val = get(path, def);
|
||||
return (val != null && clazz.isInstance(val)) ? clazz.cast(val) : def;
|
||||
}
|
||||
@@ -855,7 +856,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Nullable
|
||||
protected Object getDefault(@NotNull String path) {
|
||||
Validate.notNull(path, "Path cannot be null");
|
||||
Preconditions.checkArgument(path != null, "Path cannot be null");
|
||||
|
||||
Configuration root = getRoot();
|
||||
Configuration defaults = root == null ? null : root.getDefaults();
|
||||
@@ -940,7 +941,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
*/
|
||||
@NotNull
|
||||
public static String createPath(@NotNull ConfigurationSection section, @Nullable String key, @Nullable ConfigurationSection relativeTo) {
|
||||
Validate.notNull(section, "Cannot create path without a section");
|
||||
Preconditions.checkArgument(section != null, "Cannot create path without a section");
|
||||
Configuration root = section.getRoot();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Cannot create path without a root");
|
||||
@@ -998,7 +999,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Nullable
|
||||
private SectionPathData getSectionPathData(@NotNull String path) {
|
||||
Validate.notNull(path, "Path cannot be null");
|
||||
Preconditions.checkArgument(path != null, "Path cannot be null");
|
||||
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.configuration.file;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -12,7 +13,6 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
@@ -58,7 +58,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void save(@NotNull File file) throws IOException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
Files.createParentDirs(file);
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void save(@NotNull String file) throws IOException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
save(new File(file));
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void load(@NotNull File file) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
@@ -179,7 +179,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void load(@NotNull String file) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
load(new File(file));
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.configuration.file;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -12,7 +13,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -94,7 +94,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
|
||||
@Override
|
||||
public void loadFromString(@NotNull String contents) throws InvalidConfigurationException {
|
||||
Validate.notNull(contents, "String cannot be null");
|
||||
Preconditions.checkArgument(contents != null, "Contents cannot be null");
|
||||
yamlLoaderOptions.setProcessComments(options().parseComments());
|
||||
|
||||
MappingNode node;
|
||||
@@ -296,7 +296,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
*/
|
||||
@NotNull
|
||||
public static YamlConfiguration loadConfiguration(@NotNull File file) {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
@@ -325,7 +325,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
*/
|
||||
@NotNull
|
||||
public static YamlConfiguration loadConfiguration(@NotNull Reader reader) {
|
||||
Validate.notNull(reader, "Stream cannot be null");
|
||||
Preconditions.checkArgument(reader != null, "Stream cannot be null");
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package org.bukkit.configuration.file;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -95,8 +95,8 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||
*/
|
||||
@NotNull
|
||||
public YamlConfigurationOptions indent(int value) {
|
||||
Validate.isTrue(value >= 2, "Indent must be at least 2 characters");
|
||||
Validate.isTrue(value <= 9, "Indent cannot be greater than 9 characters");
|
||||
Preconditions.checkArgument(value >= 2, "Indent must be at least 2 characters");
|
||||
Preconditions.checkArgument(value <= 9, "Indent cannot be greater than 9 characters");
|
||||
|
||||
this.indent = value;
|
||||
return this;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.configuration.serialization;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -8,7 +9,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Location;
|
||||
@@ -115,7 +115,7 @@ public class ConfigurationSerialization {
|
||||
|
||||
@Nullable
|
||||
public ConfigurationSerializable deserialize(@NotNull Map<String, ?> args) {
|
||||
Validate.notNull(args, "Args must not be null");
|
||||
Preconditions.checkArgument(args != null, "Args must not be null");
|
||||
|
||||
ConfigurationSerializable result = null;
|
||||
Method method = null;
|
||||
|
Reference in New Issue
Block a user