Changed /p and /a to use /partychat and /adminchat as the default

command name. The use of /p, /pc, /a, and /ac is still supported.
This commit is contained in:
GJ 2013-02-06 17:57:16 -05:00
parent d0ca2b9d4b
commit d5550c8fd1
8 changed files with 121 additions and 62 deletions

View File

@ -52,6 +52,7 @@ Version 1.4.00-dev
= Fixed a bug where party join messages weren't displayed = Fixed a bug where party join messages weren't displayed
= Fixed a bug where Disarm and Deflect had wrong values = Fixed a bug where Disarm and Deflect had wrong values
= Fixed Magic Hunter (Fishing ability) favoring certain enchants = Fixed Magic Hunter (Fishing ability) favoring certain enchants
! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported.
! We're now using Bukkit sounds instead of Spout sounds. ! We're now using Bukkit sounds instead of Spout sounds.
! It is now possible to use a negative number for Max_Level in treasures.yml to not use a maximum level, changed default file accordingly ! It is now possible to use a negative number for Max_Level in treasures.yml to not use a maximum level, changed default file accordingly
! A Fishing catch will now always contains a fish even if a treasure is found ! A Fishing catch will now always contains a fish even if a treasure is found
@ -70,7 +71,6 @@ Version 1.4.00-dev
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature. - Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
- Removed unused "healthbar" files from the resources - Removed unused "healthbar" files from the resources
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions. - Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
- Removed "ac" alias from /a due to Essentials incompatibilities.
- Removed Chimaera Wing - Removed Chimaera Wing
Version 1.3.14 Version 1.3.14

View File

@ -7,46 +7,61 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public class ACommand implements CommandExecutor { public class AdminChatCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer; McMMOPlayer mcMMOPlayer;
String usage = LocaleLoader.getString("Commands.Usage.1", "a", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">");
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
return true;
}
switch (args.length) { switch (args.length) {
case 0: case 0:
if (sender instanceof Player) { if (!(sender instanceof Player)) {
mcMMOPlayer = Users.getPlayer((Player) sender); return false;
}
if (mcMMOPlayer.getPartyChatMode()) { mcMMOPlayer = Users.getPlayer((Player) sender);
mcMMOPlayer.togglePartyChat();
}
mcMMOPlayer.toggleAdminChat(); // Can't have both party & admin chat at the same time.
if (mcMMOPlayer.getPartyChatMode()) {
mcMMOPlayer.togglePartyChat();
}
if (mcMMOPlayer.getAdminChatMode()) { mcMMOPlayer.toggleAdminChat();
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
} if (mcMMOPlayer.getAdminChatMode()) {
else { sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
}
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
} }
return true; return true;
default: default:
if (args.length == 1) {
if (!(sender instanceof Player)) {
return false;
}
mcMMOPlayer = Users.getPlayer((Player) sender);
if (args[0].equalsIgnoreCase("on")) {
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setAdminChat(true);
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
return true;
}
if (args[0].equalsIgnoreCase("off")) {
mcMMOPlayer.setAdminChat(false);
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
return true;
}
}
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(args[0]); builder.append(args[0]);

View File

@ -7,60 +7,69 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public class PCommand implements CommandExecutor { public class PartyChatCommand implements CommandExecutor {
private final mcMMO plugin;
public PCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer; McMMOPlayer mcMMOPlayer;
String usage = LocaleLoader.getString("Commands.Usage.2", "p", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">");
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
return true;
}
switch (args.length) { switch (args.length) {
case 0: case 0:
if (sender instanceof Player) { if (!(sender instanceof Player)) {
mcMMOPlayer = Users.getPlayer((Player) sender); return false;
}
if (mcMMOPlayer.getAdminChatMode()) { mcMMOPlayer = Users.getPlayer((Player) sender);
mcMMOPlayer.toggleAdminChat();
}
mcMMOPlayer.togglePartyChat(); // Can't have both party & admin chat at the same time.
if (mcMMOPlayer.getAdminChatMode()) {
mcMMOPlayer.toggleAdminChat();
}
if (mcMMOPlayer.getPartyChatMode()) { mcMMOPlayer.togglePartyChat();
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
} if (mcMMOPlayer.getPartyChatMode()) {
else { sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Off"));
}
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Off"));
} }
return true; return true;
default: default:
if (args.length == 1) {
if (!(sender instanceof Player)) {
return false;
}
mcMMOPlayer = Users.getPlayer((Player) sender);
if (args[0].equalsIgnoreCase("on")) {
mcMMOPlayer.setAdminChat(false);
mcMMOPlayer.setPartyChat(true);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
return true;
}
if (args[0].equalsIgnoreCase("off")) {
mcMMOPlayer.setPartyChat(false);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Off"));
return true;
}
}
if (sender instanceof Player) { if (sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
Party party = Users.getPlayer(player).getParty(); Party party = Users.getPlayer(player).getParty();
if (party == null) { if (party == null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true; return true;
} }
@ -73,11 +82,11 @@ public class PCommand implements CommandExecutor {
} }
String message = builder.toString(); String message = builder.toString();
ChatManager.handlePartyChat(plugin, party, player.getName(), player.getDisplayName(), message); ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), message);
} }
else { else {
if (args.length < 2) { if (args.length < 2) {
sender.sendMessage(usage); sender.sendMessage(LocaleLoader.getString("Party.Specify"));
return true; return true;
} }
@ -96,10 +105,10 @@ public class PCommand implements CommandExecutor {
builder.append(args[i]); builder.append(args[i]);
} }
String ssender = LocaleLoader.getString("Commands.Chat.Console"); String consoleSender = LocaleLoader.getString("Commands.Chat.Console");
String message = builder.toString(); String message = builder.toString();
ChatManager.handlePartyChat(plugin, party, ssender, ssender, message); ChatManager.handlePartyChat(mcMMO.p, party, consoleSender, consoleSender, message);
} }
return true; return true;

View File

@ -6,6 +6,8 @@ import java.util.List;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.commands.AdminChatCommand;
import com.gmail.nossr50.chat.commands.PartyChatCommand;
import com.gmail.nossr50.commands.admin.AddlevelsCommand; import com.gmail.nossr50.commands.admin.AddlevelsCommand;
import com.gmail.nossr50.commands.admin.AddxpCommand; import com.gmail.nossr50.commands.admin.AddxpCommand;
import com.gmail.nossr50.commands.admin.McgodCommand; import com.gmail.nossr50.commands.admin.McgodCommand;
@ -179,7 +181,7 @@ public final class CommandRegistrationHelper {
command.setDescription(LocaleLoader.getString("Commands.Description.xprate")); command.setDescription(LocaleLoader.getString("Commands.Description.xprate"));
command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set"); command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set");
command.setPermissionMessage(permissionsMessage); command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "[" + LocaleLoader.getString("Commands.Usage.True") + "|" + LocaleLoader.getString("Commands.Usage.False")+ "]")); command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "<" + LocaleLoader.getString("Commands.Usage.True") + "|" + LocaleLoader.getString("Commands.Usage.False")+ ">"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset")); command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset"));
command.setAliases(aliasList); command.setAliases(aliasList);
command.setExecutor(new XprateCommand()); command.setExecutor(new XprateCommand());
@ -266,4 +268,26 @@ public final class CommandRegistrationHelper {
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate")); command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
command.setExecutor(new MmoupdateCommand()); command.setExecutor(new MmoupdateCommand());
} }
public static void registerAdminChatCommand() {
PluginCommand command = mcMMO.p.getCommand("adminchat");
command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
command.setPermission("mcmmo.chat.adminchat");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "adminchat"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.On") + "|" + LocaleLoader.getString("Commands.Usage.Off")+ ">"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"));
command.setExecutor(new AdminChatCommand());
}
public static void registerPartyChatCommand() {
PluginCommand command = mcMMO.p.getCommand("partychat");
command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "partychat"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.On") + "|" + LocaleLoader.getString("Commands.Usage.Off")+ ">"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">"));
command.setExecutor(new PartyChatCommand());
}
} }

