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.ClaimType;
|
|||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.economy.BankTransaction;
|
||||
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.type.CreateModeType;
|
||||
import com.griefdefender.api.permission.option.type.GameModeType;
|
||||
|
@ -155,7 +157,7 @@ import com.griefdefender.configuration.category.BlacklistCategory;
|
|||
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
|
||||
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
|
||||
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.WeatherTypeSerializer;
|
||||
import com.griefdefender.configuration.type.ConfigBase;
|
||||
|
@ -183,7 +185,8 @@ import com.griefdefender.permission.ContextGroupKeys;
|
|||
import com.griefdefender.permission.GDPermissionHolder;
|
||||
import com.griefdefender.permission.GDPermissionManager;
|
||||
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.provider.DynmapProvider;
|
||||
import com.griefdefender.provider.EssentialsProvider;
|
||||
|
@ -194,6 +197,7 @@ import com.griefdefender.provider.VaultProvider;
|
|||
import com.griefdefender.registry.ChatTypeRegistryModule;
|
||||
import com.griefdefender.registry.ClaimTypeRegistryModule;
|
||||
import com.griefdefender.registry.CreateModeTypeRegistryModule;
|
||||
import com.griefdefender.registry.FlagDefinitionRegistryModule;
|
||||
import com.griefdefender.registry.FlagRegistryModule;
|
||||
import com.griefdefender.registry.GameModeTypeRegistryModule;
|
||||
import com.griefdefender.registry.OptionRegistryModule;
|
||||
|
@ -413,6 +417,7 @@ public class GriefDefenderPlugin {
|
|||
ShovelTypeRegistryModule.getInstance().registerDefaults();
|
||||
TrustTypeRegistryModule.getInstance().registerDefaults();
|
||||
FlagRegistryModule.getInstance().registerDefaults();
|
||||
FlagDefinitionRegistryModule.getInstance().registerDefaults();
|
||||
ResultTypeRegistryModule.getInstance().registerDefaults();
|
||||
EntityTypeRegistryModule.getInstance().registerDefaults();
|
||||
BlockTypeRegistryModule.getInstance().registerDefaults();
|
||||
|
@ -421,8 +426,10 @@ public class GriefDefenderPlugin {
|
|||
GameModeTypeRegistryModule.getInstance().registerDefaults();
|
||||
WeatherTypeRegistryModule.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(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();
|
||||
|
||||
|
@ -821,9 +828,9 @@ public class GriefDefenderPlugin {
|
|||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Component.class), new ComponentConfigSerializer());
|
||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ClaimType.class), new ClaimTypeSerializer());
|
||||
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(WeatherType.class), new WeatherTypeSerializer());
|
||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GDCustomFlagDefinition.class), new CustomFlagSerializer());
|
||||
|
||||
if (Files.notExists(BaseStorage.dataLayerFolderPath)) {
|
||||
Files.createDirectories(BaseStorage.dataLayerFolderPath);
|
||||
|
|
|
@ -29,7 +29,6 @@ import co.aikar.commands.InvalidCommandArgument;
|
|||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
|
@ -41,7 +40,7 @@ import com.griefdefender.api.permission.ContextKeys;
|
|||
import com.griefdefender.api.permission.PermissionResult;
|
||||
import com.griefdefender.api.permission.ResultTypes;
|
||||
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.PermissionHolderCache;
|
||||
import com.griefdefender.claim.GDClaim;
|
||||
|
@ -55,14 +54,12 @@ import com.griefdefender.permission.GDPermissionHolder;
|
|||
import com.griefdefender.permission.GDPermissionManager;
|
||||
import com.griefdefender.permission.GDPermissionUser;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.permission.flag.CustomFlagData;
|
||||
import com.griefdefender.permission.flag.GDActiveFlagData;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
||||
import com.griefdefender.permission.ui.ClaimClickData;
|
||||
import com.griefdefender.permission.ui.FlagData;
|
||||
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||
import com.griefdefender.permission.ui.UIFlagData;
|
||||
import com.griefdefender.permission.ui.MenuType;
|
||||
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.text.action.GDCallbackHolder;
|
||||
import com.griefdefender.util.CauseContextHelper;
|
||||
|
@ -239,7 +236,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
}
|
||||
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
for (GDCustomFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
||||
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
||||
Component flagText = TextComponent.builder()
|
||||
.append(getCustomFlagText(customFlag))
|
||||
.append(" ")
|
||||
|
@ -388,7 +385,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
|
||||
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()) {
|
||||
final Set<Context> contextSet = mapEntry.getKey();
|
||||
if (contextSet.contains(claim.getDefaultTypeContext())) {
|
||||
|
@ -429,8 +426,8 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
}
|
||||
|
||||
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
|
||||
for (Entry<String, FlagData> mapEntry : filteredContextMap.entrySet()) {
|
||||
final FlagData flagData = mapEntry.getValue();
|
||||
for (Entry<String, UIFlagData> mapEntry : filteredContextMap.entrySet()) {
|
||||
final UIFlagData flagData = mapEntry.getValue();
|
||||
final Flag flag = flagData.flag;
|
||||
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
|
||||
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
|
||||
|
@ -494,25 +491,25 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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()) {
|
||||
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
|
||||
if (flag == null) {
|
||||
continue;
|
||||
}
|
||||
final FlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
||||
final UIFlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
||||
if (flagData != null) {
|
||||
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
|
||||
} 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();
|
||||
TextColor flagColor = TextColor.GREEN;
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("default")) {
|
||||
definitionType = TextComponent.builder()
|
||||
.append("\n")
|
||||
|
@ -544,7 +541,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
.build();
|
||||
}
|
||||
final Component baseFlagText = TextComponent.builder()
|
||||
.append(customFlag.getDisplayName(), flagColor)
|
||||
.append(customFlag.getName(), flagColor)
|
||||
.append(" ")
|
||||
.hoverEvent(HoverEvent.showText(TextComponent.builder()
|
||||
.append(customFlag.getDescription())
|
||||
|
@ -553,9 +550,9 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
return baseFlagText;
|
||||
}
|
||||
|
||||
private TextColor getCustomFlagColor(GDCustomFlagDefinition customFlag) {
|
||||
private TextColor getCustomFlagColor(GDFlagDefinition customFlag) {
|
||||
TextColor flagColor = TextColor.GREEN;
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("default")) {
|
||||
flagColor = TextColor.LIGHT_PURPLE;
|
||||
break;
|
||||
|
@ -577,7 +574,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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;
|
||||
TextComponent.Builder hoverBuilder = TextComponent.builder();
|
||||
final Player player = src.getOnlinePlayer();
|
||||
|
@ -592,7 +589,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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;
|
||||
// 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");
|
||||
hasEditPermission = false;
|
||||
hasHover = true;
|
||||
|
@ -600,8 +597,8 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
|
||||
List<GDActiveFlagData> dataResults = new ArrayList<>();
|
||||
boolean hasGDContext = false;
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("gd_claim")) {
|
||||
hasGDContext = true;
|
||||
break;
|
||||
|
@ -610,7 +607,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
if (!hasGDContext) {
|
||||
definitionContexts.add(claim.getContext());
|
||||
}
|
||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
||||
for (FlagData flagData : customFlag.getFlagData()) {
|
||||
final Set<Context> filteredContexts = new HashSet<>();
|
||||
for (Context context : definitionContexts) {
|
||||
if (context.getKey().contains("gd_claim")) {
|
||||
|
@ -698,11 +695,11 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE);
|
||||
}
|
||||
|
||||
if (!customFlag.getDefinitionContexts().isEmpty()) {
|
||||
if (!customFlag.getContexts().isEmpty()) {
|
||||
hoverBuilder.append("\nContexts: ");
|
||||
}
|
||||
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
hoverBuilder.append("\n");
|
||||
final String key = context.getKey();
|
||||
final String value = context.getValue();
|
||||
|
@ -887,13 +884,13 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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();
|
||||
return consumer -> {
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
boolean hasGDContext = false;
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("gd_claim")) {
|
||||
hasGDContext = true;
|
||||
break;
|
||||
|
@ -902,7 +899,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
if (!hasGDContext) {
|
||||
definitionContexts.add(claim.getContext());
|
||||
}
|
||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
||||
for (FlagData flagData : customFlag.getFlagData()) {
|
||||
final Set<Context> newContexts = new HashSet<>(definitionContexts);
|
||||
newContexts.addAll(flagData.getContexts());
|
||||
Tristate newValue = Tristate.UNDEFINED;
|
||||
|
|
|
@ -39,8 +39,6 @@ import com.griefdefender.api.claim.Claim;
|
|||
import com.griefdefender.api.claim.ClaimContexts;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
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.Options;
|
||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||
|
@ -60,13 +58,10 @@ import com.griefdefender.permission.GDPermissionUser;
|
|||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.permission.option.GDOption;
|
||||
import com.griefdefender.permission.ui.ClaimClickData;
|
||||
import com.griefdefender.permission.ui.FlagData;
|
||||
import com.griefdefender.permission.ui.MenuType;
|
||||
import com.griefdefender.permission.ui.OptionData;
|
||||
import com.griefdefender.permission.ui.OptionData.OptionContextHolder;
|
||||
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.text.action.GDCallbackHolder;
|
||||
import com.griefdefender.util.CauseContextHelper;
|
||||
|
|
|
@ -27,7 +27,7 @@ package com.griefdefender.configuration.category;
|
|||
import java.util.HashMap;
|
||||
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.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.")
|
||||
Component hoverText = TextComponent.empty();
|
||||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@ package com.griefdefender.configuration.category;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.griefdefender.api.claim.ClaimContexts;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinitions;
|
||||
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||
import com.griefdefender.permission.flag.GDFlagDefinitions;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
@ -51,8 +50,8 @@ public class CustomFlagGroupDefinitionCategory extends ConfigCategory {
|
|||
userGroup = new CustomFlagGroupCategory();
|
||||
}
|
||||
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
|
||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.USER_FLAGS) {
|
||||
userGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
||||
for (GDFlagDefinition definition : GDFlagDefinitions.USER_FLAGS) {
|
||||
userGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||
}
|
||||
this.groups.put("user", userGroup);
|
||||
}
|
||||
|
@ -60,8 +59,8 @@ public class CustomFlagGroupDefinitionCategory extends ConfigCategory {
|
|||
adminGroup = new CustomFlagGroupCategory();
|
||||
}
|
||||
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
|
||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.ADMIN_FLAGS) {
|
||||
adminGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
||||
for (GDFlagDefinition definition : GDFlagDefinitions.ADMIN_FLAGS) {
|
||||
adminGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||
}
|
||||
adminGroup.isAdmin = true;
|
||||
this.groups.put("admin", adminGroup);
|
||||
|
|
|
@ -34,8 +34,10 @@ import com.google.common.reflect.TypeToken;
|
|||
import com.griefdefender.api.permission.Context;
|
||||
import com.griefdefender.api.permission.ContextKeys;
|
||||
import com.griefdefender.api.permission.flag.Flag;
|
||||
import com.griefdefender.permission.flag.CustomFlagData;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
||||
import com.griefdefender.api.permission.flag.FlagData;
|
||||
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 net.kyori.text.Component;
|
||||
|
@ -45,10 +47,10 @@ import ninja.leaping.configurate.ConfigurationNode;
|
|||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||
|
||||
public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefinition> {
|
||||
public class FlagDefinitionSerializer implements TypeSerializer<FlagDefinition> {
|
||||
|
||||
@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 boolean enabled = node.getNode("enabled").getBoolean();
|
||||
final String descr = node.getNode("description").getString();
|
||||
|
@ -63,7 +65,7 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
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) {
|
||||
String permission = permissionEntry.replace(" ", "");
|
||||
String[] parts = permission.split(",");
|
||||
|
@ -106,9 +108,9 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
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);
|
||||
Set<Context> contexts = new HashSet<>();
|
||||
if (contextList != null) {
|
||||
|
@ -130,9 +132,8 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
|
||||
// try UUID
|
||||
if (value.length() == 36) {
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = UUID.fromString(value);
|
||||
UUID.fromString(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
|
||||
}
|
||||
|
@ -145,13 +146,13 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
contexts.add(new Context(key, value));
|
||||
}
|
||||
}
|
||||
flagDefinition.setDefinitionContexts(contexts);
|
||||
flagDefinition.setContexts(contexts);
|
||||
}
|
||||
return flagDefinition;
|
||||
}
|
||||
|
||||
@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());
|
||||
String description = "";
|
||||
if (obj.getDescription() != TextComponent.empty()) {
|
||||
|
@ -159,17 +160,17 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
node.getNode("description").setValue(description);
|
||||
}
|
||||
|
||||
if (!obj.getDefinitionContexts().isEmpty()) {
|
||||
if (!obj.getContexts().isEmpty()) {
|
||||
List<String> contextList = new ArrayList<>();
|
||||
ConfigurationNode contextNode = node.getNode("contexts");
|
||||
for (Context context : obj.getDefinitionContexts()) {
|
||||
for (Context context : obj.getContexts()) {
|
||||
contextList.add(context.getKey().toLowerCase() + "=" + context.getValue().toLowerCase());
|
||||
}
|
||||
contextNode.setValue(contextList);
|
||||
}
|
||||
ConfigurationNode permissionNode = node.getNode("permissions");
|
||||
List<String> permissions = new ArrayList<>();
|
||||
for (CustomFlagData flagData : obj.getFlagData()) {
|
||||
for (FlagData flagData : obj.getFlagData()) {
|
||||
int count = 0;
|
||||
final Flag flag = flagData.getFlag();
|
||||
final Set<Context> dataContexts = flagData.getContexts();
|
|
@ -42,6 +42,8 @@ import com.griefdefender.api.permission.PermissionManager;
|
|||
import com.griefdefender.api.permission.PermissionResult;
|
||||
import com.griefdefender.api.permission.ResultTypes;
|
||||
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.option.Option;
|
||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||
|
@ -1270,4 +1272,24 @@ public class GDPermissionManager implements PermissionManager {
|
|||
Set<Context> 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 @@ package com.griefdefender.permission.flag;
|
|||
|
||||
import com.griefdefender.api.Tristate;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
import com.griefdefender.api.permission.flag.FlagData;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
|
@ -40,17 +41,17 @@ public class GDActiveFlagData {
|
|||
UNDEFINED
|
||||
}
|
||||
|
||||
private final CustomFlagData flagData;
|
||||
private final FlagData flagData;
|
||||
private final Tristate value;
|
||||
private final Type type;
|
||||
|
||||
public GDActiveFlagData(CustomFlagData flagData, Tristate value, Type type) {
|
||||
public GDActiveFlagData(FlagData flagData, Tristate value, Type type) {
|
||||
this.flagData = flagData;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public CustomFlagData getFlagData() {
|
||||
public FlagData getFlagData() {
|
||||
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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.griefdefender.api.permission.Context;
|
||||
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 Set<Context> contexts;
|
||||
|
||||
public CustomFlagData(Flag flag, Set<Context> contexts) {
|
||||
public GDFlagData(Flag flag, Set<Context> contexts) {
|
||||
this.flag = flag;
|
||||
this.contexts = contexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Context> getContexts() {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flag getFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
||||
for (Context context : this.contexts) {
|
||||
boolean found = false;
|
||||
|
@ -62,4 +69,36 @@ public class CustomFlagData {
|
|||
}
|
||||
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 com.griefdefender.api.permission.flag.Flags;
|
|||
|
||||
import net.kyori.text.format.TextColor;
|
||||
|
||||
public class FlagData {
|
||||
public class UIFlagData {
|
||||
|
||||
public Flag flag;
|
||||
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.addContexts(flag, value, type, contexts);
|
||||
}
|
|
@ -40,7 +40,7 @@ import com.griefdefender.api.permission.option.Option;
|
|||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.configuration.MessageStorage;
|
||||
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.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 {
|
||||
compileOnly 'com.griefdefender:api:1.0.0-20190906.173641-10'
|
||||
compileOnly(project(path: ":GriefDefenderAPI"))
|
||||
compileOnly "com.griefdefender:reflect-helper:1.0"
|
||||
// Sponge
|
||||
apiCompile "org.spongepowered:spongeapi:$apiVersion"
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.griefdefender.api.claim.ClaimManager;
|
|||
import com.griefdefender.api.data.PlayerData;
|
||||
import com.griefdefender.api.permission.flag.Flag;
|
||||
import com.griefdefender.cache.PermissionHolderCache;
|
||||
import com.griefdefender.storage.BaseStorage;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
|
@ -80,6 +81,12 @@ public class GDCore implements Core {
|
|||
@Override
|
||||
public List<Claim> getAllPlayerClaims(UUID playerUniqueId) {
|
||||
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()) {
|
||||
claimList.addAll(this.getClaimManager(world.getUniqueId()).getPlayerClaims(playerUniqueId));
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import co.aikar.commands.RegisteredCommand;
|
|||
import co.aikar.commands.RootCommand;
|
||||
import co.aikar.commands.SpongeCommandManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Stage;
|
||||
|
@ -42,6 +41,8 @@ import com.griefdefender.api.claim.ClaimType;
|
|||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.economy.BankTransaction;
|
||||
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.type.CreateModeType;
|
||||
import com.griefdefender.api.permission.option.type.GameModeType;
|
||||
|
@ -131,7 +132,7 @@ import com.griefdefender.configuration.category.BlacklistCategory;
|
|||
import com.griefdefender.configuration.serializer.ClaimTypeSerializer;
|
||||
import com.griefdefender.configuration.serializer.ComponentConfigSerializer;
|
||||
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.WeatherTypeSerializer;
|
||||
import com.griefdefender.configuration.type.ConfigBase;
|
||||
|
@ -157,8 +158,8 @@ import com.griefdefender.permission.ContextGroupKeys;
|
|||
import com.griefdefender.permission.GDPermissionHolder;
|
||||
import com.griefdefender.permission.GDPermissionManager;
|
||||
import com.griefdefender.permission.GDPermissionUser;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
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.provider.LuckPermsProvider;
|
||||
import com.griefdefender.provider.MCClansProvider;
|
||||
|
@ -486,9 +487,11 @@ public class GriefDefenderPlugin {
|
|||
GameModeTypeRegistryModule.getInstance().registerDefaults();
|
||||
WeatherTypeRegistryModule.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(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());
|
||||
}
|
||||
|
||||
|
@ -890,9 +893,9 @@ public class GriefDefenderPlugin {
|
|||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Component.class), new ComponentConfigSerializer());
|
||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ClaimType.class), new ClaimTypeSerializer());
|
||||
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(WeatherType.class), new WeatherTypeSerializer());
|
||||
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(GDCustomFlagDefinition.class), new CustomFlagSerializer());
|
||||
|
||||
if (Files.notExists(BaseStorage.dataLayerFolderPath)) {
|
||||
Files.createDirectories(BaseStorage.dataLayerFolderPath);
|
||||
|
|
|
@ -29,7 +29,6 @@ import co.aikar.commands.InvalidCommandArgument;
|
|||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.griefdefender.GDPlayerData;
|
||||
import com.griefdefender.GriefDefenderPlugin;
|
||||
import com.griefdefender.api.GriefDefender;
|
||||
|
@ -41,7 +40,7 @@ import com.griefdefender.api.permission.ContextKeys;
|
|||
import com.griefdefender.api.permission.PermissionResult;
|
||||
import com.griefdefender.api.permission.ResultTypes;
|
||||
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.PermissionHolderCache;
|
||||
import com.griefdefender.claim.GDClaim;
|
||||
|
@ -55,14 +54,12 @@ import com.griefdefender.permission.GDPermissionHolder;
|
|||
import com.griefdefender.permission.GDPermissionManager;
|
||||
import com.griefdefender.permission.GDPermissionUser;
|
||||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.permission.flag.CustomFlagData;
|
||||
import com.griefdefender.permission.flag.GDActiveFlagData;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
||||
import com.griefdefender.permission.ui.ClaimClickData;
|
||||
import com.griefdefender.permission.ui.FlagData;
|
||||
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||
import com.griefdefender.permission.ui.UIFlagData;
|
||||
import com.griefdefender.permission.ui.MenuType;
|
||||
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.text.action.GDCallbackHolder;
|
||||
import com.griefdefender.util.CauseContextHelper;
|
||||
|
@ -239,7 +236,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
}
|
||||
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
for (GDCustomFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
||||
for (GDFlagDefinition customFlag : flagGroupCat.getFlagDefinitions().values()) {
|
||||
Component flagText = TextComponent.builder()
|
||||
.append(getCustomFlagText(customFlag))
|
||||
.append(" ")
|
||||
|
@ -388,7 +385,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
overrideContexts.add(ClaimContexts.GLOBAL_OVERRIDE_CONTEXT);
|
||||
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()) {
|
||||
final Set<Context> contextSet = mapEntry.getKey();
|
||||
if (contextSet.contains(claim.getDefaultTypeContext())) {
|
||||
|
@ -429,8 +426,8 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
}
|
||||
|
||||
final Map<String, Map<Integer, Component>> textMap = new TreeMap<>();
|
||||
for (Entry<String, FlagData> mapEntry : filteredContextMap.entrySet()) {
|
||||
final FlagData flagData = mapEntry.getValue();
|
||||
for (Entry<String, UIFlagData> mapEntry : filteredContextMap.entrySet()) {
|
||||
final UIFlagData flagData = mapEntry.getValue();
|
||||
final Flag flag = flagData.flag;
|
||||
for (FlagContextHolder flagHolder : flagData.flagContextMap.values()) {
|
||||
if (displayType != MenuType.CLAIM && flagHolder.getType() != displayType) {
|
||||
|
@ -494,25 +491,25 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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()) {
|
||||
final Flag flag = FlagRegistryModule.getInstance().getById(permissionEntry.getKey()).orElse(null);
|
||||
if (flag == null) {
|
||||
continue;
|
||||
}
|
||||
final FlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
||||
final UIFlagData flagData = filteredContextMap.get(permissionEntry.getKey());
|
||||
if (flagData != null) {
|
||||
flagData.addContexts(flag, permissionEntry.getValue(), type, contexts);
|
||||
} 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();
|
||||
TextColor flagColor = TextColor.GREEN;
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("default")) {
|
||||
definitionType = TextComponent.builder()
|
||||
.append("\n")
|
||||
|
@ -544,7 +541,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
.build();
|
||||
}
|
||||
final Component baseFlagText = TextComponent.builder()
|
||||
.append(customFlag.getDisplayName(), flagColor)
|
||||
.append(customFlag.getName(), flagColor)
|
||||
.append(" ")
|
||||
.hoverEvent(HoverEvent.showText(TextComponent.builder()
|
||||
.append(customFlag.getDescription())
|
||||
|
@ -553,9 +550,9 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
return baseFlagText;
|
||||
}
|
||||
|
||||
private TextColor getCustomFlagColor(GDCustomFlagDefinition customFlag) {
|
||||
private TextColor getCustomFlagColor(GDFlagDefinition customFlag) {
|
||||
TextColor flagColor = TextColor.GREEN;
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("default")) {
|
||||
flagColor = TextColor.LIGHT_PURPLE;
|
||||
break;
|
||||
|
@ -577,7 +574,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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;
|
||||
TextComponent.Builder hoverBuilder = TextComponent.builder();
|
||||
final Player player = src.getOnlinePlayer();
|
||||
|
@ -592,7 +589,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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;
|
||||
// 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");
|
||||
hasEditPermission = false;
|
||||
hasHover = true;
|
||||
|
@ -600,8 +597,8 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
|
||||
List<GDActiveFlagData> dataResults = new ArrayList<>();
|
||||
boolean hasGDContext = false;
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("gd_claim")) {
|
||||
hasGDContext = true;
|
||||
break;
|
||||
|
@ -610,7 +607,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
if (!hasGDContext) {
|
||||
definitionContexts.add(claim.getContext());
|
||||
}
|
||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
||||
for (FlagData flagData : customFlag.getFlagData()) {
|
||||
final Set<Context> filteredContexts = new HashSet<>();
|
||||
for (Context context : definitionContexts) {
|
||||
if (context.getKey().contains("gd_claim")) {
|
||||
|
@ -698,11 +695,11 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
hoverBuilder.append(MessageCache.getInstance().FLAG_UI_CLICK_REMOVE);
|
||||
}
|
||||
|
||||
if (!customFlag.getDefinitionContexts().isEmpty()) {
|
||||
if (!customFlag.getContexts().isEmpty()) {
|
||||
hoverBuilder.append("\nContexts: ");
|
||||
}
|
||||
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
hoverBuilder.append("\n");
|
||||
final String key = context.getKey();
|
||||
final String value = context.getValue();
|
||||
|
@ -887,13 +884,13 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
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();
|
||||
return consumer -> {
|
||||
GDCauseStackManager.getInstance().pushCause(player);
|
||||
boolean hasGDContext = false;
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getDefinitionContexts());
|
||||
for (Context context : customFlag.getDefinitionContexts()) {
|
||||
Set<Context> definitionContexts = new HashSet<>(customFlag.getContexts());
|
||||
for (Context context : customFlag.getContexts()) {
|
||||
if (context.getKey().contains("gd_claim")) {
|
||||
hasGDContext = true;
|
||||
break;
|
||||
|
@ -902,7 +899,7 @@ public abstract class ClaimFlagBase extends BaseCommand {
|
|||
if (!hasGDContext) {
|
||||
definitionContexts.add(claim.getContext());
|
||||
}
|
||||
for (CustomFlagData flagData : customFlag.getFlagData()) {
|
||||
for (FlagData flagData : customFlag.getFlagData()) {
|
||||
final Set<Context> newContexts = new HashSet<>(definitionContexts);
|
||||
newContexts.addAll(flagData.getContexts());
|
||||
Tristate newValue = Tristate.UNDEFINED;
|
||||
|
|
|
@ -39,8 +39,6 @@ import com.griefdefender.api.claim.Claim;
|
|||
import com.griefdefender.api.claim.ClaimContexts;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
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.Options;
|
||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||
|
@ -60,13 +58,10 @@ import com.griefdefender.permission.GDPermissionUser;
|
|||
import com.griefdefender.permission.GDPermissions;
|
||||
import com.griefdefender.permission.option.GDOption;
|
||||
import com.griefdefender.permission.ui.ClaimClickData;
|
||||
import com.griefdefender.permission.ui.FlagData;
|
||||
import com.griefdefender.permission.ui.MenuType;
|
||||
import com.griefdefender.permission.ui.OptionData;
|
||||
import com.griefdefender.permission.ui.OptionData.OptionContextHolder;
|
||||
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.text.action.GDCallbackHolder;
|
||||
import com.griefdefender.util.CauseContextHelper;
|
||||
|
|
|
@ -27,7 +27,7 @@ package com.griefdefender.configuration.category;
|
|||
import java.util.HashMap;
|
||||
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.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.")
|
||||
Component hoverText = TextComponent.empty();
|
||||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@ package com.griefdefender.configuration.category;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.griefdefender.api.claim.ClaimContexts;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinitions;
|
||||
import com.griefdefender.permission.flag.GDFlagDefinition;
|
||||
import com.griefdefender.permission.flag.GDFlagDefinitions;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
@ -51,8 +50,8 @@ public class CustomFlagGroupDefinitionCategory extends ConfigCategory {
|
|||
userGroup = new CustomFlagGroupCategory();
|
||||
}
|
||||
if (userGroup.isEnabled() && userGroup.getFlagDefinitions().isEmpty()) {
|
||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.USER_FLAGS) {
|
||||
userGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
||||
for (GDFlagDefinition definition : GDFlagDefinitions.USER_FLAGS) {
|
||||
userGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||
}
|
||||
this.groups.put("user", userGroup);
|
||||
}
|
||||
|
@ -60,8 +59,8 @@ public class CustomFlagGroupDefinitionCategory extends ConfigCategory {
|
|||
adminGroup = new CustomFlagGroupCategory();
|
||||
}
|
||||
if (adminGroup.isEnabled() && adminGroup.getFlagDefinitions().isEmpty()) {
|
||||
for (GDCustomFlagDefinition definition : GDCustomFlagDefinitions.ADMIN_FLAGS) {
|
||||
adminGroup.getFlagDefinitions().put(definition.getDisplayName(), definition);
|
||||
for (GDFlagDefinition definition : GDFlagDefinitions.ADMIN_FLAGS) {
|
||||
adminGroup.getFlagDefinitions().put(definition.getName(), definition);
|
||||
}
|
||||
adminGroup.isAdmin = true;
|
||||
this.groups.put("admin", adminGroup);
|
||||
|
|
|
@ -34,8 +34,10 @@ import com.google.common.reflect.TypeToken;
|
|||
import com.griefdefender.api.permission.Context;
|
||||
import com.griefdefender.api.permission.ContextKeys;
|
||||
import com.griefdefender.api.permission.flag.Flag;
|
||||
import com.griefdefender.permission.flag.CustomFlagData;
|
||||
import com.griefdefender.permission.flag.GDCustomFlagDefinition;
|
||||
import com.griefdefender.api.permission.flag.FlagData;
|
||||
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 net.kyori.text.Component;
|
||||
|
@ -45,10 +47,10 @@ import ninja.leaping.configurate.ConfigurationNode;
|
|||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
|
||||
|
||||
public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefinition> {
|
||||
public class FlagDefinitionSerializer implements TypeSerializer<FlagDefinition> {
|
||||
|
||||
@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 boolean enabled = node.getNode("enabled").getBoolean();
|
||||
final String descr = node.getNode("description").getString();
|
||||
|
@ -63,7 +65,7 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
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) {
|
||||
String permission = permissionEntry.replace(" ", "");
|
||||
String[] parts = permission.split(",");
|
||||
|
@ -106,9 +108,9 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
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);
|
||||
Set<Context> contexts = new HashSet<>();
|
||||
if (contextList != null) {
|
||||
|
@ -130,9 +132,8 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
&& !value.equalsIgnoreCase("subdivision") && !value.equalsIgnoreCase("town")) {
|
||||
// try UUID
|
||||
if (value.length() == 36) {
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = UUID.fromString(value);
|
||||
UUID.fromString(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ObjectMappingException("Invalid context '" + key + "' with value '" + value + "'.");
|
||||
}
|
||||
|
@ -145,13 +146,13 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
contexts.add(new Context(key, value));
|
||||
}
|
||||
}
|
||||
flagDefinition.setDefinitionContexts(contexts);
|
||||
flagDefinition.setContexts(contexts);
|
||||
}
|
||||
return flagDefinition;
|
||||
}
|
||||
|
||||
@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());
|
||||
String description = "";
|
||||
if (obj.getDescription() != TextComponent.empty()) {
|
||||
|
@ -159,17 +160,17 @@ public class CustomFlagSerializer implements TypeSerializer<GDCustomFlagDefiniti
|
|||
node.getNode("description").setValue(description);
|
||||
}
|
||||
|
||||
if (!obj.getDefinitionContexts().isEmpty()) {
|
||||
if (!obj.getContexts().isEmpty()) {
|
||||
List<String> contextList = new ArrayList<>();
|
||||
ConfigurationNode contextNode = node.getNode("contexts");
|
||||
for (Context context : obj.getDefinitionContexts()) {
|
||||
for (Context context : obj.getContexts()) {
|
||||
contextList.add(context.getKey().toLowerCase() + "=" + context.getValue().toLowerCase());
|
||||
}
|
||||
contextNode.setValue(contextList);
|
||||
}
|
||||
ConfigurationNode permissionNode = node.getNode("permissions");
|
||||
List<String> permissions = new ArrayList<>();
|
||||
for (CustomFlagData flagData : obj.getFlagData()) {
|
||||
for (FlagData flagData : obj.getFlagData()) {
|
||||
int count = 0;
|
||||
final Flag flag = flagData.getFlag();
|
||||
final Set<Context> dataContexts = flagData.getContexts();
|
|
@ -44,6 +44,8 @@ import com.griefdefender.api.permission.PermissionManager;
|
|||
import com.griefdefender.api.permission.PermissionResult;
|
||||
import com.griefdefender.api.permission.ResultTypes;
|
||||
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.option.Option;
|
||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||
|
@ -1438,4 +1440,24 @@ public class GDPermissionManager implements PermissionManager {
|
|||
Set<Context> 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 @@ package com.griefdefender.permission.flag;
|
|||
|
||||
import com.griefdefender.api.Tristate;
|
||||
import com.griefdefender.api.permission.Context;
|
||||
import com.griefdefender.api.permission.flag.FlagData;
|
||||
|
||||
import net.kyori.text.Component;
|
||||
import net.kyori.text.TextComponent;
|
||||
|
@ -40,17 +41,17 @@ public class GDActiveFlagData {
|
|||
UNDEFINED
|
||||
}
|
||||
|
||||
private final CustomFlagData flagData;
|
||||
private final FlagData flagData;
|
||||
private final Tristate value;
|
||||
private final Type type;
|
||||
|
||||
public GDActiveFlagData(CustomFlagData flagData, Tristate value, Type type) {
|
||||
public GDActiveFlagData(FlagData flagData, Tristate value, Type type) {
|
||||
this.flagData = flagData;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public CustomFlagData getFlagData() {
|
||||
public FlagData getFlagData() {
|
||||
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;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.griefdefender.api.permission.Context;
|
||||
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 Set<Context> contexts;
|
||||
|
||||
public CustomFlagData(Flag flag, Set<Context> contexts) {
|
||||
public GDFlagData(Flag flag, Set<Context> contexts) {
|
||||
this.flag = flag;
|
||||
this.contexts = contexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Context> getContexts() {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flag getFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Flag otherFlag, Set<Context> otherContexts) {
|
||||
for (Context context : this.contexts) {
|
||||
boolean found = false;
|
||||
|
@ -62,4 +69,36 @@ public class CustomFlagData {
|
|||
}
|
||||
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 com.griefdefender.api.permission.flag.Flags;
|
|||
|
||||
import net.kyori.text.format.TextColor;
|
||||
|
||||
public class FlagData {
|
||||
public class UIFlagData {
|
||||
|
||||
public Flag flag;
|
||||
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.addContexts(flag, value, type, contexts);
|
||||
}
|
|
@ -40,7 +40,7 @@ import com.griefdefender.api.permission.option.Option;
|
|||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.configuration.MessageStorage;
|
||||
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.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