Reworked party commands.

Party commands are now all subcommands of /party. Use /party create
<party-name> to create a new party. To join an existing party, player
can now use /party join <player-name>. You can only join unlocked
parties. New parties are locked by default and require the party leader
to invite members.
This commit is contained in:
TfT_02 2013-01-26 00:40:23 +01:00
parent 85b909a7ab
commit d601496173
8 changed files with 598 additions and 374 deletions

View File

@ -12,6 +12,8 @@ Version 1.4.00-dev
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
+ Added config options for Hylian Luck skill
+ Added display values to Unarmed command for Iron Grip
+ Added '/party create <name>' command, use this to create a party
+ Added '/party disband' command, kicks out all members and deletes the party
= Fixed several typos relating to locale string display
= Fixed bug where all skill guide headers appeared as "Skillname Guide Guide"
= Fixed bug where Impact was applied incorrectly due to an inverted method call
@ -24,11 +26,14 @@ Version 1.4.00-dev
= Fixed abilities activating with the wrong tool in hand
= Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted)
= Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's.
= Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player
= Fixed a bug where party join messages weren't displayed
! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent
! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR.
! Changed how Tree Feller is handled, it should now put less stress on the CPU
! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values
! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API.
! Changed the way party commands work, use /party ? to check how to use the new commands
Version 1.3.14
+ Added new Hylian Luck skill to Herbalism.

View File

@ -51,8 +51,6 @@ import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.commands.ACommand;
import com.gmail.nossr50.party.commands.AcceptCommand;
import com.gmail.nossr50.party.commands.InviteCommand;
import com.gmail.nossr50.party.commands.PCommand;
import com.gmail.nossr50.party.commands.PartyCommand;
import com.gmail.nossr50.party.commands.PtpCommand;
@ -414,18 +412,10 @@ public class mcMMO extends JavaPlugin {
}
//Party commands
if (configInstance.getCommandAcceptEnabled()) {
getCommand("accept").setExecutor(new AcceptCommand(this));
}
if (configInstance.getCommandAdminChatAEnabled()) {
getCommand("a").setExecutor(new ACommand(this));
}
if (configInstance.getCommandInviteEnabled()) {
getCommand("invite").setExecutor(new InviteCommand(this));
}
if (configInstance.getCommandPartyEnabled()) {
getCommand("party").setExecutor(new PartyCommand(this));
}

View File

