Command Serveur
-
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 -
Ouai c’est ce que j’ai dit, Essentials modifie 80% des choses pour en faire n’importe quoi, essaie d’enlever ces plugins et voit si ça marche
-
@‘SCAREX’:
Ouai c’est ce que j’ai dit, Essentials modifie 80% des choses pour en faire n’importe quoi, essaie d’enlever ces plugins et voit si ça marche
J’ai essayé sa marche pas
-
Ou c’est juste les commandes de plugin ne fonctionnent pas.
Faudrait voir comment cauldron gère les commandes. Mais ça va être difficile sans les sources. -
@‘robin4002’:
Ou c’est juste les commandes de plugin ne fonctionnent pas.
Faudrait voir comment cauldron gère les commandes. Mais ça va être difficile sans les sources.Sinon il faudrai que je passe autre que le serveur, par le player mais le probleme c’est que pour executé la command les personne doit avoir la permission et j’ai pas trop envie surtout que c’est pas des petites commande