mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
More work on parties
This commit is contained in:
parent
393ac886e2
commit
cbaf2f8370
@ -12,6 +12,7 @@ Version 1.3.09
|
|||||||
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
|
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
|
||||||
+ Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
|
+ Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
|
||||||
+ Added offline party members to the list displayed by /party
|
+ Added offline party members to the list displayed by /party
|
||||||
|
+ Added possibility to kick offline members from parties
|
||||||
= Fixed /mcremove being applied only after a reload
|
= Fixed /mcremove being applied only after a reload
|
||||||
= Fixed Archery PVE disablement not working properly
|
= Fixed Archery PVE disablement not working properly
|
||||||
= Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter
|
= Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter
|
||||||
|
@ -68,7 +68,7 @@ public final class PartyAPI {
|
|||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
*/
|
*/
|
||||||
public static void addToParty(Player player, String partyName) {
|
public static void addToParty(Player player, String partyName) {
|
||||||
PartyManager.getInstance().addToParty(player, Users.getProfile(player), partyName, null);
|
PartyManager.getInstance().addToParty(player.getName(), Users.getProfile(player), PartyManager.getInstance().getParty(partyName)); //TODO this will throw a NPE if the party doesn't exist
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +79,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to remove
|
* @param player The player to remove
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(Player player) {
|
public static void removeFromParty(Player player) {
|
||||||
PartyManager.getInstance().removeFromParty(player, Users.getProfile(player));
|
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +103,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to set as leader
|
* @param player The player to set as leader
|
||||||
*/
|
*/
|
||||||
public static void setPartyLeader(String partyName, String player) {
|
public static void setPartyLeader(String partyName, String player) {
|
||||||
PartyManager.getInstance().setPartyLeader(partyName, player);
|
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -32,23 +33,25 @@ public class AcceptCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
if (PP.hasPartyInvite()) {
|
if (playerProfile.hasPartyInvite()) {
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
PartyManager partyManagerInstance = PartyManager.getInstance();
|
||||||
|
|
||||||
if (PP.inParty()) {
|
if (playerProfile.inParty()) {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty().getName(), PP.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
Party party = playerProfile.getParty();
|
||||||
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(player, PP);
|
partyManagerInstance.removeFromParty(player.getName(), party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite().getName(), EventReason.JOINED_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
@ -56,7 +59,7 @@ public class AcceptCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.addToInvitedParty(player, PP, PP.getInvite());
|
partyManagerInstance.joinInvitedParty(player, playerProfile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.commands.party;
|
package com.gmail.nossr50.commands.party;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -49,15 +51,22 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String tempList = ChatColor.GOLD + party.getLeader() + " ";
|
Server server = plugin.getServer();
|
||||||
|
String leader = party.getLeader();
|
||||||
|
StringBuffer tempList = new StringBuffer();
|
||||||
|
|
||||||
for (String otherPlayerName : party.getMembers()) {
|
for (String otherPlayerName : party.getMembers()) {
|
||||||
if (plugin.getServer().getPlayer(otherPlayerName) == null) {
|
if (leader.equals(otherPlayerName)) {
|
||||||
tempList += ChatColor.GRAY + otherPlayerName + " ";
|
tempList.append(ChatColor.GOLD);
|
||||||
}
|
}
|
||||||
else if (!party.getLeader().equals(otherPlayerName)){
|
else if (server.getPlayer(otherPlayerName) != null) {
|
||||||
tempList += ChatColor.WHITE + otherPlayerName + " ";
|
tempList.append(ChatColor.WHITE);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
tempList.append(ChatColor.GRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
tempList.append(otherPlayerName + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
|
||||||
@ -76,7 +85,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(player, playerProfile);
|
partyManagerInstance.removeFromParty(playerName, party);
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -138,7 +147,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(player, playerProfile);
|
partyManagerInstance.removeFromParty(playerName, party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
|
||||||
@ -149,7 +158,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.addToParty(player, playerProfile, args[0], null);
|
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -168,33 +177,23 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("kick")) {
|
else if (args[0].equalsIgnoreCase("kick")) {
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
//TODO allow to kick offline players
|
List<String> members = party.getMembers();
|
||||||
Player target = plugin.getServer().getPlayer(args[1]);
|
|
||||||
|
|
||||||
if (target == null) {
|
if (!members.contains(args[1])) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile otherPlayerProfile = Users.getProfile(target);
|
|
||||||
String targetName = target.getName();
|
|
||||||
|
|
||||||
if (!partyManagerInstance.inSameParty(player, target)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {targetName}));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
String partyName = party.getName();
|
String partyName = party.getName();
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(target, otherPlayerProfile);
|
partyManagerInstance.removeFromParty(args[1], party);
|
||||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] {partyName}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -203,28 +202,16 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("owner")) {
|
else if (args[0].equalsIgnoreCase("owner")) {
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
//TODO allow to set the ownership to offline players
|
List<String> members = party.getMembers();
|
||||||
OfflinePlayer target = plugin.getServer().getOfflinePlayer(args[1]);
|
|
||||||
|
|
||||||
if (target == null) {
|
if (!members.contains(args[1])) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String targetName = target.getName();
|
|
||||||
|
|
||||||
if (!partyManagerInstance.inSameParty(player, target)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {targetName}));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
partyManagerInstance.setPartyLeader(party.getName(), targetName);
|
partyManagerInstance.setPartyLeader(args[1], party);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
|
||||||
@ -234,8 +221,8 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(player, playerProfile);
|
partyManagerInstance.removeFromParty(playerName, party);
|
||||||
partyManagerInstance.addToParty(player, playerProfile, args[0], args[1]);
|
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -246,7 +233,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.addToParty(player, playerProfile, args[0], args[1]);
|
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,10 +4,8 @@ import java.io.BufferedReader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -55,41 +53,16 @@ public class PartyManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if two 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(OfflinePlayer firstPlayer, OfflinePlayer secondPlayer) {
|
|
||||||
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
|
||||||
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
|
||||||
|
|
||||||
if (firstProfile == null || secondProfile == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Party firstParty = firstProfile.getParty();
|
|
||||||
Party secondParty = secondProfile.getParty();
|
|
||||||
|
|
||||||
if (firstParty == null || secondParty == null || firstParty != secondParty) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify party members when a player joins
|
* Notify party members when a player joins
|
||||||
*
|
*
|
||||||
* @param player The player that joins
|
* @param playerName The name of the player that joins
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private void informPartyMembersJoin(Player player, Party party) {
|
private void informPartyMembersJoin(String playerName, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (member != player) {
|
if (member.getName().equals(playerName)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {player.getName()}));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,13 +70,13 @@ public class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Notify party members when a party member quits.
|
* Notify party members when a party member quits.
|
||||||
*
|
*
|
||||||
* @param player The player that quits
|
* @param playerName The name of the player that quits
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private void informPartyMembersQuit(Player player, Party party) {
|
private void informPartyMembersQuit(String playerName, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (member != player) {
|
if (member.getName().equals(playerName)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {player.getName()}));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +91,7 @@ public class PartyManager {
|
|||||||
Party party = Users.getProfile(player).getParty();
|
Party party = Users.getProfile(player).getParty();
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
return Collections.emptyList();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return party.getMembers();
|
return party.getMembers();
|
||||||
@ -221,31 +194,31 @@ public class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Remove a player from a party.
|
* Remove a player from a party.
|
||||||
*
|
*
|
||||||
* @param player The player to remove
|
* @param playerName The name of the player to remove
|
||||||
* @param playerProfile The profile of the player to remove
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public void removeFromParty(Player player, PlayerProfile playerProfile) {
|
public void removeFromParty(String playerName, Party party) {
|
||||||
String playerName = player.getName();
|
|
||||||
Party party = playerProfile.getParty();
|
|
||||||
List<String> members = party.getMembers();
|
List<String> members = party.getMembers();
|
||||||
|
|
||||||
if (members.contains(playerName)) {
|
|
||||||
members.remove(playerName);
|
members.remove(playerName);
|
||||||
|
|
||||||
if (members.isEmpty()) {
|
if (members.isEmpty()) {
|
||||||
parties.remove(party);
|
parties.remove(party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (party.getLeader().equals(playerName) && party.isLocked()) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
party.setLocked(false);
|
party.setLocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
informPartyMembersQuit(player, party);
|
informPartyMembersQuit(playerName, party);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerProfile playerProfile = Users.getProfile(playerName);
|
||||||
|
|
||||||
|
if (playerProfile != null) {
|
||||||
playerProfile.removeParty();
|
playerProfile.removeParty();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a player to a party.
|
* Add a player to a party.
|
||||||
@ -255,7 +228,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
* @param password the password for this party, null if there was no password
|
* @param password the password for this party, null if there was no password
|
||||||
*/
|
*/
|
||||||
public void addToParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
public void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||||
partyName = partyName.replace(".", "");
|
partyName = partyName.replace(".", "");
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
@ -273,7 +246,24 @@ public class PartyManager {
|
|||||||
|
|
||||||
parties.add(party);
|
parties.add(party);
|
||||||
}
|
}
|
||||||
else {
|
else if (!checkJoinability(player, playerProfile, party, password)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{party.getName()}));
|
||||||
|
addToParty(player.getName(), playerProfile, party);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player can join a party
|
||||||
|
*
|
||||||
|
* @param player The player trying to join a party
|
||||||
|
* @param playerProfile The profile of the player
|
||||||
|
* @param party The party
|
||||||
|
* @param password The password provided by the player
|
||||||
|
* @return true if the player can join the party
|
||||||
|
*/
|
||||||
|
private boolean checkJoinability(Player player, PlayerProfile playerProfile, Party party, String password) {
|
||||||
//Don't care about passwords if it isn't locked
|
//Don't care about passwords if it isn't locked
|
||||||
if (party.isLocked()) {
|
if (party.isLocked()) {
|
||||||
String partyPassword = party.getPassword();
|
String partyPassword = party.getPassword();
|
||||||
@ -281,24 +271,20 @@ public class PartyManager {
|
|||||||
if (partyPassword != null) {
|
if (partyPassword != null) {
|
||||||
if (password == null) {
|
if (password == null) {
|
||||||
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
|
player.sendMessage("This party requires a password. Use /party <party> <password> to join it."); //TODO: Needs more locale.
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!password.equalsIgnoreCase(partyPassword)) {
|
else if (!password.equals(partyPassword)) {
|
||||||
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
|
player.sendMessage("Party password incorrect."); //TODO: Needs more locale.
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage("Party is locked."); //TODO: Needs more locale.
|
player.sendMessage("Party is locked."); //TODO: Needs more locale.
|
||||||
return;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{partyName}));
|
return true;
|
||||||
informPartyMembersJoin(player, party);
|
|
||||||
playerProfile.setParty(party);
|
|
||||||
party.getMembers().add(player.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,18 +292,30 @@ public class PartyManager {
|
|||||||
*
|
*
|
||||||
* @param player The player to add to the party
|
* @param player The player to add to the party
|
||||||
* @param playerProfile The profile of the player
|
* @param playerProfile The profile of the player
|
||||||
* @param party The party
|
|
||||||
*/
|
*/
|
||||||
public void addToInvitedParty(Player player, PlayerProfile playerProfile, Party party) {
|
public void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
||||||
if (!parties.contains(party)) {
|
Party invite = playerProfile.getInvite();
|
||||||
parties.add(party);
|
|
||||||
|
if (!parties.contains(invite)) {
|
||||||
|
parties.add(invite);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{party.getName()}));
|
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{invite.getName()}));
|
||||||
informPartyMembersJoin(player, party);
|
|
||||||
playerProfile.removeInvite();
|
playerProfile.removeInvite();
|
||||||
|
addToParty(player.getName(), playerProfile, invite);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a player to a party
|
||||||
|
*
|
||||||
|
* @param playerName The name of the player to add to a party
|
||||||
|
* @param playerProfile The profile of the player
|
||||||
|
* @param party The party
|
||||||
|
*/
|
||||||
|
public void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
||||||
|
informPartyMembersJoin(playerName, party);
|
||||||
playerProfile.setParty(party);
|
playerProfile.setParty(party);
|
||||||
party.getMembers().add(player.getName());
|
party.getMembers().add(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,16 +337,10 @@ public class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Set the leader of a party.
|
* Set the leader of a party.
|
||||||
*
|
*
|
||||||
* @param partyName The party name
|
|
||||||
* @param playerName The name of the player to set as leader
|
* @param playerName The name of the player to set as leader
|
||||||
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public void setPartyLeader(String partyName, String playerName) {
|
public void setPartyLeader(String playerName, Party party) {
|
||||||
Party party = getParty(partyName);
|
|
||||||
|
|
||||||
if (party == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String leaderName = party.getLeader();
|
String leaderName = party.getLeader();
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
@ -371,7 +363,7 @@ public class PartyManager {
|
|||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @param playerProfile The profile of the given player
|
* @param playerProfile The profile of the given player
|
||||||
* @return true if the player can invite, false otherwise
|
* @return true if the player can invite
|
||||||
*/
|
*/
|
||||||
public boolean canInvite(Player player, PlayerProfile playerProfile) {
|
public boolean canInvite(Player player, PlayerProfile playerProfile) {
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
Loading…
Reference in New Issue
Block a user