mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Start to migrate Party API -> mcMMO-API
This commit is contained in:
parent
d044de5350
commit
602d47698a
@ -1,255 +1,255 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class PartyAPI {
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
* Get the name of the party a player is in.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check the party name of
|
||||
* @return the name of the player's party, or null if not in a party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
if (!inParty(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mcMMO.getUserManager().queryPlayer(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is in a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
return false;
|
||||
|
||||
return mcMMO.getUserManager().queryPlayer(player).inParty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return mcMMO.getPartyManager().inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current parties.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return mcMMO.getPartyManager().getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @deprecated parties can have limits, use the other method
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
//Check if player profile is loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
return;
|
||||
|
||||
Party party = mcMMO.getPartyManager().getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
} else {
|
||||
if(mcMMO.getPartyManager().isPartyFull(player, party))
|
||||
{
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
* The max party size of the server
|
||||
* 0 or less for no size limit
|
||||
* @return the max party size on this server
|
||||
*/
|
||||
public static int getMaxPartySize()
|
||||
{
|
||||
return Config.getInstance().getPartyMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param bypassLimit if true bypasses party size limits
|
||||
*/
|
||||
//TODO: bypasslimit not used?
|
||||
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
|
||||
//Check if player profile is loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
return;
|
||||
|
||||
Party party = mcMMO.getPartyManager().getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
}
|
||||
|
||||
mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
//Check if player profile is loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
return;
|
||||
|
||||
mcMMO.getPartyManager().removeFromParty(mcMMO.getUserManager().queryPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leader of a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return mcMMO.getPartyManager().getPartyLeaderName(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The name of the party to set the leader of
|
||||
* @param playerName The playerName to set as leader
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setPartyLeader(String partyName, String playerName) {
|
||||
mcMMO.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.getPartyManager().getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
List<OfflinePlayer> members = new ArrayList<>();
|
||||
|
||||
for (UUID memberUniqueId : mcMMO.getPartyManager().getAllMembers(player).keySet()) {
|
||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
|
||||
members.add(member);
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all player names in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the player names in the player's party
|
||||
*/
|
||||
@Deprecated
|
||||
public static LinkedHashSet<String> getMembers(Player player) {
|
||||
return (LinkedHashSet<String>) mcMMO.getPartyManager().getAllMembers(player).values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all player names and uuids in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the player names and uuids in the player's party
|
||||
*/
|
||||
public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
|
||||
return mcMMO.getPartyManager().getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return mcMMO.getPartyManager().getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return mcMMO.getPartyManager().getOnlineMembers(player);
|
||||
}
|
||||
|
||||
public static boolean hasAlly(String partyName) {
|
||||
return getAllyName(partyName) != null;
|
||||
}
|
||||
|
||||
public static String getAllyName(String partyName) {
|
||||
Party ally = mcMMO.getPartyManager().getParty(partyName).getAlly();
|
||||
if (ally != null) {
|
||||
return ally.getPartyName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.api;
|
||||
//
|
||||
//import com.gmail.nossr50.config.Config;
|
||||
//import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
//import com.neetgames.mcmmo.party.Party;
|
||||
//import com.gmail.nossr50.mcMMO;
|
||||
//import com.gmail.nossr50.util.player.NotificationManager;
|
||||
//import org.bukkit.OfflinePlayer;
|
||||
//import org.bukkit.entity.Player;
|
||||
//
|
||||
//import java.util.*;
|
||||
//
|
||||
//public final class PartyAPI {
|
||||
// private PartyAPI() {}
|
||||
//
|
||||
// /**
|
||||
// * Get the name of the party a player is in.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to check the party name of
|
||||
// * @return the name of the player's party, or null if not in a party
|
||||
// */
|
||||
// public static String getPartyName(Player player) {
|
||||
// if (!inParty(player)) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return mcMMO.getUserManager().queryPlayer(player).getParty().getName();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Checks if a player is in a party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to check
|
||||
// * @return true if the player is in a party, false otherwise
|
||||
// */
|
||||
// public static boolean inParty(Player player) {
|
||||
// if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
// return false;
|
||||
//
|
||||
// return mcMMO.getUserManager().queryPlayer(player).inParty();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if two players are in the same party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param playera The first player to check
|
||||
// * @param playerb The second player to check
|
||||
// * @return true if the two players are in the same party, false otherwise
|
||||
// */
|
||||
// public static boolean inSameParty(Player playera, Player playerb) {
|
||||
// return mcMMO.getPartyManager().inSameParty(playera, playerb);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get a list of all current parties.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @return the list of parties.
|
||||
// */
|
||||
// public static List<Party> getParties() {
|
||||
// return mcMMO.getPartyManager().getParties();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Add a player to a party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to add to the party
|
||||
// * @param partyName The party to add the player to
|
||||
// * @deprecated parties can have limits, use the other method
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static void addToParty(Player player, String partyName) {
|
||||
// //Check if player profile is loaded
|
||||
// if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
// return;
|
||||
//
|
||||
// Party party = mcMMO.getPartyManager().getParty(partyName);
|
||||
//
|
||||
// if (party == null) {
|
||||
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
// } else {
|
||||
// if(mcMMO.getPartyManager().isPartyFull(player, party))
|
||||
// {
|
||||
// NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * The max party size of the server
|
||||
// * 0 or less for no size limit
|
||||
// * @return the max party size on this server
|
||||
// */
|
||||
// public static int getMaxPartySize()
|
||||
// {
|
||||
// return Config.getInstance().getPartyMaxSize();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Add a player to a party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to add to the party
|
||||
// * @param partyName The party to add the player to
|
||||
// * @param bypassLimit if true bypasses party size limits
|
||||
// */
|
||||
// //TODO: bypasslimit not used?
|
||||
// public static void addToParty(Player player, String partyName, boolean bypassLimit) {
|
||||
// //Check if player profile is loaded
|
||||
// if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
// return;
|
||||
//
|
||||
// Party party = mcMMO.getPartyManager().getParty(partyName);
|
||||
//
|
||||
// if (party == null) {
|
||||
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
// }
|
||||
//
|
||||
// mcMMO.getPartyManager().addToParty(mcMMO.getUserManager().queryPlayer(player), party);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Remove a player from a party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to remove
|
||||
// */
|
||||
// public static void removeFromParty(Player player) {
|
||||
// //Check if player profile is loaded
|
||||
// if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
// return;
|
||||
//
|
||||
// mcMMO.getPartyManager().removeFromParty(mcMMO.getUserManager().queryPlayer(player));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get the leader of a party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param partyName The party name
|
||||
// * @return the leader of the party
|
||||
// */
|
||||
// public static String getPartyLeader(String partyName) {
|
||||
// return mcMMO.getPartyManager().getPartyLeaderName(partyName);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Set the leader of a party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param partyName The name of the party to set the leader of
|
||||
// * @param playerName The playerName to set as leader
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static void setPartyLeader(String partyName, String playerName) {
|
||||
// mcMMO.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.getPartyManager().getParty(partyName));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get a list of all players in this player's party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to check
|
||||
// * @return all the players in the player's party
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
// List<OfflinePlayer> members = new ArrayList<>();
|
||||
//
|
||||
// for (UUID memberUniqueId : mcMMO.getPartyManager().getAllMembers(player).keySet()) {
|
||||
// OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
|
||||
// members.add(member);
|
||||
// }
|
||||
// return members;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get a list of all player names in this player's party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to check
|
||||
// * @return all the player names in the player's party
|
||||
// */
|
||||
// @Deprecated
|
||||
// public static LinkedHashSet<String> getMembers(Player player) {
|
||||
// return (LinkedHashSet<String>) mcMMO.getPartyManager().getAllMembers(player).values();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get a list of all player names and uuids in this player's party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to check
|
||||
// * @return all the player names and uuids in the player's party
|
||||
// */
|
||||
// public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
|
||||
// return mcMMO.getPartyManager().getAllMembers(player);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get a list of all online players in this party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param partyName The party to check
|
||||
// * @return all online players in this party
|
||||
// */
|
||||
// public static List<Player> getOnlineMembers(String partyName) {
|
||||
// return mcMMO.getPartyManager().getOnlineMembers(partyName);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get a list of all online players in this player's party.
|
||||
// * </br>
|
||||
// * This function is designed for API usage.
|
||||
// *
|
||||
// * @param player The player to check
|
||||
// * @return all online players in the player's party
|
||||
// */
|
||||
// public static List<Player> getOnlineMembers(Player player) {
|
||||
// return mcMMO.getPartyManager().getOnlineMembers(player);
|
||||
// }
|
||||
//
|
||||
// public static boolean hasAlly(String partyName) {
|
||||
// return getAllyName(partyName) != null;
|
||||
// }
|
||||
//
|
||||
// public static String getAllyName(String partyName) {
|
||||
// Party ally = mcMMO.getPartyManager().getParty(partyName).getAlly();
|
||||
// if (ally != null) {
|
||||
// return ally.getPartyName();
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
@ -8,7 +8,7 @@ import co.aikar.commands.annotation.Default;
|
||||
import com.gmail.nossr50.commands.CommandManager;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.PartyManagerImpl;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
@ -76,7 +76,7 @@ public class PartyChatCommand extends BaseCommand {
|
||||
mcMMO.p.getLogger().severe("You need to specify a party name and then write a message afterwards.");
|
||||
} else {
|
||||
//Grab party
|
||||
Party targetParty = PartyManager.getParty(args[0]);
|
||||
Party targetParty = PartyManagerImpl.getParty(args[0]);
|
||||
|
||||
if(targetParty != null) {
|
||||
pluginRef.getChatManager().processConsoleMessage(StringUtils.buildStringAfterNthElement(args, 1), targetParty);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gmail.nossr50.commands.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;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyMember;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.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;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
|
@ -2,8 +2,8 @@ package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import com.gmail.nossr50.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.neetgames.mcmmo.MobHealthBarType;
|
||||
import com.neetgames.mcmmo.skill.RootSkill;
|
||||
import com.neetgames.mcmmo.skill.SkillIdentity;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -566,7 +565,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
|
||||
public int getLevelCap(@NotNull RootSkill rootSkill) {
|
||||
|
||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(rootSkill.getSkillName()) + ".Level_Cap", 0);
|
||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(rootSkill.getRawSkillName()) + ".Level_Cap", 0);
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
|
@ -331,11 +331,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
|
||||
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
|
||||
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
|
||||
public boolean isExperienceBarEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getSkillName())+".Enable", true);}
|
||||
public boolean isExperienceBarEnabled(@NotNull RootSkill rootSkill) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getRawSkillName())+".Enable", true);}
|
||||
|
||||
public BarColor getExperienceBarColor(@NotNull RootSkill rootSkill)
|
||||
{
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getSkillName())+".Color");
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getRawSkillName())+".Color");
|
||||
|
||||
for(BarColor barColor : BarColor.values())
|
||||
{
|
||||
@ -375,7 +375,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
|
||||
public BarStyle getExperienceBarStyle(@NotNull RootSkill rootSkill) {
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getSkillName())+".BarStyle");
|
||||
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(rootSkill.getRawSkillName())+".BarStyle");
|
||||
|
||||
for(BarStyle barStyle : BarStyle.values())
|
||||
{
|
||||
|
@ -1117,7 +1117,7 @@ public final class FlatFileDatabaseManager extends AbstractDatabaseManager {
|
||||
}
|
||||
int cap = Config.getInstance().getLevelCap(rootSkill);
|
||||
if (Integer.parseInt(stringDataArray[index]) > cap) {
|
||||
mcMMO.p.getLogger().warning("Truncating " + rootSkill.getSkillName() + " to configured max level for player " + stringDataArray[FlatFileMappings.USERNAME]);
|
||||
mcMMO.p.getLogger().warning("Truncating " + rootSkill.getRawSkillName() + " to configured max level for player " + stringDataArray[FlatFileMappings.USERNAME]);
|
||||
stringDataArray[index] = cap + "";
|
||||
updated = true;
|
||||
}
|
||||
|
@ -1117,7 +1117,7 @@ public final class FlatFileDatabaseManager extends AbstractDatabaseManager {
|
||||
}
|
||||
int cap = Config.getInstance().getLevelCap(rootSkill);
|
||||
if (Integer.parseInt(stringDataArray[index]) > cap) {
|
||||
mcMMO.p.getLogger().warning("Truncating " + rootSkill.getSkillName() + " to configured max level for player " + stringDataArray[FlatFileMappings.USERNAME]);
|
||||
mcMMO.p.getLogger().warning("Truncating " + rootSkill.getRawSkillName() + " to configured max level for player " + stringDataArray[FlatFileMappings.USERNAME]);
|
||||
stringDataArray[index] = cap + "";
|
||||
updated = true;
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
||||
}
|
||||
|
||||
|
||||
String query = rootSkill == null ? ALL_QUERY_VERSION : rootSkill.getSkillName().toLowerCase(Locale.ENGLISH);
|
||||
String query = rootSkill == null ? ALL_QUERY_VERSION : rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement statement = null;
|
||||
Connection connection = null;
|
||||
@ -464,7 +464,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
for (RootSkill rootSkill : CoreSkills.getNonChildSkills()) {
|
||||
String skillName = rootSkill.getSkillName().toLowerCase(Locale.ENGLISH);
|
||||
String skillName = rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||
// Get count of all users with higher skill level than player
|
||||
String sql = "SELECT COUNT(*) AS 'rank' FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
@ -1025,8 +1025,8 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
||||
int cap = Config.getInstance().getLevelCap(rootSkill);
|
||||
if (cap != Integer.MAX_VALUE) {
|
||||
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `"
|
||||
+ rootSkill.getSkillName().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `"
|
||||
+ rootSkill.getSkillName().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
||||
+ rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` = " + cap + " WHERE `"
|
||||
+ rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH) + "` > " + cap);
|
||||
statement.executeUpdate();
|
||||
tryClose(statement);
|
||||
}
|
||||
@ -1455,7 +1455,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
|
||||
for (RootSkill rootSkill : CoreSkills.getNonChildSkills()) {
|
||||
String skill_name = rootSkill.getSkillName().toLowerCase(Locale.ENGLISH);
|
||||
String skill_name = rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
try {
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_" + skill_name + "` (`" + skill_name + "`) USING BTREE");
|
||||
|
@ -318,7 +318,7 @@ public class OnlineExperienceProcessor implements ExperienceHandler {
|
||||
if(hasReachedPowerLevelCap()) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.PowerLevel", String.valueOf(Config.getInstance().getPowerLevelCap()));
|
||||
} else if(hasReachedLevelCap(rootSkill)) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.Skill", String.valueOf(Config.getInstance().getLevelCap(rootSkill)), rootSkill.getSkillName());
|
||||
NotificationManager.sendPlayerInformationChatOnly(Misc.adaptPlayer(mmoPlayer), "LevelCap.Skill", String.valueOf(Config.getInstance().getLevelCap(rootSkill)), rootSkill.getRawSkillName());
|
||||
}
|
||||
|
||||
//Updates from Party sources
|
||||
|
@ -1,38 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum ItemShareType {
|
||||
LOOT,
|
||||
MINING,
|
||||
HERBALISM,
|
||||
WOODCUTTING,
|
||||
MISC;
|
||||
|
||||
public static ItemShareType getShareType(ItemStack itemStack) {
|
||||
if (ItemUtils.isMobDrop(itemStack)) {
|
||||
return LOOT;
|
||||
}
|
||||
else if (ItemUtils.isMiningDrop(itemStack)) {
|
||||
return MINING;
|
||||
}
|
||||
else if (ItemUtils.isHerbalismDrop(itemStack)) {
|
||||
return HERBALISM;
|
||||
}
|
||||
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
|
||||
return WOODCUTTING;
|
||||
}
|
||||
else if (ItemUtils.isMiscDrop(itemStack)) {
|
||||
return MISC;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLocaleString() {
|
||||
return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
public class PartyInviteManager {
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PartyItemShareManager {
|
||||
|
||||
private ShareMode itemShareMode = ShareMode.NONE;
|
||||
|
||||
private boolean shareLootDrops = true;
|
||||
private boolean shareMiningDrops = true;
|
||||
private boolean shareHerbalismDrops = true;
|
||||
private boolean shareWoodcuttingDrops = true;
|
||||
private boolean shareMiscDrops = true;
|
||||
|
||||
public void setItemShareMode(ShareMode itemShareMode) {
|
||||
this.itemShareMode = itemShareMode;
|
||||
}
|
||||
|
||||
public ShareMode getItemShareMode() {
|
||||
return itemShareMode;
|
||||
}
|
||||
|
||||
public boolean sharingDrops(ItemShareType shareType) {
|
||||
switch (shareType) {
|
||||
case HERBALISM:
|
||||
return shareHerbalismDrops;
|
||||
|
||||
case LOOT:
|
||||
return shareLootDrops;
|
||||
|
||||
case MINING:
|
||||
return shareMiningDrops;
|
||||
|
||||
case MISC:
|
||||
return shareMiscDrops;
|
||||
|
||||
case WOODCUTTING:
|
||||
return shareWoodcuttingDrops;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSharingDrops(ItemShareType shareType, boolean enabled) {
|
||||
switch (shareType) {
|
||||
case HERBALISM:
|
||||
shareHerbalismDrops = enabled;
|
||||
break;
|
||||
|
||||
case LOOT:
|
||||
shareLootDrops = enabled;
|
||||
break;
|
||||
|
||||
case MINING:
|
||||
shareMiningDrops = enabled;
|
||||
break;
|
||||
|
||||
case MISC:
|
||||
shareMiscDrops = enabled;
|
||||
break;
|
||||
|
||||
case WOODCUTTING:
|
||||
shareWoodcuttingDrops = enabled;
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getItemShareCategories() {
|
||||
List<String> shareCategories = new ArrayList<>();
|
||||
|
||||
for (ItemShareType shareType : ItemShareType.values()) {
|
||||
if (sharingDrops(shareType)) {
|
||||
shareCategories.add(shareType.getLocaleString());
|
||||
}
|
||||
}
|
||||
|
||||
return shareCategories;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
public enum PartyMemberRank {
|
||||
MEMBER,
|
||||
OFFICER,
|
||||
LEADER;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
public enum ShareMode {
|
||||
NONE,
|
||||
EQUAL,
|
||||
RANDOM;
|
||||
|
||||
public static ShareMode getShareMode(String string) {
|
||||
try {
|
||||
return valueOf(string);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (string.equalsIgnoreCase("even")) {
|
||||
return EQUAL;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(string)) {
|
||||
return NONE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,9 +7,8 @@ import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.skills.CoreRootSkill;
|
||||
import com.gmail.nossr50.datatypes.skills.CoreSkills;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
@ -34,9 +33,10 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
||||
import com.gmail.nossr50.util.input.SuperAbilityManager;
|
||||
import com.gmail.nossr50.util.input.SuperSkillManagerImpl;
|
||||
import com.neetgames.mcmmo.player.MMOPlayerData;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.neetgames.mcmmo.player.SuperSkillManager;
|
||||
import com.neetgames.mcmmo.skill.RootSkill;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
@ -81,7 +81,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
private @Nullable Location teleportCommence;
|
||||
|
||||
private final @NotNull FixedMetadataValue playerMetadata;
|
||||
private final @NotNull SuperAbilityManager superAbilityManager;
|
||||
private final @NotNull SuperSkillManagerImpl superSkillManagerImpl;
|
||||
private final @NotNull AbilityActivationProcessor abilityActivationProcessor;
|
||||
|
||||
/**
|
||||
@ -102,7 +102,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
playerMetadata = new FixedMetadataValue(mcMMO.p, player.getName());
|
||||
experienceBarManager = new MMOExperienceBarManager(this, mmoPlayerData.getBarStateMap());
|
||||
|
||||
superAbilityManager = new SuperAbilityManager(this, mmoPlayerData);
|
||||
superSkillManagerImpl = new SuperSkillManagerImpl(this, mmoPlayerData);
|
||||
abilityActivationProcessor = new AbilityActivationProcessor(this);
|
||||
|
||||
debugMode = false; //Debug mode helps solve support issues, players can toggle it on or off
|
||||
@ -151,7 +151,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p);
|
||||
}
|
||||
|
||||
superAbilityManager = new SuperAbilityManager(this, mmoPlayerData);
|
||||
superSkillManagerImpl = new SuperSkillManagerImpl(this, mmoPlayerData);
|
||||
abilityActivationProcessor = new AbilityActivationProcessor(this);
|
||||
experienceBarManager = new MMOExperienceBarManager(this, this.mmoPlayerData.getBarStateMap());
|
||||
|
||||
@ -335,10 +335,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
return (WoodcuttingManager) skillManagers.get(PrimarySkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
/*
|
||||
* Recently Hurt
|
||||
*/
|
||||
|
||||
/**
|
||||
* The timestamp of the last time this player was hurt
|
||||
* @return the timestamp of the most recent player damage
|
||||
@ -362,10 +358,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Exploit Prevention
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the activation time stamp for this player's last respawn
|
||||
* @return the time stamp of this player's last respawn
|
||||
@ -411,10 +403,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
databaseATS = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/*
|
||||
* God Mode
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether or not this player is in god mode
|
||||
* @return true if this player is in god mode
|
||||
@ -430,10 +418,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
godMode = !godMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Debug Mode Flags
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether or not this player is using debug mode
|
||||
* @return true if this player is in debug mode
|
||||
@ -449,10 +433,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
debugMode = !debugMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skill notifications
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether or not this player receives specific skill notifications in chat
|
||||
* @return true if the player receives specific chat notifications related to skills
|
||||
@ -491,17 +471,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the time remaining until the superAbilityType's cooldown expires.
|
||||
*
|
||||
* @param superAbilityType the super ability cooldown to check
|
||||
*
|
||||
* @return the number of seconds remaining before the cooldown expires
|
||||
*/
|
||||
public int getCooldownSeconds(SuperAbilityType superAbilityType) {
|
||||
return superAbilityManager.calculateTimeRemaining(superAbilityType);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is sort of a hack, used for thread safety
|
||||
* @return this player's {@link FixedMetadataValue}
|
||||
@ -510,14 +479,6 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
return playerMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab this players {@link SuperAbilityManager}
|
||||
* @return this player's super ability manager
|
||||
*/
|
||||
public @NotNull SuperAbilityManager getSuperAbilityManager() {
|
||||
return superAbilityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab this player's {@link AbilityActivationProcessor}
|
||||
* Used to process all things related to manually activated abilities
|
||||
@ -534,7 +495,7 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
* Etc...
|
||||
*/
|
||||
public void cleanup() {
|
||||
superAbilityManager.disableSuperAbilities();
|
||||
superSkillManagerImpl.disableSuperAbilities();
|
||||
getTamingManager().cleanupAllSummons();
|
||||
}
|
||||
|
||||
@ -641,4 +602,10 @@ public class McMMOPlayer extends PlayerProfile implements OnlineMMOPlayer, Ident
|
||||
public @Nullable Party getParty() {
|
||||
return playerPartyRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull SuperSkillManager getSuperSkillManager() {
|
||||
return superSkillManagerImpl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ public class CoreRootSkill extends AbstractRootSkill {
|
||||
|
||||
@Override
|
||||
public boolean isOffensiveActionAllowed(@NotNull Object victim) {
|
||||
return (victim instanceof Player || (victim instanceof Tameable && ((Tameable) victim).isTamed())) ? isPVPPermitted() : isPVEPermitted();;
|
||||
return (victim instanceof Player || (victim instanceof Tameable && ((Tameable) victim).isTamed())) ? isPVPPermitted() : isPVEPermitted();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.gmail.nossr50.datatypes.skills;
|
||||
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.neetgames.mcmmo.skill.RootSkill;
|
||||
import com.neetgames.mcmmo.skill.SuperSkill;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -22,6 +24,6 @@ public class SuperCoreSkill extends CoreSkill implements SuperSkill {
|
||||
|
||||
@Override
|
||||
public int getCooldown(@NotNull OnlineMMOPlayer onlineMMOPlayer) {
|
||||
//TODO: Move implementation
|
||||
return PerksUtils.handleCooldownPerks((Player) onlineMMOPlayer.getServerAPIPlayerImpl(), defaultCooldown);
|
||||
}
|
||||
}
|
||||
|
@ -1,91 +1,91 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private final String oldAlly;
|
||||
private final String newAlly;
|
||||
private final EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
if (newAlly != null) {
|
||||
newAlly = newAlly.replace(":", ".");
|
||||
}
|
||||
|
||||
this.oldAlly = oldAlly;
|
||||
this.newAlly = newAlly;
|
||||
this.reason = reason;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being left, or null if the player was not in a party
|
||||
*/
|
||||
public String getOldAlly() {
|
||||
return oldAlly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being joined, or null if the player is not joining a new party
|
||||
*/
|
||||
public String getNewAlly() {
|
||||
return newAlly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The reason for the event being fired
|
||||
*/
|
||||
public EventReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Formed an alliance for the first time.
|
||||
*/
|
||||
FORMED_ALLIANCE,
|
||||
|
||||
/**
|
||||
* Left a party and did not join a new one.
|
||||
*/
|
||||
DISBAND_ALLIANCE,
|
||||
|
||||
/**
|
||||
* Any reason that doesn't fit elsewhere.
|
||||
*/
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.bukkit.event.player.PlayerEvent;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
|
||||
// private final String oldAlly;
|
||||
// private final String newAlly;
|
||||
// private final EventReason reason;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) {
|
||||
// super(player);
|
||||
//
|
||||
// if (newAlly != null) {
|
||||
// newAlly = newAlly.replace(":", ".");
|
||||
// }
|
||||
//
|
||||
// this.oldAlly = oldAlly;
|
||||
// this.newAlly = newAlly;
|
||||
// this.reason = reason;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being left, or null if the player was not in a party
|
||||
// */
|
||||
// public String getOldAlly() {
|
||||
// return oldAlly;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being joined, or null if the player is not joining a new party
|
||||
// */
|
||||
// public String getNewAlly() {
|
||||
// return newAlly;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The reason for the event being fired
|
||||
// */
|
||||
// public EventReason getReason() {
|
||||
// return reason;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * A list of reasons why the event may have been fired
|
||||
// */
|
||||
// public enum EventReason {
|
||||
// /**
|
||||
// * Formed an alliance for the first time.
|
||||
// */
|
||||
// FORMED_ALLIANCE,
|
||||
//
|
||||
// /**
|
||||
// * Left a party and did not join a new one.
|
||||
// */
|
||||
// DISBAND_ALLIANCE,
|
||||
//
|
||||
// /**
|
||||
// * Any reason that doesn't fit elsewhere.
|
||||
// */
|
||||
// CUSTOM
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setCancelled(boolean cancelled) {
|
||||
// this.cancelled = cancelled;
|
||||
// }
|
||||
//
|
||||
// /** Rest of file is required boilerplate for custom events **/
|
||||
// private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,104 +1,75 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player attempts to join, leave, or change parties.
|
||||
*/
|
||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
private final String oldParty;
|
||||
private final String newParty;
|
||||
private final EventReason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
||||
super(player);
|
||||
|
||||
if (newParty != null) {
|
||||
newParty = newParty.replace(":", ".");
|
||||
}
|
||||
|
||||
this.oldParty = oldParty;
|
||||
this.newParty = newParty;
|
||||
this.reason = reason;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being left, or null if the player was not in a party
|
||||
*/
|
||||
public String getOldParty() {
|
||||
return oldParty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party being joined, or null if the player is not joining a new party
|
||||
*/
|
||||
public String getNewParty() {
|
||||
return newParty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The reason for the event being fired
|
||||
*/
|
||||
public EventReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of reasons why the event may have been fired
|
||||
*/
|
||||
public enum EventReason {
|
||||
/**
|
||||
* Joined a party for the first time.
|
||||
*/
|
||||
JOINED_PARTY,
|
||||
|
||||
/**
|
||||
* Left a party and did not join a new one.
|
||||
*/
|
||||
LEFT_PARTY,
|
||||
|
||||
/**
|
||||
* Was kicked from a party.
|
||||
*/
|
||||
KICKED_FROM_PARTY,
|
||||
|
||||
/**
|
||||
* Left one party to join another.
|
||||
*/
|
||||
CHANGED_PARTIES,
|
||||
|
||||
/**
|
||||
* Any reason that doesn't fit elsewhere.
|
||||
*/
|
||||
CUSTOM
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import com.neetgames.mcmmo.party.PartyEventReason;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.bukkit.event.player.PlayerEvent;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
///**
|
||||
// * Called when a player attempts to join, leave, or change parties.
|
||||
// */
|
||||
//public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||
// private final String oldParty;
|
||||
// private final String newParty;
|
||||
// private final PartyEventReason reason;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyChangeEvent(@NotNull Player player, @NotNull String oldParty, @NotNull String newParty, PartyEventReason reason) {
|
||||
// super(player);
|
||||
//
|
||||
// if (newParty != null) {
|
||||
// newParty = newParty.replace(":", ".");
|
||||
// }
|
||||
//
|
||||
// this.oldParty = oldParty;
|
||||
// this.newParty = newParty;
|
||||
// this.reason = reason;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being left, or null if the player was not in a party
|
||||
// */
|
||||
// public String getOldParty() {
|
||||
// return oldParty;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party being joined, or null if the player is not joining a new party
|
||||
// */
|
||||
// public String getNewParty() {
|
||||
// return newParty;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The reason for the event being fired
|
||||
// */
|
||||
// public PartyEventReason getReason() {
|
||||
// return reason;
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setCancelled(boolean cancelled) {
|
||||
// this.cancelled = cancelled;
|
||||
// }
|
||||
//
|
||||
// /** Rest of file is required boilerplate for custom events **/
|
||||
// private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,54 +1,54 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
|
||||
private final Party party;
|
||||
private int levelsChanged;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyLevelUpEvent(Party party, int levelsChanged) {
|
||||
this.party = party;
|
||||
this.levelsChanged = levelsChanged;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public int getLevelsChanged() {
|
||||
return levelsChanged;
|
||||
}
|
||||
|
||||
public void setLevelsChanged(int levelsChanged) {
|
||||
this.levelsChanged = levelsChanged;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import com.neetgames.mcmmo.party.Party;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.Event;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
|
||||
// private final Party party;
|
||||
// private int levelsChanged;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyLevelUpEvent(Party party, int levelsChanged) {
|
||||
// this.party = party;
|
||||
// this.levelsChanged = levelsChanged;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// public Party getParty() {
|
||||
// return party;
|
||||
// }
|
||||
//
|
||||
// public int getLevelsChanged() {
|
||||
// return levelsChanged;
|
||||
// }
|
||||
//
|
||||
// public void setLevelsChanged(int levelsChanged) {
|
||||
// this.levelsChanged = levelsChanged;
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setCancelled(boolean cancelled) {
|
||||
// this.cancelled = cancelled;
|
||||
// }
|
||||
//
|
||||
// /** Rest of file is required boilerplate for custom events **/
|
||||
// private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,46 +1,46 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called just before a player teleports using the /ptp command.
|
||||
*/
|
||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||
private final String party;
|
||||
private final Player target;
|
||||
|
||||
public McMMOPartyTeleportEvent(Player player, Player target, String party) {
|
||||
super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
|
||||
this.party = party;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The party the teleporting player is in
|
||||
*/
|
||||
public String getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The player being teleported to
|
||||
*/
|
||||
public Player getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
///**
|
||||
// * Called just before a player teleports using the /ptp command.
|
||||
// */
|
||||
//public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||
// private final String party;
|
||||
// private final Player target;
|
||||
//
|
||||
// public McMMOPartyTeleportEvent(Player player, Player target, String party) {
|
||||
// super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
|
||||
// this.party = party;
|
||||
// this.target = target;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The party the teleporting player is in
|
||||
// */
|
||||
// public String getParty() {
|
||||
// return party;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The player being teleported to
|
||||
// */
|
||||
// public Player getTarget() {
|
||||
// return target;
|
||||
// }
|
||||
//
|
||||
// /** Rest of file is required boilerplate for custom events **/
|
||||
// private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static @NotNull HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,76 +1,76 @@
|
||||
package com.gmail.nossr50.events.party;
|
||||
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class McMMOPartyXpGainEvent extends Event implements Cancellable {
|
||||
private final Party party;
|
||||
private float xpGained;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPartyXpGainEvent(Party party, float xpGained) {
|
||||
this.party = party;
|
||||
this.xpGained = xpGained;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The amount of experience gained in this event
|
||||
*/
|
||||
public float getRawXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int amount of experience gained in this event
|
||||
*/
|
||||
@Deprecated
|
||||
public int getXpGained() {
|
||||
return (int) xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xpGained set amount of experience gained in this event
|
||||
*/
|
||||
public void setRawXpGained(float xpGained) {
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param xpGained set int amount of experience gained in this event
|
||||
*/
|
||||
@Deprecated
|
||||
public void setXpGained(int xpGained) {
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
//package com.gmail.nossr50.events.party;
|
||||
//
|
||||
//import com.neetgames.mcmmo.party.Party;
|
||||
//import org.bukkit.event.Cancellable;
|
||||
//import org.bukkit.event.Event;
|
||||
//import org.bukkit.event.HandlerList;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//
|
||||
//public class McMMOPartyXpGainEvent extends Event implements Cancellable {
|
||||
// private final Party party;
|
||||
// private float xpGained;
|
||||
// private boolean cancelled;
|
||||
//
|
||||
// public McMMOPartyXpGainEvent(Party party, float xpGained) {
|
||||
// this.party = party;
|
||||
// this.xpGained = xpGained;
|
||||
// this.cancelled = false;
|
||||
// }
|
||||
//
|
||||
// public Party getParty() {
|
||||
// return party;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The amount of experience gained in this event
|
||||
// */
|
||||
// public float getRawXpGained() {
|
||||
// return xpGained;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return int amount of experience gained in this event
|
||||
// */
|
||||
// @Deprecated
|
||||
// public int getXpGained() {
|
||||
// return (int) xpGained;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param xpGained set amount of experience gained in this event
|
||||
// */
|
||||
// public void setRawXpGained(float xpGained) {
|
||||
// this.xpGained = xpGained;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param xpGained set int amount of experience gained in this event
|
||||
// */
|
||||
// @Deprecated
|
||||
// public void setXpGained(int xpGained) {
|
||||
// this.xpGained = xpGained;
|
||||
// }
|
||||
//
|
||||
// /** Following are required for Cancellable **/
|
||||
// @Override
|
||||
// public boolean isCancelled() {
|
||||
// return cancelled;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setCancelled(boolean cancelled) {
|
||||
// this.cancelled = cancelled;
|
||||
// }
|
||||
//
|
||||
// /** Rest of file is required boilerplate for custom events **/
|
||||
// private static final HandlerList handlers = new HandlerList();
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull HandlerList getHandlers() {
|
||||
// return handlers;
|
||||
// }
|
||||
//
|
||||
// public static HandlerList getHandlerList() {
|
||||
// return handlers;
|
||||
// }
|
||||
//}
|
||||
|
@ -15,7 +15,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillRegisterImpl;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
|
||||
import com.gmail.nossr50.listeners.*;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.PartyManagerImpl;
|
||||
import com.gmail.nossr50.runnables.CheckDateTask;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||
@ -51,6 +51,7 @@ import com.gmail.nossr50.util.upgrade.UpgradeManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.neetgames.mcmmo.api.SkillRegister;
|
||||
import com.neetgames.mcmmo.party.PartyManager;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
38
src/main/java/com/gmail/nossr50/party/ItemShareType.java
Normal file
38
src/main/java/com/gmail/nossr50/party/ItemShareType.java
Normal file
@ -0,0 +1,38 @@
|
||||
//package com.gmail.nossr50.party;
|
||||
//
|
||||
//import com.gmail.nossr50.locale.LocaleLoader;
|
||||
//import com.gmail.nossr50.util.ItemUtils;
|
||||
//import com.gmail.nossr50.util.text.StringUtils;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
//
|
||||
//public enum ItemShareType {
|
||||
// LOOT,
|
||||
// MINING,
|
||||
// HERBALISM,
|
||||
// WOODCUTTING,
|
||||
// MISC;
|
||||
//
|
||||
// public static ItemShareType getShareType(ItemStack itemStack) {
|
||||
// if (ItemUtils.isMobDrop(itemStack)) {
|
||||
// return LOOT;
|
||||
// }
|
||||
// else if (ItemUtils.isMiningDrop(itemStack)) {
|
||||
// return MINING;
|
||||
// }
|
||||
// else if (ItemUtils.isHerbalismDrop(itemStack)) {
|
||||
// return HERBALISM;
|
||||
// }
|
||||
// else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
|
||||
// return WOODCUTTING;
|
||||
// }
|
||||
// else if (ItemUtils.isMiscDrop(itemStack)) {
|
||||
// return MISC;
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public String getLocaleString() {
|
||||
// return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
|
||||
// }
|
||||
//}
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
@ -8,29 +8,33 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.party.PartyExperience;
|
||||
import com.neetgames.mcmmo.party.PartyExperienceShareMode;
|
||||
import com.neetgames.mcmmo.party.PartyMemberManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class PartyExperienceManager {
|
||||
public class PartyExperienceManagerImpl implements PartyExperience {
|
||||
|
||||
private int partyLevel;
|
||||
private float partyExperience;
|
||||
private final @NotNull Party partyRef;
|
||||
private final @NotNull PartyMemberManager partyMemberManagerRef;
|
||||
private @NotNull ShareMode xpShareMode = ShareMode.NONE;
|
||||
private @NotNull PartyExperienceShareMode xpShareMode = PartyExperienceShareMode.NONE;
|
||||
|
||||
public PartyExperienceManager(@NotNull PartyMemberManager partyMemberManager, @NotNull Party party) {
|
||||
public PartyExperienceManagerImpl(@NotNull PartyMemberManager partyMemberManagerRef, @NotNull Party party) {
|
||||
this.partyRef = party;
|
||||
this.partyMemberManagerRef = partyMemberManager;
|
||||
this.partyMemberManagerRef = partyMemberManagerRef;
|
||||
}
|
||||
|
||||
public void setXpShareMode(@NotNull ShareMode xpShareMode) {
|
||||
this.xpShareMode = xpShareMode;
|
||||
public void setXpShareMode(@NotNull PartyExperienceShareMode partyExperienceShareMode) {
|
||||
this.xpShareMode = partyExperienceShareMode;
|
||||
}
|
||||
|
||||
public @NotNull ShareMode getXpShareMode() {
|
||||
public @NotNull PartyExperienceShareMode getXpShareMode() {
|
||||
return xpShareMode;
|
||||
}
|
||||
|
||||
@ -124,8 +128,4 @@ public class PartyExperienceManager {
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
return percent.format(this.getXp() / getXpToLevel());
|
||||
}
|
||||
|
||||
public @NotNull Party getParty() {
|
||||
return partyRef;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.commands.party.PartySubCommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
@ -1,7 +1,10 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.chat.SamePartyPredicate;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.party.PartyExperience;
|
||||
import com.neetgames.mcmmo.party.PartyMember;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -15,34 +18,39 @@ import java.util.function.Predicate;
|
||||
public class PartyImpl implements Party {
|
||||
private final @NotNull Predicate<CommandSender> samePartyPredicate;
|
||||
private final @NotNull PersistentPartyData persistentPartyData;
|
||||
private final @NotNull PartyMemberManager partyMemberManager;
|
||||
private final @NotNull PartyExperienceManager partyExperienceManager;
|
||||
private final @NotNull PartyMemberManagerImpl partyMemberManagerImpl;
|
||||
private final @NotNull PartyExperience partyExperienceManager;
|
||||
|
||||
public PartyImpl(@NotNull PersistentPartyData persistentPartyData) {
|
||||
this.persistentPartyData = persistentPartyData;
|
||||
|
||||
//Initialize Managers
|
||||
partyMemberManager = new PartyMemberManager(persistentPartyData);
|
||||
partyExperienceManager = new PartyExperienceManager(partyMemberManager, this);
|
||||
partyMemberManagerImpl = new PartyMemberManagerImpl(persistentPartyData);
|
||||
partyExperienceManager = new PartyExperienceManagerImpl(partyMemberManagerImpl, this);
|
||||
samePartyPredicate = new SamePartyPredicate<>(this);
|
||||
}
|
||||
|
||||
public @NotNull PartyMemberManager getPartyMemberManager() {
|
||||
return partyMemberManager;
|
||||
public @NotNull PartyMemberManagerImpl getPartyMemberManager() {
|
||||
return partyMemberManagerImpl;
|
||||
}
|
||||
|
||||
public @NotNull PartyExperienceManager getPartyExperienceManager() {
|
||||
public @NotNull PartyExperience getPartyExperienceManager() {
|
||||
return partyExperienceManager;
|
||||
}
|
||||
|
||||
public @NotNull Set<PartyMember> getPartyMembers() {
|
||||
return partyMemberManager.getPartyMembers();
|
||||
return partyMemberManagerImpl.getPartyMembers();
|
||||
}
|
||||
|
||||
public @NotNull String getPartyName() {
|
||||
return persistentPartyData.getPartyName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PartyMember getPartyMember(@NotNull OnlineMMOPlayer onlineMMOPlayer) {
|
||||
return getPartyMemberManager().getPartyMember(onlineMMOPlayer.getUUID());
|
||||
}
|
||||
|
||||
private void buildChatMessage(@NotNull StringBuilder stringBuilder, String @NotNull [] names) {
|
||||
for(int i = 0; i < names.length; i++) {
|
||||
if(i + 1 >= names.length) {
|
||||
@ -63,13 +71,13 @@ public class PartyImpl implements Party {
|
||||
PartyImpl party = (PartyImpl) o;
|
||||
return samePartyPredicate.equals(party.samePartyPredicate)
|
||||
&& persistentPartyData.equals(party.persistentPartyData)
|
||||
&& partyMemberManager.equals(party.partyMemberManager)
|
||||
&& partyMemberManagerImpl.equals(party.partyMemberManagerImpl)
|
||||
&& partyExperienceManager.equals(party.partyExperienceManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(samePartyPredicate, persistentPartyData, partyMemberManager, partyExperienceManager);
|
||||
return Objects.hash(samePartyPredicate, persistentPartyData, partyMemberManagerImpl, partyExperienceManager);
|
||||
}
|
||||
|
||||
public @Nullable PartyMember getPartyMember(@NotNull Player player) {
|
||||
@ -77,7 +85,7 @@ public class PartyImpl implements Party {
|
||||
}
|
||||
|
||||
public @Nullable PartyMember getPartyMember(@NotNull UUID playerUUID) {
|
||||
return partyMemberManager.getPartyMember(playerUUID);
|
||||
return partyMemberManagerImpl.getPartyMember(playerUUID);
|
||||
}
|
||||
|
||||
public @NotNull Predicate<CommandSender> getSamePartyPredicate() {
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
@ -0,0 +1,4 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
public class PartyInviteManagerImpl {
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
//package com.gmail.nossr50.party;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class PartyItemShareManager {
|
||||
//
|
||||
// private ShareMode itemShareMode = ShareMode.NONE;
|
||||
//
|
||||
// private boolean shareLootDrops = true;
|
||||
// private boolean shareMiningDrops = true;
|
||||
// private boolean shareHerbalismDrops = true;
|
||||
// private boolean shareWoodcuttingDrops = true;
|
||||
// private boolean shareMiscDrops = true;
|
||||
//
|
||||
// public void setItemShareMode(ShareMode itemShareMode) {
|
||||
// this.itemShareMode = itemShareMode;
|
||||
// }
|
||||
//
|
||||
// public ShareMode getItemShareMode() {
|
||||
// return itemShareMode;
|
||||
// }
|
||||
//
|
||||
// public boolean sharingDrops(ItemShareType shareType) {
|
||||
// switch (shareType) {
|
||||
// case HERBALISM:
|
||||
// return shareHerbalismDrops;
|
||||
//
|
||||
// case LOOT:
|
||||
// return shareLootDrops;
|
||||
//
|
||||
// case MINING:
|
||||
// return shareMiningDrops;
|
||||
//
|
||||
// case MISC:
|
||||
// return shareMiscDrops;
|
||||
//
|
||||
// case WOODCUTTING:
|
||||
// return shareWoodcuttingDrops;
|
||||
//
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void setSharingDrops(ItemShareType shareType, boolean enabled) {
|
||||
// switch (shareType) {
|
||||
// case HERBALISM:
|
||||
// shareHerbalismDrops = enabled;
|
||||
// break;
|
||||
//
|
||||
// case LOOT:
|
||||
// shareLootDrops = enabled;
|
||||
// break;
|
||||
//
|
||||
// case MINING:
|
||||
// shareMiningDrops = enabled;
|
||||
// break;
|
||||
//
|
||||
// case MISC:
|
||||
// shareMiscDrops = enabled;
|
||||
// break;
|
||||
//
|
||||
// case WOODCUTTING:
|
||||
// shareWoodcuttingDrops = enabled;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public List<String> getItemShareCategories() {
|
||||
// List<String> shareCategories = new ArrayList<>();
|
||||
//
|
||||
// for (ItemShareType shareType : ItemShareType.values()) {
|
||||
// if (sharingDrops(shareType)) {
|
||||
// shareCategories.add(shareType.getLocaleString());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return shareCategories;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
@ -1,864 +0,0 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyMember;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* About mcMMO parties
|
||||
* Parties are identified by a {@link String} name
|
||||
* Parties always have a party leader, if the party leader is not defined mcMMO will force party leadership onto someone in the party
|
||||
*/
|
||||
//TODO: Needs to be optimized, currently all parties are loaded into memory, it should be changed to as needed, but then we need to handle loading asynchronously and accommodate for that
|
||||
public final class PartyManager {
|
||||
private final @NotNull HashMap<String, Party> parties;
|
||||
private final @NotNull File partyFile;
|
||||
|
||||
public PartyManager() {
|
||||
String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||
partyFile = new File(partiesFilePath);
|
||||
parties = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to find a party for a player by UUID
|
||||
*
|
||||
* @param playerUUID target uuid
|
||||
* @return the party if it exists otherwise null
|
||||
*/
|
||||
public @Nullable Party queryParty(@NotNull UUID playerUUID) {
|
||||
for(Party party : parties.values()) {
|
||||
if(party.getPartyMemberManager().hasMember(playerUUID)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null; //No party
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to find a party by party name
|
||||
* Party names are not case sensitive
|
||||
*
|
||||
* @param partyName party name
|
||||
* @return the party if it exists otherwise null
|
||||
*/
|
||||
public @Nullable Party queryParty(@NotNull String partyName) {
|
||||
return parties.get(partyName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level of a party
|
||||
*
|
||||
* @param party target party
|
||||
* @return the level value of the target party
|
||||
*/
|
||||
public int getPartyLevel(@NotNull Party party) {
|
||||
return party.getPartyExperienceManager().getLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a party with a given name already exists.
|
||||
*
|
||||
* @param partyName The name of the party to check
|
||||
* @return true if a party with that name exists, false otherwise
|
||||
*/
|
||||
public boolean isParty(@NotNull String partyName) {
|
||||
return getParty(partyName) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player can join a party, parties can have a size limit, although there is a permission to bypass this
|
||||
*
|
||||
* @param player player who is attempting to join the party
|
||||
* @param targetParty the target party
|
||||
* @return true if party is full and cannot be joined
|
||||
*/
|
||||
public boolean isPartyFull(@NotNull Player player, @NotNull Party targetParty)
|
||||
{
|
||||
return !Permissions.partySizeBypass(player)
|
||||
&& targetParty.getPartyMembers().size() >= Config.getInstance().getPartyMaxSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to change parties or join a new party.
|
||||
*
|
||||
* @param mmoPlayer The player changing or joining parties
|
||||
* @param newPartyName The name of the party being joined
|
||||
* @return true if the party was joined successfully, false otherwise
|
||||
*/
|
||||
public boolean changeOrJoinParty(@NotNull OnlineMMOPlayer mmoPlayer, @NotNull String newPartyName) {
|
||||
Player player = Misc.adaptPlayer(mmoPlayer);
|
||||
|
||||
if (inParty(mmoPlayer)) {
|
||||
Party oldParty = mmoPlayer.getParty();
|
||||
|
||||
if (!handlePartyChangeEvent(player, oldParty.getPartyName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
removeFromParty(mmoPlayer);
|
||||
}
|
||||
else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two online players are in the same party.
|
||||
*
|
||||
* @param firstPlayer The first player
|
||||
* @param secondPlayer The second player
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(firstPlayer) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(secondPlayer) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = mcMMO.getUserManager().queryPlayer(firstPlayer).getParty();
|
||||
Party secondParty = mcMMO.getUserManager().queryPlayer(secondPlayer).getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return firstParty.equals(secondParty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the near party members.
|
||||
*
|
||||
* @param mmoPlayer The player to check
|
||||
* @return the near party members
|
||||
*/
|
||||
public List<Player> getNearMembers(OnlineMMOPlayer mmoPlayer) {
|
||||
List<Player> nearMembers = new ArrayList<>();
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
Player player = Misc.adaptPlayer(mmoPlayer);
|
||||
double range = Config.getInstance().getPartyShareRange();
|
||||
|
||||
for (PartyMember member : party.getPartyMembers()) {
|
||||
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
nearMembers.add(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nearMembers;
|
||||
}
|
||||
|
||||
public List<Player> getNearVisibleMembers(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
List<Player> nearMembers = new ArrayList<>();
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
Player player = Misc.adaptPlayer(mmoPlayer);
|
||||
double range = Config.getInstance().getPartyShareRange();
|
||||
|
||||
for (Player member : party.getVisibleMembers(player)) {
|
||||
if (!player.equals(member)
|
||||
&& member.isValid()
|
||||
&& Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
||||
nearMembers.add(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nearMembers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public LinkedHashMap<UUID, String> getAllMembers(Player player) {
|
||||
Party party = getParty(player);
|
||||
|
||||
return party == null ? new LinkedHashMap<>() : party.getMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public List<Player> getOnlineMembers(String partyName) {
|
||||
return getOnlineMembers(getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public List<Player> getOnlineMembers(Player player) {
|
||||
return getOnlineMembers(getParty(player));
|
||||
}
|
||||
|
||||
private List<Player> getOnlineMembers(Party party) {
|
||||
return party == null ? new ArrayList<>() : party.getPartyMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a party by its name
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getParty(String partyName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getPartyName().equalsIgnoreCase(partyName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a party by a members name
|
||||
*
|
||||
* @param playerName The members name
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public Party getPlayerParty(String playerName) {
|
||||
for (Party party : parties) {
|
||||
if (party.getMembers().containsKey(playerName)) {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a party by a members uuid
|
||||
*
|
||||
* @param uuid The members uuid
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getPlayerParty(String playerName, UUID uuid) {
|
||||
for (Party party : parties) {
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
if (members.containsKey(uuid) || members.containsValue(playerName)) {
|
||||
|
||||
// Name changes
|
||||
if (members.get(uuid) == null || !members.get(uuid).equals(playerName)) {
|
||||
members.put(uuid, playerName);
|
||||
}
|
||||
|
||||
return party;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a party by member
|
||||
*
|
||||
* @param player The member
|
||||
* @return the existing party, null otherwise
|
||||
*/
|
||||
public Party getParty(Player player) {
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(player) == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
|
||||
|
||||
return mmoPlayer.getParty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current parties.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public List<Party> getParties() {
|
||||
return parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param player The player to remove
|
||||
* @param party The party
|
||||
*/
|
||||
public void removeFromParty(OfflinePlayer player, Party party) {
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
String playerName = player.getName();
|
||||
|
||||
members.remove(player.getUniqueId());
|
||||
|
||||
if (player.isOnline()) {
|
||||
party.getPartyMembers().remove(player.getPlayer());
|
||||
}
|
||||
|
||||
if (members.isEmpty()) {
|
||||
parties.remove(party);
|
||||
}
|
||||
else {
|
||||
// If the leaving player was the party leader, appoint a new leader from the party members
|
||||
if (party.getLeader().getUniqueId().equals(player.getUniqueId())) {
|
||||
setPartyLeader(members.keySet().iterator().next(), party);
|
||||
}
|
||||
|
||||
informPartyMembersQuit(party, playerName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
*
|
||||
* @param mmoPlayer The player to remove
|
||||
*/
|
||||
public void removeFromParty(OnlineMMOPlayer mmoPlayer) {
|
||||
removeFromParty(Misc.adaptPlayer(mmoPlayer), mmoPlayer.getParty());
|
||||
processPartyLeaving(mmoPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband a party. Kicks out all members and removes the party.
|
||||
*
|
||||
* @param party The party to remove
|
||||
*/
|
||||
public void disbandParty(Party party) {
|
||||
//TODO: Potential issues with unloaded profile?
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().queryPlayer(member) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
processPartyLeaving(mcMMO.getUserManager().queryPlayer(member));
|
||||
}
|
||||
|
||||
// Disband the alliance between the disbanded party and it's ally
|
||||
if (party.getAlly() != null) {
|
||||
party.getAlly().setAlly(null);
|
||||
}
|
||||
|
||||
parties.remove(party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new party
|
||||
*
|
||||
* @param mmoPlayer The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password The password for this party, null if there was no password
|
||||
*/
|
||||
public void createParty(OnlineMMOPlayer mmoPlayer, String partyName, String password) {
|
||||
Player player = Misc.adaptPlayer(mmoPlayer);
|
||||
|
||||
Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password);
|
||||
|
||||
if (password != null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
|
||||
}
|
||||
|
||||
parties.add(party);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getPartyName()));
|
||||
addToParty(mmoPlayer, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can join a party
|
||||
*
|
||||
* @param player The player trying to join a party
|
||||
* @param party The party
|
||||
* @param password The password provided by the player
|
||||
* @return true if the player can join the party
|
||||
*/
|
||||
public boolean checkPartyPassword(Player player, Party party, String password) {
|
||||
if (party.isLocked()) {
|
||||
String partyPassword = party.getPartyPassword();
|
||||
|
||||
if (partyPassword == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.None"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!password.equals(partyPassword)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Password.Incorrect"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a party invitation
|
||||
*
|
||||
* @param mmoPlayer The player to add to the party
|
||||
*/
|
||||
public void joinInvitedParty(OnlineMMOPlayer mmoPlayer) {
|
||||
Party invite = mmoPlayer.getPartyInvite();
|
||||
|
||||
// Check if the party still exists, it might have been disbanded
|
||||
if (!parties.contains(invite)) {
|
||||
NotificationManager.sendPlayerInformation(Misc.adaptPlayer(mmoPlayer), NotificationType.PARTY_MESSAGE, "Party.Disband");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't let players join a full party
|
||||
*/
|
||||
if(Config.getInstance().getPartyMaxSize() > 0 && invite.getMembers().size() >= Config.getInstance().getPartyMaxSize())
|
||||
{
|
||||
NotificationManager.sendPlayerInformation(Misc.adaptPlayer(mmoPlayer), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getPartyName(), String.valueOf(Config.getInstance().getPartyMaxSize()));
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationManager.sendPlayerInformation(Misc.adaptPlayer(mmoPlayer), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getPartyName());
|
||||
mmoPlayer.removePartyInvite();
|
||||
addToParty(mmoPlayer, invite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept a party alliance invitation
|
||||
*
|
||||
* @param mmoPlayer The player who accepts the alliance invite
|
||||
*/
|
||||
public void acceptAllianceInvite(OnlineMMOPlayer mmoPlayer) {
|
||||
Party invite = mmoPlayer.getPartyAllianceInvite();
|
||||
Player player = Misc.adaptPlayer(mmoPlayer);
|
||||
|
||||
// Check if the party still exists, it might have been disbanded
|
||||
if (!parties.contains(invite)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!handlePartyChangeAllianceEvent(player, mmoPlayer.getParty().getName(), invite.getPartyName(), McMMOPartyAllianceChangeEvent.EventReason.FORMED_ALLIANCE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.Accepted", invite.getPartyName()));
|
||||
mmoPlayer.removePartyAllianceInvite();
|
||||
|
||||
createAlliance(mmoPlayer.getParty(), invite);
|
||||
}
|
||||
|
||||
public void createAlliance(Party firstParty, Party secondParty) {
|
||||
firstParty.setAlly(secondParty);
|
||||
secondParty.setAlly(firstParty);
|
||||
|
||||
for (Player member : firstParty.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", secondParty.getPartyName()));
|
||||
}
|
||||
|
||||
for (Player member : secondParty.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", firstParty.getPartyName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean disbandAlliance(Player player, Party firstParty, Party secondParty){
|
||||
if (!handlePartyChangeAllianceEvent(player, firstParty.getPartyName(), secondParty.getPartyName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMO.getPartyManager().disbandAlliance(firstParty, secondParty);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void disbandAlliance(Party firstParty, Party secondParty) {
|
||||
firstParty.setAlly(null);
|
||||
secondParty.setAlly(null);
|
||||
|
||||
for (Player member : firstParty.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", secondParty.getPartyName()));
|
||||
}
|
||||
|
||||
for (Player member : secondParty.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", firstParty.getPartyName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party
|
||||
*
|
||||
* @param mmoPlayer The player to add to the party
|
||||
* @param party The party
|
||||
*/
|
||||
public void addToParty(OnlineMMOPlayer mmoPlayer, Party party) {
|
||||
Player player = Misc.adaptPlayer(mmoPlayer);
|
||||
String playerName = player.getName();
|
||||
|
||||
informPartyMembersJoin(party, playerName);
|
||||
party.getMembers().put(player.getUniqueId(), player.getName());
|
||||
party.getPartyMembers().add(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leader of a party.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public String getPartyLeaderName(String partyName) {
|
||||
Party party = getParty(partyName);
|
||||
|
||||
return party == null ? null : party.getLeader().getPlayerName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
*
|
||||
* @param uuid The uuid of the player to set as leader
|
||||
* @param party The party
|
||||
*/
|
||||
public void setPartyLeader(UUID uuid, Party party) {
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid);
|
||||
UUID leaderUniqueId = party.getLeader().getUniqueId();
|
||||
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
UUID memberUniqueId = member.getUniqueId();
|
||||
|
||||
if (memberUniqueId.equals(player.getUniqueId())) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.Player"));
|
||||
}
|
||||
else if (memberUniqueId.equals(leaderUniqueId)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader"));
|
||||
}
|
||||
else {
|
||||
member.sendMessage(LocaleLoader.getString("Party.Owner.New", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
party.setLeader(new PartyLeader(player.getUniqueId(), player.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can invite others to his party.
|
||||
*
|
||||
* @return true if the player can invite
|
||||
*/
|
||||
public boolean canInvite(OnlineMMOPlayer mmoPlayer) {
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
return !party.isLocked() || party.getLeader().getUniqueId().equals(mmoPlayer.getUUID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load party file.
|
||||
*/
|
||||
public void loadParties() {
|
||||
if (!partyFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) {
|
||||
loadAndUpgradeParties();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
YamlConfiguration partiesFile;
|
||||
partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||
|
||||
ArrayList<Party> hasAlly = new ArrayList<>();
|
||||
|
||||
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
Party party = new Party(partyName);
|
||||
|
||||
String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
|
||||
party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
|
||||
party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
|
||||
party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
|
||||
if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
hasAlly.add(party);
|
||||
}
|
||||
|
||||
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
|
||||
for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
}
|
||||
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
|
||||
for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) {
|
||||
String[] memberSplit = memberEntry.split("[|]");
|
||||
members.put(UUID.fromString(memberSplit[0]), memberSplit[1]);
|
||||
}
|
||||
|
||||
parties.add(party);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
|
||||
|
||||
for (Party party : hasAlly) {
|
||||
party.setAlly(mcMMO.getPartyManager().getParty(partiesFile.getString(party.getPartyName() + ".Ally")));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save party file.
|
||||
*/
|
||||
public void saveParties() {
|
||||
if (partyFile.exists()) {
|
||||
if (!partyFile.delete()) {
|
||||
mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration partiesFile = new YamlConfiguration();
|
||||
|
||||
mcMMO.p.getLogger().info("Saving Parties... (" + parties.size() + ")");
|
||||
for (Party party : parties) {
|
||||
String partyName = party.getPartyName();
|
||||
PartyLeader leader = party.getLeader();
|
||||
|
||||
partiesFile.set(partyName + ".Leader", leader.getUniqueId().toString() + "|" + leader.getPlayerName());
|
||||
partiesFile.set(partyName + ".Password", party.getPartyPassword());
|
||||
partiesFile.set(partyName + ".Locked", party.isLocked());
|
||||
partiesFile.set(partyName + ".Level", party.getLevel());
|
||||
partiesFile.set(partyName + ".Xp", (int) party.getXp());
|
||||
partiesFile.set(partyName + ".Ally", (party.getAlly() != null) ? party.getAlly().getPartyName() : "");
|
||||
partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString());
|
||||
partiesFile.set(partyName + ".ItemShareMode", party.getItemShareMode().toString());
|
||||
|
||||
for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
partiesFile.set(partyName + ".ItemShareType." + itemShareType.toString(), party.sharingDrops(itemShareType));
|
||||
}
|
||||
|
||||
List<String> members = new ArrayList<>();
|
||||
|
||||
for (Entry<UUID, String> memberEntry : party.getMembers().entrySet()) {
|
||||
String memberUniqueId = memberEntry.getKey() == null ? "" : memberEntry.getKey().toString();
|
||||
String memberName = memberEntry.getValue();
|
||||
|
||||
if (!members.contains(memberName)) {
|
||||
members.add(memberUniqueId + "|" + memberName);
|
||||
}
|
||||
}
|
||||
|
||||
partiesFile.set(partyName + ".Members", members);
|
||||
}
|
||||
|
||||
try {
|
||||
partiesFile.save(partyFile);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAndUpgradeParties() {
|
||||
YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||
|
||||
if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
|
||||
mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Party> hasAlly = new ArrayList<>();
|
||||
|
||||
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
Party party = new Party(partyName);
|
||||
|
||||
String leaderName = partiesFile.getString(partyName + ".Leader");
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(leaderName, false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName);
|
||||
continue;
|
||||
}
|
||||
|
||||
UUID leaderUniqueId = profile.getUniqueId();
|
||||
|
||||
party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
|
||||
party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
|
||||
party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
|
||||
if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
hasAlly.add(party);
|
||||
}
|
||||
|
||||
party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
|
||||
for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
}
|
||||
|
||||
LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
|
||||
for (String memberName : partiesFile.getStringList(partyName + ".Members")) {
|
||||
PlayerProfile memberProfile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(memberName, false);
|
||||
|
||||
if (!memberProfile.isLoaded()) {
|
||||
mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName);
|
||||
continue;
|
||||
}
|
||||
|
||||
UUID memberUniqueId = memberProfile.getUniqueId();
|
||||
|
||||
members.put(memberUniqueId, memberName);
|
||||
}
|
||||
|
||||
parties.add(party);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
|
||||
|
||||
for (Party party : hasAlly) {
|
||||
party.setAlly(mcMMO.getPartyManager().getParty(partiesFile.getString(party.getPartyName() + ".Ally")));
|
||||
}
|
||||
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle party change event.
|
||||
*
|
||||
* @param player The player changing parties
|
||||
* @param oldPartyName The name of the old party
|
||||
* @param newPartyName The name of the new party
|
||||
* @param reason The reason for changing parties
|
||||
* @return true if the change event was successful, false otherwise
|
||||
*/
|
||||
public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle party alliance change event.
|
||||
*
|
||||
* @param player The player changing party alliances
|
||||
* @param oldAllyName The name of the old ally
|
||||
* @param newAllyName The name of the new ally
|
||||
* @param reason The reason for changing allies
|
||||
* @return true if the change event was successful, false otherwise
|
||||
*/
|
||||
public boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) {
|
||||
McMMOPartyAllianceChangeEvent event = new McMMOPartyAllianceChangeEvent(player, oldAllyName, newAllyName, reason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove party data from the mmoPlayer.
|
||||
*
|
||||
* @param mmoPlayer The player to remove party data from.
|
||||
*/
|
||||
public void processPartyLeaving(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
mmoPlayer.removeParty();
|
||||
mmoPlayer.setChatMode(ChatChannel.NONE);
|
||||
mmoPlayer.setItemShareModifier(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when the party levels up.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param levelsGained The amount of levels gained
|
||||
* @param level The current party level
|
||||
*/
|
||||
public void informPartyMembersLevelUp(Party party, int levelsGained, int level) {
|
||||
boolean levelUpSoundsEnabled = Config.getInstance().getLevelUpSoundsEnabled();
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
|
||||
|
||||
if (levelUpSoundsEnabled) {
|
||||
SoundManager.sendSound(member, member.getLocation(), SoundType.LEVEL_UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when a player joins.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that joined
|
||||
*/
|
||||
private void informPartyMembersJoin(Party party, String playerName) {
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify party members when a party member quits.
|
||||
*
|
||||
* @param party The concerned party
|
||||
* @param playerName The name of the player that left
|
||||
*/
|
||||
private void informPartyMembersQuit(Party party, String playerName) {
|
||||
for (Player member : party.getPartyMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName));
|
||||
}
|
||||
}
|
||||
}
|
211
src/main/java/com/gmail/nossr50/party/PartyManagerImpl.java
Normal file
211
src/main/java/com/gmail/nossr50/party/PartyManagerImpl.java
Normal file
@ -0,0 +1,211 @@
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.party.PartyManager;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* About mcMMO parties
|
||||
* Parties are identified by a {@link String} name
|
||||
* Parties always have a party leader, if the party leader is not defined mcMMO will force party leadership onto someone in the party
|
||||
*/
|
||||
//TODO: Needs to be optimized, currently all parties are loaded into memory, it should be changed to as needed, but then we need to handle loading asynchronously and accommodate for that
|
||||
public final class PartyManagerImpl implements PartyManager {
|
||||
private final @NotNull HashMap<String, Party> parties;
|
||||
private final @NotNull File partyFile;
|
||||
|
||||
public PartyManagerImpl() {
|
||||
String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||
partyFile = new File(partiesFilePath);
|
||||
parties = new HashMap<>();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Load party file.
|
||||
// */
|
||||
// public void loadParties() {
|
||||
// if (!partyFile.exists()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS_PARTY)) {
|
||||
// loadAndUpgradeParties();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// YamlConfiguration partiesFile;
|
||||
// partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||
//
|
||||
// ArrayList<Party> hasAlly = new ArrayList<>();
|
||||
//
|
||||
// for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
// Party party = new Party(partyName);
|
||||
//
|
||||
// String[] leaderSplit = partiesFile.getString(partyName + ".Leader").split("[|]");
|
||||
// party.setLeader(new PartyLeader(UUID.fromString(leaderSplit[0]), leaderSplit[1]));
|
||||
// party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
|
||||
// party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
// party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
// party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
//
|
||||
// if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
// hasAlly.add(party);
|
||||
// }
|
||||
//
|
||||
// party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
// party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
//
|
||||
// for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
// party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
// }
|
||||
//
|
||||
// LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
//
|
||||
// for (String memberEntry : partiesFile.getStringList(partyName + ".Members")) {
|
||||
// String[] memberSplit = memberEntry.split("[|]");
|
||||
// members.put(UUID.fromString(memberSplit[0]), memberSplit[1]);
|
||||
// }
|
||||
//
|
||||
// parties.add(party);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
|
||||
//
|
||||
// for (Party party : hasAlly) {
|
||||
// party.setAlly(mcMMO.getPartyManager().getParty(partiesFile.getString(party.getPartyName() + ".Ally")));
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Save party file.
|
||||
// */
|
||||
// public void saveParties() {
|
||||
// if (partyFile.exists()) {
|
||||
// if (!partyFile.delete()) {
|
||||
// mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// YamlConfiguration partiesFile = new YamlConfiguration();
|
||||
//
|
||||
// mcMMO.p.getLogger().info("Saving Parties... (" + parties.size() + ")");
|
||||
// for (Party party : parties) {
|
||||
// String partyName = party.getPartyName();
|
||||
// PartyLeader leader = party.getLeader();
|
||||
//
|
||||
// partiesFile.set(partyName + ".Leader", leader.getUniqueId().toString() + "|" + leader.getPlayerName());
|
||||
// partiesFile.set(partyName + ".Password", party.getPartyPassword());
|
||||
// partiesFile.set(partyName + ".Locked", party.isLocked());
|
||||
// partiesFile.set(partyName + ".Level", party.getLevel());
|
||||
// partiesFile.set(partyName + ".Xp", (int) party.getXp());
|
||||
// partiesFile.set(partyName + ".Ally", (party.getAlly() != null) ? party.getAlly().getPartyName() : "");
|
||||
// partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString());
|
||||
// partiesFile.set(partyName + ".ItemShareMode", party.getItemShareMode().toString());
|
||||
//
|
||||
// for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
// partiesFile.set(partyName + ".ItemShareType." + itemShareType.toString(), party.sharingDrops(itemShareType));
|
||||
// }
|
||||
//
|
||||
// List<String> members = new ArrayList<>();
|
||||
//
|
||||
// for (Entry<UUID, String> memberEntry : party.getMembers().entrySet()) {
|
||||
// String memberUniqueId = memberEntry.getKey() == null ? "" : memberEntry.getKey().toString();
|
||||
// String memberName = memberEntry.getValue();
|
||||
//
|
||||
// if (!members.contains(memberName)) {
|
||||
// members.add(memberUniqueId + "|" + memberName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// partiesFile.set(partyName + ".Members", members);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// partiesFile.save(partyFile);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void loadAndUpgradeParties() {
|
||||
// YamlConfiguration partiesFile = YamlConfiguration.loadConfiguration(partyFile);
|
||||
//
|
||||
// if (!partyFile.renameTo(new File(mcMMO.getFlatFileDirectory() + "parties.yml.converted"))) {
|
||||
// mcMMO.p.getLogger().severe("Could not rename parties.yml to parties.yml.converted!");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ArrayList<Party> hasAlly = new ArrayList<>();
|
||||
//
|
||||
// for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
|
||||
// Party party = new Party(partyName);
|
||||
//
|
||||
// String leaderName = partiesFile.getString(partyName + ".Leader");
|
||||
// PlayerProfile profile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(leaderName, false);
|
||||
//
|
||||
// if (!profile.isLoaded()) {
|
||||
// mcMMO.p.getLogger().warning("Could not find UUID in database for party leader " + leaderName + " in party " + partyName);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// UUID leaderUniqueId = profile.getUniqueId();
|
||||
//
|
||||
// party.setLeader(new PartyLeader(leaderUniqueId, leaderName));
|
||||
// party.setPartyPassword(partiesFile.getString(partyName + ".Password"));
|
||||
// party.setPartyLock(partiesFile.getBoolean(partyName + ".Locked"));
|
||||
// party.setLevel(partiesFile.getInt(partyName + ".Level"));
|
||||
// party.setXp(partiesFile.getInt(partyName + ".Xp"));
|
||||
//
|
||||
// if (partiesFile.getString(partyName + ".Ally") != null) {
|
||||
// hasAlly.add(party);
|
||||
// }
|
||||
//
|
||||
// party.setXpShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ExpShareMode", "NONE")));
|
||||
// party.setItemShareMode(ShareMode.getShareMode(partiesFile.getString(partyName + ".ItemShareMode", "NONE")));
|
||||
//
|
||||
// for (ItemShareType itemShareType : ItemShareType.values()) {
|
||||
// party.setSharingDrops(itemShareType, partiesFile.getBoolean(partyName + ".ItemShareType." + itemShareType.toString(), true));
|
||||
// }
|
||||
//
|
||||
// LinkedHashMap<UUID, String> members = party.getMembers();
|
||||
//
|
||||
// for (String memberName : partiesFile.getStringList(partyName + ".Members")) {
|
||||
// PlayerProfile memberProfile = mcMMO.getDatabaseManager().queryPlayerDataByUUID(memberName, false);
|
||||
//
|
||||
// if (!memberProfile.isLoaded()) {
|
||||
// mcMMO.p.getLogger().warning("Could not find UUID in database for party member " + memberName + " in party " + partyName);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// UUID memberUniqueId = memberProfile.getUniqueId();
|
||||
//
|
||||
// members.put(memberUniqueId, memberName);
|
||||
// }
|
||||
//
|
||||
// parties.add(party);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getLogger().info("Loaded (" + parties.size() + ") Parties...");
|
||||
//
|
||||
// for (Party party : hasAlly) {
|
||||
// party.setAlly(mcMMO.getPartyManager().getParty(partiesFile.getString(party.getPartyName() + ".Ally")));
|
||||
// }
|
||||
//
|
||||
// mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY);
|
||||
// }
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.neetgames.mcmmo.party.PartyMemberRank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -7,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyMember {
|
||||
public class PartyMemberImpl {
|
||||
private String playerName;
|
||||
private final @NotNull UUID playerUUID;
|
||||
private @Nullable OfflinePlayer offlinePlayer;
|
||||
@ -15,7 +16,7 @@ public class PartyMember {
|
||||
private @Nullable PartyTeleportRecord partyTeleportRecord;
|
||||
private int itemShareModifier;
|
||||
|
||||
public PartyMember(@NotNull UUID playerUUID, @NotNull PartyMemberRank partyMemberRank) {
|
||||
public PartyMemberImpl(@NotNull UUID playerUUID, @NotNull PartyMemberRank partyMemberRank) {
|
||||
this.playerUUID = playerUUID;
|
||||
this.partyMemberRank = partyMemberRank;
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.neetgames.mcmmo.party.PartyMember;
|
||||
import com.neetgames.mcmmo.party.PartyMemberManager;
|
||||
import com.neetgames.mcmmo.party.PartyMemberRank;
|
||||
import com.neetgames.mcmmo.player.MMOPlayer;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -11,13 +15,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PartyMemberManager {
|
||||
public class PartyMemberManagerImpl implements PartyMemberManager {
|
||||
|
||||
private final @NotNull PersistentPartyData persistentPartyData;
|
||||
private final @NotNull HashMap<UUID, PartyMember> partyMemberMap;
|
||||
private @Nullable PartyMember partyLeaderRef;
|
||||
|
||||
public PartyMemberManager(@NotNull PersistentPartyData persistentPartyData) {
|
||||
public PartyMemberManagerImpl(@NotNull PersistentPartyData persistentPartyData) {
|
||||
this.persistentPartyData = persistentPartyData;
|
||||
this.partyMemberMap = new HashMap<>();
|
||||
initPartyLeaderRef();
|
||||
@ -28,6 +32,7 @@ public class PartyMemberManager {
|
||||
*
|
||||
* @return all party members
|
||||
*/
|
||||
@Override
|
||||
public @NotNull Set<PartyMember> getPartyMembers() {
|
||||
return persistentPartyData.getPartyMembers();
|
||||
}
|
||||
@ -38,6 +43,7 @@ public class PartyMemberManager {
|
||||
* @param playerUUID target UUID
|
||||
* @return the party member if they exist, otherwise null
|
||||
*/
|
||||
@Override
|
||||
public @Nullable PartyMember getPartyMember(@NotNull UUID playerUUID) {
|
||||
return partyMemberMap.get(playerUUID);
|
||||
}
|
||||
@ -50,10 +56,11 @@ public class PartyMemberManager {
|
||||
* @param playerUUID target player's uuid
|
||||
* @param partyMemberRank target rank
|
||||
*/
|
||||
@Override
|
||||
public void addPartyMember(@NotNull UUID playerUUID, @NotNull PartyMemberRank partyMemberRank) {
|
||||
//TODO: Prevent adding multiple leaders
|
||||
//TODO: Call event
|
||||
PartyMember partyMember = new PartyMember(playerUUID, partyMemberRank);
|
||||
PartyMember partyMember = new PartyMemberImpl(playerUUID, partyMemberRank);
|
||||
persistentPartyData.getPartyMembers().add(partyMember);
|
||||
partyMemberMap.put(playerUUID, partyMember);
|
||||
}
|
||||
@ -62,10 +69,10 @@ public class PartyMemberManager {
|
||||
* Get party members that are "Visible" to a target {@link Player}
|
||||
*
|
||||
* @param player target {@link Player}
|
||||
* @return returns a {@link HashSet<PartyMember>} which are visible to the player
|
||||
* @return returns a {@link HashSet< PartyMember >} which are visible to the player
|
||||
*/
|
||||
public @NotNull HashSet<PartyMember> getVisibleMembers(@NotNull Player player)
|
||||
{
|
||||
@Override
|
||||
public @NotNull HashSet<PartyMember> getVisibleMembers(@NotNull OnlineMMOPlayer onlineMMOPlayer) {
|
||||
HashSet<PartyMember> visibleMembers = new HashSet<>();
|
||||
|
||||
for(PartyMember partyMember : persistentPartyData.getPartyMembers())
|
||||
@ -116,6 +123,7 @@ public class PartyMemberManager {
|
||||
*
|
||||
* @return the party leader
|
||||
*/
|
||||
@Override
|
||||
public @NotNull PartyMember getPartyLeader() {
|
||||
if(partyLeaderRef == null) {
|
||||
//The first player in a party is now the leader
|
||||
@ -126,10 +134,16 @@ public class PartyMemberManager {
|
||||
return partyLeaderRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMember(@NotNull UUID playerUUID) {
|
||||
return partyMemberMap.containsKey(playerUUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMember(@NotNull MMOPlayer mmoPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasMember(@NotNull Player player) {
|
||||
return hasMember(player.getUniqueId());
|
||||
}
|
||||
@ -162,7 +176,7 @@ public class PartyMemberManager {
|
||||
* @param mmoPlayer The player to check
|
||||
* @return the near party members
|
||||
*/
|
||||
public @NotNull List<Player> getNearMembers(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
public @NotNull List<OnlineMMOPlayer> getNearMembers(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
List<Player> nearMembers = new ArrayList<>();
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Misc;
|
@ -1,5 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes.party;
|
||||
package com.gmail.nossr50.party;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.neetgames.mcmmo.party.PartyMember;
|
||||
import com.neetgames.neetlib.dirtydata.DirtyData;
|
||||
import com.neetgames.neetlib.dirtydata.DirtySet;
|
||||
import com.neetgames.neetlib.mutableprimitives.MutableBoolean;
|
||||
@ -7,7 +9,6 @@ import com.neetgames.neetlib.mutableprimitives.MutableString;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public class PersistentPartyData {
|
||||
@ -34,16 +35,24 @@ public class PersistentPartyData {
|
||||
return dirtyFlag.getImmutableCopy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PersistentPartyData{" +
|
||||
"partyName=" + partyName +
|
||||
", partyMembers=" + partyMembers +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersistentPartyData that = (PersistentPartyData) o;
|
||||
return dirtyFlag.equals(that.dirtyFlag) && partyName.equals(that.partyName) && partyMembers.equals(that.partyMembers);
|
||||
return Objects.equal(partyName, that.partyName) && Objects.equal(partyMembers, that.partyMembers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(dirtyFlag, partyName, partyMembers);
|
||||
return Objects.hashCode(partyName, partyMembers);
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@ package com.gmail.nossr50.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||
import com.neetgames.mcmmo.experience.XPGainReason;
|
||||
import com.neetgames.mcmmo.experience.XPGainSource;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -59,102 +59,6 @@ public final class ShareHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Distribute Items amongst party members.
|
||||
*
|
||||
* @param drop Item that will get shared
|
||||
* @param mmoPlayer Player who picked up the item
|
||||
* @return True if the item has been shared
|
||||
*/
|
||||
public static boolean handleItemShare(Item drop, OnlineMMOPlayer mmoPlayer) {
|
||||
ItemStack itemStack = drop.getItemStack();
|
||||
ItemShareType dropType = ItemShareType.getShareType(itemStack);
|
||||
|
||||
if (dropType == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party party = mmoPlayer.getParty();
|
||||
|
||||
if (!party.sharingDrops(dropType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ShareMode shareMode = party.getItemShareMode();
|
||||
|
||||
if (shareMode == ShareMode.NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Player> nearMembers = mcMMO.getPartyManager().getNearMembers(mmoPlayer);
|
||||
|
||||
if (nearMembers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player winningPlayer = null;
|
||||
ItemStack newStack = itemStack.clone();
|
||||
|
||||
nearMembers.add(mmoPlayer.getPlayer());
|
||||
int partySize = nearMembers.size();
|
||||
|
||||
drop.remove();
|
||||
newStack.setAmount(1);
|
||||
|
||||
switch (shareMode) {
|
||||
case EQUAL:
|
||||
int itemWeight = ItemWeightConfig.getInstance().getItemWeight(itemStack.getType());
|
||||
|
||||
for (int i = 0; i < itemStack.getAmount(); i++) {
|
||||
int highestRoll = 0;
|
||||
|
||||
for (Player member : nearMembers) {
|
||||
OnlineMMOPlayer mcMMOMember = mcMMO.getUserManager().getPlayer(member);
|
||||
|
||||
//Profile not loaded
|
||||
if(mcMMO.getUserManager().getPlayer(member) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int itemShareModifier = mcMMOMember.getItemShareModifier();
|
||||
int diceRoll = Misc.getRandom().nextInt(itemShareModifier);
|
||||
|
||||
if (diceRoll <= highestRoll) {
|
||||
mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight);
|
||||
continue;
|
||||
}
|
||||
|
||||
highestRoll = diceRoll;
|
||||
|
||||
if (winningPlayer != null) {
|
||||
OnlineMMOPlayer mcMMOWinning = mcMMO.getUserManager().getPlayer(winningPlayer);
|
||||
mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight);
|
||||
}
|
||||
|
||||
winningPlayer = member;
|
||||
}
|
||||
|
||||
OnlineMMOPlayer mcMMOTarget = mcMMO.getUserManager().getPlayer(winningPlayer);
|
||||
mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight);
|
||||
awardDrop(winningPlayer, newStack);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case RANDOM:
|
||||
for (int i = 0; i < itemStack.getAmount(); i++) {
|
||||
winningPlayer = nearMembers.get(Misc.getRandom().nextInt(partySize));
|
||||
awardDrop(winningPlayer, newStack);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) {
|
||||
if (xpGainReason == XPGainReason.PVE) {
|
||||
return XPGainReason.SHARED_PVE;
|
||||
@ -166,12 +70,4 @@ public final class ShareHandler {
|
||||
return xpGainReason;
|
||||
}
|
||||
}
|
||||
|
||||
private static void awardDrop(Player winningPlayer, ItemStack drop) {
|
||||
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
|
||||
winningPlayer.getWorld().dropItem(winningPlayer.getLocation(), drop);
|
||||
}
|
||||
|
||||
winningPlayer.updateInventory();
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public final class Permissions {
|
||||
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); }
|
||||
|
||||
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
||||
public static boolean lucky(Permissible permissible, RootSkill rootSkill) { return permissible.hasPermission("mcmmo.perks.lucky." + rootSkill.getSkillName().toLowerCase(Locale.ENGLISH)); }
|
||||
public static boolean lucky(Permissible permissible, RootSkill rootSkill) { return permissible.hasPermission("mcmmo.perks.lucky." + rootSkill.getRawSkillName().toLowerCase(Locale.ENGLISH)); }
|
||||
|
||||
/* XP PERKS */
|
||||
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase(Locale.ENGLISH)); }
|
||||
|
@ -167,7 +167,7 @@ public class MMOExperienceBarManager {
|
||||
private void informPlayer(@NotNull SkillBossBarSetting settingTarget, @NotNull RootSkill rootSkill) {
|
||||
//Inform player of setting change
|
||||
if(settingTarget != SkillBossBarSetting.RESET) {
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.SettingChanged", rootSkill.getSkillName(), settingTarget.toString());
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.SettingChanged", rootSkill.getRawSkillName(), settingTarget.toString());
|
||||
} else {
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(Misc.adaptPlayer(mmoPlayer), "Commands.XPBar.Reset");
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.input;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
@ -24,12 +25,13 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbilityActivationProcessor {
|
||||
private final OnlineMMOPlayer mmoPlayer;
|
||||
private final Player player;
|
||||
private final @NotNull OnlineMMOPlayer mmoPlayer;
|
||||
private final @NotNull Player player;
|
||||
|
||||
public AbilityActivationProcessor(OnlineMMOPlayer mmoPlayer) {
|
||||
public AbilityActivationProcessor(@NotNull OnlineMMOPlayer mmoPlayer) {
|
||||
this.mmoPlayer = mmoPlayer;
|
||||
this.player = Misc.adaptPlayer(mmoPlayer);
|
||||
}
|
||||
@ -238,7 +240,7 @@ public class AbilityActivationProcessor {
|
||||
return !getAbilityMode(ability) && calculateTimeRemaining(ability) > 0;
|
||||
}
|
||||
|
||||
private SuperAbilityManager getSuperAbilityManager() {
|
||||
private SuperSkillManagerImpl getSuperAbilityManager() {
|
||||
return mmoPlayer.getSuperAbilityManager();
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import com.neetgames.mcmmo.player.SuperSkillManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SuperAbilityManager {
|
||||
public class SuperSkillManagerImpl implements SuperSkillManager {
|
||||
|
||||
private final McMMOPlayer mmoPlayer;
|
||||
private final Player player;
|
||||
@ -39,7 +40,7 @@ public class SuperAbilityManager {
|
||||
private final Map<AbilityToolType, Boolean> toolMode = new HashMap<>();
|
||||
private final MMOPlayerData mmoPlayerData;
|
||||
|
||||
public SuperAbilityManager(@NotNull McMMOPlayer mmoPlayer, @NotNull MMOPlayerData mmoPlayerData) {
|
||||
public SuperSkillManagerImpl(@NotNull McMMOPlayer mmoPlayer, @NotNull MMOPlayerData mmoPlayerData) {
|
||||
this.mmoPlayer = mmoPlayer;
|
||||
this.mmoPlayerData = mmoPlayerData;
|
||||
this.player = Misc.adaptPlayer(mmoPlayer);
|
@ -2,8 +2,7 @@ package com.gmail.nossr50.util.player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.neetgames.mcmmo.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.party.PartyMember;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||
import com.gmail.nossr50.party.PartyFeature;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
|
Loading…
Reference in New Issue
Block a user