package nl.rutgerkok.blocklocker.impl;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import nl.rutgerkok.blocklocker.HopperCache;
import org.bukkit.block.Block;
import org.bukkit.plugin.Plugin;

import java.util.concurrent.TimeUnit;

final class HopperCacheImpl implements HopperCache {

    private static class CacheContainer {

        final long creationTimeMillis;
        final boolean isLocked;

        public CacheContainer(boolean locked, long time) {
            this.isLocked = locked;
            this.creationTimeMillis = time;
        }
    }

    private static final long EXPIRE_TIME_SECONDS = 10;
    private Cache<Block, CacheContainer> accessCaching;

    HopperCacheImpl(Plugin plugin) {
        accessCaching = CacheBuilder.newBuilder().initialCapacity(1000)
                .maximumSize(5000)
                .expireAfterWrite(EXPIRE_TIME_SECONDS, TimeUnit.SECONDS)
                .build();
    }

    @Override
    public CacheFlag getIsRedstoneAllowed(Block block) {
        CacheContainer container;
        container = accessCaching.getIfPresent(block);

        if (container == null) {
            return CacheFlag.MISS_CACHE;
        }
        if (container.isLocked) {
            return CacheFlag.PROTECTED;
        } else {
            return CacheFlag.NOT_PROTECTED;
        }
    }

    @Override
    public void setIsRedstoneAllowed(Block block, boolean locked) {
        accessCaching.put(block, new CacheContainer(locked, System.currentTimeMillis()));
    }
}

@@ -33,16 +33,120 @@
 .impl;%0A%0A
+import java.util.concurrent.TimeUnit;%0A%0Aimport org.bukkit.block.Block;%0Aimport org.bukkit.plugin.Plugin;%0A%0A
 import c
@@ -220,16 +220,17 @@
 uilder;%0A
+%0A
 import n
@@ -270,435 +270,61 @@
 he;%0A
-import org.bukkit.block.Block;%0Aimport org.bukkit.plugin.Plugin;%0A%0Aimport java.util.concurrent.TimeUnit;%0A%0Afinal class HopperCacheImpl implements HopperCache %7B%0A%0A    private static class CacheContainer %7B%0A%0A        final long creationTimeMillis;%0A        final boolean isLocked;%0A%0A        public CacheContainer(boolean locked, long time) %7B%0A            this.isLocked = locked;%0A            this.creationTimeMillis = time;%0A        %7D%0A    %7D
+%0Afinal class HopperCacheImpl implements HopperCache %7B
 %0A%0A  
@@ -402,30 +402,23 @@
 %3CBlock, 
-CacheContainer
+Boolean
 %3E access
@@ -760,51 +760,24 @@
     
-CacheContainer container;%0A        container
+Boolean isLocked
  = a
@@ -823,25 +823,24 @@
     if (
-container
+isLocked
  == null
@@ -910,26 +910,16 @@
 if (
-container.
 isLocked
 ) %7B%0A
@@ -910,24 +910,32 @@
 if (isLocked
+ == true
 ) %7B%0A        
@@ -1163,62 +1163,14 @@
 ck, 
-new CacheContainer(locked, System.currentTimeMillis())
+locked
 );%0A 

Remove unnecessary CacheContainer class