Package dev.majek.pc.data
Class DataHandler
- java.lang.Object
-
- dev.majek.pc.mechanic.Mechanic
-
- dev.majek.pc.data.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataHandler.MessageType
-
Field Summary
Fields Modifier and Type Field Description booleanblockInappropriateChatbooleanblockInappropriateNamesList<String>censorWordsorg.bukkit.configuration.file.FileConfigurationcommandConfigbooleandebugbooleandisableGuisorg.bukkit.configuration.file.FileConfigurationguiConfigPartyChatinstanceorg.bukkit.configuration.file.FileConfigurationmainConfigorg.bukkit.configuration.file.FileConfigurationmessagesDataHandler.MessageTypemessageTypebooleanmigratedintminecraftVersionbooleanpersistentPartiesbooleanuseDisplayNamesbooleanuseVault
-
Constructor Summary
Constructors Constructor Description DataHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToUserMap(User user)Add a user to the user map.booleangetConfigBoolean(org.bukkit.configuration.file.FileConfiguration config, String path)Get a boolean value from a config file.intgetConfigInt(org.bukkit.configuration.file.FileConfiguration config, String path)Get an int value from a config file.StringgetConfigString(org.bukkit.configuration.file.FileConfiguration config, String path)Get a String value from a config file.List<String>getConfigStringList(org.bukkit.configuration.file.FileConfiguration config, String path)Get a list of strings from a config file.FilegetTodaysLog()Get today's plugin log file.@Nullable UsergetUser(@NotNull String name)Get a PartyChat user from a name.UsergetUser(@NotNull org.bukkit.entity.Player player)Get PartyChat user from map.@Nullable UsergetUser(@Nullable UUID uuid)Get PartyChat user from map.Map<UUID,User>getUserMap()Get PartyChat's user map.voidlogToFile(String message, String level)Log a message to today's log file.voidonCommandPreprocess(org.bukkit.event.player.PlayerCommandPreprocessEvent event)voidonStartup()Runs on plugin startup.voidpostStartup()Set message config file a little after startup.voidreload()voidreload(boolean updateLang)Reload config files to recognize changes.voidremoveFromUserMap(User user)Remove a user from the user map.voidsetMessages(String lang)Set themessagesconfig file to a different language.voidupdateMainConfig()Initialize the main config file before doing anything else.voidupdatePerms(org.bukkit.entity.Player player)Update a players staff permissions.voidwipeOldPlugin()This will replace the old config files if they still exist.-
Methods inherited from class dev.majek.pc.mechanic.Mechanic
onPlayerJoin, onPlayerQuit, onShutdown
-
-
-
-
Field Detail
-
instance
public PartyChat instance
-
minecraftVersion
public int minecraftVersion
-
messageType
public DataHandler.MessageType messageType
-
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
-
-
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.
-
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 themessagesconfig 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 toUsers.- 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.
-
-