Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Parties API #81

Open
wants to merge 4 commits into
base: party
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ subprojects {
url 'https://repo.essentialsx.net/releases/'
}

maven {
name = 'alessiodp-repo'
url = 'https://repo.alessiodp.com/releases/'
}

flatDir {
dirs "$rootDir/libs/"
}
Expand Down
1 change: 1 addition & 0 deletions duels-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ processResources {
}

dependencies {
compileOnly 'com.alessiodp.parties:parties-api:3.2.6'
compileOnly 'org.jetbrains:annotations-java5:22.0.0'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
Expand Down
9 changes: 4 additions & 5 deletions duels-plugin/src/main/java/me/realized/duels/DuelsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import me.realized.duels.command.commands.SpectateCommand;
import me.realized.duels.command.commands.duel.DuelCommand;
import me.realized.duels.command.commands.duels.DuelsCommand;
import me.realized.duels.command.commands.party.PartyCommand;
import me.realized.duels.command.commands.queue.QueueCommand;
import me.realized.duels.config.Config;
import me.realized.duels.config.Lang;
Expand Down Expand Up @@ -165,19 +164,19 @@ public void onEnable() {
loadables.add(lang = new Lang(this));
loadables.add(userManager = new UserManagerImpl(this));
loadables.add(guiListener = new GuiListener<>(this));
loadables.add(partyManager = new PartyManagerImpl(this));
loadables.add(kitManager = new KitManagerImpl(this));
loadables.add(arenaManager = new ArenaManagerImpl(this));
loadables.add(settingManager = new SettingsManager(this));
loadables.add(playerManager = new PlayerInfoManager(this));
loadables.add(spectateManager = new SpectateManagerImpl(this));
loadables.add(bettingManager = new BettingManager(this));
loadables.add(inventoryManager = new InventoryManager(this));
loadables.add(duelManager = new DuelManager(this));
loadables.add(queueManager = new QueueManager(this));
loadables.add(queueSignManager = new QueueSignManagerImpl(this));
loadables.add(requestManager = new RequestManager(this));
hookManager = new HookManager(this);
loadables.add(partyManager = new PartyManagerImpl(this));
loadables.add(requestManager = new RequestManager(this));
loadables.add(duelManager = new DuelManager(this));
loadables.add(validatorManager = new ValidatorManager(this));
loadables.add(teleport = new Teleport(this));
loadables.add(extensionManager = new ExtensionManager(this));
Expand Down Expand Up @@ -238,7 +237,7 @@ public void onDisable() {
private boolean load() {
registerCommands(
new DuelCommand(this),
new PartyCommand(this),
// new PartyCommand(this),
new QueueCommand(this),
new SpectateCommand(this),
new DuelsCommand(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import me.realized.duels.kit.KitImpl;
import me.realized.duels.match.DuelMatch;
import me.realized.duels.match.party.PartyDuelMatch;
import me.realized.duels.party.Party;
import com.alessiodp.parties.api.interfaces.Party;
import me.realized.duels.queue.Queue;
import me.realized.duels.setting.Settings;
import me.realized.duels.spectate.SpectatorImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

import com.alessiodp.parties.api.interfaces.PartyPlayer;
import me.realized.duels.DuelsPlugin;
import me.realized.duels.Permissions;
import me.realized.duels.command.BaseCommand;
Expand All @@ -13,10 +17,11 @@
import me.realized.duels.command.commands.duel.subcommands.ToggleCommand;
import me.realized.duels.command.commands.duel.subcommands.TopCommand;
import me.realized.duels.command.commands.duel.subcommands.VersionCommand;
import me.realized.duels.hook.hooks.PartiesHook;
import me.realized.duels.hook.hooks.VaultHook;
import me.realized.duels.hook.hooks.worldguard.WorldGuardHook;
import me.realized.duels.kit.KitImpl;
import me.realized.duels.party.Party;
import com.alessiodp.parties.api.interfaces.Party;
import me.realized.duels.setting.Settings;
import me.realized.duels.util.NumberUtil;
import me.realized.duels.util.StringUtil;
Expand All @@ -32,6 +37,7 @@ public class DuelCommand extends BaseCommand {

private final WorldGuardHook worldGuard;
private final VaultHook vault;
private final PartiesHook parties;

public DuelCommand(final DuelsPlugin plugin) {
super(plugin, "duel", Permissions.DUEL, true);
Expand All @@ -46,6 +52,7 @@ public DuelCommand(final DuelsPlugin plugin) {
);
this.worldGuard = hookManager.getHook(WorldGuardHook.class);
this.vault = hookManager.getHook(VaultHook.class);
this.parties = hookManager.getHook(PartiesHook.class);
}

@Override
Expand All @@ -65,23 +72,27 @@ protected boolean executeFirst(final CommandSender sender, final String label, f
if (isChild(args[0])) {
return false;
}

final Party party = partyManager.get(player);
final Collection<Player> players = party == null ? Collections.singleton(player) : party.getOnlineMembers();

final com.alessiodp.parties.api.interfaces.Party party = parties.getApi().getPartyOfPlayer(player.getUniqueId());
final Collection<Player> players = party == null ? Collections.singleton(player) : partyManager.getOnlinePlayers(party);
if (!ValidatorUtil.validate(validatorManager.getDuelSelfValidators(), player, party, players)) {
return true;
}

final Player target = Bukkit.getPlayerExact(args[0]);
Player target = Bukkit.getPlayerExact(args[0]);
final com.alessiodp.parties.api.interfaces.Party targetParty = target == null ? parties.getApi().getParty(args[0]) : parties.getApi().getPartyOfPlayer(target.getUniqueId());

if (target == null && targetParty != null && targetParty.getLeader() != null) {
target = Bukkit.getPlayer(targetParty.getLeader());
}

if (target == null || !player.canSee(target)) {
lang.sendMessage(sender, "ERROR.player.not-found", "name", args[0]);
return true;
}

final Party targetParty = partyManager.get(target);
final Collection<Player> targetPlayers = targetParty == null ? Collections.singleton(target) : targetParty.getOnlineMembers();
final Collection<Player> targetPlayers = targetParty == null ? Collections.singleton(target) : partyManager.getOnlinePlayers(targetParty);

if (!ValidatorUtil.validate(validatorManager.getDuelTargetValidators(), new Pair<>(player, target), targetParty, targetPlayers)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import java.util.Collection;
import java.util.Collections;

import com.alessiodp.parties.api.interfaces.PartyPlayer;
import me.realized.duels.util.TextBuilder;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand All @@ -11,7 +15,7 @@
import me.realized.duels.api.event.request.RequestAcceptEvent;
import me.realized.duels.command.BaseCommand;
import me.realized.duels.hook.hooks.worldguard.WorldGuardHook;
import me.realized.duels.party.Party;
import com.alessiodp.parties.api.interfaces.Party;
import me.realized.duels.request.RequestImpl;
import me.realized.duels.setting.Settings;
import me.realized.duels.util.function.Pair;
Expand All @@ -30,7 +34,7 @@ public AcceptCommand(final DuelsPlugin plugin) {
protected void execute(final CommandSender sender, final String label, final String[] args) {
final Player player = (Player) sender;
final Party party = partyManager.get(player);
final Collection<Player> players = party == null ? Collections.singleton(player) : party.getOnlineMembers();
final Collection<Player> players = party == null ? Collections.singleton(player) : partyManager.getOnlinePlayers(party);

if (!ValidatorUtil.validate(validatorManager.getDuelAcceptSelfValidators(), player, party, players)) {
return;
Expand All @@ -44,7 +48,7 @@ protected void execute(final CommandSender sender, final String label, final Str
}

final Party targetParty = partyManager.get(target);
final Collection<Player> targetPlayers = targetParty == null ? Collections.singleton(target) : targetParty.getOnlineMembers();
final Collection<Player> targetPlayers = targetParty == null ? Collections.singleton(target) : partyManager.getOnlinePlayers(targetParty);

if (!ValidatorUtil.validate(validatorManager.getDuelAcceptTargetValidators(), new Pair<>(player, target), targetParty, targetPlayers)) {
return;
Expand All @@ -64,19 +68,40 @@ protected void execute(final CommandSender sender, final String label, final Str
final String arena = settings.getArena() != null ? settings.getArena().getName() : lang.getMessage("GENERAL.random");

if (request.isPartyDuel()) {
final Collection<Player> senderPartyMembers = request.getSenderParty().getOnlineMembers();
final Collection<Player> targetPartyMembers = request.getTargetParty().getOnlineMembers();
final Party senderParty = request.getSenderParty();
final Party targetParty1 = request.getTargetParty();

final Collection<Player> senderPartyMembers = partyManager.getOnlinePlayers(senderParty);
final Collection<Player> targetPartyMembers = partyManager.getOnlinePlayers(targetParty1);

lang.sendMessage(senderPartyMembers, "COMMAND.duel.party-request.accept.receiver-party",
"owner", player.getName(), "name", target.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena);
"name", targetParty1.getName(),
"kit", kit,
"own_inventory", ownInventory,
"arena", arena);

lang.sendMessage(targetPartyMembers, "COMMAND.duel.party-request.accept.sender-party",
"owner", target.getName(), "name", player.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena);
"name", targetParty1.getName(),
"kit", kit,
"own_inventory", ownInventory,
"arena", arena);
} else {
final double bet = settings.getBet();
final String itemBetting = settings.isItemBetting() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled");

lang.sendMessage(player, "COMMAND.duel.request.accept.receiver",
"name", target.getName(), "kit", kit, "arena", arena, "bet_amount", bet, "item_betting", itemBetting);
"name", target.getName(),
"kit", kit,
"arena", arena,
"bet_amount", bet,
"item_betting", itemBetting);

lang.sendMessage(target, "COMMAND.duel.request.accept.sender",
"name", player.getName(), "kit", kit, "arena", arena, "bet_amount", bet, "item_betting", itemBetting);
"name", player.getName(),
"kit", kit,
"arena", arena,
"bet_amount", bet,
"item_betting", itemBetting);
}

if (settings.isItemBetting()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ protected void execute(final CommandSender sender, final String label, final Str
Bukkit.getPluginManager().callEvent(event);

if (request.isPartyDuel()) {
final Collection<Player> senderPartyMembers = request.getSenderParty().getOnlineMembers();
final Collection<Player> targetPartyMembers = request.getTargetParty().getOnlineMembers();
final Collection<Player> senderPartyMembers = partyManager.getOnlinePlayers(request.getSenderParty());
final Collection<Player> targetPartyMembers = partyManager.getOnlinePlayers(request.getTargetParty());
lang.sendMessage(senderPartyMembers, "COMMAND.duel.party-request.deny.receiver-party", "owner", player.getName(), "name", target.getName());
lang.sendMessage(targetPartyMembers, "COMMAND.duel.party-request.deny.sender-party", "owner", target.getName(), "name", player.getName());
} else {
Expand Down

This file was deleted.

Loading