Fix client side commands adding parts of the color codes on autocomplete (prefix "7" and suffix "r").
This commit is contained in:
parent
1dcc9abab2
commit
b665026378
2 changed files with 76 additions and 0 deletions
|
@ -29,3 +29,11 @@
|
|||
for (String s : p_146406_1_)
|
||||
{
|
||||
if (s.length() > 0)
|
||||
@@ -291,6 +298,7 @@
|
||||
|
||||
String s1 = this.field_146415_a.func_146179_b().substring(this.field_146415_a.func_146197_a(-1, this.field_146415_a.func_146198_h(), false));
|
||||
String s2 = StringUtils.getCommonPrefix(p_146406_1_);
|
||||
+ s2 = net.minecraft.util.EnumChatFormatting.func_110646_a(s2);
|
||||
|
||||
if (s2.length() > 0 && !s1.equalsIgnoreCase(s2))
|
||||
{
|
||||
|
|
68
src/test/java/net/minecraftforge/test/ClientCommandTest.java
Normal file
68
src/test/java/net/minecraftforge/test/ClientCommandTest.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
package net.minecraftforge.test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
|
||||
@Mod(modid="clientcommandtest", name="Client Command Test", version="0.0.0")
|
||||
public class ClientCommandTest {
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
ClientCommandHandler.instance.registerCommand(new TestCommand());
|
||||
}
|
||||
|
||||
private class TestCommand extends CommandBase {
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "clientCommandTest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender sender)
|
||||
{
|
||||
return "clientCommandTest <block>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender sender)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, GameData.getBlockRegistry().getKeys());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
sender.addChatMessage(new ChatComponentText("Input: " + Arrays.toString(args)));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.addChatMessage(new ChatComponentText("No arguments."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue