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 class
DataHandler.MessageType
-
Field Summary
Fields Modifier and Type Field Description boolean
blockInappropriateChat
boolean
blockInappropriateNames
List<String>
censorWords
org.bukkit.configuration.file.FileConfiguration
commandConfig
boolean
debug
boolean
disableGuis
org.bukkit.configuration.file.FileConfiguration
guiConfig
PartyChat
instance
org.bukkit.configuration.file.FileConfiguration
mainConfig
org.bukkit.configuration.file.FileConfiguration
messages
DataHandler.MessageType
messageType
boolean
migrated
int
minecraftVersion
boolean
persistentParties
boolean
useDisplayNames
boolean
useVault
-
Constructor Summary
Constructors Constructor Description DataHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToUserMap(User user)
Add a user to the user map.boolean
getConfigBoolean(org.bukkit.configuration.file.FileConfiguration config, String path)
Get a boolean value from a config file.int
getConfigInt(org.bukkit.configuration.file.FileConfiguration config, String path)
Get an int value from a config file.String
getConfigString(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.File
getTodaysLog()
Get today's plugin log file.@Nullable User
getUser(@NotNull String name)
Get a PartyChat user from a name.User
getUser(@NotNull org.bukkit.entity.Player player)
Get PartyChat user from map.@Nullable User
getUser(@Nullable UUID uuid)
Get PartyChat user from map.Map<UUID,User>
getUserMap()
Get PartyChat's user map.void
logToFile(String message, String level)
Log a message to today's log file.void
onCommandPreprocess(org.bukkit.event.player.PlayerCommandPreprocessEvent event)
void
onStartup()
Runs on plugin startup.void
postStartup()
Set message config file a little after startup.void
reload()
void
reload(boolean updateLang)
Reload config files to recognize changes.void
removeFromUserMap(User user)
Remove a user from the user map.void
setMessages(String lang)
Set themessages
config file to a different language.void
updateMainConfig()
Initialize the main config file before doing anything else.void
updatePerms(org.bukkit.entity.Player player)
Update a players staff permissions.void
wipeOldPlugin()
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 themessages
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 toUser
s.- 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.
-
-