[DYNMAP]Get message console

Bonjour, j’aimerais récupérer ce que retourne la commande /dmarker list dans la console
La commande est envoyé comme ça:

CommandResult command = Sponge.getGame().getCommandManager().process(Sponge.getGame().getServer().getConsole(), "dmarker list");

Mais je récupère rien du tour:

Sponge.getLogger().info("" + command.toString());

Est ce qu’il y a une autre façon ?

Google trad:
Hello, I would like to recover that returns control ** / ** dmarker list in the Console
The command is sent like this:

CommandResult command = Sponge.getGame().getCommandManager().process(Sponge.getGame().getServer().getConsole(), "dmarker list");

But I get nothing at all:

Sponge.getLogger().info("" + command.toString());

Is what there another way ?

Alright I don’t know I I completely understand what you mean, but I’ll try.

So I assume you want to execute the command named “dmarker” with the arguments list.
What you first need to do is to get the CommandCallable for the command “dmarker”. After that you can process that command with the arguments you want.

It would look something like this

CommandSource server = Sponge.getServer().getConsole();
Optional<? extends CommandMapping> optMapping = Sponge.getCommandManager().get("dmarker", server);
optMapping.ifPresent(m -> {
   try {
      LogHelper.info(m.getCallable().process(server, "list"));
   }
   catch(CommandException e) {
      e.printStackTrace();
   }
});

PS: No I did not check that this works. I just woke up so I can’t be bothered to.

In fact he want to get the result of the command by getting a handle to the console to copy the content of the call

ricky30 => Yes! C’est ce que je veux faire

mais je n’ai pas l’impression que ça soit possible. :slight_smile: je suis français.

but i don’t think we can do it.

J’ai plus qu’a réussi à lire le fichier yml de dynmap alors. On peut ?
moi aussi je suis fr^^

Google trad:
I have more that was able to read the xml file then DYNMAP

il y a peut être (même probablement) moyen de lire un fichier quelconque mais je ne sais pas (encore) comment. Sinon je vais essayer de tester une idée, voir si ça donne quelque chose.

Ok. Si Sponge peut lire les config yml, je pourrais passer par ça ?

Je ne pense pas, c’est proche des fichiers config mais pas identique, essai plutôt ça: yaml beans ou un équivalent.

If the command writes it back to the CommandSource instead of to the console, you could call the command with a custom commandSource to receive messages sent to it.

Otherwise depending on what you need to do, you could ask for the plugin to implement/extend CommandResult better, with more information on what happened.

Finalement, j’utilise directement le fichier de config, c’est plus simple pour moi vu que j’ai pas trouvé comment faire autrement:

Google trad:
Finally, I use the config file directly, it is easier for me because I have not found how to do otherwise:

        File fileyml = new File("dynmap/markers.yml");    
        ConfigurationLoader<ConfigurationNode> yamlReader = YAMLConfigurationLoader.builder().setFile(fileyml).build();
        ConfigurationNode bukkitConfig = null;
        try {
            bukkitConfig = yamlReader.load();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        Sponge.getLogger().info("-----");
        for(Entry<Object, ? extends ConfigurationNode> markers : bukkitConfig.getNode("sets", "markers", "markers").getChildrenMap().entrySet()) {
            String key = (String) markers.getKey();
            
            String world = bukkitConfig.getNode("sets", "markers", "markers", key, "world").getValue().toString();
            String icon = bukkitConfig.getNode("sets", "markers", "markers", key, "icon").getValue().toString();
            String label = bukkitConfig.getNode("sets", "markers", "markers", key, "label").getValue().toString();
            
            String x = bukkitConfig.getNode("sets", "markers", "markers", key, "x").getValue().toString();
            String y = bukkitConfig.getNode("sets", "markers", "markers", key, "y").getValue().toString();
            String z = bukkitConfig.getNode("sets", "markers", "markers", key, "z").getValue().toString();
            
            Sponge.getLogger().info("" + key + " world:" + world + " " + x + " " + y + " " + z + " " + icon + " " + label);
        }