@ -66,7 +66,7 @@ public class PartyManager {
*/
private void informPartyMembersJoin(String playerName, Party party) {
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
if (!member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
@ -80,7 +80,7 @@ public class PartyManager {
*/
private void informPartyMembersQuit(String playerName, Party party) {
for (Player member : party.getOnlineMembers()) {
if (member.getName().equals(playerName)) {
if (!member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
@ -156,7 +156,6 @@ public class PartyManager {
return party;
}
}
return null;
}
@ -177,6 +176,7 @@ public class PartyManager {
*/
public void removeFromParty(String playerName, Party party) {
List<String> members = party.getMembers();
List<Player> onlineMembers = party.getOnlineMembers();
members.remove(playerName);
@ -184,8 +184,12 @@ public class PartyManager {
parties.remove(party);
}
else {
//If the leaving player was the party leader, appoint a new leader from the online party members
if (party.getLeader().equals(playerName)) {
party.setLocked(false);
if (!onlineMembers.isEmpty()) {
Player newLeader = onlineMembers.get(0);
party.setLeader(newLeader.getName());
}
}
informPartyMembersQuit(playerName, party);
@ -198,6 +202,63 @@ public class PartyManager {
}
}
/**
* Disband a party. Kicks out all members and removes the party.
*
* @param party The party to remove
*/
public void disbandParty(Party party) {
List<String> members = party.getMembers();
for (String member : party.getMembers()) {
PlayerProfile playerProfile = Users.getProfile(member);
if (playerProfile != null) {
playerProfile.removeParty();
}
}
members.clear();
if (members.isEmpty()) {
parties.remove(party);
}
}
/**
* 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 partyName The party to add the player to
* @param password the password for this party, null if there was no password
*/
public void createParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
partyName = partyName.replace(".", "");
Party party = getParty(partyName);
String playerName = player.getName();
if (party == null) {
party = new Party();
party.setName(partyName);
party.setLeader(playerName);
party.setLocked(true);//Parties are now invite-only by default, can be set to open with /party unlock
if (password != null) {
party.setPassword(password);
party.setLocked(true);
}
parties.add(party);
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists"));
return;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", new Object[]{party.getName()}));
addToParty(player.getName(), playerProfile, party);
}
/**
* Add a player to a party.
*

View File

@ -1,70 +0,0 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
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.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class AcceptCommand implements CommandExecutor {
private final mcMMO plugin;
public AcceptCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
return true;
}
Player player = (Player) sender;
PlayerProfile playerProfile = Users.getProfile(player);
if (playerProfile.hasPartyInvite()) {
PartyManager partyManagerInstance = PartyManager.getInstance();
if (playerProfile.inParty()) {
Party party = playerProfile.getParty();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(player.getName(), party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
partyManagerInstance.joinInvitedParty(player, playerProfile);
}
else {
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
}
return true;
}
}

View File

@ -1,71 +0,0 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
//TODO: Make this work from console.
public class InviteCommand implements CommandExecutor {
private final mcMMO plugin;
public InviteCommand(mcMMO instance) {
this.plugin = instance;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = LocaleLoader.getString("Commands.Usage.1", new Object[] {"invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"});
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
return true;
}
switch (args.length) {
case 1:
Player player = (Player) sender;
PlayerProfile playerProfile = Users.getProfile(player);
if (!playerProfile.inParty()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
Player target = plugin.getServer().getPlayer(args[0]);
if (target != null) {
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
Party party = playerProfile.getParty();
Users.getProfile(target).setInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
default:
sender.sendMessage(usage);
return true;
}
}
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
@ -35,20 +36,63 @@ public class PartyCommand implements CommandExecutor {
}
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if(args.length < 1)
return party(sender);
switch (args.length) {
case 0:
if (party == null) {
if(args[0].equalsIgnoreCase("join"))
return join(sender, args);
else if(args[0].equalsIgnoreCase("accept"))
return accept(sender, args);
else if(args[0].equalsIgnoreCase("create"))
return create(sender, args);
else if(args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help"))
return help(sender, args);
if (playerProfile.inParty()) {
if(args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave"))
return quit(sender, args);
else if(args[0].equalsIgnoreCase("expshare"))
return expshare(sender, args);
else if(args[0].equalsIgnoreCase("itemshare"))
return itemshare(sender, args);
else if(args[0].equalsIgnoreCase("invite"))
return invite(sender, args);
else if(args[0].equalsIgnoreCase("kick"))
return kick(sender, args);
else if(args[0].equalsIgnoreCase("disband"))
return disband(sender, args);
else if(args[0].equalsIgnoreCase("owner"))
return owner(sender, args);
else if(args[0].equalsIgnoreCase("lock"))
return lock(sender, args);
else if(args[0].equalsIgnoreCase("unlock"))
return unlock(sender, args);
else if(args[0].equalsIgnoreCase("password"))
return password(sender, args);
else
return usage(sender);
} else {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return usage(sender);
}
}
private boolean usage(CommandSender sender) {
Player player = (Player) sender;
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
return true;
}
else {
private boolean party(CommandSender sender) {
Player player = (Player) sender;
PlayerProfile playerProfile = Users.getProfile(player);
if (playerProfile.inParty()) {
Party party = playerProfile.getParty();
Server server = plugin.getServer();
String leader = party.getLeader();
StringBuffer tempList = new StringBuffer();
@ -63,42 +107,373 @@ public class PartyCommand implements CommandExecutor {
else {
tempList.append(ChatColor.GRAY);
}
tempList.append(otherPlayerName + " ");
}
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
String status = LocaleLoader.getString("Party.Status.Locked");
if (!party.isLocked())
status = LocaleLoader.getString("Party.Status.Unlocked");
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", new Object[] {party.getName(), status}));
// player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode", new Object[] { "NONE", "NONE" })); Party share modes will get implemented later
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
} else {
return usage(sender);
}
return true;
}
private boolean join(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.join"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if(args.length < 2) {
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
return true;
} else {
Player target = Bukkit.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.NotOnline", new Object[] {args[1]}));
return false;
}
if (!Users.getProfile(target).inParty()) {
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", new Object[] {args[1]}));
return false;
}
String password = null;
if(args.length > 2) password = args[2];
String partyTarget = partyManagerInstance.getPlayerParty(target.getName()).getName();
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, null)) {
return true; // End before any event is fired.
}
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), partyTarget, EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(playerName, party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyTarget, EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
partyManagerInstance.joinParty(player, playerProfile, partyTarget, password);
return true;
}
}
private boolean accept(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.accept"))
return true;
case 1:
if (args[0].equalsIgnoreCase("q")) {
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
Player player = (Player) sender;
PlayerProfile playerProfile = Users.getProfile(player);
if (playerProfile.hasPartyInvite()) {
PartyManager partyManagerInstance = PartyManager.getInstance();
if (playerProfile.inParty()) {
Party party = playerProfile.getParty();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(player.getName(), party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
partyManagerInstance.joinInvitedParty(player, playerProfile);
}
else {
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
}
return true;
}
private boolean create(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.create"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if(args.length < 2) {
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
return true;
} else {
String partyname = args[1];
String password = null;
if(args.length > 2) password = args[2];
Party newParty = partyManagerInstance.getParty(args[1]);
// Check to see if the party exists, and if it does cancel creating a new party
if (newParty != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {partyname}));
return true;
}
if (playerProfile.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, playerProfile.getPlayerName(), partyname, EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(playerName, party);
partyManagerInstance.createParty(player, playerProfile, partyname, password);
} else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyname, EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.createParty(player, playerProfile, partyname, password);
return true;
}
}
return true;
}
private boolean quit(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.quit"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(playerName, party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
}
else {
else
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return false;
}
private boolean expshare(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.expshare"))
return true;
return true;
}
else if (args[0].equals("?")) {
private boolean itemshare(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.itemshare"))
return true;
return true;
}
private boolean help(CommandSender sender, String[] args) {
Player player = (Player) sender;
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.4"));
player.sendMessage(LocaleLoader.getString("Party.Help.5"));
player.sendMessage(LocaleLoader.getString("Party.Help.6"));
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
player.sendMessage(LocaleLoader.getString("Party.Help.8"));
return true;
}
else if (args[0].equalsIgnoreCase("lock")) {
private boolean invite(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.invite"))
return true;
switch (args.length) {
case 2:
Player player = (Player) sender;
PlayerProfile playerProfile = Users.getProfile(player);
if (!playerProfile.inParty()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
Player target = plugin.getServer().getPlayer(args[1]);
if (target != null) {
if (PartyManager.getInstance().inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.Player.InSameParty"));
return true;
}
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
Party party = playerProfile.getParty();
Users.getProfile(target).setInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"}));
return true;
}
}
/**
* Kick a party member
*/
private boolean kick(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.kick"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
Player target = plugin.getServer().getOfflinePlayer(args[1]).getPlayer();
if (target != null) {
String partyName = party.getName();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] {partyName}));
}
partyManagerInstance.removeFromParty(args[1], party);
}
else
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
/**
* Disband the current party, kicks out all party members.
*/
private boolean disband(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.disband"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if (party.getLeader().equals(playerName)) {
for (Player onlineMembers : party.getOnlineMembers()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband"));
}
partyManagerInstance.disbandParty(party);
}
else
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
/**
* Change the owner of the current party
*/
private boolean owner(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.owner"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
if(args.length < 2) {
player.sendMessage("Usage: /party owner [player]");
return true;
}
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
partyManagerInstance.setPartyLeader(args[1], party);
}
return true;
}
/**
* Lock the current party
*/
private boolean lock(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.lock"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
Party party = playerProfile.getParty();
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (party.isLocked()) {
@ -109,15 +484,26 @@ public class PartyCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
}
}
else {
else
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
else
player.sendMessage("Commands.Party.None");
return true;
}
}
else if (args[0].equalsIgnoreCase("unlock")) {
/**
* Unlock the current party
*/
private boolean unlock(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.unlock"))
return true;
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
Party party = playerProfile.getParty();
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (!party.isLocked()) {
@ -128,134 +514,35 @@ public class PartyCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
}
else {
else
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
else
player.sendMessage("Commands.Party.None");
}
}
else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, null)) {
return true; // End before any event is fired.
}
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(playerName, party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
}
private boolean password(CommandSender sender, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.password"))
return true;
case 2:
if (playerProfile.inParty()) {
if (args[0].equalsIgnoreCase("password")) {
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile playerProfile = Users.getProfile(player);
Party party = playerProfile.getParty();
if(args.length < 2) {
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"}));
return true;
}
if (party.getLeader().equals(playerName)) {
party.setLocked(true);
party.setPassword(args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
}
else {
else
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("kick")) {
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
String partyName = party.getName();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(args[1], party);
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("owner")) {
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
partyManagerInstance.setPartyLeader(args[1], party);
}
}
else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
return true; // End before any event is fired.
}
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.removeFromParty(playerName, party);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
}
else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, args[1])) {
return true; // End before any event is fired.
}
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
return true;
default:
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
return true;
}
}
}

