Basic7x7
Basic7x7

Reputation: 31

CraftBukkit 1.8.8 - Is it possible to let the client send a message by himself?

I wanna make an anti-hack plugin, which should let the client write ".msg Test". So it would print "Test" and without a hackclient ".msg Test" (ikr, not with all hackclients but with a lot).

For this the client have to write the message by his own. It is possible to do this by sending the player a message and let the client sending this ".msg"-message when clicking on the text.

But is there a way to do this without an interaction of the player?

Upvotes: 1

Views: 448

Answers (2)

andrewgazelka
andrewgazelka

Reputation: 1816

Unfortunately, this is not possible through bukkit-api. The closest thing to this you can do is by using Server#dispatchCommand, but it will only execute the command if it is registered server-side. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#dispatchCommand(org.bukkit.command.CommandSender,%20java.lang.String)

However, if you feel up to using NMS (net.minecraft.server) code, then

CommandBlockListenerAbstract.executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command)

should work, as this is what I saw the implementation was for command signs in the 1.8.8 spigot-server (TileEntitySign.java line:181).

Upvotes: 1

Victor Olaitan
Victor Olaitan

Reputation: 79

This is possible my friend 😃

People tend to miss out the usefulness of the method

myPlayer.chat();

The method forces the player to put something in chat, and because both chat and commands go through the same stream, you can simply change a chat message to a command by prefixing with a '/'

myPlayer.chat("/msg test");

Would force the player to run the command 'msg' with arguments 'test'.

Upvotes: 2

Related Questions