mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
More work on parties
This commit is contained in:
parent
11c29c8299
commit
86fdafef08
@ -14,9 +14,6 @@ Version 2.2.000
|
||||
Added Sub-Skill named Crossbows Limit Break to Crossbows
|
||||
|
||||
Permission node descriptions had mentions of ability changed to sub-skill and other minor corrections
|
||||
Smelting now has a Bonus Drops section in config.yml
|
||||
Second Smelt now only doubles smelting results for items which have bonus drop entries in the config
|
||||
Fixed an array out of index bug for inventory click events
|
||||
mcMMO will now register arrows shot from the offhand as being from either Archery or Crossbows (before mcMMO ignored offhand Archery)
|
||||
|
||||
(These permissions are all included in the mcmmo.defaults node)
|
||||
@ -32,6 +29,30 @@ Version 2.2.000
|
||||
New permission node 'mcmmo.ability.crossbows.crossbowslimitbreak'
|
||||
New permission node 'mcmmo.ability.crossbows.coneofdeath'
|
||||
|
||||
|
||||
The Party system has some new features, and a lot of bad features were removed completely, read the notes
|
||||
Parties can no longer have passwords (see notes)
|
||||
Parties can no longer be locked (see notes)
|
||||
Parties no longer have item share (see notes)
|
||||
Party alliances are gone (see notes)
|
||||
Parties are always private (see notes)
|
||||
Party members can be promoted to Officer by the Party Leader (officers are mini-party leaders)
|
||||
Added Party Officer chat, only other officers (including the party leader) can read and participate
|
||||
Added the following party subcommands: promote, demote
|
||||
Removed the following party subcommands: join, lock, unlock, password, alliance, item share
|
||||
|
||||
Added permission node 'mcmmo.chat.officerpartychat'
|
||||
|
||||
The following permission nodes were removed because their related feature was removed
|
||||
Removed permission node 'mcmmo.commands.party.unlock'
|
||||
Removed permission node 'mcmmo.commands.party.alliance'
|
||||
Removed permission node 'mcmmo.commands.party.password'
|
||||
Removed permission node 'mcmmo.commands.party.itemshare'
|
||||
|
||||
The following permission nodes were removed because permissions for these commands don't make sense, if you want to disable party commands just negate 'mcmmo.commands.party'
|
||||
Removed permission node 'mcmmo.commands.party.quit'
|
||||
Removed permission node 'mcmmo.commands.party.kick'
|
||||
|
||||
Added new locale string 'Overhaul.Name.Tridents'
|
||||
Added new locale string 'Tridents.SubSkill.TridentsLimitBreak.Name'
|
||||
Added new locale string 'Tridents.SubSkill.TridentsLimitBreak.Description'
|
||||
@ -60,6 +81,10 @@ Version 2.2.000
|
||||
|
||||
Notes:
|
||||
These are the first new skills that I've written for mcMMO in about 9 years, I'll be listening closely to feedback and tweaking them often.
|
||||
Parties got unnecessarily complex in my absence, I have removed many party features in order to simplify parties and bring them closer to my vision. I have also added new features which should improve parties where it matters.
|
||||
About the removed party features, all the features I removed I consider poor quality features and I don't think they belong in mcMMO. Feel free to yell at me in discord if you disagree.
|
||||
I don't know what genius decided to make parties public by default, when I found out that parties had been changed to such a system I could barely contain my disgust. Parties are back to being private, you get invited by a party leader or party officer. That is the only way to join a party.
|
||||
|
||||
Version 2.1.145
|
||||
Reverted 'Changed one of the PlayerInteractEvent listeners to ignore cancelled events' from 2.1.144
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.commands.party.PartySubCommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -109,7 +109,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
|
||||
if (Permissions.partySubcommand(sender, PartySubCommandType.TELEPORT)) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
|
@ -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 org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -31,7 +30,7 @@ public class PartyCommand implements TabExecutor {
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
for (PartySubCommandType subcommand : PartySubCommandType.values()) {
|
||||
subcommands.add(subcommand.toString());
|
||||
}
|
||||
|
||||
@ -39,24 +38,19 @@ 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 partyChatCommand = new PartyChatCommand();
|
||||
private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
@ -92,21 +86,19 @@ public class PartyCommand implements TabExecutor {
|
||||
return partyInfoCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
PartySubCommandType subcommand = PartySubCommandType.getSubcommand(args[0]);
|
||||
|
||||
if (subcommand == null) {
|
||||
return printUsage(player);
|
||||
}
|
||||
|
||||
// Can't use this for lock/unlock since they're handled by the same command
|
||||
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) {
|
||||
if (!Permissions.partySubcommand(sender, subcommand)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case JOIN:
|
||||
return partyJoinCommand.onCommand(sender, command, label, args);
|
||||
case ACCEPT:
|
||||
return partyAcceptCommand.onCommand(sender, command, label, args);
|
||||
case CREATE:
|
||||
@ -147,23 +139,14 @@ public class PartyCommand implements TabExecutor {
|
||||
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;
|
||||
}
|
||||
@ -177,7 +160,7 @@ public class PartyCommand implements TabExecutor {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<>(PARTY_SUBCOMMANDS.size()));
|
||||
case 2:
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
PartySubCommandType subcommand = PartySubCommandType.getSubcommand(args[0]);
|
||||
|
||||
if (subcommand == null) {
|
||||
return ImmutableList.of();
|
||||
@ -223,7 +206,7 @@ public class PartyCommand implements TabExecutor {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
case 3:
|
||||
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) {
|
||||
if (PartySubCommandType.getSubcommand(args[0]) == PartySubCommandType.ITEMSHARE && isItemShareCategory(args[1])) {
|
||||
return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
}
|
||||
|
||||
|
@ -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 org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyMember;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -21,7 +23,7 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
Party playerParty = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
|
||||
String partyName = playerParty.getPartyName();
|
||||
|
||||
for (Player member : playerParty.getPartyMembers()) {
|
||||
for (PartyMember member : playerParty.getPartyMembers()) {
|
||||
if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -3,10 +3,9 @@ package com.gmail.nossr50.commands.party;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import org.bukkit.ChatColor;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -88,34 +87,18 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
|
||||
private void displayShareModeInfo(Player player, Party party) {
|
||||
boolean xpShareEnabled = isUnlockedFeature(party, PartyFeature.XP_SHARE);
|
||||
boolean itemShareEnabled = isUnlockedFeature(party, PartyFeature.ITEM_SHARE);
|
||||
boolean itemSharingActive = (party.getItemShareMode() != ShareMode.NONE);
|
||||
|
||||
if (!xpShareEnabled && !itemShareEnabled) {
|
||||
if (!xpShareEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
String expShareInfo = "";
|
||||
String itemShareInfo = "";
|
||||
String separator = "";
|
||||
|
||||
if (xpShareEnabled) {
|
||||
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
|
||||
}
|
||||
|
||||
if (itemShareEnabled) {
|
||||
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString());
|
||||
}
|
||||
|
||||
if (xpShareEnabled && itemShareEnabled) {
|
||||
separator = ChatColor.DARK_GRAY + " || ";
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
||||
|
||||
if (itemSharingActive) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", party.getItemShareCategories()));
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo);
|
||||
}
|
||||
|
||||
private void displayMemberInfo(Player player, McMMOPlayer mmoPlayer, Party party) {
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.config.Config;
|
||||
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.util.commands.CommandUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -1,96 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class PartyItemShareCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
|
||||
|
||||
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase(Locale.ENGLISH));
|
||||
|
||||
if (mode == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
handleChangingShareMode(party, mode);
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
boolean toggle;
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[2])) {
|
||||
toggle = true;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[2])) {
|
||||
toggle = false;
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase(Locale.ENGLISH)), toggle);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChangingShareMode(Party party, ShareMode mode) {
|
||||
party.setItemShareMode(mode);
|
||||
|
||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
member.sendMessage(changeModeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
|
||||
party.setSharingDrops(type, toggle);
|
||||
|
||||
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
|
||||
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
member.sendMessage(toggleMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
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.util.commands.CommandUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyJoinCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (!mcMMOTarget.inParty()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
|
||||
Party targetParty = mcMMOTarget.getParty();
|
||||
|
||||
if (player.equals(target) || (mmoPlayer.inParty() && mmoPlayer.getParty().equals(targetParty))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String password = getPassword(args);
|
||||
|
||||
// Make sure party passwords match
|
||||
if (!mcMMO.getPartyManager().checkPartyPassword(player, targetParty, password)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyName = targetParty.getPartyName();
|
||||
|
||||
// Changing parties
|
||||
if (!mcMMO.getPartyManager().changeOrJoinParty(mmoPlayer, partyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(mcMMO.getPartyManager().isPartyFull(player, targetParty))
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
|
||||
mcMMO.getPartyManager().addToParty(mmoPlayer, targetParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String getPassword(String[] args) {
|
||||
if (args.length == 3) {
|
||||
return args[2];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyLockCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("lock")) {
|
||||
togglePartyLock(sender, true);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
togglePartyLock(sender, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("lock")) {
|
||||
sendUsageStrings(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
togglePartyLock(sender, true);
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
togglePartyLock(sender, false);
|
||||
}
|
||||
else {
|
||||
sendUsageStrings(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sendUsageStrings(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendUsageStrings(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
|
||||
}
|
||||
|
||||
private void togglePartyLock(CommandSender sender, boolean lock) {
|
||||
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
|
||||
|
||||
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (lock == party.isLocked()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
|
||||
return;
|
||||
}
|
||||
|
||||
party.setPartyLock(lock);
|
||||
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
public enum PartySubcommandType {
|
||||
public enum PartySubCommandType {
|
||||
JOIN,
|
||||
ACCEPT,
|
||||
CREATE,
|
||||
@ -8,21 +8,18 @@ public enum PartySubcommandType {
|
||||
INFO,
|
||||
QUIT,
|
||||
XPSHARE,
|
||||
ITEMSHARE,
|
||||
INVITE,
|
||||
KICK,
|
||||
DISBAND,
|
||||
OWNER,
|
||||
LOCK,
|
||||
UNLOCK,
|
||||
PASSWORD,
|
||||
RENAME,
|
||||
TELEPORT,
|
||||
CHAT,
|
||||
ALLIANCE;
|
||||
PROMOTE,
|
||||
DEMOTE;
|
||||
|
||||
public static PartySubcommandType getSubcommand(String commandName) {
|
||||
for (PartySubcommandType command : values()) {
|
||||
public static PartySubCommandType getSubcommand(String commandName) {
|
||||
for (PartySubCommandType command : values()) {
|
||||
if (command.name().equalsIgnoreCase(commandName)) {
|
||||
return command;
|
||||
}
|
||||
@ -39,14 +36,8 @@ public enum PartySubcommandType {
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
return XPSHARE;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
|
||||
return ITEMSHARE;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("ally")) {
|
||||
return ALLIANCE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -1,38 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyAllianceAcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
|
||||
|
||||
if (!mmoPlayer.hasPartyAllianceInvite()) {
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mmoPlayer.getParty().getAlly() != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMO.getPartyManager().acceptAllianceInvite(mmoPlayer);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartyAllianceCommand implements TabExecutor {
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
private Party targetParty;
|
||||
|
||||
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
|
||||
|
||||
private final CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
|
||||
private final CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
|
||||
private final CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
|
||||
|
||||
playerParty = mmoPlayer.getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerParty.getAlly() == null) {
|
||||
printUsage();
|
||||
return true;
|
||||
}
|
||||
|
||||
targetParty = playerParty.getAlly();
|
||||
|
||||
displayPartyHeader();
|
||||
displayMemberInfo(mmoPlayer);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("invite")) {
|
||||
return partyAllianceInviteCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("accept")) {
|
||||
return partyAllianceAcceptCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("disband")) {
|
||||
return partyAllianceDisbandCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (playerParty.getAlly() == null) {
|
||||
printUsage();
|
||||
return true;
|
||||
}
|
||||
|
||||
targetParty = playerParty.getAlly();
|
||||
|
||||
displayPartyHeader();
|
||||
displayMemberInfo(mmoPlayer);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean printUsage() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.0"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.1"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void displayPartyHeader() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getPartyName(), targetParty.getPartyName()));
|
||||
}
|
||||
|
||||
private void displayMemberInfo(McMMOPlayer mmoPlayer) {
|
||||
List<Player> nearMembers = mcMMO.getPartyManager().getNearMembers(mmoPlayer);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
|
||||
player.sendMessage(playerParty.createMembersList(player));
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
|
||||
player.sendMessage(targetParty.createMembersList(player));
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
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 org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyAllianceDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 2) {
|
||||
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (party.getAlly() == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMO.getPartyManager().disbandAlliance(player, party, party.getAlly());
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
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.util.commands.CommandUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyAllianceInviteCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (args.length == 3) {
|
||||
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
|
||||
McMMOPlayer mcMMOTarget = mcMMO.getUserManager().getOfflinePlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (mcMMO.getUserManager().getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (player.equals(target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.getPartyManager().inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mmoPlayer.getParty();
|
||||
|
||||
if (playerParty.getAlly() != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOTarget.setPartyAllianceInvite(playerParty);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getPartyName(), playerName));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1"));
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party.teleport;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.World;
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.dirtydata;
|
||||
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean;
|
||||
import com.google.common.base.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DirtyData<T> {
|
||||
@ -35,4 +36,17 @@ public class DirtyData<T> {
|
||||
this.data = data;
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DirtyData<?> dirtyData = (DirtyData<?>) o;
|
||||
return Objects.equal(getData(), dirtyData.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getData());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.dirtydata;
|
||||
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean;
|
||||
import com.google.common.base.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -145,4 +146,17 @@ public class DirtyDataMap<K, V> {
|
||||
setDirty();
|
||||
return dataMap.merge(key, value, remappingFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DirtyDataMap<?, ?> that = (DirtyDataMap<?, ?>) o;
|
||||
return Objects.equal(getDataMap(), that.getDataMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getDataMap());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
package com.gmail.nossr50.datatypes.dirtydata;
|
||||
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean;
|
||||
import com.google.common.base.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DirtyDataSet<E> {
|
||||
|
||||
private final @NotNull MutableBoolean dirtyFlag; //Can be pointed at a reference
|
||||
private @NotNull Set<E> dataSet;
|
||||
|
||||
public DirtyDataSet(@NotNull Set<E> data, @NotNull MutableBoolean referenceFlag) {
|
||||
this.dataSet = data;
|
||||
this.dirtyFlag = referenceFlag;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return dirtyFlag.getImmutableCopy();
|
||||
}
|
||||
|
||||
private void setDirty() {
|
||||
dirtyFlag.setBoolean(true);
|
||||
}
|
||||
|
||||
public void setData(@NotNull Set<E> dataSet) {
|
||||
this.dataSet = dataSet;
|
||||
setDirty();
|
||||
}
|
||||
|
||||
public @NotNull Set<E> getDataSet() {
|
||||
setDirty();
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
/* Set Interface Delegates */
|
||||
|
||||
public int size() {
|
||||
return dataSet.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return dataSet.isEmpty();
|
||||
}
|
||||
|
||||
public boolean contains(Object o) {
|
||||
return dataSet.contains(o);
|
||||
}
|
||||
|
||||
public Iterator<E> iterator() {
|
||||
return dataSet.iterator();
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
return dataSet.toArray();
|
||||
}
|
||||
|
||||
public <T> T[] toArray(@NotNull T[] ts) {
|
||||
return dataSet.toArray(ts);
|
||||
}
|
||||
|
||||
public boolean add(E e) {
|
||||
return dataSet.add(e);
|
||||
}
|
||||
|
||||
public boolean remove(Object o) {
|
||||
return dataSet.remove(o);
|
||||
}
|
||||
|
||||
public boolean containsAll(@NotNull Collection<? extends E> collection) {
|
||||
return dataSet.containsAll(collection);
|
||||
}
|
||||
|
||||
public boolean addAll(@NotNull Collection<? extends E> collection) {
|
||||
return dataSet.addAll(collection);
|
||||
}
|
||||
|
||||
public boolean retainAll(@NotNull Collection<? extends E> collection) {
|
||||
return dataSet.retainAll(collection);
|
||||
}
|
||||
|
||||
public boolean removeAll(@NotNull Collection<? extends E> collection) {
|
||||
return dataSet.removeAll(collection);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
dataSet.clear();
|
||||
}
|
||||
|
||||
public Spliterator<E> spliterator() {
|
||||
return dataSet.spliterator();
|
||||
}
|
||||
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
return dataSet.removeIf(filter);
|
||||
}
|
||||
|
||||
public Stream<E> stream() {
|
||||
return dataSet.stream();
|
||||
}
|
||||
|
||||
public Stream<E> parallelStream() {
|
||||
return dataSet.parallelStream();
|
||||
}
|
||||
|
||||
public void forEach(Consumer<? super E> action) {
|
||||
dataSet.forEach(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DirtyDataSet<?> that = (DirtyDataSet<?>) o;
|
||||
return Objects.equal(getDataSet(), that.getDataSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getDataSet());
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableBoolean {
|
||||
private boolean bool;
|
||||
|
||||
@ -14,4 +16,17 @@ public class MutableBoolean {
|
||||
public void setBoolean(boolean bool) {
|
||||
this.bool = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableBoolean that = (MutableBoolean) o;
|
||||
return bool == that.bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(bool);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableByte {
|
||||
|
||||
private byte byteValue;
|
||||
@ -16,4 +18,16 @@ public class MutableByte {
|
||||
this.byteValue = byteValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableByte that = (MutableByte) o;
|
||||
return byteValue == that.byteValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(byteValue);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableChar {
|
||||
|
||||
private char charValue;
|
||||
@ -16,4 +18,16 @@ public class MutableChar {
|
||||
this.charValue = charValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableChar that = (MutableChar) o;
|
||||
return charValue == that.charValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(charValue);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableDouble {
|
||||
|
||||
private double doubleValue;
|
||||
@ -16,4 +18,16 @@ public class MutableDouble {
|
||||
this.doubleValue = doubleValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableDouble that = (MutableDouble) o;
|
||||
return Double.compare(that.doubleValue, doubleValue) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(doubleValue);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableFloat {
|
||||
|
||||
private float floatValue;
|
||||
@ -16,4 +18,16 @@ public class MutableFloat {
|
||||
this.floatValue = floatValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableFloat that = (MutableFloat) o;
|
||||
return Float.compare(that.floatValue, floatValue) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(floatValue);
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableInteger {
|
||||
private int integer;
|
||||
|
||||
@ -14,4 +16,17 @@ public class MutableInteger {
|
||||
public void setInt(int integer) {
|
||||
this.integer = integer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableInteger that = (MutableInteger) o;
|
||||
return integer == that.integer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(integer);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableLong {
|
||||
|
||||
private long longValue;
|
||||
@ -16,4 +18,16 @@ public class MutableLong {
|
||||
this.longValue = longValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableLong that = (MutableLong) o;
|
||||
return longValue == that.longValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(longValue);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class MutableShort {
|
||||
|
||||
private short shortValue;
|
||||
@ -16,4 +18,16 @@ public class MutableShort {
|
||||
this.shortValue = shortValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableShort that = (MutableShort) o;
|
||||
return shortValue == that.shortValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(shortValue);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.mutableprimitives;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MutableString {
|
||||
@ -18,4 +19,16 @@ public class MutableString {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MutableString that = (MutableString) o;
|
||||
return Objects.equal(string, that.string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(string);
|
||||
}
|
||||
}
|
||||
|
@ -3,65 +3,69 @@ package com.gmail.nossr50.datatypes.party;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.ChatColor;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Party {
|
||||
private final String partyName;
|
||||
private String partyPassword;
|
||||
private boolean partyLock;
|
||||
private final @NotNull PersistentPartyData persistentPartyData;
|
||||
private final @NotNull PartyMemberManager partyMemberManager;
|
||||
private final @NotNull PartyExperienceManager partyExperienceManager;
|
||||
|
||||
private final PartyMemberManager partyMemberManager;
|
||||
private final PartyItemShareManager partyItemShareManager;
|
||||
private final PartyExperienceManager partyExperienceManager;
|
||||
private final PartyAllianceManager partyAllianceManager;
|
||||
public Party(@NotNull PersistentPartyData persistentPartyData) {
|
||||
this.persistentPartyData = persistentPartyData;
|
||||
|
||||
public Party(Persistent)
|
||||
//Initialize Managers
|
||||
partyMemberManager = new PartyMemberManager();
|
||||
partyExperienceManager = new PartyExperienceManager();
|
||||
}
|
||||
|
||||
public HashSet<PartyMember> getPartyMembers() {
|
||||
public @NotNull PartyMemberManager getPartyMemberManager() {
|
||||
return partyMemberManager;
|
||||
}
|
||||
|
||||
public @NotNull PartyExperienceManager getPartyExperienceManager() {
|
||||
return partyExperienceManager;
|
||||
}
|
||||
|
||||
public Set<PartyMember> getPartyMembers() {
|
||||
return partyMemberManager.getPartyMembers();
|
||||
}
|
||||
|
||||
public String getPartyName() {
|
||||
return partyName;
|
||||
}
|
||||
|
||||
public String getPartyPassword() {
|
||||
return partyPassword;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return partyLock;
|
||||
}
|
||||
|
||||
public Party getAlly() {
|
||||
return ally;
|
||||
}
|
||||
|
||||
public void setPartyName(String partyName) {
|
||||
this.partyName = partyName;
|
||||
return persistentPartyData.getPartyName();
|
||||
}
|
||||
|
||||
public void setLeader(UUID newPartyLeader) {
|
||||
this.partyMemberManager = ;
|
||||
}
|
||||
|
||||
public void setPartyPassword(String partyPassword) {
|
||||
this.partyPassword = partyPassword;
|
||||
}
|
||||
|
||||
public void setPartyLock(boolean partyLock) {
|
||||
this.partyLock = partyLock;
|
||||
}
|
||||
|
||||
public boolean hasMember(Player player) {
|
||||
return hasMember(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean hasMember(OfflinePlayer offlinePlayer) {
|
||||
return hasMember(offlinePlayer.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean hasMember(UUID playerUUID) {
|
||||
for(PartyMember partyMember : getPartyMembers()) {
|
||||
if(partyMember.getUniqueId().equals(player.getUniqueId()))
|
||||
if(partyMember.getUniqueId().equals(playerUUID))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasMember(String playerName) {
|
||||
for(PartyMember partyMember : getPartyMembers()) {
|
||||
if(partyMember.getName().equalsIgnoreCase(playerName))
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -78,15 +82,7 @@ public class Party {
|
||||
public String createMembersList(Player player) {
|
||||
/* BUILD THE PARTY LIST WITH FORMATTING */
|
||||
boolean useDisplayNames = Config.getInstance().getPartyDisplayNames();
|
||||
|
||||
StringBuilder formattedPartyMemberList = new StringBuilder();
|
||||
|
||||
PartyMember partyLeader = getLeader();
|
||||
|
||||
//First add the party leader
|
||||
memberList.append(PARTY_LEADER_PREFIX);
|
||||
|
||||
return memberList.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,10 +114,14 @@ public class Party {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Party party = (Party) o;
|
||||
return Objects.equal(persistentPartyData, party.persistentPartyData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ;
|
||||
return Objects.hashCode(persistentPartyData);
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
public class PartyAllianceManager {
|
||||
private Party ally;
|
||||
private Party allianceInvite;
|
||||
|
||||
public void setPartyAllianceInvite(Party allianceInvite) {
|
||||
this.allianceInvite = allianceInvite;
|
||||
}
|
||||
|
||||
public Party getPartyAllianceInvite() {
|
||||
return allianceInvite;
|
||||
}
|
||||
|
||||
public boolean hasPartyAllianceInvite() {
|
||||
return (allianceInvite != null);
|
||||
}
|
||||
|
||||
public void removePartyAllianceInvite() {
|
||||
allianceInvite = null;
|
||||
}
|
||||
|
||||
public void setAlly(Party ally) {
|
||||
this.ally = ally;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.commands.party.PartySubCommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@ -23,22 +23,22 @@ public enum PartyFeature {
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player) {
|
||||
PartySubcommandType partySubCommandType;
|
||||
PartySubCommandType partySubCommandType;
|
||||
switch (this) {
|
||||
case CHAT:
|
||||
partySubCommandType = PartySubcommandType.CHAT;
|
||||
partySubCommandType = PartySubCommandType.CHAT;
|
||||
break;
|
||||
case TELEPORT:
|
||||
partySubCommandType = PartySubcommandType.TELEPORT;
|
||||
partySubCommandType = PartySubCommandType.TELEPORT;
|
||||
break;
|
||||
case ALLIANCE:
|
||||
partySubCommandType = PartySubcommandType.ALLIANCE;
|
||||
partySubCommandType = PartySubCommandType.ALLIANCE;
|
||||
break;
|
||||
case ITEM_SHARE:
|
||||
partySubCommandType = PartySubcommandType.ITEMSHARE;
|
||||
partySubCommandType = PartySubCommandType.ITEMSHARE;
|
||||
break;
|
||||
case XP_SHARE:
|
||||
partySubCommandType = PartySubcommandType.XPSHARE;
|
||||
partySubCommandType = PartySubCommandType.XPSHARE;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -7,37 +8,49 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyMember {
|
||||
private final OfflinePlayer offlinePlayer;
|
||||
private PartyMemberRank partyMemberRank;
|
||||
private final PartyTeleportRecord partyTeleportRecord;
|
||||
|
||||
private String playerName;
|
||||
private final @NotNull UUID playerUUID;
|
||||
private @Nullable OfflinePlayer offlinePlayer;
|
||||
private @NotNull PartyMemberRank partyMemberRank;
|
||||
private @Nullable PartyTeleportRecord partyTeleportRecord;
|
||||
private int itemShareModifier;
|
||||
|
||||
public PartyMember(OfflinePlayer offlinePlayer, PartyMemberRank partyMemberRank) {
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
public PartyMember(@NotNull UUID playerUUID, @NotNull PartyMemberRank partyMemberRank) {
|
||||
this.playerUUID = playerUUID;
|
||||
this.partyMemberRank = partyMemberRank;
|
||||
this.partyTeleportRecord = new PartyTeleportRecord();
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer() {
|
||||
if(offlinePlayer == null)
|
||||
offlinePlayer = Bukkit.getOfflinePlayer(playerUUID);
|
||||
|
||||
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
public PartyMemberRank getPartyMemberRank() {
|
||||
public @NotNull PartyMemberRank getPartyMemberRank() {
|
||||
return partyMemberRank;
|
||||
}
|
||||
|
||||
public void setPartyMemberRank(PartyMemberRank partyMemberRank) {
|
||||
public void setPartyMemberRank(@NotNull PartyMemberRank partyMemberRank) {
|
||||
this.partyMemberRank = partyMemberRank;
|
||||
}
|
||||
|
||||
public @NotNull UUID getUniqueId() {
|
||||
return offlinePlayer.getUniqueId();
|
||||
return playerUUID;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return offlinePlayer.getName();
|
||||
if(playerName == null) {
|
||||
if(getOfflinePlayer().getName() != null)
|
||||
playerName = getOfflinePlayer().getName();
|
||||
}
|
||||
|
||||
if(playerName == null)
|
||||
return playerUUID.toString();
|
||||
else
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public int getItemShareModifier() {
|
||||
@ -52,7 +65,7 @@ public class PartyMember {
|
||||
itemShareModifier = Math.max(10, modifier);
|
||||
}
|
||||
|
||||
public PartyTeleportRecord getPartyTeleportRecord() {
|
||||
public @Nullable PartyTeleportRecord getPartyTeleportRecord() {
|
||||
return partyTeleportRecord;
|
||||
}
|
||||
|
||||
|
@ -4,47 +4,19 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class PartyMemberManager {
|
||||
private final @NotNull Map<String, PartyMember> partyMembers;
|
||||
private @NotNull PartyMember partyLeaderRef;
|
||||
private final @NotNull HashSet<PartyMember> partyOfficers;
|
||||
|
||||
public PartyMemberManager(@NotNull HashSet<PartyMember> partyMembers) {
|
||||
this.partyMembers = partyMembers;
|
||||
private final @NotNull PersistentPartyData persistentPartyData;
|
||||
|
||||
public PartyMemberManager(@NotNull PersistentPartyData persistentPartyData, @NotNull HashSet<PartyMember> partyMembers) {
|
||||
this.persistentPartyData = persistentPartyData;
|
||||
}
|
||||
|
||||
public PartyMemberManager(@NotNull Player partyLeader) {
|
||||
addPartyMember(partyLeader, PartyMemberRank.LEADER);
|
||||
}
|
||||
|
||||
public @NotNull Collection<PartyMember> getPartyMembers() {
|
||||
return partyMembers.values();
|
||||
}
|
||||
|
||||
private void registerSpecialPartyMembers() {
|
||||
clearOfficers();
|
||||
|
||||
for(PartyMember partyMember : partyMembers) {
|
||||
switch (partyMember.getPartyMemberRank()) {
|
||||
|
||||
case MEMBER:
|
||||
break;
|
||||
case OFFICER:
|
||||
partyOfficers.add(partyMember);
|
||||
break;
|
||||
case LEADER:
|
||||
partyLeaderRef = partyMember;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clearOfficers() {
|
||||
partyOfficers.clear();
|
||||
public @NotNull Set<PartyMember> getPartyMembers() {
|
||||
return persistentPartyData.getPartyMembers();
|
||||
}
|
||||
|
||||
public void addPartyMember(OfflinePlayer player, PartyMemberRank partyMemberRank) {
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.dirtydata.DirtyData;
|
||||
import com.gmail.nossr50.datatypes.dirtydata.DirtyDataSet;
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableBoolean;
|
||||
import com.gmail.nossr50.datatypes.mutableprimitives.MutableString;
|
||||
import com.google.common.base.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PersistentPartyData {
|
||||
|
||||
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
|
||||
private final @NotNull DirtyData<MutableString> partyName;
|
||||
private final @NotNull DirtyDataSet<PartyMember> partyMembers; //TODO: Add cache for subsets
|
||||
|
||||
public PersistentPartyData(@NotNull String partyName,
|
||||
@NotNull Set<PartyMember> partyMembers) {
|
||||
dirtyFlag = new MutableBoolean(false);
|
||||
this.partyName = new DirtyData<>(new MutableString(partyName), dirtyFlag);
|
||||
this.partyMembers = new DirtyDataSet<>(new HashSet<>(partyMembers), dirtyFlag);
|
||||
}
|
||||
|
||||
public String getPartyName() {
|
||||
return partyName.getData().getImmutableCopy();
|
||||
}
|
||||
|
||||
public Set<PartyMember> getPartyMembers() {
|
||||
return partyMembers.getDataSet();
|
||||
}
|
||||
|
||||
public boolean isDataDirty() {
|
||||
return dirtyFlag.getImmutableCopy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersistentPartyData that = (PersistentPartyData) o;
|
||||
return Objects.equal(getPartyName(), that.getPartyName()) &&
|
||||
Objects.equal(getPartyMembers(), that.getPartyMembers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getPartyName(), getPartyMembers());
|
||||
}
|
||||
}
|
@ -25,6 +25,8 @@ import java.util.UUID;
|
||||
|
||||
public class PersistentPlayerData {
|
||||
|
||||
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
|
||||
|
||||
/* Player Stuff */
|
||||
private final @NotNull DirtyData<MutableString> playerName;
|
||||
private final @NotNull UUID playerUUID;
|
||||
@ -34,7 +36,6 @@ public class PersistentPlayerData {
|
||||
|
||||
/* HUDs */
|
||||
private final @NotNull DirtyData<MobHealthBarType> mobHealthBarType;
|
||||
private final @NotNull MutableBoolean dirtyFlag; //Dirty values in this class will change this flag as needed
|
||||
|
||||
/* Skill Data */
|
||||
private final @NotNull DirtyDataMap<PrimarySkillType, Integer> skillLevelValues;
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthBarType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -134,6 +137,10 @@ public class PlayerProfile {
|
||||
return cooldownManager;
|
||||
}
|
||||
|
||||
public @Nullable Party getParty(){
|
||||
return mcMMO.getPartyManager().getParty(persistentPlayerData.getPlayerUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this player is excluded from leaderboards
|
||||
* @return true if the player is excluded from leaderboards
|
||||
|
@ -5,7 +5,6 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyMember;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
@ -120,29 +121,6 @@ public final class PartyManager {
|
||||
return firstParty.equals(secondParty);
|
||||
}
|
||||
|
||||
public boolean areAllies(Player firstPlayer, Player secondPlayer) {
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().getPlayer(firstPlayer) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().getPlayer(secondPlayer) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = mcMMO.getUserManager().getPlayer(firstPlayer).getParty();
|
||||
Party secondParty = mcMMO.getUserManager().getPlayer(secondPlayer).getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null || firstParty.getAlly() == null || secondParty.getAlly() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return firstParty.equals(secondParty.getAlly()) && secondParty.equals(firstParty.getAlly());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the near party members.
|
||||
*
|
||||
@ -157,7 +135,7 @@ public final class PartyManager {
|
||||
Player player = mmoPlayer.getPlayer();
|
||||
double range = Config.getInstance().getPartyShareRange();
|
||||
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
for (PartyMember member : party.getPartyMembers()) {
|
||||
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
nearMembers.add(member);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.commands.party.PartySubCommandType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemType;
|
||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
@ -206,7 +206,7 @@ public final class Permissions {
|
||||
*/
|
||||
public static boolean partySizeBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.partylimit" ); }
|
||||
public static boolean party(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.party"); }
|
||||
public static boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) { return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase(Locale.ENGLISH)); }
|
||||
public static boolean partySubcommand(Permissible permissible, PartySubCommandType subcommand) { return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase(Locale.ENGLISH)); }
|
||||
public static boolean friendlyFire(Permissible permissible) { return permissible.hasPermission("mcmmo.party.friendlyfire"); }
|
||||
|
||||
/* TELEPORT */
|
||||
|
@ -1081,15 +1081,9 @@ permissions:
|
||||
mcmmo.commands.party.invite: true
|
||||
mcmmo.commands.party.itemshare: true
|
||||
mcmmo.commands.party.join: true
|
||||
mcmmo.commands.party.kick: true
|
||||
mcmmo.commands.party.lock: true
|
||||
mcmmo.commands.party.owner: true
|
||||
mcmmo.commands.party.password: true
|
||||
mcmmo.commands.party.quit: true
|
||||
mcmmo.commands.party.rename: true
|
||||
mcmmo.commands.party.teleport: true
|
||||
mcmmo.commands.party.unlock: true
|
||||
mcmmo.commands.party.alliance: true
|
||||
mcmmo.commands.party:
|
||||
description: Allows access to the party command
|
||||
mcmmo.commands.party.accept:
|
||||
@ -1098,6 +1092,7 @@ permissions:
|
||||
description: Dummy permission for mcmmo.chat.partychat
|
||||
children:
|
||||
mcmmo.chat.partychat: true
|
||||
mcmmo.chat.officerpartychat: true
|
||||
mcmmo.commands.party.create:
|
||||
description: Allows access to the party create command
|
||||
mcmmo.commands.party.disband:
|
||||
@ -1114,26 +1109,14 @@ permissions:
|
||||
description: Allows access to the party itemshare command
|
||||
mcmmo.commands.party.join:
|
||||
description: Allows access to the party join command
|
||||
mcmmo.commands.party.kick:
|
||||
description: Allows access to the party kick command
|
||||
mcmmo.commands.party.lock:
|
||||
description: Allows access to the party lock command
|
||||
mcmmo.commands.party.owner:
|
||||
description: Allows access to the party owner command
|
||||
mcmmo.commands.party.password:
|
||||
description: Allows access to the party password command
|
||||
mcmmo.commands.party.quit:
|
||||
description: Allows access to the party quit command
|
||||
mcmmo.commands.party.rename:
|
||||
description: Allows access to the party rename command
|
||||
mcmmo.commands.party.teleport:
|
||||
description: Dummy permission for mcmmo.commands.ptp
|
||||
children:
|
||||
mcmmo.commands.ptp: true
|
||||
mcmmo.commands.party.unlock:
|
||||
description: Allows access to the party unlock command
|
||||
mcmmo.commands.party.alliance:
|
||||
description: Allows access to the party alliance command
|
||||
mcmmo.commands.ptp.*:
|
||||
default: false
|
||||
description: Implies access to all mcmmo.commands.ptp permissions.
|
||||
|
Loading…
Reference in New Issue
Block a user