From ef4e1d1fd8a670288090df01162a037ac0d3426f Mon Sep 17 00:00:00 2001 From: RemainingToast Date: Thu, 13 Oct 2022 15:38:42 +1000 Subject: [PATCH 1/4] Use Parties API --- build.gradle | 5 + duels-plugin/build.gradle | 1 + .../java/me/realized/duels/DuelsPlugin.java | 9 +- .../me/realized/duels/arena/ArenaImpl.java | 2 +- .../command/commands/duel/DuelCommand.java | 24 ++- .../duel/subcommands/AcceptCommand.java | 10 +- .../duel/subcommands/DenyCommand.java | 4 +- .../command/commands/party/PartyCommand.java | 110 ----------- .../party/subcommands/AcceptCommand.java | 58 ------ .../party/subcommands/DisbandCommand.java | 35 ---- .../subcommands/FriendlyfireCommand.java | 34 ---- .../party/subcommands/KickCommand.java | 55 ------ .../party/subcommands/LeaveCommand.java | 36 ---- .../party/subcommands/ListCommand.java | 85 --------- .../party/subcommands/ToggleCommand.java | 29 --- .../party/subcommands/TransferCommand.java | 48 ----- .../countdown/party/PartyDuelCountdown.java | 2 +- .../realized/duels/data/UserManagerImpl.java | 2 +- .../me/realized/duels/duel/DuelManager.java | 4 +- .../settings/buttons/RequestSendButton.java | 4 +- .../me/realized/duels/hook/HookManager.java | 15 +- .../duels/hook/hooks/PartiesHook.java | 44 +++++ .../duels/match/party/PartyDuelMatch.java | 2 +- .../java/me/realized/duels/party/Party.java | 93 --------- .../me/realized/duels/party/PartyInvite.java | 25 --- .../duels/party/PartyManagerImpl.java | 178 ++---------------- .../me/realized/duels/party/PartyMember.java | 62 ------ .../realized/duels/request/RequestImpl.java | 2 +- .../duels/request/RequestManager.java | 16 +- .../me/realized/duels/setting/Settings.java | 2 +- .../duels/validator/ValidatorManager.java | 6 +- .../validators/match/PartyValidator.java | 4 +- .../self/SelfBlacklistedWorldValidator.java | 2 +- .../request/self/SelfCheckMatchValidator.java | 2 +- .../self/SelfCheckSpectateValidator.java | 2 +- .../request/self/SelfCombatTagValidator.java | 2 +- .../request/self/SelfDuelZoneValidator.java | 2 +- .../self/SelfEmptyInventoryValidator.java | 2 +- .../request/self/SelfPartyValidator.java | 7 +- .../self/SelfPreventCreativeValidator.java | 2 +- .../target/TargetCanRequestValidator.java | 2 +- .../target/TargetCheckMatchValidator.java | 2 +- .../target/TargetCheckSelfValidator.java | 2 +- .../target/TargetCheckSpectateValidator.java | 4 +- .../target/TargetHasRequestValidator.java | 2 +- .../target/TargetNoRequestValidator.java | 2 +- .../request/target/TargetPartyValidator.java | 6 +- 47 files changed, 141 insertions(+), 906 deletions(-) delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/PartyCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/AcceptCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/DisbandCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/FriendlyfireCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/KickCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/LeaveCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ListCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ToggleCommand.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/TransferCommand.java create mode 100644 duels-plugin/src/main/java/me/realized/duels/hook/hooks/PartiesHook.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/party/Party.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/party/PartyInvite.java delete mode 100644 duels-plugin/src/main/java/me/realized/duels/party/PartyMember.java diff --git a/build.gradle b/build.gradle index 67294587..4ea57553 100644 --- a/build.gradle +++ b/build.gradle @@ -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/" } diff --git a/duels-plugin/build.gradle b/duels-plugin/build.gradle index cbad72c0..f477d72e 100644 --- a/duels-plugin/build.gradle +++ b/duels-plugin/build.gradle @@ -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' diff --git a/duels-plugin/src/main/java/me/realized/duels/DuelsPlugin.java b/duels-plugin/src/main/java/me/realized/duels/DuelsPlugin.java index 9ee094da..ea1b63eb 100644 --- a/duels-plugin/src/main/java/me/realized/duels/DuelsPlugin.java +++ b/duels-plugin/src/main/java/me/realized/duels/DuelsPlugin.java @@ -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; @@ -165,7 +164,6 @@ 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)); @@ -173,11 +171,12 @@ public void onEnable() { 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)); @@ -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) diff --git a/duels-plugin/src/main/java/me/realized/duels/arena/ArenaImpl.java b/duels-plugin/src/main/java/me/realized/duels/arena/ArenaImpl.java index 32ad6f42..e1349029 100644 --- a/duels-plugin/src/main/java/me/realized/duels/arena/ArenaImpl.java +++ b/duels-plugin/src/main/java/me/realized/duels/arena/ArenaImpl.java @@ -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; diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java index 5b58073c..98b3dfde 100644 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java +++ b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java @@ -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; @@ -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; @@ -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); @@ -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 @@ -65,10 +72,10 @@ protected boolean executeFirst(final CommandSender sender, final String label, f if (isChild(args[0])) { return false; } - - final Party party = partyManager.get(player); - final Collection players = party == null ? Collections.singleton(player) : party.getOnlineMembers(); - + + final com.alessiodp.parties.api.interfaces.Party party = parties.getApi().getPartyOfPlayer(player.getUniqueId()); + final Collection players = party == null ? Collections.singleton(player) : partyManager.getOnlinePlayers(party); + if (!ValidatorUtil.validate(validatorManager.getDuelSelfValidators(), player, party, players)) { return true; } @@ -80,8 +87,11 @@ protected boolean executeFirst(final CommandSender sender, final String label, f return true; } - final Party targetParty = partyManager.get(target); - final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : targetParty.getOnlineMembers(); + final com.alessiodp.parties.api.interfaces.Party targetParty = parties.getApi().getPartyOfPlayer(target.getUniqueId()); + final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : partyManager.getOnlinePlayers(targetParty); + +// final Party targetParty = partyManager.get(target); +// final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : targetParty.getOnlineMembers(); if (!ValidatorUtil.validate(validatorManager.getDuelTargetValidators(), new Pair<>(player, target), targetParty, targetPlayers)) { return true; diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java index 4b2f1e20..ac78bf46 100644 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java +++ b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java @@ -11,7 +11,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; @@ -30,7 +30,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 players = party == null ? Collections.singleton(player) : party.getOnlineMembers(); + final Collection players = party == null ? Collections.singleton(player) : partyManager.getOnlinePlayers(party); if (!ValidatorUtil.validate(validatorManager.getDuelAcceptSelfValidators(), player, party, players)) { return; @@ -44,7 +44,7 @@ protected void execute(final CommandSender sender, final String label, final Str } final Party targetParty = partyManager.get(target); - final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : targetParty.getOnlineMembers(); + final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : partyManager.getOnlinePlayers(targetParty); if (!ValidatorUtil.validate(validatorManager.getDuelAcceptTargetValidators(), new Pair<>(player, target), targetParty, targetPlayers)) { return; @@ -64,8 +64,8 @@ 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 senderPartyMembers = request.getSenderParty().getOnlineMembers(); - final Collection targetPartyMembers = request.getTargetParty().getOnlineMembers(); + final Collection senderPartyMembers = partyManager.getOnlinePlayers(request.getSenderParty()); + final Collection targetPartyMembers = partyManager.getOnlinePlayers(request.getTargetParty()); lang.sendMessage(senderPartyMembers, "COMMAND.duel.party-request.accept.receiver-party", "owner", player.getName(), "name", target.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena); lang.sendMessage(targetPartyMembers, "COMMAND.duel.party-request.accept.sender-party", diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/DenyCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/DenyCommand.java index e3842c4c..24e31d28 100644 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/DenyCommand.java +++ b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/DenyCommand.java @@ -39,8 +39,8 @@ protected void execute(final CommandSender sender, final String label, final Str Bukkit.getPluginManager().callEvent(event); if (request.isPartyDuel()) { - final Collection senderPartyMembers = request.getSenderParty().getOnlineMembers(); - final Collection targetPartyMembers = request.getTargetParty().getOnlineMembers(); + final Collection senderPartyMembers = partyManager.getOnlinePlayers(request.getSenderParty()); + final Collection 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 { diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/PartyCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/PartyCommand.java deleted file mode 100644 index c6bdd1f2..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/PartyCommand.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.realized.duels.command.commands.party; - -import java.util.List; -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.command.commands.party.subcommands.AcceptCommand; -import me.realized.duels.command.commands.party.subcommands.DisbandCommand; -import me.realized.duels.command.commands.party.subcommands.FriendlyfireCommand; -import me.realized.duels.command.commands.party.subcommands.KickCommand; -import me.realized.duels.command.commands.party.subcommands.LeaveCommand; -import me.realized.duels.command.commands.party.subcommands.ListCommand; -import me.realized.duels.command.commands.party.subcommands.ToggleCommand; -import me.realized.duels.command.commands.party.subcommands.TransferCommand; -import me.realized.duels.data.UserData; -import me.realized.duels.party.Party; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class PartyCommand extends BaseCommand { - - public PartyCommand(final DuelsPlugin plugin) { - super(plugin, "party", Permissions.PARTY, true); - child( - new ToggleCommand(plugin), - new AcceptCommand(plugin), - new ListCommand(plugin), - new LeaveCommand(plugin), - new KickCommand(plugin), - new FriendlyfireCommand(plugin), - new TransferCommand(plugin), - new DisbandCommand(plugin) - ); - } - - @Override - protected boolean executeFirst(final CommandSender sender, final String label, final String[] args) { - final Player player = (Player) sender; - - if (args.length == 0) { - lang.sendMessage(sender, "COMMAND.party.usage", "command", label); - return true; - } - - if (isChild(args[0])) { - return false; - } - - final Player target = Bukkit.getPlayerExact(args[0]); - - if (target == null || !player.canSee(target)) { - lang.sendMessage(sender, "ERROR.player.not-found", "name", args[0]); - return true; - } - - if (player.equals(target)) { - lang.sendMessage(sender, "ERROR.party.is-self"); - return true; - } - - final UserData user = userManager.get(target); - - if (user == null) { - lang.sendMessage(sender, "ERROR.data.not-found", "name", target.getName()); - return true; - } - - if (!user.canPartyRequest()) { - lang.sendMessage(sender, "ERROR.party.requests-disabled", "name", target.getName()); - return true; - } - - if (partyManager.isInParty(target)) { - lang.sendMessage(sender, "ERROR.party.already-in-party.target", "name", target.getName()); - return true; - } - - if (partyManager.hasInvite(player, target)) { - lang.sendMessage(sender, "ERROR.party.already-has-invite", "name", target.getName()); - return true; - } - - final Party party = partyManager.getOrCreate(player); - - if (!party.isOwner(player)) { - lang.sendMessage(sender, "ERROR.party.is-not-owner"); - return true; - } - - if (!partyManager.sendInvite(player, target, party)) { - lang.sendMessage(sender, "ERROR.party.max-size-reached.sender"); - return true; - } - - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.invite.send.members", "owner", player.getName(), "name", target.getName()); - lang.sendMessage(target, "COMMAND.party.invite.send.receiver", "name", sender.getName()); - return true; - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) {} - - // Disables default TabCompleter - @Override - public List onTabComplete(final CommandSender sender, final Command command, final String alias, final String[] args) { - return null; - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/AcceptCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/AcceptCommand.java deleted file mode 100644 index 71fc8cd1..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/AcceptCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; -import me.realized.duels.party.PartyInvite; - -public class AcceptCommand extends BaseCommand { - - public AcceptCommand(final DuelsPlugin plugin) { - super(plugin, "accept", "accept [player]", "Accepts a party invitation.", Permissions.PARTY, 2, true, "a"); - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) { - final Player player = (Player) sender; - - if (partyManager.isInParty(player)) { - lang.sendMessage(sender, "ERROR.party.already-in-party.sender"); - return; - } - - final Player target = Bukkit.getPlayerExact(args[1]); - - if (target == null || !player.canSee(target)) { - lang.sendMessage(sender, "ERROR.player.not-found", "name", args[1]); - return; - } - - final PartyInvite invite = partyManager.removeInvite(target, player); - - if (invite == null) { - lang.sendMessage(sender, "ERROR.party.no-invite", "name", target.getName()); - return; - } - - final Party party = invite.getParty(); - - if (party.isRemoved()) { - lang.sendMessage(sender, "ERROR.party.not-found"); - return; - } - - if (party.size() >= config.getPartyMaxSize()) { - lang.sendMessage(sender, "ERROR.party.max-size-reached.target", "name", target.getName()); - return; - } - - lang.sendMessage(player, "COMMAND.party.invite.accept.receiver", "name", target.getName()); - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.invite.accept.members", "name", player.getName()); - partyManager.join(player, party); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/DisbandCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/DisbandCommand.java deleted file mode 100644 index 836c38a4..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/DisbandCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; - -public class DisbandCommand extends BaseCommand { - - public DisbandCommand(final DuelsPlugin plugin) { - super(plugin, "disband", null, null, Permissions.PARTY, 1, true); - } - - @Override - protected void execute(CommandSender sender, String label, String[] args) { - final Player player = (Player) sender; - final Party party = partyManager.get(player); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - if (!party.isOwner(player)) { - lang.sendMessage(sender, "ERROR.party.is-not-owner"); - return; - } - - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.disband", "owner", player.getName()); - partyManager.remove(party); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/FriendlyfireCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/FriendlyfireCommand.java deleted file mode 100644 index 4ac15222..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/FriendlyfireCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class FriendlyfireCommand extends BaseCommand { - - public FriendlyfireCommand(final DuelsPlugin plugin) { - super(plugin, "friendlyfire", null, null, Permissions.PARTY, 1, true, "ff"); - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) { - final Player player = (Player) sender; - final Party party = partyManager.get(player); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - if (!party.isOwner(player)) { - lang.sendMessage(sender, "ERROR.party.is-not-owner"); - return; - } - - party.setFriendlyFire(!party.isFriendlyFire()); - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.friendly-fire." + (party.isFriendlyFire() ? "enabled" : "disabled")); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/KickCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/KickCommand.java deleted file mode 100644 index 9f71cdad..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/KickCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; -import me.realized.duels.party.PartyMember; - -public class KickCommand extends BaseCommand { - - public KickCommand(final DuelsPlugin plugin) { - super(plugin, "kick", "kick [player]", "Kicks a player from your party.", Permissions.PARTY, 2, true, "remove"); - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) { - final Player player = (Player) sender; - final Party party = partyManager.get(player); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - if (!party.isOwner(player)) { - lang.sendMessage(sender, "ERROR.party.is-not-owner"); - return; - } - - final PartyMember member = party.get(args[1]); - - if (member == null) { - lang.sendMessage(sender, "ERROR.party.not-a-member", "name", args[1]); - return; - } - - if (member.getUuid().equals(player.getUniqueId())) { - lang.sendMessage(sender, "ERROR.party.kick-self"); - return; - } - - partyManager.remove(member, party); - - final Player target = member.getPlayer(); - - if (target != null) { - lang.sendMessage(target, "COMMAND.party.kick.receiver", "owner", player.getName()); - } - - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.kick.members", "owner", player.getName(), "name", member.getName()); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/LeaveCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/LeaveCommand.java deleted file mode 100644 index 8bd15768..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/LeaveCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; - -public class LeaveCommand extends BaseCommand { - - public LeaveCommand(final DuelsPlugin plugin) { - super(plugin, "leave", null, null, Permissions.PARTY, 1, true, "l"); - } - - @Override - protected void execute(CommandSender sender, String label, String[] args) { - final Player player = (Player) sender; - final Party party = partyManager.get(player); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - if (party.isOwner(player)) { - lang.sendMessage(sender, "ERROR.party.is-owner"); - return; - } - - partyManager.remove(player, party); - lang.sendMessage(player, "COMMAND.party.leave.sender", "name", party.getOwner().getName()); - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.leave.members", "name", player.getName()); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ListCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ListCommand.java deleted file mode 100644 index 50384005..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ListCommand.java +++ /dev/null @@ -1,85 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import java.util.ArrayList; -import java.util.List; -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; -import me.realized.duels.party.PartyMember; -import me.realized.duels.util.StringUtil; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class ListCommand extends BaseCommand { - - public ListCommand(final DuelsPlugin plugin) { - super(plugin, "list", null, null, Permissions.PARTY, 1, true, "ls"); - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) { - final Player player = (Player) sender; - final Party party; - - if (args.length > getLength()) { - if (!sender.hasPermission(Permissions.PARTY_LIST_OTHERS)) { - lang.sendMessage(sender, "ERROR.no-permission", "permission", Permissions.PARTY_LIST_OTHERS); - return; - } - - final Player target = Bukkit.getPlayerExact(args[1]); - - if (target == null || !player.canSee(target)) { - lang.sendMessage(sender, "ERROR.player.not-found", "name", args[1]); - return; - } - - party = partyManager.get(target); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.target", "name", target.getName()); - return; - } - - showList(sender, party); - return; - } - - party = partyManager.get(player); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - showList(sender, party); - } - - private void showList(final CommandSender sender, final Party party) { - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - final List memberNames = new ArrayList<>(party.size()); - final List onlineNames = new ArrayList<>(); - - for (final PartyMember member : party.getMembers()) { - memberNames.add(member.getName()); - - if (member.isOnline()) { - onlineNames.add(member.getName()); - } - } - - lang.sendMessage(sender, "COMMAND.party.list", - "members_count", memberNames.size(), - "members", !memberNames.isEmpty() ? StringUtil.join(memberNames, ", ") : lang.getMessage("GENERAL.none"), - "online_count", onlineNames.size(), - "online_members", !onlineNames.isEmpty() ? StringUtil.join(onlineNames, ", ") : lang.getMessage("GENERAL.none"), - "owner", party.getOwner().getName() - ); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ToggleCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ToggleCommand.java deleted file mode 100644 index 72c5fc04..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/ToggleCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.data.UserData; - -public class ToggleCommand extends BaseCommand { - - public ToggleCommand(final DuelsPlugin plugin) { - super(plugin, "toggle", null, null, Permissions.PARTY_TOGGLE, 1, true); - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) { - final UserData user = userManager.get((Player) sender); - - if (user == null) { - lang.sendMessage(sender, "ERROR.data.load-failure"); - return; - } - - user.setPartyRequests(!user.canPartyRequest()); - lang.sendMessage(sender, "COMMAND.party.toggle." + (user.canPartyRequest() ? "enabled" : "disabled")); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/TransferCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/TransferCommand.java deleted file mode 100644 index 60f91a05..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/party/subcommands/TransferCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.realized.duels.command.commands.party.subcommands; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import me.realized.duels.DuelsPlugin; -import me.realized.duels.Permissions; -import me.realized.duels.command.BaseCommand; -import me.realized.duels.party.Party; - -public class TransferCommand extends BaseCommand { - - public TransferCommand(final DuelsPlugin plugin) { - super(plugin, "transfer", "transfer [player]", "Transfers the party ownership to another member of your party.", Permissions.PARTY, 2, true); - } - - @Override - protected void execute(final CommandSender sender, final String label, final String[] args) { - final Player player = (Player) sender; - final Party party = partyManager.get(player); - - if (party == null) { - lang.sendMessage(sender, "ERROR.party.not-in-party.sender"); - return; - } - - if (!party.isOwner(player)) { - lang.sendMessage(sender, "ERROR.party.is-not-owner"); - return; - } - - final Player target = Bukkit.getPlayerExact(args[1]); - - if (target == null || !player.canSee(target)) { - lang.sendMessage(sender, "ERROR.player.not-found", "name", args[1]); - return; - } - - if (!party.isMember(target)) { - lang.sendMessage(sender, "ERROR.party.not-a-member", "name", target.getName()); - return; - } - - party.setOwner(target); - lang.sendMessage(party.getOnlineMembers(), "COMMAND.party.transfer", "owner", player.getName(), "name", target.getName()); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java b/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java index 448b9ab1..4f376c29 100644 --- a/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java +++ b/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java @@ -9,7 +9,7 @@ import me.realized.duels.arena.ArenaImpl; import me.realized.duels.countdown.DuelCountdown; import me.realized.duels.match.party.PartyDuelMatch; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.StringUtil; import me.realized.duels.util.compat.Titles; diff --git a/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java b/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java index 731ceafb..dae89836 100644 --- a/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java +++ b/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java @@ -31,7 +31,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.util.DateUtil; import me.realized.duels.util.Loadable; import me.realized.duels.util.Log; diff --git a/duels-plugin/src/main/java/me/realized/duels/duel/DuelManager.java b/duels-plugin/src/main/java/me/realized/duels/duel/DuelManager.java index 9a78acdb..86fc8f5f 100644 --- a/duels-plugin/src/main/java/me/realized/duels/duel/DuelManager.java +++ b/duels-plugin/src/main/java/me/realized/duels/duel/DuelManager.java @@ -23,7 +23,7 @@ import me.realized.duels.inventories.InventoryManager; import me.realized.duels.kit.KitImpl; import me.realized.duels.match.DuelMatch; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.party.PartyManagerImpl; import me.realized.duels.player.PlayerInfo; import me.realized.duels.player.PlayerInfoManager; @@ -318,7 +318,7 @@ public boolean startMatch(final Player sender, final Player target, final Settin return false; } - return startMatch(settings.getSenderParty().getOnlineMembers(), settings.getTargetParty().getOnlineMembers(), settings, items, source); + return startMatch(partyManager.getOnlinePlayers(settings.getSenderParty()), partyManager.getOnlinePlayers(settings.getTargetParty()), settings, items, source); } else if (senderParty != null || targetParty != null) { lang.sendMessage(Arrays.asList(sender, target), "DUEL.party-start-failure.party-changed"); return false; diff --git a/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestSendButton.java b/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestSendButton.java index 92c9aadc..3d86f14a 100644 --- a/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestSendButton.java +++ b/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestSendButton.java @@ -2,7 +2,7 @@ import me.realized.duels.DuelsPlugin; import me.realized.duels.gui.BaseButton; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.setting.Settings; import me.realized.duels.util.compat.Items; import me.realized.duels.util.inventory.ItemBuilder; @@ -43,7 +43,7 @@ public void onClick(final Player player) { final Party senderParty = settings.getSenderParty(); final Party targetParty = settings.getTargetParty(); - if ((senderParty != null && senderParty.isRemoved()) || (targetParty != null && targetParty.isRemoved())) { + if (senderParty == null || targetParty == null) { player.closeInventory(); lang.sendMessage(player, "ERROR.party.not-found"); return; diff --git a/duels-plugin/src/main/java/me/realized/duels/hook/HookManager.java b/duels-plugin/src/main/java/me/realized/duels/hook/HookManager.java index 8eaf9805..3890385d 100644 --- a/duels-plugin/src/main/java/me/realized/duels/hook/HookManager.java +++ b/duels-plugin/src/main/java/me/realized/duels/hook/HookManager.java @@ -1,19 +1,7 @@ package me.realized.duels.hook; import me.realized.duels.DuelsPlugin; -import me.realized.duels.hook.hooks.BountyHuntersHook; -import me.realized.duels.hook.hooks.CombatLogXHook; -import me.realized.duels.hook.hooks.CombatTagPlusHook; -import me.realized.duels.hook.hooks.EssentialsHook; -import me.realized.duels.hook.hooks.FactionsHook; -import me.realized.duels.hook.hooks.LeaderHeadsHook; -import me.realized.duels.hook.hooks.MVdWPlaceholderHook; -import me.realized.duels.hook.hooks.McMMOHook; -import me.realized.duels.hook.hooks.MyPetHook; -import me.realized.duels.hook.hooks.PlaceholderHook; -import me.realized.duels.hook.hooks.PvPManagerHook; -import me.realized.duels.hook.hooks.SimpleClansHook; -import me.realized.duels.hook.hooks.VaultHook; +import me.realized.duels.hook.hooks.*; import me.realized.duels.hook.hooks.worldguard.WorldGuardHook; import me.realized.duels.util.hook.AbstractHookManager; @@ -30,6 +18,7 @@ public HookManager(final DuelsPlugin plugin) { register(McMMOHook.NAME, McMMOHook.class); register(MVdWPlaceholderHook.NAME, MVdWPlaceholderHook.class); register(MyPetHook.NAME, MyPetHook.class); + register(PartiesHook.NAME, PartiesHook.class); register(PlaceholderHook.NAME, PlaceholderHook.class); register(PvPManagerHook.NAME, PvPManagerHook.class); register(SimpleClansHook.NAME, SimpleClansHook.class); diff --git a/duels-plugin/src/main/java/me/realized/duels/hook/hooks/PartiesHook.java b/duels-plugin/src/main/java/me/realized/duels/hook/hooks/PartiesHook.java new file mode 100644 index 00000000..377db388 --- /dev/null +++ b/duels-plugin/src/main/java/me/realized/duels/hook/hooks/PartiesHook.java @@ -0,0 +1,44 @@ +package me.realized.duels.hook.hooks; + +import com.alessiodp.parties.api.Parties; +import com.alessiodp.parties.api.interfaces.PartiesAPI; +import lombok.Getter; +import me.realized.duels.DuelsPlugin; +import me.realized.duels.util.Log; +import me.realized.duels.util.hook.PluginHook; +import net.milkbowl.vault.economy.Economy; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredServiceProvider; + +import java.util.Arrays; +import java.util.Collection; + +public class PartiesHook extends PluginHook { + + public static final String NAME = "Parties"; + + @Getter + private PartiesAPI api; + + public PartiesHook(final DuelsPlugin plugin) { + super(plugin, NAME); + + Plugin p = Bukkit.getPluginManager().getPlugin("Parties"); + + if (p == null) { + Log.warn("Parties not found."); + return; + } + + if (!p.isEnabled()) { + Log.warn("Parties not enabled."); + return; + } + + api = Parties.getApi(); + Log.info("Using Parties: " + api.getClass().getName()); + } + +} diff --git a/duels-plugin/src/main/java/me/realized/duels/match/party/PartyDuelMatch.java b/duels-plugin/src/main/java/me/realized/duels/match/party/PartyDuelMatch.java index bcd43b95..b9e97354 100644 --- a/duels-plugin/src/main/java/me/realized/duels/match/party/PartyDuelMatch.java +++ b/duels-plugin/src/main/java/me/realized/duels/match/party/PartyDuelMatch.java @@ -20,7 +20,7 @@ import me.realized.duels.arena.ArenaImpl; import me.realized.duels.kit.KitImpl; import me.realized.duels.match.DuelMatch; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.queue.Queue; public class PartyDuelMatch extends DuelMatch { diff --git a/duels-plugin/src/main/java/me/realized/duels/party/Party.java b/duels-plugin/src/main/java/me/realized/duels/party/Party.java deleted file mode 100644 index ea99ad12..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/party/Party.java +++ /dev/null @@ -1,93 +0,0 @@ -package me.realized.duels.party; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; -import java.util.stream.Collectors; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; -import org.bukkit.entity.Player; - -public class Party { - - @Getter - private final long creation; - @Getter - @Setter - private boolean friendlyFire; - @Getter - @Setter(value = AccessLevel.PACKAGE) - private boolean removed; - - @Getter - private PartyMember owner; - - private final Map members = new HashMap<>(); - - public Party(final Player owner) { - this.creation = System.currentTimeMillis(); - add(owner); - this.owner = get(owner); - } - - public PartyMember get(final String name) { - return members.values().stream().filter(member -> member.getName().equalsIgnoreCase(name)).findFirst().orElse(null); - } - - public PartyMember get(final Player player) { - return members.get(player.getUniqueId()); - } - - public boolean isMember(final Player player) { - return get(player) != null; - } - - public boolean add(final Player player) { - PartyMember member = get(player); - - if (member != null) { - return false; - } - - members.put(player.getUniqueId(), new PartyMember(player, this)); - return true; - } - - public boolean remove(final PartyMember member) { - return members.remove(member.getUuid()) != null; - } - - public boolean remove(final Player player) { - return members.remove(player.getUniqueId()) != null; - } - - public boolean isOwner(final Player player) { - return owner != null && owner.equals(get(player)); - } - - public void setOwner(final Player other) { - PartyMember member = get(other); - - if (member == null) { - return; - } - - this.owner = member; - } - - public int size() { - return members.size(); - } - - public Collection getMembers() { - return members.values(); - } - - public List getOnlineMembers() { - return members.values().stream().map(PartyMember::getPlayer).filter(Objects::nonNull).collect(Collectors.toList()); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/party/PartyInvite.java b/duels-plugin/src/main/java/me/realized/duels/party/PartyInvite.java deleted file mode 100644 index 2591ae04..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/party/PartyInvite.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.realized.duels.party; - -import java.util.UUID; -import lombok.Getter; -import org.bukkit.entity.Player; - -public class PartyInvite { - - @Getter - private final long creation; - - @Getter - private final UUID sender; - @Getter - private final UUID receiver; - @Getter - private final Party party; - - public PartyInvite(final Player sender, final Player receiver, final Party party) { - this.creation = System.currentTimeMillis(); - this.sender = sender.getUniqueId(); - this.receiver = receiver.getUniqueId(); - this.party = party; - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java b/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java index 07781807..f7434028 100644 --- a/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java +++ b/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java @@ -1,14 +1,9 @@ package me.realized.duels.party; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import com.alessiodp.parties.api.interfaces.PartiesAPI; import me.realized.duels.DuelsPlugin; -import me.realized.duels.config.Config; import me.realized.duels.config.Lang; +import me.realized.duels.hook.hooks.PartiesHook; import me.realized.duels.util.EventUtil; import me.realized.duels.util.Loadable; import org.bukkit.Bukkit; @@ -16,180 +11,49 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.Collection; +import java.util.stream.Collectors; public class PartyManagerImpl implements Loadable, Listener { private final DuelsPlugin plugin; - private final Config config; private final Lang lang; - - private final Map> invites = new HashMap<>(); - - private final Map partyMap = new HashMap<>(); - private final List parties = new ArrayList<>(); - - private int autoDisbandTask; + private final PartiesAPI partiesAPI; public PartyManagerImpl(final DuelsPlugin plugin) { this.plugin = plugin; - this.config = plugin.getConfiguration(); this.lang = plugin.getLang(); + this.partiesAPI = plugin.getHookManager().getHook(PartiesHook.class).getApi(); Bukkit.getPluginManager().registerEvents(this, plugin); } @Override public void handleLoad() { - if (config.getPartyAutoDisbandAfter() > 0) { - this.autoDisbandTask = plugin.doSyncRepeat(() -> { - Iterator iterator = parties.iterator(); - - while (iterator.hasNext()) { - final Party party = iterator.next(); - - if (party.getOwner().isOnline() || System.currentTimeMillis() - party.getOwner().getLastLogout() < (config.getPartyAutoDisbandAfter() * 60 * 1000L)) { - continue; - } - - lang.sendMessage(party.getOnlineMembers(), "PARTY.auto-disband"); - party.setRemoved(true); - party.getMembers().forEach(member -> partyMap.remove(member.getUuid())); - iterator.remove(); - } - }, 0L, 20L * 60).getTaskId(); - } + } @Override public void handleUnload() { - plugin.cancelTask(autoDisbandTask); - invites.clear(); - parties.clear(); - partyMap.clear(); - } - - private Map getInvites(final Player player, final boolean create) { - Map cached = invites.get(player.getUniqueId()); - - if (cached == null && create) { - invites.put(player.getUniqueId(), cached = new HashMap<>()); - return cached; - } - - return cached; - } - - public PartyInvite getInvite(final Player sender, final Player target) { - final Map cached = getInvites(sender, false); - - if (cached == null) { - return null; - } - - final PartyInvite invite = cached.get(target.getUniqueId()); - if (invite == null) { - return null; - } - - if (System.currentTimeMillis() - invite.getCreation() >= config.getPartyInviteExpiration() * 1000L) { - cached.remove(target.getUniqueId()); - return null; - } - - return invite; } - public boolean hasInvite(final Player sender, final Player target) { - return getInvite(sender, target) != null; + public com.alessiodp.parties.api.interfaces.Party get(final Player player) { + return partiesAPI.getPartyOfPlayer(player.getUniqueId()); } - public PartyInvite removeInvite(final Player sender, final Player target) { - final Map cached = getInvites(sender, false); - - if (cached == null) { - return null; - } - - final PartyInvite invite = cached.remove(target.getUniqueId()); - - if (invite == null) { - return null; - } - - if (System.currentTimeMillis() - invite.getCreation() >= config.getPartyInviteExpiration() * 1000L) { - cached.remove(target.getUniqueId()); - return null; - } - - return invite; - } - - public boolean sendInvite(final Player sender, final Player target, final Party party) { - if (party.size() >= config.getPartyMaxSize()) { - return false; - } - - final PartyInvite invite = new PartyInvite(sender, target, party); - getInvites(sender, true).put(target.getUniqueId(), invite); - return true; - } - - public Party get(final Player player) { - return partyMap.get(player.getUniqueId()); - } - - public Party getOrCreate(final Player player) { - Party party = get(player); - - if (party != null) { - return party; - } - - party = new Party(player); - parties.add(party); - partyMap.put(player.getUniqueId(), party); - return party; - } - - public boolean isInParty(final Player player) { - return get(player) != null; + public Collection getOnlinePlayers(com.alessiodp.parties.api.interfaces.Party party) { + return party.getOnlineMembers().stream().map(partyPlayer -> plugin.getServer().getPlayer(partyPlayer.getPlayerUUID())).collect(Collectors.toList()); } public boolean canDamage(final Player damager, final Player damaged) { - final Party party = get(damager); + final com.alessiodp.parties.api.interfaces.Party party = get(damager); if (party == null || !party.equals(get(damaged))) { return true; } - return party.isFriendlyFire(); - } - - public boolean join(final Player player, final Party party) { - if (party.size() >= config.getPartyMaxSize()) { - return false; - } - - party.add(player); - partyMap.put(player.getUniqueId(), party); - return true; - } - - public void remove(final Player player, final Party party) { - party.remove(player); - partyMap.remove(player.getUniqueId()); - } - - public void remove(final PartyMember member, final Party party) { - party.remove(member); - partyMap.remove(member.getUuid()); - } - - public void remove(final Party party) { - party.setRemoved(true); - party.getMembers().forEach(member -> partyMap.remove(member.getUuid())); - parties.remove(party); + return party.isFriendlyFireProtected(); } @EventHandler @@ -208,18 +72,4 @@ public void on(final EntityDamageByEntityEvent event) { event.setCancelled(true); lang.sendMessage(damager, "ERROR.party.cannot-friendly-fire", "name", damaged.getName()); } - - @EventHandler - public void on(final PlayerQuitEvent event) { - final Player player = event.getPlayer(); - invites.remove(player.getUniqueId()); - - final Party party = get(player); - - if (party == null) { - return; - } - - party.get(player).setLastLogout(); - } } diff --git a/duels-plugin/src/main/java/me/realized/duels/party/PartyMember.java b/duels-plugin/src/main/java/me/realized/duels/party/PartyMember.java deleted file mode 100644 index fced8379..00000000 --- a/duels-plugin/src/main/java/me/realized/duels/party/PartyMember.java +++ /dev/null @@ -1,62 +0,0 @@ -package me.realized.duels.party; - -import java.util.Objects; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import lombok.Getter; - -public class PartyMember { - - @Getter - private final long creation; - - @Getter - private final UUID uuid; - @Getter - private final String name; - @Getter - private final Party party; - - @Getter - private long lastLogout; - - public PartyMember(final Player player, final Party party) { - this.creation = System.currentTimeMillis(); - this.uuid = player.getUniqueId(); - this.name = player.getName(); - this.party = party; - } - - public Player getPlayer() { - return Bukkit.getPlayer(uuid); - } - - public boolean isOnline() { - return getPlayer() != null; - } - - public void setLastLogout() { - lastLogout = System.currentTimeMillis(); - } - - @Override - public boolean equals(final Object other) { - if (this == other) { - return true; - } - - if (other == null || getClass() != other.getClass()) { - return false; - } - - return uuid.equals(((PartyMember) other).uuid); - } - - @Override - public int hashCode() { - return Objects.hash(uuid); - } -} diff --git a/duels-plugin/src/main/java/me/realized/duels/request/RequestImpl.java b/duels-plugin/src/main/java/me/realized/duels/request/RequestImpl.java index 231251ea..f13d5d51 100644 --- a/duels-plugin/src/main/java/me/realized/duels/request/RequestImpl.java +++ b/duels-plugin/src/main/java/me/realized/duels/request/RequestImpl.java @@ -5,7 +5,7 @@ import me.realized.duels.api.arena.Arena; import me.realized.duels.api.kit.Kit; import me.realized.duels.api.request.Request; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.setting.Settings; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; diff --git a/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java b/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java index 03d753bf..7cd05ea9 100644 --- a/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java +++ b/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java @@ -5,11 +5,13 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +import java.util.stream.Collectors; import me.realized.duels.DuelsPlugin; import me.realized.duels.api.event.request.RequestSendEvent; import me.realized.duels.config.Config; import me.realized.duels.config.Lang; +import me.realized.duels.party.PartyManagerImpl; import me.realized.duels.setting.Settings; import me.realized.duels.util.Loadable; import me.realized.duels.util.TextBuilder; @@ -23,13 +25,17 @@ public class RequestManager implements Loadable, Listener { + private final DuelsPlugin plugin; + private final PartyManagerImpl partyManager; private final Config config; private final Lang lang; private final Map> requests = new HashMap<>(); public RequestManager(final DuelsPlugin plugin) { + this.plugin = plugin; this.config = plugin.getConfiguration(); this.lang = plugin.getLang(); + this.partyManager = plugin.getPartyManager(); Bukkit.getPluginManager().registerEvents(this, plugin); } @@ -62,19 +68,19 @@ public void send(final Player sender, final Player target, final Settings settin } final boolean isParty = request.isPartyDuel(); - get(sender, true).put(isParty ? request.getTargetParty().getOwner().getUuid() : target.getUniqueId(), request); + get(sender, true).put(isParty ? request.getTargetParty().getLeader() : target.getUniqueId(), request); final String kit = settings.getKit() != null ? settings.getKit().getName() : lang.getMessage("GENERAL.not-selected"); final String ownInventory = settings.isOwnInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"); final String arena = settings.getArena() != null ? settings.getArena().getName() : lang.getMessage("GENERAL.random"); if (request.isPartyDuel()) { - final Collection senderPartyMembers = request.getSenderParty().getOnlineMembers(); - final Collection targetPartyMembers = request.getTargetParty().getOnlineMembers(); + final Collection senderPartyMembers = partyManager.getOnlinePlayers(request.getSenderParty()); + final Collection targetPartyMembers = partyManager.getOnlinePlayers(request.getTargetParty()); lang.sendMessage(senderPartyMembers, "COMMAND.duel.party-request.send.sender-party", - "owner", sender.getName(), "name", target.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena); + "owner", sender.getName(), "name", target.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena, "party", request.getTargetParty().getName()); lang.sendMessage(targetPartyMembers, "COMMAND.duel.party-request.send.receiver-party", - "name", sender.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena); + "name", sender.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena, "party", request.getSenderParty().getName()); sendClickableMessage("COMMAND.duel.party-request.send.clickable-text.", sender, targetPartyMembers); } else { final int betAmount = settings.getBet(); diff --git a/duels-plugin/src/main/java/me/realized/duels/setting/Settings.java b/duels-plugin/src/main/java/me/realized/duels/setting/Settings.java index 85e0b11f..0cac5ebd 100644 --- a/duels-plugin/src/main/java/me/realized/duels/setting/Settings.java +++ b/duels-plugin/src/main/java/me/realized/duels/setting/Settings.java @@ -9,7 +9,7 @@ import me.realized.duels.arena.ArenaImpl; import me.realized.duels.gui.settings.SettingsGui; import me.realized.duels.kit.KitImpl; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import org.bukkit.Location; import org.bukkit.entity.Player; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/ValidatorManager.java b/duels-plugin/src/main/java/me/realized/duels/validator/ValidatorManager.java index b988a73f..66e35076 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/ValidatorManager.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/ValidatorManager.java @@ -4,13 +4,13 @@ import java.util.HashMap; import java.util.Map; +import com.alessiodp.parties.api.interfaces.Party; import com.google.common.collect.ImmutableList; import org.bukkit.entity.Player; import lombok.Getter; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; import me.realized.duels.setting.Settings; import me.realized.duels.util.Loadable; import me.realized.duels.util.function.Pair; @@ -123,8 +123,8 @@ public void handleLoad() { new BlacklistedWorldValidator(plugin), new CheckMoveValidator(plugin), new CombatTagValidator(plugin), - new DuelZoneValidator(plugin), - new PartyValidator(plugin) + new DuelZoneValidator(plugin) +// new PartyValidator(plugin) ); } diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/match/PartyValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/match/PartyValidator.java index 74f3279d..23fa0df7 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/match/PartyValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/match/PartyValidator.java @@ -20,8 +20,8 @@ public boolean validate(final Collection players, final Settings setting return true; } - int senderPartySize = settings.getSenderParty().size(); - int targetPartySize = settings.getTargetParty().size(); + int senderPartySize = settings.getSenderParty().getMembers().size(); + int targetPartySize = settings.getTargetParty().getMembers().size(); if (config.isPartySameSizeOnly() && senderPartySize != targetPartySize) { lang.sendMessage(players, "DUEL.party-start-failure.is-not-same-size"); diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfBlacklistedWorldValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfBlacklistedWorldValidator.java index ef4d56cb..3983fc3a 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfBlacklistedWorldValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfBlacklistedWorldValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.validator.BaseTriValidator; public class SelfBlacklistedWorldValidator extends BaseTriValidator> { diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckMatchValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckMatchValidator.java index ad4f8c2b..e2ef72e7 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckMatchValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckMatchValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.validator.BaseTriValidator; public class SelfCheckMatchValidator extends BaseTriValidator> { diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckSpectateValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckSpectateValidator.java index 28edfc03..37fafc2c 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckSpectateValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCheckSpectateValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.validator.BaseTriValidator; public class SelfCheckSpectateValidator extends BaseTriValidator> { diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCombatTagValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCombatTagValidator.java index 31eb7301..6eeada72 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCombatTagValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfCombatTagValidator.java @@ -8,7 +8,7 @@ import me.realized.duels.hook.hooks.CombatLogXHook; import me.realized.duels.hook.hooks.CombatTagPlusHook; import me.realized.duels.hook.hooks.PvPManagerHook; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.validator.BaseTriValidator; public class SelfCombatTagValidator extends BaseTriValidator> { diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfDuelZoneValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfDuelZoneValidator.java index 401ff85d..f5107860 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfDuelZoneValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfDuelZoneValidator.java @@ -6,7 +6,7 @@ import me.realized.duels.DuelsPlugin; 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.validator.BaseTriValidator; public class SelfDuelZoneValidator extends BaseTriValidator> { diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfEmptyInventoryValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfEmptyInventoryValidator.java index a9982baf..5d0d620e 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfEmptyInventoryValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfEmptyInventoryValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.inventory.InventoryUtil; import me.realized.duels.validator.BaseTriValidator; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPartyValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPartyValidator.java index 84e2f90f..efaecaa0 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPartyValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPartyValidator.java @@ -1,11 +1,12 @@ package me.realized.duels.validator.validators.request.self; import java.util.Collection; +import java.util.Objects; import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.validator.BaseTriValidator; public class SelfPartyValidator extends BaseTriValidator> { @@ -21,12 +22,12 @@ public boolean validate(final Player sender, final Party party, final Collection return true; } - if (!party.isOwner(sender)) { + if (!Objects.equals(party.getLeader(), sender.getUniqueId())) { lang.sendMessage(sender, "ERROR.party.is-not-owner"); return false; } - if (players.size() != party.size()) { + if (players.size() != party.getMembers().size()) { lang.sendMessage(sender, "ERROR.party.is-not-online.sender"); return false; } diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPreventCreativeValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPreventCreativeValidator.java index 7593980b..e998bb33 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPreventCreativeValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/self/SelfPreventCreativeValidator.java @@ -8,7 +8,7 @@ import me.realized.duels.validator.BaseTriValidator; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; public class SelfPreventCreativeValidator extends BaseTriValidator> { diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCanRequestValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCanRequestValidator.java index 8ebcc315..dd8e4c75 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCanRequestValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCanRequestValidator.java @@ -7,7 +7,7 @@ import me.realized.duels.DuelsPlugin; import me.realized.duels.Permissions; import me.realized.duels.data.UserData; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckMatchValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckMatchValidator.java index 206a602c..923cc42e 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckMatchValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckMatchValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSelfValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSelfValidator.java index 1c69d0a3..fc791f4a 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSelfValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSelfValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSpectateValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSpectateValidator.java index 298f8e25..6a3f6d5b 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSpectateValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetCheckSpectateValidator.java @@ -2,10 +2,10 @@ import java.util.Collection; +import com.alessiodp.parties.api.interfaces.Party; import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; @@ -20,7 +20,7 @@ public TargetCheckSpectateValidator(final DuelsPlugin plugin) { @Override public boolean validate(final Pair pair, final Party party, final Collection players) { - if (players.stream().anyMatch(player -> spectateManager.isSpectating(player))) { + if (players.stream().anyMatch(spectateManager::isSpectating)) { lang.sendMessage(pair.getKey(), party != null ? PARTY_MESSAGE_KEY : MESSAGE_KEY); return false; } diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetHasRequestValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetHasRequestValidator.java index e112fef3..dd4d9a25 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetHasRequestValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetHasRequestValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetNoRequestValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetNoRequestValidator.java index 53434d13..bb455377 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetNoRequestValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetNoRequestValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java index 0712ba3a..e4bc3ce9 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import me.realized.duels.DuelsPlugin; -import me.realized.duels.party.Party; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.util.function.Pair; import me.realized.duels.validator.BaseTriValidator; @@ -39,12 +39,12 @@ public boolean validate(final Pair pair, final Party party, fina return false; } - if (config.isPartySameSizeOnly() && senderParty.size() != party.size()) { + if (config.isPartySameSizeOnly() && senderParty.getMembers().size() != party.getMembers().size()) { lang.sendMessage(pair.getKey(), "ERROR.party.is-not-same-size"); return false; } - if (players.size() != party.size()) { + if (players.size() != party.getMembers().size()) { lang.sendMessage(pair.getKey(), "ERROR.party.is-not-online.target", "name", pair.getValue().getName()); return false; } From ebf208e83e8c011804257df4f5598ace7a0745b1 Mon Sep 17 00:00:00 2001 From: RemainingToast Date: Thu, 13 Oct 2022 17:11:46 +1000 Subject: [PATCH 2/4] new branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd766b26..85a1813b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![](https://jitpack.io/v/Realizedd/Duels.svg)](https://jitpack.io/#Realizedd/Duels) -A duel plugin for spigot. Spigot Project Page +A duel plugin for auscpvp.org. Spigot Project Page --- From 6657b97629a3dc97b9e2f87ab82a393ac2ceefd0 Mon Sep 17 00:00:00 2001 From: RemainingToast Date: Fri, 14 Oct 2022 13:24:16 +1000 Subject: [PATCH 3/4] Update lang to use party name --- .../command/commands/duel/DuelCommand.java | 11 +- .../duel/subcommands/AcceptCommand.java | 37 ++++- .../countdown/party/PartyDuelCountdown.java | 11 +- .../realized/duels/data/UserManagerImpl.java | 4 +- .../buttons/RequestDetailsButton.java | 16 +- .../duels/party/PartyManagerImpl.java | 8 +- .../duels/request/RequestManager.java | 21 ++- .../me/realized/duels/util/TextBuilder.java | 12 +- .../request/target/TargetPartyValidator.java | 10 +- duels-plugin/src/main/resources/lang.yml | 139 +++--------------- duels-plugin/src/main/resources/plugin.yml | 2 +- 11 files changed, 122 insertions(+), 149 deletions(-) diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java index 98b3dfde..e80b23ba 100644 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java +++ b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/DuelCommand.java @@ -80,19 +80,20 @@ protected boolean executeFirst(final CommandSender sender, final String label, f 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 com.alessiodp.parties.api.interfaces.Party targetParty = parties.getApi().getPartyOfPlayer(target.getUniqueId()); final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : partyManager.getOnlinePlayers(targetParty); -// final Party targetParty = partyManager.get(target); -// final Collection targetPlayers = targetParty == null ? Collections.singleton(target) : targetParty.getOnlineMembers(); - if (!ValidatorUtil.validate(validatorManager.getDuelTargetValidators(), new Pair<>(player, target), targetParty, targetPlayers)) { return true; } diff --git a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java index ac78bf46..99f9fb95 100644 --- a/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java +++ b/duels-plugin/src/main/java/me/realized/duels/command/commands/duel/subcommands/AcceptCommand.java @@ -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; @@ -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 senderPartyMembers = partyManager.getOnlinePlayers(request.getSenderParty()); - final Collection targetPartyMembers = partyManager.getOnlinePlayers(request.getTargetParty()); + final Party senderParty = request.getSenderParty(); + final Party targetParty1 = request.getTargetParty(); + + final Collection senderPartyMembers = partyManager.getOnlinePlayers(senderParty); + final Collection 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()) { diff --git a/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java b/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java index 4f376c29..4106b177 100644 --- a/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java +++ b/duels-plugin/src/main/java/me/realized/duels/countdown/party/PartyDuelCountdown.java @@ -28,15 +28,14 @@ public PartyDuelCountdown(final DuelsPlugin plugin, final ArenaImpl arena, final @Override protected void sendMessage(final String rawMessage, final String message, final String title) { final String kitName = match.getKit() != null ? match.getKit().getName() : lang.getMessage("GENERAL.none"); - match.getPlayerToParty().entrySet().forEach(entry -> { - final Player player = entry.getKey(); + match.getPlayerToParty().forEach((player, value) -> { config.playSound(player, rawMessage); player.sendMessage(message - .replace("%opponents%", info.get(arena.getOpponent(entry.getValue()))) - .replace("%kit%", kitName) - .replace("%arena%", arena.getName()) + .replace("%opponents%", info.get(arena.getOpponent(value))) + .replace("%kit%", kitName) + .replace("%arena%", arena.getName()) ); - + if (title != null) { Titles.send(player, title, null, 0, 20, 50); } diff --git a/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java b/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java index dae89836..01af1247 100644 --- a/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java +++ b/duels-plugin/src/main/java/me/realized/duels/data/UserManagerImpl.java @@ -281,8 +281,8 @@ public void handleMatchEnd(final DuelMatch match, final Set winners) { final Party winnerParty = partyMatch.getPlayerToParty().get(winner); final Party loserParty = match.getArena().getOpponent(winnerParty); message = lang.getMessage("DUEL.on-end.party-opponent-defeat", - "winners", StringUtil.join(partyMatch.getNames(winnerParty), ", "), - "losers", StringUtil.join(partyMatch.getNames(loserParty), ", "), + "winner", StringUtil.join(partyMatch.getNames(winnerParty), ", "), + "loser", StringUtil.join(partyMatch.getNames(loserParty), ", "), "kit", kitName, "arena", match.getArena().getName() ); diff --git a/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestDetailsButton.java b/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestDetailsButton.java index 7a90fd22..e4b8ed1e 100644 --- a/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestDetailsButton.java +++ b/duels-plugin/src/main/java/me/realized/duels/gui/settings/buttons/RequestDetailsButton.java @@ -1,13 +1,18 @@ package me.realized.duels.gui.settings.buttons; +import com.alessiodp.parties.api.interfaces.Party; +import com.alessiodp.parties.api.interfaces.PartyPlayer; import me.realized.duels.DuelsPlugin; import me.realized.duels.gui.BaseButton; import me.realized.duels.setting.Settings; +import me.realized.duels.util.StringUtil; import me.realized.duels.util.compat.Items; import me.realized.duels.util.inventory.ItemBuilder; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.util.stream.Collectors; + public class RequestDetailsButton extends BaseButton { public RequestDetailsButton(final DuelsPlugin plugin) { @@ -26,8 +31,17 @@ public void update(final Player player) { return; } + Party targetParty = null; + String opponent = target.getName(); + + if (settings.isPartyDuel()) { + targetParty = plugin.getPartyManager().get(target); + opponent = StringUtil.join(targetParty.getOnlineMembers().stream().map(PartyPlayer::getName).collect(Collectors.toList()), ", "); + } + final String lore = lang.getMessage("GUI.settings.buttons.details.lore", - "opponent", target.getName(), + "opponent", opponent, + "opponent_cmd", targetParty != null ? targetParty.getName() : target.getName(), "kit", settings.getKit() != null ? settings.getKit().getName() : lang.getMessage("GENERAL.not-selected"), "own_inventory", settings.isOwnInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"), "arena", settings.getArena() != null ? settings.getArena().getName() : lang.getMessage("GENERAL.random"), diff --git a/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java b/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java index f7434028..f82d67c1 100644 --- a/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java +++ b/duels-plugin/src/main/java/me/realized/duels/party/PartyManagerImpl.java @@ -1,6 +1,7 @@ package me.realized.duels.party; import com.alessiodp.parties.api.interfaces.PartiesAPI; +import com.alessiodp.parties.api.interfaces.Party; import me.realized.duels.DuelsPlugin; import me.realized.duels.config.Lang; import me.realized.duels.hook.hooks.PartiesHook; @@ -38,7 +39,7 @@ public void handleUnload() { } - public com.alessiodp.parties.api.interfaces.Party get(final Player player) { + public Party get(final Player player) { return partiesAPI.getPartyOfPlayer(player.getUniqueId()); } @@ -47,9 +48,10 @@ public Collection getOnlinePlayers(com.alessiodp.parties.api.interfaces. } public boolean canDamage(final Player damager, final Player damaged) { - final com.alessiodp.parties.api.interfaces.Party party = get(damager); + final Party party = get(damager); + final Party party1 = get(damaged); - if (party == null || !party.equals(get(damaged))) { + if (party == null || !party.equals(party1) || damager == damaged) { return true; } diff --git a/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java b/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java index 7cd05ea9..a928f777 100644 --- a/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java +++ b/duels-plugin/src/main/java/me/realized/duels/request/RequestManager.java @@ -7,6 +7,7 @@ import java.util.UUID; import java.util.stream.Collectors; +import com.alessiodp.parties.api.interfaces.PartyPlayer; import me.realized.duels.DuelsPlugin; import me.realized.duels.api.event.request.RequestSendEvent; import me.realized.duels.config.Config; @@ -14,10 +15,12 @@ import me.realized.duels.party.PartyManagerImpl; import me.realized.duels.setting.Settings; import me.realized.duels.util.Loadable; +import me.realized.duels.util.StringUtil; import me.realized.duels.util.TextBuilder; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.HoverEvent.Action; import org.bukkit.Bukkit; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -74,13 +77,25 @@ public void send(final Player sender, final Player target, final Settings settin final String ownInventory = settings.isOwnInventory() ? lang.getMessage("GENERAL.enabled") : lang.getMessage("GENERAL.disabled"); final String arena = settings.getArena() != null ? settings.getArena().getName() : lang.getMessage("GENERAL.random"); - if (request.isPartyDuel()) { + if (isParty) { final Collection senderPartyMembers = partyManager.getOnlinePlayers(request.getSenderParty()); final Collection targetPartyMembers = partyManager.getOnlinePlayers(request.getTargetParty()); + + lang.sendMessage(senderPartyMembers, "COMMAND.duel.party-request.send.sender-party", - "owner", sender.getName(), "name", target.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena, "party", request.getTargetParty().getName()); + "opponents", StringUtil.join(targetPartyMembers.stream().map(HumanEntity::getName).collect(Collectors.toList()), ", "), + "name", request.getTargetParty().getName(), + "kit", kit, + "own_inventory", ownInventory, + "arena", arena); + lang.sendMessage(targetPartyMembers, "COMMAND.duel.party-request.send.receiver-party", - "name", sender.getName(), "kit", kit, "own_inventory", ownInventory, "arena", arena, "party", request.getSenderParty().getName()); + "opponents", StringUtil.join(senderPartyMembers.stream().map(HumanEntity::getName).collect(Collectors.toList()), ", "), + "name", request.getSenderParty().getName(), + "kit", kit, + "own_inventory", ownInventory, + "arena", arena); + sendClickableMessage("COMMAND.duel.party-request.send.clickable-text.", sender, targetPartyMembers); } else { final int betAmount = settings.getBet(); diff --git a/duels-plugin/src/main/java/me/realized/duels/util/TextBuilder.java b/duels-plugin/src/main/java/me/realized/duels/util/TextBuilder.java index 825bf50f..b052c007 100644 --- a/duels-plugin/src/main/java/me/realized/duels/util/TextBuilder.java +++ b/duels-plugin/src/main/java/me/realized/duels/util/TextBuilder.java @@ -45,7 +45,6 @@ public static TextBuilder of(final String base, public static TextBuilder of(final String base) { return of(base, null, null, null, null); } - public TextBuilder add(final String text) { if (text == null) { return this; @@ -131,4 +130,15 @@ public void send(final Collection players) { public void send(final Player... players) { send(Arrays.asList(players)); } + + @Override + public String toString() { + final BaseComponent[] message = list.toArray(new BaseComponent[0]); + final StringBuilder stringBuilder = new StringBuilder(); + Arrays.stream(message).forEach(baseComponent -> stringBuilder + .append(baseComponent.toLegacyText()) + .append("\n")); + final String s = stringBuilder.toString(); + return s.endsWith("\n") ? s.substring(0, s.length() - 1) : s; + } } diff --git a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java index e4bc3ce9..de498317 100644 --- a/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java +++ b/duels-plugin/src/main/java/me/realized/duels/validator/validators/request/target/TargetPartyValidator.java @@ -29,23 +29,23 @@ public boolean validate(final Pair pair, final Party party, fina } if (senderParty == null) { - lang.sendMessage(pair.getKey(), "ERROR.party.not-in-party.sender", "name", pair.getKey().getName()); + lang.sendMessage(pair.getKey(), "ERROR.party-duel.not-in-party.sender", "name", pair.getKey().getName()); return false; } // If sender is in the same party as target if (senderParty.equals(party)) { - lang.sendMessage(pair.getKey(), "ERROR.party.in-same-party", "name", pair.getValue().getName()); + lang.sendMessage(pair.getKey(), "ERROR.party-duel.in-same-party", "name", pair.getValue().getName()); return false; } if (config.isPartySameSizeOnly() && senderParty.getMembers().size() != party.getMembers().size()) { - lang.sendMessage(pair.getKey(), "ERROR.party.is-not-same-size"); + lang.sendMessage(pair.getKey(), "ERROR.party-duel.is-not-same-size"); return false; } - if (players.size() != party.getMembers().size()) { - lang.sendMessage(pair.getKey(), "ERROR.party.is-not-online.target", "name", pair.getValue().getName()); + if (players.size() != party.getOnlineMembers().size()) { + lang.sendMessage(pair.getKey(), "ERROR.party-duel.is-not-online.target", "name", party.getName()); return false; } diff --git a/duels-plugin/src/main/resources/lang.yml b/duels-plugin/src/main/resources/lang.yml index 80cd38cf..a72073ae 100644 --- a/duels-plugin/src/main/resources/lang.yml +++ b/duels-plugin/src/main/resources/lang.yml @@ -70,40 +70,23 @@ ERROR: in-blacklisted-world: '{PREFIX} &cYou or your party member is in a blacklisted world.' is-tagged: '{PREFIX} &cYou or your party member is currently combat tagged.' not-in-duelzone: '{PREFIX} &cYou or your party member is currently not in one of the following regions: %regions%' - already-has-request: '{PREFIX} &cYou already have a request sent to %name%''s party.' - no-request: '{PREFIX} &cYou do not have a request from %name%''s party.' + already-has-request: '{PREFIX} &cYou already have a request sent to %name%' + no-request: '{PREFIX} &cYou do not have a request from %name%' already-in-match: sender: '{PREFIX} &cYou cannot do this while your party in a duel.' - target: '{PREFIX} &c%name%''s party is already in a duel.' + target: '{PREFIX} &c%name% is already in a duel.' already-spectating: sender: '{PREFIX} &cYou cannot do this while you or your party member is in spectator mode.' - target: '{PREFIX} &cA member of %name%''s party is in spectator mode.' - option-unavailable: '{PREFIX} &cItem/Money Betting is currently not available for party duels.' - party: - is-self: '{PREFIX} &cYou cannot create a party with yourself.' - is-not-owner: '{PREFIX} &cYou must be the owner of this party to do this.' - is-owner: '{PREFIX} &cYou cannot leave this party as you are the owner. You must either transfer the ownership of the party using ''/party transfer'' or disband the party using ''/party disband''.' - requests-disabled: '{PREFIX} &c%name% is currently not accepting party requests.' - already-has-invite: '{PREFIX} &cYou already have a invite sent to %name%.' - no-invite: '{PREFIX} &cYou do not have an invite from %name%.' - not-found: '{PREFIX} &cThat party no longer exists.' - already-in-party: - sender: '{PREFIX} &cYou cannot do this while in a party.' - target: '{PREFIX} &c%name% is already in a party.' + target: '{PREFIX} &cA member of %name% is in spectator mode.' not-in-party: sender: '{PREFIX} &cYou must be in a party to do this.' target: '{PREFIX} &c%name% is not in a party.' - not-a-member: '{PREFIX} &c%name% is not a member of your party.' - in-same-party: '{PREFIX} &c%name% is in your party.' - kick-self: '{PREFIX} &cYou cannot kick yourself from the party.' - is-not-same-size: '{PREFIX} &cParty sizes must match to do this.' is-not-online: sender: '{PREFIX} &cAll members of your party must be online!' - target: '{PREFIX} &cAll members of %name%''s party must be online!' - max-size-reached: - sender: '{PREFIX} &cYour party has reached the maximum number of members!' - target: '{PREFIX} &c%name%''s Party has reached the maximum number of members!' - cannot-friendly-fire: '{PREFIX} &cFriendly fire is not allowed.' + target: '{PREFIX} &cAll members of %name% must be online!' + option-unavailable: '{PREFIX} &cItem/Money Betting is currently not available for party duels.' + in-same-party: '{PREFIX} &c%name% is in your party.' + is-not-same-size: '{PREFIX} &cParty sizes must match to do this.' setting: disabled-option: '{PREFIX} &c%option% is currently disabled.' arena-not-applicable: '{PREFIX} &cYou cannot use kit %kit% on arena %arena%.' @@ -132,7 +115,6 @@ ERROR: lobby-save-failure: '{PREFIX} &cCould not save lobby location. Please check the console for more information.' name-not-alphanumeric: '{PREFIX} &c''%name%'' is not alphanumeric.' - COMMAND: duel: usage: @@ -186,14 +168,16 @@ COMMAND: send: sender-party: - '{LINE}' - - '&f%owner% &7has sent a duel request sent to &f%name%''s Party&7.' + - '&fSent a duel request sent to &f%name%&7.' + - '&6- &7Opponent(s): &3%opponents%' - '&6- &7Kit: &3%kit%' - '&6- &7Own Inventory: &r%own_inventory%' - '&6- &7Arena: &e%arena%' - '{LINE}' receiver-party: - '{LINE}' - - '&7Duel request received from &f%name%''s Party&7.' + - '&7Duel request received from &f%name%&7.' + - '&6- &7Opponent(s): &3%opponents%' - '&6- &7Kit: &3%kit%' - '&6- &7Own Inventory: &r%own_inventory%' - '&6- &7Arena: &e%arena%' @@ -211,22 +195,22 @@ COMMAND: text: '{LINE}' hover-text: '' accept: - sender-party: + sender-party: - '{LINE}' - - '{PREFIX} &f%name%''s Party &7has accepted &f%owner%&7''s duel request.' + - '{PREFIX} &f%name% &7has accepted the duel request.' - '{LINE}' - receiver-party: + receiver-party: - '{LINE}' - - '{PREFIX} &f%owner% &7has accepted the duel request from &f%name%''s Party&7.' + - '{PREFIX} &f%name% &7has accepted the duel request&7.' - '{LINE}' deny: - sender-party: + sender-party: - '{LINE}' - - '{PREFIX} &f%name%''s Party &7has declined &f%owner%&7''s duel request.' + - '{PREFIX} &f%name% &7has declined the duel request.' - '{LINE}' - receiver-party: + receiver-party: - '{LINE}' - - '{PREFIX} &7&f%owner%&7''s has declined the duel request from &f%name%''s Party&7.' + - '{PREFIX} &f%name%&7 has declined the duel request&7.' - '{LINE}' stats: displayed: @@ -365,83 +349,6 @@ COMMAND: - '{LINE}' start-spectate: '{PREFIX} &7Now spectating &f%name%&7 vs &f%opponent%&7 in arena &e%arena%&7. Type &f/spectate &7to stop spectating.' stop-spectate: '{PREFIX} &7You are no longer spectating &f%name%&7.' - - party: - usage: - - '{LINE}' - - '&f/%command% toggle &e- &7Enable or disable receiving party invites.' - - '&f/%command% [player] &e- &7Sends a party invite to a player.' - - '&f/%command% list &e- &7Lists the current party''s members.' - - '&f/%command% accept [player] &e- &7Accepts a party invite.' - - '&f/%command% leave &e- &7Leaves the current party.' - - '&f/%command% kick [player] &e- &7Kicks a player from your party.' - - '&f/%command% friendlyfire &e- &7Enable or disable friendly fire for your party.' - - '&f/%command% transfer [player] &e- &7Transfers the ownership of your party to player.' - - '&f/%command% disband &e- &7Disbands the current party.' - - '{LINE}' - toggle: - enabled: '{PREFIX} &aYou are now receiving party requests.' - disabled: '{PREFIX} &cYou are no longer accepting party requests.' - list: - - '{LINE}' - - '&7Leader: &f%owner%' - - '&7Members (&r%members_count%&7): &r%members%' - - '&7Online (&r%online_count%&7): &r%online_members%' - - '{LINE}' - invite: - send: - receiver: - - '{LINE}' - - '{PREFIX} &7Party invite received from &f%name%&7. Type &f/party accept %name% &7to join the party.' - - '{LINE}' - members: - - '{LINE}' - - '{PREFIX} &f%owner% &7has invited &f%name% &7to the party!' - - '{LINE}' - accept: - receiver: - - '{LINE}' - - '{PREFIX} &7Accepted the party invite from &f%name%&7.' - - '{LINE}' - members: - - '{LINE}' - - '{PREFIX} &f%name% &7has joined the party!' - - '{LINE}' - leave: - sender: - - '{LINE}' - - '{PREFIX} &7You have left &f%name%''s Party&7.' - - '{LINE}' - members: - - '{LINE}' - - '{PREFIX} &f%name% &7has left the party!' - - '{LINE}' - kick: - receiver: - - '{LINE}' - - '{PREFIX} &f%owner% &7has kicked you from the party!' - - '{LINE}' - members: - - '{LINE}' - - '{PREFIX} &f%owner% &7has kicked &f%name% &7from the party!' - - '{LINE}' - friendly-fire: - enabled: - - '{LINE}' - - '{PREFIX} &cFriendly fire &7is now &aenabled&7!' - - '{LINE}' - disabled: - - '{LINE}' - - '{PREFIX} &cFriendly fire &7is now &cdisabled&7!' - - '{LINE}' - transfer: - - '{LINE}' - - '{PREFIX} &f%owner% &7has transferred the party to &f%name%&7.' - - '{LINE}' - disband: - - '{LINE}' - - '{PREFIX} &f%owner% &7has disbanded the party.' - - '{LINE}' sub-command-usage: '{PREFIX} &f/%command% %usage% &e- &7%description%' @@ -483,7 +390,7 @@ DUEL: tie: '{PREFIX} &7Tie Game!' plugin-disable: '{PREFIX} &cPlugin is disabling! Ending match automatically.' opponent-defeat: '{PREFIX} &f%winner% &a(%winner_rating%) (+%change%) &7defeated &f%loser% &c(%loser_rating%) (-%change%) &7with kit &3%kit% &7on arena &e%arena%&7.' - party-opponent-defeat: '{PREFIX} &f%winners% &7defeated &f%losers% &7with kit &3%kit% &7on arena &e%arena%&7.' + party-opponent-defeat: '{PREFIX} &f%winner% &7defeated &f%loser% &7with kit &3%kit% &7on arena &e%arena%&7.' inventories: message: '&7Inventories (click on the name to view): ' name-color: '&b' @@ -533,7 +440,7 @@ GUI: details: name: '&9Request Details' lore: - - '&7Opponent: &f%opponent%' + - '&7Opponent(s): &f%opponent%' - '&7Kit: &3%kit%' - '&7Own Inventory: &r%own_inventory%' - '&7Arena: &e%arena%' @@ -542,7 +449,7 @@ GUI: - ' ' - '&7To change the bet' - '&7amount, please type' - - '&b/duel %opponent% [amount]' + - '&b/duel %opponent_cmd% [amount]' kit-selector: name: '&9Kit Selection' lore: diff --git a/duels-plugin/src/main/resources/plugin.yml b/duels-plugin/src/main/resources/plugin.yml index 6722b3fa..6ad6611a 100644 --- a/duels-plugin/src/main/resources/plugin.yml +++ b/duels-plugin/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: Duels main: me.realized.duels.DuelsPlugin version: @VERSION@ -softdepend: [BountyHunters, CombatLogX, CombatTagPlus, Essentials, Factions, LeaderHeads, mcMMO, MVdWPlaceholderAPI, MyPet, PlaceholderAPI, PvPManager, SimpleClans, Vault, WorldGuard, Multiverse-Core] +softdepend: [BountyHunters, CombatLogX, CombatTagPlus, Essentials, Factions, LeaderHeads, mcMMO, MVdWPlaceholderAPI, MyPet, PlaceholderAPI, PvPManager, SimpleClans, Vault, WorldGuard, Multiverse-Core, Parties] # Multiverse-Core added as soft-depend due to locations being null when Duels is loaded first. # Add any world management plugins to softdepend list if arena doesn't load properly in the generated world. api-version: 1.14 From c01991d227b7ffda9af55fd4d57a2285308daba8 Mon Sep 17 00:00:00 2001 From: RemainingToast Date: Sun, 16 Oct 2022 10:20:12 +1000 Subject: [PATCH 4/4] Fix README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85a1813b..bd766b26 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![](https://jitpack.io/v/Realizedd/Duels.svg)](https://jitpack.io/#Realizedd/Duels) -A duel plugin for auscpvp.org. Spigot Project Page +A duel plugin for spigot. Spigot Project Page ---