Java 类net.minecraft.command.PlayerSelector 实例源码

项目:Cauldron    文件:CommandBlockLogic.java   
private ArrayList<String[]> buildCommands(String[] args, int pos)
{
    ArrayList<String[]> commands = new ArrayList<String[]>();
    EntityPlayerMP[] players = PlayerSelector.matchPlayers(this, args[pos]);

    if (players != null)
    {
        for (EntityPlayerMP player : players)
        {
            if (player.worldObj != this.getEntityWorld())
            {
                continue;
            }

            String[] command = args.clone();
            command[pos] = player.getCommandSenderName();
            commands.add(command);
        }
    }

    return commands;
}
项目:RuneCraftery    文件:CommandBase.java   
public static String func_82361_a(ICommandSender p_82361_0_, String[] p_82361_1_, int p_82361_2_, boolean p_82361_3_) {
   StringBuilder var4 = new StringBuilder();

   for(int var5 = p_82361_2_; var5 < p_82361_1_.length; ++var5) {
      if(var5 > p_82361_2_) {
         var4.append(" ");
      }

      String var6 = p_82361_1_[var5];
      if(p_82361_3_) {
         String var7 = PlayerSelector.func_82385_b(p_82361_0_, var6);
         if(var7 != null) {
            var6 = var7;
         } else if(PlayerSelector.func_82378_b(var6)) {
            throw new PlayerNotFoundException();
         }
      }

      var4.append(var6);
   }

   return var4.toString();
}
项目:LookingGlass    文件:CommandBaseAdv.java   
public static EntityPlayerMP getTargetPlayer(ICommandSender sender, String target) {
    EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(sender, target);

    if (entityplayermp == null) {
        entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(target);
    }
    if (entityplayermp == null) { throw new PlayerNotFoundException(); }
    return entityplayermp;
}
项目:Mocap    文件:Mocap.java   
public static EntityPlayerMP getPlayerForName(ICommandSender sender,
        String name) {
    EntityPlayerMP var2 = PlayerSelector.matchOnePlayer(sender, name);

    if (var2 != null) {
        return var2;
    } else {
        return getPlayerForName(name);
    }
}
项目:RuneCraftery    文件:CommandHandler.java   
private int func_82370_a(ICommand p_82370_1_, String[] p_82370_2_) {
   if(p_82370_1_ == null) {
      return -1;
   } else {
      for(int var3 = 0; var3 < p_82370_2_.length; ++var3) {
         if(p_82370_1_.func_82358_a(p_82370_2_, var3) && PlayerSelector.func_82377_a(p_82370_2_[var3])) {
            return var3;
         }
      }

      return -1;
   }
}
项目:RuneCraftery    文件:CommandBase.java   
public static EntityPlayerMP func_82359_c(ICommandSender p_82359_0_, String p_82359_1_) {
   EntityPlayerMP var2 = PlayerSelector.func_82386_a(p_82359_0_, p_82359_1_);
   if(var2 != null) {
      return var2;
   } else {
      var2 = MinecraftServer.func_71276_C().func_71203_ab().func_72361_f(p_82359_1_);
      if(var2 == null) {
         throw new PlayerNotFoundException();
      } else {
         return var2;
      }
   }
}
项目:RuneCraftery    文件:CommandBase.java   
public static String func_96332_d(ICommandSender p_96332_0_, String p_96332_1_) {
   EntityPlayerMP var2 = PlayerSelector.func_82386_a(p_96332_0_, p_96332_1_);
   if(var2 != null) {
      return var2.func_70023_ak();
   } else if(PlayerSelector.func_82378_b(p_96332_1_)) {
      throw new PlayerNotFoundException();
   } else {
      return p_96332_1_;
   }
}
项目:DecompiledMinecraft    文件:ChatComponentProcessor.java   
public static IChatComponent processComponent(ICommandSender commandSender, IChatComponent component, Entity entityIn) throws CommandException
{
    IChatComponent ichatcomponent = null;

    if (component instanceof ChatComponentScore)
    {
        ChatComponentScore chatcomponentscore = (ChatComponentScore)component;
        String s = chatcomponentscore.getName();

        if (PlayerSelector.hasArguments(s))
        {
            List<Entity> list = PlayerSelector.<Entity>matchEntities(commandSender, s, Entity.class);

            if (list.size() != 1)
            {
                throw new EntityNotFoundException();
            }

            s = ((Entity)list.get(0)).getName();
        }

        ichatcomponent = entityIn != null && s.equals("*") ? new ChatComponentScore(entityIn.getName(), chatcomponentscore.getObjective()) : new ChatComponentScore(s, chatcomponentscore.getObjective());
        ((ChatComponentScore)ichatcomponent).setValue(chatcomponentscore.getUnformattedTextForChat());
    }
    else if (component instanceof ChatComponentSelector)
    {
        String s1 = ((ChatComponentSelector)component).getSelector();
        ichatcomponent = PlayerSelector.matchEntitiesToChatComponent(commandSender, s1);

        if (ichatcomponent == null)
        {
            ichatcomponent = new ChatComponentText("");
        }
    }
    else if (component instanceof ChatComponentText)
    {
        ichatcomponent = new ChatComponentText(((ChatComponentText)component).getChatComponentText_TextValue());
    }
    else
    {
        if (!(component instanceof ChatComponentTranslation))
        {
            return component;
        }

        Object[] aobject = ((ChatComponentTranslation)component).getFormatArgs();

        for (int i = 0; i < aobject.length; ++i)
        {
            Object object = aobject[i];

            if (object instanceof IChatComponent)
            {
                aobject[i] = processComponent(commandSender, (IChatComponent)object, entityIn);
            }
        }

        ichatcomponent = new ChatComponentTranslation(((ChatComponentTranslation)component).getKey(), aobject);
    }

    ChatStyle chatstyle = component.getChatStyle();

    if (chatstyle != null)
    {
        ichatcomponent.setChatStyle(chatstyle.createShallowCopy());
    }

    for (IChatComponent ichatcomponent1 : component.getSiblings())
    {
        ichatcomponent.appendSibling(processComponent(commandSender, ichatcomponent1, entityIn));
    }

    return ichatcomponent;
}
项目:DecompiledMinecraft    文件:ChatComponentProcessor.java   
public static IChatComponent processComponent(ICommandSender commandSender, IChatComponent component, Entity entityIn) throws CommandException
{
    IChatComponent ichatcomponent = null;

    if (component instanceof ChatComponentScore)
    {
        ChatComponentScore chatcomponentscore = (ChatComponentScore)component;
        String s = chatcomponentscore.getName();

        if (PlayerSelector.hasArguments(s))
        {
            List<Entity> list = PlayerSelector.<Entity>matchEntities(commandSender, s, Entity.class);

            if (list.size() != 1)
            {
                throw new EntityNotFoundException();
            }

            s = ((Entity)list.get(0)).getName();
        }

        ichatcomponent = entityIn != null && s.equals("*") ? new ChatComponentScore(entityIn.getName(), chatcomponentscore.getObjective()) : new ChatComponentScore(s, chatcomponentscore.getObjective());
        ((ChatComponentScore)ichatcomponent).setValue(chatcomponentscore.getUnformattedTextForChat());
    }
    else if (component instanceof ChatComponentSelector)
    {
        String s1 = ((ChatComponentSelector)component).getSelector();
        ichatcomponent = PlayerSelector.matchEntitiesToChatComponent(commandSender, s1);

        if (ichatcomponent == null)
        {
            ichatcomponent = new ChatComponentText("");
        }
    }
    else if (component instanceof ChatComponentText)
    {
        ichatcomponent = new ChatComponentText(((ChatComponentText)component).getChatComponentText_TextValue());
    }
    else
    {
        if (!(component instanceof ChatComponentTranslation))
        {
            return component;
        }

        Object[] aobject = ((ChatComponentTranslation)component).getFormatArgs();

        for (int i = 0; i < aobject.length; ++i)
        {
            Object object = aobject[i];

            if (object instanceof IChatComponent)
            {
                aobject[i] = processComponent(commandSender, (IChatComponent)object, entityIn);
            }
        }

        ichatcomponent = new ChatComponentTranslation(((ChatComponentTranslation)component).getKey(), aobject);
    }

    ChatStyle chatstyle = component.getChatStyle();

    if (chatstyle != null)
    {
        ichatcomponent.setChatStyle(chatstyle.createShallowCopy());
    }

    for (IChatComponent ichatcomponent1 : component.getSiblings())
    {
        ichatcomponent.appendSibling(processComponent(commandSender, ichatcomponent1, entityIn));
    }

    return ichatcomponent;
}
项目:BaseClient    文件:ChatComponentProcessor.java   
public static IChatComponent processComponent(ICommandSender commandSender, IChatComponent component, Entity entityIn) throws CommandException
{
    IChatComponent ichatcomponent = null;

    if (component instanceof ChatComponentScore)
    {
        ChatComponentScore chatcomponentscore = (ChatComponentScore)component;
        String s = chatcomponentscore.getName();

        if (PlayerSelector.hasArguments(s))
        {
            List<Entity> list = PlayerSelector.<Entity>matchEntities(commandSender, s, Entity.class);

            if (list.size() != 1)
            {
                throw new EntityNotFoundException();
            }

            s = ((Entity)list.get(0)).getName();
        }

        ichatcomponent = entityIn != null && s.equals("*") ? new ChatComponentScore(entityIn.getName(), chatcomponentscore.getObjective()) : new ChatComponentScore(s, chatcomponentscore.getObjective());
        ((ChatComponentScore)ichatcomponent).setValue(chatcomponentscore.getUnformattedTextForChat());
    }
    else if (component instanceof ChatComponentSelector)
    {
        String s1 = ((ChatComponentSelector)component).getSelector();
        ichatcomponent = PlayerSelector.matchEntitiesToChatComponent(commandSender, s1);

        if (ichatcomponent == null)
        {
            ichatcomponent = new ChatComponentText("");
        }
    }
    else if (component instanceof ChatComponentText)
    {
        ichatcomponent = new ChatComponentText(((ChatComponentText)component).getChatComponentText_TextValue());
    }
    else
    {
        if (!(component instanceof ChatComponentTranslation))
        {
            return component;
        }

        Object[] aobject = ((ChatComponentTranslation)component).getFormatArgs();

        for (int i = 0; i < aobject.length; ++i)
        {
            Object object = aobject[i];

            if (object instanceof IChatComponent)
            {
                aobject[i] = processComponent(commandSender, (IChatComponent)object, entityIn);
            }
        }

        ichatcomponent = new ChatComponentTranslation(((ChatComponentTranslation)component).getKey(), aobject);
    }

    ChatStyle chatstyle = component.getChatStyle();

    if (chatstyle != null)
    {
        ichatcomponent.setChatStyle(chatstyle.createShallowCopy());
    }

    for (IChatComponent ichatcomponent1 : component.getSiblings())
    {
        ichatcomponent.appendSibling(processComponent(commandSender, ichatcomponent1, entityIn));
    }

    return ichatcomponent;
}
项目:BaseClient    文件:ChatComponentProcessor.java   
public static IChatComponent processComponent(ICommandSender commandSender, IChatComponent component, Entity entityIn) throws CommandException
{
    IChatComponent ichatcomponent = null;

    if (component instanceof ChatComponentScore)
    {
        ChatComponentScore chatcomponentscore = (ChatComponentScore)component;
        String s = chatcomponentscore.getName();

        if (PlayerSelector.hasArguments(s))
        {
            List<Entity> list = PlayerSelector.<Entity>matchEntities(commandSender, s, Entity.class);

            if (list.size() != 1)
            {
                throw new EntityNotFoundException();
            }

            s = ((Entity)list.get(0)).getName();
        }

        ichatcomponent = entityIn != null && s.equals("*") ? new ChatComponentScore(entityIn.getName(), chatcomponentscore.getObjective()) : new ChatComponentScore(s, chatcomponentscore.getObjective());
        ((ChatComponentScore)ichatcomponent).setValue(chatcomponentscore.getUnformattedTextForChat());
    }
    else if (component instanceof ChatComponentSelector)
    {
        String s1 = ((ChatComponentSelector)component).getSelector();
        ichatcomponent = PlayerSelector.matchEntitiesToChatComponent(commandSender, s1);

        if (ichatcomponent == null)
        {
            ichatcomponent = new ChatComponentText("");
        }
    }
    else if (component instanceof ChatComponentText)
    {
        ichatcomponent = new ChatComponentText(((ChatComponentText)component).getChatComponentText_TextValue());
    }
    else
    {
        if (!(component instanceof ChatComponentTranslation))
        {
            return component;
        }

        Object[] aobject = ((ChatComponentTranslation)component).getFormatArgs();

        for (int i = 0; i < aobject.length; ++i)
        {
            Object object = aobject[i];

            if (object instanceof IChatComponent)
            {
                aobject[i] = processComponent(commandSender, (IChatComponent)object, entityIn);
            }
        }

        ichatcomponent = new ChatComponentTranslation(((ChatComponentTranslation)component).getKey(), aobject);
    }

    ChatStyle chatstyle = component.getChatStyle();

    if (chatstyle != null)
    {
        ichatcomponent.setChatStyle(chatstyle.createShallowCopy());
    }

    for (IChatComponent ichatcomponent1 : component.getSiblings())
    {
        ichatcomponent.appendSibling(processComponent(commandSender, ichatcomponent1, entityIn));
    }

    return ichatcomponent;
}
项目:RuneCraftery    文件:CommandHandler.java   
public int func_71556_a(ICommandSender p_71556_1_, String p_71556_2_) {
   p_71556_2_ = p_71556_2_.trim();
   if(p_71556_2_.startsWith("/")) {
      p_71556_2_ = p_71556_2_.substring(1);
   }

   String[] var3 = p_71556_2_.split(" ");
   String var4 = var3[0];
   var3 = func_71559_a(var3);
   ICommand var5 = (ICommand)this.field_71562_a.get(var4);
   int var6 = this.func_82370_a(var5, var3);
   int var7 = 0;

   try {
      if(var5 == null) {
         throw new CommandNotFoundException();
      }

      if(var5.func_71519_b(p_71556_1_)) {
         if(var6 > -1) {
            EntityPlayerMP[] var8 = PlayerSelector.func_82380_c(p_71556_1_, var3[var6]);
            String var9 = var3[var6];
            EntityPlayerMP[] var10 = var8;
            int var11 = var8.length;

            for(int var12 = 0; var12 < var11; ++var12) {
               EntityPlayerMP var13 = var10[var12];
               var3[var6] = var13.func_70023_ak();

               try {
                  var5.func_71515_b(p_71556_1_, var3);
                  ++var7;
               } catch (CommandException var15) {
                  p_71556_1_.func_70006_a(ChatMessageComponent.func_111082_b(var15.getMessage(), var15.func_74844_a()).func_111059_a(EnumChatFormatting.RED));
               }
            }

            var3[var6] = var9;
         } else {
            var5.func_71515_b(p_71556_1_, var3);
            ++var7;
         }
      } else {
         p_71556_1_.func_70006_a(ChatMessageComponent.func_111077_e("commands.generic.permission").func_111059_a(EnumChatFormatting.RED));
      }
   } catch (WrongUsageException var16) {
      p_71556_1_.func_70006_a(ChatMessageComponent.func_111082_b("commands.generic.usage", new Object[]{ChatMessageComponent.func_111082_b(var16.getMessage(), var16.func_74844_a())}).func_111059_a(EnumChatFormatting.RED));
   } catch (CommandException var17) {
      p_71556_1_.func_70006_a(ChatMessageComponent.func_111082_b(var17.getMessage(), var17.func_74844_a()).func_111059_a(EnumChatFormatting.RED));
   } catch (Throwable var18) {
      p_71556_1_.func_70006_a(ChatMessageComponent.func_111077_e("commands.generic.exception").func_111059_a(EnumChatFormatting.RED));
      var18.printStackTrace();
   }

   return var7;
}
项目:RuneCraftery    文件:CommandSpreadPlayers.java   
public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
   if(p_71515_2_.length < 6) {
      throw new WrongUsageException("commands.spreadplayers.usage", new Object[0]);
   } else {
      byte var3 = 0;
      int var17 = var3 + 1;
      double var4 = func_110666_a(p_71515_1_, Double.NaN, p_71515_2_[var3]);
      double var6 = func_110666_a(p_71515_1_, Double.NaN, p_71515_2_[var17++]);
      double var8 = func_110664_a(p_71515_1_, p_71515_2_[var17++], 0.0D);
      double var10 = func_110664_a(p_71515_1_, p_71515_2_[var17++], var8 + 1.0D);
      boolean var12 = func_110662_c(p_71515_1_, p_71515_2_[var17++]);
      ArrayList var13 = Lists.newArrayList();

      while(true) {
         while(var17 < p_71515_2_.length) {
            String var14 = p_71515_2_[var17++];
            if(PlayerSelector.func_82378_b(var14)) {
               EntityPlayerMP[] var18 = PlayerSelector.func_82380_c(p_71515_1_, var14);
               if(var18 == null || var18.length == 0) {
                  throw new PlayerNotFoundException();
               }

               Collections.addAll(var13, var18);
            } else {
               EntityPlayerMP var15 = MinecraftServer.func_71276_C().func_71203_ab().func_72361_f(var14);
               if(var15 == null) {
                  throw new PlayerNotFoundException();
               }

               var13.add(var15);
            }
         }

         if(var13.isEmpty()) {
            throw new PlayerNotFoundException();
         }

         p_71515_1_.func_70006_a(ChatMessageComponent.func_111082_b("commands.spreadplayers.spreading." + (var12?"teams":"players"), new Object[]{func_110663_b(var13), Double.valueOf(var4), Double.valueOf(var6), Double.valueOf(var8), Double.valueOf(var10)}));
         this.func_110669_a(p_71515_1_, var13, new CommandSpreadPlayersPosition(var4, var6), var8, var10, ((EntityLivingBase)var13.get(0)).field_70170_p, var12);
         return;
      }
   }
}