Class Session

  • All Implemented Interfaces:
    Serializable, SectionMap
    Direct Known Subclasses:
    SessionSection

    public class Session
    extends Object
    implements SectionMap
    This class is used to build better communication between Command and CommandSender. It can save something in the executing process and can be used for future.
    See Also:
    Serialized Form
    • Constructor Detail

      • Session

        public Session​(@Nullable
                       Map<String,​Object> values)
        Initialize the YamlConfiguration with existed key-value pairs or not (usually not)
        Parameters:
        values - the session key-value pairs
    • Method Detail

      • createSection

        public SessionSection createSection​(String key)
        Description copied from interface: SectionMap
        Create the section named key
        Specified by:
        createSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        a section named key
      • getSection

        public SectionMap getSection​(String key)
        Description copied from interface: SectionMap
        Get the section named key
        Specified by:
        getSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        the section named key
      • set

        public void set​(String key,
                        Object value)
        Description copied from interface: SectionMap
        Store the key-value pair
        Specified by:
        set in interface SectionMap
        Parameters:
        key - the key of the key-value pair
        value - the value of the key-value pair
      • get

        public <T> T get​(String key)
        Description copied from interface: SectionMap
        Get the value of the key-value pair
        Specified by:
        get in interface SectionMap
        Type Parameters:
        T - the desired type
        Parameters:
        key - the key of the key-value pair
        Returns:
        the desired value
      • getOrDefault

        public <T> T getOrDefault​(String key,
                                  T defaultValue)
        Description copied from interface: SectionMap
        Get the value of the key-value pair
        Specified by:
        getOrDefault in interface SectionMap
        Type Parameters:
        T - the desired type
        Parameters:
        key - the key of the key-value pair
        defaultValue - the default value
        Returns:
        the desired value or defaultValue if there is no value
      • contains

        public boolean contains​(String key)
        Description copied from interface: SectionMap
        Indicate there is a key-value pair named key
        Specified by:
        contains in interface SectionMap
        Parameters:
        key - the key of the key-value pair
        Returns:
        true there is a key-value pair named key, false otherwise
      • remove

        public void remove​(String key)
        Description copied from interface: SectionMap
        Remove the key-value pair named key
        Specified by:
        remove in interface SectionMap
        Parameters:
        key - the key of the key-value pair
      • compute

        public void compute​(String key,
                            java.util.function.BiFunction<? super String,​? super Object,​?> remappingFunction)
        Description copied from interface: SectionMap
        compute the value of the key-value pair
        Specified by:
        compute in interface SectionMap
        Parameters:
        key - the key of the key-value pair
        remappingFunction - the remapping function