Class DataHandler

  • All Implemented Interfaces:
    org.bukkit.event.Listener

    public class DataHandler
    extends Mechanic
    Handles all plugin data storage, config file access, and the main config file.
    • Field Detail

      • minecraftVersion

        public int minecraftVersion
      • mainConfig

        public org.bukkit.configuration.file.FileConfiguration mainConfig
      • messages

        public org.bukkit.configuration.file.FileConfiguration messages
      • commandConfig

        public org.bukkit.configuration.file.FileConfiguration commandConfig
      • guiConfig

        public org.bukkit.configuration.file.FileConfiguration guiConfig
      • debug

        public boolean debug
      • disableGuis

        public boolean disableGuis
      • persistentParties

        public boolean persistentParties
      • blockInappropriateNames

        public boolean blockInappropriateNames
      • blockInappropriateChat

        public boolean blockInappropriateChat
      • useVault

        public boolean useVault
      • useDisplayNames

        public boolean useDisplayNames
      • migrated

        public boolean migrated
    • Constructor Detail

      • DataHandler

        public DataHandler()
    • Method Detail

      • wipeOldPlugin

        public void wipeOldPlugin()
        This will replace the old config files if they still exist.
      • updateMainConfig

        public void updateMainConfig()
        Initialize the main config file before doing anything else.
      • onStartup

        public void onStartup()
        Runs on plugin startup. Get config options and initialize bStats metrics.
        Overrides:
        onStartup in class Mechanic
      • postStartup

        public void postStartup()
        Set message config file a little after startup.
      • reload

        public void reload()
      • reload

        public void reload​(boolean updateLang)
        Reload config files to recognize changes. This is called on /pc reload
        Parameters:
        updateLang - whether to update lang files
      • onCommandPreprocess

        public void onCommandPreprocess​(org.bukkit.event.player.PlayerCommandPreprocessEvent event)
      • updatePerms

        public void updatePerms​(org.bukkit.entity.Player player)
        Update a players staff permissions.
        Parameters:
        player - The player to update.
      • getTodaysLog

        public File getTodaysLog()
        Get today's plugin log file.
        Returns:
        Today's log file.
      • logToFile

        public void logToFile​(String message,
                              String level)
        Log a message to today's log file.
        Parameters:
        message - Message to log.
        level - Log level.
      • getConfigBoolean

        public boolean getConfigBoolean​(org.bukkit.configuration.file.FileConfiguration config,
                                        String path)
        Get a boolean value from a config file.
        Parameters:
        config - The config file to get the value from.
        path - The path to get the value from.
        Returns:
        Boolean value.
      • getConfigString

        public String getConfigString​(org.bukkit.configuration.file.FileConfiguration config,
                                      String path)
        Get a String value from a config file.
        Parameters:
        config - The config file to get the value from.
        path - The path to get the value from.
        Returns:
        String value.
      • getConfigInt

        public int getConfigInt​(org.bukkit.configuration.file.FileConfiguration config,
                                String path)
        Get an int value from a config file.
        Parameters:
        config - The config file to get the value from.
        path - The path to get the value from.
        Returns:
        Integer value.
      • getConfigStringList

        public List<String> getConfigStringList​(org.bukkit.configuration.file.FileConfiguration config,
                                                String path)
        Get a list of strings from a config file.
        Parameters:
        config - The config file to get the value from.
        path - The path to get the value from.
        Returns:
        List of strings.
      • setMessages

        public void setMessages​(String lang)
        Set the messages config file to a different language. If this method fails it's probably because the language ID you're trying to set isn't present in the main config file's supported-languages section.
        Parameters:
        lang - The language ID to set the plugin language to.
      • getUser

        @Nullable
        public @Nullable User getUser​(@NotNull
                                      @NotNull String name)
        Get a PartyChat user from a name. This may be null.
        Parameters:
        name - The user's name.
        Returns:
        User from name.
      • getUser

        public User getUser​(@NotNull
                            @NotNull org.bukkit.entity.Player player)
        Get PartyChat user from map.
        Parameters:
        player - The player to get a user from.
        Returns:
        User from player.
      • getUser

        @Nullable
        public @Nullable User getUser​(@Nullable
                                      @Nullable UUID uuid)
        Get PartyChat user from map. May be null if uuid hasn't joined or been in a party.
        Parameters:
        uuid - The unique id to get a user from.
        Returns:
        User from unique id.
      • getUserMap

        public Map<UUID,​User> getUserMap()
        Get PartyChat's user map. Unique ids are tied to Users.
        Returns:
        UserMap
      • addToUserMap

        public void addToUserMap​(User user)
        Add a user to the user map.
        Parameters:
        user - User to add.
      • removeFromUserMap

        public void removeFromUserMap​(User user)
        Remove a user from the user map.
        Parameters:
        user - User to remove.