Use newer Java features in places where it makes sense and more (#1009)
This commit is contained in:
1 parent
28cb136c6b
commit
7fb5e47da5
34 files changed
+338
-399
No files matched your search
@@ -2,7 +2,6 @@ package carpet.settings;
|
||||
|
||||
import carpet.utils.Translations;
|
||||
import carpet.utils.Messenger;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -11,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
|
||||
@@ -29,9 +29,9 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
public final String name;
|
||||
public final String description;
|
||||
public final String scarpetApp;
|
||||
public final ImmutableList<String> extraInfo;
|
||||
public final ImmutableList<String> categories;
|
||||
public final ImmutableList<String> options;
|
||||
public final List<String> extraInfo;
|
||||
public final List<String> categories;
|
||||
public final List<String> options;
|
||||
public boolean isStrict;
|
||||
public boolean isClient;
|
||||
public final Class<T> type;
|
||||
@@ -47,8 +47,8 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
this.type = (Class<T>) field.getType();
|
||||
this.description = rule.desc();
|
||||
this.isStrict = rule.strict();
|
||||
this.extraInfo = ImmutableList.copyOf(rule.extra());
|
||||
this.categories = ImmutableList.copyOf(rule.category());
|
||||
this.extraInfo = List.of(rule.extra());
|
||||
this.categories = List.of(rule.category());
|
||||
this.scarpetApp = rule.appSource();
|
||||
this.settingsManager = settingsManager;
|
||||
this.validators = new ArrayList<>();
|
||||
@@ -76,22 +76,22 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
this.defaultAsString = convertToString(this.defaultValue);
|
||||
if (rule.options().length > 0)
|
||||
{
|
||||
this.options = ImmutableList.copyOf(rule.options());
|
||||
this.options = List.of(rule.options());
|
||||
}
|
||||
else if (this.type == boolean.class){
|
||||
this.options = ImmutableList.of("true","false");
|
||||
this.options = List.of("true","false");
|
||||
}
|
||||
else if(this.type == String.class && categories.contains(RuleCategory.COMMAND))
|
||||
{
|
||||
this.options = ImmutableList.of("true", "false", "ops");
|
||||
this.options = List.of("true", "false", "ops");
|
||||
}
|
||||
else if (this.type.isEnum())
|
||||
{
|
||||
this.options = Arrays.stream(this.type.getEnumConstants()).map(e -> ((Enum) e).name().toLowerCase(Locale.ROOT)).collect(ImmutableList.toImmutableList());
|
||||
this.options = Arrays.stream(this.type.getEnumConstants()).map(e -> ((Enum) e).name().toLowerCase(Locale.ROOT)).collect(Collectors.toUnmodifiableList());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.options = ImmutableList.of();
|
||||
this.options = List.of();
|
||||
}
|
||||
if (isStrict && !this.options.isEmpty())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user