mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-25 12:45:48 +01:00
Add option default value for list type.
This commit is contained in:
parent
091106308b
commit
0ec94bb2cb
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
import com.griefdefender.GriefDefenderPlugin;
|
import com.griefdefender.GriefDefenderPlugin;
|
||||||
import com.griefdefender.api.Tristate;
|
import com.griefdefender.api.Tristate;
|
||||||
import com.griefdefender.api.permission.Context;
|
|
||||||
import com.griefdefender.api.permission.option.Option;
|
import com.griefdefender.api.permission.option.Option;
|
||||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||||
import com.griefdefender.api.permission.option.type.CreateModeTypes;
|
import com.griefdefender.api.permission.option.type.CreateModeTypes;
|
||||||
@ -38,6 +37,7 @@
|
|||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -141,6 +141,7 @@ public void reloadDescription() {
|
|||||||
this.description = null;
|
this.description = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public T getDefaultValue() {
|
public T getDefaultValue() {
|
||||||
if (this.allowed.isAssignableFrom(Tristate.class)) {
|
if (this.allowed.isAssignableFrom(Tristate.class)) {
|
||||||
@ -158,6 +159,9 @@ public T getDefaultValue() {
|
|||||||
if (this.allowed.isAssignableFrom(Boolean.class)) {
|
if (this.allowed.isAssignableFrom(Boolean.class)) {
|
||||||
return (T) Boolean.FALSE;
|
return (T) Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
if (this.allowed.isAssignableFrom(List.class)) {
|
||||||
|
return (T) new ArrayList<>();
|
||||||
|
}
|
||||||
if (this.allowed.isAssignableFrom(CreateModeType.class)) {
|
if (this.allowed.isAssignableFrom(CreateModeType.class)) {
|
||||||
return (T) CreateModeTypes.AREA;
|
return (T) CreateModeTypes.AREA;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -158,6 +159,9 @@ public T getDefaultValue() {
|
|||||||
if (this.allowed.isAssignableFrom(Boolean.class)) {
|
if (this.allowed.isAssignableFrom(Boolean.class)) {
|
||||||
return (T) Boolean.FALSE;
|
return (T) Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
if (this.allowed.isAssignableFrom(List.class)) {
|
||||||
|
return (T) new ArrayList<>();
|
||||||
|
}
|
||||||
if (this.allowed.isAssignableFrom(CreateModeType.class)) {
|
if (this.allowed.isAssignableFrom(CreateModeType.class)) {
|
||||||
return (T) CreateModeTypes.AREA;
|
return (T) CreateModeTypes.AREA;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user