65 lines
2.1 KiB
Java
65 lines
2.1 KiB
Java
package me.unurled.raxen.manager.entity;
|
|
|
|
import java.util.ArrayList;
|
|
import lombok.Getter;
|
|
import me.unurled.raxen.Raxen;
|
|
import me.unurled.raxen.components.entity.player.RaxenPlayer;
|
|
import me.unurled.raxen.components.party.Party;
|
|
import me.unurled.raxen.utils.Utils;
|
|
import net.kyori.adventure.text.Component;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
public class PartyManager {
|
|
|
|
Raxen main;
|
|
|
|
public static final int MAX_SIZE = 10;
|
|
|
|
public static final Component PREFIX = Utils.colorComp("<reset><gray>[Party] </gray><yellow>");
|
|
public static final Component PREFIX_SYSTEM = Utils.colorComp(
|
|
"<reset><gray>[Party] </gray><dark_aqua>");
|
|
|
|
@Getter
|
|
private ArrayList<Party> parties;
|
|
|
|
public PartyManager(Raxen main) {
|
|
this.main = main;
|
|
}
|
|
|
|
public void initialize() {
|
|
parties = new ArrayList<Party>();
|
|
new BukkitRunnable() {
|
|
@Override
|
|
public void run() {
|
|
for (int k = 0; k < parties.size(); k++) {
|
|
Party p = parties.get(k);
|
|
if (p.getPlayers().size() == 0) {
|
|
parties.remove(k);
|
|
if (p != null) {
|
|
p.destroy();
|
|
}
|
|
k--;
|
|
if (k < 0) {
|
|
k = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}.runTaskTimerAsynchronously(main, 0L, 20L * 30L);
|
|
}
|
|
|
|
public void createParty(Player p, RaxenPlayer rx) {
|
|
if (rx.getParty() != null) {
|
|
p.sendMessage(PREFIX_SYSTEM.append(Utils.colorComp(
|
|
"<reset><dark_aqua>You are already in a party!\nLeave your current party to create a new one.")));
|
|
return;
|
|
} else {
|
|
Party party = new Party(main, p);
|
|
rx.setParty(party);
|
|
parties.add(party);
|
|
p.sendMessage(PREFIX_SYSTEM.append(Utils.colorComp(
|
|
"<reset><dark_aqua>You have created a party!")));
|
|
}
|
|
}
|
|
}
|