More command auto completion stuff!

This commit is contained in:
Pahimar 2015-02-05 21:03:08 -05:00
parent 0ee0ac5995
commit 927facc9fa
5 changed files with 106 additions and 4 deletions

View file

@ -65,6 +65,8 @@ public class CommandEE extends CommandBase
{ {
modCommands.add(new CommandPlayerLearnEverything()); modCommands.add(new CommandPlayerLearnEverything());
modCommands.add(new CommandPlayerLearnItem()); modCommands.add(new CommandPlayerLearnItem());
modCommands.add(new CommandPlayerForgetEverything());
modCommands.add(new CommandPlayerForgetItem());
modCommands.add(new CommandTemplateLearnEverything()); modCommands.add(new CommandTemplateLearnEverything());
modCommands.add(new CommandTemplateLearnItem()); modCommands.add(new CommandTemplateLearnItem());
modCommands.add(new CommandTemplateForgetEverything()); modCommands.add(new CommandTemplateForgetEverything());

View file

@ -0,0 +1,47 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import java.util.List;
public class CommandPlayerForgetEverything extends CommandBase
{
@Override
public String getCommandName()
{
return Names.Commands.PLAYER_FORGET_EVERYTHING;
}
@Override
public int getRequiredPermissionLevel()
{
return 2;
}
@Override
public String getCommandUsage(ICommandSender commandSender)
{
return Messages.Commands.PLAYER_FORGET_EVERYTHING_USAGE;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args)
{
// TODO
}
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args)
{
if (args.length == 2)
{
return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames());
}
return null;
}
}

View file

@ -0,0 +1,52 @@
package com.pahimar.ee3.command;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.item.Item;
import java.util.List;
public class CommandPlayerForgetItem extends CommandBase
{
@Override
public String getCommandName()
{
return Names.Commands.PLAYER_FORGET_ITEM;
}
@Override
public int getRequiredPermissionLevel()
{
return 2;
}
@Override
public String getCommandUsage(ICommandSender commandSender)
{
return Messages.Commands.PLAYER_FORGET_ITEM_USAGE;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args)
{
// TODO
}
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args)
{
if (args.length == 2)
{
return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames());
}
else if (args.length == 3)
{
return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys());
}
return null;
}
}

View file

@ -1,7 +1,7 @@
package com.pahimar.ee3.command; package com.pahimar.ee3.command;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Names;
import com.pahimar.ee3.util.LogHelper;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.CommandBase; import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender; import net.minecraft.command.ICommandSender;
@ -25,13 +25,13 @@ public class CommandPlayerLearnEverything extends CommandBase
@Override @Override
public String getCommandUsage(ICommandSender commandSender) public String getCommandUsage(ICommandSender commandSender)
{ {
return "TODO"; return Messages.Commands.PLAYER_LEARN_EVERYTHING_USAGE;
} }
@Override @Override
public void processCommand(ICommandSender commandSender, String[] args) public void processCommand(ICommandSender commandSender, String[] args)
{ {
LogHelper.info("Teaching player everything"); // TODO
} }
@Override @Override

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.command; package com.pahimar.ee3.command;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Names;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.CommandBase; import net.minecraft.command.CommandBase;
@ -25,7 +26,7 @@ public class CommandPlayerLearnItem extends CommandBase
@Override @Override
public String getCommandUsage(ICommandSender commandSender) public String getCommandUsage(ICommandSender commandSender)
{ {
return "TODO"; return Messages.Commands.PLAYER_LEARN_ITEM_USAGE;
} }
@Override @Override