Java: Minecraft plugin code error?

Za
- in Plugins
10

I have now written a small clear chat plugin for my Bukkit server. But it doesn't work. When I write / clearchat on my server (1.15.2), the string from the plugin.yml file is always displayed under usage:. What is wrong? Here is the code:

package package1;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.plugin.java.JavaPlugin;

import com.mojang.brigadier.Command;

public class main class extends JavaPlugin {
private string pluginName = this.getDescription (). GetName ();
private string pluginVers = this.getDescription (). GetVersion ();
private int timer = 100;

@Override
public void onEnable () {
System.out.println ("");
System.out.println ("[" + pluginName + "] §aPlugin started! Version:" + pluginVers);
System.out.println ("");
}

@Override
public void onDisable () {
System.out.println ("");
System.out.println ("[" + pluginName + "] §aPlugin switched off! Version:" + pluginVers);
System.out.println ("");
}

@SuppressWarnings ("rawtypes")
public boolean onCommand (CommandSender sender, Command cmd, String label, String [] args) {

Player player = null;
if (sender instanceof Player) {
player = (player) transmitter;
}

if CommandSender) cmd) .getName (). EqualsIgnoreCase ("clearchat")) {
if (sender.hasPermission ("system.clearchat")) {
while (timer> 0) {
timer--;
Bukkit.broadcastMessage ("\ n");
}
Bukkit.broadcastMessage ("§9 [Server] §cThe chat was emptied by" + sender + ".");
timer = 100;
return true;
} else {
player.sendMessage ("§9 [Server] §cYou may not.");
}
}

return false;

}
}

Em

That doesn't solve your problem, but how about a for loop instead of your weird while?

Za

So you have no solution?

Em

No

cl

@SuppressWarnings ({"rawtypes", "unused"})

How about getting to the bottom of this and taking the warnings seriously? Are you overriding the method properly? (@Override)

St

Player player = null;
if (sender instanceof Player) {
player = (player) transmitter;
}

That doesn't cause the error, but it doesn't make much sense either. You should send a message if sender is not a player and then exit the method.

if CommandSender) cmd) .getName (). EqualsIgnoreCase ("clearchat")) {

Obviously, that can't work. Cmd is not a CommandSender, just leave out the cast.

It would probably also be helpful to learn Java first and then write plugins with it.

St

@Override is just a marker annotation with no functionality. Overriding methods works the same way.

cl

S a c h g e m

In other words, he is sure that his method signature is correct - he could easily check this with @Override.

St
Ra

Why are you answering here

Em

Can't I?

Script Error Message? Sh Shockbakery71