mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-09-28 04:37:35 +02:00
Implement FlagDefinition API.
This commit is contained in:
parent
3f8156836e
commit
75fbcebb58
@ -1 +1 @@
|
|||||||
Subproject commit f9fd13652a4c257565dd766fdbbc934aad738e51
|
Subproject commit 85fca6156bc71b67199ff1bec1ceb14ee184cb12
|
@ -68,6 +68,8 @@
|
|||||||
import com.griefdefender.api.claim.TrustType;
|
import com.griefdefender.api.claim.TrustType;
|
||||||
import com.griefdefender.api.economy.BankTransaction;
|
import com.griefdefender.api.economy.BankTransaction;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
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.GameModeType;
|
import com.griefdefender.api.permission.option.type.GameModeType;
|
||||||
@ -155,7 +157,7 @@
|
|||||||
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
|
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
|
||||||
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
|
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
|
||||||
import com.griefdefender.configuration.serializer.CreateModeTypeSerializer;
|
import com.griefdefender.configuration.serializer.CreateModeTypeSerializer;
|
||||||
import com.griefdefender.configuration.serializer.CustomFlagSerializer;
|
import com.griefdefender.configuration.serializer.FlagDefinitionSerializer;
|
||||||
import com.griefdefender.configuration.serializer.GameModeTypeSerializer;
|
import com.griefdefender.configuration.serializer.GameModeTypeSerializer;
|
||||||
import com.griefdefender.configuration.serializer.WeatherTypeSerializer;
|
import com.griefdefender.configuration.serializer.WeatherTypeSerializer;
|
||||||
import com.griefdefender.configuration.type.ConfigBase;
|
import com.griefdefender.configuration.type.ConfigBase;
|
||||||
@ -183,7 +185,8 @@
|
|||||||
import com.griefdefender.permission.GDPermissionHolder;
|
import com.griefdefender.permission.GDPermissionHolder;
|
||||||
import com.griefdefender.permission.GDPermissionManager;
|
import com.griefdefender.permission.GDPermissionManager;
|
||||||
import com.griefdefender.permission.GDPermissionUser;
|
import com.griefdefender.permission.GDPermissionUser;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagData;
|
||||||
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.permission.flag.GDFlags;
|
import com.griefdefender.permission.flag.GDFlags;
|
||||||
import com.griefdefender.provider.DynmapProvider;
|
import com.griefdefender.provider.DynmapProvider;
|
||||||
import com.griefdefender.provider.EssentialsProvider;
|
import com.griefdefender.provider.EssentialsProvider;
|
||||||
@ -194,6 +197,7 @@
|
|||||||
import com.griefdefender.registry.ChatTypeRegistryModule;
|
import com.griefdefender.registry.ChatTypeRegistryModule;
|
||||||
import com.griefdefender.registry.ClaimTypeRegistryModule;
|
import com.griefdefender.registry.ClaimTypeRegistryModule;
|
||||||
import com.griefdefender.registry.CreateModeTypeRegistryModule;
|
import com.griefdefender.registry.CreateModeTypeRegistryModule;
|
||||||
|
import com.griefdefender.registry.FlagDefinitionRegistryModule;
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
import com.griefdefender.registry.FlagRegistryModule;
|
||||||
import com.griefdefender.registry.GameModeTypeRegistryModule;
|
import com.griefdefender.registry.GameModeTypeRegistryModule;
|
||||||
import com.griefdefender.registry.OptionRegistryModule;
|
import com.griefdefender.registry.OptionRegistryModule;
|
||||||
@ -413,6 +417,7 @@ public void onEnable() {
|
|||||||
ShovelTypeRegistryModule.getInstance().registerDefaults();
|
ShovelTypeRegistryModule.getInstance().registerDefaults();
|
||||||
TrustTypeRegistryModule.getInstance().registerDefaults();
|
TrustTypeRegistryModule.getInstance().registerDefaults();
|
||||||
FlagRegistryModule.getInstance().registerDefaults();
|
FlagRegistryModule.getInstance().registerDefaults();
|
||||||
|
FlagDefinitionRegistryModule.getInstance().registerDefaults();
|
||||||
ResultTypeRegistryModule.getInstance().registerDefaults();
|
ResultTypeRegistryModule.getInstance().registerDefaults();
|
||||||
EntityTypeRegistryModule.getInstance().registerDefaults();
|
EntityTypeRegistryModule.getInstance().registerDefaults();
|
||||||
BlockTypeRegistryModule.getInstance().registerDefaults();
|
BlockTypeRegistryModule.getInstance().registerDefaults();
|
||||||
@ -421,8 +426,10 @@ public void onEnable() {
|
|||||||
GameModeTypeRegistryModule.getInstance().registerDefaults();
|
GameModeTypeRegistryModule.getInstance().registerDefaults();
|
||||||
WeatherTypeRegistryModule.getInstance().registerDefaults();
|
WeatherTypeRegistryModule.getInstance().registerDefaults();
|
||||||
OptionRegistryModule.getInstance().registerDefaults();
|
OptionRegistryModule.getInstance().registerDefaults();
|
||||||
GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
|
|
||||||
GriefDefender.getRegistry().registerBuilderSupplier(BankTransaction.Builder.class, GDBankTransaction.BankTransactionBuilder::new);
|
GriefDefender.getRegistry().registerBuilderSupplier(BankTransaction.Builder.class, GDBankTransaction.BankTransactionBuilder::new);
|
||||||
|
GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
|
||||||
|
GriefDefender.getRegistry().registerBuilderSupplier(FlagData.Builder.class, GDFlagData.FlagDataBuilder::new);
|
||||||
|
GriefDefender.getRegistry().registerBuilderSupplier(FlagDefinition.Builder.class, GDFlagDefinition.FlagDefinitionBuilder::new);
|
||||||
|
|
||||||
this.loadConfig();
|
this.loadConfig();
|
||||||
|
|
||||||
@ -821,9 +828,9 @@ public void loadConfig() {
|
|||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Component.class), new ComponentConfigSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Component.class), new ComponentConfigSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ClaimType.class), new ClaimTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ClaimType.class), new ClaimTypeSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(CreateModeType.class), new CreateModeTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(CreateModeType.class), new CreateModeTypeSerializer());
|
||||||
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(FlagDefinition.class), new FlagDefinitionSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GameModeType.class), new GameModeTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GameModeType.class), new GameModeTypeSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(WeatherType.class), new WeatherTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(WeatherType.class), new WeatherTypeSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GDCustomFlagDefinition.class), new CustomFlagSerializer());
|
|
||||||
|
|
||||||
if (Files.notExists(BaseStorage.dataLayerFolderPath)) {
|
if (Files.notExists(BaseStorage.dataLayerFolderPath)) {
|
||||||
Files.createDirectories(BaseStorage.dataLayerFolderPath);
|
Files.createDirectories(BaseStorage.dataLayerFolderPath);
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.griefdefender.GDPlayerData;
|
import com.griefdefender.GDPlayerData;
|
||||||
import com.griefdefender.GriefDefenderPlugin;
|
import com.griefdefender.GriefDefenderPlugin;
|
||||||
import com.griefdefender.api.GriefDefender;
|
import com.griefdefender.api.GriefDefender;
|
||||||
@ -41,7 +40,7 @@
|
|||||||
import com.griefdefender.api.permission.PermissionResult;
|
import com.griefdefender.api.permission.PermissionResult;
|
||||||
import com.griefdefender.api.permission.ResultTypes;
|
import com.griefdefender.api.permission.ResultTypes;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
import com.griefdefender.cache.MessageCache;
|
import com.griefdefender.cache.MessageCache;
|
||||||
import com.griefdefender.cache.PermissionHolderCache;
|
import com.griefdefender.cache.PermissionHolderCache;
|
||||||
import com.griefdefender.claim.GDClaim;
|
import com.griefdefender.claim.GDClaim;
|
||||||
@ -55,14 +54,12 @@
|
|||||||
import com.griefdefender.permission.GDPermissionManager;
|
import com.griefdefender.permission.GDPermissionManager;
|
||||||
import com.griefdefender.permission.GDPermissionUser;
|
import com.griefdefender.permission.GDPermissionUser;
|
||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.GDPermissions;
|
||||||
import com.griefdefender.permission.flag.CustomFlagData;
|
|
||||||
import com.griefdefender.permission.flag.GDActiveFlagData;
|
import com.griefdefender.permission.flag.GDActiveFlagData;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.permission.ui.ClaimClickData;
|
import com.griefdefender.permission.ui.UIFlagData;
|
||||||
import com.griefdefender.permission.ui.FlagData;
|
|
||||||
import com.griefdefender.permission.ui.MenuType;
|
import com.griefdefender.permission.ui.MenuType;
|
||||||
import com.griefdefender.permission.ui.UIHelper;
|
import com.griefdefender.permission.ui.UIHelper;
|
||||||
import com.griefdefender.permission.ui.FlagData.FlagContextHolder;
|
import com.griefdefender.permission.ui.UIFlagData.FlagContextHolder;
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
import com.griefdefender.registry.FlagRegistryModule;
|
||||||
import com.griefdefender.text.action.GDCallbackHolder;
|
import com.griefdefender.text.action.GDCallbackHolder;
|
||||||
import com.griefdefender.util.CauseContextHelper;
|
import com.griefdefender.util.CauseContextHelper;
|
||||||
@ -239,7 +236,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
for (GDCustomFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
||||||
Component flagText = TextComponent.builder()
|
Component flagText = TextComponent.builder()
|
||||||
.append(getCustomFlagText(customFlag))
|
.append(getCustomFlagText(customFlag))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
@ -388,7 +385,7 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
|
|||||||
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
|
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
|
||||||
overrideContexts.add(claim.getOverrideClaimContext());
|
overrideContexts.add(claim.getOverrideClaimContext());
|
||||||
|
|
||||||
Map<String, FlagData> filteredContextMap = new HashMap<>();
|
Map<String, UIFlagData> filteredContextMap = new HashMap<>();
|
||||||
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getTransientPermissions(this.subject).entrySet()) {
|
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getTransientPermissions(this.subject).entrySet()) {
|
||||||
final Set<Context> contextSet = mapEntry.getKey();
|
final Set<Context> contextSet = mapEntry.getKey();
|
||||||
if (contextSet.contains(claim.getDefaultTypeContext())) {
|
if (contextSet.contains(claim.getDefaultTypeContext())) {
|
||||||
@ -429,8 +426,8 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
|
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
|
||||||
for (Entry<String, FlagData> mapEntry : filteredContextMap.entrySet()) {
|
for (Entry<String, UIFlagData> mapEntry : filteredContextMap.entrySet()) {
|
||||||
final FlagData flagData = mapEntry.getValue();
|
final UIFlagData flagData = mapEntry.getValue();
|
||||||
final Flag flag = flagData.flag;
|
final Flag flag = flagData.flag;
|
||||||
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
|
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
|
||||||
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
|
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
|
||||||
@ -494,25 +491,25 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
|
|||||||
paginationList.sendTo(player, activePage);
|
paginationList.sendTo(player, activePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFilteredContexts(Map<String, FlagData> filteredContextMap, Set<Context> contexts, MenuType type, Map<String, Boolean> permissions) {
|
private void addFilteredContexts(Map<String, UIFlagData> filteredContextMap, Set<Context> contexts, MenuType type, Map<String, Boolean> permissions) {
|
||||||
for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) {
|
for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) {
|
||||||
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
|
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final FlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
final UIFlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
||||||
if (flagData != null) {
|
if (flagData != null) {
|
||||||
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
|
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
|
||||||
} else {
|
} else {
|
||||||
filteredContextMap.put(permissionEntry.getKey(), new FlagData(flag, permissionEntry.getValue(), type, contexts));
|
filteredContextMap.put(permissionEntry.getKey(), new UIFlagData(flag, permissionEntry.getValue(), type, contexts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getCustomFlagText(GDCustomFlagDefinition customFlag) {
|
private Component getCustomFlagText(GDFlagDefinition customFlag) {
|
||||||
TextComponent definitionType = TextComponent.empty();
|
TextComponent definitionType = TextComponent.empty();
|
||||||
TextColor flagColor = TextColor.GREEN;
|
TextColor flagColor = TextColor.GREEN;
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("default")) {
|
if (context.getKey().contains("default")) {
|
||||||
definitionType = TextComponent.builder()
|
definitionType = TextComponent.builder()
|
||||||
.append("\n")
|
.append("\n")
|
||||||
@ -544,7 +541,7 @@ private Component getCustomFlagText(GDCustomFlagDefinition customFlag) {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
final Component baseFlagText = TextComponent.builder()
|
final Component baseFlagText = TextComponent.builder()
|
||||||
.append(customFlag.getDisplayName(), flagColor)
|
.append(customFlag.getName(), flagColor)
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.hoverEvent(HoverEvent.showText(TextComponent.builder()
|
.hoverEvent(HoverEvent.showText(TextComponent.builder()
|
||||||
.append(customFlag.getDescription())
|
.append(customFlag.getDescription())
|
||||||
@ -553,9 +550,9 @@ private Component getCustomFlagText(GDCustomFlagDefinition customFlag) {
|
|||||||
return baseFlagText;
|
return baseFlagText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextColor getCustomFlagColor(GDCustomFlagDefinition customFlag) {
|
private TextColor getCustomFlagColor(GDFlagDefinition customFlag) {
|
||||||
TextColor flagColor = TextColor.GREEN;
|
TextColor flagColor = TextColor.GREEN;
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("default")) {
|
if (context.getKey().contains("default")) {
|
||||||
flagColor = TextColor.LIGHT_PURPLE;
|
flagColor = TextColor.LIGHT_PURPLE;
|
||||||
break;
|
break;
|
||||||
@ -577,7 +574,7 @@ private Component getFlagText(Flag flag, Set<Context> contexts) {
|
|||||||
return baseFlagText;
|
return baseFlagText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GDCustomFlagDefinition customFlag, String flagGroup) {
|
private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, String flagGroup) {
|
||||||
boolean hasHover = false;
|
boolean hasHover = false;
|
||||||
TextComponent.Builder hoverBuilder = TextComponent.builder();
|
TextComponent.Builder hoverBuilder = TextComponent.builder();
|
||||||
final Player player = src.getOnlinePlayer();
|
final Player player = src.getOnlinePlayer();
|
||||||
@ -592,7 +589,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
|
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
|
||||||
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
|
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
|
||||||
// check flag perm
|
// check flag perm
|
||||||
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getDisplayName())) {
|
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getName())) {
|
||||||
hoverBuilder.append(MessageCache.getInstance().PERMISSION_FLAG_USE).append("\n");
|
hoverBuilder.append(MessageCache.getInstance().PERMISSION_FLAG_USE).append("\n");
|
||||||
hasEditPermission = false;
|
hasEditPermission = false;
|
||||||
hasHover = true;
|
hasHover = true;
|
||||||
@ -600,8 +597,8 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
|
|
||||||
List<GDActiveFlagData> dataResults = new ArrayList<>();
|
List<GDActiveFlagData> dataResults = new ArrayList<>();
|
||||||
boolean hasGDContext = false;
|
boolean hasGDContext = false;
|
||||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("gd_claim")) {
|
if (context.getKey().contains("gd_claim")) {
|
||||||
hasGDContext = true;
|
hasGDContext = true;
|
||||||
break;
|
break;
|
||||||
@ -610,7 +607,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
if (!hasGDContext) {
|
if (!hasGDContext) {
|
||||||
definitionContexts.add(claim.getContext());
|
definitionContexts.add(claim.getContext());
|
||||||
}
|
}
|
||||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
for (FlagData flagData : customFlag.getFlagData()) {
|
||||||
final Set<Context> filteredContexts = new HashSet<>();
|
final Set<Context> filteredContexts = new HashSet<>();
|
||||||
for (Context context : definitionContexts) {
|
for (Context context : definitionContexts) {
|
||||||
if (context.getKey().contains("gd_claim")) {
|
if (context.getKey().contains("gd_claim")) {
|
||||||
@ -698,11 +695,11 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE);
|
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!customFlag.getDefinitionContexts().isEmpty()) {
|
if (!customFlag.getContexts().isEmpty()) {
|
||||||
hoverBuilder.append("\nContexts: ");
|
hoverBuilder.append("\nContexts: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
hoverBuilder.append("\n");
|
hoverBuilder.append("\n");
|
||||||
final String key = context.getKey();
|
final String key = context.getKey();
|
||||||
final String value = context.getValue();
|
final String value = context.getValue();
|
||||||
@ -887,13 +884,13 @@ public int compare(Context o1, Context o2) {
|
|||||||
return textBuilder.build();
|
return textBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDCustomFlagDefinition customFlag, Tristate currentValue, String displayType) {
|
private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, Tristate currentValue, String displayType) {
|
||||||
final Player player = src.getOnlinePlayer();
|
final Player player = src.getOnlinePlayer();
|
||||||
return consumer -> {
|
return consumer -> {
|
||||||
GDCauseStackManager.getInstance().pushCause(player);
|
GDCauseStackManager.getInstance().pushCause(player);
|
||||||
boolean hasGDContext = false;
|
boolean hasGDContext = false;
|
||||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("gd_claim")) {
|
if (context.getKey().contains("gd_claim")) {
|
||||||
hasGDContext = true;
|
hasGDContext = true;
|
||||||
break;
|
break;
|
||||||
@ -902,7 +899,7 @@ private Consumer<CommandSender> createCustomFlagConsumer(GDPermissionUser src, G
|
|||||||
if (!hasGDContext) {
|
if (!hasGDContext) {
|
||||||
definitionContexts.add(claim.getContext());
|
definitionContexts.add(claim.getContext());
|
||||||
}
|
}
|
||||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
for (FlagData flagData : customFlag.getFlagData()) {
|
||||||
final Set<Context> newContexts = new HashSet<>(definitionContexts);
|
final Set<Context> newContexts = new HashSet<>(definitionContexts);
|
||||||
newContexts.addAll(flagData.getContexts());
|
newContexts.addAll(flagData.getContexts());
|
||||||
Tristate newValue = Tristate.UNDEFINED;
|
Tristate newValue = Tristate.UNDEFINED;
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
import com.griefdefender.api.claim.ClaimContexts;
|
import com.griefdefender.api.claim.ClaimContexts;
|
||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
import com.griefdefender.api.permission.ContextKeys;
|
import com.griefdefender.api.permission.ContextKeys;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
|
||||||
import com.griefdefender.api.permission.option.Option;
|
import com.griefdefender.api.permission.option.Option;
|
||||||
import com.griefdefender.api.permission.option.Options;
|
import com.griefdefender.api.permission.option.Options;
|
||||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||||
@ -60,13 +58,10 @@
|
|||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.GDPermissions;
|
||||||
import com.griefdefender.permission.option.GDOption;
|
import com.griefdefender.permission.option.GDOption;
|
||||||
import com.griefdefender.permission.ui.ClaimClickData;
|
import com.griefdefender.permission.ui.ClaimClickData;
|
||||||
import com.griefdefender.permission.ui.FlagData;
|
|
||||||
import com.griefdefender.permission.ui.MenuType;
|
import com.griefdefender.permission.ui.MenuType;
|
||||||
import com.griefdefender.permission.ui.OptionData;
|
import com.griefdefender.permission.ui.OptionData;
|
||||||
import com.griefdefender.permission.ui.OptionData.OptionContextHolder;
|
import com.griefdefender.permission.ui.OptionData.OptionContextHolder;
|
||||||
import com.griefdefender.permission.ui.UIHelper;
|
import com.griefdefender.permission.ui.UIHelper;
|
||||||
import com.griefdefender.permission.ui.FlagData.FlagContextHolder;
|
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
|
||||||
import com.griefdefender.registry.OptionRegistryModule;
|
import com.griefdefender.registry.OptionRegistryModule;
|
||||||
import com.griefdefender.text.action.GDCallbackHolder;
|
import com.griefdefender.text.action.GDCallbackHolder;
|
||||||
import com.griefdefender.util.CauseContextHelper;
|
import com.griefdefender.util.CauseContextHelper;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
@ -48,9 +48,9 @@ public class CustomFlagGroupCategory extends ConfigCategory {
|
|||||||
@Setting(value = "hover", comment = "The hover text to be displayed when hovering over group name in GUI.")
|
@Setting(value = "hover", comment = "The hover text to be displayed when hovering over group name in GUI.")
|
||||||
Component hoverText = TextComponent.empty();
|
Component hoverText = TextComponent.empty();
|
||||||
@Setting
|
@Setting
|
||||||
Map<String, GDCustomFlagDefinition> definitions = new HashMap<>();
|
Map<String, GDFlagDefinition> definitions = new HashMap<>();
|
||||||
|
|
||||||
public Map<String, GDCustomFlagDefinition> getFlagDefinitions() {
|
public Map<String, GDFlagDefinition> getFlagDefinitions() {
|
||||||
return this.definitions;
|
return this.definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,8 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.griefdefender.api.claim.ClaimContexts;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinitions;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinitions;
|
|
||||||
|
|
||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
@ -51,8 +50,8 @@ public void initDefaults() {
|
|||||||
userGroup = new CustomFlagGroupCategory();
|
userGroup = new CustomFlagGroupCategory();
|
||||||
}
|
}
|
||||||
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
|
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
|
||||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.USER_FLAGS) {
|
for (GDFlagDefinition definition : GDFlagDefinitions.USER_FLAGS) {
|
||||||
userGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
userGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||||
}
|
}
|
||||||
this.groups.put("user", userGroup);
|
this.groups.put("user", userGroup);
|
||||||
}
|
}
|
||||||
@ -60,8 +59,8 @@ public void initDefaults() {
|
|||||||
adminGroup = new CustomFlagGroupCategory();
|
adminGroup = new CustomFlagGroupCategory();
|
||||||
}
|
}
|
||||||
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
|
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
|
||||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.ADMIN_FLAGS) {
|
for (GDFlagDefinition definition : GDFlagDefinitions.ADMIN_FLAGS) {
|
||||||
adminGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
adminGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||||
}
|
}
|
||||||
adminGroup.isAdmin = true;
|
adminGroup.isAdmin = true;
|
||||||
this.groups.put("admin", adminGroup);
|
this.groups.put("admin", adminGroup);
|
||||||
|
@ -34,8 +34,10 @@
|
|||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
import com.griefdefender.api.permission.ContextKeys;
|
import com.griefdefender.api.permission.ContextKeys;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
import com.griefdefender.permission.flag.CustomFlagData;
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
|
import com.griefdefender.permission.flag.GDFlagData;
|
||||||
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
import com.griefdefender.registry.FlagRegistryModule;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
@ -45,10 +47,10 @@
|
|||||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||||
|
|
||||||
public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefinition> {
|
public class FlagDefinitionSerializer implements TypeSerializer<FlagDefinition> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
|
public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
|
||||||
final String flagDisplayName = node.getKey().toString();
|
final String flagDisplayName = node.getKey().toString();
|
||||||
final boolean enabled = node.getNode("enabled").getBoolean();
|
final boolean enabled = node.getNode("enabled").getBoolean();
|
||||||
final String descr = node.getNode("description").getString();
|
final String descr = node.getNode("description").getString();
|
||||||
@ -63,7 +65,7 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
throw new ObjectMappingException("No permissions found for flag definition '" + flagDisplayName + "'. You must specify at least 1 or more permissions.");
|
throw new ObjectMappingException("No permissions found for flag definition '" + flagDisplayName + "'. You must specify at least 1 or more permissions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CustomFlagData> flagDataList = new ArrayList<>();
|
List<FlagData> flagDataList = new ArrayList<>();
|
||||||
for (String permissionEntry : permissionList) {
|
for (String permissionEntry : permissionList) {
|
||||||
String permission = permissionEntry.replace(" ", "");
|
String permission = permissionEntry.replace(" ", "");
|
||||||
String[] parts = permission.split(",");
|
String[] parts = permission.split(",");
|
||||||
@ -106,9 +108,9 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
throw new ObjectMappingException("No linked flag specified. You need to specify 'flag=<flagname>'.");
|
throw new ObjectMappingException("No linked flag specified. You need to specify 'flag=<flagname>'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
flagDataList.add(new CustomFlagData(linkedFlag, flagContexts));
|
flagDataList.add(new GDFlagData(linkedFlag, flagContexts));
|
||||||
}
|
}
|
||||||
final GDCustomFlagDefinition flagDefinition = new GDCustomFlagDefinition(flagDataList, flagDisplayName, description);
|
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description);
|
||||||
flagDefinition.setIsEnabled(enabled);
|
flagDefinition.setIsEnabled(enabled);
|
||||||
Set<Context> contexts = new HashSet<>();
|
Set<Context> contexts = new HashSet<>();
|
||||||
if (contextList != null) {
|
if (contextList != null) {
|
||||||
@ -130,9 +132,8 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
|
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
|
||||||
// try UUID
|
// try UUID
|
||||||
if (value.length() == 36) {
|
if (value.length() == 36) {
|
||||||
UUID uuid = null;
|
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(value);
|
UUID.fromString(value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
|
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
|
||||||
}
|
}
|
||||||
@ -145,13 +146,13 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
contexts.add(new Context(key, value));
|
contexts.add(new Context(key, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flagDefinition.setDefinitionContexts(contexts);
|
flagDefinition.setContexts(contexts);
|
||||||
}
|
}
|
||||||
return flagDefinition;
|
return flagDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(TypeToken<?> type, GDCustomFlagDefinition obj, ConfigurationNode node) throws ObjectMappingException {
|
public void serialize(TypeToken<?> type, FlagDefinition obj, ConfigurationNode node) throws ObjectMappingException {
|
||||||
node.getNode("enabled").setValue(obj.isEnabled());
|
node.getNode("enabled").setValue(obj.isEnabled());
|
||||||
String description = "";
|
String description = "";
|
||||||
if (obj.getDescription() != TextComponent.empty()) {
|
if (obj.getDescription() != TextComponent.empty()) {
|
||||||
@ -159,17 +160,17 @@ public void serialize(TypeToken<?> type, GDCustomFlagDefinition obj, Configurati
|
|||||||
node.getNode("description").setValue(description);
|
node.getNode("description").setValue(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj.getDefinitionContexts().isEmpty()) {
|
if (!obj.getContexts().isEmpty()) {
|
||||||
List<String> contextList = new ArrayList<>();
|
List<String> contextList = new ArrayList<>();
|
||||||
ConfigurationNode contextNode = node.getNode("contexts");
|
ConfigurationNode contextNode = node.getNode("contexts");
|
||||||
for (Context context : obj.getDefinitionContexts()) {
|
for (Context context : obj.getContexts()) {
|
||||||
contextList.add(context.getKey().toLowerCase() + "=" + context.getValue().toLowerCase());
|
contextList.add(context.getKey().toLowerCase() + "=" + context.getValue().toLowerCase());
|
||||||
}
|
}
|
||||||
contextNode.setValue(contextList);
|
contextNode.setValue(contextList);
|
||||||
}
|
}
|
||||||
ConfigurationNode permissionNode = node.getNode("permissions");
|
ConfigurationNode permissionNode = node.getNode("permissions");
|
||||||
List<String> permissions = new ArrayList<>();
|
List<String> permissions = new ArrayList<>();
|
||||||
for (CustomFlagData flagData : obj.getFlagData()) {
|
for (FlagData flagData : obj.getFlagData()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
final Flag flag = flagData.getFlag();
|
final Flag flag = flagData.getFlag();
|
||||||
final Set<Context> dataContexts = flagData.getContexts();
|
final Set<Context> dataContexts = flagData.getContexts();
|
@ -42,6 +42,8 @@
|
|||||||
import com.griefdefender.api.permission.PermissionResult;
|
import com.griefdefender.api.permission.PermissionResult;
|
||||||
import com.griefdefender.api.permission.ResultTypes;
|
import com.griefdefender.api.permission.ResultTypes;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
import com.griefdefender.api.permission.flag.Flags;
|
||||||
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;
|
||||||
@ -1270,4 +1272,24 @@ public <T> T getActiveOptionValue(TypeToken<T> type, Option<T> option, Subject s
|
|||||||
Set<Context> contexts) {
|
Set<Context> contexts) {
|
||||||
return this.getInternalOptionValue(type, (GDPermissionHolder) subject, option, claim, claim.getType(), contexts);
|
return this.getInternalOptionValue(type, (GDPermissionHolder) subject, option, claim, claim.getType(), contexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<PermissionResult> setFlagDefinition(Subject subject, FlagDefinition flagDefinition, Tristate value) {
|
||||||
|
final Set<Context> contexts = new HashSet<>();
|
||||||
|
contexts.addAll(flagDefinition.getContexts());
|
||||||
|
PermissionResult result = null;
|
||||||
|
CompletableFuture<PermissionResult> future = new CompletableFuture<>();
|
||||||
|
for (FlagData flagData : flagDefinition.getFlagData()) {
|
||||||
|
final Set<Context> flagContexts = new HashSet<>(contexts);
|
||||||
|
flagContexts.addAll(flagData.getContexts());
|
||||||
|
result = PermissionUtil.getInstance().setPermissionValue((GDPermissionHolder) subject, flagData.getFlag(), value, flagContexts);
|
||||||
|
if (!result.successful()) {
|
||||||
|
future.complete(result);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
future.complete(result);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
import com.griefdefender.api.Tristate;
|
import com.griefdefender.api.Tristate;
|
||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
@ -40,17 +41,17 @@ public enum Type {
|
|||||||
UNDEFINED
|
UNDEFINED
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CustomFlagData flagData;
|
private final FlagData flagData;
|
||||||
private final Tristate value;
|
private final Tristate value;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
public GDActiveFlagData(CustomFlagData flagData, Tristate value, Type type) {
|
public GDActiveFlagData(FlagData flagData, Tristate value, Type type) {
|
||||||
this.flagData = flagData;
|
this.flagData = flagData;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomFlagData getFlagData() {
|
public FlagData getFlagData() {
|
||||||
return this.flagData;
|
return this.flagData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) bloodmc
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.griefdefender.permission.flag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.griefdefender.GriefDefenderPlugin;
|
|
||||||
import com.griefdefender.api.Tristate;
|
|
||||||
import com.griefdefender.api.permission.Context;
|
|
||||||
import com.griefdefender.api.permission.PermissionResult;
|
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
|
||||||
import com.griefdefender.claim.GDClaim;
|
|
||||||
import com.griefdefender.configuration.category.CustomFlagGroupCategory;
|
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
|
||||||
import net.kyori.text.TextComponent;
|
|
||||||
import net.kyori.text.format.TextColor;
|
|
||||||
|
|
||||||
public class GDCustomFlagDefinition {
|
|
||||||
|
|
||||||
private boolean enabled = true;
|
|
||||||
private Set<Context> definitionContexts = new HashSet<>();
|
|
||||||
private List<CustomFlagData> data = new ArrayList<>();
|
|
||||||
private String displayName;
|
|
||||||
private Tristate defaultValue = Tristate.UNDEFINED;
|
|
||||||
private Component description;
|
|
||||||
|
|
||||||
public GDCustomFlagDefinition(Flag flag, Set<Context> contexts, String displayName, Component description) {
|
|
||||||
this.data.add(new CustomFlagData(flag, contexts));
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GDCustomFlagDefinition(List<CustomFlagData> flagData, String displayName, Component description) {
|
|
||||||
this.data = flagData;
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFlagData(Flag flag, Set<Context> contexts) {
|
|
||||||
this.data.add(new CustomFlagData(flag, contexts));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Flag> getFlags() {
|
|
||||||
List<Flag> flags = new ArrayList<>();
|
|
||||||
for (CustomFlagData flagData : this.data) {
|
|
||||||
flags.add(flagData.getFlag());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CustomFlagData> getFlagData() {
|
|
||||||
return this.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getDescription() {
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Context> getDefinitionContexts() {
|
|
||||||
return this.definitionContexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefinitionContexts(Set<Context> contexts) {
|
|
||||||
this.definitionContexts = contexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
return this.displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return this.enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultValue(Tristate value) {
|
|
||||||
this.defaultValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsEnabled(boolean val) {
|
|
||||||
this.enabled = val;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,415 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) bloodmc
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.griefdefender.permission.flag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.griefdefender.api.Tristate;
|
|
||||||
import com.griefdefender.api.claim.ClaimContexts;
|
|
||||||
import com.griefdefender.api.permission.Context;
|
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
|
||||||
import com.griefdefender.cache.MessageCache;
|
|
||||||
import com.griefdefender.event.GDCauseStackManager;
|
|
||||||
|
|
||||||
public class GDCustomFlagDefinitions {
|
|
||||||
|
|
||||||
// ADMIN
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_BREAK;
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_GROW;
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_PLACE;
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_SPREAD;
|
|
||||||
public static final GDCustomFlagDefinition ENDERPEARL;
|
|
||||||
public static final GDCustomFlagDefinition EXIT_PLAYER;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_BLOCK;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_ENTITY;
|
|
||||||
public static final GDCustomFlagDefinition EXP_DROP;
|
|
||||||
public static final GDCustomFlagDefinition FALL_DAMAGE;
|
|
||||||
public static final GDCustomFlagDefinition INTERACT_BLOCK;
|
|
||||||
public static final GDCustomFlagDefinition INTERACT_ENTITY;
|
|
||||||
public static final GDCustomFlagDefinition INTERACT_INVENTORY;
|
|
||||||
public static final GDCustomFlagDefinition INVINCIBLE;
|
|
||||||
public static final GDCustomFlagDefinition ITEM_DROP;
|
|
||||||
public static final GDCustomFlagDefinition ITEM_PICKUP;
|
|
||||||
public static final GDCustomFlagDefinition MONSTER_DAMAGE;
|
|
||||||
public static final GDCustomFlagDefinition PISTONS;
|
|
||||||
public static final GDCustomFlagDefinition PORTAL_USE;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_MONSTER;
|
|
||||||
public static final GDCustomFlagDefinition TELEPORT_FROM;
|
|
||||||
public static final GDCustomFlagDefinition TELEPORT_TO;
|
|
||||||
public static final GDCustomFlagDefinition USE;
|
|
||||||
public static final GDCustomFlagDefinition VEHICLE_DESTROY;
|
|
||||||
public static final GDCustomFlagDefinition WITHER_DAMAGE;
|
|
||||||
|
|
||||||
// USER
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_TRAMPLING;
|
|
||||||
public static final GDCustomFlagDefinition CHEST_ACCESS;
|
|
||||||
public static final GDCustomFlagDefinition CHORUS_FRUIT_TELEPORT;
|
|
||||||
public static final GDCustomFlagDefinition CROP_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition DAMAGE_ANIMALS;
|
|
||||||
public static final GDCustomFlagDefinition ENDERMAN_GRIEF;
|
|
||||||
public static final GDCustomFlagDefinition ENTER_PLAYER;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_CREEPER;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_TNT;
|
|
||||||
public static final GDCustomFlagDefinition FIRE_DAMAGE;
|
|
||||||
public static final GDCustomFlagDefinition FIRE_SPREAD;
|
|
||||||
public static final GDCustomFlagDefinition GRASS_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition ICE_FORM;
|
|
||||||
public static final GDCustomFlagDefinition ICE_MELT;
|
|
||||||
public static final GDCustomFlagDefinition LAVA_FLOW;
|
|
||||||
public static final GDCustomFlagDefinition LEAF_DECAY;
|
|
||||||
public static final GDCustomFlagDefinition LIGHTNING;
|
|
||||||
public static final GDCustomFlagDefinition LIGHTER;
|
|
||||||
public static final GDCustomFlagDefinition MUSHROOM_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition MYCELIUM_SPREAD;
|
|
||||||
public static final GDCustomFlagDefinition PVP;
|
|
||||||
public static final GDCustomFlagDefinition RIDE;
|
|
||||||
public static final GDCustomFlagDefinition SLEEP;
|
|
||||||
public static final GDCustomFlagDefinition SNOW_FALL;
|
|
||||||
public static final GDCustomFlagDefinition SNOW_MELT;
|
|
||||||
public static final GDCustomFlagDefinition SNOWMAN_TRAIL;
|
|
||||||
public static final GDCustomFlagDefinition SOIL_DRY;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_AMBIENT;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_ANIMAL;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_AQUATIC;
|
|
||||||
public static final GDCustomFlagDefinition VEHICLE_DESTROY_CLAIM;
|
|
||||||
public static final GDCustomFlagDefinition VEHICLE_PLACE;
|
|
||||||
public static final GDCustomFlagDefinition VINE_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition WATER_FLOW;
|
|
||||||
|
|
||||||
public static final List<GDCustomFlagDefinition> ADMIN_FLAGS = new ArrayList<>();
|
|
||||||
public static final List<GDCustomFlagDefinition> USER_FLAGS = new ArrayList<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
Set<Context> contexts = new HashSet<>();
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_BREAK = new GDCustomFlagDefinition(Flags.BLOCK_BREAK, contexts, "block-break", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_PLACE = new GDCustomFlagDefinition(Flags.BLOCK_PLACE, contexts, "block-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_GROW = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "block-grow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_SPREAD = new GDCustomFlagDefinition(Flags.BLOCK_SPREAD, contexts, "block-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD);
|
|
||||||
|
|
||||||
// ADMIN
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
|
||||||
ENDERPEARL = new GDCustomFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "enderpearl", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERPEARL);
|
|
||||||
ENDERPEARL.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
ENTER_PLAYER = new GDCustomFlagDefinition(Flags.ENTER_CLAIM, contexts, "enter-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
EXIT_PLAYER = new GDCustomFlagDefinition(Flags.ENTER_CLAIM, contexts, "exit-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
EXPLOSION_BLOCK = new GDCustomFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK);
|
|
||||||
EXPLOSION_BLOCK.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_CREEPER);
|
|
||||||
EXPLOSION_CREEPER = new GDCustomFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-creeper", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER);
|
|
||||||
EXPLOSION_CREEPER.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
EXPLOSION_ENTITY = new GDCustomFlagDefinition(Flags.EXPLOSION_ENTITY, contexts, "explosion-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY);
|
|
||||||
EXPLOSION_ENTITY.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_TNT);
|
|
||||||
EXPLOSION_TNT = new GDCustomFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-tnt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT);
|
|
||||||
EXPLOSION_TNT.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_XP_ORB);
|
|
||||||
EXP_DROP = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "exp-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_FALL);
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
FALL_DAMAGE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "fall-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
INTERACT_BLOCK = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "interact-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
INTERACT_ENTITY = new GDCustomFlagDefinition(Flags.INTERACT_ENTITY_SECONDARY, contexts, "interact-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
INTERACT_INVENTORY = new GDCustomFlagDefinition(Flags.INTERACT_INVENTORY, contexts, "interact-inventory", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
INVINCIBLE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "invincible", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INVINCIBLE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
ITEM_DROP = new GDCustomFlagDefinition(Flags.ITEM_DROP, contexts, "item-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_DROP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
ITEM_PICKUP = new GDCustomFlagDefinition(Flags.ITEM_PICKUP, contexts, "item-pickup", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
|
|
||||||
MONSTER_DAMAGE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "monster-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PISTON);
|
|
||||||
PISTONS = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "pistons", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTONS);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_PORTAL);
|
|
||||||
PORTAL_USE = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "portal-use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PORTAL_USE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
|
|
||||||
SPAWN_MONSTER = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-monster", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
TELEPORT_FROM = new GDCustomFlagDefinition(Flags.ENTITY_TELEPORT_FROM, contexts, "teleport-from", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
TELEPORT_TO = new GDCustomFlagDefinition(Flags.ENTITY_TELEPORT_TO, contexts, "teleport-to", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
VEHICLE_DESTROY = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
|
||||||
VEHICLE_DESTROY.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_WITHER);
|
|
||||||
WITHER_DAMAGE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "wither-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE);
|
|
||||||
WITHER_DAMAGE.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
ADMIN_FLAGS.add(BLOCK_BREAK);
|
|
||||||
ADMIN_FLAGS.add(BLOCK_PLACE);
|
|
||||||
ADMIN_FLAGS.add(BLOCK_GROW);
|
|
||||||
ADMIN_FLAGS.add(BLOCK_SPREAD);
|
|
||||||
ADMIN_FLAGS.add(ENDERPEARL);
|
|
||||||
ADMIN_FLAGS.add(ENTER_PLAYER);
|
|
||||||
ADMIN_FLAGS.add(EXIT_PLAYER);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_BLOCK);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_CREEPER);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_ENTITY);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_TNT);
|
|
||||||
ADMIN_FLAGS.add(EXP_DROP);
|
|
||||||
ADMIN_FLAGS.add(FALL_DAMAGE);
|
|
||||||
ADMIN_FLAGS.add(INTERACT_BLOCK);
|
|
||||||
ADMIN_FLAGS.add(INTERACT_ENTITY);
|
|
||||||
ADMIN_FLAGS.add(INTERACT_INVENTORY);
|
|
||||||
ADMIN_FLAGS.add(INVINCIBLE);
|
|
||||||
ADMIN_FLAGS.add(ITEM_DROP);
|
|
||||||
ADMIN_FLAGS.add(ITEM_PICKUP);
|
|
||||||
ADMIN_FLAGS.add(MONSTER_DAMAGE);
|
|
||||||
ADMIN_FLAGS.add(PISTONS);
|
|
||||||
ADMIN_FLAGS.add(SPAWN_MONSTER);
|
|
||||||
ADMIN_FLAGS.add(TELEPORT_FROM);
|
|
||||||
ADMIN_FLAGS.add(TELEPORT_TO);
|
|
||||||
ADMIN_FLAGS.add(VEHICLE_DESTROY);
|
|
||||||
ADMIN_FLAGS.add(WITHER_DAMAGE);
|
|
||||||
|
|
||||||
|
|
||||||
// USER
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_FARMLAND);
|
|
||||||
contexts.add(FlagContexts.TARGET_TURTLE_EGG);
|
|
||||||
BLOCK_TRAMPLING = new GDCustomFlagDefinition(Flags.COLLIDE_BLOCK, contexts, "block-trampling", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_CHEST);
|
|
||||||
CHEST_ACCESS = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "chest-access", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS);
|
|
||||||
CHEST_ACCESS.addFlagData(Flags.INTERACT_INVENTORY, contexts);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_CHORUS_FRUIT);
|
|
||||||
CHORUS_FRUIT_TELEPORT = new GDCustomFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "chorus-fruit-teleport", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_CROP);
|
|
||||||
CROP_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "crop-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
|
||||||
DAMAGE_ANIMALS = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "damage-animals", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
|
||||||
ENDERMAN_GRIEF = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "enderman-grief", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_FIRE);
|
|
||||||
FIRE_DAMAGE = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "fire-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_FIRE);
|
|
||||||
FIRE_SPREAD = new GDCustomFlagDefinition(Flags.BLOCK_SPREAD, contexts, "fire-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_GRASS);
|
|
||||||
GRASS_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "grass-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_ICE_FORM);
|
|
||||||
ICE_FORM = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-form", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_ICE_MELT);
|
|
||||||
ICE_MELT = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_LAVA);
|
|
||||||
LAVA_FLOW = new GDCustomFlagDefinition(Flags.LIQUID_FLOW, contexts, "lava-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
LEAF_DECAY = new GDCustomFlagDefinition(Flags.LEAF_DECAY, contexts, "leaf-decay", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_LIGHTNING_BOLT);
|
|
||||||
LIGHTNING = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "lightning", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_FLINTANDSTEEL);
|
|
||||||
LIGHTER = new GDCustomFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "lighter", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_MUSHROOM);
|
|
||||||
MUSHROOM_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "mushroom-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_MYCELIUM);
|
|
||||||
MYCELIUM_SPREAD = new GDCustomFlagDefinition(Flags.BLOCK_SPREAD, contexts, "mycelium-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
PVP = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "pvp", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
RIDE = new GDCustomFlagDefinition(Flags.ENTITY_RIDING, contexts, "ride", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_BED);
|
|
||||||
SLEEP = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "sleep", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
|
||||||
SNOW_FALL = new GDCustomFlagDefinition(Flags.BLOCK_PLACE, contexts, "snow-fall", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
|
||||||
SNOW_MELT = new GDCustomFlagDefinition(Flags.BLOCK_BREAK, contexts, "snow-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_SNOWMAN);
|
|
||||||
SNOWMAN_TRAIL = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "snowman-trail", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.STATE_FARMLAND_DRY);
|
|
||||||
SOIL_DRY = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "soil-dry", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_AMBIENT);
|
|
||||||
SPAWN_AMBIENT = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-ambient", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
|
||||||
SPAWN_ANIMAL = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-animal", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_AQUATIC);
|
|
||||||
SPAWN_AQUATIC = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-aquatic", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
USE = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_USE);
|
|
||||||
USE.addFlagData(Flags.INTERACT_ENTITY_SECONDARY, new HashSet<>(contexts));
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
VEHICLE_DESTROY_CLAIM = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
VEHICLE_PLACE = new GDCustomFlagDefinition(Flags.BLOCK_PLACE, contexts, "vehicle-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_VINE);
|
|
||||||
VINE_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "vine-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_WATER);
|
|
||||||
WATER_FLOW = new GDCustomFlagDefinition(Flags.LIQUID_FLOW, contexts, "water-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW);
|
|
||||||
|
|
||||||
USER_FLAGS.add(CHEST_ACCESS);
|
|
||||||
USER_FLAGS.add(CHORUS_FRUIT_TELEPORT);
|
|
||||||
USER_FLAGS.add(CROP_GROWTH);
|
|
||||||
USER_FLAGS.add(DAMAGE_ANIMALS);
|
|
||||||
USER_FLAGS.add(ENDERMAN_GRIEF);
|
|
||||||
USER_FLAGS.add(FIRE_DAMAGE);
|
|
||||||
USER_FLAGS.add(FIRE_SPREAD);
|
|
||||||
USER_FLAGS.add(GRASS_GROWTH);
|
|
||||||
USER_FLAGS.add(ICE_FORM);
|
|
||||||
USER_FLAGS.add(ICE_MELT);
|
|
||||||
USER_FLAGS.add(LAVA_FLOW);
|
|
||||||
USER_FLAGS.add(LEAF_DECAY);
|
|
||||||
USER_FLAGS.add(LIGHTER);
|
|
||||||
USER_FLAGS.add(LIGHTNING);
|
|
||||||
USER_FLAGS.add(MYCELIUM_SPREAD);
|
|
||||||
USER_FLAGS.add(PVP);
|
|
||||||
USER_FLAGS.add(RIDE);
|
|
||||||
USER_FLAGS.add(SLEEP);
|
|
||||||
USER_FLAGS.add(SNOW_FALL);
|
|
||||||
USER_FLAGS.add(SNOW_MELT);
|
|
||||||
USER_FLAGS.add(SOIL_DRY);
|
|
||||||
USER_FLAGS.add(SPAWN_AMBIENT);
|
|
||||||
USER_FLAGS.add(SPAWN_ANIMAL);
|
|
||||||
USER_FLAGS.add(SPAWN_AQUATIC);
|
|
||||||
USER_FLAGS.add(USE);
|
|
||||||
USER_FLAGS.add(VEHICLE_DESTROY_CLAIM);
|
|
||||||
USER_FLAGS.add(VEHICLE_PLACE);
|
|
||||||
USER_FLAGS.add(WATER_FLOW);
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,29 +24,36 @@
|
|||||||
*/
|
*/
|
||||||
package com.griefdefender.permission.flag;
|
package com.griefdefender.permission.flag;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
|
||||||
public class CustomFlagData {
|
public class GDFlagData implements FlagData {
|
||||||
|
|
||||||
private Flag flag;
|
private Flag flag;
|
||||||
private Set<Context> contexts;
|
private Set<Context> contexts;
|
||||||
|
|
||||||
public CustomFlagData(Flag flag, Set<Context> contexts) {
|
public GDFlagData(Flag flag, Set<Context> contexts) {
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.contexts = contexts;
|
this.contexts = contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Set<Context> getContexts() {
|
public Set<Context> getContexts() {
|
||||||
return this.contexts;
|
return this.contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Flag getFlag() {
|
public Flag getFlag() {
|
||||||
return this.flag;
|
return this.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
||||||
for (Context context : this.contexts) {
|
for (Context context : this.contexts) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -62,4 +69,36 @@ public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class FlagDataBuilder implements Builder {
|
||||||
|
|
||||||
|
private Flag flag;
|
||||||
|
private Set<Context> contexts = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder flag(Flag flag) {
|
||||||
|
this.flag = flag;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder contexts(Set<Context> contexts) {
|
||||||
|
this.contexts = contexts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder reset() {
|
||||||
|
this.flag = null;
|
||||||
|
this.contexts = new HashSet<>();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlagData build() {
|
||||||
|
checkNotNull(this.flag);
|
||||||
|
return new GDFlagData(this.flag, this.contexts);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) bloodmc
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.griefdefender.permission.flag;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.griefdefender.GriefDefenderPlugin;
|
||||||
|
import com.griefdefender.api.Tristate;
|
||||||
|
import com.griefdefender.api.permission.Context;
|
||||||
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
|
import com.griefdefender.registry.FlagDefinitionRegistryModule;
|
||||||
|
|
||||||
|
import net.kyori.text.Component;
|
||||||
|
import net.kyori.text.TextComponent;
|
||||||
|
import net.kyori.text.serializer.plain.PlainComponentSerializer;
|
||||||
|
|
||||||
|
public class GDFlagDefinition implements FlagDefinition {
|
||||||
|
|
||||||
|
private boolean enabled = true;
|
||||||
|
private Set<Context> definitionContexts = new HashSet<>();
|
||||||
|
private List<FlagData> data = new ArrayList<>();
|
||||||
|
private String displayName;
|
||||||
|
private String groupName;
|
||||||
|
private Tristate defaultValue = Tristate.UNDEFINED;
|
||||||
|
private Component description;
|
||||||
|
|
||||||
|
public GDFlagDefinition(Flag flag, Set<Context> contexts, String displayName, Component description) {
|
||||||
|
this.data.add(new GDFlagData(flag, contexts));
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.description = description;
|
||||||
|
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description) {
|
||||||
|
this.data = flagData;
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.description = description;
|
||||||
|
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFlagData(Flag flag, Set<Context> contexts) {
|
||||||
|
this.data.add(new GDFlagData(flag, contexts));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFlagData(FlagData flagData) {
|
||||||
|
this.data.add(new GDFlagData(flagData.getFlag(), flagData.getContexts()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Flag> getFlags() {
|
||||||
|
List<Flag> flags = new ArrayList<>();
|
||||||
|
for (FlagData flagData : this.data) {
|
||||||
|
flags.add(flagData.getFlag());
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FlagData> getFlagData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFriendlyDescription() {
|
||||||
|
if (this.description == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlainComponentSerializer.INSTANCE.serialize(this.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Context> getContexts() {
|
||||||
|
return this.definitionContexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContexts(Set<Context> contexts) {
|
||||||
|
this.definitionContexts = contexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsEnabled(boolean val) {
|
||||||
|
this.enabled = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return GriefDefenderPlugin.MOD_ID + ":" + this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroupName() {
|
||||||
|
return this.groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGroupName(String group) {
|
||||||
|
this.groupName = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tristate getDefaultValue() {
|
||||||
|
return this.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefaultValue(Tristate value) {
|
||||||
|
this.defaultValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FlagDefinitionBuilder implements Builder {
|
||||||
|
|
||||||
|
private boolean enabled = true;
|
||||||
|
private Set<Context> definitionContexts = new HashSet<>();
|
||||||
|
private List<FlagData> data = new ArrayList<>();
|
||||||
|
private String displayName;
|
||||||
|
private String groupName;
|
||||||
|
private Tristate defaultValue = Tristate.UNDEFINED;
|
||||||
|
private Component description = TextComponent.empty();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder enabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder defaultValue(Tristate value) {
|
||||||
|
this.defaultValue = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder flagData(List<FlagData> data) {
|
||||||
|
this.data = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder contexts(Set<Context> contexts) {
|
||||||
|
this.definitionContexts = contexts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.displayName = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder description(Component description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder reset() {
|
||||||
|
this.enabled = true;
|
||||||
|
this.definitionContexts = new HashSet<>();
|
||||||
|
this.data = new ArrayList<>();
|
||||||
|
this.displayName = "";
|
||||||
|
this.groupName = "";
|
||||||
|
this.defaultValue = Tristate.UNDEFINED;
|
||||||
|
this.description = TextComponent.empty();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlagDefinition build() {
|
||||||
|
checkNotNull(this.data);
|
||||||
|
checkNotNull(this.displayName);
|
||||||
|
checkNotNull(this.groupName);
|
||||||
|
checkNotNull(this.description);
|
||||||
|
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description);
|
||||||
|
definition.setContexts(this.definitionContexts);
|
||||||
|
definition.setIsEnabled(this.enabled);
|
||||||
|
definition.setDefaultValue(this.defaultValue);
|
||||||
|
definition.setGroupName(this.groupName);
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,412 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) bloodmc
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.griefdefender.permission.flag;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.griefdefender.api.claim.ClaimContexts;
|
||||||
|
import com.griefdefender.api.permission.Context;
|
||||||
|
import com.griefdefender.api.permission.flag.Flags;
|
||||||
|
import com.griefdefender.cache.MessageCache;
|
||||||
|
|
||||||
|
public class GDFlagDefinitions {
|
||||||
|
|
||||||
|
// ADMIN
|
||||||
|
public static final GDFlagDefinition BLOCK_BREAK;
|
||||||
|
public static final GDFlagDefinition BLOCK_GROW;
|
||||||
|
public static final GDFlagDefinition BLOCK_PLACE;
|
||||||
|
public static final GDFlagDefinition BLOCK_SPREAD;
|
||||||
|
public static final GDFlagDefinition ENDERPEARL;
|
||||||
|
public static final GDFlagDefinition EXIT_PLAYER;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_BLOCK;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_ENTITY;
|
||||||
|
public static final GDFlagDefinition EXP_DROP;
|
||||||
|
public static final GDFlagDefinition FALL_DAMAGE;
|
||||||
|
public static final GDFlagDefinition INTERACT_BLOCK;
|
||||||
|
public static final GDFlagDefinition INTERACT_ENTITY;
|
||||||
|
public static final GDFlagDefinition INTERACT_INVENTORY;
|
||||||
|
public static final GDFlagDefinition INVINCIBLE;
|
||||||
|
public static final GDFlagDefinition ITEM_DROP;
|
||||||
|
public static final GDFlagDefinition ITEM_PICKUP;
|
||||||
|
public static final GDFlagDefinition MONSTER_DAMAGE;
|
||||||
|
public static final GDFlagDefinition PISTONS;
|
||||||
|
public static final GDFlagDefinition PORTAL_USE;
|
||||||
|
public static final GDFlagDefinition SPAWN_MONSTER;
|
||||||
|
public static final GDFlagDefinition TELEPORT_FROM;
|
||||||
|
public static final GDFlagDefinition TELEPORT_TO;
|
||||||
|
public static final GDFlagDefinition USE;
|
||||||
|
public static final GDFlagDefinition VEHICLE_DESTROY;
|
||||||
|
public static final GDFlagDefinition WITHER_DAMAGE;
|
||||||
|
|
||||||
|
// USER
|
||||||
|
public static final GDFlagDefinition BLOCK_TRAMPLING;
|
||||||
|
public static final GDFlagDefinition CHEST_ACCESS;
|
||||||
|
public static final GDFlagDefinition CHORUS_FRUIT_TELEPORT;
|
||||||
|
public static final GDFlagDefinition CROP_GROWTH;
|
||||||
|
public static final GDFlagDefinition DAMAGE_ANIMALS;
|
||||||
|
public static final GDFlagDefinition ENDERMAN_GRIEF;
|
||||||
|
public static final GDFlagDefinition ENTER_PLAYER;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_CREEPER;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_TNT;
|
||||||
|
public static final GDFlagDefinition FIRE_DAMAGE;
|
||||||
|
public static final GDFlagDefinition FIRE_SPREAD;
|
||||||
|
public static final GDFlagDefinition GRASS_GROWTH;
|
||||||
|
public static final GDFlagDefinition ICE_FORM;
|
||||||
|
public static final GDFlagDefinition ICE_MELT;
|
||||||
|
public static final GDFlagDefinition LAVA_FLOW;
|
||||||
|
public static final GDFlagDefinition LEAF_DECAY;
|
||||||
|
public static final GDFlagDefinition LIGHTNING;
|
||||||
|
public static final GDFlagDefinition LIGHTER;
|
||||||
|
public static final GDFlagDefinition MUSHROOM_GROWTH;
|
||||||
|
public static final GDFlagDefinition MYCELIUM_SPREAD;
|
||||||
|
public static final GDFlagDefinition PVP;
|
||||||
|
public static final GDFlagDefinition RIDE;
|
||||||
|
public static final GDFlagDefinition SLEEP;
|
||||||
|
public static final GDFlagDefinition SNOW_FALL;
|
||||||
|
public static final GDFlagDefinition SNOW_MELT;
|
||||||
|
public static final GDFlagDefinition SNOWMAN_TRAIL;
|
||||||
|
public static final GDFlagDefinition SOIL_DRY;
|
||||||
|
public static final GDFlagDefinition SPAWN_AMBIENT;
|
||||||
|
public static final GDFlagDefinition SPAWN_ANIMAL;
|
||||||
|
public static final GDFlagDefinition SPAWN_AQUATIC;
|
||||||
|
public static final GDFlagDefinition VEHICLE_DESTROY_CLAIM;
|
||||||
|
public static final GDFlagDefinition VEHICLE_PLACE;
|
||||||
|
public static final GDFlagDefinition VINE_GROWTH;
|
||||||
|
public static final GDFlagDefinition WATER_FLOW;
|
||||||
|
|
||||||
|
public static final List<GDFlagDefinition> ADMIN_FLAGS = new ArrayList<>();
|
||||||
|
public static final List<GDFlagDefinition> USER_FLAGS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Set<Context> contexts = new HashSet<>();
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_BREAK = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "block-break", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_PLACE = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "block-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_GROW = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "block-grow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "block-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD);
|
||||||
|
|
||||||
|
// ADMIN
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
||||||
|
ENDERPEARL = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "enderpearl", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERPEARL);
|
||||||
|
ENDERPEARL.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
ENTER_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "enter-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
EXIT_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "exit-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
EXPLOSION_BLOCK = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK);
|
||||||
|
EXPLOSION_BLOCK.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_CREEPER);
|
||||||
|
EXPLOSION_CREEPER = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-creeper", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER);
|
||||||
|
EXPLOSION_CREEPER.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
EXPLOSION_ENTITY = new GDFlagDefinition(Flags.EXPLOSION_ENTITY, contexts, "explosion-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY);
|
||||||
|
EXPLOSION_ENTITY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_TNT);
|
||||||
|
EXPLOSION_TNT = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-tnt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT);
|
||||||
|
EXPLOSION_TNT.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_XP_ORB);
|
||||||
|
EXP_DROP = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "exp-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_FALL);
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
FALL_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "fall-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
INTERACT_BLOCK = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "interact-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
INTERACT_ENTITY = new GDFlagDefinition(Flags.INTERACT_ENTITY_SECONDARY, contexts, "interact-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
INTERACT_INVENTORY = new GDFlagDefinition(Flags.INTERACT_INVENTORY, contexts, "interact-inventory", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
INVINCIBLE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "invincible", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INVINCIBLE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
ITEM_DROP = new GDFlagDefinition(Flags.ITEM_DROP, contexts, "item-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_DROP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
ITEM_PICKUP = new GDFlagDefinition(Flags.ITEM_PICKUP, contexts, "item-pickup", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
|
||||||
|
MONSTER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "monster-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PISTON);
|
||||||
|
PISTONS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "pistons", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTONS);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_PORTAL);
|
||||||
|
PORTAL_USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "portal-use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PORTAL_USE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
|
||||||
|
SPAWN_MONSTER = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-monster", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
TELEPORT_FROM = new GDFlagDefinition(Flags.ENTITY_TELEPORT_FROM, contexts, "teleport-from", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
TELEPORT_TO = new GDFlagDefinition(Flags.ENTITY_TELEPORT_TO, contexts, "teleport-to", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
VEHICLE_DESTROY = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
||||||
|
VEHICLE_DESTROY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_WITHER);
|
||||||
|
WITHER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "wither-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE);
|
||||||
|
WITHER_DAMAGE.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
ADMIN_FLAGS.add(BLOCK_BREAK);
|
||||||
|
ADMIN_FLAGS.add(BLOCK_PLACE);
|
||||||
|
ADMIN_FLAGS.add(BLOCK_GROW);
|
||||||
|
ADMIN_FLAGS.add(BLOCK_SPREAD);
|
||||||
|
ADMIN_FLAGS.add(ENDERPEARL);
|
||||||
|
ADMIN_FLAGS.add(ENTER_PLAYER);
|
||||||
|
ADMIN_FLAGS.add(EXIT_PLAYER);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_BLOCK);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_CREEPER);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_ENTITY);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_TNT);
|
||||||
|
ADMIN_FLAGS.add(EXP_DROP);
|
||||||
|
ADMIN_FLAGS.add(FALL_DAMAGE);
|
||||||
|
ADMIN_FLAGS.add(INTERACT_BLOCK);
|
||||||
|
ADMIN_FLAGS.add(INTERACT_ENTITY);
|
||||||
|
ADMIN_FLAGS.add(INTERACT_INVENTORY);
|
||||||
|
ADMIN_FLAGS.add(INVINCIBLE);
|
||||||
|
ADMIN_FLAGS.add(ITEM_DROP);
|
||||||
|
ADMIN_FLAGS.add(ITEM_PICKUP);
|
||||||
|
ADMIN_FLAGS.add(MONSTER_DAMAGE);
|
||||||
|
ADMIN_FLAGS.add(PISTONS);
|
||||||
|
ADMIN_FLAGS.add(SPAWN_MONSTER);
|
||||||
|
ADMIN_FLAGS.add(TELEPORT_FROM);
|
||||||
|
ADMIN_FLAGS.add(TELEPORT_TO);
|
||||||
|
ADMIN_FLAGS.add(VEHICLE_DESTROY);
|
||||||
|
ADMIN_FLAGS.add(WITHER_DAMAGE);
|
||||||
|
|
||||||
|
|
||||||
|
// USER
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_FARMLAND);
|
||||||
|
contexts.add(FlagContexts.TARGET_TURTLE_EGG);
|
||||||
|
BLOCK_TRAMPLING = new GDFlagDefinition(Flags.COLLIDE_BLOCK, contexts, "block-trampling", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_CHEST);
|
||||||
|
CHEST_ACCESS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "chest-access", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS);
|
||||||
|
CHEST_ACCESS.addFlagData(Flags.INTERACT_INVENTORY, contexts);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_CHORUS_FRUIT);
|
||||||
|
CHORUS_FRUIT_TELEPORT = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "chorus-fruit-teleport", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_CROP);
|
||||||
|
CROP_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "crop-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
||||||
|
DAMAGE_ANIMALS = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "damage-animals", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
||||||
|
ENDERMAN_GRIEF = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "enderman-grief", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_FIRE);
|
||||||
|
FIRE_DAMAGE = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "fire-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_FIRE);
|
||||||
|
FIRE_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "fire-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_GRASS);
|
||||||
|
GRASS_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "grass-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_ICE_FORM);
|
||||||
|
ICE_FORM = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-form", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_ICE_MELT);
|
||||||
|
ICE_MELT = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_LAVA);
|
||||||
|
LAVA_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "lava-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
LEAF_DECAY = new GDFlagDefinition(Flags.LEAF_DECAY, contexts, "leaf-decay", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_LIGHTNING_BOLT);
|
||||||
|
LIGHTNING = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "lightning", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_FLINTANDSTEEL);
|
||||||
|
LIGHTER = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "lighter", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_MUSHROOM);
|
||||||
|
MUSHROOM_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "mushroom-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_MYCELIUM);
|
||||||
|
MYCELIUM_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "mycelium-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
PVP = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "pvp", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
RIDE = new GDFlagDefinition(Flags.ENTITY_RIDING, contexts, "ride", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_BED);
|
||||||
|
SLEEP = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "sleep", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
||||||
|
SNOW_FALL = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "snow-fall", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
||||||
|
SNOW_MELT = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "snow-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_SNOWMAN);
|
||||||
|
SNOWMAN_TRAIL = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "snowman-trail", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.STATE_FARMLAND_DRY);
|
||||||
|
SOIL_DRY = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "soil-dry", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_AMBIENT);
|
||||||
|
SPAWN_AMBIENT = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-ambient", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
||||||
|
SPAWN_ANIMAL = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-animal", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_AQUATIC);
|
||||||
|
SPAWN_AQUATIC = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-aquatic", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_USE);
|
||||||
|
USE.addFlagData(Flags.INTERACT_ENTITY_SECONDARY, new HashSet<>(contexts));
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
VEHICLE_DESTROY_CLAIM = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
VEHICLE_PLACE = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "vehicle-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_VINE);
|
||||||
|
VINE_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "vine-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_WATER);
|
||||||
|
WATER_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "water-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW);
|
||||||
|
|
||||||
|
USER_FLAGS.add(CHEST_ACCESS);
|
||||||
|
USER_FLAGS.add(CHORUS_FRUIT_TELEPORT);
|
||||||
|
USER_FLAGS.add(CROP_GROWTH);
|
||||||
|
USER_FLAGS.add(DAMAGE_ANIMALS);
|
||||||
|
USER_FLAGS.add(ENDERMAN_GRIEF);
|
||||||
|
USER_FLAGS.add(FIRE_DAMAGE);
|
||||||
|
USER_FLAGS.add(FIRE_SPREAD);
|
||||||
|
USER_FLAGS.add(GRASS_GROWTH);
|
||||||
|
USER_FLAGS.add(ICE_FORM);
|
||||||
|
USER_FLAGS.add(ICE_MELT);
|
||||||
|
USER_FLAGS.add(LAVA_FLOW);
|
||||||
|
USER_FLAGS.add(LEAF_DECAY);
|
||||||
|
USER_FLAGS.add(LIGHTER);
|
||||||
|
USER_FLAGS.add(LIGHTNING);
|
||||||
|
USER_FLAGS.add(MYCELIUM_SPREAD);
|
||||||
|
USER_FLAGS.add(PVP);
|
||||||
|
USER_FLAGS.add(RIDE);
|
||||||
|
USER_FLAGS.add(SLEEP);
|
||||||
|
USER_FLAGS.add(SNOW_FALL);
|
||||||
|
USER_FLAGS.add(SNOW_MELT);
|
||||||
|
USER_FLAGS.add(SOIL_DRY);
|
||||||
|
USER_FLAGS.add(SPAWN_AMBIENT);
|
||||||
|
USER_FLAGS.add(SPAWN_ANIMAL);
|
||||||
|
USER_FLAGS.add(SPAWN_AQUATIC);
|
||||||
|
USER_FLAGS.add(USE);
|
||||||
|
USER_FLAGS.add(VEHICLE_DESTROY_CLAIM);
|
||||||
|
USER_FLAGS.add(VEHICLE_PLACE);
|
||||||
|
USER_FLAGS.add(WATER_FLOW);
|
||||||
|
}
|
||||||
|
}
|
@ -37,12 +37,12 @@
|
|||||||
|
|
||||||
import net.kyori.text.format.TextColor;
|
import net.kyori.text.format.TextColor;
|
||||||
|
|
||||||
public class FlagData {
|
public class UIFlagData {
|
||||||
|
|
||||||
public Flag flag;
|
public Flag flag;
|
||||||
public Map<Integer, FlagContextHolder> flagContextMap = new HashMap<>();
|
public Map<Integer, FlagContextHolder> flagContextMap = new HashMap<>();
|
||||||
|
|
||||||
public FlagData(Flag flag, Boolean value, MenuType type, Set<Context> contexts) {
|
public UIFlagData(Flag flag, Boolean value, MenuType type, Set<Context> contexts) {
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.addContexts(flag, value, type, contexts);
|
this.addContexts(flag, value, type, contexts);
|
||||||
}
|
}
|
@ -40,7 +40,7 @@
|
|||||||
import com.griefdefender.cache.MessageCache;
|
import com.griefdefender.cache.MessageCache;
|
||||||
import com.griefdefender.configuration.MessageStorage;
|
import com.griefdefender.configuration.MessageStorage;
|
||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.GDPermissions;
|
||||||
import com.griefdefender.permission.ui.FlagData.FlagContextHolder;
|
import com.griefdefender.permission.ui.UIFlagData.FlagContextHolder;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) bloodmc
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.griefdefender.registry;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
|
import com.griefdefender.api.registry.CatalogRegistryModule;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class FlagDefinitionRegistryModule implements CatalogRegistryModule<FlagDefinition> {
|
||||||
|
|
||||||
|
private static FlagDefinitionRegistryModule instance;
|
||||||
|
|
||||||
|
public static FlagDefinitionRegistryModule getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<String, FlagDefinition> registryMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<FlagDefinition> getById(String id) {
|
||||||
|
if (id == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!id.contains(":")) {
|
||||||
|
id = "griefdefender:" + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.ofNullable(this.registryMap.get(checkNotNull(id.toLowerCase())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<FlagDefinition> getAll() {
|
||||||
|
return this.registryMap.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerDefaults() {
|
||||||
|
// Currently done via config
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerCustomType(FlagDefinition type) {
|
||||||
|
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
instance = new FlagDefinitionRegistryModule();
|
||||||
|
}
|
||||||
|
}
|
@ -94,7 +94,7 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.griefdefender:api:1.0.0-20190906.173641-10'
|
compileOnly(project(path: ":GriefDefenderAPI"))
|
||||||
compileOnly "com.griefdefender:reflect-helper:1.0"
|
compileOnly "com.griefdefender:reflect-helper:1.0"
|
||||||
// Sponge
|
// Sponge
|
||||||
apiCompile "org.spongepowered:spongeapi:$apiVersion"
|
apiCompile "org.spongepowered:spongeapi:$apiVersion"
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
import com.griefdefender.api.data.PlayerData;
|
import com.griefdefender.api.data.PlayerData;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
import com.griefdefender.cache.PermissionHolderCache;
|
import com.griefdefender.cache.PermissionHolderCache;
|
||||||
|
import com.griefdefender.storage.BaseStorage;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
|
|
||||||
@ -80,6 +81,12 @@ public Optional<PlayerData> getPlayerData(UUID worldUniqueId, UUID playerUniqueI
|
|||||||
@Override
|
@Override
|
||||||
public List<Claim> getAllPlayerClaims(UUID playerUniqueId) {
|
public List<Claim> getAllPlayerClaims(UUID playerUniqueId) {
|
||||||
List<Claim> claimList = new ArrayList<>();
|
List<Claim> claimList = new ArrayList<>();
|
||||||
|
if (BaseStorage.USE_GLOBAL_PLAYER_STORAGE) {
|
||||||
|
final ClaimManager claimManager = this.getClaimManager(Sponge.getServer().getDefaultWorld().get().getUniqueId());
|
||||||
|
claimList.addAll(claimManager.getPlayerClaims(playerUniqueId));
|
||||||
|
return ImmutableList.copyOf(claimList);
|
||||||
|
}
|
||||||
|
|
||||||
for (World world : Sponge.getServer().getWorlds()) {
|
for (World world : Sponge.getServer().getWorlds()) {
|
||||||
claimList.addAll(this.getClaimManager(world.getUniqueId()).getPlayerClaims(playerUniqueId));
|
claimList.addAll(this.getClaimManager(world.getUniqueId()).getPlayerClaims(playerUniqueId));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
import co.aikar.commands.RootCommand;
|
import co.aikar.commands.RootCommand;
|
||||||
import co.aikar.commands.SpongeCommandManager;
|
import co.aikar.commands.SpongeCommandManager;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Stage;
|
import com.google.inject.Stage;
|
||||||
@ -42,6 +41,8 @@
|
|||||||
import com.griefdefender.api.claim.TrustType;
|
import com.griefdefender.api.claim.TrustType;
|
||||||
import com.griefdefender.api.economy.BankTransaction;
|
import com.griefdefender.api.economy.BankTransaction;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
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.GameModeType;
|
import com.griefdefender.api.permission.option.type.GameModeType;
|
||||||
@ -131,7 +132,7 @@
|
|||||||
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
|
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
|
||||||
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
|
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
|
||||||
import com.griefdefender.configuration.serializer.CreateModeTypeSerializer;
|
import com.griefdefender.configuration.serializer.CreateModeTypeSerializer;
|
||||||
import com.griefdefender.configuration.serializer.CustomFlagSerializer;
|
import com.griefdefender.configuration.serializer.FlagDefinitionSerializer;
|
||||||
import com.griefdefender.configuration.serializer.GameModeTypeSerializer;
|
import com.griefdefender.configuration.serializer.GameModeTypeSerializer;
|
||||||
import com.griefdefender.configuration.serializer.WeatherTypeSerializer;
|
import com.griefdefender.configuration.serializer.WeatherTypeSerializer;
|
||||||
import com.griefdefender.configuration.type.ConfigBase;
|
import com.griefdefender.configuration.type.ConfigBase;
|
||||||
@ -157,8 +158,8 @@
|
|||||||
import com.griefdefender.permission.GDPermissionHolder;
|
import com.griefdefender.permission.GDPermissionHolder;
|
||||||
import com.griefdefender.permission.GDPermissionManager;
|
import com.griefdefender.permission.GDPermissionManager;
|
||||||
import com.griefdefender.permission.GDPermissionUser;
|
import com.griefdefender.permission.GDPermissionUser;
|
||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.flag.GDFlagData;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.permission.flag.GDFlags;
|
import com.griefdefender.permission.flag.GDFlags;
|
||||||
import com.griefdefender.provider.LuckPermsProvider;
|
import com.griefdefender.provider.LuckPermsProvider;
|
||||||
import com.griefdefender.provider.MCClansProvider;
|
import com.griefdefender.provider.MCClansProvider;
|
||||||
@ -486,9 +487,11 @@ public void onPreInit(GamePreInitializationEvent event, Logger logger, Path path
|
|||||||
GameModeTypeRegistryModule.getInstance().registerDefaults();
|
GameModeTypeRegistryModule.getInstance().registerDefaults();
|
||||||
WeatherTypeRegistryModule.getInstance().registerDefaults();
|
WeatherTypeRegistryModule.getInstance().registerDefaults();
|
||||||
OptionRegistryModule.getInstance().registerDefaults();
|
OptionRegistryModule.getInstance().registerDefaults();
|
||||||
|
GriefDefender.getRegistry().registerBuilderSupplier(BankTransaction.Builder.class, GDBankTransaction.BankTransactionBuilder::new);
|
||||||
GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
|
GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
|
||||||
GriefDefender.getRegistry().registerBuilderSupplier(ClaimSchematic.Builder.class, ClaimSchematicBuilder::new);
|
GriefDefender.getRegistry().registerBuilderSupplier(ClaimSchematic.Builder.class, ClaimSchematicBuilder::new);
|
||||||
GriefDefender.getRegistry().registerBuilderSupplier(BankTransaction.Builder.class, GDBankTransaction.BankTransactionBuilder::new);
|
GriefDefender.getRegistry().registerBuilderSupplier(FlagData.Builder.class, GDFlagData.FlagDataBuilder::new);
|
||||||
|
GriefDefender.getRegistry().registerBuilderSupplier(FlagDefinition.Builder.class, GDFlagDefinition.FlagDefinitionBuilder::new);
|
||||||
Sponge.getEventManager().registerListeners(GDBootstrap.getInstance(), GriefDefenderPlugin.getInstance());
|
Sponge.getEventManager().registerListeners(GDBootstrap.getInstance(), GriefDefenderPlugin.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,9 +893,9 @@ public void loadConfig() {
|
|||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Component.class), new ComponentConfigSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Component.class), new ComponentConfigSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ClaimType.class), new ClaimTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ClaimType.class), new ClaimTypeSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(CreateModeType.class), new CreateModeTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(CreateModeType.class), new CreateModeTypeSerializer());
|
||||||
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(FlagDefinition.class), new FlagDefinitionSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GameModeType.class), new GameModeTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GameModeType.class), new GameModeTypeSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(WeatherType.class), new WeatherTypeSerializer());
|
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(WeatherType.class), new WeatherTypeSerializer());
|
||||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GDCustomFlagDefinition.class), new CustomFlagSerializer());
|
|
||||||
|
|
||||||
if (Files.notExists(BaseStorage.dataLayerFolderPath)) {
|
if (Files.notExists(BaseStorage.dataLayerFolderPath)) {
|
||||||
Files.createDirectories(BaseStorage.dataLayerFolderPath);
|
Files.createDirectories(BaseStorage.dataLayerFolderPath);
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.griefdefender.GDPlayerData;
|
import com.griefdefender.GDPlayerData;
|
||||||
import com.griefdefender.GriefDefenderPlugin;
|
import com.griefdefender.GriefDefenderPlugin;
|
||||||
import com.griefdefender.api.GriefDefender;
|
import com.griefdefender.api.GriefDefender;
|
||||||
@ -41,7 +40,7 @@
|
|||||||
import com.griefdefender.api.permission.PermissionResult;
|
import com.griefdefender.api.permission.PermissionResult;
|
||||||
import com.griefdefender.api.permission.ResultTypes;
|
import com.griefdefender.api.permission.ResultTypes;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
import com.griefdefender.cache.MessageCache;
|
import com.griefdefender.cache.MessageCache;
|
||||||
import com.griefdefender.cache.PermissionHolderCache;
|
import com.griefdefender.cache.PermissionHolderCache;
|
||||||
import com.griefdefender.claim.GDClaim;
|
import com.griefdefender.claim.GDClaim;
|
||||||
@ -55,14 +54,12 @@
|
|||||||
import com.griefdefender.permission.GDPermissionManager;
|
import com.griefdefender.permission.GDPermissionManager;
|
||||||
import com.griefdefender.permission.GDPermissionUser;
|
import com.griefdefender.permission.GDPermissionUser;
|
||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.GDPermissions;
|
||||||
import com.griefdefender.permission.flag.CustomFlagData;
|
|
||||||
import com.griefdefender.permission.flag.GDActiveFlagData;
|
import com.griefdefender.permission.flag.GDActiveFlagData;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.permission.ui.ClaimClickData;
|
import com.griefdefender.permission.ui.UIFlagData;
|
||||||
import com.griefdefender.permission.ui.FlagData;
|
|
||||||
import com.griefdefender.permission.ui.MenuType;
|
import com.griefdefender.permission.ui.MenuType;
|
||||||
import com.griefdefender.permission.ui.UIHelper;
|
import com.griefdefender.permission.ui.UIHelper;
|
||||||
import com.griefdefender.permission.ui.FlagData.FlagContextHolder;
|
import com.griefdefender.permission.ui.UIFlagData.FlagContextHolder;
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
import com.griefdefender.registry.FlagRegistryModule;
|
||||||
import com.griefdefender.text.action.GDCallbackHolder;
|
import com.griefdefender.text.action.GDCallbackHolder;
|
||||||
import com.griefdefender.util.CauseContextHelper;
|
import com.griefdefender.util.CauseContextHelper;
|
||||||
@ -239,7 +236,7 @@ protected void showCustomFlags(GDPermissionUser src, GDClaim claim, String displ
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
for (GDCustomFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
||||||
Component flagText = TextComponent.builder()
|
Component flagText = TextComponent.builder()
|
||||||
.append(getCustomFlagText(customFlag))
|
.append(getCustomFlagText(customFlag))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
@ -388,7 +385,7 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
|
|||||||
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
|
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
|
||||||
overrideContexts.add(claim.getOverrideClaimContext());
|
overrideContexts.add(claim.getOverrideClaimContext());
|
||||||
|
|
||||||
Map<String, FlagData> filteredContextMap = new HashMap<>();
|
Map<String, UIFlagData> filteredContextMap = new HashMap<>();
|
||||||
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getTransientPermissions(this.subject).entrySet()) {
|
for (Map.Entry<Set<Context>, Map<String, Boolean>> mapEntry : PermissionUtil.getInstance().getTransientPermissions(this.subject).entrySet()) {
|
||||||
final Set<Context> contextSet = mapEntry.getKey();
|
final Set<Context> contextSet = mapEntry.getKey();
|
||||||
if (contextSet.contains(claim.getDefaultTypeContext())) {
|
if (contextSet.contains(claim.getDefaultTypeContext())) {
|
||||||
@ -429,8 +426,8 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
|
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
|
||||||
for (Entry<String, FlagData> mapEntry : filteredContextMap.entrySet()) {
|
for (Entry<String, UIFlagData> mapEntry : filteredContextMap.entrySet()) {
|
||||||
final FlagData flagData = mapEntry.getValue();
|
final UIFlagData flagData = mapEntry.getValue();
|
||||||
final Flag flag = flagData.flag;
|
final Flag flag = flagData.flag;
|
||||||
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
|
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
|
||||||
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
|
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
|
||||||
@ -494,25 +491,25 @@ protected void showFlagPermissions(GDPermissionUser src, GDClaim claim, MenuType
|
|||||||
paginationList.sendTo(player, activePage);
|
paginationList.sendTo(player, activePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFilteredContexts(Map<String, FlagData> filteredContextMap, Set<Context> contexts, MenuType type, Map<String, Boolean> permissions) {
|
private void addFilteredContexts(Map<String, UIFlagData> filteredContextMap, Set<Context> contexts, MenuType type, Map<String, Boolean> permissions) {
|
||||||
for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) {
|
for (Map.Entry<String, Boolean> permissionEntry : permissions.entrySet()) {
|
||||||
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
|
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final FlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
final UIFlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
||||||
if (flagData != null) {
|
if (flagData != null) {
|
||||||
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
|
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
|
||||||
} else {
|
} else {
|
||||||
filteredContextMap.put(permissionEntry.getKey(), new FlagData(flag, permissionEntry.getValue(), type, contexts));
|
filteredContextMap.put(permissionEntry.getKey(), new UIFlagData(flag, permissionEntry.getValue(), type, contexts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getCustomFlagText(GDCustomFlagDefinition customFlag) {
|
private Component getCustomFlagText(GDFlagDefinition customFlag) {
|
||||||
TextComponent definitionType = TextComponent.empty();
|
TextComponent definitionType = TextComponent.empty();
|
||||||
TextColor flagColor = TextColor.GREEN;
|
TextColor flagColor = TextColor.GREEN;
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("default")) {
|
if (context.getKey().contains("default")) {
|
||||||
definitionType = TextComponent.builder()
|
definitionType = TextComponent.builder()
|
||||||
.append("\n")
|
.append("\n")
|
||||||
@ -544,7 +541,7 @@ private Component getCustomFlagText(GDCustomFlagDefinition customFlag) {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
final Component baseFlagText = TextComponent.builder()
|
final Component baseFlagText = TextComponent.builder()
|
||||||
.append(customFlag.getDisplayName(), flagColor)
|
.append(customFlag.getName(), flagColor)
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.hoverEvent(HoverEvent.showText(TextComponent.builder()
|
.hoverEvent(HoverEvent.showText(TextComponent.builder()
|
||||||
.append(customFlag.getDescription())
|
.append(customFlag.getDescription())
|
||||||
@ -553,9 +550,9 @@ private Component getCustomFlagText(GDCustomFlagDefinition customFlag) {
|
|||||||
return baseFlagText;
|
return baseFlagText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TextColor getCustomFlagColor(GDCustomFlagDefinition customFlag) {
|
private TextColor getCustomFlagColor(GDFlagDefinition customFlag) {
|
||||||
TextColor flagColor = TextColor.GREEN;
|
TextColor flagColor = TextColor.GREEN;
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("default")) {
|
if (context.getKey().contains("default")) {
|
||||||
flagColor = TextColor.LIGHT_PURPLE;
|
flagColor = TextColor.LIGHT_PURPLE;
|
||||||
break;
|
break;
|
||||||
@ -577,7 +574,7 @@ private Component getFlagText(Flag flag, Set<Context> contexts) {
|
|||||||
return baseFlagText;
|
return baseFlagText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GDCustomFlagDefinition customFlag, String flagGroup) {
|
private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, String flagGroup) {
|
||||||
boolean hasHover = false;
|
boolean hasHover = false;
|
||||||
TextComponent.Builder hoverBuilder = TextComponent.builder();
|
TextComponent.Builder hoverBuilder = TextComponent.builder();
|
||||||
final Player player = src.getOnlinePlayer();
|
final Player player = src.getOnlinePlayer();
|
||||||
@ -592,7 +589,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
|
final boolean isAdminGroup = GriefDefenderPlugin.getGlobalConfig().getConfig().customFlags.getGroups().get(flagGroup).isAdminGroup();
|
||||||
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
|
final String permission = isAdminGroup ? GDPermissions.FLAG_CUSTOM_ADMIN_BASE : GDPermissions.FLAG_CUSTOM_USER_BASE;
|
||||||
// check flag perm
|
// check flag perm
|
||||||
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getDisplayName())) {
|
if (!player.hasPermission(permission + "." + flagGroup + "." + customFlag.getName())) {
|
||||||
hoverBuilder.append(MessageCache.getInstance().PERMISSION_FLAG_USE).append("\n");
|
hoverBuilder.append(MessageCache.getInstance().PERMISSION_FLAG_USE).append("\n");
|
||||||
hasEditPermission = false;
|
hasEditPermission = false;
|
||||||
hasHover = true;
|
hasHover = true;
|
||||||
@ -600,8 +597,8 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
|
|
||||||
List<GDActiveFlagData> dataResults = new ArrayList<>();
|
List<GDActiveFlagData> dataResults = new ArrayList<>();
|
||||||
boolean hasGDContext = false;
|
boolean hasGDContext = false;
|
||||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("gd_claim")) {
|
if (context.getKey().contains("gd_claim")) {
|
||||||
hasGDContext = true;
|
hasGDContext = true;
|
||||||
break;
|
break;
|
||||||
@ -610,7 +607,7 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
if (!hasGDContext) {
|
if (!hasGDContext) {
|
||||||
definitionContexts.add(claim.getContext());
|
definitionContexts.add(claim.getContext());
|
||||||
}
|
}
|
||||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
for (FlagData flagData : customFlag.getFlagData()) {
|
||||||
final Set<Context> filteredContexts = new HashSet<>();
|
final Set<Context> filteredContexts = new HashSet<>();
|
||||||
for (Context context : definitionContexts) {
|
for (Context context : definitionContexts) {
|
||||||
if (context.getKey().contains("gd_claim")) {
|
if (context.getKey().contains("gd_claim")) {
|
||||||
@ -698,11 +695,11 @@ private Component getCustomClickableText(GDPermissionUser src, GDClaim claim, GD
|
|||||||
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE);
|
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!customFlag.getDefinitionContexts().isEmpty()) {
|
if (!customFlag.getContexts().isEmpty()) {
|
||||||
hoverBuilder.append("\nContexts: ");
|
hoverBuilder.append("\nContexts: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
hoverBuilder.append("\n");
|
hoverBuilder.append("\n");
|
||||||
final String key = context.getKey();
|
final String key = context.getKey();
|
||||||
final String value = context.getValue();
|
final String value = context.getValue();
|
||||||
@ -887,13 +884,13 @@ public int compare(Context o1, Context o2) {
|
|||||||
return textBuilder.build();
|
return textBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDCustomFlagDefinition customFlag, Tristate currentValue, String displayType) {
|
private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, GDClaim claim, GDFlagDefinition customFlag, Tristate currentValue, String displayType) {
|
||||||
final Player player = src.getOnlinePlayer();
|
final Player player = src.getOnlinePlayer();
|
||||||
return consumer -> {
|
return consumer -> {
|
||||||
GDCauseStackManager.getInstance().pushCause(player);
|
GDCauseStackManager.getInstance().pushCause(player);
|
||||||
boolean hasGDContext = false;
|
boolean hasGDContext = false;
|
||||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||||
for (Context context : customFlag.getDefinitionContexts()) {
|
for (Context context : customFlag.getContexts()) {
|
||||||
if (context.getKey().contains("gd_claim")) {
|
if (context.getKey().contains("gd_claim")) {
|
||||||
hasGDContext = true;
|
hasGDContext = true;
|
||||||
break;
|
break;
|
||||||
@ -902,7 +899,7 @@ private Consumer<CommandSource> createCustomFlagConsumer(GDPermissionUser src, G
|
|||||||
if (!hasGDContext) {
|
if (!hasGDContext) {
|
||||||
definitionContexts.add(claim.getContext());
|
definitionContexts.add(claim.getContext());
|
||||||
}
|
}
|
||||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
for (FlagData flagData : customFlag.getFlagData()) {
|
||||||
final Set<Context> newContexts = new HashSet<>(definitionContexts);
|
final Set<Context> newContexts = new HashSet<>(definitionContexts);
|
||||||
newContexts.addAll(flagData.getContexts());
|
newContexts.addAll(flagData.getContexts());
|
||||||
Tristate newValue = Tristate.UNDEFINED;
|
Tristate newValue = Tristate.UNDEFINED;
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
import com.griefdefender.api.claim.ClaimContexts;
|
import com.griefdefender.api.claim.ClaimContexts;
|
||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
import com.griefdefender.api.permission.ContextKeys;
|
import com.griefdefender.api.permission.ContextKeys;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
|
||||||
import com.griefdefender.api.permission.option.Option;
|
import com.griefdefender.api.permission.option.Option;
|
||||||
import com.griefdefender.api.permission.option.Options;
|
import com.griefdefender.api.permission.option.Options;
|
||||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||||
@ -60,13 +58,10 @@
|
|||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.GDPermissions;
|
||||||
import com.griefdefender.permission.option.GDOption;
|
import com.griefdefender.permission.option.GDOption;
|
||||||
import com.griefdefender.permission.ui.ClaimClickData;
|
import com.griefdefender.permission.ui.ClaimClickData;
|
||||||
import com.griefdefender.permission.ui.FlagData;
|
|
||||||
import com.griefdefender.permission.ui.MenuType;
|
import com.griefdefender.permission.ui.MenuType;
|
||||||
import com.griefdefender.permission.ui.OptionData;
|
import com.griefdefender.permission.ui.OptionData;
|
||||||
import com.griefdefender.permission.ui.OptionData.OptionContextHolder;
|
import com.griefdefender.permission.ui.OptionData.OptionContextHolder;
|
||||||
import com.griefdefender.permission.ui.UIHelper;
|
import com.griefdefender.permission.ui.UIHelper;
|
||||||
import com.griefdefender.permission.ui.FlagData.FlagContextHolder;
|
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
|
||||||
import com.griefdefender.registry.OptionRegistryModule;
|
import com.griefdefender.registry.OptionRegistryModule;
|
||||||
import com.griefdefender.text.action.GDCallbackHolder;
|
import com.griefdefender.text.action.GDCallbackHolder;
|
||||||
import com.griefdefender.util.CauseContextHelper;
|
import com.griefdefender.util.CauseContextHelper;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
@ -48,9 +48,9 @@ public class CustomFlagGroupCategory extends ConfigCategory {
|
|||||||
@Setting(value = "hover", comment = "The hover text to be displayed when hovering over group name in GUI.")
|
@Setting(value = "hover", comment = "The hover text to be displayed when hovering over group name in GUI.")
|
||||||
Component hoverText = TextComponent.empty();
|
Component hoverText = TextComponent.empty();
|
||||||
@Setting
|
@Setting
|
||||||
Map<String, GDCustomFlagDefinition> definitions = new HashMap<>();
|
Map<String, GDFlagDefinition> definitions = new HashMap<>();
|
||||||
|
|
||||||
public Map<String, GDCustomFlagDefinition> getFlagDefinitions() {
|
public Map<String, GDFlagDefinition> getFlagDefinitions() {
|
||||||
return this.definitions;
|
return this.definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,8 @@
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.griefdefender.api.claim.ClaimContexts;
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.permission.flag.GDFlagDefinitions;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinitions;
|
|
||||||
|
|
||||||
import ninja.leaping.configurate.objectmapping.Setting;
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
@ -51,8 +50,8 @@ public void initDefaults() {
|
|||||||
userGroup = new CustomFlagGroupCategory();
|
userGroup = new CustomFlagGroupCategory();
|
||||||
}
|
}
|
||||||
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
|
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
|
||||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.USER_FLAGS) {
|
for (GDFlagDefinition definition : GDFlagDefinitions.USER_FLAGS) {
|
||||||
userGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
userGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||||
}
|
}
|
||||||
this.groups.put("user", userGroup);
|
this.groups.put("user", userGroup);
|
||||||
}
|
}
|
||||||
@ -60,8 +59,8 @@ public void initDefaults() {
|
|||||||
adminGroup = new CustomFlagGroupCategory();
|
adminGroup = new CustomFlagGroupCategory();
|
||||||
}
|
}
|
||||||
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
|
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
|
||||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.ADMIN_FLAGS) {
|
for (GDFlagDefinition definition : GDFlagDefinitions.ADMIN_FLAGS) {
|
||||||
adminGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
adminGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||||
}
|
}
|
||||||
adminGroup.isAdmin = true;
|
adminGroup.isAdmin = true;
|
||||||
this.groups.put("admin", adminGroup);
|
this.groups.put("admin", adminGroup);
|
||||||
|
@ -34,8 +34,10 @@
|
|||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
import com.griefdefender.api.permission.ContextKeys;
|
import com.griefdefender.api.permission.ContextKeys;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
import com.griefdefender.permission.flag.CustomFlagData;
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
|
import com.griefdefender.permission.flag.GDFlagData;
|
||||||
|
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||||
import com.griefdefender.registry.FlagRegistryModule;
|
import com.griefdefender.registry.FlagRegistryModule;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
@ -45,10 +47,10 @@
|
|||||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||||
|
|
||||||
public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefinition> {
|
public class FlagDefinitionSerializer implements TypeSerializer<FlagDefinition> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
|
public FlagDefinition deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
|
||||||
final String flagDisplayName = node.getKey().toString();
|
final String flagDisplayName = node.getKey().toString();
|
||||||
final boolean enabled = node.getNode("enabled").getBoolean();
|
final boolean enabled = node.getNode("enabled").getBoolean();
|
||||||
final String descr = node.getNode("description").getString();
|
final String descr = node.getNode("description").getString();
|
||||||
@ -63,7 +65,7 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
throw new ObjectMappingException("No permissions found for flag definition '" + flagDisplayName + "'. You must specify at least 1 or more permissions.");
|
throw new ObjectMappingException("No permissions found for flag definition '" + flagDisplayName + "'. You must specify at least 1 or more permissions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CustomFlagData> flagDataList = new ArrayList<>();
|
List<FlagData> flagDataList = new ArrayList<>();
|
||||||
for (String permissionEntry : permissionList) {
|
for (String permissionEntry : permissionList) {
|
||||||
String permission = permissionEntry.replace(" ", "");
|
String permission = permissionEntry.replace(" ", "");
|
||||||
String[] parts = permission.split(",");
|
String[] parts = permission.split(",");
|
||||||
@ -106,9 +108,9 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
throw new ObjectMappingException("No linked flag specified. You need to specify 'flag=<flagname>'.");
|
throw new ObjectMappingException("No linked flag specified. You need to specify 'flag=<flagname>'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
flagDataList.add(new CustomFlagData(linkedFlag, flagContexts));
|
flagDataList.add(new GDFlagData(linkedFlag, flagContexts));
|
||||||
}
|
}
|
||||||
final GDCustomFlagDefinition flagDefinition = new GDCustomFlagDefinition(flagDataList, flagDisplayName, description);
|
final GDFlagDefinition flagDefinition = new GDFlagDefinition(flagDataList, flagDisplayName, description);
|
||||||
flagDefinition.setIsEnabled(enabled);
|
flagDefinition.setIsEnabled(enabled);
|
||||||
Set<Context> contexts = new HashSet<>();
|
Set<Context> contexts = new HashSet<>();
|
||||||
if (contextList != null) {
|
if (contextList != null) {
|
||||||
@ -130,9 +132,8 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
|
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
|
||||||
// try UUID
|
// try UUID
|
||||||
if (value.length() == 36) {
|
if (value.length() == 36) {
|
||||||
UUID uuid = null;
|
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(value);
|
UUID.fromString(value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
|
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
|
||||||
}
|
}
|
||||||
@ -145,13 +146,13 @@ public GDCustomFlagDefinition deserialize(TypeToken<?> type, ConfigurationNode n
|
|||||||
contexts.add(new Context(key, value));
|
contexts.add(new Context(key, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flagDefinition.setDefinitionContexts(contexts);
|
flagDefinition.setContexts(contexts);
|
||||||
}
|
}
|
||||||
return flagDefinition;
|
return flagDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(TypeToken<?> type, GDCustomFlagDefinition obj, ConfigurationNode node) throws ObjectMappingException {
|
public void serialize(TypeToken<?> type, FlagDefinition obj, ConfigurationNode node) throws ObjectMappingException {
|
||||||
node.getNode("enabled").setValue(obj.isEnabled());
|
node.getNode("enabled").setValue(obj.isEnabled());
|
||||||
String description = "";
|
String description = "";
|
||||||
if (obj.getDescription() != TextComponent.empty()) {
|
if (obj.getDescription() != TextComponent.empty()) {
|
||||||
@ -159,17 +160,17 @@ public void serialize(TypeToken<?> type, GDCustomFlagDefinition obj, Configurati
|
|||||||
node.getNode("description").setValue(description);
|
node.getNode("description").setValue(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj.getDefinitionContexts().isEmpty()) {
|
if (!obj.getContexts().isEmpty()) {
|
||||||
List<String> contextList = new ArrayList<>();
|
List<String> contextList = new ArrayList<>();
|
||||||
ConfigurationNode contextNode = node.getNode("contexts");
|
ConfigurationNode contextNode = node.getNode("contexts");
|
||||||
for (Context context : obj.getDefinitionContexts()) {
|
for (Context context : obj.getContexts()) {
|
||||||
contextList.add(context.getKey().toLowerCase() + "=" + context.getValue().toLowerCase());
|
contextList.add(context.getKey().toLowerCase() + "=" + context.getValue().toLowerCase());
|
||||||
}
|
}
|
||||||
contextNode.setValue(contextList);
|
contextNode.setValue(contextList);
|
||||||
}
|
}
|
||||||
ConfigurationNode permissionNode = node.getNode("permissions");
|
ConfigurationNode permissionNode = node.getNode("permissions");
|
||||||
List<String> permissions = new ArrayList<>();
|
List<String> permissions = new ArrayList<>();
|
||||||
for (CustomFlagData flagData : obj.getFlagData()) {
|
for (FlagData flagData : obj.getFlagData()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
final Flag flag = flagData.getFlag();
|
final Flag flag = flagData.getFlag();
|
||||||
final Set<Context> dataContexts = flagData.getContexts();
|
final Set<Context> dataContexts = flagData.getContexts();
|
@ -44,6 +44,8 @@
|
|||||||
import com.griefdefender.api.permission.PermissionResult;
|
import com.griefdefender.api.permission.PermissionResult;
|
||||||
import com.griefdefender.api.permission.ResultTypes;
|
import com.griefdefender.api.permission.ResultTypes;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
import com.griefdefender.api.permission.flag.Flags;
|
||||||
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;
|
||||||
@ -1438,4 +1440,24 @@ public <T> T getActiveOptionValue(TypeToken<T> type, Option<T> option, Subject s
|
|||||||
Set<Context> contexts) {
|
Set<Context> contexts) {
|
||||||
return this.getInternalOptionValue(type, (GDPermissionHolder) subject, option, claim, claim.getType(), contexts);
|
return this.getInternalOptionValue(type, (GDPermissionHolder) subject, option, claim, claim.getType(), contexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<PermissionResult> setFlagDefinition(Subject subject, FlagDefinition flagDefinition, Tristate value) {
|
||||||
|
final Set<Context> contexts = new HashSet<>();
|
||||||
|
contexts.addAll(flagDefinition.getContexts());
|
||||||
|
PermissionResult result = null;
|
||||||
|
CompletableFuture<PermissionResult> future = new CompletableFuture<>();
|
||||||
|
for (FlagData flagData : flagDefinition.getFlagData()) {
|
||||||
|
final Set<Context> flagContexts = new HashSet<>(contexts);
|
||||||
|
flagContexts.addAll(flagData.getContexts());
|
||||||
|
result = PermissionUtil.getInstance().setPermissionValue((GDPermissionHolder) subject, flagData.getFlag(), value, flagContexts);
|
||||||
|
if (!result.successful()) {
|
||||||
|
future.complete(result);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
future.complete(result);
|
||||||
|
return future;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
import com.griefdefender.api.Tristate;
|
import com.griefdefender.api.Tristate;
|
||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
@ -40,17 +41,17 @@ public enum Type {
|
|||||||
UNDEFINED
|
UNDEFINED
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CustomFlagData flagData;
|
private final FlagData flagData;
|
||||||
private final Tristate value;
|
private final Tristate value;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
public GDActiveFlagData(CustomFlagData flagData, Tristate value, Type type) {
|
public GDActiveFlagData(FlagData flagData, Tristate value, Type type) {
|
||||||
this.flagData = flagData;
|
this.flagData = flagData;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomFlagData getFlagData() {
|
public FlagData getFlagData() {
|
||||||
return this.flagData;
|
return this.flagData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) bloodmc
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.griefdefender.permission.flag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.griefdefender.GriefDefenderPlugin;
|
|
||||||
import com.griefdefender.api.Tristate;
|
|
||||||
import com.griefdefender.api.permission.Context;
|
|
||||||
import com.griefdefender.api.permission.PermissionResult;
|
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
|
||||||
import com.griefdefender.claim.GDClaim;
|
|
||||||
import com.griefdefender.configuration.category.CustomFlagGroupCategory;
|
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
|
||||||
import net.kyori.text.TextComponent;
|
|
||||||
import net.kyori.text.format.TextColor;
|
|
||||||
|
|
||||||
public class GDCustomFlagDefinition {
|
|
||||||
|
|
||||||
private boolean enabled = true;
|
|
||||||
private Set<Context> definitionContexts = new HashSet<>();
|
|
||||||
private List<CustomFlagData> data = new ArrayList<>();
|
|
||||||
private String displayName;
|
|
||||||
private Tristate defaultValue = Tristate.UNDEFINED;
|
|
||||||
private Component description;
|
|
||||||
|
|
||||||
public GDCustomFlagDefinition(Flag flag, Set<Context> contexts, String displayName, Component description) {
|
|
||||||
this.data.add(new CustomFlagData(flag, contexts));
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GDCustomFlagDefinition(List<CustomFlagData> flagData, String displayName, Component description) {
|
|
||||||
this.data = flagData;
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFlagData(Flag flag, Set<Context> contexts) {
|
|
||||||
this.data.add(new CustomFlagData(flag, contexts));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Flag> getFlags() {
|
|
||||||
List<Flag> flags = new ArrayList<>();
|
|
||||||
for (CustomFlagData flagData : this.data) {
|
|
||||||
flags.add(flagData.getFlag());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CustomFlagData> getFlagData() {
|
|
||||||
return this.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component getDescription() {
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Context> getDefinitionContexts() {
|
|
||||||
return this.definitionContexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefinitionContexts(Set<Context> contexts) {
|
|
||||||
this.definitionContexts = contexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
return this.displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return this.enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultValue(Tristate value) {
|
|
||||||
this.defaultValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsEnabled(boolean val) {
|
|
||||||
this.enabled = val;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,415 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) bloodmc
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.griefdefender.permission.flag;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.griefdefender.api.Tristate;
|
|
||||||
import com.griefdefender.api.claim.ClaimContexts;
|
|
||||||
import com.griefdefender.api.permission.Context;
|
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
|
||||||
import com.griefdefender.api.permission.flag.Flags;
|
|
||||||
import com.griefdefender.cache.MessageCache;
|
|
||||||
import com.griefdefender.event.GDCauseStackManager;
|
|
||||||
|
|
||||||
public class GDCustomFlagDefinitions {
|
|
||||||
|
|
||||||
// ADMIN
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_BREAK;
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_GROW;
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_PLACE;
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_SPREAD;
|
|
||||||
public static final GDCustomFlagDefinition ENDERPEARL;
|
|
||||||
public static final GDCustomFlagDefinition EXIT_PLAYER;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_BLOCK;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_ENTITY;
|
|
||||||
public static final GDCustomFlagDefinition EXP_DROP;
|
|
||||||
public static final GDCustomFlagDefinition FALL_DAMAGE;
|
|
||||||
public static final GDCustomFlagDefinition INTERACT_BLOCK;
|
|
||||||
public static final GDCustomFlagDefinition INTERACT_ENTITY;
|
|
||||||
public static final GDCustomFlagDefinition INTERACT_INVENTORY;
|
|
||||||
public static final GDCustomFlagDefinition INVINCIBLE;
|
|
||||||
public static final GDCustomFlagDefinition ITEM_DROP;
|
|
||||||
public static final GDCustomFlagDefinition ITEM_PICKUP;
|
|
||||||
public static final GDCustomFlagDefinition MONSTER_DAMAGE;
|
|
||||||
public static final GDCustomFlagDefinition PISTONS;
|
|
||||||
public static final GDCustomFlagDefinition PORTAL_USE;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_MONSTER;
|
|
||||||
public static final GDCustomFlagDefinition TELEPORT_FROM;
|
|
||||||
public static final GDCustomFlagDefinition TELEPORT_TO;
|
|
||||||
public static final GDCustomFlagDefinition USE;
|
|
||||||
public static final GDCustomFlagDefinition VEHICLE_DESTROY;
|
|
||||||
public static final GDCustomFlagDefinition WITHER_DAMAGE;
|
|
||||||
|
|
||||||
// USER
|
|
||||||
public static final GDCustomFlagDefinition BLOCK_TRAMPLING;
|
|
||||||
public static final GDCustomFlagDefinition CHEST_ACCESS;
|
|
||||||
public static final GDCustomFlagDefinition CHORUS_FRUIT_TELEPORT;
|
|
||||||
public static final GDCustomFlagDefinition CROP_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition DAMAGE_ANIMALS;
|
|
||||||
public static final GDCustomFlagDefinition ENDERMAN_GRIEF;
|
|
||||||
public static final GDCustomFlagDefinition ENTER_PLAYER;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_CREEPER;
|
|
||||||
public static final GDCustomFlagDefinition EXPLOSION_TNT;
|
|
||||||
public static final GDCustomFlagDefinition FIRE_DAMAGE;
|
|
||||||
public static final GDCustomFlagDefinition FIRE_SPREAD;
|
|
||||||
public static final GDCustomFlagDefinition GRASS_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition ICE_FORM;
|
|
||||||
public static final GDCustomFlagDefinition ICE_MELT;
|
|
||||||
public static final GDCustomFlagDefinition LAVA_FLOW;
|
|
||||||
public static final GDCustomFlagDefinition LEAF_DECAY;
|
|
||||||
public static final GDCustomFlagDefinition LIGHTNING;
|
|
||||||
public static final GDCustomFlagDefinition LIGHTER;
|
|
||||||
public static final GDCustomFlagDefinition MUSHROOM_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition MYCELIUM_SPREAD;
|
|
||||||
public static final GDCustomFlagDefinition PVP;
|
|
||||||
public static final GDCustomFlagDefinition RIDE;
|
|
||||||
public static final GDCustomFlagDefinition SLEEP;
|
|
||||||
public static final GDCustomFlagDefinition SNOW_FALL;
|
|
||||||
public static final GDCustomFlagDefinition SNOW_MELT;
|
|
||||||
public static final GDCustomFlagDefinition SNOWMAN_TRAIL;
|
|
||||||
public static final GDCustomFlagDefinition SOIL_DRY;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_AMBIENT;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_ANIMAL;
|
|
||||||
public static final GDCustomFlagDefinition SPAWN_AQUATIC;
|
|
||||||
public static final GDCustomFlagDefinition VEHICLE_DESTROY_CLAIM;
|
|
||||||
public static final GDCustomFlagDefinition VEHICLE_PLACE;
|
|
||||||
public static final GDCustomFlagDefinition VINE_GROWTH;
|
|
||||||
public static final GDCustomFlagDefinition WATER_FLOW;
|
|
||||||
|
|
||||||
public static final List<GDCustomFlagDefinition> ADMIN_FLAGS = new ArrayList<>();
|
|
||||||
public static final List<GDCustomFlagDefinition> USER_FLAGS = new ArrayList<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
Set<Context> contexts = new HashSet<>();
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_BREAK = new GDCustomFlagDefinition(Flags.BLOCK_BREAK, contexts, "block-break", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_PLACE = new GDCustomFlagDefinition(Flags.BLOCK_PLACE, contexts, "block-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_GROW = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "block-grow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
BLOCK_SPREAD = new GDCustomFlagDefinition(Flags.BLOCK_SPREAD, contexts, "block-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD);
|
|
||||||
|
|
||||||
// ADMIN
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
|
||||||
ENDERPEARL = new GDCustomFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "enderpearl", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERPEARL);
|
|
||||||
ENDERPEARL.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
ENTER_PLAYER = new GDCustomFlagDefinition(Flags.ENTER_CLAIM, contexts, "enter-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
EXIT_PLAYER = new GDCustomFlagDefinition(Flags.ENTER_CLAIM, contexts, "exit-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
EXPLOSION_BLOCK = new GDCustomFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK);
|
|
||||||
EXPLOSION_BLOCK.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_CREEPER);
|
|
||||||
EXPLOSION_CREEPER = new GDCustomFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-creeper", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER);
|
|
||||||
EXPLOSION_CREEPER.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
EXPLOSION_ENTITY = new GDCustomFlagDefinition(Flags.EXPLOSION_ENTITY, contexts, "explosion-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY);
|
|
||||||
EXPLOSION_ENTITY.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_TNT);
|
|
||||||
EXPLOSION_TNT = new GDCustomFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-tnt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT);
|
|
||||||
EXPLOSION_TNT.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_XP_ORB);
|
|
||||||
EXP_DROP = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "exp-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_FALL);
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
FALL_DAMAGE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "fall-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
INTERACT_BLOCK = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "interact-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
INTERACT_ENTITY = new GDCustomFlagDefinition(Flags.INTERACT_ENTITY_SECONDARY, contexts, "interact-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
INTERACT_INVENTORY = new GDCustomFlagDefinition(Flags.INTERACT_INVENTORY, contexts, "interact-inventory", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
INVINCIBLE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "invincible", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INVINCIBLE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
ITEM_DROP = new GDCustomFlagDefinition(Flags.ITEM_DROP, contexts, "item-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_DROP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
ITEM_PICKUP = new GDCustomFlagDefinition(Flags.ITEM_PICKUP, contexts, "item-pickup", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
|
|
||||||
MONSTER_DAMAGE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "monster-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PISTON);
|
|
||||||
PISTONS = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "pistons", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTONS);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_PORTAL);
|
|
||||||
PORTAL_USE = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "portal-use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PORTAL_USE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
|
|
||||||
SPAWN_MONSTER = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-monster", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
TELEPORT_FROM = new GDCustomFlagDefinition(Flags.ENTITY_TELEPORT_FROM, contexts, "teleport-from", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
TELEPORT_TO = new GDCustomFlagDefinition(Flags.ENTITY_TELEPORT_TO, contexts, "teleport-to", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
VEHICLE_DESTROY = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
|
||||||
VEHICLE_DESTROY.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_WITHER);
|
|
||||||
WITHER_DAMAGE = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "wither-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE);
|
|
||||||
WITHER_DAMAGE.getDefinitionContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
|
||||||
|
|
||||||
ADMIN_FLAGS.add(BLOCK_BREAK);
|
|
||||||
ADMIN_FLAGS.add(BLOCK_PLACE);
|
|
||||||
ADMIN_FLAGS.add(BLOCK_GROW);
|
|
||||||
ADMIN_FLAGS.add(BLOCK_SPREAD);
|
|
||||||
ADMIN_FLAGS.add(ENDERPEARL);
|
|
||||||
ADMIN_FLAGS.add(ENTER_PLAYER);
|
|
||||||
ADMIN_FLAGS.add(EXIT_PLAYER);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_BLOCK);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_CREEPER);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_ENTITY);
|
|
||||||
ADMIN_FLAGS.add(EXPLOSION_TNT);
|
|
||||||
ADMIN_FLAGS.add(EXP_DROP);
|
|
||||||
ADMIN_FLAGS.add(FALL_DAMAGE);
|
|
||||||
ADMIN_FLAGS.add(INTERACT_BLOCK);
|
|
||||||
ADMIN_FLAGS.add(INTERACT_ENTITY);
|
|
||||||
ADMIN_FLAGS.add(INTERACT_INVENTORY);
|
|
||||||
ADMIN_FLAGS.add(INVINCIBLE);
|
|
||||||
ADMIN_FLAGS.add(ITEM_DROP);
|
|
||||||
ADMIN_FLAGS.add(ITEM_PICKUP);
|
|
||||||
ADMIN_FLAGS.add(MONSTER_DAMAGE);
|
|
||||||
ADMIN_FLAGS.add(PISTONS);
|
|
||||||
ADMIN_FLAGS.add(SPAWN_MONSTER);
|
|
||||||
ADMIN_FLAGS.add(TELEPORT_FROM);
|
|
||||||
ADMIN_FLAGS.add(TELEPORT_TO);
|
|
||||||
ADMIN_FLAGS.add(VEHICLE_DESTROY);
|
|
||||||
ADMIN_FLAGS.add(WITHER_DAMAGE);
|
|
||||||
|
|
||||||
|
|
||||||
// USER
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_FARMLAND);
|
|
||||||
contexts.add(FlagContexts.TARGET_TURTLE_EGG);
|
|
||||||
BLOCK_TRAMPLING = new GDCustomFlagDefinition(Flags.COLLIDE_BLOCK, contexts, "block-trampling", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_CHEST);
|
|
||||||
CHEST_ACCESS = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "chest-access", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS);
|
|
||||||
CHEST_ACCESS.addFlagData(Flags.INTERACT_INVENTORY, contexts);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_CHORUS_FRUIT);
|
|
||||||
CHORUS_FRUIT_TELEPORT = new GDCustomFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "chorus-fruit-teleport", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_CROP);
|
|
||||||
CROP_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "crop-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
|
||||||
DAMAGE_ANIMALS = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "damage-animals", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
|
||||||
ENDERMAN_GRIEF = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "enderman-grief", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_FIRE);
|
|
||||||
FIRE_DAMAGE = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "fire-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_FIRE);
|
|
||||||
FIRE_SPREAD = new GDCustomFlagDefinition(Flags.BLOCK_SPREAD, contexts, "fire-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_GRASS);
|
|
||||||
GRASS_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "grass-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_ICE_FORM);
|
|
||||||
ICE_FORM = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-form", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_ICE_MELT);
|
|
||||||
ICE_MELT = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_LAVA);
|
|
||||||
LAVA_FLOW = new GDCustomFlagDefinition(Flags.LIQUID_FLOW, contexts, "lava-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
LEAF_DECAY = new GDCustomFlagDefinition(Flags.LEAF_DECAY, contexts, "leaf-decay", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_LIGHTNING_BOLT);
|
|
||||||
LIGHTNING = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "lightning", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_FLINTANDSTEEL);
|
|
||||||
LIGHTER = new GDCustomFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "lighter", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_MUSHROOM);
|
|
||||||
MUSHROOM_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "mushroom-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_MYCELIUM);
|
|
||||||
MYCELIUM_SPREAD = new GDCustomFlagDefinition(Flags.BLOCK_SPREAD, contexts, "mycelium-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_PLAYER);
|
|
||||||
PVP = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "pvp", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
RIDE = new GDCustomFlagDefinition(Flags.ENTITY_RIDING, contexts, "ride", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
contexts.add(FlagContexts.TARGET_BED);
|
|
||||||
SLEEP = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "sleep", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
|
||||||
SNOW_FALL = new GDCustomFlagDefinition(Flags.BLOCK_PLACE, contexts, "snow-fall", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
|
||||||
SNOW_MELT = new GDCustomFlagDefinition(Flags.BLOCK_BREAK, contexts, "snow-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_SNOWMAN);
|
|
||||||
SNOWMAN_TRAIL = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "snowman-trail", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.STATE_FARMLAND_DRY);
|
|
||||||
SOIL_DRY = new GDCustomFlagDefinition(Flags.BLOCK_MODIFY, contexts, "soil-dry", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_AMBIENT);
|
|
||||||
SPAWN_AMBIENT = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-ambient", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
|
||||||
SPAWN_ANIMAL = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-animal", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_AQUATIC);
|
|
||||||
SPAWN_AQUATIC = new GDCustomFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-aquatic", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_PLAYER);
|
|
||||||
USE = new GDCustomFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_USE);
|
|
||||||
USE.addFlagData(Flags.INTERACT_ENTITY_SECONDARY, new HashSet<>(contexts));
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
VEHICLE_DESTROY_CLAIM = new GDCustomFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
|
||||||
VEHICLE_PLACE = new GDCustomFlagDefinition(Flags.BLOCK_PLACE, contexts, "vehicle-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.TARGET_VINE);
|
|
||||||
VINE_GROWTH = new GDCustomFlagDefinition(Flags.BLOCK_GROW, contexts, "vine-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH);
|
|
||||||
|
|
||||||
contexts = new HashSet<>();
|
|
||||||
contexts.add(FlagContexts.SOURCE_WATER);
|
|
||||||
WATER_FLOW = new GDCustomFlagDefinition(Flags.LIQUID_FLOW, contexts, "water-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW);
|
|
||||||
|
|
||||||
USER_FLAGS.add(CHEST_ACCESS);
|
|
||||||
USER_FLAGS.add(CHORUS_FRUIT_TELEPORT);
|
|
||||||
USER_FLAGS.add(CROP_GROWTH);
|
|
||||||
USER_FLAGS.add(DAMAGE_ANIMALS);
|
|
||||||
USER_FLAGS.add(ENDERMAN_GRIEF);
|
|
||||||
USER_FLAGS.add(FIRE_DAMAGE);
|
|
||||||
USER_FLAGS.add(FIRE_SPREAD);
|
|
||||||
USER_FLAGS.add(GRASS_GROWTH);
|
|
||||||
USER_FLAGS.add(ICE_FORM);
|
|
||||||
USER_FLAGS.add(ICE_MELT);
|
|
||||||
USER_FLAGS.add(LAVA_FLOW);
|
|
||||||
USER_FLAGS.add(LEAF_DECAY);
|
|
||||||
USER_FLAGS.add(LIGHTER);
|
|
||||||
USER_FLAGS.add(LIGHTNING);
|
|
||||||
USER_FLAGS.add(MYCELIUM_SPREAD);
|
|
||||||
USER_FLAGS.add(PVP);
|
|
||||||
USER_FLAGS.add(RIDE);
|
|
||||||
USER_FLAGS.add(SLEEP);
|
|
||||||
USER_FLAGS.add(SNOW_FALL);
|
|
||||||
USER_FLAGS.add(SNOW_MELT);
|
|
||||||
USER_FLAGS.add(SOIL_DRY);
|
|
||||||
USER_FLAGS.add(SPAWN_AMBIENT);
|
|
||||||
USER_FLAGS.add(SPAWN_ANIMAL);
|
|
||||||
USER_FLAGS.add(SPAWN_AQUATIC);
|
|
||||||
USER_FLAGS.add(USE);
|
|
||||||
USER_FLAGS.add(VEHICLE_DESTROY_CLAIM);
|
|
||||||
USER_FLAGS.add(VEHICLE_PLACE);
|
|
||||||
USER_FLAGS.add(WATER_FLOW);
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,29 +24,36 @@
|
|||||||
*/
|
*/
|
||||||
package com.griefdefender.permission.flag;
|
package com.griefdefender.permission.flag;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.griefdefender.api.permission.Context;
|
import com.griefdefender.api.permission.Context;
|
||||||
import com.griefdefender.api.permission.flag.Flag;
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
|
||||||
public class CustomFlagData {
|
public class GDFlagData implements FlagData {
|
||||||
|
|
||||||
private Flag flag;
|
private Flag flag;
|
||||||
private Set<Context> contexts;
|
private Set<Context> contexts;
|
||||||
|
|
||||||
public CustomFlagData(Flag flag, Set<Context> contexts) {
|
public GDFlagData(Flag flag, Set<Context> contexts) {
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.contexts = contexts;
|
this.contexts = contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Set<Context> getContexts() {
|
public Set<Context> getContexts() {
|
||||||
return this.contexts;
|
return this.contexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Flag getFlag() {
|
public Flag getFlag() {
|
||||||
return this.flag;
|
return this.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
||||||
for (Context context : this.contexts) {
|
for (Context context : this.contexts) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
@ -62,4 +69,36 @@ public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class FlagDataBuilder implements Builder {
|
||||||
|
|
||||||
|
private Flag flag;
|
||||||
|
private Set<Context> contexts = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder flag(Flag flag) {
|
||||||
|
this.flag = flag;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder contexts(Set<Context> contexts) {
|
||||||
|
this.contexts = contexts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder reset() {
|
||||||
|
this.flag = null;
|
||||||
|
this.contexts = new HashSet<>();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlagData build() {
|
||||||
|
checkNotNull(this.flag);
|
||||||
|
return new GDFlagData(this.flag, this.contexts);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) bloodmc
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.griefdefender.permission.flag;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.griefdefender.GriefDefenderPlugin;
|
||||||
|
import com.griefdefender.api.Tristate;
|
||||||
|
import com.griefdefender.api.permission.Context;
|
||||||
|
import com.griefdefender.api.permission.flag.Flag;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagData;
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
|
import com.griefdefender.registry.FlagDefinitionRegistryModule;
|
||||||
|
|
||||||
|
import net.kyori.text.Component;
|
||||||
|
import net.kyori.text.TextComponent;
|
||||||
|
import net.kyori.text.serializer.plain.PlainComponentSerializer;
|
||||||
|
|
||||||
|
public class GDFlagDefinition implements FlagDefinition {
|
||||||
|
|
||||||
|
private boolean enabled = true;
|
||||||
|
private Set<Context> definitionContexts = new HashSet<>();
|
||||||
|
private List<FlagData> data = new ArrayList<>();
|
||||||
|
private String displayName;
|
||||||
|
private String groupName;
|
||||||
|
private Tristate defaultValue = Tristate.UNDEFINED;
|
||||||
|
private Component description;
|
||||||
|
|
||||||
|
public GDFlagDefinition(Flag flag, Set<Context> contexts, String displayName, Component description) {
|
||||||
|
this.data.add(new GDFlagData(flag, contexts));
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.description = description;
|
||||||
|
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GDFlagDefinition(List<FlagData> flagData, String displayName, Component description) {
|
||||||
|
this.data = flagData;
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.description = description;
|
||||||
|
FlagDefinitionRegistryModule.getInstance().registerCustomType(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFlagData(Flag flag, Set<Context> contexts) {
|
||||||
|
this.data.add(new GDFlagData(flag, contexts));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFlagData(FlagData flagData) {
|
||||||
|
this.data.add(new GDFlagData(flagData.getFlag(), flagData.getContexts()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Flag> getFlags() {
|
||||||
|
List<Flag> flags = new ArrayList<>();
|
||||||
|
for (FlagData flagData : this.data) {
|
||||||
|
flags.add(flagData.getFlag());
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FlagData> getFlagData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFriendlyDescription() {
|
||||||
|
if (this.description == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlainComponentSerializer.INSTANCE.serialize(this.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Context> getContexts() {
|
||||||
|
return this.definitionContexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContexts(Set<Context> contexts) {
|
||||||
|
this.definitionContexts = contexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsEnabled(boolean val) {
|
||||||
|
this.enabled = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return GriefDefenderPlugin.MOD_ID + ":" + this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGroupName() {
|
||||||
|
return this.groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGroupName(String group) {
|
||||||
|
this.groupName = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tristate getDefaultValue() {
|
||||||
|
return this.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefaultValue(Tristate value) {
|
||||||
|
this.defaultValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FlagDefinitionBuilder implements Builder {
|
||||||
|
|
||||||
|
private boolean enabled = true;
|
||||||
|
private Set<Context> definitionContexts = new HashSet<>();
|
||||||
|
private List<FlagData> data = new ArrayList<>();
|
||||||
|
private String displayName;
|
||||||
|
private String groupName;
|
||||||
|
private Tristate defaultValue = Tristate.UNDEFINED;
|
||||||
|
private Component description = TextComponent.empty();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder enabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder defaultValue(Tristate value) {
|
||||||
|
this.defaultValue = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder flagData(List<FlagData> data) {
|
||||||
|
this.data = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder contexts(Set<Context> contexts) {
|
||||||
|
this.definitionContexts = contexts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.displayName = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder description(Component description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder reset() {
|
||||||
|
this.enabled = true;
|
||||||
|
this.definitionContexts = new HashSet<>();
|
||||||
|
this.data = new ArrayList<>();
|
||||||
|
this.displayName = "";
|
||||||
|
this.groupName = "";
|
||||||
|
this.defaultValue = Tristate.UNDEFINED;
|
||||||
|
this.description = TextComponent.empty();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlagDefinition build() {
|
||||||
|
checkNotNull(this.data);
|
||||||
|
checkNotNull(this.displayName);
|
||||||
|
checkNotNull(this.groupName);
|
||||||
|
checkNotNull(this.description);
|
||||||
|
final GDFlagDefinition definition = new GDFlagDefinition(this.data, this.displayName, this.description);
|
||||||
|
definition.setContexts(this.definitionContexts);
|
||||||
|
definition.setIsEnabled(this.enabled);
|
||||||
|
definition.setDefaultValue(this.defaultValue);
|
||||||
|
definition.setGroupName(this.groupName);
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,412 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) bloodmc
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.griefdefender.permission.flag;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.griefdefender.api.claim.ClaimContexts;
|
||||||
|
import com.griefdefender.api.permission.Context;
|
||||||
|
import com.griefdefender.api.permission.flag.Flags;
|
||||||
|
import com.griefdefender.cache.MessageCache;
|
||||||
|
|
||||||
|
public class GDFlagDefinitions {
|
||||||
|
|
||||||
|
// ADMIN
|
||||||
|
public static final GDFlagDefinition BLOCK_BREAK;
|
||||||
|
public static final GDFlagDefinition BLOCK_GROW;
|
||||||
|
public static final GDFlagDefinition BLOCK_PLACE;
|
||||||
|
public static final GDFlagDefinition BLOCK_SPREAD;
|
||||||
|
public static final GDFlagDefinition ENDERPEARL;
|
||||||
|
public static final GDFlagDefinition EXIT_PLAYER;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_BLOCK;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_ENTITY;
|
||||||
|
public static final GDFlagDefinition EXP_DROP;
|
||||||
|
public static final GDFlagDefinition FALL_DAMAGE;
|
||||||
|
public static final GDFlagDefinition INTERACT_BLOCK;
|
||||||
|
public static final GDFlagDefinition INTERACT_ENTITY;
|
||||||
|
public static final GDFlagDefinition INTERACT_INVENTORY;
|
||||||
|
public static final GDFlagDefinition INVINCIBLE;
|
||||||
|
public static final GDFlagDefinition ITEM_DROP;
|
||||||
|
public static final GDFlagDefinition ITEM_PICKUP;
|
||||||
|
public static final GDFlagDefinition MONSTER_DAMAGE;
|
||||||
|
public static final GDFlagDefinition PISTONS;
|
||||||
|
public static final GDFlagDefinition PORTAL_USE;
|
||||||
|
public static final GDFlagDefinition SPAWN_MONSTER;
|
||||||
|
public static final GDFlagDefinition TELEPORT_FROM;
|
||||||
|
public static final GDFlagDefinition TELEPORT_TO;
|
||||||
|
public static final GDFlagDefinition USE;
|
||||||
|
public static final GDFlagDefinition VEHICLE_DESTROY;
|
||||||
|
public static final GDFlagDefinition WITHER_DAMAGE;
|
||||||
|
|
||||||
|
// USER
|
||||||
|
public static final GDFlagDefinition BLOCK_TRAMPLING;
|
||||||
|
public static final GDFlagDefinition CHEST_ACCESS;
|
||||||
|
public static final GDFlagDefinition CHORUS_FRUIT_TELEPORT;
|
||||||
|
public static final GDFlagDefinition CROP_GROWTH;
|
||||||
|
public static final GDFlagDefinition DAMAGE_ANIMALS;
|
||||||
|
public static final GDFlagDefinition ENDERMAN_GRIEF;
|
||||||
|
public static final GDFlagDefinition ENTER_PLAYER;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_CREEPER;
|
||||||
|
public static final GDFlagDefinition EXPLOSION_TNT;
|
||||||
|
public static final GDFlagDefinition FIRE_DAMAGE;
|
||||||
|
public static final GDFlagDefinition FIRE_SPREAD;
|
||||||
|
public static final GDFlagDefinition GRASS_GROWTH;
|
||||||
|
public static final GDFlagDefinition ICE_FORM;
|
||||||
|
public static final GDFlagDefinition ICE_MELT;
|
||||||
|
public static final GDFlagDefinition LAVA_FLOW;
|
||||||
|
public static final GDFlagDefinition LEAF_DECAY;
|
||||||
|
public static final GDFlagDefinition LIGHTNING;
|
||||||
|
public static final GDFlagDefinition LIGHTER;
|
||||||
|
public static final GDFlagDefinition MUSHROOM_GROWTH;
|
||||||
|
public static final GDFlagDefinition MYCELIUM_SPREAD;
|
||||||
|
public static final GDFlagDefinition PVP;
|
||||||
|
public static final GDFlagDefinition RIDE;
|
||||||
|
public static final GDFlagDefinition SLEEP;
|
||||||
|
public static final GDFlagDefinition SNOW_FALL;
|
||||||
|
public static final GDFlagDefinition SNOW_MELT;
|
||||||
|
public static final GDFlagDefinition SNOWMAN_TRAIL;
|
||||||
|
public static final GDFlagDefinition SOIL_DRY;
|
||||||
|
public static final GDFlagDefinition SPAWN_AMBIENT;
|
||||||
|
public static final GDFlagDefinition SPAWN_ANIMAL;
|
||||||
|
public static final GDFlagDefinition SPAWN_AQUATIC;
|
||||||
|
public static final GDFlagDefinition VEHICLE_DESTROY_CLAIM;
|
||||||
|
public static final GDFlagDefinition VEHICLE_PLACE;
|
||||||
|
public static final GDFlagDefinition VINE_GROWTH;
|
||||||
|
public static final GDFlagDefinition WATER_FLOW;
|
||||||
|
|
||||||
|
public static final List<GDFlagDefinition> ADMIN_FLAGS = new ArrayList<>();
|
||||||
|
public static final List<GDFlagDefinition> USER_FLAGS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Set<Context> contexts = new HashSet<>();
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_BREAK = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "block-break", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_BREAK);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_PLACE = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "block-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_PLACE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_GROW = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "block-grow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_GROW);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
BLOCK_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "block-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_SPREAD);
|
||||||
|
|
||||||
|
// ADMIN
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
||||||
|
ENDERPEARL = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "enderpearl", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERPEARL);
|
||||||
|
ENDERPEARL.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
ENTER_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "enter-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENTER_PLAYER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
EXIT_PLAYER = new GDFlagDefinition(Flags.ENTER_CLAIM, contexts, "exit-player", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXIT_PLAYER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
EXPLOSION_BLOCK = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_BLOCK);
|
||||||
|
EXPLOSION_BLOCK.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_CREEPER);
|
||||||
|
EXPLOSION_CREEPER = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-creeper", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_CREEPER);
|
||||||
|
EXPLOSION_CREEPER.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
EXPLOSION_ENTITY = new GDFlagDefinition(Flags.EXPLOSION_ENTITY, contexts, "explosion-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_ENTITY);
|
||||||
|
EXPLOSION_ENTITY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_TNT);
|
||||||
|
EXPLOSION_TNT = new GDFlagDefinition(Flags.EXPLOSION_BLOCK, contexts, "explosion-tnt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXPLOSION_TNT);
|
||||||
|
EXPLOSION_TNT.addFlagData(Flags.EXPLOSION_ENTITY, contexts);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_XP_ORB);
|
||||||
|
EXP_DROP = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "exp-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_EXP_DROP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_FALL);
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
FALL_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "fall-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FALL_DAMAGE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
INTERACT_BLOCK = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "interact-block", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_BLOCK);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
INTERACT_ENTITY = new GDFlagDefinition(Flags.INTERACT_ENTITY_SECONDARY, contexts, "interact-entity", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_ENTITY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
INTERACT_INVENTORY = new GDFlagDefinition(Flags.INTERACT_INVENTORY, contexts, "interact-inventory", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INTERACT_INVENTORY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
INVINCIBLE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "invincible", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_INVINCIBLE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
ITEM_DROP = new GDFlagDefinition(Flags.ITEM_DROP, contexts, "item-drop", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_DROP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
ITEM_PICKUP = new GDFlagDefinition(Flags.ITEM_PICKUP, contexts, "item-pickup", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ITEM_PICKUP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_TYPE_MONSTER);
|
||||||
|
MONSTER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "monster-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MONSTER_DAMAGE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PISTON);
|
||||||
|
PISTONS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "pistons", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PISTONS);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_PORTAL);
|
||||||
|
PORTAL_USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "portal-use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PORTAL_USE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_MONSTER);
|
||||||
|
SPAWN_MONSTER = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-monster", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_MONSTER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
TELEPORT_FROM = new GDFlagDefinition(Flags.ENTITY_TELEPORT_FROM, contexts, "teleport-from", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_FROM);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
TELEPORT_TO = new GDFlagDefinition(Flags.ENTITY_TELEPORT_TO, contexts, "teleport-to", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_TELEPORT_TO);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
VEHICLE_DESTROY = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
||||||
|
VEHICLE_DESTROY.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_WITHER);
|
||||||
|
WITHER_DAMAGE = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "wither-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WITHER_DAMAGE);
|
||||||
|
WITHER_DAMAGE.getContexts().add(ClaimContexts.GLOBAL_DEFAULT_CONTEXT);
|
||||||
|
|
||||||
|
ADMIN_FLAGS.add(BLOCK_BREAK);
|
||||||
|
ADMIN_FLAGS.add(BLOCK_PLACE);
|
||||||
|
ADMIN_FLAGS.add(BLOCK_GROW);
|
||||||
|
ADMIN_FLAGS.add(BLOCK_SPREAD);
|
||||||
|
ADMIN_FLAGS.add(ENDERPEARL);
|
||||||
|
ADMIN_FLAGS.add(ENTER_PLAYER);
|
||||||
|
ADMIN_FLAGS.add(EXIT_PLAYER);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_BLOCK);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_CREEPER);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_ENTITY);
|
||||||
|
ADMIN_FLAGS.add(EXPLOSION_TNT);
|
||||||
|
ADMIN_FLAGS.add(EXP_DROP);
|
||||||
|
ADMIN_FLAGS.add(FALL_DAMAGE);
|
||||||
|
ADMIN_FLAGS.add(INTERACT_BLOCK);
|
||||||
|
ADMIN_FLAGS.add(INTERACT_ENTITY);
|
||||||
|
ADMIN_FLAGS.add(INTERACT_INVENTORY);
|
||||||
|
ADMIN_FLAGS.add(INVINCIBLE);
|
||||||
|
ADMIN_FLAGS.add(ITEM_DROP);
|
||||||
|
ADMIN_FLAGS.add(ITEM_PICKUP);
|
||||||
|
ADMIN_FLAGS.add(MONSTER_DAMAGE);
|
||||||
|
ADMIN_FLAGS.add(PISTONS);
|
||||||
|
ADMIN_FLAGS.add(SPAWN_MONSTER);
|
||||||
|
ADMIN_FLAGS.add(TELEPORT_FROM);
|
||||||
|
ADMIN_FLAGS.add(TELEPORT_TO);
|
||||||
|
ADMIN_FLAGS.add(VEHICLE_DESTROY);
|
||||||
|
ADMIN_FLAGS.add(WITHER_DAMAGE);
|
||||||
|
|
||||||
|
|
||||||
|
// USER
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_FARMLAND);
|
||||||
|
contexts.add(FlagContexts.TARGET_TURTLE_EGG);
|
||||||
|
BLOCK_TRAMPLING = new GDFlagDefinition(Flags.COLLIDE_BLOCK, contexts, "block-trampling", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_BLOCK_TRAMPLING);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_CHEST);
|
||||||
|
CHEST_ACCESS = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "chest-access", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHEST_ACCESS);
|
||||||
|
CHEST_ACCESS.addFlagData(Flags.INTERACT_INVENTORY, contexts);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_CHORUS_FRUIT);
|
||||||
|
CHORUS_FRUIT_TELEPORT = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "chorus-fruit-teleport", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CHORUS_FRUIT_TELEPORT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_CROP);
|
||||||
|
CROP_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "crop-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_CROP_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
||||||
|
DAMAGE_ANIMALS = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "damage-animals", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_DAMAGE_ANIMALS);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_ENDERMAN);
|
||||||
|
ENDERMAN_GRIEF = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "enderman-grief", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ENDERMAN_GRIEF);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_FIRE);
|
||||||
|
FIRE_DAMAGE = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "fire-damage", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_DAMAGE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_FIRE);
|
||||||
|
FIRE_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "fire-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_FIRE_SPREAD);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_GRASS);
|
||||||
|
GRASS_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "grass-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_GRASS_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_ICE_FORM);
|
||||||
|
ICE_FORM = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-form", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_FORM);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_ICE_MELT);
|
||||||
|
ICE_MELT = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "ice-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_ICE_MELT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_LAVA);
|
||||||
|
LAVA_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "lava-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LAVA_FLOW);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
LEAF_DECAY = new GDFlagDefinition(Flags.LEAF_DECAY, contexts, "leaf-decay", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LEAF_DECAY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_LIGHTNING_BOLT);
|
||||||
|
LIGHTNING = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "lightning", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTNING);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_FLINTANDSTEEL);
|
||||||
|
LIGHTER = new GDFlagDefinition(Flags.INTERACT_ITEM_SECONDARY, contexts, "lighter", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_LIGHTER);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_MUSHROOM);
|
||||||
|
MUSHROOM_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "mushroom-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MUSHROOM_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_MYCELIUM);
|
||||||
|
MYCELIUM_SPREAD = new GDFlagDefinition(Flags.BLOCK_SPREAD, contexts, "mycelium-spread", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_MYCELIUM_SPREAD);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_PLAYER);
|
||||||
|
PVP = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "pvp", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_PVP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
RIDE = new GDFlagDefinition(Flags.ENTITY_RIDING, contexts, "ride", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_RIDE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
contexts.add(FlagContexts.TARGET_BED);
|
||||||
|
SLEEP = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "sleep", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SLEEP);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
||||||
|
SNOW_FALL = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "snow-fall", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_FALL);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_SNOW_LAYER);
|
||||||
|
SNOW_MELT = new GDFlagDefinition(Flags.BLOCK_BREAK, contexts, "snow-melt", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOW_MELT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_SNOWMAN);
|
||||||
|
SNOWMAN_TRAIL = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "snowman-trail", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SNOWMAN_TRAIL);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.STATE_FARMLAND_DRY);
|
||||||
|
SOIL_DRY = new GDFlagDefinition(Flags.BLOCK_MODIFY, contexts, "soil-dry", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SOIL_DRY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_AMBIENT);
|
||||||
|
SPAWN_AMBIENT = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-ambient", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AMBIENT);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_ANIMAL);
|
||||||
|
SPAWN_ANIMAL = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-animal", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_ANIMAL);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_AQUATIC);
|
||||||
|
SPAWN_AQUATIC = new GDFlagDefinition(Flags.ENTITY_SPAWN, contexts, "spawn-aquatic", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_SPAWN_AQUATIC);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_PLAYER);
|
||||||
|
USE = new GDFlagDefinition(Flags.INTERACT_BLOCK_SECONDARY, contexts, "use", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_USE);
|
||||||
|
USE.addFlagData(Flags.INTERACT_ENTITY_SECONDARY, new HashSet<>(contexts));
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
VEHICLE_DESTROY_CLAIM = new GDFlagDefinition(Flags.ENTITY_DAMAGE, contexts, "vehicle-destroy", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_DESTROY);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_TYPE_VEHICLE);
|
||||||
|
VEHICLE_PLACE = new GDFlagDefinition(Flags.BLOCK_PLACE, contexts, "vehicle-place", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VEHICLE_PLACE);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.TARGET_VINE);
|
||||||
|
VINE_GROWTH = new GDFlagDefinition(Flags.BLOCK_GROW, contexts, "vine-growth", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_VINE_GROWTH);
|
||||||
|
|
||||||
|
contexts = new HashSet<>();
|
||||||
|
contexts.add(FlagContexts.SOURCE_WATER);
|
||||||
|
WATER_FLOW = new GDFlagDefinition(Flags.LIQUID_FLOW, contexts, "water-flow", MessageCache.getInstance().FLAG_DESCRIPTION_CUSTOM_WATER_FLOW);
|
||||||
|
|
||||||
|
USER_FLAGS.add(CHEST_ACCESS);
|
||||||
|
USER_FLAGS.add(CHORUS_FRUIT_TELEPORT);
|
||||||
|
USER_FLAGS.add(CROP_GROWTH);
|
||||||
|
USER_FLAGS.add(DAMAGE_ANIMALS);
|
||||||
|
USER_FLAGS.add(ENDERMAN_GRIEF);
|
||||||
|
USER_FLAGS.add(FIRE_DAMAGE);
|
||||||
|
USER_FLAGS.add(FIRE_SPREAD);
|
||||||
|
USER_FLAGS.add(GRASS_GROWTH);
|
||||||
|
USER_FLAGS.add(ICE_FORM);
|
||||||
|
USER_FLAGS.add(ICE_MELT);
|
||||||
|
USER_FLAGS.add(LAVA_FLOW);
|
||||||
|
USER_FLAGS.add(LEAF_DECAY);
|
||||||
|
USER_FLAGS.add(LIGHTER);
|
||||||
|
USER_FLAGS.add(LIGHTNING);
|
||||||
|
USER_FLAGS.add(MYCELIUM_SPREAD);
|
||||||
|
USER_FLAGS.add(PVP);
|
||||||
|
USER_FLAGS.add(RIDE);
|
||||||
|
USER_FLAGS.add(SLEEP);
|
||||||
|
USER_FLAGS.add(SNOW_FALL);
|
||||||
|
USER_FLAGS.add(SNOW_MELT);
|
||||||
|
USER_FLAGS.add(SOIL_DRY);
|
||||||
|
USER_FLAGS.add(SPAWN_AMBIENT);
|
||||||
|
USER_FLAGS.add(SPAWN_ANIMAL);
|
||||||
|
USER_FLAGS.add(SPAWN_AQUATIC);
|
||||||
|
USER_FLAGS.add(USE);
|
||||||
|
USER_FLAGS.add(VEHICLE_DESTROY_CLAIM);
|
||||||
|
USER_FLAGS.add(VEHICLE_PLACE);
|
||||||
|
USER_FLAGS.add(WATER_FLOW);
|
||||||
|
}
|
||||||
|
}
|
@ -37,12 +37,12 @@
|
|||||||
|
|
||||||
import net.kyori.text.format.TextColor;
|
import net.kyori.text.format.TextColor;
|
||||||
|
|
||||||
public class FlagData {
|
public class UIFlagData {
|
||||||
|
|
||||||
public Flag flag;
|
public Flag flag;
|
||||||
public Map<Integer, FlagContextHolder> flagContextMap = new HashMap<>();
|
public Map<Integer, FlagContextHolder> flagContextMap = new HashMap<>();
|
||||||
|
|
||||||
public FlagData(Flag flag, Boolean value, MenuType type, Set<Context> contexts) {
|
public UIFlagData(Flag flag, Boolean value, MenuType type, Set<Context> contexts) {
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.addContexts(flag, value, type, contexts);
|
this.addContexts(flag, value, type, contexts);
|
||||||
}
|
}
|
@ -40,7 +40,7 @@
|
|||||||
import com.griefdefender.cache.MessageCache;
|
import com.griefdefender.cache.MessageCache;
|
||||||
import com.griefdefender.configuration.MessageStorage;
|
import com.griefdefender.configuration.MessageStorage;
|
||||||
import com.griefdefender.permission.GDPermissions;
|
import com.griefdefender.permission.GDPermissions;
|
||||||
import com.griefdefender.permission.ui.FlagData.FlagContextHolder;
|
import com.griefdefender.permission.ui.UIFlagData.FlagContextHolder;
|
||||||
|
|
||||||
import net.kyori.text.Component;
|
import net.kyori.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of GriefDefender, licensed under the MIT License (MIT).
|
||||||
|
*
|
||||||
|
* Copyright (c) bloodmc
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.griefdefender.registry;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.griefdefender.api.permission.flag.FlagDefinition;
|
||||||
|
import com.griefdefender.api.registry.CatalogRegistryModule;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class FlagDefinitionRegistryModule implements CatalogRegistryModule<FlagDefinition> {
|
||||||
|
|
||||||
|
private static FlagDefinitionRegistryModule instance;
|
||||||
|
|
||||||
|
public static FlagDefinitionRegistryModule getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<String, FlagDefinition> registryMap = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<FlagDefinition> getById(String id) {
|
||||||
|
if (id == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!id.contains(":")) {
|
||||||
|
id = "griefdefender:" + id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.ofNullable(this.registryMap.get(checkNotNull(id.toLowerCase())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<FlagDefinition> getAll() {
|
||||||
|
return this.registryMap.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerDefaults() {
|
||||||
|
// Currently done via config
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerCustomType(FlagDefinition type) {
|
||||||
|
this.registryMap.put(type.getId().toLowerCase(Locale.ENGLISH), type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
instance = new FlagDefinitionRegistryModule();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user