GriefDefender/bukkit/src/main/java/com/griefdefender/provider/permissionsex/PermissionsExProvider.java

472 lines
20 KiB
Java
Raw Normal View History

/*
* This file is part of GriefDefender, licensed under the MIT License (MIT).
*
* Copyright (c) bloodmc
* Copyright (c) zml
* 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.provider.permissionsex;
import ca.stellardrift.permissionsex.bukkit.PermissionsExPlugin;
import ca.stellardrift.permissionsex.context.ContextDefinition;
import ca.stellardrift.permissionsex.context.ContextValue;
import ca.stellardrift.permissionsex.subject.SubjectType;
import ca.stellardrift.permissionsex.util.Change;
import ca.stellardrift.permissionsex.util.Util;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.griefdefender.GDPlayerData;
import com.griefdefender.GriefDefenderPlugin;
import com.griefdefender.api.CatalogType;
import com.griefdefender.api.Tristate;
import com.griefdefender.api.claim.Claim;
import com.griefdefender.api.claim.ClaimType;
import com.griefdefender.api.permission.Context;
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;
Update for 1.5.0 * Fix blockstate id lookup not using proper id when block data was different than actual block. * Fix block-break showing air as target when source block broke on its own. * Fix race condition when migrating GP Bukkit playerdata. * Fix race condition during flag definition saves. * Fix wrong owner showing in claim when non-owner changes claim type. * Fix explosions causing no sound when cancelling event. * Fix rent min message showing max. * Fix rent min payment not being applied as credit. * Fix rent restore not working on rent end. * Fix sell sign not working when rent system was disabled. * Fix '/abandonall' not giving all money back when using economy mode. * Fix '/claimsell' requiring for sale to be turned on. * Fix '/givepet' taming pets without owner. * Fix explosion sounds not triggering on cancel. * Fix pvp 'allow-fly' only affecting creative mode. * Fix confirmation message not showing after abandoning a subdivision. * Fix wrong location being checked when placing water/lava with bucket. * Fix dynmap owner style colors not being used. * Fix NPE when using /reload. * Fix ghost claim overlap error when creating claim. * Fix user showing up as cause when using rtp. * Fix high memory usage caused by GDClaimManager fastutil usage. * (Bukkit) Fix NPE during InventoryMoveItemEvent. * (Sponge) Fix explosion-surface being triggered with no settings. * Refactor CompletableFuture handling when applying LP permissions and meta to avoid race conditions. * Remove owner override context for flag definition 'fire-spread' as it doesn't affect global overrides. * Change flag definition 'turtle-egg-hatch' target from 'air' to 'turtle-egg-hatch' * Change flag definition 'snow-melt' target from 'air' to 'snow' * Change onPlayerInteractBlockSecondary event priority from lowest to low in order to support plugins that need to cancel early. * Add support for CustomItems. Any customitem used in game will show up in debug as customitems:<item_id>. You can also use customitems for modification and investigation tool in config. * Add support for Slimefun4. Any slimefun item/block used in game will show up in debug as slimefun:<id>. You can also use slimefun items for modification and investigation tool in config. * Add '/acball' command for adjusting all online players' bonus blocks. * Add '/claiminvestigate' command to investigate claims. * Add '/claimtool' to toggle claim tool usage. * Add source/target any contexts to flag definitions. * Add 'piston-protection-in-claims' setting to control piston protection within claims. * Add pvp setting 'combat-logout' to determine if a player should be killed on logout during combat. Default 'false'. * Add `projectile-impact-entity` to `endcrystal-use` flag definition. * Add aquatic target for `monster-animal-damage` flag definition. * Add `restrict-world-max-height` to determine if claiming should be restricted to world max height. Default 'true'. * Add ability to control dynmap color settings by claim type. * Add permission griefdefender.user.claim.command.info.teleport.inside which controls whether a player can ONLY teleport within the claim they are in. This is useful if players become trapped. Note: This does not allow players to teleport to any other claim except the one they are in. It can only be used if the player cannot build in claim. * Add permission griefdefender.user.claim.command.info.others.creation-date to control whether a player sees creation date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.last-active to control whether a player sees last active date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.claim-uuid to control whether a player sees claim uuid in /claiminfo * All flag definitions will now persist. * Refresh player option cache on permission change. * Show TP info in '/claiminfo' when player does not have TP permission. * (Sponge) Use 'tnt' as identifier instead of 'primedtnt' to match bukkit. * (Sponge) Use 'item_frame' as identifier instead of 'itemframe' to match bukkit.
2020-08-16 06:39:38 +02:00
import com.griefdefender.api.permission.flag.FlagDefinition;
import com.griefdefender.api.permission.option.Option;
import com.griefdefender.claim.GDClaim;
import com.griefdefender.internal.registry.BlockTypeRegistryModule;
import com.griefdefender.internal.registry.EntityTypeRegistryModule;
import com.griefdefender.internal.registry.ItemTypeRegistryModule;
import com.griefdefender.permission.GDPermissionHolder;
import com.griefdefender.permission.GDPermissionResult;
import com.griefdefender.permission.GDPermissionUser;
import ca.stellardrift.permissionsex.PermissionsEx;
import ca.stellardrift.permissionsex.subject.CalculatedSubject;
import ca.stellardrift.permissionsex.subject.ImmutableSubjectData;
import com.griefdefender.provider.PermissionProvider;
import com.griefdefender.registry.ClaimTypeRegistryModule;
import com.griefdefender.registry.FlagRegistryModule;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import net.kyori.text.event.HoverEvent;
import net.kyori.text.format.TextColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.Nullable;
Finish implementing options for next major release. * Fixed '/cfg' and '/cog' commands. * Fixed 'create-mode' not working as intended. * Fixed 'any' usage with flag commands. * Fixed 'command-execute' usage. * Fixed 'command-execute-pvp' usage. * Fixed option removal/save with LP v5. * Added context support for controlling user flag command usage. * Added context support to option GUI. * Added permission 'griefdefender.user.claim.command.flag.arg' which controls if a user can use flag command with arguments. * Added permission 'griefdefender.user.claim.command.flag.gui' which controls if a user can use flag GUI. * Added new group context '#all' which can be used to represent all sources or targets. * Removed 'max-claim-inspection-distance' from config as it is now controlled by 'radius-inspect' option. * Removed 'combat-timeout' from config as it is now controlled by 'pvp-combat-timeout' option. * Implemented the folloing new options 'player-command-enter' - Handles executing commands when a player enters a claim. 'player-command-exit' - Handles executing commands when a player exits a claim. Note: both command options support the following placeholders : %player%, %owner%, %uuid%, %world%, %server%, %location% 'player-gamemode' - Used to determine the gamemode of a player when entering a claim. 'player-deny-godmode' - Used to determine if a player can be in godmode when entering a claim. 'player-walk-speed' - Controls the player walk speed when entering a claim. 'player-weather' - Controls player local weather when entering a claim. 'pvp-combat-command' - Used to determine if a player can use commands during PvP combat. 'pvp-combat-teleport' - Used to determine if a player can teleport during PvP combat. 'pvp-combat-timeout' - Used to determine how many seconds PvP combat is considered to continue after the most recent damage. 'radius-inspect' - Controls the radius in blocks to search within when inspecting for claims. 'spawn-limit' - Used to control the spawn limit for a specific set of entities in a claim. * Only save once when toggling flag definitions that include multiple definitions.
2019-12-31 00:25:55 +01:00
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
public class PermissionsExProvider implements PermissionProvider {
private static final ContextDefinition<UUID> CTX_CLAIM = new ClaimContextDefinition();
private static final ContextDefinition<ClaimType> CTX_CLAIM_DEFAULT = new CatalogTypeContextDefinition<>(ContextKeys.CLAIM_DEFAULT, ClaimTypeRegistryModule.getInstance(), claimAttributeValue(GDClaim::getType));
private static final ContextDefinition<ClaimType> CTX_CLAIM_OVERRIDE = new CatalogTypeContextDefinition<>(ContextKeys.CLAIM_OVERRIDE, ClaimTypeRegistryModule.getInstance());
private static final ContextDefinition<Flag> CTX_FLAG = new CatalogTypeContextDefinition<>(ContextKeys.FLAG, FlagRegistryModule.getInstance());
private static final ContextDefinition<CatalogType> CTX_SOURCE = new MultiCatalogTypeContextDefinition(ContextKeys.SOURCE, BlockTypeRegistryModule.getInstance(), ItemTypeRegistryModule.getInstance(), EntityTypeRegistryModule.getInstance());
private static final ContextDefinition<CatalogType> CTX_STATE = new MultiCatalogTypeContextDefinition(ContextKeys.STATE);
private static final ContextDefinition<CatalogType> CTX_TARGET = new MultiCatalogTypeContextDefinition(ContextKeys.TARGET);
private final PermissionsEx<?> pex;
public PermissionsExProvider(PermissionsEx<?> engine) {
this.pex = engine;
engine.registerContextDefinition(CTX_CLAIM);
engine.registerContextDefinition(CTX_CLAIM_DEFAULT);
engine.registerContextDefinition(CTX_CLAIM_OVERRIDE);
engine.registerContextDefinition(CTX_FLAG);
engine.registerContextDefinition(CTX_SOURCE);
engine.registerContextDefinition(CTX_STATE);
engine.registerContextDefinition(CTX_TARGET);
}
public static PermissionsExProvider initBukkit(Plugin pexPlugin) {
if (pexPlugin instanceof PermissionsExPlugin) {
return new PermissionsExProvider(((PermissionsExPlugin) pexPlugin).getManager());
}
throw new RuntimeException("Provided plugin " + pexPlugin + " was not a proper instance of PermissionsExPlugin");
}
private static <T> BiConsumer<CalculatedSubject, Consumer<? super T>> claimAttributeValue(Function<GDClaim, T> claimFunc) {
return (subj, collector) -> {
GDClaim claim = getClaimForSubject(subj);
if (claim != null) {
T attr = claimFunc.apply(claim);
if (attr != null) {
collector.accept(attr);
}
}
};
}
/**
* Get the current applicable claim for a given subject for permissions purposes. This takes into account a claim being ignored as well
*
* @param subj The subject to get the active claim for
* @return A claim if applicable, otherwise null
*/
static GDClaim getClaimForSubject(CalculatedSubject subj) {
Player ply = Util.castOptional(Optional.ofNullable(subj.getAssociatedObject()), Player.class).orElse(null);
if (ply == null) {// not an online player
return null;
}
GDPlayerData plyData = GriefDefenderPlugin.getInstance().dataStore.getPlayerData(ply.getWorld(), ply.getUniqueId());
if (plyData != null && plyData.ignoreActiveContexts) {
plyData.ignoreActiveContexts = false;
return null;
}
GDClaim ret = GriefDefenderPlugin.getInstance().dataStore.getClaimAtPlayer(plyData, ply.getLocation());
if (plyData != null && !plyData.canIgnoreClaim(ret)) {
return null;
}
GDClaim parentClaim = ret.parent;
if (ret.getData().doesInheritParent() && parentClaim != null) {
return parentClaim;
} else {
return ret;
}
}
// - Data conversion
private ContextValue<?> contextGDToPEX(Context gdCtx) {
return new ContextValue<>(gdCtx.getKey(), gdCtx.getValue());
}
private Context contextPEXToGD(ContextValue<?> pexCtx) {
return new Context(pexCtx.key(), pexCtx.rawValue());
}
private Set<ContextValue<?>> contextsGDToPEX(Set<Context> gdCtxs) {
return gdCtxs.stream()
.map(this::contextGDToPEX)
.collect(Collectors.toSet());
}
private Set<Context> contextsPEXToGD(Set<ContextValue<?>> ctxs) {
return ctxs.stream()
.map(this::contextPEXToGD)
.collect(Collectors.toSet());
}
private CalculatedSubject holderToPEXSubject(GDPermissionHolder holder) {
return pex.getSubjects(holder instanceof GDPermissionUser ? PermissionsEx.SUBJECTS_USER : PermissionsEx.SUBJECTS_GROUP).get(holder.getIdentifier()).join();
}
private <ValueType> Map<Set<Context>, ValueType> tKeys(Map<Set<ContextValue<?>>, ValueType> pexMap) {
return tKeys(pexMap, Function.identity());
}
private <ValueType, InputValueType> Map<Set<Context>, ValueType> tKeys(Map<Set<ContextValue<?>>, InputValueType> pexMap, Function<InputValueType, ValueType> valueXform) {
ImmutableMap.Builder<Set<Context>, ValueType> ret = ImmutableMap.builder();
pexMap.forEach((key, val) -> ret.put(contextsPEXToGD(key), valueXform.apply(val)));
return ret.build();
}
private Component textForError(Throwable t) { // TODO: is this already done somewhere else in GD?
TextComponent.Builder build = TextComponent.builder(t.getMessage(), TextColor.RED);
TextComponent.Builder stackTrace = TextComponent.builder();
for (StackTraceElement el : t.getStackTrace()) {
stackTrace.append(el.toString()).append("\n");
}
build.hoverEvent(HoverEvent.showText(stackTrace.build()));
return build.build();
}
private CompletableFuture<PermissionResult> convertResult(CompletableFuture<Change<ImmutableSubjectData>> pexResult) {
return pexResult.handle((res, err) -> {
if (err != null) {
return new GDPermissionResult(ResultTypes.FAILURE, textForError(err));
} else {
return new GDPermissionResult(ResultTypes.SUCCESS);
}
});
}
private Tristate tristateFromInt(int value) {
if (value > 0) {
return Tristate.TRUE;
} else if (value < 0) {
return Tristate.FALSE;
}
return Tristate.UNDEFINED;
}
private int intFromTristate(Tristate value) {
switch (value) {
case TRUE: return 1;
case FALSE: return -1;
case UNDEFINED: return 0;
default: throw new IllegalArgumentException("unknown tristate value " + value);
}
}
private int pValFromBool(@Nullable Boolean value) {
if (value == null) {
return 0;
}
return value ? 1 : -1;
}
private boolean pValIntegerToBool(@Nullable Integer value) {
return value != null && value > 0;
}
// - Implement API
Update for 1.5.0 * Fix blockstate id lookup not using proper id when block data was different than actual block. * Fix block-break showing air as target when source block broke on its own. * Fix race condition when migrating GP Bukkit playerdata. * Fix race condition during flag definition saves. * Fix wrong owner showing in claim when non-owner changes claim type. * Fix explosions causing no sound when cancelling event. * Fix rent min message showing max. * Fix rent min payment not being applied as credit. * Fix rent restore not working on rent end. * Fix sell sign not working when rent system was disabled. * Fix '/abandonall' not giving all money back when using economy mode. * Fix '/claimsell' requiring for sale to be turned on. * Fix '/givepet' taming pets without owner. * Fix explosion sounds not triggering on cancel. * Fix pvp 'allow-fly' only affecting creative mode. * Fix confirmation message not showing after abandoning a subdivision. * Fix wrong location being checked when placing water/lava with bucket. * Fix dynmap owner style colors not being used. * Fix NPE when using /reload. * Fix ghost claim overlap error when creating claim. * Fix user showing up as cause when using rtp. * Fix high memory usage caused by GDClaimManager fastutil usage. * (Bukkit) Fix NPE during InventoryMoveItemEvent. * (Sponge) Fix explosion-surface being triggered with no settings. * Refactor CompletableFuture handling when applying LP permissions and meta to avoid race conditions. * Remove owner override context for flag definition 'fire-spread' as it doesn't affect global overrides. * Change flag definition 'turtle-egg-hatch' target from 'air' to 'turtle-egg-hatch' * Change flag definition 'snow-melt' target from 'air' to 'snow' * Change onPlayerInteractBlockSecondary event priority from lowest to low in order to support plugins that need to cancel early. * Add support for CustomItems. Any customitem used in game will show up in debug as customitems:<item_id>. You can also use customitems for modification and investigation tool in config. * Add support for Slimefun4. Any slimefun item/block used in game will show up in debug as slimefun:<id>. You can also use slimefun items for modification and investigation tool in config. * Add '/acball' command for adjusting all online players' bonus blocks. * Add '/claiminvestigate' command to investigate claims. * Add '/claimtool' to toggle claim tool usage. * Add source/target any contexts to flag definitions. * Add 'piston-protection-in-claims' setting to control piston protection within claims. * Add pvp setting 'combat-logout' to determine if a player should be killed on logout during combat. Default 'false'. * Add `projectile-impact-entity` to `endcrystal-use` flag definition. * Add aquatic target for `monster-animal-damage` flag definition. * Add `restrict-world-max-height` to determine if claiming should be restricted to world max height. Default 'true'. * Add ability to control dynmap color settings by claim type. * Add permission griefdefender.user.claim.command.info.teleport.inside which controls whether a player can ONLY teleport within the claim they are in. This is useful if players become trapped. Note: This does not allow players to teleport to any other claim except the one they are in. It can only be used if the player cannot build in claim. * Add permission griefdefender.user.claim.command.info.others.creation-date to control whether a player sees creation date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.last-active to control whether a player sees last active date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.claim-uuid to control whether a player sees claim uuid in /claiminfo * All flag definitions will now persist. * Refresh player option cache on permission change. * Show TP info in '/claiminfo' when player does not have TP permission. * (Sponge) Use 'tnt' as identifier instead of 'primedtnt' to match bukkit. * (Sponge) Use 'item_frame' as identifier instead of 'itemframe' to match bukkit.
2020-08-16 06:39:38 +02:00
@Override
public boolean createDefaultGroup(String identifier) {
if (!this.hasGroupSubject(identifier)) {
pex.createSubjectIdentifier(PermissionsEx.SUBJECTS_GROUP, identifier);
}
return true;
}
Finish implementing options for next major release. * Fixed '/cfg' and '/cog' commands. * Fixed 'create-mode' not working as intended. * Fixed 'any' usage with flag commands. * Fixed 'command-execute' usage. * Fixed 'command-execute-pvp' usage. * Fixed option removal/save with LP v5. * Added context support for controlling user flag command usage. * Added context support to option GUI. * Added permission 'griefdefender.user.claim.command.flag.arg' which controls if a user can use flag command with arguments. * Added permission 'griefdefender.user.claim.command.flag.gui' which controls if a user can use flag GUI. * Added new group context '#all' which can be used to represent all sources or targets. * Removed 'max-claim-inspection-distance' from config as it is now controlled by 'radius-inspect' option. * Removed 'combat-timeout' from config as it is now controlled by 'pvp-combat-timeout' option. * Implemented the folloing new options 'player-command-enter' - Handles executing commands when a player enters a claim. 'player-command-exit' - Handles executing commands when a player exits a claim. Note: both command options support the following placeholders : %player%, %owner%, %uuid%, %world%, %server%, %location% 'player-gamemode' - Used to determine the gamemode of a player when entering a claim. 'player-deny-godmode' - Used to determine if a player can be in godmode when entering a claim. 'player-walk-speed' - Controls the player walk speed when entering a claim. 'player-weather' - Controls player local weather when entering a claim. 'pvp-combat-command' - Used to determine if a player can use commands during PvP combat. 'pvp-combat-teleport' - Used to determine if a player can teleport during PvP combat. 'pvp-combat-timeout' - Used to determine how many seconds PvP combat is considered to continue after the most recent damage. 'radius-inspect' - Controls the radius in blocks to search within when inspecting for claims. 'spawn-limit' - Used to control the spawn limit for a specific set of entities in a claim. * Only save once when toggling flag definitions that include multiple definitions.
2019-12-31 00:25:55 +01:00
@Override
public String getServerName() {
return pex.getConfig().getServerTags().get(0);
}
@Override
public boolean hasGroupSubject(String identifier) {
return pex.getSubjects(PermissionsEx.SUBJECTS_GROUP).isRegistered(identifier).join();
}
@Override
public UUID lookupUserUniqueId(String name) {
return Bukkit.getOfflinePlayer(name).getUniqueId(); // TODO: this is not a thing pex does, should be a platform thing
}
@Override
public List<String> getAllLoadedPlayerNames() {
return getAllLoadedSubjectNames(PermissionsEx.SUBJECTS_USER);
}
@Override
public List<String> getAllLoadedGroupNames() {
return getAllLoadedSubjectNames(PermissionsEx.SUBJECTS_GROUP);
}
private List<String> getAllLoadedSubjectNames(String subjectType) {
return pex.getSubjects(subjectType).getActiveSubjects().stream()
.map(subj -> subj.getIdentifier().getValue())
.collect(Collectors.toList());
}
@Override
public void addActiveContexts(Set<Context> contexts, GDPermissionHolder permissionHolder) {
addActiveContexts(contexts, permissionHolder, null, null);
}
@Override
public void addActiveContexts(Set<Context> contexts, GDPermissionHolder permissionHolder, GDPlayerData playerData, Claim claim) {
contexts.addAll(contextsPEXToGD(holderToPEXSubject(permissionHolder).getActiveContexts()));
// ??? TODO anything else
}
private ImmutableSubjectData clearContext(ImmutableSubjectData in, ContextValue<?> ctx) {
for (Set<ContextValue<?>> ctxSet : in.getActiveContexts()) {
if (ctxSet.contains(ctx)) {
in = in.clearPermissions(ctxSet).clearOptions(ctxSet).clearParents(ctxSet);
}
}
return in;
}
@Override
public void clearPermissions(GDClaim claim) {
ContextValue<UUID> claimContext = CTX_CLAIM.createValue(claim.getUniqueId());
pex.performBulkOperation(() -> {
List<CompletableFuture<?>> dataAwait = new LinkedList<>();
pex.getRegisteredSubjectTypes().forEach(type -> {
SubjectType subjects = pex.getSubjects(type);
subjects.getAllIdentifiers().forEach(ident -> {
dataAwait.add(subjects.persistentData().getReference(ident).thenCombine(subjects.transientData().getReference(ident), (persist, trans) -> {
return CompletableFuture.allOf(persist.update(data -> clearContext(data, claimContext)),
trans.update(data -> clearContext(data, claimContext)));
}));
});
});
return CompletableFuture.allOf(dataAwait.toArray(new CompletableFuture[0]));
}).join();
}
@Override
public void clearPermissions(GDPermissionHolder holder, Context context) {
holderToPEXSubject(holder).data().update(data -> data.clearPermissions(ImmutableSet.of(contextGDToPEX(context))));
}
@Override
public void clearPermissions(GDPermissionHolder holder, Set<Context> contexts) {
holderToPEXSubject(holder).data().update(data -> data.clearPermissions(contextsGDToPEX(contexts)));
}
@Override
public boolean holderHasPermission(GDPermissionHolder holder, String permission) {
return holderToPEXSubject(holder).hasPermission(permission);
}
@Override
public Map<String, Boolean> getPermissions(GDPermissionHolder holder, Set<Context> contexts) {
return Maps.transformValues(holderToPEXSubject(holder).getPermissions(contextsGDToPEX(contexts)).asMap(), this::pValIntegerToBool);
}
@Override
Update for 1.5.10 release. * Fix ClaimBlockTask prematurely exiting if a player had max claim blocks. * Fix TaxApplyTask not pulling funds from claim bank first. * Fix ClaimContextCalculator overwriting option claim contexts. * Fix player option commands running during a command causing a loop. * Fix player-command-enter running command from subclaim. * Fix player-command-exit running command to subclaim. * Fix player contexts not being added in all cases where a player is involved. * Fix flag definitions not accepting any context. * Fix elytra enter-claim bypass. * Add 'claim-create-radius-limit' to global config. * Add Simplified Chinese language support (zh_CN). * Add enter-claim flag permission check on player login. * Add enter/exit-claim support for player respawns. If denied, GD will respawn player back in source claim in a safe location. * Add TE NBT id support for mods such as gregtech. * (Hybrid) Fix mohist EntityType mod registration. * (Hybrid/Sponge) Add TE NBT id support for mods such as gregtech. See new setting 'tile-id-nbt-map' under mod category in global.conf * (Sponge) Add 'interact-item-force-list' to global config. Used to force interact-item flag checks when a player left/right-clicks with an item in hand. * (Sponge) Add check to prevent re-registration of worlds. * (Sponge) Add workaround during collisions when user is wrapped in ProjectileSource. * (Sponge) Add EntityThrowable support for getEntityOwner. * (Sponge) Add method to get internal DamageSource type name. * (Sponge) Fix NPE when cancelling claim with '/claimrent cancel' * (Sponge) Fix wrong block being checked during bucket interactions such as lava and water. * (Sponge) Fix block-pre not handing certain mod permission checks such as AE2 cables. * (Sponge) Fix 'block-id-convert-list' feature not using correct id during player interactions. * (Sponge) Fix item-pickup flag not checking trust.
2021-02-06 00:06:14 +01:00
public Map<String, List<String>> getOptions(GDPermissionHolder holder, Set<Context> contexts) {
//return holderToPEXSubject(holder).getOptions(contextsGDToPEX(contexts));
return new HashMap<>();
}
Update for 1.5.0 * Fix blockstate id lookup not using proper id when block data was different than actual block. * Fix block-break showing air as target when source block broke on its own. * Fix race condition when migrating GP Bukkit playerdata. * Fix race condition during flag definition saves. * Fix wrong owner showing in claim when non-owner changes claim type. * Fix explosions causing no sound when cancelling event. * Fix rent min message showing max. * Fix rent min payment not being applied as credit. * Fix rent restore not working on rent end. * Fix sell sign not working when rent system was disabled. * Fix '/abandonall' not giving all money back when using economy mode. * Fix '/claimsell' requiring for sale to be turned on. * Fix '/givepet' taming pets without owner. * Fix explosion sounds not triggering on cancel. * Fix pvp 'allow-fly' only affecting creative mode. * Fix confirmation message not showing after abandoning a subdivision. * Fix wrong location being checked when placing water/lava with bucket. * Fix dynmap owner style colors not being used. * Fix NPE when using /reload. * Fix ghost claim overlap error when creating claim. * Fix user showing up as cause when using rtp. * Fix high memory usage caused by GDClaimManager fastutil usage. * (Bukkit) Fix NPE during InventoryMoveItemEvent. * (Sponge) Fix explosion-surface being triggered with no settings. * Refactor CompletableFuture handling when applying LP permissions and meta to avoid race conditions. * Remove owner override context for flag definition 'fire-spread' as it doesn't affect global overrides. * Change flag definition 'turtle-egg-hatch' target from 'air' to 'turtle-egg-hatch' * Change flag definition 'snow-melt' target from 'air' to 'snow' * Change onPlayerInteractBlockSecondary event priority from lowest to low in order to support plugins that need to cancel early. * Add support for CustomItems. Any customitem used in game will show up in debug as customitems:<item_id>. You can also use customitems for modification and investigation tool in config. * Add support for Slimefun4. Any slimefun item/block used in game will show up in debug as slimefun:<id>. You can also use slimefun items for modification and investigation tool in config. * Add '/acball' command for adjusting all online players' bonus blocks. * Add '/claiminvestigate' command to investigate claims. * Add '/claimtool' to toggle claim tool usage. * Add source/target any contexts to flag definitions. * Add 'piston-protection-in-claims' setting to control piston protection within claims. * Add pvp setting 'combat-logout' to determine if a player should be killed on logout during combat. Default 'false'. * Add `projectile-impact-entity` to `endcrystal-use` flag definition. * Add aquatic target for `monster-animal-damage` flag definition. * Add `restrict-world-max-height` to determine if claiming should be restricted to world max height. Default 'true'. * Add ability to control dynmap color settings by claim type. * Add permission griefdefender.user.claim.command.info.teleport.inside which controls whether a player can ONLY teleport within the claim they are in. This is useful if players become trapped. Note: This does not allow players to teleport to any other claim except the one they are in. It can only be used if the player cannot build in claim. * Add permission griefdefender.user.claim.command.info.others.creation-date to control whether a player sees creation date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.last-active to control whether a player sees last active date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.claim-uuid to control whether a player sees claim uuid in /claiminfo * All flag definitions will now persist. * Refresh player option cache on permission change. * Show TP info in '/claiminfo' when player does not have TP permission. * (Sponge) Use 'tnt' as identifier instead of 'primedtnt' to match bukkit. * (Sponge) Use 'item_frame' as identifier instead of 'itemframe' to match bukkit.
2020-08-16 06:39:38 +02:00
@Override
public Map<Set<Context>, Map<String, Boolean>> getAllPermanentPermissions() {
// TODO
return new HashMap<>();
}
@Override
More fixes and improvements for 1.2.2 release. * Fix flags being reset on claim deletion. * Fix user claim flag permission check. * Fix sign interaction not using proper flag 'interact-block-secondary'. * Fix '/claimexpand' and '/claimcontract' tab completion. * Fix 'entity-damage' flag attempting to protect dropped items. * Fix 'player-keep-inventory' not clearing drops on death. * Fix 'player-keep-level' not clearing XP drops on death. * Fix EntityChangeBlockEvent using wrong source location. * Fix claim create mode triggering twice on first right-click. * Fix default/override claim types not showing up properly in Flag GUI. * Fix entity-damage flag not using proper user on left-click. * Fix abandon-delay default value. * Remove ability to resize claims when auto-schematic-restore is enabled. * Add support for setting no modification/investigation tool in config. * Add '/claim', '/gd mode claim' command to toggle a new claim mode for inspecting and claim creation. * Add 'combat-timeout' pvp setting to config to control how long a player stays in pvp combat after an attack. * Implement 'abandon-delay' option. * Implement 'player-teleport-delay' option. * Implement 'pvp' option. - When a player attempts to attack another player, both players must have pvp allowed. If 1 player is not allowed to PvP, the attack will be cancelled. * Improve '/claimlist' command. - Only trusted claims will be shown to users. - Admins can use '/ignoreclaims' to see all claims. - Fixed server crash if too many claims were listed. - Fixed subdivision filter. * Improve '/claimspawn' command. - The command now takes the following arguments '/claimspawn [name] [player]' Ex. If you want to spawn in a claim that you own named 'lair', you would enter '/claimspawn lair' Ex. If you want to spawn in a claim owned by 'Mike' named 'stables', you would enter '/claimspawn stables mike' * Improve flag definition defaults. * Improve flag default configuration. Fixes #51, Fixes #53, Fixes #54 Fixes #55, Fixes #56, Fixes #57
2019-09-18 17:28:49 +02:00
public Map<Set<Context>, Map<String, Boolean>> getPermanentPermissions(GDPermissionHolder holder) {
return tKeys(holderToPEXSubject(holder).data().get().getAllPermissions(), map -> Maps.transformValues(map, this::pValIntegerToBool));
}
@Override
More fixes and improvements for 1.2.2 release. * Fix flags being reset on claim deletion. * Fix user claim flag permission check. * Fix sign interaction not using proper flag 'interact-block-secondary'. * Fix '/claimexpand' and '/claimcontract' tab completion. * Fix 'entity-damage' flag attempting to protect dropped items. * Fix 'player-keep-inventory' not clearing drops on death. * Fix 'player-keep-level' not clearing XP drops on death. * Fix EntityChangeBlockEvent using wrong source location. * Fix claim create mode triggering twice on first right-click. * Fix default/override claim types not showing up properly in Flag GUI. * Fix entity-damage flag not using proper user on left-click. * Fix abandon-delay default value. * Remove ability to resize claims when auto-schematic-restore is enabled. * Add support for setting no modification/investigation tool in config. * Add '/claim', '/gd mode claim' command to toggle a new claim mode for inspecting and claim creation. * Add 'combat-timeout' pvp setting to config to control how long a player stays in pvp combat after an attack. * Implement 'abandon-delay' option. * Implement 'player-teleport-delay' option. * Implement 'pvp' option. - When a player attempts to attack another player, both players must have pvp allowed. If 1 player is not allowed to PvP, the attack will be cancelled. * Improve '/claimlist' command. - Only trusted claims will be shown to users. - Admins can use '/ignoreclaims' to see all claims. - Fixed server crash if too many claims were listed. - Fixed subdivision filter. * Improve '/claimspawn' command. - The command now takes the following arguments '/claimspawn [name] [player]' Ex. If you want to spawn in a claim that you own named 'lair', you would enter '/claimspawn lair' Ex. If you want to spawn in a claim owned by 'Mike' named 'stables', you would enter '/claimspawn stables mike' * Improve flag definition defaults. * Improve flag default configuration. Fixes #51, Fixes #53, Fixes #54 Fixes #55, Fixes #56, Fixes #57
2019-09-18 17:28:49 +02:00
public Map<Set<Context>, Map<String, Boolean>> getTransientPermissions(GDPermissionHolder holder) {
return tKeys(holderToPEXSubject(holder).transientData().get().getAllPermissions(), map -> Maps.transformValues(map, this::pValIntegerToBool));
}
@Override
Update for 1.5.10 release. * Fix ClaimBlockTask prematurely exiting if a player had max claim blocks. * Fix TaxApplyTask not pulling funds from claim bank first. * Fix ClaimContextCalculator overwriting option claim contexts. * Fix player option commands running during a command causing a loop. * Fix player-command-enter running command from subclaim. * Fix player-command-exit running command to subclaim. * Fix player contexts not being added in all cases where a player is involved. * Fix flag definitions not accepting any context. * Fix elytra enter-claim bypass. * Add 'claim-create-radius-limit' to global config. * Add Simplified Chinese language support (zh_CN). * Add enter-claim flag permission check on player login. * Add enter/exit-claim support for player respawns. If denied, GD will respawn player back in source claim in a safe location. * Add TE NBT id support for mods such as gregtech. * (Hybrid) Fix mohist EntityType mod registration. * (Hybrid/Sponge) Add TE NBT id support for mods such as gregtech. See new setting 'tile-id-nbt-map' under mod category in global.conf * (Sponge) Add 'interact-item-force-list' to global config. Used to force interact-item flag checks when a player left/right-clicks with an item in hand. * (Sponge) Add check to prevent re-registration of worlds. * (Sponge) Add workaround during collisions when user is wrapped in ProjectileSource. * (Sponge) Add EntityThrowable support for getEntityOwner. * (Sponge) Add method to get internal DamageSource type name. * (Sponge) Fix NPE when cancelling claim with '/claimrent cancel' * (Sponge) Fix wrong block being checked during bucket interactions such as lava and water. * (Sponge) Fix block-pre not handing certain mod permission checks such as AE2 cables. * (Sponge) Fix 'block-id-convert-list' feature not using correct id during player interactions. * (Sponge) Fix item-pickup flag not checking trust.
2021-02-06 00:06:14 +01:00
public Map<Set<Context>, Map<String, List<String>>> getPermanentOptions(GDPermissionHolder holder) {
//return tKeys(holderToPEXSubject(holder).data().get().getAllOptions());
return new HashMap<>();
}
@Override
Update for 1.5.10 release. * Fix ClaimBlockTask prematurely exiting if a player had max claim blocks. * Fix TaxApplyTask not pulling funds from claim bank first. * Fix ClaimContextCalculator overwriting option claim contexts. * Fix player option commands running during a command causing a loop. * Fix player-command-enter running command from subclaim. * Fix player-command-exit running command to subclaim. * Fix player contexts not being added in all cases where a player is involved. * Fix flag definitions not accepting any context. * Fix elytra enter-claim bypass. * Add 'claim-create-radius-limit' to global config. * Add Simplified Chinese language support (zh_CN). * Add enter-claim flag permission check on player login. * Add enter/exit-claim support for player respawns. If denied, GD will respawn player back in source claim in a safe location. * Add TE NBT id support for mods such as gregtech. * (Hybrid) Fix mohist EntityType mod registration. * (Hybrid/Sponge) Add TE NBT id support for mods such as gregtech. See new setting 'tile-id-nbt-map' under mod category in global.conf * (Sponge) Add 'interact-item-force-list' to global config. Used to force interact-item flag checks when a player left/right-clicks with an item in hand. * (Sponge) Add check to prevent re-registration of worlds. * (Sponge) Add workaround during collisions when user is wrapped in ProjectileSource. * (Sponge) Add EntityThrowable support for getEntityOwner. * (Sponge) Add method to get internal DamageSource type name. * (Sponge) Fix NPE when cancelling claim with '/claimrent cancel' * (Sponge) Fix wrong block being checked during bucket interactions such as lava and water. * (Sponge) Fix block-pre not handing certain mod permission checks such as AE2 cables. * (Sponge) Fix 'block-id-convert-list' feature not using correct id during player interactions. * (Sponge) Fix item-pickup flag not checking trust.
2021-02-06 00:06:14 +01:00
public Map<Set<Context>, Map<String, List<String>>> getTransientOptions(GDPermissionHolder holder) {
//return tKeys(holderToPEXSubject(holder).transientData().get().getAllOptions());
return new HashMap<>();
}
@Override
More fixes and improvements for 1.2.2 release. * Fix flags being reset on claim deletion. * Fix user claim flag permission check. * Fix sign interaction not using proper flag 'interact-block-secondary'. * Fix '/claimexpand' and '/claimcontract' tab completion. * Fix 'entity-damage' flag attempting to protect dropped items. * Fix 'player-keep-inventory' not clearing drops on death. * Fix 'player-keep-level' not clearing XP drops on death. * Fix EntityChangeBlockEvent using wrong source location. * Fix claim create mode triggering twice on first right-click. * Fix default/override claim types not showing up properly in Flag GUI. * Fix entity-damage flag not using proper user on left-click. * Fix abandon-delay default value. * Remove ability to resize claims when auto-schematic-restore is enabled. * Add support for setting no modification/investigation tool in config. * Add '/claim', '/gd mode claim' command to toggle a new claim mode for inspecting and claim creation. * Add 'combat-timeout' pvp setting to config to control how long a player stays in pvp combat after an attack. * Implement 'abandon-delay' option. * Implement 'player-teleport-delay' option. * Implement 'pvp' option. - When a player attempts to attack another player, both players must have pvp allowed. If 1 player is not allowed to PvP, the attack will be cancelled. * Improve '/claimlist' command. - Only trusted claims will be shown to users. - Admins can use '/ignoreclaims' to see all claims. - Fixed server crash if too many claims were listed. - Fixed subdivision filter. * Improve '/claimspawn' command. - The command now takes the following arguments '/claimspawn [name] [player]' Ex. If you want to spawn in a claim that you own named 'lair', you would enter '/claimspawn lair' Ex. If you want to spawn in a claim owned by 'Mike' named 'stables', you would enter '/claimspawn stables mike' * Improve flag definition defaults. * Improve flag default configuration. Fixes #51, Fixes #53, Fixes #54 Fixes #55, Fixes #56, Fixes #57
2019-09-18 17:28:49 +02:00
public Map<Set<Context>, Map<String, Boolean>> getAllPermissions(GDPermissionHolder holder) {
final Map<Set<Context>, Map<String, Boolean>> allPermissions = new HashMap<>();
holderToPEXSubject(holder).data().get().getAllPermissions().forEach((contexts, perms) ->
allPermissions.put(contextsPEXToGD(contexts), new HashMap<>(Maps.transformValues(perms, this::pValIntegerToBool))));
holderToPEXSubject(holder).transientData().get().getAllPermissions().forEach((contexts, perms) -> {
Set<Context> gdContexts = contextsPEXToGD(contexts);
if (allPermissions.containsKey(gdContexts)) {
Map<String, Boolean> ctxPerms = allPermissions.get(gdContexts);
perms.forEach((k, v) -> ctxPerms.put(k, v > 0));
} else {
allPermissions.put(gdContexts, Maps.transformValues(perms, this::pValIntegerToBool));
}
});
return Collections.unmodifiableMap(allPermissions);
}
@Override
public Tristate getPermissionValue(GDPermissionHolder holder, String permission) {
return tristateFromInt(holderToPEXSubject(holder).getPermission(permission));
}
@Override
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) {
return tristateFromInt(holderToPEXSubject(holder).getPermission(contextsGDToPEX(contexts), permission));
}
@Override
Update for 1.4.2 release. * Fix entity damage not passing source in all cases. * Fix vehicle destroy source. * Fix collision interactions being ignored. * Fix #vehicle context not being added on vehicle item use. * Fix 'any' context showing up as 'all'. * Fix context entity type format using '#' in front of name instead of modid. * Fix parent exit claim messages showing on subclaims. * Fix block-place using wrong target in some cases. * Fix NPE during chunk load on new world creation. * Fix claim resize/subdivide resetting on error. * Fix offline players not being found with some commands. * Fix NPE in migrator during claim migration of subclaims. * Fix accrued blocks not being set for players if value exceeded max during migration. * Fix playerdata migrate file not being created if parent folder did not exist. * Fix hover contexts for partial results in flag GUI. * Fix #pet tag not being formatted properly with contexts. * Fix entity-damage used_item context not being added. * Add new group context #hanging which represents hanging entities such as item frames. * Add lava source to fire-spread flag definition. * Add user context support for advanced flag GUI. * Add endercrystal-use and armorstand-use definitions. * Add entity-damage-source-blacklist. * Add active claim visual time to config. * Add tag support for used_item. * Add visual tracking for create block visuals. * (Bukkit) Add extra permission check when using item on a block. * Add gd_claim_override=claim context to water-flow flag definition. * Add new admin command '/abandonworld [<world>]' which will abandon all user claims in world specified. * Add support for world argument in commands '/abandonall', '/deleteall', and '/deletealladmin'. * Add MC 1.16.1 support. * Update kyori libraries to latest. * Don't process stair blocks on right-click. * Refactor ADMIN group handling in PRESET GUI. - All ADMIN flags will now be forced to claim only. - If you want to change flags globally then simply provide a default context in the definition which will be applied at startup. * Cleanup USER PRESET hover for normal users. * Improve persistent check done if a user is trusted. - Only non-claim owners that are trusted will have an additional permission check to see if an admin denied/allowed something via a flag not given by trust system. * (Hybrid) Add mod registry support for hybrid servers. * (Hybrid) Add mod category to 'global.conf' to identify fakeplayers and mod id's. * (Hybrid) Add initial fakeplayer support. * (Hybrid) Added pixelmon animal support. * (Hybrid) Added #pixelmon:animal tag for natural spawns. * Check user/group permission excluding default group before trust is checked. Note: This allows admins to allow/deny permissions while using trust. Note: Only '/cfp' and '/cfg' is supported. * Only check persistent permissions with overrides. * Change user context to support all claim types except wilderness. * Change global context to support all claim types including wilderness. * Rename /cfd command to /cfdebug to avoid accidental use. * Disable /cfdebug on logout.
2020-06-25 09:15:24 +02:00
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts, PermissionDataType type) {
return tristateFromInt(holderToPEXSubject(holder).getPermission(contextsGDToPEX(contexts), permission));
}
@Override
Update for 1.4.2 release. * Fix entity damage not passing source in all cases. * Fix vehicle destroy source. * Fix collision interactions being ignored. * Fix #vehicle context not being added on vehicle item use. * Fix 'any' context showing up as 'all'. * Fix context entity type format using '#' in front of name instead of modid. * Fix parent exit claim messages showing on subclaims. * Fix block-place using wrong target in some cases. * Fix NPE during chunk load on new world creation. * Fix claim resize/subdivide resetting on error. * Fix offline players not being found with some commands. * Fix NPE in migrator during claim migration of subclaims. * Fix accrued blocks not being set for players if value exceeded max during migration. * Fix playerdata migrate file not being created if parent folder did not exist. * Fix hover contexts for partial results in flag GUI. * Fix #pet tag not being formatted properly with contexts. * Fix entity-damage used_item context not being added. * Add new group context #hanging which represents hanging entities such as item frames. * Add lava source to fire-spread flag definition. * Add user context support for advanced flag GUI. * Add endercrystal-use and armorstand-use definitions. * Add entity-damage-source-blacklist. * Add active claim visual time to config. * Add tag support for used_item. * Add visual tracking for create block visuals. * (Bukkit) Add extra permission check when using item on a block. * Add gd_claim_override=claim context to water-flow flag definition. * Add new admin command '/abandonworld [<world>]' which will abandon all user claims in world specified. * Add support for world argument in commands '/abandonall', '/deleteall', and '/deletealladmin'. * Add MC 1.16.1 support. * Update kyori libraries to latest. * Don't process stair blocks on right-click. * Refactor ADMIN group handling in PRESET GUI. - All ADMIN flags will now be forced to claim only. - If you want to change flags globally then simply provide a default context in the definition which will be applied at startup. * Cleanup USER PRESET hover for normal users. * Improve persistent check done if a user is trusted. - Only non-claim owners that are trusted will have an additional permission check to see if an admin denied/allowed something via a flag not given by trust system. * (Hybrid) Add mod registry support for hybrid servers. * (Hybrid) Add mod category to 'global.conf' to identify fakeplayers and mod id's. * (Hybrid) Add initial fakeplayer support. * (Hybrid) Added pixelmon animal support. * (Hybrid) Added #pixelmon:animal tag for natural spawns. * Check user/group permission excluding default group before trust is checked. Note: This allows admins to allow/deny permissions while using trust. Note: Only '/cfp' and '/cfg' is supported. * Only check persistent permissions with overrides. * Change user context to support all claim types except wilderness. * Change global context to support all claim types including wilderness. * Rename /cfd command to /cfdebug to avoid accidental use. * Disable /cfdebug on logout.
2020-06-25 09:15:24 +02:00
public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) {
return tristateFromInt(holderToPEXSubject(holder).getPermission(contextsGDToPEX(contexts), permission));
}
@Override
public String getOptionValue(GDPermissionHolder holder, Option option, Set<Context> contexts) {
return holderToPEXSubject(holder).getOption(contextsGDToPEX(contexts), option.getPermission()).orElse(null);
}
@Override
Finish implementing options for next major release. * Fixed '/cfg' and '/cog' commands. * Fixed 'create-mode' not working as intended. * Fixed 'any' usage with flag commands. * Fixed 'command-execute' usage. * Fixed 'command-execute-pvp' usage. * Fixed option removal/save with LP v5. * Added context support for controlling user flag command usage. * Added context support to option GUI. * Added permission 'griefdefender.user.claim.command.flag.arg' which controls if a user can use flag command with arguments. * Added permission 'griefdefender.user.claim.command.flag.gui' which controls if a user can use flag GUI. * Added new group context '#all' which can be used to represent all sources or targets. * Removed 'max-claim-inspection-distance' from config as it is now controlled by 'radius-inspect' option. * Removed 'combat-timeout' from config as it is now controlled by 'pvp-combat-timeout' option. * Implemented the folloing new options 'player-command-enter' - Handles executing commands when a player enters a claim. 'player-command-exit' - Handles executing commands when a player exits a claim. Note: both command options support the following placeholders : %player%, %owner%, %uuid%, %world%, %server%, %location% 'player-gamemode' - Used to determine the gamemode of a player when entering a claim. 'player-deny-godmode' - Used to determine if a player can be in godmode when entering a claim. 'player-walk-speed' - Controls the player walk speed when entering a claim. 'player-weather' - Controls player local weather when entering a claim. 'pvp-combat-command' - Used to determine if a player can use commands during PvP combat. 'pvp-combat-teleport' - Used to determine if a player can teleport during PvP combat. 'pvp-combat-timeout' - Used to determine how many seconds PvP combat is considered to continue after the most recent damage. 'radius-inspect' - Controls the radius in blocks to search within when inspecting for claims. 'spawn-limit' - Used to control the spawn limit for a specific set of entities in a claim. * Only save once when toggling flag definitions that include multiple definitions.
2019-12-31 00:25:55 +01:00
public List<String> getOptionValueList(GDPermissionHolder holder, Option option, Set<Context> contexts) {
final List<String> valueList = new ArrayList<>();
valueList.add(holderToPEXSubject(holder).getOption(contextsGDToPEX(contexts), option.getPermission()).orElse(null));
return valueList;
}
@Override
public CompletableFuture<PermissionResult> setOptionValue(GDPermissionHolder holder, String permission, String value, Set<Context> contexts, boolean check) {
return convertResult(holderToPEXSubject(holder).data().update(data -> data.setOption(contextsGDToPEX(contexts), permission, value)));
}
@Override
public CompletableFuture<PermissionResult> setTransientOption(GDPermissionHolder holder, String permission, String value, Set<Context> contexts) {
return convertResult(holderToPEXSubject(holder).transientData().update(data -> data.setOption(contextsGDToPEX(contexts), permission, value)));
}
@Override
public CompletableFuture<PermissionResult> setTransientPermission(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts) {
return convertResult(holderToPEXSubject(holder).transientData().update(data -> data.setPermission(contextsGDToPEX(contexts), permission, pValFromBool(value.asBoolean()))));
}
@Override
public void refreshCachedData(GDPermissionHolder holder) {
// TODO
//holderToPEXSubject(holder).data().getCache().invalidate(holder.getIdentifier());
//holderToPEXSubject(holder).transientData().getCache().invalidate(holder.getIdentifier());
}
Finish implementing options for next major release. * Fixed '/cfg' and '/cog' commands. * Fixed 'create-mode' not working as intended. * Fixed 'any' usage with flag commands. * Fixed 'command-execute' usage. * Fixed 'command-execute-pvp' usage. * Fixed option removal/save with LP v5. * Added context support for controlling user flag command usage. * Added context support to option GUI. * Added permission 'griefdefender.user.claim.command.flag.arg' which controls if a user can use flag command with arguments. * Added permission 'griefdefender.user.claim.command.flag.gui' which controls if a user can use flag GUI. * Added new group context '#all' which can be used to represent all sources or targets. * Removed 'max-claim-inspection-distance' from config as it is now controlled by 'radius-inspect' option. * Removed 'combat-timeout' from config as it is now controlled by 'pvp-combat-timeout' option. * Implemented the folloing new options 'player-command-enter' - Handles executing commands when a player enters a claim. 'player-command-exit' - Handles executing commands when a player exits a claim. Note: both command options support the following placeholders : %player%, %owner%, %uuid%, %world%, %server%, %location% 'player-gamemode' - Used to determine the gamemode of a player when entering a claim. 'player-deny-godmode' - Used to determine if a player can be in godmode when entering a claim. 'player-walk-speed' - Controls the player walk speed when entering a claim. 'player-weather' - Controls player local weather when entering a claim. 'pvp-combat-command' - Used to determine if a player can use commands during PvP combat. 'pvp-combat-teleport' - Used to determine if a player can teleport during PvP combat. 'pvp-combat-timeout' - Used to determine how many seconds PvP combat is considered to continue after the most recent damage. 'radius-inspect' - Controls the radius in blocks to search within when inspecting for claims. 'spawn-limit' - Used to control the spawn limit for a specific set of entities in a claim. * Only save once when toggling flag definitions that include multiple definitions.
2019-12-31 00:25:55 +01:00
@Override
public CompletableFuture<PermissionResult> setPermissionValue(GDPermissionHolder holder, String permission, Tristate value, Set<Context> contexts, boolean check, boolean save) {
return convertResult(holderToPEXSubject(holder).data().update(data -> data.setPermission(contextsGDToPEX(contexts), permission, intFromTristate(value))));
Finish implementing options for next major release. * Fixed '/cfg' and '/cog' commands. * Fixed 'create-mode' not working as intended. * Fixed 'any' usage with flag commands. * Fixed 'command-execute' usage. * Fixed 'command-execute-pvp' usage. * Fixed option removal/save with LP v5. * Added context support for controlling user flag command usage. * Added context support to option GUI. * Added permission 'griefdefender.user.claim.command.flag.arg' which controls if a user can use flag command with arguments. * Added permission 'griefdefender.user.claim.command.flag.gui' which controls if a user can use flag GUI. * Added new group context '#all' which can be used to represent all sources or targets. * Removed 'max-claim-inspection-distance' from config as it is now controlled by 'radius-inspect' option. * Removed 'combat-timeout' from config as it is now controlled by 'pvp-combat-timeout' option. * Implemented the folloing new options 'player-command-enter' - Handles executing commands when a player enters a claim. 'player-command-exit' - Handles executing commands when a player exits a claim. Note: both command options support the following placeholders : %player%, %owner%, %uuid%, %world%, %server%, %location% 'player-gamemode' - Used to determine the gamemode of a player when entering a claim. 'player-deny-godmode' - Used to determine if a player can be in godmode when entering a claim. 'player-walk-speed' - Controls the player walk speed when entering a claim. 'player-weather' - Controls player local weather when entering a claim. 'pvp-combat-command' - Used to determine if a player can use commands during PvP combat. 'pvp-combat-teleport' - Used to determine if a player can teleport during PvP combat. 'pvp-combat-timeout' - Used to determine how many seconds PvP combat is considered to continue after the most recent damage. 'radius-inspect' - Controls the radius in blocks to search within when inspecting for claims. 'spawn-limit' - Used to control the spawn limit for a specific set of entities in a claim. * Only save once when toggling flag definitions that include multiple definitions.
2019-12-31 00:25:55 +01:00
}
@Override
public CompletableFuture<Void> save(GDPermissionHolder holder) {
// TODO
return new CompletableFuture<>();
}
Update for 1.5.0 * Fix blockstate id lookup not using proper id when block data was different than actual block. * Fix block-break showing air as target when source block broke on its own. * Fix race condition when migrating GP Bukkit playerdata. * Fix race condition during flag definition saves. * Fix wrong owner showing in claim when non-owner changes claim type. * Fix explosions causing no sound when cancelling event. * Fix rent min message showing max. * Fix rent min payment not being applied as credit. * Fix rent restore not working on rent end. * Fix sell sign not working when rent system was disabled. * Fix '/abandonall' not giving all money back when using economy mode. * Fix '/claimsell' requiring for sale to be turned on. * Fix '/givepet' taming pets without owner. * Fix explosion sounds not triggering on cancel. * Fix pvp 'allow-fly' only affecting creative mode. * Fix confirmation message not showing after abandoning a subdivision. * Fix wrong location being checked when placing water/lava with bucket. * Fix dynmap owner style colors not being used. * Fix NPE when using /reload. * Fix ghost claim overlap error when creating claim. * Fix user showing up as cause when using rtp. * Fix high memory usage caused by GDClaimManager fastutil usage. * (Bukkit) Fix NPE during InventoryMoveItemEvent. * (Sponge) Fix explosion-surface being triggered with no settings. * Refactor CompletableFuture handling when applying LP permissions and meta to avoid race conditions. * Remove owner override context for flag definition 'fire-spread' as it doesn't affect global overrides. * Change flag definition 'turtle-egg-hatch' target from 'air' to 'turtle-egg-hatch' * Change flag definition 'snow-melt' target from 'air' to 'snow' * Change onPlayerInteractBlockSecondary event priority from lowest to low in order to support plugins that need to cancel early. * Add support for CustomItems. Any customitem used in game will show up in debug as customitems:<item_id>. You can also use customitems for modification and investigation tool in config. * Add support for Slimefun4. Any slimefun item/block used in game will show up in debug as slimefun:<id>. You can also use slimefun items for modification and investigation tool in config. * Add '/acball' command for adjusting all online players' bonus blocks. * Add '/claiminvestigate' command to investigate claims. * Add '/claimtool' to toggle claim tool usage. * Add source/target any contexts to flag definitions. * Add 'piston-protection-in-claims' setting to control piston protection within claims. * Add pvp setting 'combat-logout' to determine if a player should be killed on logout during combat. Default 'false'. * Add `projectile-impact-entity` to `endcrystal-use` flag definition. * Add aquatic target for `monster-animal-damage` flag definition. * Add `restrict-world-max-height` to determine if claiming should be restricted to world max height. Default 'true'. * Add ability to control dynmap color settings by claim type. * Add permission griefdefender.user.claim.command.info.teleport.inside which controls whether a player can ONLY teleport within the claim they are in. This is useful if players become trapped. Note: This does not allow players to teleport to any other claim except the one they are in. It can only be used if the player cannot build in claim. * Add permission griefdefender.user.claim.command.info.others.creation-date to control whether a player sees creation date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.last-active to control whether a player sees last active date in /claiminfo * Add permission griefdefender.user.claim.command.info.others.claim-uuid to control whether a player sees claim uuid in /claiminfo * All flag definitions will now persist. * Refresh player option cache on permission change. * Show TP info in '/claiminfo' when player does not have TP permission. * (Sponge) Use 'tnt' as identifier instead of 'primedtnt' to match bukkit. * (Sponge) Use 'item_frame' as identifier instead of 'itemframe' to match bukkit.
2020-08-16 06:39:38 +02:00
@Override
public CompletableFuture<PermissionResult> setFlagDefinition(GDPermissionHolder holder, FlagDefinition definition, Tristate value, Set<Context> contexts, boolean isTransient) {
// TODO
return new CompletableFuture<>();
}
}