You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Checks if a player can access the given capability provider; validating that protection is enabled in the config. Additionally, this method also checks to see if
50
+
* operators bypassing security is enabled in the config and if it is, provides access to the player if they are an operator.
51
+
*
52
+
* @param player Player to check access for.
53
+
* @param provider The provider to get the capabilities for.
54
+
* @param securityProvider Supplier to get the security capability to check. Can return {@code null} if there is no security.
55
+
* @param ownerProvider Supplier to get the owner capability to check. Can return {@code null} if there is no owner.
56
+
*
57
+
* @return {@code true} if the player can access the given provider.
58
+
*
59
+
* @implNote This method assumes that if the security is {@link SecurityMode#TRUSTED} and there is a clientside player, then the player can access the
60
+
* {@link ISecurityObject security object}. This is done because the list of trusted players is not currently synced to all clients.
* Checks if a player can access the given security object; validating that protection is enabled in the config. Additionally, this method also checks to see if
49
71
* operators bypassing security is enabled in the config and if it is, provides access to the player if they are an operator.
@@ -81,6 +103,28 @@ public interface ISecurityUtils {
* Checks if a player can access the given capability provider; validating that protection is enabled in the config.
108
+
*
109
+
* @param player Player to check access for.
110
+
* @param provider The provider to get the capabilities for.
111
+
* @param securityProvider Supplier to get the security capability to check. Can return {@code null} if there is no security.
112
+
* @param ownerProvider Supplier to get the owner capability to check. Can return {@code null} if there is no owner.
113
+
* @param isClient {@code true} if this method is being run clientside.
114
+
*
115
+
* @return {@code true} if the player can access the given provider. If the player is {@code null} this will return {@code true} if the provider's security is
116
+
* {@link SecurityMode#PUBLIC}.
117
+
*
118
+
* @implNote This method assumes that if the security is {@link SecurityMode#TRUSTED} and there is a player and {@code isClient} is {@code true}, then the player can
119
+
* access the {@link ISecurityObject security object}. This is done because the list of trusted players is not currently synced to all clients.
* Gets the "effective" security mode for a given provider. If no provider is given, or it does not expose a {@link ISecurityObject security object}, then the
183
+
* security will be assumed to be {@link SecurityMode#PUBLIC} <em>unless</em> an {@link IOwnerObject} is exposed, in which case the security will be assumed
184
+
* {@link SecurityMode#PRIVATE} if protection is enabled.
185
+
* <br><br>
186
+
* When a {@link ISecurityObject security object} is exposed; this method is <em>different</em> from just querying {@link ISecurityObject#getSecurityMode()} as this
187
+
* method takes into account whether protection is disabled in the config and whether the owner of the {@link ISecurityObject} has their security frequency configured
188
+
* to override the access level of less restrictive {@link ISecurityObject security objects}.
189
+
*
190
+
* @param provider The provider to get the capabilities for.
191
+
* @param securityProvider Supplier to get the security capability to check. Can return {@code null} if there is no security.
192
+
* @param ownerProvider Supplier to get the owner capability to check. Can return {@code null} if there is no owner.
193
+
* @param isClient {@code true} if this method is being run clientside.
194
+
*
195
+
* @return Effective security mode.
196
+
*
197
+
* @implNote If the provider is {@code null} or doesn't expose a {@link ISecurityObject security object}, then the returned mode is {@link SecurityMode#PUBLIC}
* Gets the "effective" security mode for a given object. This is <em>different</em> from just querying {@link ISecurityObject#getSecurityMode()} as this method takes
139
206
* into account whether protection is disabled in the config and whether the owner of the {@link ISecurityObject} has their security frequency configured to override
* @implNote This method assumes that if the security is {@link SecurityMode#TRUSTED} and there is a player and {@code isClient} is {@code true}, then the player can
75
78
* access the {@link ISecurityObject security object}. This is done because the list of trusted players is not currently synced to all clients.
* @implNote If the provider is {@code null} or doesn't expose a {@link ISecurityObject security object}, then the returned mode is {@link SecurityMode#PUBLIC}
for (Playerplayer : newObjectOpenHashSet<>(playersUsing)) {
71
+
if (!ISecurityUtils.INSTANCE.canAccess(player, lookup, CachingCapabilityLookup::securityCapability, CachingCapabilityLookup::ownerCapability)) {
72
+
//and if they can't then boot them out
73
+
player.closeContainer();
74
+
}
75
+
}
76
+
}
64
77
}
65
78
66
79
/**
67
80
* Used to allow caching the block state and block entity lookup between security capability and owner capability lookup. That way if the block queried does not
68
81
* expose a security capability at the given position we don't have to do more world lookups when querying if the block exposes an owner capability.
82
+
*
83
+
* @implNote As this caches the security and owner objects, this is not suitable for persisting between calls.
* @apiNote Do not instantiate this class directly as it will be done via the service loader. Instead, access instances of this via {@link IEntitySecurityUtils#INSTANCE}
@@ -35,6 +38,46 @@ public EntityCapability<ISecurityObject, Void> securityCapability() {
0 commit comments