The Bukkit Metadata API base implementation is thread-safe.
(Checking can be turned off.)
This commit is contained in:
parent
4a7efdc3a4
commit
806e3c2ef8
|
@ -195,7 +195,7 @@ public class BlockBreakListener extends CheckListener {
|
||||||
// Destroying liquid blocks.
|
// Destroying liquid blocks.
|
||||||
if (!cancelled && BlockProperties.isLiquid(block.getType())
|
if (!cancelled && BlockProperties.isLiquid(block.getType())
|
||||||
&& !pData.hasPermission(Permissions.BLOCKBREAK_BREAK_LIQUID, player)
|
&& !pData.hasPermission(Permissions.BLOCKBREAK_BREAK_LIQUID, player)
|
||||||
&& !NCPExemptionManager.isExempted(player, CheckType.BLOCKBREAK_BREAK, true)){
|
&& !NCPExemptionManager.isExempted(player, CheckType.BLOCKBREAK_BREAK)){
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -666,7 +666,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||||
data.adjustWalkSpeed(player.getWalkSpeed(), tick, cc.speedGrace);
|
data.adjustWalkSpeed(player.getWalkSpeed(), tick, cc.speedGrace);
|
||||||
}
|
}
|
||||||
else if (cc.creativeFlyCheck
|
else if (cc.creativeFlyCheck
|
||||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY, true)
|
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_CREATIVEFLY)
|
||||||
&& !pData.hasPermission(Permissions.MOVING_CREATIVEFLY, player)) {
|
&& !pData.hasPermission(Permissions.MOVING_CREATIVEFLY, player)) {
|
||||||
checkCf = true;
|
checkCf = true;
|
||||||
checkSf = false;
|
checkSf = false;
|
||||||
|
@ -780,7 +780,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||||
// TODO: Redesign to set set backs later (queue + invalidate).
|
// TODO: Redesign to set set backs later (queue + invalidate).
|
||||||
boolean mightSkipNoFall = false; // If to skip nofall check (mainly on violation of other checks).
|
boolean mightSkipNoFall = false; // If to skip nofall check (mainly on violation of other checks).
|
||||||
if (newTo == null && cc.passableCheck && player.getGameMode() != BridgeMisc.GAME_MODE_SPECTATOR
|
if (newTo == null && cc.passableCheck && player.getGameMode() != BridgeMisc.GAME_MODE_SPECTATOR
|
||||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_PASSABLE, true)
|
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_PASSABLE)
|
||||||
&& !pData.hasPermission(Permissions.MOVING_PASSABLE, player)) {
|
&& !pData.hasPermission(Permissions.MOVING_PASSABLE, player)) {
|
||||||
// Passable is checked first to get the original set back locations from the other checks, if needed.
|
// Passable is checked first to get the original set back locations from the other checks, if needed.
|
||||||
newTo = passable.check(player, pFrom, pTo, data, cc, tick, useBlockChangeTracker);
|
newTo = passable.check(player, pFrom, pTo, data, cc, tick, useBlockChangeTracker);
|
||||||
|
@ -867,7 +867,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||||
|
|
||||||
// Morepackets.
|
// Morepackets.
|
||||||
if (cc.morePacketsCheck && (newTo == null || data.isMorePacketsSetBackOldest())
|
if (cc.morePacketsCheck && (newTo == null || data.isMorePacketsSetBackOldest())
|
||||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_MOREPACKETS, true)
|
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_MOREPACKETS)
|
||||||
&& !pData.hasPermission(Permissions.MOVING_MOREPACKETS, player)) {
|
&& !pData.hasPermission(Permissions.MOVING_MOREPACKETS, player)) {
|
||||||
/* (Always check morepackets, if there is a chance that setting/overriding newTo is appropriate,
|
/* (Always check morepackets, if there is a chance that setting/overriding newTo is appropriate,
|
||||||
to avoid packet speeding using micro-violations.) */
|
to avoid packet speeding using micro-violations.) */
|
||||||
|
|
|
@ -401,7 +401,7 @@ public class NoFall extends Check {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isEnabled(final Player player , final MovingConfig cc, final PlayerData pData) {
|
public boolean isEnabled(final Player player , final MovingConfig cc, final PlayerData pData) {
|
||||||
return cc.noFallCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_NOFALL, true)
|
return cc.noFallCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_NOFALL)
|
||||||
&& !pData.hasPermission(Permissions.MOVING_NOFALL, player);
|
&& !pData.hasPermission(Permissions.MOVING_NOFALL, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class MovingUtil {
|
||||||
return cc.survivalFlyCheck && gameMode != BridgeMisc.GAME_MODE_SPECTATOR
|
return cc.survivalFlyCheck && gameMode != BridgeMisc.GAME_MODE_SPECTATOR
|
||||||
&& (cc.ignoreCreative || gameMode != GameMode.CREATIVE) && !player.isFlying()
|
&& (cc.ignoreCreative || gameMode != GameMode.CREATIVE) && !player.isFlying()
|
||||||
&& (cc.ignoreAllowFlight || !player.getAllowFlight())
|
&& (cc.ignoreAllowFlight || !player.getAllowFlight())
|
||||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY, true)
|
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY)
|
||||||
&& (
|
&& (
|
||||||
!Bridge1_9.isGlidingWithElytra(player)
|
!Bridge1_9.isGlidingWithElytra(player)
|
||||||
|| !isGlidingWithElytraValid(player, fromLocation, data, cc)
|
|| !isGlidingWithElytraValid(player, fromLocation, data, cc)
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.NPC;
|
import org.bukkit.entity.NPC;
|
||||||
|
|
||||||
|
@ -157,17 +156,6 @@ public class ExemptionSettings {
|
||||||
this.npcMetaData = npcMetaData == null ? new MetaDataListCheck(null) : npcMetaData;
|
this.npcMetaData = npcMetaData == null ? new MetaDataListCheck(null) : npcMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Top level check for exemption by meta data, including NPCs. Meta data is
|
|
||||||
* only checked if this is the primary thread (!).
|
|
||||||
*
|
|
||||||
* @param entity
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isExemptedBySettings(final Entity entity) {
|
|
||||||
return isExemptedBySettings(entity, Bukkit.isPrimaryThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if according to this instance of settings, the player is regarded as
|
* Test if according to this instance of settings, the player is regarded as
|
||||||
* an NPC. Meta data is only checked if this is the primary thread (!).
|
* an NPC. Meta data is only checked if this is the primary thread (!).
|
||||||
|
@ -176,20 +164,14 @@ public class ExemptionSettings {
|
||||||
* @param isPrimaryThread
|
* @param isPrimaryThread
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isExemptedBySettings(final Entity entity, final boolean isPrimaryThread) {
|
public boolean isExemptedBySettings(final Entity entity) {
|
||||||
return isPrimaryThread && defaultMetaData.hasAnyMetaDataKey(entity)
|
return defaultMetaData.hasAnyMetaDataKey(entity)
|
||||||
|| npcWildCardExempt && isRegardedAsNpc(entity, isPrimaryThread);
|
|| npcWildCardExempt && isRegardedAsNpc(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Deprecated
|
||||||
* Test if according to this instance of settings, the player is regarded as
|
public boolean isExemptedBySettings(final Entity entity, final boolean isPrimaryThread) {
|
||||||
* an NPC.Meta data is only checked if this is the primary thread (!).
|
return isExemptedBySettings(entity);
|
||||||
*
|
|
||||||
* @param entity
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isRegardedAsNpc(final Entity entity) {
|
|
||||||
return isRegardedAsNpc(entity, Bukkit.isPrimaryThread());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,8 +182,13 @@ public class ExemptionSettings {
|
||||||
* @param isPrimaryThread
|
* @param isPrimaryThread
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
public boolean isRegardedAsNpc(final Entity entity) {
|
||||||
|
return npcBukkitInterface && (entity instanceof NPC) || npcMetaData.hasAnyMetaDataKey(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public boolean isRegardedAsNpc(final Entity entity, final boolean isPrimaryThread) {
|
public boolean isRegardedAsNpc(final Entity entity, final boolean isPrimaryThread) {
|
||||||
return npcBukkitInterface && (entity instanceof NPC) || isPrimaryThread && npcMetaData.hasAnyMetaDataKey(entity);
|
return isRegardedAsNpc(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ package fr.neatmonster.nocheatplus.hooks;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||||
|
@ -145,19 +144,6 @@ public class NCPExemptionManager {
|
||||||
return data != null && data.isExempted(checkType);
|
return data != null && data.isExempted(checkType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for exemption, including meta data. Convenience method, testing for
|
|
||||||
* primary thread.
|
|
||||||
*
|
|
||||||
* @see #isExempted(Player, CheckType, boolean)
|
|
||||||
* @param player
|
|
||||||
* @param checkType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static final boolean isExempted(final Player player, final CheckType checkType) {
|
|
||||||
return isExempted(player, checkType, Bukkit.isPrimaryThread());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a player is exempted from a check right now. This also checks
|
* Check if a player is exempted from a check right now. This also checks
|
||||||
* for exemption by meta data, iff it's called from within execution of the
|
* for exemption by meta data, iff it's called from within execution of the
|
||||||
|
@ -174,10 +160,15 @@ public class NCPExemptionManager {
|
||||||
* meta data can't be checked!
|
* meta data can't be checked!
|
||||||
* @return If the player is exempted from the check right now.
|
* @return If the player is exempted from the check right now.
|
||||||
*/
|
*/
|
||||||
|
public static final boolean isExempted(final Player player, final CheckType checkType) {
|
||||||
|
return isExempted(player.getUniqueId(), checkType)
|
||||||
|
|| settings.isExemptedBySettings(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static final boolean isExempted(final Player player, final CheckType checkType,
|
public static final boolean isExempted(final Player player, final CheckType checkType,
|
||||||
final boolean isPrimaryThread) {
|
final boolean isPrimaryThread) {
|
||||||
return isExempted(player.getUniqueId(), checkType)
|
return isExempted(player, checkType);
|
||||||
|| settings.isExemptedBySettings(player, isPrimaryThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class CheckUtils {
|
||||||
improperAPIAccess(checkType);
|
improperAPIAccess(checkType);
|
||||||
}
|
}
|
||||||
// Exemption check.
|
// Exemption check.
|
||||||
if (NCPExemptionManager.isExempted(player, checkType, isPrimaryThread)) {
|
if (NCPExemptionManager.isExempted(player, checkType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check permission policy/cache regardless of the thread context.
|
// Check permission policy/cache regardless of the thread context.
|
||||||
|
|
Loading…
Reference in New Issue