View File

@ -437,18 +437,24 @@ Commands.mmoupdate.Finish=[[GREEN]]Conversion finished!
Commands.ModDescription=[[RED]]- Read brief mod description
Commands.NoConsole=This command does not support console usage.
Commands.Other=[[GREEN]]--OTHER COMMANDS--
Commands.Party.Header=[[RED]]-----[][[GREEN]]PARTY[[RED]][]-----
Commands.Party.Status=[[DARK_GRAY]]NAME: [[WHITE]]{0} {1}
Commands.Party.ShareMode=[[DARK_GRAY]]SHARE MODE: [[GRAY]]ITEM [[DARK_AQUA]]({0}) [[DARK_GRAY]]|| [[GRAY]]EXP [[DARK_AQUA]]({1})
Commands.Party.Accept=[[RED]]- Accept party invite
Commands.Party.Chat.Off=Party Chat only [[RED]]Off
Commands.Party.Chat.On=Party Chat only [[GREEN]]On
Commands.Party.Chat.Prefix=[[GREEN]]([[WHITE]]{0}[[GREEN]])
Commands.Party.Commands=[[GREEN]]--PARTY COMMANDS--
Commands.Party.Invite.0=[[RED]]ALERT: [[GREEN]]You have received a party invite for {0} from {1}
Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/accept[[YELLOW]] to accept the invite
Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/party accept[[YELLOW]] to accept the invite
Commands.Party.Invite=<player> [[RED]]- Send party invite
Commands.Party.Join=Joined Party: {0}
Commands.Party.Join=[[GRAY]]Joined Party: {0}
Commands.Party.Create=[[GRAY]]Created Party: {0}
Commands.Party.AlreadyExists=[[DARK_RED]]Party {0} already exists!
Commands.Party.Kick=[[RED]]You were kicked from party {0}!
Commands.Party.Leave=[[RED]]You have left that party
Commands.Party.Members=[[GREEN]]Party Members: {0}
Commands.Party.Members.Header=[[RED]]-----[][[GREEN]]MEMBERS[[RED]][]-----
Commands.Party.Members={0}
Commands.Party.None=[[RED]]You are not in a party.
Commands.Party.Quit=[[RED]]- Leave your current party
Commands.Party.Teleport=<player> [[RED]]- Teleport to party member
@ -473,6 +479,7 @@ Commands.Usage.Level=level
Commands.Usage.Message=message
Commands.Usage.Page=page
Commands.Usage.PartyName=party-name
Commands.Usage.Password=password
Commands.Usage.Player=player
Commands.Usage.Skill=skill
Commands.Usage.XP=xp
@ -481,16 +488,16 @@ mcMMO.NoPermission=[[DARK_RED]]Insufficient permissions.
mcMMO.NoSkillNote=[[DARK_GRAY]]If you don't have access to a skill it will not be shown here.
##party
Commands.Party.InParty=[[GREEN]]Party: {0}
Party.Forbidden=[mcMMO] Parties not permitted on this world (See Permissions)
Party.Help.0=[[RED]]Proper usage is /party <party-name> to join or /party q to quit
Party.Help.1=[[RED]]To join a passworded party, use /party <party-name> <password>
Party.Help.2=[[RED]]Consult /party ? for more information
Party.Help.3=[[RED]]Use /party <party-name> to join or /party q to quit
Party.Help.4=[[RED]]To lock or unlock your party, use /party <lock/unlock>
Party.Help.5=[[RED]]To password protect your party, use /party password <password>
Party.Help.6=[[RED]]To kick a player from your party, use /party kick <player>
Party.Help.7=[[RED]]To transfer ownership of your party, use /party owner <player>
Party.Help.0=[[RED]]Proper usage is [[DARK_AQUA]]/party join <player> [password].
Party.Help.1=[[RED]]To create a party, use [[DARK_AQUA]]/party create <name> [password]
Party.Help.2=[[RED]]Consult [[DARK_AQUA]]/party ? [[RED]]for more information
Party.Help.3=[[RED]]Use [[DARK_AQUA]]/party join <player> [[RED]]to join or [[DARK_AQUA]]/party quit [[RED]]to quit
Party.Help.4=[[RED]]To lock or unlock your party, use [[DARK_AQUA]]/party <lock>
Party.Help.5=[[RED]]To password protect your party, use [[DARK_AQUA]]/party password <password>
Party.Help.6=[[RED]]To kick a player from your party, use [[DARK_AQUA]]/party kick <player>
Party.Help.7=[[RED]]To transfer ownership of your party, use [[DARK_AQUA]]/party owner <player>
Party.Help.8=[[RED]]To disband your party, use [[DARK_AQUA]]/party disband
Party.InformedOnJoin={0} [[GREEN]]has joined your party
Party.InformedOnQuit={0} [[GREEN]]has left your party
Party.InvalidName=[[DARK_RED]]That is not a valid party name.
@ -503,14 +510,20 @@ Party.Owner.New=[[GREEN]]{0} is the new party leader.
Party.Owner.NotLeader=[[DARK_RED]]You are no longer the party leader.
Party.Owner.Player =[[GREEN]]You are now the party leader.
Party.Password.Incorrect=[[RED]]Party password is incorrect.
Party.NotOnline=[[DARK_RED]]{0} is not online!
Party.PasswordSet=[[GREEN]]Party password set to {0}
Party.Player.Invalid=[[RED]]That is not a valid player.
Party.Player.InSameParty=[[RED]]{0} already is in your party!
Party.PlayerNotInParty=[[DARK_RED]]{0} is not in a party
Party.Teleport.Dead=[[RED]]You can't teleport to a dead player.
Party.Teleport.Hurt=[[RED]]You''ve been hurt in the last {0} seconds and cannnot teleport.
Party.Teleport.Player=[[GREEN]]You have teleported to {0}.
Party.Teleport.Self=[[RED]]You can't teleport to yourself!
Party.Teleport.Self=[[RED]]You can''t teleport to yourself!
Party.Teleport.Target=[[GREEN]]{0} has teleported to you.
Party.Unlocked=[[GRAY]]Party is unlocked
Party.Disband=[[GRAY]]The party has been disbanded
Party.Status.Locked=[[DARK_RED]](INVITE-ONLY)
Party.Status.Unlocked=[[DARK_GREEN]](OPEN)
##xp
Commands.XPGain.Acrobatics=Falling

