I want to try executing a command on a Minecraft server with the help of eclipse. That means that now I can only leaven with / bw leave the bed wars round but I would like to be able to leaven with / l. Do you have an idea how I can get the game / lw to execute the / bw leave command
Do you want to program that? Because you're talking about Eclipse. If so, I would be happy to send you the code that I would use. Oh yes: / l: Should the command send you to another server or just throw you out of the round?
/ l should throw you out of the round and to the lobby tpn. So what is now only with / bw leave. So it would be cool if you do something with / l / bw leave. If that works at all
OK. I'm still not sure if you want to program this, but here is the code that comes to mind so spontaneously:
Yes, that's exactly what I wanted to thank
Everything is recognized in eclipse but many error messages in the server console. And the command doesn't work in game
What errors are there?
Did you register the listener in the Main?
Is the plugin.yml correct?
The yml is correct
but I don't know exactly how to do the rest.
You could e.g. Build your class file like this:
public class ChatListener implements Listener {
private main main;
public ChatListener (Main main) {
this.main = main;
Bukkit.getPluginManager (). RegisterEvents (this, main);
}
@EventHandler
public void oncPE (PlayerCommandPreprocessEvent e) {
Player player = e.getPlayer ();
String message = e.getMessage ();
if (message.startsWith ( "/ l")) {
player.performCommand ("/ bw leave");
}
}
}
in your onEnable part of the Main then simply new ChatListener (this); enter.
And what do I have to write in the main class?
Well the standard stuff. An onEnable method, an onDisable method and just in the onEnable method of this new ChatListener (this);
Um… Can you maybe send me the code for that too?
that would be nice
Whew. Yes, but that's really standard stuff. You absolutely have to learn that - preferably before you sit down on heavier systems!
public class Main extends JavaPlugin {
public void onEnable () {
new ChatListener (this);
}
public void onDisable () {
Yes
now comes in main class all the time
"The constructor ChatListener (main) is undefined"
Then you imported the wrong main in your ChatListener class.
I let it now somehow it does not matter no matter what I do it is now no longer recognized at all * frustration *