Class DataCollection


  • public class DataCollection
    extends Object
    Store and parser arguments for better CommandExecutor usage.
    • Constructor Detail

      • DataCollection

        public DataCollection​(DataConverter<?>[] dataConverters)
        Initialize the DataCollection with fixed size.
        Parameters:
        dataConverters - the data converters
    • Method Detail

      • register

        public static void register​(Plugin plugin,
                                    DataConverter<?> dataConverter,
                                    DataCollection.BufferGetter bufferGetter)
        Register the getter of the buffer
        Parameters:
        plugin - the plugin
        dataConverter - the buffer data converter
        bufferGetter - the getter of the buffer
      • unregister

        public static void unregister​(Plugin plugin)
        Unregister the getter of the buffers by plugin
        Parameters:
        plugin - the plugin
      • unregisterAll

        public static boolean unregisterAll()
        Unregister all the getter of the buffers
        Returns:
        true if there are some getter of the buffers not belonging to MainPlugin not been unregistered, false otherwise
      • get

        public String get()
        Get String argument in order
        Returns:
        the String argument in order
      • getInt

        public int getInt()
        Get int argument in order
        Returns:
        the int argument in order
      • getDouble

        public double getDouble()
        Get double argument in order
        Returns:
        the double argument in order
      • getBoolean

        public boolean getBoolean()
        Get boolean argument in order
        Returns:
        the boolean argument in order
      • getLong

        public long getLong()
        Get long argument in order
        Returns:
        the long argument in order
      • writePlugin

        public void writePlugin​(Plugin p)
        Write a Plugin argument
        Parameters:
        p - Plugin argument
      • getPlugin

        public Plugin getPlugin()
        Get Plugin argument in order
        Returns:
        the Plugin argument in order
      • getCommand

        public Command getCommand()
        Get Command argument in order
        Returns:
        the Command argument in order
      • writeCommand

        public void writeCommand​(Command command)
        Write a Command argument
        Parameters:
        command - Command argument
      • write

        public <T> void write​(Class<T> cls,
                              T t)
        Write customize buffer element
        Type Parameters:
        T - the buffer elements' type
        Parameters:
        cls - the buffer elements' class
        t - the buffer element
        Throws:
        UnsupportedOperationException - if the buffer is not registered
      • get

        public <T> T get​(Class<T> c)
        Get customize buffer element
        Type Parameters:
        T - the buffer elements' type
        Parameters:
        c - the buffer elements' class
        Returns:
        T the buffer element
        Throws:
        UnsupportedOperationException - if the buffer is not registered