mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
parent
c358c8ce0b
commit
3361d28887
@ -1,3 +1,16 @@
|
||||
Version 2.1.229
|
||||
Added new party.yml config, which lets admins disable the party system entirely without having to use permissions
|
||||
Fixed error caused by missing API in McMMOEntityDamageByRuptureEvent
|
||||
(API) Major API changes to PartyManager
|
||||
(API) PartyManager is no longer a static singleton class, use mcMMO.getPartyManager() to get the PartyManager
|
||||
(API) Added com.gmail.nossr50.mcMMO.isPartySystemEnabled to check if the party system is enabled
|
||||
(API) Added com.gmail.nossr50.api.PartyAPI.isPartySystemEnabled as an alternative, to check if the party system is enabled
|
||||
(API) Added missing com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent.getHandlerList
|
||||
|
||||
NOTES:
|
||||
Admins can now enable/disable the whole party system with a setting in the new party.yml config
|
||||
You'll have to start your server one time to generate the config, then change the setting and reboot your server.
|
||||
|
||||
Version 2.1.228
|
||||
Fixed a stack trace due to Spigot API break on EntityDamageEvent and EntityDamageByEntity event
|
||||
(API) - Removed FakeEntityDamageEvent and FakeEntityDamageByEntityEvent
|
||||
|
8
pom.xml
8
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.229-SNAPSHOT</version>
|
||||
<version>2.1.229</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
@ -14,9 +14,9 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
<maven.compiler.target>16</maven.compiler.target>
|
||||
<java.version>16</java.version>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<issueManagement>
|
||||
|
@ -3,12 +3,15 @@ package com.gmail.nossr50.api;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyLeader;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import jdk.jfr.Experimental;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -24,13 +27,22 @@ public final class PartyAPI {
|
||||
* @return the name of the player's party, or null if not in a party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
if (!inParty(player)) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || !inParty(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return UserManager.getPlayer(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the party system is enabled.
|
||||
*
|
||||
* @return true if the party system is enabled, false otherwise
|
||||
*/
|
||||
public static boolean isPartySystemEnabled() {
|
||||
return mcMMO.p.getPartyConfig().isPartyEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is in a party.
|
||||
* </br>
|
||||
@ -40,7 +52,7 @@ public final class PartyAPI {
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
|
||||
return false;
|
||||
|
||||
return UserManager.getPlayer(player).inParty();
|
||||
@ -51,12 +63,15 @@ public final class PartyAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
* @param playerA The first player to check
|
||||
* @param playerB The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.inSameParty(playera, playerb);
|
||||
public static boolean inSameParty(Player playerA, Player playerB) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return false;
|
||||
|
||||
return mcMMO.p.getPartyManager().inSameParty(playerA, playerB);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +82,7 @@ public final class PartyAPI {
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getParties();
|
||||
return mcMMO.p.getPartyManager().getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,23 +96,29 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mmoPlayer == null)
|
||||
return;
|
||||
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
Party party = mcMMO.p.getPartyManager().getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
} else {
|
||||
if(PartyManager.isPartyFull(player, party))
|
||||
if(mcMMO.p.getPartyManager().isPartyFull(player, party))
|
||||
{
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PartyManager.addToParty(UserManager.getPlayer(player), party);
|
||||
mcMMO.p.getPartyManager().addToParty(mmoPlayer, party);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,19 +140,18 @@ public final class PartyAPI {
|
||||
* @param partyName The party to add the player to
|
||||
* @param bypassLimit if true bypasses party size limits
|
||||
*/
|
||||
//TODO: bypasslimit not used?
|
||||
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
Party party = mcMMO.p.getPartyManager().getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
}
|
||||
|
||||
PartyManager.addToParty(UserManager.getPlayer(player), party);
|
||||
mcMMO.p.getPartyManager().addToParty(UserManager.getPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,10 +163,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
PartyManager.removeFromParty(UserManager.getPlayer(player));
|
||||
mcMMO.p.getPartyManager().removeFromParty(UserManager.getPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,8 +177,11 @@ public final class PartyAPI {
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getPartyLeaderName(partyName);
|
||||
public static @Nullable String getPartyLeader(String partyName) {
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return mcMMO.p.getPartyManager().getPartyLeaderName(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,7 +194,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setPartyLeader(String partyName, String playerName) {
|
||||
PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName));
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return;
|
||||
|
||||
mcMMO.p.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.p.getPartyManager().getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,9 +210,12 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
List<OfflinePlayer> members = new ArrayList<>();
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
|
||||
List<OfflinePlayer> members = new ArrayList<>();
|
||||
for (UUID memberUniqueId : mcMMO.p.getPartyManager().getAllMembers(player).keySet()) {
|
||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
|
||||
members.add(member);
|
||||
}
|
||||
@ -203,7 +232,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static LinkedHashSet<String> getMembers(Player player) {
|
||||
return (LinkedHashSet<String>) PartyManager.getAllMembers(player).values();
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return (LinkedHashSet<String>) mcMMO.p.getPartyManager().getAllMembers(player).values();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +247,10 @@ public final class PartyAPI {
|
||||
* @return all the player names and uuids in the player's party
|
||||
*/
|
||||
public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
|
||||
return PartyManager.getAllMembers(player);
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return mcMMO.p.getPartyManager().getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +262,10 @@ public final class PartyAPI {
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getOnlineMembers(partyName);
|
||||
if(!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return mcMMO.p.getPartyManager().getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,7 +277,7 @@ public final class PartyAPI {
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getOnlineMembers(player);
|
||||
return mcMMO.p.getPartyManager().getOnlineMembers(player);
|
||||
}
|
||||
|
||||
public static boolean hasAlly(String partyName) {
|
||||
@ -247,7 +285,7 @@ public final class PartyAPI {
|
||||
}
|
||||
|
||||
public static String getAllyName(String partyName) {
|
||||
Party ally = PartyManager.getParty(partyName).getAlly();
|
||||
Party ally = mcMMO.p.getPartyManager().getParty(partyName).getAlly();
|
||||
if (ally != null) {
|
||||
return ally.getName();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class CommandManager {
|
||||
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.ADMIN)) {
|
||||
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef));
|
||||
}
|
||||
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
|
||||
if(pluginRef.getPartyConfig().isPartyEnabled() && ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
|
||||
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef));
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class CommandManager {
|
||||
public void validatePlayerParty(@NotNull Player player) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mmoPlayer.getParty() == null) {
|
||||
if(!pluginRef.getPartyConfig().isPartyEnabled() || mmoPlayer.getParty() == null) {
|
||||
throw new ConditionFailedException(LocaleLoader.getString("Commands.Party.None"));
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class PartyChatCommand extends BaseCommand {
|
||||
mcMMO.p.getLogger().severe("You need to specify a party name and then write a message afterwards.");
|
||||
} else {
|
||||
//Grab party
|
||||
Party targetParty = PartyManager.getParty(args[0]);
|
||||
Party targetParty = mcMMO.p.getPartyManager().getParty(args[0]);
|
||||
|
||||
if(targetParty != null) {
|
||||
pluginRef.getChatManager().processConsoleMessage(StringUtils.buildStringAfterNthElement(args, 1), targetParty);
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -31,11 +32,11 @@ public class PartyAcceptCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.joinInvitedParty(mcMMOPlayer);
|
||||
mcMMO.p.getPartyManager().joinInvitedParty(mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
|
||||
|
@ -31,7 +31,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.setPartyLeader(target.getUniqueId(), playerParty);
|
||||
mcMMO.p.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
|
@ -23,11 +23,45 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PartyCommand implements TabExecutor {
|
||||
private static final List<String> PARTY_SUBCOMMANDS;
|
||||
private static final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
|
||||
private final List<String> PARTY_SUBCOMMANDS;
|
||||
private final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
|
||||
private final CommandExecutor partyJoinCommand;
|
||||
private final CommandExecutor partyAcceptCommand;
|
||||
private final CommandExecutor partyCreateCommand;
|
||||
private final CommandExecutor partyQuitCommand;
|
||||
private final CommandExecutor partyXpShareCommand;
|
||||
private final CommandExecutor partyItemShareCommand;
|
||||
private final CommandExecutor partyInviteCommand;
|
||||
private final CommandExecutor partyKickCommand;
|
||||
private final CommandExecutor partyDisbandCommand;
|
||||
private final CommandExecutor partyChangeOwnerCommand;
|
||||
private final CommandExecutor partyLockCommand;
|
||||
private final CommandExecutor partyChangePasswordCommand;
|
||||
private final CommandExecutor partyRenameCommand;
|
||||
private final CommandExecutor partyInfoCommand;
|
||||
private final CommandExecutor partyHelpCommand;
|
||||
private final CommandExecutor partyTeleportCommand;
|
||||
private final CommandExecutor partyAllianceCommand;
|
||||
public PartyCommand() {
|
||||
partyJoinCommand = new PartyJoinCommand();
|
||||
partyAcceptCommand = new PartyAcceptCommand();
|
||||
partyCreateCommand = new PartyCreateCommand();
|
||||
partyQuitCommand = new PartyQuitCommand();
|
||||
partyXpShareCommand = new PartyXpShareCommand();
|
||||
partyItemShareCommand = new PartyItemShareCommand();
|
||||
partyInviteCommand = new PartyInviteCommand();
|
||||
partyKickCommand = new PartyKickCommand();
|
||||
partyDisbandCommand = new PartyDisbandCommand();
|
||||
partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
partyLockCommand = new PartyLockCommand();
|
||||
partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
partyRenameCommand = new PartyRenameCommand();
|
||||
partyInfoCommand = new PartyInfoCommand();
|
||||
partyHelpCommand = new PartyHelpCommand();
|
||||
partyTeleportCommand = new PtpCommand();
|
||||
partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
@ -38,24 +72,6 @@ public class PartyCommand implements TabExecutor {
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private final CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private final CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
private final CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||
private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
|
||||
private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private final CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private final CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
private final CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||
private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
private final CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private final CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private final CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private final CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||
private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@ -73,13 +89,13 @@ public class PartyCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
if(mcMMOPlayer == null)
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (args.length < 1) {
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
@ -140,31 +156,18 @@ public class PartyCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case XPSHARE:
|
||||
return partyXpShareCommand.onCommand(sender, command, label, args);
|
||||
case ITEMSHARE:
|
||||
return partyItemShareCommand.onCommand(sender, command, label, args);
|
||||
case KICK:
|
||||
return partyKickCommand.onCommand(sender, command, label, args);
|
||||
case DISBAND:
|
||||
return partyDisbandCommand.onCommand(sender, command, label, args);
|
||||
case OWNER:
|
||||
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||
case LOCK:
|
||||
case UNLOCK:
|
||||
return partyLockCommand.onCommand(sender, command, label, args);
|
||||
case PASSWORD:
|
||||
return partyChangePasswordCommand.onCommand(sender, command, label, args);
|
||||
case RENAME:
|
||||
return partyRenameCommand.onCommand(sender, command, label, args);
|
||||
case ALLIANCE:
|
||||
return partyAllianceCommand.onCommand(sender, command, label, args);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return switch (subcommand) {
|
||||
case XPSHARE -> partyXpShareCommand.onCommand(sender, command, label, args);
|
||||
case ITEMSHARE -> partyItemShareCommand.onCommand(sender, command, label, args);
|
||||
case KICK -> partyKickCommand.onCommand(sender, command, label, args);
|
||||
case DISBAND -> partyDisbandCommand.onCommand(sender, command, label, args);
|
||||
case OWNER -> partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||
case LOCK, UNLOCK -> partyLockCommand.onCommand(sender, command, label, args);
|
||||
case PASSWORD -> partyChangePasswordCommand.onCommand(sender, command, label, args);
|
||||
case RENAME -> partyRenameCommand.onCommand(sender, command, label, args);
|
||||
case ALLIANCE -> partyAllianceCommand.onCommand(sender, command, label, args);
|
||||
default -> true;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,12 +182,13 @@ public class PartyCommand implements TabExecutor {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
|
||||
switch (subcommand) {
|
||||
case JOIN:
|
||||
case INVITE:
|
||||
case KICK:
|
||||
case OWNER:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
|
||||
case XPSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size()));
|
||||
@ -198,7 +202,7 @@ public class PartyCommand implements TabExecutor {
|
||||
case TELEPORT:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
if (matches.isEmpty()) {
|
||||
Player player = (Player) sender;
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -26,16 +27,16 @@ public class PartyCreateCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
// Check to see if the party exists, and if it does cancel creating a new party
|
||||
if (PartyManager.checkPartyExistence(player, args[1])) {
|
||||
if (mcMMO.p.getPartyManager().checkPartyExistence(player, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
|
||||
mcMMO.p.getPartyManager().createParty(mcMMOPlayer, args[1], getPassword(args));
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -26,14 +27,14 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
final String partyName = playerParty.getName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(mcMMOPlayer, playerParty);
|
||||
mcMMO.p.getPartyManager().disbandParty(mcMMOPlayer, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||
|
@ -125,7 +125,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
* Only show members of the party that this member can see
|
||||
*/
|
||||
|
||||
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
|
||||
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearVisibleMembers(mcMMOPlayer);
|
||||
int membersOnline = party.getVisibleMembers(player).size();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||
|
@ -40,19 +40,19 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
if (mcMMO.p.getPartyManager().inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PartyManager.canInvite(mcMMOPlayer)) {
|
||||
if (!mcMMO.p.getPartyManager().canInvite(mcMMOPlayer)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (PartyManager.isPartyFull(target, playerParty)) {
|
||||
if (mcMMO.p.getPartyManager().isPartyFull(target, playerParty)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), mcMMO.p.getGeneralConfig().getPartyMaxSize()));
|
||||
return true;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -51,25 +52,25 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
String password = getPassword(args);
|
||||
|
||||
// Make sure party passwords match
|
||||
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
||||
if (!mcMMO.p.getPartyManager().checkPartyPassword(player, targetParty, password)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyName = targetParty.getName();
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(PartyManager.isPartyFull(player, targetParty))
|
||||
if(mcMMO.p.getPartyManager().isPartyFull(player, targetParty))
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
|
||||
PartyManager.addToParty(mcMMOPlayer, targetParty);
|
||||
mcMMO.p.getPartyManager().addToParty(mcMMOPlayer, targetParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -37,15 +37,15 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
Player onlineTarget = target.getPlayer();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||
mcMMO.p.getPartyManager().processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(target, playerParty);
|
||||
mcMMO.p.getPartyManager().removeFromParty(target, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -26,11 +27,11 @@ public class PartyQuitCommand implements CommandExecutor {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(mcMMOPlayer);
|
||||
mcMMO.p.getPartyManager().removeFromParty(mcMMOPlayer);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
return true;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -36,14 +37,14 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check to see if the party exists, and if it does cancel renaming the party
|
||||
if (PartyManager.checkPartyExistence(player, newPartyName)) {
|
||||
if (mcMMO.p.getPartyManager().checkPartyExistence(player, newPartyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String leaderName = playerParty.getLeader().getPlayerName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -31,7 +32,7 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.acceptAllianceInvite(mcMMOPlayer);
|
||||
mcMMO.p.getPartyManager().acceptAllianceInvite(mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
|
||||
|
@ -129,7 +129,7 @@ public class PartyAllianceCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
|
||||
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearMembers(mcMMOPlayer);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
|
||||
player.sendMessage(playerParty.createMembersList(player));
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@ -28,7 +29,7 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.disbandAlliance(player, party, party.getAlly());
|
||||
mcMMO.p.getPartyManager().disbandAlliance(player, party, party.getAlly());
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -44,7 +45,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
if (mcMMO.p.getPartyManager().inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public class PtpCommand implements TabExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PartyManager.inSameParty(player, target)) {
|
||||
if (!mcMMO.p.getPartyManager().inSameParty(player, target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||
return false;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PartyConfig extends BukkitConfig {
|
||||
public PartyConfig(File dataFolder) {
|
||||
super("party.yml", dataFolder);
|
||||
validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isPartyEnabled() {
|
||||
return config.getBoolean("Party.Enabled", true);
|
||||
}
|
||||
}
|
@ -253,7 +253,7 @@ public class Party {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
mcMMO.p.getPartyManager().informPartyMembersLevelUp(this, levelsGained, getLevel());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
@ -642,11 +643,11 @@ public class McMMOPlayer implements Identified {
|
||||
|
||||
applyXpGain(skill, modifyXpGain(skill, xp), xpGainReason, xpGainSource);
|
||||
|
||||
if (party == null || party.hasReachedLevelCap()) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || party == null || party.hasReachedLevelCap()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mcMMO.p.getGeneralConfig().getPartyXpNearMembersNeeded() || !PartyManager.getNearMembers(this).isEmpty()) {
|
||||
if (!mcMMO.p.getGeneralConfig().getPartyXpNearMembersNeeded() || !mcMMO.p.getPartyManager().getNearMembers(this).isEmpty()) {
|
||||
party.applyXpGain(modifyXpGain(skill, xp));
|
||||
}
|
||||
}
|
||||
@ -746,11 +747,13 @@ public class McMMOPlayer implements Identified {
|
||||
*/
|
||||
|
||||
public void setupPartyData() {
|
||||
party = PartyManager.getPlayerParty(player.getName(), player.getUniqueId());
|
||||
ptpRecord = new PartyTeleportRecord();
|
||||
if (mcMMO.p.isPartySystemEnabled()) {
|
||||
party = mcMMO.p.getPartyManager().getPlayerParty(player.getName(), player.getUniqueId());
|
||||
ptpRecord = new PartyTeleportRecord();
|
||||
|
||||
if (inParty()) {
|
||||
loginParty();
|
||||
if (inParty()) {
|
||||
loginParty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -770,7 +773,7 @@ public class McMMOPlayer implements Identified {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
public @Nullable Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
@ -786,7 +789,7 @@ public class McMMOPlayer implements Identified {
|
||||
invite = null;
|
||||
}
|
||||
|
||||
public PartyTeleportRecord getPartyTeleportRecord() {
|
||||
public @Nullable PartyTeleportRecord getPartyTeleportRecord() {
|
||||
return ptpRecord;
|
||||
}
|
||||
|
||||
|
@ -495,8 +495,8 @@ public class EntityListener implements Listener {
|
||||
|
||||
//Party Friendly Fire
|
||||
if(!mcMMO.p.getGeneralConfig().getPartyFriendlyFire())
|
||||
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer)
|
||||
|| PartyManager.areAllies(defendingPlayer, attackingPlayer))
|
||||
if ((mcMMO.p.getPartyManager().inSameParty(defendingPlayer, attackingPlayer)
|
||||
|| mcMMO.p.getPartyManager().areAllies(defendingPlayer, attackingPlayer))
|
||||
&& !(Permissions.friendlyFire(attackingPlayer)
|
||||
&& Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
|
@ -8,6 +8,7 @@ import com.gmail.nossr50.config.mods.ArmorConfigManager;
|
||||
import com.gmail.nossr50.config.mods.BlockConfigManager;
|
||||
import com.gmail.nossr50.config.mods.EntityConfigManager;
|
||||
import com.gmail.nossr50.config.mods.ToolConfigManager;
|
||||
import com.gmail.nossr50.config.party.PartyConfig;
|
||||
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
|
||||
@ -139,8 +140,10 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
private GeneralConfig generalConfig;
|
||||
private AdvancedConfig advancedConfig;
|
||||
private PartyConfig partyConfig;
|
||||
|
||||
private FoliaLib foliaLib;
|
||||
private PartyManager partyManager;
|
||||
|
||||
// private RepairConfig repairConfig;
|
||||
// private SalvageConfig salvageConfig;
|
||||
@ -182,6 +185,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Init configs
|
||||
advancedConfig = new AdvancedConfig(getDataFolder());
|
||||
partyConfig = new PartyConfig(getDataFolder());
|
||||
|
||||
//Store this value so other plugins can check it
|
||||
isRetroModeEnabled = generalConfig.getIsRetroMode();
|
||||
@ -259,7 +263,10 @@ public class mcMMO extends JavaPlugin {
|
||||
registerCoreSkills();
|
||||
registerCustomRecipes();
|
||||
|
||||
PartyManager.loadParties();
|
||||
if (partyConfig.isPartyEnabled()) {
|
||||
partyManager = new PartyManager(this);
|
||||
partyManager.loadParties();
|
||||
}
|
||||
|
||||
formulaManager = new FormulaManager();
|
||||
|
||||
@ -377,7 +384,7 @@ public class mcMMO extends JavaPlugin {
|
||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||
UserManager.clearAll();
|
||||
Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
|
||||
PartyManager.saveParties(); // Save our parties
|
||||
getPartyManager().saveParties(); // Save our parties
|
||||
|
||||
//TODO: Needed?
|
||||
if(generalConfig.getScoreboardsEnabled())
|
||||
@ -783,6 +790,23 @@ public class mcMMO extends JavaPlugin {
|
||||
return advancedConfig;
|
||||
}
|
||||
|
||||
public @NotNull PartyConfig getPartyConfig() {
|
||||
return partyConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the party system is enabled
|
||||
*
|
||||
* @return true if the party system is enabled, false otherwise
|
||||
*/
|
||||
public boolean isPartySystemEnabled() {
|
||||
return partyConfig.isPartyEnabled();
|
||||
}
|
||||
|
||||
public PartyManager getPartyManager() {
|
||||
return partyManager;
|
||||
}
|
||||
|
||||
public @NotNull FoliaLib getFoliaLib() {
|
||||
return foliaLib;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -31,104 +33,44 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public final class PartyManager {
|
||||
private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||
private static final List<Party> parties = new ArrayList<>();
|
||||
private static final File partyFile = new File(partiesFilePath);
|
||||
private final @NotNull List<Party> parties;
|
||||
private final @NotNull File partyFile;
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
private PartyManager() {}
|
||||
|
||||
/**
|
||||
* Check if a party with a given name already exists.
|
||||
*
|
||||
* @param player The player to notify
|
||||
* @param partyName The name of the party to check
|
||||
* @return true if a party with that name exists, false otherwise
|
||||
*/
|
||||
public static boolean checkPartyExistence(Player player, String partyName) {
|
||||
if (getParty(partyName) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", partyName));
|
||||
return true;
|
||||
public PartyManager(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||
this.partyFile = new File(partiesFilePath);
|
||||
this.parties = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player can join a party, parties can have a size limit, although there is a permission to bypass this
|
||||
* @param player player who is attempting to join the party
|
||||
*
|
||||
* @param player player who is attempting to join the party
|
||||
* @param targetParty the target party
|
||||
* @return true if party is full and cannot be joined
|
||||
*/
|
||||
public static boolean isPartyFull(Player player, Party targetParty)
|
||||
{
|
||||
return !Permissions.partySizeBypass(player) && mcMMO.p.getGeneralConfig().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= mcMMO.p.getGeneralConfig().getPartyMaxSize();
|
||||
public boolean isPartyFull(@NotNull Player player, @NotNull Party targetParty) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
requireNonNull(targetParty, "targetParty cannot be null!");
|
||||
return !Permissions.partySizeBypass(player) && pluginRef.getGeneralConfig().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= pluginRef.getGeneralConfig().getPartyMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to change parties or join a new party.
|
||||
*
|
||||
* @param mcMMOPlayer The player changing or joining parties
|
||||
* @param newPartyName The name of the party being joined
|
||||
* @return true if the party was joined successfully, false otherwise
|
||||
*/
|
||||
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
public boolean areAllies(@NotNull Player firstPlayer, @NotNull Player secondPlayer) {
|
||||
requireNonNull(firstPlayer, "firstPlayer cannot be null!");
|
||||
requireNonNull(secondPlayer, "secondPlayer cannot be null!");
|
||||
|
||||
if (mcMMOPlayer.inParty()) {
|
||||
Party oldParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
removeFromParty(mcMMOPlayer);
|
||||
}
|
||||
else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two online players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(firstPlayer) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(firstPlayer) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(secondPlayer) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
|
||||
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return firstParty.equals(secondParty);
|
||||
}
|
||||
|
||||
public static boolean areAllies(Player firstPlayer, Player secondPlayer) {
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(firstPlayer) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(secondPlayer) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(secondPlayer) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -145,16 +87,17 @@ public final class PartyManager {
|
||||
/**
|
||||
* Get the near party members.
|
||||
*
|
||||
* @param mcMMOPlayer The player to check
|
||||
* @param mmoPlayer The player to check
|
||||
* @return the near party members
|
||||
*/
|
||||
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
|
||||
public @NotNull List<Player> getNearMembers(@NotNull McMMOPlayer mmoPlayer) {
|
||||
requireNonNull(mmoPlayer, "mmoPlayer cannot be null!");
|
||||
List<Player> nearMembers = new ArrayList<>();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
double range = mcMMO.p.getGeneralConfig().getPartyShareRange();
|
||||
Player player = mmoPlayer.getPlayer();
|
||||
double range = pluginRef.getGeneralConfig().getPartyShareRange();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
@ -166,13 +109,14 @@ public final class PartyManager {
|
||||
return nearMembers;
|
||||
}
|
||||
|
||||
public static List<Player> getNearVisibleMembers(McMMOPlayer mcMMOPlayer) {
|
||||
public @NotNull List<Player> getNearVisibleMembers(@NotNull McMMOPlayer mmoPlayer) {
|
||||
requireNonNull(mmoPlayer, "mmoPlayer cannot be null!");
|
||||
List<Player> nearMembers = new ArrayList<>();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
double range = mcMMO.p.getGeneralConfig().getPartyShareRange();
|
||||
Player player = mmoPlayer.getPlayer();
|
||||
double range = pluginRef.getGeneralConfig().getPartyShareRange();
|
||||
|
||||
for (Player member : party.getVisibleMembers(player)) {
|
||||
if (!player.equals(member)
|
||||
@ -186,14 +130,14 @@ public final class PartyManager {
|
||||
return nearMembers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static LinkedHashMap<UUID, String> getAllMembers(Player player) {
|
||||
public @NotNull LinkedHashMap<UUID, String> getAllMembers(@NotNull Player player) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
Party party = getParty(player);
|
||||
|
||||
return party == null ? new LinkedHashMap<>() : party.getMembers();
|
||||
@ -205,7 +149,8 @@ public final class PartyManager {
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
public @NotNull List<Player> getOnlineMembers(@NotNull String partyName) {
|
||||
requireNonNull(partyName, "partyName cannot be null!");
|
||||
return getOnlineMembers(getParty(partyName));
|
||||
}
|
||||
|
||||
@ -215,11 +160,12 @@ public final class PartyManager {
|
||||
* @param player The player to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
public @NotNull List<Player> getOnlineMembers(@NotNull Player player) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
return getOnlineMembers(getParty(player));
|
||||
}
|
||||
|
||||
private static List<Player> getOnlineMembers(Party party) {
|
||||
private List<Player> getOnlineMembers(@Nullable Party party) {
|
||||
return party == null ? new ArrayList<>() : party.getOnlineMembers();
|
||||
}
|
||||
|
||||
@ -229,7 +175,8 @@ public final class PartyManager {
|
||||
* @param partyName The party name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getParty(String partyName) {
|
||||
public @Nullable Party getParty(@NotNull String partyName) {
|
||||
requireNonNull(partyName, "partyName cannot be null!");
|
||||
for (Party party : parties) {
|
||||
if (party.getName().equalsIgnoreCase(partyName)) {
|
||||
return party;
|
||||
@ -246,9 +193,10 @@ public final class PartyManager {
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public static Party getPlayerParty(String playerName) {
|
||||
public @Nullable Party getPlayerParty(@NotNull String playerName) {
|
||||
requireNonNull(playerName, "playerName cannot be null!");
|
||||
for (Party party : parties) {
|
||||
if (party.getMembers().containsKey(playerName)) {
|
||||
if (party.getMembers().containsValue(playerName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
@ -262,7 +210,9 @@ public final class PartyManager {
|
||||
* @param uuid The members uuid
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getPlayerParty(String playerName, UUID uuid) {
|
||||
public @Nullable Party getPlayerParty(@NotNull String playerName, @NotNull UUID uuid) {
|
||||
requireNonNull(playerName, "playerName cannot be null!");
|
||||
requireNonNull(uuid, "uuid cannot be null!");
|
||||
for (Party party : parties) {
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
if (members.containsKey(uuid) || members.containsValue(playerName)) {
|
||||
@ -285,16 +235,18 @@ public final class PartyManager {
|
||||
* @param player The member
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public static Party getParty(Player player) {
|
||||
public @Nullable Party getParty(@NotNull Player player) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(player) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
if(mmoPlayer == null)
|
||||
return null;
|
||||
|
||||
return mcMMOPlayer.getParty();
|
||||
return mmoPlayer.getParty();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,7 +254,7 @@ public final class PartyManager {
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
public @NotNull List<Party> getParties() {
|
||||
return parties;
|
||||
}
|
||||
|
||||
@ -310,9 +262,12 @@ public final class PartyManager {
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param player The player to remove
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void removeFromParty(OfflinePlayer player, Party party) {
|
||||
public void removeFromParty(@NotNull OfflinePlayer player, @NotNull Party party) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
requireNonNull(party, "party cannot be null!");
|
||||
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
String playerName = player.getName();
|
||||
|
||||
@ -324,8 +279,7 @@ public final class PartyManager {
|
||||
|
||||
if (members.isEmpty()) {
|
||||
parties.remove(party);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// If the leaving player was the party leader, appoint a new leader from the party members
|
||||
if (party.getLeader().getUniqueId().equals(player.getUniqueId())) {
|
||||
setPartyLeader(members.keySet().iterator().next(), party);
|
||||
@ -340,7 +294,12 @@ public final class PartyManager {
|
||||
*
|
||||
* @param mcMMOPlayer The player to remove
|
||||
*/
|
||||
public static void removeFromParty(McMMOPlayer mcMMOPlayer) {
|
||||
public void removeFromParty(@NotNull McMMOPlayer mcMMOPlayer) {
|
||||
requireNonNull(mcMMOPlayer, "mcMMOPlayer cannot be null!");
|
||||
if (mcMMOPlayer.getParty() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeFromParty(mcMMOPlayer.getPlayer(), mcMMOPlayer.getParty());
|
||||
processPartyLeaving(mcMMOPlayer);
|
||||
}
|
||||
@ -351,21 +310,23 @@ public final class PartyManager {
|
||||
* @param party The party to remove
|
||||
* @deprecated Use {@link #disbandParty(McMMOPlayer, Party)}
|
||||
*/
|
||||
public static void disbandParty(Party party) {
|
||||
public void disbandParty(@NotNull Party party) {
|
||||
requireNonNull(party, "party cannot be null!");
|
||||
disbandParty(null, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param mcMMOPlayer The player to remove (can be null? lol)
|
||||
* @param party The party to remove
|
||||
*/
|
||||
public static void disbandParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||
public void disbandParty(@Nullable McMMOPlayer mcMMOPlayer, @NotNull Party party) {
|
||||
requireNonNull(party, "party cannot be null!");
|
||||
//TODO: Potential issues with unloaded profile?
|
||||
for (final Player member : party.getOnlineMembers()) {
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(member) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(member) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -387,10 +348,14 @@ public final class PartyManager {
|
||||
* Create a new party
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
*/
|
||||
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||
public void createParty(@NotNull McMMOPlayer mcMMOPlayer, @NotNull String partyName, @Nullable String password) {
|
||||
requireNonNull(mcMMOPlayer, "mcMMOPlayer cannot be null!");
|
||||
requireNonNull(partyName, "partyName cannot be null!");
|
||||
requireNonNull(password, "password cannot be null!");
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password);
|
||||
@ -409,12 +374,12 @@ public final class PartyManager {
|
||||
/**
|
||||
* Check if a player can join a party
|
||||
*
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param password The password provided by the player
|
||||
* @return true if the player can join the party
|
||||
*/
|
||||
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
||||
public boolean checkPartyPassword(@NotNull Player player, @NotNull Party party, @Nullable String password) {
|
||||
if (party.isLocked()) {
|
||||
String partyPassword = party.getPassword();
|
||||
|
||||
@ -442,7 +407,8 @@ public final class PartyManager {
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
*/
|
||||
public static void joinInvitedParty(McMMOPlayer mcMMOPlayer) {
|
||||
public void joinInvitedParty(@NotNull McMMOPlayer mcMMOPlayer) {
|
||||
requireNonNull(mcMMOPlayer, "mcMMOPlayer cannot be null!");
|
||||
Party invite = mcMMOPlayer.getPartyInvite();
|
||||
|
||||
// Check if the party still exists, it might have been disbanded
|
||||
@ -454,9 +420,8 @@ public final class PartyManager {
|
||||
/*
|
||||
* Don't let players join a full party
|
||||
*/
|
||||
if(mcMMO.p.getGeneralConfig().getPartyMaxSize() > 0 && invite.getMembers().size() >= mcMMO.p.getGeneralConfig().getPartyMaxSize())
|
||||
{
|
||||
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getName(), String.valueOf(mcMMO.p.getGeneralConfig().getPartyMaxSize()));
|
||||
if (pluginRef.getGeneralConfig().getPartyMaxSize() > 0 && invite.getMembers().size() >= pluginRef.getGeneralConfig().getPartyMaxSize()) {
|
||||
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getName(), String.valueOf(pluginRef.getGeneralConfig().getPartyMaxSize()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -470,7 +435,8 @@ public final class PartyManager {
|
||||
*
|
||||
* @param mcMMOPlayer The player who accepts the alliance invite
|
||||
*/
|
||||
public static void acceptAllianceInvite(McMMOPlayer mcMMOPlayer) {
|
||||
public void acceptAllianceInvite(@NotNull McMMOPlayer mcMMOPlayer) {
|
||||
requireNonNull(mcMMOPlayer, "mcMMOPlayer cannot be null!");
|
||||
Party invite = mcMMOPlayer.getPartyAllianceInvite();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
@ -490,7 +456,10 @@ public final class PartyManager {
|
||||
createAlliance(mcMMOPlayer.getParty(), invite);
|
||||
}
|
||||
|
||||
public static void createAlliance(Party firstParty, Party secondParty) {
|
||||
public void createAlliance(@NotNull Party firstParty, @NotNull Party secondParty) {
|
||||
requireNonNull(firstParty, "firstParty cannot be null!");
|
||||
requireNonNull(secondParty, "secondParty cannot be null!");
|
||||
|
||||
firstParty.setAlly(secondParty);
|
||||
secondParty.setAlly(firstParty);
|
||||
|
||||
@ -503,16 +472,22 @@ public final class PartyManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean disbandAlliance(Player player, Party firstParty, Party secondParty){
|
||||
public boolean disbandAlliance(@NotNull Player player, @NotNull Party firstParty, @NotNull Party secondParty) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
requireNonNull(firstParty, "firstParty cannot be null!");
|
||||
requireNonNull(secondParty, "secondParty cannot be null!");
|
||||
|
||||
if (!handlePartyChangeAllianceEvent(player, firstParty.getName(), secondParty.getName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PartyManager.disbandAlliance(firstParty, secondParty);
|
||||
disbandAlliance(firstParty, secondParty);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void disbandAlliance(Party firstParty, Party secondParty) {
|
||||
private void disbandAlliance(@NotNull Party firstParty, @NotNull Party secondParty) {
|
||||
requireNonNull(firstParty, "firstParty cannot be null!");
|
||||
requireNonNull(secondParty, "secondParty cannot be null!");
|
||||
firstParty.setAlly(null);
|
||||
secondParty.setAlly(null);
|
||||
|
||||
@ -529,9 +504,12 @@ public final class PartyManager {
|
||||
* Add a player to a party
|
||||
*
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param party The party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
|
||||
public void addToParty(@NotNull McMMOPlayer mcMMOPlayer, @NotNull Party party) {
|
||||
requireNonNull(mcMMOPlayer, "mcMMOPlayer cannot be null!");
|
||||
requireNonNull(party, "party cannot be null!");
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
String playerName = player.getName();
|
||||
|
||||
@ -547,7 +525,8 @@ public final class PartyManager {
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeaderName(String partyName) {
|
||||
public @Nullable String getPartyLeaderName(@NotNull String partyName) {
|
||||
requireNonNull(partyName, "partyName cannot be null!");
|
||||
Party party = getParty(partyName);
|
||||
|
||||
return party == null ? null : party.getLeader().getPlayerName();
|
||||
@ -556,11 +535,13 @@ public final class PartyManager {
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
*
|
||||
* @param uuid The uuid of the player to set as leader
|
||||
* @param uuid The uuid of the player to set as leader
|
||||
* @param party The party
|
||||
*/
|
||||
public static void setPartyLeader(UUID uuid, Party party) {
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid);
|
||||
public void setPartyLeader(@NotNull UUID uuid, @NotNull Party party) {
|
||||
requireNonNull(uuid, "uuid cannot be null!");
|
||||
requireNonNull(party, "party cannot be null!");
|
||||
OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(uuid);
|
||||
UUID leaderUniqueId = party.getLeader().getUniqueId();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
@ -568,11 +549,9 @@ public final class PartyManager {
|
||||
|
||||
if (memberUniqueId.equals(player.getUniqueId())) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
|
||||
}
|
||||
else if (memberUniqueId.equals(leaderUniqueId)) {
|
||||
} else if (memberUniqueId.equals(leaderUniqueId)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.New", player.getName()));
|
||||
}
|
||||
}
|
||||
@ -585,24 +564,96 @@ public final class PartyManager {
|
||||
*
|
||||
* @return true if the player can invite
|
||||
*/
|
||||
public static boolean canInvite(McMMOPlayer mcMMOPlayer) {
|
||||
public boolean canInvite(@NotNull McMMOPlayer mcMMOPlayer) {
|
||||
requireNonNull(mcMMOPlayer, "mcMMOPlayer cannot be null!");
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
return !party.isLocked() || party.getLeader().getUniqueId().equals(mcMMOPlayer.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load party file.
|
||||
* Check if a party with a given name already exists.
|
||||
*
|
||||
* @param player The player to notify
|
||||
* @param partyName The name of the party to check
|
||||
* @return true if a party with that name exists, false otherwise
|
||||
*/
|
||||
public static void loadParties() {
|
||||
if (!partyFile.exists()) {
|
||||
return;
|
||||
public boolean checkPartyExistence(@NotNull Player player, @NotNull String partyName) {
|
||||
requireNonNull(player, "player cannot be null!");
|
||||
requireNonNull(partyName, "partyName cannot be null!");
|
||||
|
||||
if (getParty(partyName) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) {
|
||||
// loadAndUpgradeParties();
|
||||
// return;
|
||||
// }
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", partyName));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to change parties or join a new party.
|
||||
*
|
||||
* @param mmoPlayer The player changing or joining parties
|
||||
* @param newPartyName The name of the party being joined
|
||||
* @return true if the party was joined successfully, false otherwise
|
||||
*/
|
||||
public boolean changeOrJoinParty(@NotNull McMMOPlayer mmoPlayer, @NotNull String newPartyName) {
|
||||
requireNonNull(mmoPlayer, "mmoPlayer cannot be null!");
|
||||
requireNonNull(newPartyName, "newPartyName cannot be null!");
|
||||
|
||||
final Player player = mmoPlayer.getPlayer();
|
||||
|
||||
if (mmoPlayer.inParty()) {
|
||||
final Party oldParty = mmoPlayer.getParty();
|
||||
|
||||
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
removeFromParty(mmoPlayer);
|
||||
} else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two online players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(@NotNull Player firstPlayer, @NotNull Player secondPlayer) {
|
||||
requireNonNull(firstPlayer, "firstPlayer cannot be null!");
|
||||
requireNonNull(secondPlayer, "secondPlayer cannot be null!");
|
||||
|
||||
//Profile not loaded
|
||||
if (UserManager.getPlayer(firstPlayer) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if (UserManager.getPlayer(secondPlayer) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
|
||||
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return firstParty.equals(secondParty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load party file.
|
||||
*/
|
||||
public void loadParties() {
|
||||
if (!pluginRef.getPartyConfig().isPartyEnabled() || !partyFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
YamlConfiguration partiesFile;
|
||||
@ -641,31 +692,30 @@ public final class PartyManager {
|
||||
|
||||
parties.add(party);
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().log(Level.WARNING, "An exception occurred while loading a party with name '" + partyName + "'. Skipped loading party.", e);
|
||||
pluginRef.getLogger().log(Level.WARNING, "An exception occurred while loading a party with name '" + partyName + "'. Skipped loading party.", e);
|
||||
}
|
||||
}
|
||||
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loaded (" + parties.size() + ") Parties...");
|
||||
LogUtils.debug(pluginRef.getLogger(), "Loaded (" + parties.size() + ") Parties...");
|
||||
|
||||
for (Party party : hasAlly) {
|
||||
party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
|
||||
party.setAlly(getParty(partiesFile.getString(party.getName() + ".Ally")));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save party file.
|
||||
*/
|
||||
public static void saveParties() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "[Party Data] Saving...");
|
||||
public void saveParties() {
|
||||
LogUtils.debug(pluginRef.getLogger(), "[Party Data] Saving...");
|
||||
|
||||
if (partyFile.exists()) {
|
||||
if (!partyFile.delete()) {
|
||||
mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!");
|
||||
pluginRef.getLogger().warning("Could not delete party file. Party saving failed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -705,91 +755,23 @@ public final class PartyManager {
|
||||
|
||||
try {
|
||||
partiesFile.save(partyFile);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// private static void loadAndUpgradeParties() {
|
||||
// YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||
//
|
||||
// if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
|
||||
// mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ArrayList<Party> hasAlly = new ArrayList<>();
|
||||
//
|
||||
// for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
// Party party = new Party(partyName);
|
||||
//
|
||||
// String leaderName = partiesFile.getString(partyName + ".Leader");
|
||||
// PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(leaderName, false);
|
||||
//
|
||||
// if (!profile.isLoaded()) {
|
||||
// mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// UUID leaderUniqueId = profile.getUniqueId();
|
||||
//
|
||||
// party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
|
||||
// party.setPassword(partiesFile.getString(partyName + ".Password"));
|
||||
// party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
// party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
// party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
//
|
||||
// if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
// hasAlly.add(party);
|
||||
// }
|
||||
//
|
||||
// party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
// party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
//
|
||||
// for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
// party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
// }
|
||||
//
|
||||
// LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
//
|
||||
// for (String memberName : partiesFile.getStringList(partyName + ".Members")) {
|
||||
// PlayerProfile memberProfile = mcMMO.getDatabaseManager().loadPlayerProfile(memberName, false);
|
||||
//
|
||||
// if (!memberProfile.isLoaded()) {
|
||||
// mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// UUID memberUniqueId = memberProfile.getUniqueId();
|
||||
//
|
||||
// members.put(memberUniqueId, memberName);
|
||||
// }
|
||||
//
|
||||
// parties.add(party);
|
||||
// }
|
||||
//
|
||||
// LogUtils.debug(mcMMO.p.getLogger(), "Loaded (" + parties.size() + ") Parties...");
|
||||
//
|
||||
// for (Party party : hasAlly) {
|
||||
// party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally")));
|
||||
// }
|
||||
//
|
||||
// mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Handle party change event.
|
||||
*
|
||||
* @param player The player changing parties
|
||||
* @param player The player changing parties
|
||||
* @param oldPartyName The name of the old party
|
||||
* @param newPartyName The name of the new party
|
||||
* @param reason The reason for changing parties
|
||||
* @param reason The reason for changing parties
|
||||
* @return true if the change event was successful, false otherwise
|
||||
*/
|
||||
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||
public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
@ -797,15 +779,15 @@ public final class PartyManager {
|
||||
/**
|
||||
* Handle party alliance change event.
|
||||
*
|
||||
* @param player The player changing party alliances
|
||||
* @param player The player changing party alliances
|
||||
* @param oldAllyName The name of the old ally
|
||||
* @param newAllyName The name of the new ally
|
||||
* @param reason The reason for changing allies
|
||||
* @param reason The reason for changing allies
|
||||
* @return true if the change event was successful, false otherwise
|
||||
*/
|
||||
public static boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) {
|
||||
public boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) {
|
||||
McMMOPartyAllianceChangeEvent event = new McMMOPartyAllianceChangeEvent(player, oldAllyName, newAllyName, reason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
@ -815,7 +797,7 @@ public final class PartyManager {
|
||||
*
|
||||
* @param mcMMOPlayer The player to remove party data from.
|
||||
*/
|
||||
public static void processPartyLeaving(McMMOPlayer mcMMOPlayer) {
|
||||
public void processPartyLeaving(@NotNull McMMOPlayer mcMMOPlayer) {
|
||||
mcMMOPlayer.removeParty();
|
||||
mcMMOPlayer.setChatMode(ChatChannel.NONE);
|
||||
mcMMOPlayer.setItemShareModifier(10);
|
||||
@ -824,12 +806,12 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when the party levels up.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param levelsGained The amount of levels gained
|
||||
* @param level The current party level
|
||||
* @param level The current party level
|
||||
*/
|
||||
public static void informPartyMembersLevelUp(Party party, int levelsGained, int level) {
|
||||
boolean levelUpSoundsEnabled = mcMMO.p.getGeneralConfig().getLevelUpSoundsEnabled();
|
||||
public void informPartyMembersLevelUp(Party party, int levelsGained, int level) {
|
||||
boolean levelUpSoundsEnabled = pluginRef.getGeneralConfig().getLevelUpSoundsEnabled();
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
|
||||
|
||||
@ -842,10 +824,10 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when a player joins.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that joined
|
||||
*/
|
||||
private static void informPartyMembersJoin(Party party, String playerName) {
|
||||
private void informPartyMembersJoin(Party party, String playerName) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName));
|
||||
}
|
||||
@ -854,10 +836,10 @@ public final class PartyManager {
|
||||
/**
|
||||
* Notify party members when a party member quits.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that left
|
||||
*/
|
||||
private static void informPartyMembersQuit(Party party, String playerName) {
|
||||
private void informPartyMembersQuit(Party party, String playerName) {
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public final class ShareHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
|
||||
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearVisibleMembers(mcMMOPlayer);
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
@ -87,7 +87,7 @@ public final class ShareHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
|
||||
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearMembers(mcMMOPlayer);
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
|
@ -21,6 +21,6 @@ public class SaveTimerTask extends CancellableRunnable {
|
||||
}
|
||||
|
||||
|
||||
PartyManager.saveParties();
|
||||
mcMMO.p.getPartyManager().saveParties();
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class TeleportationWarmup extends CancellableRunnable {
|
||||
|
||||
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||
|
||||
if (!PartyManager.inSameParty(teleportingPlayer, targetPlayer)) {
|
||||
if (!mcMMO.p.getPartyManager().inSameParty(teleportingPlayer, targetPlayer)) {
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName()));
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class PartyAutoKickTask extends CancellableRunnable {
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
for (Party party : PartyManager.getParties()) {
|
||||
for (Party party : mcMMO.p.getPartyManager().getParties()) {
|
||||
for (UUID memberUniqueId : party.getMembers().keySet()) {
|
||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
|
||||
boolean isProcessed = processedPlayers.contains(memberUniqueId);
|
||||
@ -38,7 +38,7 @@ public class PartyAutoKickTask extends CancellableRunnable {
|
||||
}
|
||||
|
||||
for (Entry<OfflinePlayer, Party> entry : toRemove.entrySet()) {
|
||||
PartyManager.removeFromParty(entry.getKey(), entry.getValue());
|
||||
mcMMO.p.getPartyManager().removeFromParty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,15 +139,6 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new McgodCommand());
|
||||
}
|
||||
|
||||
// private static void registerDropTreasureCommand() {
|
||||
// PluginCommand command = mcMMO.p.getCommand("mmodroptreasures");
|
||||
// command.setDescription(LocaleLoader.getString("Commands.Description.droptreasures"));
|
||||
// command.setPermission("mcmmo.commands.droptreasures");
|
||||
// command.setPermissionMessage(permissionsMessage);
|
||||
// command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcgod"));
|
||||
// command.setExecutor(new DropTreasureCommand());
|
||||
// }
|
||||
|
||||
private static void registerMmoInfoCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mmoinfo");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoinfo"));
|
||||
@ -317,28 +308,6 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new McconvertCommand());
|
||||
}
|
||||
|
||||
// private static void registerAdminChatCommand() {
|
||||
// PluginCommand command = mcMMO.p.getCommand("adminchat");
|
||||
// command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
|
||||
// command.setPermission("mcmmo.chat.adminchat");
|
||||
// command.setPermissionMessage(permissionsMessage);
|
||||
// command.setUsage(LocaleLoader.getString("Commands.Usage.0", "adminchat"));
|
||||
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<on|off>"));
|
||||
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"));
|
||||
// command.setExecutor(new AdminChatCommand());
|
||||
// }
|
||||
|
||||
// private static void registerPartyChatCommand() {
|
||||
// PluginCommand command = mcMMO.p.getCommand("partychat");
|
||||
// command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
|
||||
// command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
|
||||
// command.setPermissionMessage(permissionsMessage);
|
||||
// command.setUsage(LocaleLoader.getString("Commands.Usage.0", "partychat"));
|
||||
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<on|off>"));
|
||||
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"));
|
||||
// command.setExecutor(new PartyChatCommand());
|
||||
// }
|
||||
|
||||
private static void registerPartyCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("party");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.party"));
|
||||
@ -360,26 +329,6 @@ public final class CommandRegistrationManager {
|
||||
command.setExecutor(new PtpCommand());
|
||||
}
|
||||
|
||||
// private static void registerHardcoreCommand() {
|
||||
// PluginCommand command = mcMMO.p.getCommand("hardcore");
|
||||
// command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
|
||||
// command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
|
||||
// command.setPermissionMessage(permissionsMessage);
|
||||
// command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]"));
|
||||
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
|
||||
// command.setExecutor(new HardcoreCommand());
|
||||
// }
|
||||
//
|
||||
// private static void registerVampirismCommand() {
|
||||
// PluginCommand command = mcMMO.p.getCommand("vampirism");
|
||||
// command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
|
||||
// command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
|
||||
// command.setPermissionMessage(permissionsMessage);
|
||||
// command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]"));
|
||||
// command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
|
||||
// command.setExecutor(new VampirismCommand());
|
||||
// }
|
||||
|
||||
private static void registerMcnotifyCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcnotify");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
|
||||
@ -459,13 +408,11 @@ public final class CommandRegistrationManager {
|
||||
registerMmoeditCommand();
|
||||
registerSkillresetCommand();
|
||||
|
||||
// Hardcore Commands
|
||||
// registerHardcoreCommand();
|
||||
// registerVampirismCommand();
|
||||
|
||||
// Party Commands
|
||||
registerPartyCommand();
|
||||
registerPtpCommand();
|
||||
if (mcMMO.p.getPartyConfig().isPartyEnabled()) {
|
||||
registerPartyCommand();
|
||||
registerPtpCommand();
|
||||
}
|
||||
|
||||
// Player Commands
|
||||
registerInspectCommand();
|
||||
|
@ -741,7 +741,7 @@ public final class CombatUtils {
|
||||
XPGainReason xpGainReason;
|
||||
|
||||
if (target instanceof Player defender) {
|
||||
if (!ExperienceConfig.getInstance().getExperienceGainsPlayerVersusPlayerEnabled() || PartyManager.inSameParty(mcMMOPlayer.getPlayer(), (Player) target)) {
|
||||
if (!ExperienceConfig.getInstance().getExperienceGainsPlayerVersusPlayerEnabled() || mcMMO.p.getPartyManager().inSameParty(mcMMOPlayer.getPlayer(), (Player) target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -828,7 +828,7 @@ public final class CombatUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((PartyManager.inSameParty(player, defender) || PartyManager.areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
||||
if ((mcMMO.p.getPartyManager().inSameParty(player, defender) || mcMMO.p.getPartyManager().areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -879,7 +879,7 @@ public final class CombatUtils {
|
||||
|
||||
if (tamer instanceof Player owner) {
|
||||
|
||||
return (owner == attacker || PartyManager.inSameParty(attacker, owner) || PartyManager.areAllies(attacker, owner));
|
||||
return (owner == attacker || mcMMO.p.getPartyManager().inSameParty(attacker, owner) || mcMMO.p.getPartyManager().areAllies(attacker, owner));
|
||||
}
|
||||
}
|
||||
|
||||
|
4
src/main/resources/party.yml
Normal file
4
src/main/resources/party.yml
Normal file
@ -0,0 +1,4 @@
|
||||
# Settings for mcMMO Party System
|
||||
Party:
|
||||
# Enable or disable the mcMMO party system
|
||||
Enabled: true
|
Loading…
Reference in New Issue
Block a user