Command Serveur
-
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), message.text);
-
@‘robin4002’:
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), message.text);
Sa marche pas sa execute plus dans la consol
-
J’ai regardé au niveau du code de Minecraft, c’est exactement ce que le serveur fait lorsqu’on entre une commande depuis l’interface.
-
@‘robin4002’:
J’ai regardé au niveau du code de Minecraft, c’est exactement ce que le serveur fait lorsqu’on entre une commande depuis l’interface.
Alors je doit avoir un probleme quelle que part car la y a plus rien qui se passe
-
Si tu fais ça :
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), “say message de test”);
ça fonctionne ? -
@‘robin4002’:
Si tu fais ça :
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), “say message de test”);
ça fonctionne ?Sa marche pas non plus mais je remarquer que dans ma console maintenant sa me mais /help 2 fois
Edit:
Je pense que sa doit marher en faire sa me mais le /help car il va chercher sa
Main.message.sendToServer(new MyMessage(“/manuadd " + this.mc.getSession().getUsername() + " Druide”));
Main.message.sendToServer(new MyMessage(“/broadcast " + this.mc.getSession().getUsername() + " A choisi la classe Druide”));puis mais sa a la suite say message de test
Enfin je pense
-
J’ai pas tout comprit x)
-
@‘robin4002’:
J’ai pas tout comprit x)
Moi non plus je me comprend pas la dessus.
J’ai essayé se que tu ma donner sa ne marche pas non plus.
Mais dans la console du serveur quand j’appuie sur le bouton j’ai de /help qui s’affiche
-
Remets ça :
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), message.text);
Et retires les / de tes commandes. -
Darkvince si la console te dit commande inconnu c’est quel reçoit bien la commande mais qu’il ne la comprend pas, quand tu es sur ta console tu ne met pas le “/”
tu met juste “broadcast nanana” donc comme te le dit robin plus haut si tu enleve le “/” la console va comprendre “/broadcast nanana” et pas “//broadcast nanana” -
@‘robin4002’:
Remets ça :
MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), message.text);
Et retires les / de tes commandes.Déjà essayé sa marcher pas tu peut voir que sur le Paladin y a pas de / pour essayé des 2 façon
-
A la place de addChatMessage, essaie : player.sendChatMessage(“/taCommande”);
Dans le handler de ton packet… -
Son but est d’exécuter la commande directement côté serveur en temps que op.
Donc ce que tu proposes n’est pas bon.EDIT :
Le problème vient de ton côté, la fonction que je t’ai donné fait ce qu’il faut.

Code de test :package fr.minecraftforgefrance.test; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.MinecraftForge; @Mod(modid = "test", name = "Test") public class Main { @Instance("test") public static Main instance; public static SimpleNetworkWrapper network; @EventHandler public void init(FMLInitializationEvent event) { FMLCommonHandler.instance().bus().register(this); network = NetworkRegistry.INSTANCE.newSimpleChannel("test"); network.registerMessage(PaquetCommand.Handler.class, PaquetCommand.class, 0, Side.SERVER); } @SubscribeEvent @SideOnly(Side.CLIENT) public void onInput(InputEvent.KeyInputEvent event) { if(GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak)) { System.out.println("sneak !"); network.sendToServer(new PaquetCommand("tp " + Minecraft.getMinecraft().thePlayer.getCommandSenderName() + " 0 128 0")); } } public static class PaquetCommand implements IMessage { private String command; public PaquetCommand(String command) { this.command = command; } public PaquetCommand() { } @Override public void fromBytes(ByteBuf buf) { this.command = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, this.command); } public static class Handler implements IMessageHandler <paquetcommand, imessage="">{ @Override public IMessage onMessage(PaquetCommand message, MessageContext ctx) { MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), message.command); return null; } } } } ```</paquetcommand,> -
@‘robin4002’:
Son but est d’exécuter la commande directement côté serveur en temps que op.
Donc ce que tu proposes n’est pas bon.EDIT :
Le problème vient de ton côté, la fonction que je t’ai donné fait ce qu’il faut.

Code de test :package fr.minecraftforgefrance.test; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.MinecraftForge; @Mod(modid = "test", name = "Test") public class Main { @Instance("test") public static Main instance; public static SimpleNetworkWrapper network; @EventHandler public void init(FMLInitializationEvent event) { FMLCommonHandler.instance().bus().register(this); network = NetworkRegistry.INSTANCE.newSimpleChannel("test"); network.registerMessage(PaquetCommand.Handler.class, PaquetCommand.class, 0, Side.SERVER); } @SubscribeEvent @SideOnly(Side.CLIENT) public void onInput(InputEvent.KeyInputEvent event) { if(GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak)) { System.out.println("sneak !"); network.sendToServer(new PaquetCommand("tp " + Minecraft.getMinecraft().thePlayer.getCommandSenderName() + " 0 128 0")); } } public static class PaquetCommand implements IMessage { private String command; public PaquetCommand(String command) { this.command = command; } public PaquetCommand() { } @Override public void fromBytes(ByteBuf buf) { this.command = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, this.command); } public static class Handler implements IMessageHandler <paquetcommand, imessage="">{ @Override public IMessage onMessage(PaquetCommand message, MessageContext ctx) { MinecraftServer.getServer().getCommandManager().executeCommand(MinecraftServer.getServer(), message.command); return null; } } } } ```</paquetcommand,>Alors la je comprend pas j’ai fait pareil que toi exactement mais sa marche pas
[21:46:51] [Server thread/INFO]: Unknown command. Try /help for a list of commands [21:46:51] [Server thread/INFO]: Unknown command. Try /help for a list of commands -
Peut-être un bug de la 1.7.2 alors.
Je suis en 1.7.10. -
@‘robin4002’:
Peut-être un bug de la 1.7.2 alors.
Je suis en 1.7.10.Enfaite je code en 1.7.10 car plus fiable mais pour un serveur 1.7.2 sa peut venir de sa peut etre
-
System out se qui est écris dans la console et regarde vois a partir de ça

-
Oui j’ai bien le message qui se mais les autre commands se mais en /help
-
Peut être tu as un mod ou un plugin qui modifie cette commande, non ?
-
@‘SCAREX’:
Peut être tu as un mod ou un plugin qui modifie cette commande, non ?
Je pense pas car en mods j’ai que lui et javafixer
et plugin j’ai que Faction, FactionPus, Essentials, World Edit/Guard et GroupManager