diff --git a/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java b/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java index 9e72993..f32007d 100644 --- a/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java +++ b/src/main/java/rip/tilly/bedwars/managers/party/PartyManager.java @@ -1,11 +1,13 @@ package rip.tilly.bedwars.managers.party; import lombok.Getter; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import rip.tilly.bedwars.BedWars; import rip.tilly.bedwars.player.PlayerData; import rip.tilly.bedwars.player.PlayerState; import rip.tilly.bedwars.utils.CC; +import rip.tilly.bedwars.utils.Clickable; import rip.tilly.bedwars.utils.TtlHashMap; import java.util.ArrayList; @@ -50,6 +52,12 @@ public class PartyManager { public void createPartyInvite(UUID requester, UUID requested) { this.partyInvites.computeIfAbsent(requested, k -> new ArrayList<>()).add(requester); + Clickable partyInv = new Clickable( + CC.translate("&d" + Bukkit.getPlayer(requested).getName() + " &ehas invited you to play in their party!"), + CC.translate("&aClick to join the party!"), + "/party accept " + Bukkit.getPlayer(requested).getName() + ); + partyInv.sendToPlayer(Bukkit.getPlayer(requested)); } public boolean isInParty(UUID player, Party party) { diff --git a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java index ccc4f0c..8f41454 100644 --- a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java +++ b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java @@ -1,5 +1,7 @@ package rip.tilly.bedwars.providers.scoreboard; +import org.bukkit.Bukkit; +import rip.tilly.bedwars.managers.party.Party; import rip.tilly.bedwars.utils.assemble.AssembleAdapter; import org.bukkit.entity.Player; import rip.tilly.bedwars.BedWars; @@ -40,8 +42,15 @@ public class ScoreboardProvider implements AssembleAdapter { private List spawnScoreboard(PlayerData playerData) { List lines = new ArrayList(); + boolean inParty = this.main.getPartyManager().getParty(playerData.getUniqueId()) != null; lines.add(CC.scoreboardBar); + if (inParty) { + Party party = this.main.getPartyManager().getParty(playerData.getUniqueId()); + lines.add("&9Party Leader: &d" + Bukkit.getPlayer(party.getLeader()).getName()); + lines.add("&9Party Members: &d" + party.getMembers().size()); + lines.add(CC.scoreboardBar); + } lines.add("&fOnline: &d" + this.main.getServer().getOnlinePlayers().size()); lines.add("&fPlaying: &d"); lines.add(" "); diff --git a/src/main/java/rip/tilly/bedwars/utils/Clickable.java b/src/main/java/rip/tilly/bedwars/utils/Clickable.java new file mode 100644 index 0000000..9a0b446 --- /dev/null +++ b/src/main/java/rip/tilly/bedwars/utils/Clickable.java @@ -0,0 +1,51 @@ +package rip.tilly.bedwars.utils; + +import lombok.NoArgsConstructor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@NoArgsConstructor +public class Clickable { + + private final List components = new ArrayList<>(); + + public Clickable(String msg) { + TextComponent message = new TextComponent(msg); + this.components.add(message); + } + + public Clickable(String msg, String hoverMsg, String clickString) { + this.add(msg, hoverMsg, clickString); + } + + public TextComponent add(String msg, String hoverMsg, String clickString) { + TextComponent message = new TextComponent(msg); + if (hoverMsg != null) { + message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverMsg).create())); + } + if (clickString != null) { + message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickString)); + } + this.components.add(message); + + return message; + } + + public void add(String message) { + this.components.add(new TextComponent(message)); + } + + public void sendToPlayer(Player player) { + player.spigot().sendMessage(this.asComponents()); + } + + public TextComponent[] asComponents() { + return this.components.toArray(new TextComponent[0]); + } +}