mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-18 19:39:15 +00:00
Security provider framework; CoFH provider support via Thermal Foundation integration. Not currently loading...
This commit is contained in:
1 parent
fed0641187
commit
2cc1fc2c32
19 files changed
+252
-14
No files matched your search
@@ -32,8 +32,10 @@ item.storagedrawers.upgradeSorting.name=Sorting Upgrade
|
||||
item.storagedrawers.upgradeSorting.description=For Refined Relocation
|
||||
item.storagedrawers.shroudKey.name=Concealment Key
|
||||
item.storagedrawers.shroudKey.description=Show or hide item labels
|
||||
item.storagedrawers.personalKey.name=Personal Key
|
||||
item.storagedrawers.personalKey.description=Protect access from other players
|
||||
item.storagedrawers.personalKey.default.name=Personal Key
|
||||
item.storagedrawers.personalKey.default.description=Protect access from other players
|
||||
item.storagedrawers.personalKey.cofh.name=Personal Key (CoFH)
|
||||
item.storagedrawers.personalKey.cofh.description=Protect access from other players
|
||||
item.storagedrawers.tape.name=Packing Tape
|
||||
item.storagedrawers.tape.description=Seals drawers for moving
|
||||
|
||||
@@ -187,3 +189,4 @@ storageDrawers.config.integration.enableThaumcraft=Enable Thaumcraft Integration
|
||||
storageDrawers.config.integration.enableMineTweaker=Enable MineTweaker Integration
|
||||
storageDrawers.config.integration.enableRefinedRelocation=Enable Refined Relocation Integration
|
||||
storageDrawers.config.integration.enableThermalExpansion=Enable Thermal Expansion Integration
|
||||
storageDrawers.config.integration.enableThermalFoundation=Enable Thermal Foundation Integration
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 364 B |
File renamed without changes.
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
@@ -8,6 +8,7 @@ import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage;
|
||||
import com.jaquadro.minecraft.storagedrawers.security.SecurityRegistry;
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
@@ -46,6 +47,7 @@ public class StorageDrawers
|
||||
public static RenderRegistry renderRegistry;
|
||||
public static WailaRegistry wailaRegistry;
|
||||
public static BlockRegistry blockRegistry;
|
||||
public static SecurityRegistry securityRegistry;
|
||||
|
||||
@Mod.Instance(MOD_ID)
|
||||
public static StorageDrawers instance;
|
||||
@@ -73,6 +75,7 @@ public class StorageDrawers
|
||||
renderRegistry = new RenderRegistry();
|
||||
wailaRegistry = new WailaRegistry();
|
||||
blockRegistry = new BlockRegistry();
|
||||
securityRegistry = new SecurityRegistry();
|
||||
|
||||
blocks.init();
|
||||
items.init();
|
||||
|
||||
@@ -5,5 +5,9 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
public interface ISecurityProvider
|
||||
{
|
||||
String getProviderID ();
|
||||
|
||||
boolean hasOwnership (GameProfile profile, IProtectable target);
|
||||
|
||||
boolean hasAccess (GameProfile profile, IProtectable target);
|
||||
}
|
||||
@@ -22,4 +22,10 @@ public interface IProtectable
|
||||
* @return null to use the default provider, which enforces strict owner access.
|
||||
*/
|
||||
ISecurityProvider getSecurityProvider ();
|
||||
|
||||
/**
|
||||
* Sets the provider managing security for the target. Set to null for default provider.
|
||||
* @return false if the operation is not supported, true otherwise.
|
||||
*/
|
||||
boolean setSecurityProvider (ISecurityProvider provder);
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.block;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -130,8 +132,13 @@ public class BlockController extends BlockContainer implements INetworked
|
||||
return true;
|
||||
}
|
||||
else if (item.getItem() == ModItems.personalKey) {
|
||||
if (!world.isRemote)
|
||||
te.toggleProtection(player.getGameProfile());
|
||||
if (!world.isRemote) {
|
||||
String securityKey = ((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage());
|
||||
ISecurityProvider provider = StorageDrawers.securityRegistry.getProvider(securityKey);
|
||||
|
||||
te.toggleProtection(player.getGameProfile(), provider);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.gson.JsonParser;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.pack.BlockType;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
|
||||
@@ -13,6 +14,7 @@ import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandar
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModItems;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey;
|
||||
import com.jaquadro.minecraft.storagedrawers.item.ItemTrim;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
|
||||
|
||||
@@ -348,11 +350,18 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
tileDrawers.setIsShrouded(!tileDrawers.isShrouded());
|
||||
return true;
|
||||
}
|
||||
else if (item.getItem() == ModItems.personalKey) {
|
||||
if (tileDrawers.getOwner() == null)
|
||||
else if (item.getItem() instanceof ItemPersonalKey) {
|
||||
String securityKey = ((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage());
|
||||
ISecurityProvider provider = StorageDrawers.securityRegistry.getProvider(securityKey);
|
||||
|
||||
if (tileDrawers.getOwner() == null) {
|
||||
tileDrawers.setOwner(player.getPersistentID());
|
||||
else if (player.getPersistentID().equals(tileDrawers.getOwner()))
|
||||
tileDrawers.setSecurityProvider(provider);
|
||||
}
|
||||
else if (SecurityManager.hasOwnership(player.getGameProfile(), tileDrawers)) {
|
||||
tileDrawers.setOwner(null);
|
||||
tileDrawers.setSecurityProvider(null);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockSlave;
|
||||
@@ -232,7 +233,7 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP
|
||||
return remainder;
|
||||
}
|
||||
|
||||
public void toggleProtection (GameProfile profile) {
|
||||
public void toggleProtection (GameProfile profile, ISecurityProvider provider) {
|
||||
IProtectable template = null;
|
||||
UUID state = null;
|
||||
|
||||
@@ -242,7 +243,7 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP
|
||||
|
||||
if (record.storage instanceof IProtectable) {
|
||||
IProtectable protectable = (IProtectable)record.storage;
|
||||
if (!SecurityManager.hasAccess(profile, protectable))
|
||||
if (!SecurityManager.hasOwnership(profile, protectable))
|
||||
continue;
|
||||
|
||||
if (template == null) {
|
||||
@@ -250,11 +251,14 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP
|
||||
|
||||
if (template.getOwner() == null)
|
||||
state = profile.getId();
|
||||
else
|
||||
else {
|
||||
state = null;
|
||||
provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
protectable.setOwner(state);
|
||||
protectable.setSecurityProvider(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
private boolean taped = false;
|
||||
private boolean hideUpgrade = false;
|
||||
private UUID owner;
|
||||
private String securityKey;
|
||||
|
||||
private EnumSet<LockAttribute> lockAttributes = null;
|
||||
|
||||
@@ -271,7 +272,25 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
|
||||
@Override
|
||||
public ISecurityProvider getSecurityProvider () {
|
||||
return null;
|
||||
return StorageDrawers.securityRegistry.getProvider(securityKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSecurityProvider (ISecurityProvider provider) {
|
||||
if (!StorageDrawers.config.cache.enablePersonalUpgrades)
|
||||
return false;
|
||||
|
||||
String newKey = (provider == null) ? null : provider.getProviderID();
|
||||
if ((newKey != null && !newKey.equals(securityKey)) || (securityKey != null && !securityKey.equals(newKey))) {
|
||||
securityKey = newKey;
|
||||
|
||||
if (worldObj != null && !worldObj.isRemote) {
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldHideUpgrades () {
|
||||
@@ -513,6 +532,10 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
if (tag.hasKey("Own"))
|
||||
owner = UUID.fromString(tag.getString("Own"));
|
||||
|
||||
securityKey = null;
|
||||
if (tag.hasKey("Sec"))
|
||||
securityKey = tag.getString("Sec");
|
||||
|
||||
hideUpgrade = false;
|
||||
if (tag.hasKey("HideUp"))
|
||||
hideUpgrade = tag.getBoolean("HideUp");
|
||||
@@ -557,6 +580,9 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
if (owner != null)
|
||||
tag.setString("Own", owner.toString());
|
||||
|
||||
if (securityKey != null)
|
||||
tag.setString("Sec", securityKey);
|
||||
|
||||
if (hideUpgrade)
|
||||
tag.setBoolean("HideUp", hideUpgrade);
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ public class ConfigManager
|
||||
public boolean enableMineTweakerIntegration;
|
||||
public boolean enableRefinedRelocationIntegration;
|
||||
public boolean enableThermalExpansionIntegration;
|
||||
public boolean enableThermalFoundationIntegration;
|
||||
public boolean enableTape;
|
||||
public boolean enableFallbackRecipes;
|
||||
public boolean invertShift;
|
||||
@@ -255,6 +256,7 @@ public class ConfigManager
|
||||
cache.enableMineTweakerIntegration = config.get(sectionIntegration.getQualifiedName(), "enableMineTweaker", true).setLanguageKey(LANG_PREFIX + "integration.enableMineTweaker").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableRefinedRelocationIntegration = config.get(sectionIntegration.getQualifiedName(), "enableRefinedRelocation", true).setLanguageKey(LANG_PREFIX + "integration.enableRefinedRelocation").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableThermalExpansionIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThermalExpansion", true).setLanguageKey(LANG_PREFIX + "integration.enableThermalExpansion").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableThermalFoundationIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThermalFoundation", true).setLanguageKey(LANG_PREFIX + "integration.enableThermalFoundation").setRequiresMcRestart(true).getBoolean();
|
||||
|
||||
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
|
||||
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "baseStorage", 32).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
|
||||
|
||||
@@ -30,6 +30,8 @@ public class IntegrationRegistry
|
||||
reg.add(new NotEnoughItems());
|
||||
if (Loader.isModLoaded("ThermalExpansion") && StorageDrawers.config.cache.enableThermalExpansionIntegration)
|
||||
reg.add(new ThermalExpansion());
|
||||
if (Loader.isModLoaded("ThermalFoundation") && StorageDrawers.config.cache.enableThermalFoundationIntegration)
|
||||
reg.add(new ThermalFoundation());
|
||||
}
|
||||
|
||||
private IntegrationRegistry () {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.thermalfoundation.CoFHSecurityProvider;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ThermalFoundation extends IntegrationModule
|
||||
{
|
||||
private Class classRegistrySocial;
|
||||
|
||||
private Method methodPlayerHasAccess;
|
||||
|
||||
@Override
|
||||
public String getModID () {
|
||||
return "ThermalFoundation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init () throws Throwable {
|
||||
classRegistrySocial = Class.forName("cofh.core.RegistrySocial");
|
||||
|
||||
methodPlayerHasAccess = classRegistrySocial.getDeclaredMethod("playerHasAccess", String.class, GameProfile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit () {
|
||||
StorageDrawers.securityRegistry.registerProvider(new CoFHSecurityProvider(this));
|
||||
}
|
||||
|
||||
public boolean playerHasAccess (String playerName, GameProfile owner) {
|
||||
try {
|
||||
return (Boolean) methodPlayerHasAccess.invoke(null, playerName, owner);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration.thermalfoundation;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.ThermalFoundation;
|
||||
import com.jaquadro.minecraft.storagedrawers.security.DefaultSecurityProvider;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class CoFHSecurityProvider implements ISecurityProvider
|
||||
{
|
||||
ThermalFoundation foundation;
|
||||
private DefaultSecurityProvider defaultProvider = new DefaultSecurityProvider();
|
||||
|
||||
public CoFHSecurityProvider (ThermalFoundation foundation) {
|
||||
this.foundation = foundation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderID () {
|
||||
return "cofh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOwnership (GameProfile profile, IProtectable target) {
|
||||
return defaultProvider.hasOwnership(profile, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccess (GameProfile profile, IProtectable target) {
|
||||
if (target.getOwner() == null)
|
||||
return true;
|
||||
|
||||
GameProfile ownerProfile = MinecraftServer.getServer().func_152358_ax().func_152652_a(target.getOwner());
|
||||
if (ownerProfile == null)
|
||||
return false;
|
||||
|
||||
return foundation.playerHasAccess(profile.getName(), ownerProfile);
|
||||
}
|
||||
}
|
||||
@@ -3,26 +3,51 @@ package com.jaquadro.minecraft.storagedrawers.item;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPersonalKey extends Item
|
||||
{
|
||||
public static final String[] iconNames = new String[] { "default", "cofh" };
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public ItemPersonalKey (String name) {
|
||||
setUnlocalizedName(name);
|
||||
setCreativeTab(ModCreativeTabs.tabStorageDrawers);
|
||||
setTextureName(StorageDrawers.MOD_ID + ":drawer_key_personal");
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage (int meta) {
|
||||
return icons[MathHelper.clamp_int(meta, 0, iconNames.length - 1)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName (ItemStack itemStack) {
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, iconNames.length - 1);
|
||||
if (iconNames[meta] == null)
|
||||
return super.getUnlocalizedName();
|
||||
|
||||
return super.getUnlocalizedName() + "." + iconNames[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
|
||||
@@ -42,4 +67,31 @@ public class ItemPersonalKey extends Item
|
||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)2, 0));
|
||||
return multimap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems (Item item, CreativeTabs creativeTabs, List list) {
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
if (StorageDrawers.config.cache.enableThermalFoundationIntegration && IntegrationRegistry.instance().isModLoaded("ThermalFoundation"))
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IIconRegister register) {
|
||||
icons = new IIcon[iconNames.length];
|
||||
|
||||
for (int i = 0, n = iconNames.length; i < n; i++) {
|
||||
if (iconNames[i] != null)
|
||||
icons[i] = register.registerIcon(StorageDrawers.MOD_ID + ":drawer_key_personal_" + iconNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSecurityProviderKey (int meta) {
|
||||
switch (meta) {
|
||||
case 0: return null;
|
||||
case 1: return "cofh";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class ItemTape extends Item
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof IProtectable) {
|
||||
if (!SecurityManager.hasAccess(player.getGameProfile(), (IProtectable)tile))
|
||||
if (!SecurityManager.hasOwnership(player.getGameProfile(), (IProtectable)tile))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,20 @@ import com.mojang.authlib.GameProfile;
|
||||
public class DefaultSecurityProvider implements ISecurityProvider
|
||||
{
|
||||
@Override
|
||||
public boolean hasAccess (GameProfile profile, IProtectable target) {
|
||||
public String getProviderID () {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOwnership (GameProfile profile, IProtectable target) {
|
||||
if (target == null || profile == null)
|
||||
return false;
|
||||
|
||||
return target.getOwner() == null || target.getOwner().equals(profile.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccess (GameProfile profile, IProtectable target) {
|
||||
return hasOwnership(profile, target);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,17 @@ public class SecurityManager
|
||||
{
|
||||
private static ISecurityProvider defaultProvider = new DefaultSecurityProvider();
|
||||
|
||||
public static boolean hasOwnership (GameProfile profile, IProtectable target) {
|
||||
if (target == null || profile == null)
|
||||
return false;
|
||||
|
||||
ISecurityProvider provider = target.getSecurityProvider();
|
||||
if (provider == null)
|
||||
provider = defaultProvider;
|
||||
|
||||
return provider.hasOwnership(profile, target);
|
||||
}
|
||||
|
||||
public static boolean hasAccess (GameProfile profile, IProtectable target) {
|
||||
if (target == null || profile == null)
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.security;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SecurityRegistry
|
||||
{
|
||||
private Map<String, ISecurityProvider> registry = new HashMap<String, ISecurityProvider>();
|
||||
|
||||
public void registerProvider (ISecurityProvider provider) {
|
||||
registry.put(provider.getProviderID(), provider);
|
||||
}
|
||||
|
||||
public ISecurityProvider getProvider (String name) {
|
||||
return registry.get(name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user