View File

@ -255,6 +255,10 @@ public class McMMOPlayer {
return adminChatMode; return adminChatMode;
} }
public void setAdminChat(boolean enabled) {
adminChatMode = enabled;
}
public void toggleAdminChat() { public void toggleAdminChat() {
adminChatMode = !adminChatMode; adminChatMode = !adminChatMode;
} }
@ -263,6 +267,10 @@ public class McMMOPlayer {
return partyChatMode; return partyChatMode;
} }
public void setPartyChat(boolean enabled) {
partyChatMode = enabled;
}
public void togglePartyChat() { public void togglePartyChat() {
partyChatMode = !partyChatMode; partyChatMode = !partyChatMode;
} }

View File

@ -22,8 +22,6 @@ import org.mcstats.Metrics.Graph;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.chat.commands.ACommand;
import com.gmail.nossr50.chat.commands.PCommand;
import com.gmail.nossr50.commands.CommandRegistrationHelper; import com.gmail.nossr50.commands.CommandRegistrationHelper;
import com.gmail.nossr50.commands.player.MccCommand; import com.gmail.nossr50.commands.player.MccCommand;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
@ -293,9 +291,9 @@ public class mcMMO extends JavaPlugin {
CommandRegistrationHelper.registerMcstatsCommand(); CommandRegistrationHelper.registerMcstatsCommand();
// Party commands // Party commands
getCommand("a").setExecutor(new ACommand()); CommandRegistrationHelper.registerAdminChatCommand();
getCommand("party").setExecutor(new PartyCommand()); getCommand("party").setExecutor(new PartyCommand());
getCommand("p").setExecutor(new PCommand(this)); CommandRegistrationHelper.registerPartyChatCommand();
getCommand("ptp").setExecutor(new PtpCommand(this)); getCommand("ptp").setExecutor(new PtpCommand(this));
// Other commands // Other commands

View File

@ -495,6 +495,8 @@ Commands.Usage.3=[[RED]]Proper usage is /{0} {1} {2} {3}
Commands.Usage.False=false Commands.Usage.False=false
Commands.Usage.Level=level Commands.Usage.Level=level
Commands.Usage.Message=message Commands.Usage.Message=message
Commands.Usage.Off=off
Commands.Usage.On=on
Commands.Usage.Page=page Commands.Usage.Page=page
Commands.Usage.PartyName=party-name Commands.Usage.PartyName=party-name
Commands.Usage.Password=password Commands.Usage.Password=password
@ -538,6 +540,7 @@ Party.Player.Invalid=[[RED]]That is not a valid player.
Party.NotOnline=[[DARK_RED]]{0} is not online! Party.NotOnline=[[DARK_RED]]{0} is not online!
Party.Player.InSameParty=[[RED]]{0} already is in your party! Party.Player.InSameParty=[[RED]]{0} already is in your party!
Party.PlayerNotInParty=[[DARK_RED]]{0} is not in a party Party.PlayerNotInParty=[[DARK_RED]]{0} is not in a party
Party.Specify=[[RED]]You must specify a party.
Party.Teleport.Dead=[[RED]]You can't teleport to a dead player. 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.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.Player=[[GREEN]]You have teleported to {0}.
@ -690,12 +693,13 @@ Smelting.SkillName=SMELTING
#COMMAND DESCRIPTIONS #COMMAND DESCRIPTIONS
Commands.Description.addlevels=Add mcMMO levels to a user Commands.Description.addlevels=Add mcMMO levels to a user
Commands.Description.adminchat=Toggle mcMMO admin chat on/off or send admin chat messages
Commands.Description.addxp=Add mcMMO XP to a user Commands.Description.addxp=Add mcMMO XP to a user
Commands.Description.inspect=View detailed mcMMO info on another player Commands.Description.inspect=View detailed mcMMO info on another player
Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off
Commands.Description.mcgod=Toggle mcMMO god-mode on/off Commands.Description.mcgod=Toggle mcMMO god-mode on/off
Commands.Description.mcmmo=Show a brief description of mcMMO Commands.Description.mcmmo=Show a brief description of mcMMO
Commands.Description.mcpurge=Purge users with no mcMMO levels and users who haven't connected in over {0} months from the mcMMO database. Commands.Description.mcpurge=Purge users with no mcMMO levels and users who have not connected in over {0} months from the mcMMO database.
Commands.Description.mcrank=Show mcMMO ranking for a player Commands.Description.mcrank=Show mcMMO ranking for a player
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
Commands.Description.mcremove=Remove a user from the mcMMO database Commands.Description.mcremove=Remove a user from the mcMMO database
@ -703,6 +707,7 @@ Commands.Description.mcstats=Show your mcMMO levels and XP
Commands.Description.mctop=Show mcMMO leader boards Commands.Description.mctop=Show mcMMO leader boards
Commands.Description.mmoedit=Edit mcMMO levels for a user Commands.Description.mmoedit=Edit mcMMO levels for a user
Commands.Description.mmoupdate=Convert mcMMO database from Flatfile to MySQL Commands.Description.mmoupdate=Convert mcMMO database from Flatfile to MySQL
Commands.Description.partychat=Toggle mcMMO party chat on/off or send party chat messages
Commands.Description.Skill=Display detailed mcMMO skill info for {0} Commands.Description.Skill=Display detailed mcMMO skill info for {0}
Commands.Description.skillreset=Reset mcMMO levels for a user Commands.Description.skillreset=Reset mcMMO levels for a user
Commands.Description.xprate=Modify the mcMMO XP rate or start an mcMMO XP event Commands.Description.xprate=Modify the mcMMO XP rate or start an mcMMO XP event

View File

@ -64,8 +64,8 @@ commands:
description: View detailed mcMMO info on another player description: View detailed mcMMO info on another player
mmoupdate: mmoupdate:
description: Convert from Flat File to MySQL description: Convert from Flat File to MySQL
p: partychat:
aliases: [pc] aliases: [pc, p]
description: Toggle Party chat or send party chat messages description: Toggle Party chat or send party chat messages
skillreset: skillreset:
description: Reset the level of one or all of your skills description: Reset the level of one or all of your skills
@ -95,8 +95,8 @@ commands:
description: Detailed mcMMO skill info description: Detailed mcMMO skill info
smelting: smelting:
description: Detailed mcMMO skill info description: Detailed mcMMO skill info
a: adminchat:
aliases: [] aliases: [ac, a]
description: Toggle Admin chat or send admin chat messages description: Toggle Admin chat or send admin chat messages
mcpurge: mcpurge:
description: Purge users with 0 powerlevel and/or who haven't connected in several months from the server DB. description: Purge users with 0 powerlevel and/or who haven't connected in several months from the server DB.