mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Party now store OfflinePlayer instead of String
This commit is contained in:
parent
74df4a4fb6
commit
c659f8a9a9
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.api;
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
@ -69,15 +71,14 @@ public final class PartyAPI {
|
|||||||
*/
|
*/
|
||||||
public static void addToParty(Player player, String partyName) {
|
public static void addToParty(Player player, String partyName) {
|
||||||
Party party = PartyManager.getParty(partyName);
|
Party party = PartyManager.getParty(partyName);
|
||||||
String playerName = player.getName();
|
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
party = new Party();
|
party = new Party();
|
||||||
party.setName(partyName);
|
party.setName(partyName);
|
||||||
party.setLeader(playerName);
|
party.setLeader(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.addToParty(playerName, Users.getPlayer(player), party);
|
PartyManager.addToParty(player, Users.getPlayer(player), party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +89,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.removeFromParty(player.getName(), Users.getPlayer(player).getParty());
|
PartyManager.removeFromParty(player, Users.getPlayer(player).getParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,9 +123,18 @@ public final class PartyAPI {
|
|||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
// TODO: I naively tried to add another getAllMembers that returns a List<OffflinePlayer>, but that wasn't possible
|
||||||
|
// since the return type isn't part of the the method's signature. If anybody has an idea...
|
||||||
public static List<String> getAllMembers(Player player) {
|
public static List<String> getAllMembers(Player player) {
|
||||||
return PartyManager.getAllMembers(player);
|
List<String> memberNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (OfflinePlayer member : PartyManager.getAllMembers(player)) {
|
||||||
|
memberNames.add(member.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return memberNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,12 +3,11 @@ package com.gmail.nossr50.party;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
|
|
||||||
public class Party {
|
public class Party {
|
||||||
private List<String> members = new ArrayList<String>();
|
private List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
|
||||||
private String leader;
|
private String leader;
|
||||||
private String name;
|
private String name;
|
||||||
private String password;
|
private String password;
|
||||||
@ -16,17 +15,16 @@ public class Party {
|
|||||||
private ShareHandler.ShareMode xpShareMode;
|
private ShareHandler.ShareMode xpShareMode;
|
||||||
private ShareHandler.ShareMode itemShareMode;
|
private ShareHandler.ShareMode itemShareMode;
|
||||||
|
|
||||||
public List<String> getMembers() {
|
public List<OfflinePlayer> getMembers() {
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> getOnlineMembers() {
|
public List<Player> getOnlineMembers() {
|
||||||
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
|
|
||||||
List<Player> onlineMembers = new ArrayList<Player>();
|
List<Player> onlineMembers = new ArrayList<Player>();
|
||||||
|
|
||||||
for (Player onlinePlayer : onlinePlayers) {
|
for (OfflinePlayer member : members) {
|
||||||
if (members.contains(onlinePlayer.getName())) {
|
if (member.isOnline()) {
|
||||||
onlineMembers.add(onlinePlayer);
|
onlineMembers.add(member.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.Server;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -27,7 +29,7 @@ public final class PartyManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFromParty(player.getName(), oldParty);
|
removeFromParty(player, oldParty);
|
||||||
}
|
}
|
||||||
else if (!handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY)) {
|
else if (!handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY)) {
|
||||||
return false;
|
return false;
|
||||||
@ -83,13 +85,13 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Notify party members when a player joins
|
* Notify party members when a player joins
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player that joins
|
* @param player The player that joins
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private static void informPartyMembersJoin(String playerName, Party party) {
|
private static void informPartyMembersJoin(OfflinePlayer player, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!member.getName().equals(playerName)) {
|
if (!member.equals(player)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,13 +99,13 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Notify party members when a party member quits.
|
* Notify party members when a party member quits.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player that quits
|
* @param player The player that quits
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private static void informPartyMembersQuit(String playerName, Party party) {
|
private static void informPartyMembersQuit(OfflinePlayer player, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!member.getName().equals(playerName)) {
|
if (!member.equals(player)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +116,7 @@ public final class PartyManager {
|
|||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
*/
|
*/
|
||||||
public static List<String> getAllMembers(Player player) {
|
public static List<OfflinePlayer> getAllMembers(Player player) {
|
||||||
Party party = Users.getPlayer(player).getParty();
|
Party party = Users.getPlayer(player).getParty();
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@ -193,28 +195,28 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Remove a player from a party.
|
* Remove a player from a party.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to remove
|
* @param player The player to remove
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(String playerName, Party party) {
|
public static void removeFromParty(OfflinePlayer player, Party party) {
|
||||||
List<String> members = party.getMembers();
|
List<OfflinePlayer> members = party.getMembers();
|
||||||
|
|
||||||
members.remove(playerName);
|
members.remove(player);
|
||||||
|
|
||||||
if (members.isEmpty()) {
|
if (members.isEmpty()) {
|
||||||
parties.remove(party);
|
parties.remove(party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//If the leaving player was the party leader, appoint a new leader from the party members
|
//If the leaving player was the party leader, appoint a new leader from the party members
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(player)) {
|
||||||
String newLeader = members.get(0);
|
String newLeader = members.get(0).toString();
|
||||||
party.setLeader(newLeader);
|
party.setLeader(newLeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
informPartyMembersQuit(playerName, party);
|
informPartyMembersQuit(player, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(playerName);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(player.getName());
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
mcMMOPlayer.removeParty();
|
mcMMOPlayer.removeParty();
|
||||||
@ -227,11 +229,10 @@ public final class PartyManager {
|
|||||||
* @param party The party to remove
|
* @param party The party to remove
|
||||||
*/
|
*/
|
||||||
public static void disbandParty(Party party) {
|
public static void disbandParty(Party party) {
|
||||||
List<String> members = party.getMembers();
|
List<OfflinePlayer> members = party.getMembers();
|
||||||
|
|
||||||
for (String member : party.getMembers()) {
|
for (OfflinePlayer member : members) {
|
||||||
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(member.getName());
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(member);
|
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
mcMMOPlayer.removeParty();
|
mcMMOPlayer.removeParty();
|
||||||
@ -239,9 +240,7 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
members.clear();
|
members.clear();
|
||||||
if (members.isEmpty()) {
|
parties.remove(party);
|
||||||
parties.remove(party);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,21 +254,21 @@ public final class PartyManager {
|
|||||||
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||||
partyName = partyName.replace(".", "");
|
partyName = partyName.replace(".", "");
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
String playerName = player.getName();
|
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
party = new Party();
|
party = new Party();
|
||||||
|
|
||||||
party.setName(partyName);
|
party.setName(partyName);
|
||||||
party.setLeader(playerName);
|
party.setLeader(player.getName());
|
||||||
party.setXpShareMode(ShareHandler.ShareMode.NONE);
|
party.setXpShareMode(ShareHandler.ShareMode.NONE);
|
||||||
party.setLocked(true);//Parties are now invite-only by default, can be set to open with /party unlock
|
party.setLocked(true); // Parties are now invite-only by default, can be set to open with /party unlock
|
||||||
|
|
||||||
if (password != null) {
|
if (password != null) {
|
||||||
party.setPassword(password);
|
party.setPassword(password);
|
||||||
party.setLocked(true);
|
party.setLocked(true);
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
|
player.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
|
||||||
}
|
}
|
||||||
|
|
||||||
parties.add(party);
|
parties.add(party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -278,7 +277,7 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
||||||
addToParty(player.getName(), mcMMOPlayer, party);
|
addToParty(player, mcMMOPlayer, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,13 +291,12 @@ public final class PartyManager {
|
|||||||
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||||
partyName = partyName.replace(".", "");
|
partyName = partyName.replace(".", "");
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
String playerName = player.getName();
|
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
party = new Party();
|
party = new Party();
|
||||||
|
|
||||||
party.setName(partyName);
|
party.setName(partyName);
|
||||||
party.setLeader(playerName);
|
party.setLeader(player.getName());
|
||||||
|
|
||||||
if (password != null) {
|
if (password != null) {
|
||||||
party.setPassword(password);
|
party.setPassword(password);
|
||||||
@ -312,7 +310,7 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
|
||||||
addToParty(player.getName(), mcMMOPlayer, party);
|
addToParty(player, mcMMOPlayer, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,7 +322,7 @@ public final class PartyManager {
|
|||||||
* @return true if the player can join the party
|
* @return true if the player can join the party
|
||||||
*/
|
*/
|
||||||
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
public static boolean checkPartyPassword(Player player, 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();
|
||||||
|
|
||||||
@ -362,20 +360,20 @@ public final class PartyManager {
|
|||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
|
||||||
mcMMOPlayer.removePartyInvite();
|
mcMMOPlayer.removePartyInvite();
|
||||||
addToParty(player.getName(), mcMMOPlayer, invite);
|
addToParty(player, mcMMOPlayer, invite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a player to a party
|
* Add a player to a party
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to add to a party
|
* @param player The player to add to a party
|
||||||
* @param mcMMOPlayer The player to add to the party
|
* @param mcMMOPlayer The player to add to the party
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public static void addToParty(String playerName, McMMOPlayer mcMMOPlayer, Party party) {
|
public static void addToParty(OfflinePlayer player, McMMOPlayer mcMMOPlayer, Party party) {
|
||||||
informPartyMembersJoin(playerName, party);
|
informPartyMembersJoin(player, party);
|
||||||
mcMMOPlayer.setParty(party);
|
mcMMOPlayer.setParty(party);
|
||||||
party.getMembers().add(playerName);
|
party.getMembers().add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -476,7 +474,14 @@ public final class PartyManager {
|
|||||||
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
|
||||||
party.setXpShareMode(ShareHandler.ShareMode.getFromString(partiesFile.getString(partyName + ".ExpShareMode")));
|
party.setXpShareMode(ShareHandler.ShareMode.getFromString(partiesFile.getString(partyName + ".ExpShareMode")));
|
||||||
party.setItemShareMode(ShareHandler.ShareMode.getFromString(partiesFile.getString(partyName + ".ItemShareMode")));
|
party.setItemShareMode(ShareHandler.ShareMode.getFromString(partiesFile.getString(partyName + ".ItemShareMode")));
|
||||||
party.getMembers().addAll(partiesFile.getStringList(partyName + ".Members"));
|
|
||||||
|
List<String> memberNames = partiesFile.getStringList(partyName + ".Members");
|
||||||
|
List<OfflinePlayer> members = party.getMembers();
|
||||||
|
Server server = mcMMO.p.getServer();
|
||||||
|
|
||||||
|
for (String memberName : memberNames) {
|
||||||
|
members.add(server.getOfflinePlayer(memberName));
|
||||||
|
}
|
||||||
|
|
||||||
parties.add(party);
|
parties.add(party);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.party.commands;
|
package com.gmail.nossr50.party.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.OfflinePlayer;
|
||||||
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;
|
||||||
@ -115,8 +115,6 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
private boolean party() {
|
private boolean party() {
|
||||||
if (mcMMOPlayer.inParty()) {
|
if (mcMMOPlayer.inParty()) {
|
||||||
Party party = mcMMOPlayer.getParty();
|
Party party = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
Server server = mcMMO.p.getServer();
|
|
||||||
String leader = party.getLeader();
|
String leader = party.getLeader();
|
||||||
StringBuilder tempList = new StringBuilder();
|
StringBuilder tempList = new StringBuilder();
|
||||||
|
|
||||||
@ -127,17 +125,18 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
String ExpShare = "";
|
String ExpShare = "";
|
||||||
String Split = "";
|
String Split = "";
|
||||||
|
|
||||||
for (String otherPlayerName : party.getMembers()) {
|
for (OfflinePlayer otherMember : party.getMembers()) {
|
||||||
if (leader.equals(otherPlayerName)) {
|
if (leader.equals(otherMember.getName())) {
|
||||||
tempList.append(ChatColor.GOLD);
|
tempList.append(ChatColor.GOLD);
|
||||||
}
|
}
|
||||||
else if (server.getPlayer(otherPlayerName) != null) {
|
else if (otherMember.isOnline()) {
|
||||||
tempList.append(ChatColor.WHITE);
|
tempList.append(ChatColor.WHITE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tempList.append(ChatColor.GRAY);
|
tempList.append(ChatColor.GRAY);
|
||||||
}
|
}
|
||||||
tempList.append(otherPlayerName).append(" ");
|
|
||||||
|
tempList.append(otherMember).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String status = LocaleLoader.getString("Party.Status.Locked");
|
String status = LocaleLoader.getString("Party.Status.Locked");
|
||||||
@ -174,6 +173,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
else {
|
else {
|
||||||
return printUsage();
|
return printUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,16 +202,17 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
Party party = mcMMOPlayer.getParty();
|
Party party = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
if (!party.getMembers().contains(args[1])) {
|
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||||
|
|
||||||
|
if (!party.getMembers().contains(member)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player target = mcMMO.p.getServer().getOfflinePlayer(args[1]).getPlayer();
|
if (member.isOnline()) {
|
||||||
|
Player onlineMember = member.getPlayer();
|
||||||
if (target != null) {
|
|
||||||
String partyName = party.getName();
|
String partyName = party.getName();
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMember, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||||
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -219,10 +220,10 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
onlineMember.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.removeFromParty(args[1], party);
|
PartyManager.removeFromParty(member, party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
@ -285,7 +286,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
if (!party.getMembers().contains(args[1])) {
|
if (!party.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -324,6 +325,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
party.setLocked(true);
|
party.setLocked(true);
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class PartyQuitCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.removeFromParty(player.getName(), playerParty);
|
PartyManager.removeFromParty(player, playerParty);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package com.gmail.nossr50.skills.runnables;
|
package com.gmail.nossr50.skills.runnables;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
|
||||||
public class PartyAutoKick implements Runnable {
|
public class PartyAutoKick implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updatePartyMembers();
|
updatePartyMembers();
|
||||||
@ -18,14 +16,9 @@ public class PartyAutoKick implements Runnable {
|
|||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
|
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
|
||||||
|
|
||||||
ArrayList<Party> parties = new ArrayList<Party>(PartyManager.getParties());
|
for (Party party : PartyManager.getParties()) {
|
||||||
|
for (OfflinePlayer member : party.getMembers()) {
|
||||||
for (Party party : parties) {
|
if (currentTime - member.getLastPlayed() > kickTime) {
|
||||||
ArrayList<String> members = new ArrayList<String>(party.getMembers());
|
|
||||||
for (String member : members) {
|
|
||||||
long lastPlayed = mcMMO.p.getServer().getOfflinePlayer(member).getLastPlayed();
|
|
||||||
|
|
||||||
if (currentTime - lastPlayed > kickTime) {
|
|
||||||
PartyManager.removeFromParty(member, party);
|
PartyManager.removeFromParty(member, party);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user