Package com.ultikits.ultitools.manager
Class DataScope
java.lang.Object
com.ultikits.ultitools.manager.DataScope
A framework-issued credential identifying the caller of a
DataStore
method.
Unlike a raw File, a DataScope cannot be constructed outside this package: both
the constructor and the static factories are package-private, so the only way to obtain one is
through PluginManager (internal modules) or DataStoreManager / the external
plugin registration path (external plugins). UltiTools#getDataStore()
being public in the published jar is therefore no longer a bypass: a caller outside the
framework has no way to mint the token DataStore.getOperator(DataScope, Class) requires.
- Since:
- 6.3.0
- Author:
- wisdomme
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean(package private) static DataScopeforExternal(String pluginName, File dataFolder, Set<Class<?>> ownedEntities) Mints a scope for an external Bukkit plugin borrowing the framework viaUltiToolsAPI.connect(...).(package private) static DataScopeforPlugin(UltiToolsPlugin plugin, Set<Class<?>> ownedEntities) Mints a scope for an internalUltiToolsPluginmodule.inthashCode()booleanWhether the given entity class belongs to this scope.refusalFor(Class<?> dataEntity) Builds the refusal for a caller in this scope requestingdataEntity, which this scope does not own (D-14, D-15).
-
Field Details
-
pluginName
-
dataFolder
-
ownedEntities
-
-
Constructor Details
-
DataScope
-
-
Method Details
-
forPlugin
Mints a scope for an internalUltiToolsPluginmodule.ownedEntitiesis the result ofPluginManager's D-19 scan of the plugin's own JAR (classes carrying@Table), unioned with anything declared via@UltiToolsModule#additionalEntities().- Parameters:
plugin- the internal plugin moduleownedEntities- the entity classes this plugin owns- Returns:
- a scope identifying that plugin
-
forExternal
Mints a scope for an external Bukkit plugin borrowing the framework viaUltiToolsAPI.connect(...).- Parameters:
pluginName- the external plugin's namedataFolder- the external plugin's own data folderownedEntities- the entity classes this plugin owns- Returns:
- a scope identifying that external plugin
-
owns
Whether the given entity class belongs to this scope.- Parameters:
entityClass- the entity class to check- Returns:
- true if this scope owns the entity
-
refusalFor
Builds the refusal for a caller in this scope requestingdataEntity, which this scope does not own (D-14, D-15). Framework-internal; the single source everygetOperatoroverload routes through so the refusal is identical regardless of which one a caller reaches. When another loaded module's scope is known to own the entity, the message names it -- "confirmed to belong to another module"; otherwise it says the entity is not registered to the requester and no owner is known -- "not registered to you" (D-15). The message carries only the entity's fully-qualified name, the requesting plugin's name, and the route (the owning module's exposed service or the EventBus) -- never a table name, column name, row count, or file path, so a refusal cannot be used to enumerate another module's schema.- Parameters:
dataEntity- the entity class this scope does not own- Returns:
- the exception to throw
-
getPluginName
-
getDataFolder
-
getOwnedEntities
-
equals
-
hashCode
public int hashCode()
-