Package dev.majek.pc.data
Class PartyHandler
- java.lang.Object
-
- dev.majek.pc.mechanic.Mechanic
-
- dev.majek.pc.data.PartyHandler
-
- All Implemented Interfaces:
org.bukkit.event.Listener
public class PartyHandler extends Mechanic
Handles party saving, loading, and storage.
-
-
Constructor Summary
Constructors Constructor Description PartyHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToPartyMap(UUID uuid, Party party)
Add a party id and the party to the party map.void
deleteParty(Party party)
Delete a party from the JSON file storage.List<Party>
getParties()
Get a list of all active parties.@Nullable Party
getParty(User user)
Get a party from aUser
.@Nullable Party
getParty(UUID uuid)
Get a party from a party unique id.@Nullable Party
getParty(org.bukkit.entity.Player player)
Get a party from a player.Map<UUID,Party>
getPartyMap()
Get main party map.boolean
isNameTaken(String name)
Check if a certain party name is already taken.void
loadParties()
Load parties from JSON file storage.void
onShutdown()
Runs on plugin shutdown.void
onStartup()
Runs when the plugin is being enabled.void
removeFromPartyMap(UUID uuid)
Remove a player from the party map.void
saveParty(Party party)
Save a party to the JSON file storage.void
sendMessageToPartyChat(Party party, User sender, String message)
Send a message to a party.-
Methods inherited from class dev.majek.pc.mechanic.Mechanic
onPlayerJoin, onPlayerQuit
-
-
-
-
Method Detail
-
onStartup
public void onStartup()
Description copied from class:Mechanic
Runs when the plugin is being enabled.
-
onShutdown
public void onShutdown()
Runs on plugin shutdown. Save parties if persistent parties is enabled.- Overrides:
onShutdown
in classMechanic
-
loadParties
public void loadParties()
Load parties from JSON file storage.
-
saveParty
public void saveParty(Party party)
Save a party to the JSON file storage.- Parameters:
party
- Party so save.
-
deleteParty
public void deleteParty(Party party)
Delete a party from the JSON file storage.- Parameters:
party
- Party to delete.
-
isNameTaken
public boolean isNameTaken(String name)
Check if a certain party name is already taken.- Parameters:
name
- Name to check.- Returns:
- true if taken | false if free
-
getParty
@Nullable public @Nullable Party getParty(User user)
Get a party from aUser
. May be null if the user is not in a party.- Parameters:
user
- User to get party from.- Returns:
- Party, if it exists.
-
getParty
@Nullable public @Nullable Party getParty(UUID uuid)
Get a party from a party unique id. May be null if the party doesn't exist.- Parameters:
uuid
- Party's unique id.- Returns:
- Party, if it exists.
-
getParty
@Nullable public @Nullable Party getParty(org.bukkit.entity.Player player)
Get a party from a player. May be null if the player is not in a party.- Parameters:
player
- Player to get party from.- Returns:
- Party, if it exists.
-
getParties
public List<Party> getParties()
Get a list of all active parties.- Returns:
- All active parties.
-
addToPartyMap
public void addToPartyMap(UUID uuid, Party party)
Add a party id and the party to the party map.- Parameters:
uuid
- The party's unique id.party
- The party to add.
-
removeFromPartyMap
public void removeFromPartyMap(UUID uuid)
Remove a player from the party map.- Parameters:
uuid
- The unique id of the player to remove.
-
sendMessageToPartyChat
public void sendMessageToPartyChat(Party party, User sender, String message)
Send a message to a party. This will fire thePartyChatEvent
.- Parameters:
party
- The party to send the message to.sender
- TheUser
sending the message.message
- The message being sent.
-
-