Add option default value for list type.

This commit is contained in:
bloodshot 2019-12-31 04:19:04 -05:00
parent 091106308b
commit 0ec94bb2cb
2 changed files with 9 additions and 1 deletions

View File

@ -26,7 +26,6 @@
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.permission.Context;
import com.griefdefender.api.permission.option.Option;
import com.griefdefender.api.permission.option.type.CreateModeType;
import com.griefdefender.api.permission.option.type.CreateModeTypes;
@ -38,6 +37,7 @@
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@ -141,6 +141,7 @@ public void reloadDescription() {
this.description = null;
}
@SuppressWarnings("unchecked")
@Override
public T getDefaultValue() {
if (this.allowed.isAssignableFrom(Tristate.class)) {
@ -158,6 +159,9 @@ public T getDefaultValue() {
if (this.allowed.isAssignableFrom(Boolean.class)) {
return (T) Boolean.FALSE;
}
if (this.allowed.isAssignableFrom(List.class)) {
return (T) new ArrayList<>();
}
if (this.allowed.isAssignableFrom(CreateModeType.class)) {
return (T) CreateModeTypes.AREA;
}

View File

@ -37,6 +37,7 @@
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@ -158,6 +159,9 @@ public T getDefaultValue() {
if (this.allowed.isAssignableFrom(Boolean.class)) {
return (T) Boolean.FALSE;
}
if (this.allowed.isAssignableFrom(List.class)) {
return (T) new ArrayList<>();
}
if (this.allowed.isAssignableFrom(CreateModeType.class)) {
return (T) CreateModeTypes.AREA;
}