:D
This commit is contained in:
parent
59d5f0185a
commit
cab2ec9fa3
@ -1,11 +1,13 @@
|
|||||||
package rip.tilly.bedwars.managers.party;
|
package rip.tilly.bedwars.managers.party;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import rip.tilly.bedwars.BedWars;
|
import rip.tilly.bedwars.BedWars;
|
||||||
import rip.tilly.bedwars.player.PlayerData;
|
import rip.tilly.bedwars.player.PlayerData;
|
||||||
import rip.tilly.bedwars.player.PlayerState;
|
import rip.tilly.bedwars.player.PlayerState;
|
||||||
import rip.tilly.bedwars.utils.CC;
|
import rip.tilly.bedwars.utils.CC;
|
||||||
|
import rip.tilly.bedwars.utils.Clickable;
|
||||||
import rip.tilly.bedwars.utils.TtlHashMap;
|
import rip.tilly.bedwars.utils.TtlHashMap;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -50,6 +52,12 @@ public class PartyManager {
|
|||||||
|
|
||||||
public void createPartyInvite(UUID requester, UUID requested) {
|
public void createPartyInvite(UUID requester, UUID requested) {
|
||||||
this.partyInvites.computeIfAbsent(requested, k -> new ArrayList<>()).add(requester);
|
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) {
|
public boolean isInParty(UUID player, Party party) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package rip.tilly.bedwars.providers.scoreboard;
|
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 rip.tilly.bedwars.utils.assemble.AssembleAdapter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import rip.tilly.bedwars.BedWars;
|
import rip.tilly.bedwars.BedWars;
|
||||||
@ -40,8 +42,15 @@ public class ScoreboardProvider implements AssembleAdapter {
|
|||||||
|
|
||||||
private List<String> spawnScoreboard(PlayerData playerData) {
|
private List<String> spawnScoreboard(PlayerData playerData) {
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
|
boolean inParty = this.main.getPartyManager().getParty(playerData.getUniqueId()) != null;
|
||||||
|
|
||||||
lines.add(CC.scoreboardBar);
|
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("&fOnline: &d" + this.main.getServer().getOnlinePlayers().size());
|
||||||
lines.add("&fPlaying: &d");
|
lines.add("&fPlaying: &d");
|
||||||
lines.add(" ");
|
lines.add(" ");
|
||||||
|
51
src/main/java/rip/tilly/bedwars/utils/Clickable.java
Normal file
51
src/main/java/rip/tilly/bedwars/utils/Clickable.java
Normal file
@ -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<TextComponent> 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]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user