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 voidaddToPartyMap(UUID uuid, Party party)Add a party id and the party to the party map.voiddeleteParty(Party party)Delete a party from the JSON file storage.List<Party>getParties()Get a list of all active parties.@Nullable PartygetParty(User user)Get a party from aUser.@Nullable PartygetParty(UUID uuid)Get a party from a party unique id.@Nullable PartygetParty(org.bukkit.entity.Player player)Get a party from a player.Map<UUID,Party>getPartyMap()Get main party map.booleanisNameTaken(String name)Check if a certain party name is already taken.voidloadParties()Load parties from JSON file storage.voidonShutdown()Runs on plugin shutdown.voidonStartup()Runs when the plugin is being enabled.voidremoveFromPartyMap(UUID uuid)Remove a player from the party map.voidsaveParty(Party party)Save a party to the JSON file storage.voidsendMessageToPartyChat(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:MechanicRuns when the plugin is being enabled.
-
onShutdown
public void onShutdown()
Runs on plugin shutdown. Save parties if persistent parties is enabled.- Overrides:
onShutdownin 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- TheUsersending the message.message- The message being sent.
-
-