// Path: src/main/java/io/github/mrblobman/spigotcommandlib/FragmentExecutionContext.java
// public class FragmentExecutionContext {
//     public static final int DEFAULT_STATE = 0;
// 
//     private int state;
// 
//     public FragmentExecutionContext() {
//         this.state = 0;
//     }
// 
//     /**
//      * Get the current state that the executor bound to
//      * this context is in.
//      * <p>
//      * The executor must be in the correct state in order for
//      * execution of a fragment command to occur.
//      *
//      * @return the state of the executor bound to this context.
//      */
//     public final int getState() {
//         return this.state;
//     }
// 
//     /**
//      * Set the current state that the executor bound to this context
//      * is in.
//      *
//      * @param state the new state for this executor's context.
//      */
//     public final void setState(int state) {
//         this.state = state;
//     }
// }
// 
// Path: src/main/java/io/github/mrblobman/spigotcommandlib/FragmentedCommandContextSupplier.java
// public interface FragmentedCommandContextSupplier<T> {
//     /**
//      * Create a new command context for passing between commands.
//      *
//      * @return the new context created for a sender in state 0
//      *         of a fragmented command.
//      */
//     T get();
// }
// 
// Path: src/main/java/io/github/mrblobman/spigotcommandlib/FragmentedCommandHandler.java
// public interface FragmentedCommandHandler<T extends FragmentExecutionContext> {
// 
//     /**
//      * This method is invoked when the context for the sender
//      * with the given UUID is being removed from the context
//      * handler. Do not count on this method executing immediately
//      * on timeout, the cleanup time is arbitrary but this hook allows
//      * you to be notified of the context's removal from memory.
//      *
//      * @param id      the UUID of the sender
//      * @param context their execution context
//      */
//     void onCleanup(UUID id, T context);
// }


import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalNotification;
import io.github.mrblobman.spigotcommandlib.FragmentExecutionContext;
import io.github.mrblobman.spigotcommandlib.FragmentedCommandContextSupplier;
import io.github.mrblobman.spigotcommandlib.FragmentedCommandHandler;
import net.md_5.bungee.api.ChatColor;
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2018 MrBlobman
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package io.github.mrblobman.spigotcommandlib.registry;



public class FragmentBundle<T extends FragmentExecutionContext> implements Invoker {
    private static final int CACHE_SPEC_CONCURRENCY_LEVEL = 1;
    /* The term cache may be a little bit misleading, we
    really just need a time based evicting map and this lib is
    bundled with spigot.
     */
    //name -> context
    private Cache<UUID, T> openContexts;
    private FragmentedCommandContextSupplier<T> contextGenerator;
    private Map<SubCommand, FragmentHandleInvoker[]> invokers;
    private Set<SubCommand> hasDefaultStateHandler;
// Path: src/main/java/io/github/mrblobman/spigotcommandlib/FragmentExecutionContext.java
// public class FragmentExecutionContext {
//     public static final int DEFAULT_STATE = 0;
// 
//     private int state;
// 
//     public FragmentExecutionContext() {
//         this.state = 0;
//     }
// 
//     /**
//      * Get the current state that the executor bound to
//      * this context is in.
//      * <p>
//      * The executor must be in the correct state in order for
//      * execution of a fragment command to occur.
//      *
//      * @return the state of the executor bound to this context.
//      */
//     public final int getState() {
//         return this.state;
//     }
// 
//     /**
//      * Set the current state that the executor bound to this context
//      * is in.
//      *
//      * @param state the new state for this executor's context.
//      */
//     public final void setState(int state) {
//         this.state = state;
//     }
// }
// 
// Path: src/main/java/io/github/mrblobman/spigotcommandlib/FragmentedCommandContextSupplier.java
// public interface FragmentedCommandContextSupplier<T> {
//     /**
//      * Create a new command context for passing between commands.
//      *
//      * @return the new context created for a sender in state 0
//      *         of a fragmented command.
//      */
//     T get();
// }
// 
// Path: src/main/java/io/github/mrblobman/spigotcommandlib/FragmentedCommandHandler.java
// public interface FragmentedCommandHandler<T extends FragmentExecutionContext> {
// 
//     /**
//      * This method is invoked when the context for the sender
//      * with the given UUID is being removed from the context
//      * handler. Do not count on this method executing immediately
//      * on timeout, the cleanup time is arbitrary but this hook allows
//      * you to be notified of the context's removal from memory.
//      *
//      * @param id      the UUID of the sender
//      * @param context their execution context
//      */
//     void onCleanup(UUID id, T context);
// }


// Path: src/main/java/io/github/mrblobman/spigotcommandlib/registry/FragmentBundle.java
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalNotification;
import io.github.mrblobman.spigotcommandlib.FragmentExecutionContext;
import io.github.mrblobman.spigotcommandlib.FragmentedCommandContextSupplier;
import io.github.mrblobman.spigotcommandlib.FragmentedCommandHandler;
import net.md_5.bungee.api.ChatColor;

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2018 MrBlobman
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package io.github.mrblobman.spigotcommandlib.registry;



public class FragmentBundle<T extends FragmentExecutionContext> implements Invoker {
    private static final int CACHE_SPEC_CONCURRENCY_LEVEL = 1;
    /* The term cache may be a little bit misleading, we
    really just need a time based evicting map and this lib is
    bundled with spigot.
     */
    //name -> context
    private Cache<UUID, T> openContexts;
    private FragmentedCommandContextSupplier<T> contextGenerator;
    private Map<SubCommand, FragmentHandleInvoker[]> invokers;
    private Set<SubCommand> hasDefaultStateHandler;
    private FragmentedCommandHandler<T> handler;