Initial 1.11.2 update
This commit is contained in:
@@ -21,7 +21,7 @@ import net.minecraft.util.text.TextFormatting;
|
||||
public class CommandSetAlly extends CommandBase {
|
||||
|
||||
@Override
|
||||
public String getCommandName(){
|
||||
public String getName(){
|
||||
return Wizardry.settings.allyCommandName;
|
||||
}
|
||||
|
||||
@@ -32,30 +32,32 @@ public class CommandSetAlly extends CommandBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPermission(MinecraftServer server, ICommandSender p_71519_1_)
|
||||
{
|
||||
public boolean checkPermission(MinecraftServer server, ICommandSender p_71519_1_){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender p_71518_1_){
|
||||
public String getUsage(ICommandSender p_71518_1_){
|
||||
// Not ideal, but the way this is implemented means I have no choice. Only used in the help command, so in there
|
||||
// the custom command name will not display.
|
||||
return "commands.wizardry:ally.usage";
|
||||
//return I18n.format("commands.wizardry:ally.usage", Wizardry.settings.allyCommandName);
|
||||
// return I18n.format("commands.wizardry:ally.usage", Wizardry.settings.allyCommandName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] arguments, BlockPos pos) {
|
||||
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] arguments,
|
||||
BlockPos pos){
|
||||
switch(arguments.length){
|
||||
case 1: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames());
|
||||
case 2: return getListOfStringsMatchingLastWord(arguments, server.getAllUsernames());
|
||||
case 1:
|
||||
return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames());
|
||||
case 2:
|
||||
return getListOfStringsMatchingLastWord(arguments, server.getOnlinePlayerNames());
|
||||
}
|
||||
return super.getTabCompletionOptions(server, sender, arguments, pos);
|
||||
return super.getTabCompletions(server, sender, arguments, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException {
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] arguments) throws CommandException{
|
||||
|
||||
if(arguments.length < 1){
|
||||
throw new WrongUsageException("commands.wizardry:ally.usage", Wizardry.settings.allyCommandName);
|
||||
@@ -65,8 +67,9 @@ public class CommandSetAlly extends CommandBase {
|
||||
|
||||
try{
|
||||
allyOf = getCommandSenderAsPlayer(sender);
|
||||
}catch(PlayerNotFoundException exception){
|
||||
// Nothing here since the player specifying is done later, I just don't want it to throw an exception here.
|
||||
}catch (PlayerNotFoundException exception){
|
||||
// Nothing here since the player specifying is done later, I just don't want it to throw an exception
|
||||
// here.
|
||||
}
|
||||
|
||||
boolean executeAsOtherPlayer = false;
|
||||
@@ -79,11 +82,13 @@ public class CommandSetAlly extends CommandBase {
|
||||
allyOf = getPlayer(server, sender, arguments[1]);
|
||||
// Don't want to catch the exception here either, because there can be no other second argument.
|
||||
|
||||
if(allyOf != sender && sender instanceof EntityPlayer && !WizardryUtilities.isPlayerOp((EntityPlayer)sender, server)){
|
||||
if(allyOf != sender && sender instanceof EntityPlayer
|
||||
&& !WizardryUtilities.isPlayerOp((EntityPlayer)sender, server)){
|
||||
// Displays a chat message if a non-op tries to modify another player's allies.
|
||||
TextComponentTranslation TextComponentTranslation2 = new TextComponentTranslation("commands.wizardry:ally.permission");
|
||||
TextComponentTranslation TextComponentTranslation2 = new TextComponentTranslation(
|
||||
"commands.wizardry:ally.permission");
|
||||
TextComponentTranslation2.getStyle().setColor(TextFormatting.RED);
|
||||
allyOf.addChatMessage(TextComponentTranslation2);
|
||||
allyOf.sendMessage(TextComponentTranslation2);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,18 +97,20 @@ public class CommandSetAlly extends CommandBase {
|
||||
|
||||
// If, after this point, allyOf is still null, the sender must be a command block or the console and two
|
||||
// players must not have been specified, meaning an exception should be thrown.
|
||||
if(allyOf == null) throw new PlayerNotFoundException("You must specify which player you wish to perform this action on.");
|
||||
if(allyOf == null)
|
||||
throw new PlayerNotFoundException("You must specify which player you wish to perform this action on.");
|
||||
|
||||
if(allyOf == ally) throw new NumberInvalidException("commands.wizardry:ally.self");
|
||||
|
||||
if(WizardData.get(allyOf) != null){
|
||||
String string = WizardData.get(allyOf).toggleAlly(ally) ? "add" : "remove";
|
||||
if(executeAsOtherPlayer){
|
||||
sender.addChatMessage(new TextComponentTranslation("commands.wizardry:ally." + string + "ally", ally.getName(), allyOf.getName()));
|
||||
sender.sendMessage(new TextComponentTranslation("commands.wizardry:ally." + string + "ally",
|
||||
ally.getName(), allyOf.getName()));
|
||||
// In this case, the player whose allies have been modified is also notified.
|
||||
allyOf.addChatMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName()));
|
||||
allyOf.sendMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName()));
|
||||
}else{
|
||||
sender.addChatMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName()));
|
||||
sender.sendMessage(new TextComponentTranslation("item.wand." + string + "ally", ally.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user