View File

@ -73,12 +73,6 @@ commands:
description: Create/join a party
inspect:
aliases: []
invite:
aliases: []
description: Invite a player into your party
accept:
aliases: []
description: Accept a party invite
mmoupdate:
aliases: []
description: Convert from Flat File to MySQL
@ -706,15 +700,30 @@ permissions:
mcmmo.commands.ability: true
mcmmo.commands.ptp: true
mcmmo.commands.inspect: true
mcmmo.commands.party: true
mcmmo.commands.party.all: true
mcmmo.commands.ability:
description: Allows access to the mcability command
mcmmo.commands.ptp:
description: Allows access to the ptp command
mcmmo.commands.inspect:
description: Allows access to the inspect command
mcmmo.commands.party:
description: Allows acces to the party command
mcmmo.commands.party.all:
description: Implies all mcmmo.commands.party permissions.
children:
mcmmo.commands.party: true
mcmmo.commands.party.join: true
mcmmo.commands.party.create: true
mcmmo.commands.party.quit: true
mcmmo.commands.party.expshare: true
mcmmo.commands.party.itemshare: true
mcmmo.commands.party.accept: true
mcmmo.commands.party.invite: true
mcmmo.commands.party.kick: true
mcmmo.commands.party.disband: true
mcmmo.commands.party.owner: true
mcmmo.commands.party.lock: true
mcmmo.commands.party.unlock: true
mcmmo.commands.party.password: true
mcmmo.chat.*:
description: Implies all mcmmo.chat permissions. (Warning, contains adminchat)
children: