You can now silence mmoedit, addlevels, and addxp with -s

This commit is contained in:
nossr50 2020-10-27 11:03:47 -07:00
parent 33287b650f
commit 05f2763311
7 changed files with 61 additions and 28 deletions

View File

@ -4,11 +4,13 @@ Version 2.1.150
The style and look of admin/party chat is now determined by locale file instead of options in config.yml
Improved messages players recieve when they toggle on or off admin or party chat
All locale files have had [[]] color codes replaced by & color codes, you can still use [[GOLD]] and stuff if you want
Added new locale string 'Chat.Identity.Console'
Added new locale string 'Chat.Style.Admin'
Added new locale string 'Chat.Style.Party'
Added new locale string 'Chat.Channel.On'
Added new locale string 'Chat.Channel.Off'
You can now add "-s" at the end of mmoedit, addlevels, or addxp to silence the command. Which will prevent the target of the command from being informed that the command was executed.
Added new locale entry 'Commands.Usage.3.XP'
Added new locale entry 'Chat.Identity.Console'
Added new locale entry 'Chat.Style.Admin'
Added new locale entry 'Chat.Style.Party'
Added new locale entry 'Chat.Channel.On'
Added new locale entry 'Chat.Channel.Off'
Fixed an ArrayIndexOutOfBounds exception when using /skillreset
(API) ChatAPI::getPartyChatManager() has been removed
(API) ChatAPI::sendPartyChat has been removed (similar functionality can be found in the new ChatManager class)

View File

@ -34,12 +34,18 @@ public class AddlevelsCommand extends ExperienceCommand {
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
}
}

View File

@ -37,12 +37,18 @@ public class AddxpCommand extends ExperienceCommand {
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
}
}

View File

@ -25,8 +25,10 @@ public abstract class ExperienceCommand implements TabExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
PrimarySkillType skill;
switch (args.length) {
case 2:
if(args.length < 2) {
return false;
} else {
if(args.length == 2 && !isSilent(args) || args.length == 3 && isSilent(args)) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
@ -62,10 +64,10 @@ public abstract class ExperienceCommand implements TabExecutor {
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]), isSilent(args));
return true;
case 3:
} else if((args.length == 3 && !isSilent(args))
|| (args.length == 4 && isSilent(args))) {
if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
@ -105,20 +107,30 @@ public abstract class ExperienceCommand implements TabExecutor {
return true;
}
editValues(null, profile, skill, value);
editValues(null, profile, skill, value, isSilent(args));
}
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value, isSilent(args));
}
handleSenderMessage(sender, playerName, skill);
return true;
default:
} else {
return false;
}
}
}
private boolean isSilent(String[] args) {
int length = args.length;
if(length == 0)
return false;
return args[length-1].equalsIgnoreCase("-s");
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
switch (args.length) {
@ -135,8 +147,8 @@ public abstract class ExperienceCommand implements TabExecutor {
protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
protected abstract void handlePlayerMessageAll(Player player, int value, boolean isSilent);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent);
private boolean validateArguments(CommandSender sender, String skillName, String value) {
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
@ -151,21 +163,21 @@ public abstract class ExperienceCommand implements TabExecutor {
}
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value, boolean isSilent) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType, value);
}
if (player != null) {
handlePlayerMessageAll(player, value);
handlePlayerMessageAll(player, value, isSilent);
}
}
else {
handleCommand(player, profile, skill, value);
if (player != null) {
handlePlayerMessageSkill(player, value, skill);
handlePlayerMessageSkill(player, value, skill, isSilent);
}
}
}

View File

@ -40,12 +40,18 @@ public class MmoeditCommand extends ExperienceCommand {
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
if(isSilent)
return;
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
}
}

View File

@ -120,7 +120,7 @@ public final class CommandRegistrationManager {
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
command.setUsage(LocaleLoader.getString("Commands.Usage.3.XP", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
command.setExecutor(new AddlevelsCommand());
}
@ -129,7 +129,7 @@ public final class CommandRegistrationManager {
command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">"));
command.setUsage(LocaleLoader.getString("Commands.Usage.3.XP", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">"));
command.setExecutor(new AddxpCommand());
}
@ -183,7 +183,7 @@ public final class CommandRegistrationManager {
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
command.setUsage(LocaleLoader.getString("Commands.Usage.3.XP", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">"));
command.setExecutor(new MmoeditCommand());
}

View File

@ -711,6 +711,7 @@ Commands.Usage.0=&cProper usage is /{0}
Commands.Usage.1=&cProper usage is /{0} {1}
Commands.Usage.2=&cProper usage is /{0} {1} {2}
Commands.Usage.3=&cProper usage is /{0} {1} {2} {3}
Commands.Usage.3.XP=&cProper usage is /{0} {1} {2} {3}&7 (You can include -s at the end to execute the command without informing the player, effectively silencing it)
Commands.Usage.FullClassName=classname
Commands.Usage.Level=level
Commands.Usage.Message=message