mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 19:54:44 +02:00
Moving party stuff from PlayerProfile to McMMOPlayer
This commit is contained in:
@ -8,6 +8,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@ -27,15 +28,15 @@ public final class PartyManager {
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
||||
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
||||
McMMOPlayer firstMcMMOPlayer = Users.getPlayer(firstPlayer);
|
||||
McMMOPlayer secondMcMMOPlayer = Users.getPlayer(secondPlayer);
|
||||
|
||||
if (firstProfile == null || secondProfile == null) {
|
||||
if (firstMcMMOPlayer == null || secondMcMMOPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = firstProfile.getParty();
|
||||
Party secondParty = secondProfile.getParty();
|
||||
Party firstParty = firstMcMMOPlayer.getParty();
|
||||
Party secondParty = secondMcMMOPlayer.getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null || firstParty != secondParty) {
|
||||
return false;
|
||||
@ -98,7 +99,7 @@ public final class PartyManager {
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
Party party = Users.getProfile(player).getParty();
|
||||
Party party = Users.getPlayer(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
return null;
|
||||
@ -197,10 +198,10 @@ public final class PartyManager {
|
||||
informPartyMembersQuit(playerName, party);
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = Users.getProfile(playerName);
|
||||
|
||||
if (playerProfile != null) {
|
||||
playerProfile.removeParty();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(playerName);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
mcMMOPlayer.removeParty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,10 +214,11 @@ public final class PartyManager {
|
||||
List<String> members = party.getMembers();
|
||||
|
||||
for (String member : party.getMembers()) {
|
||||
PlayerProfile playerProfile = Users.getProfile(member);
|
||||
|
||||
if (playerProfile != null) {
|
||||
playerProfile.removeParty();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(member);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
mcMMOPlayer.removeParty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,11 +232,11 @@ public final class PartyManager {
|
||||
* Create a new party
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player to add to the party
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password the password for this party, null if there was no password
|
||||
* @param password The password for this party, null if there was no password
|
||||
*/
|
||||
public static void createParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||
partyName = partyName.replace(".", "");
|
||||
Party party = getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
@ -260,18 +262,18 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
||||
addToParty(player.getName(), playerProfile, party);
|
||||
addToParty(player.getName(), mcMMOPlayer, party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player to add to the party
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
* @param password the password for this party, null if there was no password
|
||||
*/
|
||||
public static void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
||||
partyName = partyName.replace(".", "");
|
||||
Party party = getParty(partyName);
|
||||
String playerName = player.getName();
|
||||
@ -294,7 +296,7 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
|
||||
addToParty(player.getName(), playerProfile, party);
|
||||
addToParty(player.getName(), mcMMOPlayer, party);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,31 +335,31 @@ public final class PartyManager {
|
||||
/**
|
||||
* Accept a party invitation
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param playerProfile The profile of the player
|
||||
* @param Player The plaer to add to the party
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
*/
|
||||
public static void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
||||
Party invite = playerProfile.getInvite();
|
||||
public static void joinInvitedParty(Player player, McMMOPlayer mcMMOPlayer) {
|
||||
Party invite = mcMMOPlayer.getInvite();
|
||||
|
||||
if (!parties.contains(invite)) {
|
||||
parties.add(invite);
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
|
||||
playerProfile.removeInvite();
|
||||
addToParty(player.getName(), playerProfile, invite);
|
||||
mcMMOPlayer.removeInvite();
|
||||
addToParty(player.getName(), mcMMOPlayer, invite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party
|
||||
*
|
||||
* @param playerName The name of the player to add to a party
|
||||
* @param playerProfile The profile of the player
|
||||
* @param mcMMOPlayer The player to add to the party
|
||||
* @param party The party
|
||||
*/
|
||||
public static void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
||||
public static void addToParty(String playerName, McMMOPlayer mcMMOPlayer, Party party) {
|
||||
informPartyMembersJoin(playerName, party);
|
||||
playerProfile.setParty(party);
|
||||
mcMMOPlayer.setParty(party);
|
||||
party.getMembers().add(playerName);
|
||||
}
|
||||
|
||||
@ -402,14 +404,14 @@ public final class PartyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player can invite others to their party.
|
||||
* Check if a player can invite others to his party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param playerProfile The profile of the given player
|
||||
* @param mcMMOPlayer The player to check
|
||||
* @return true if the player can invite
|
||||
*/
|
||||
public static boolean canInvite(Player player, PlayerProfile playerProfile) {
|
||||
Party party = playerProfile.getParty();
|
||||
public static boolean canInvite(Player player, McMMOPlayer mcMMOPlayer) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
|
||||
return false;
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -20,8 +20,8 @@ import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@ -33,8 +33,8 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.player = (Player) sender;
|
||||
this.playerProfile = Users.getProfile(player);
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = Users.getPlayer(player);
|
||||
|
||||
if (args.length < 1 || args[0].equalsIgnoreCase("info")) {
|
||||
return party();
|
||||
@ -53,7 +53,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return printHelp();
|
||||
}
|
||||
|
||||
if (playerProfile.inParty()) {
|
||||
if (mcMMOPlayer.inParty()) {
|
||||
if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave")) {
|
||||
return quit();
|
||||
}
|
||||
@ -104,8 +104,8 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean party() {
|
||||
if (playerProfile.inParty()) {
|
||||
Party party = playerProfile.getParty();
|
||||
if (mcMMOPlayer.inParty()) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
Server server = mcMMO.p.getServer();
|
||||
String leader = party.getLeader();
|
||||
@ -174,9 +174,6 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||
return true;
|
||||
@ -189,7 +186,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Users.getProfile(target).inParty()) {
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", args[1]));
|
||||
return false;
|
||||
}
|
||||
@ -199,7 +196,9 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (party != null && party.equals(Users.getProfile(target).getParty())) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party != null && party.equals(Users.getPlayer(target).getParty())) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return true;
|
||||
}
|
||||
@ -210,26 +209,26 @@ public class PartyCommand implements CommandExecutor {
|
||||
password = args[2];
|
||||
}
|
||||
|
||||
String partyTarget = PartyManager.getPlayerParty(target.getName()).getName();
|
||||
Party newParty = PartyManager.getParty(args[0]);
|
||||
Party targetParty = Users.getPlayer(target).getParty();
|
||||
|
||||
// Check to see if the party exists, and if it does, can the player join it?
|
||||
if (newParty != null && !PartyManager.checkJoinability(player, newParty, null)) {
|
||||
if (targetParty != null && !PartyManager.checkJoinability(player, targetParty, null)) {
|
||||
return true; // End before any event is fired.
|
||||
}
|
||||
|
||||
// TODO: We shoudln't fire the event before checking if the password is correct
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), partyTarget, EventReason.CHANGED_PARTIES);
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), targetParty.getName(), EventReason.CHANGED_PARTIES);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(playerName, party);
|
||||
PartyManager.removeFromParty(player.getName(), party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyTarget, EventReason.JOINED_PARTY);
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, targetParty.getName(), EventReason.JOINED_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -237,7 +236,8 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
PartyManager.joinParty(player, playerProfile, partyTarget, password);
|
||||
|
||||
PartyManager.joinParty(player, mcMMOPlayer, targetParty.getName(), password);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -246,10 +246,10 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerProfile.hasPartyInvite()) {
|
||||
if (playerProfile.inParty()) {
|
||||
Party party = playerProfile.getParty();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||
if (mcMMOPlayer.hasPartyInvite()) {
|
||||
if (mcMMOPlayer.inParty()) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), mcMMOPlayer.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@ -260,7 +260,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
PartyManager.removeFromParty(player.getName(), party);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, mcMMOPlayer.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -268,7 +268,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
PartyManager.joinInvitedParty(player, playerProfile);
|
||||
PartyManager.joinInvitedParty(player, mcMMOPlayer);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
@ -283,7 +283,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||
@ -304,7 +304,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerProfile.inParty()) {
|
||||
if (mcMMOPlayer.inParty()) {
|
||||
String oldPartyName = party.getName();
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, partyname, EventReason.CHANGED_PARTIES);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
@ -314,7 +314,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(playerName, party);
|
||||
PartyManager.createParty(player, playerProfile, partyname, password);
|
||||
PartyManager.createParty(player, mcMMOPlayer, partyname, password);
|
||||
}
|
||||
else {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyname, EventReason.JOINED_PARTY);
|
||||
@ -324,7 +324,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.createParty(player, playerProfile, partyname, password);
|
||||
PartyManager.createParty(player, mcMMOPlayer, partyname, password);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
||||
@ -361,15 +361,14 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[sharemode]"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("false")) {
|
||||
party.setXpShareMode(ShareHandler.XpShareMode.NONE);
|
||||
@ -411,7 +410,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!playerProfile.inParty()) {
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return true;
|
||||
}
|
||||
@ -423,10 +422,11 @@ public class PartyCommand implements CommandExecutor {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.InSameParty"));
|
||||
return true;
|
||||
}
|
||||
if (PartyManager.canInvite(player, playerProfile)) {
|
||||
Party party = playerProfile.getParty();
|
||||
|
||||
Users.getProfile(target).setInvite(party);
|
||||
if (PartyManager.canInvite(player, mcMMOPlayer)) {
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
Users.getPlayer(target).setInvite(party);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", party.getName(), player.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
@ -455,7 +455,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
if (!party.getMembers().contains(targetName)) {
|
||||
@ -496,7 +496,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||
@ -528,7 +528,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||
@ -556,7 +556,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
@ -588,7 +588,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party != null) {
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
@ -617,7 +617,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (!party.getLeader().equals(playerName)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
@ -647,7 +647,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = playerProfile.getParty();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
String leader = party.getLeader();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -18,7 +19,7 @@ import com.gmail.nossr50.util.Users;
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
private Player player;
|
||||
private PlayerProfile playerProfile;
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
|
||||
public PtpCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
@ -38,8 +39,9 @@ public class PtpCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
this.player = (Player) sender;
|
||||
this.playerProfile = Users.getProfile(player);
|
||||
player = (Player) sender;
|
||||
mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return togglePartyTeleportation();
|
||||
@ -86,15 +88,15 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
PlayerProfile targetProfile = Users.getProfile(target);
|
||||
McMMOPlayer targetMcMMOPlayer = Users.getPlayer(target);
|
||||
|
||||
if (!targetProfile.getPtpEnabled()) {
|
||||
if (!targetMcMMOPlayer.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Users.getProfile(target).getPtpConfirmRequired()) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, playerProfile.getParty().getName());
|
||||
if (!targetMcMMOPlayer.getPtpConfirmRequired()) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -104,10 +106,10 @@ public class PtpCommand implements CommandExecutor {
|
||||
player.teleport(target);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName()));
|
||||
playerProfile.setRecentlyHurt(System.currentTimeMillis());
|
||||
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
|
||||
} else {
|
||||
targetProfile.setPtpRequest(player);
|
||||
targetProfile.actualizePtpTimeout();
|
||||
targetMcMMOPlayer.setPtpRequest(player);
|
||||
targetMcMMOPlayer.actualizePtpTimeout();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
|
||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||
@ -122,20 +124,20 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean acceptTeleportRequest() {
|
||||
if (!playerProfile.hasPtpRequest()) {
|
||||
if (!mcMMOPlayer.hasPtpRequest()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
|
||||
return true;
|
||||
}
|
||||
|
||||
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
|
||||
|
||||
if ((playerProfile.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
|
||||
playerProfile.removePtpRequest();
|
||||
if ((mcMMOPlayer.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
|
||||
mcMMOPlayer.removePtpRequest();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = playerProfile.getPtpRequest();
|
||||
Player target = mcMMOPlayer.getPtpRequest();
|
||||
|
||||
if (target == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||
@ -147,7 +149,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, playerProfile.getParty().getName());
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -157,31 +159,31 @@ public class PtpCommand implements CommandExecutor {
|
||||
target.teleport(player);
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName()));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName()));
|
||||
playerProfile.setRecentlyHurt(System.currentTimeMillis());
|
||||
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean acceptAnyTeleportRequest() {
|
||||
if (playerProfile.getPtpConfirmRequired()) {
|
||||
if (mcMMOPlayer.getPtpConfirmRequired()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
|
||||
}
|
||||
|
||||
playerProfile.togglePtpConfirmRequired();
|
||||
mcMMOPlayer.togglePtpConfirmRequired();
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean togglePartyTeleportation() {
|
||||
if (playerProfile.getPtpEnabled()) {
|
||||
if (mcMMOPlayer.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
|
||||
}
|
||||
|
||||
playerProfile.togglePtpUse();
|
||||
mcMMOPlayer.togglePtpUse();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user