• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Recupérer un Pseudo et un String dans une Commande

    Sans suite
    1.7.10
    4
    10
    1418
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      SanXyS last edited by

      Je cherche à récuprérer dans l’argument[1] un String et dans l’argument[2] un Joueur, comment faire ?

      Je vous montre ma classe

      
      @Override
      public void processCommand(ICommandSender sender, String[] arguments) {
      if (arguments.length <= 0)
      throw new WrongUsageException(this.getCommandUsage(sender));
      if (arguments[0].matches("add")) {
      
      }
      if (arguments[0].matches("remove")) {
      
      }
      if (arguments[0].matches("set")) {
      
      }
      
      }
      
      1 Reply Last reply Reply Quote 0
      • Deleted
        Deleted last edited by

        Salut, inspire toi du fonctionnement des commandes mc, qui requièrent elles aussi un pseudo.

        1 Reply Last reply Reply Quote 0
        • S
          SanXyS last edited by

          Les commandes MC ?

          1 Reply Last reply Reply Quote 0
          • Deleted
            Deleted last edited by

            Les commandes de base présentes dans MC

            1 Reply Last reply Reply Quote 0
            • S
              SanXyS last edited by

              Je regarde ça comment ? Avec MCP ?

              1 Reply Last reply Reply Quote 0
              • Deleted
                Deleted last edited by

                Non avec forge tu peux.

                1. Soit dans le jar de forge, dans “Referenced Librairies”, en bas de ton projet Java.
                2. Soit en orthographiant correctement, le nom de la classe, et en ctrl+clic gauche dessus.
                1 Reply Last reply Reply Quote 0
                • robin4002
                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

                  .equals pour comparer des string, .match c’est pour les regex.

                  1 Reply Last reply Reply Quote 1
                  • S
                    SanXyS last edited by

                    J’ai réussis à récupérer un String mais pour récupéré le joueur grace au string je ne trouve pas 😕 un ppeu d’aide ? S’il vous plait ?

                    1 Reply Last reply Reply Quote 0
                    • Deleted
                      Deleted last edited by

                      De l’aide ? Je pense que tu n’as pas suffisamment cherché comme la majorité des débutants en modding.
                      Voici la classe CommandGameMode:

                      
                      package net.minecraft.command;
                      
                      import java.util.List;
                      import net.minecraft.entity.player.EntityPlayerMP;
                      import net.minecraft.server.MinecraftServer;
                      import net.minecraft.util.ChatComponentTranslation;
                      import net.minecraft.world.WorldSettings;
                      
                      public class CommandGameMode extends CommandBase
                      {
                      private static final String __OBFID = "CL_00000448";
                      
                      public String getCommandName()
                      {
                      return "gamemode";
                      }
                      
                      /**
                      * Return the required permission level for this command.
                      */
                      public int getRequiredPermissionLevel()
                      {
                      return 2;
                      }
                      
                      public String getCommandUsage(ICommandSender p_71518_1_)
                      {
                      return "commands.gamemode.usage";
                      }
                      
                      public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_)
                      {
                      if (p_71515_2_.length > 0)
                      {
                      WorldSettings.GameType gametype = this.getGameModeFromCommand(p_71515_1_, p_71515_2_[0]);
                      EntityPlayerMP entityplayermp = p_71515_2_.length >= 2 ? getPlayer(p_71515_1_, p_71515_2_[1]) : getCommandSenderAsPlayer(p_71515_1_);
                      entityplayermp.setGameType(gametype);
                      entityplayermp.fallDistance = 0.0F;
                      ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("gameMode." + gametype.getName(), new Object[0]);
                      
                      if (entityplayermp != p_71515_1_)
                      {
                      func_152374_a(p_71515_1_, this, 1, "commands.gamemode.success.other", new Object[] {entityplayermp.getCommandSenderName(), chatcomponenttranslation});
                      }
                      else
                      {
                      func_152374_a(p_71515_1_, this, 1, "commands.gamemode.success.self", new Object[] {chatcomponenttranslation});
                      }
                      }
                      else
                      {
                      throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
                      }
                      }
                      
                      /**
                      * Gets the Game Mode specified in the command.
                      */
                      protected WorldSettings.GameType getGameModeFromCommand(ICommandSender p_71539_1_, String p_71539_2_)
                      {
                      return !p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.SURVIVAL.getName()) && !p_71539_2_.equalsIgnoreCase("s") ? (!p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.CREATIVE.getName()) && !p_71539_2_.equalsIgnoreCase("c") ? (!p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.ADVENTURE.getName()) && !p_71539_2_.equalsIgnoreCase("a") ? WorldSettings.getGameTypeById(parseIntBounded(p_71539_1_, p_71539_2_, 0, WorldSettings.GameType.values().length - 2)) : WorldSettings.GameType.ADVENTURE) : WorldSettings.GameType.CREATIVE) : WorldSettings.GameType.SURVIVAL;
                      }
                      
                      /**
                      * Adds the strings available in this command to the given list of tab completion options.
                      */
                      public List addTabCompletionOptions(ICommandSender p_71516_1_, String[] p_71516_2_)
                      {
                      return p_71516_2_.length == 1 ? getListOfStringsMatchingLastWord(p_71516_2_, new String[] {"survival", "creative", "adventure"}): (p_71516_2_.length == 2 ? getListOfStringsMatchingLastWord(p_71516_2_, this.getListOfPlayerUsernames()) : null);
                      }
                      
                      /**
                      * Returns String array containing all player usernames in the server.
                      */
                      protected String[] getListOfPlayerUsernames()
                      {
                      return MinecraftServer.getServer().getAllUsernames();
                      }
                      
                      /**
                      * Return whether the specified command parameter index is a username parameter.
                      */
                      public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_)
                      {
                      return p_82358_2_ == 1;
                      }
                      }
                      
                      

                      Dis moi ce qui te bloque et ce qui t’empêche de trouver la ligne permettant d’instancier un joueur en fonction de son pseudo, rentré en argument dans ta commande ?

                      1 Reply Last reply Reply Quote 0
                      • Joelchasseu
                        Joelchasseu last edited by

                        Bon je pense qu’il ne reviendras pas mais je donne quand même une réponse si des gens cherchent la réponse.
                        En 1.7.10 on utilise cette méthode pour récupérer un EntityPlayerMP à partir d’une String.

                        FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().func_152612_a(**PSEUDO**)
                        
                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Design by Woryk
                        Contact / Mentions Légales

                        MINECRAFT FORGE FRANCE © 2018

                        Powered by NodeBB