You are not logged in.

  • Login
Bitte besucht unser neues Forum unter https://forum.nitrado.net | Please visit our new Forum at https://forum.nitrado.net

Dear visitor, welcome to Nitrado.net Prepaid Gameserver Community-Support - Archiv. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

didi090302

User / Kunde

  • "didi090302" started this thread

Posts: 5

  • Send private message

1

Wednesday, May 30th 2018, 10:12pm

MySQL Reportsystem -Daten werden nicht in die Tabelle eingetragen

Hallo,
ich arbeite zurzeit an einem Reportsystem, dass Datenbank übergreifend ist und auf einer Website abgerufen werden kann.
Nun habe ich das Problem, dass beim Ausführen des Befehls eine ERROR-Meldung kommt und nichts in meine MySQL-Tabelle eingetragen wird. In meinen Augen ist das was ich programmiert habe richtig und müsste eigentlich funktionieren. Ich habe meinen Code und die ERROR-Meldung unten eingefügt, vielleicht wist ihr woran es liegt.

Mein Code:

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package de.didi090302.reportsystem.utils;

import de.didi090302.reportsystem.Main;
import de.didi090302.reportsystem.mysql.MySQL;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class Commands implements CommandExecutor {

    public static MySQL mysql;

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

        if(args.length >= 2) {
            if(Bukkit.getPlayer(args[0]) != null) {
                String reason ="";

                for(int i = 1; i<args.length; i++) {
                    reason = reason + args[i] + " ";
                }

                for(Player player : Bukkit.getOnlinePlayers()) {
                    if(player.hasPermission("report.notify")) {
                        player.sendMessage(Main.pr+"§3The player §6"+player.getName()+" §3reported the player §c"+args[0]);
                        player.sendMessage(Main.pr+"§cReason: §b"+reason);
                    }
                }

                mysql.update("INSERT INTO reports (reported_user, reporter_user, reason) VALUES ('"+args[0]+"','"+sender.getName()+"','"+reason+"')");
                sender.sendMessage(Main.pr+"§bYou're reported §c"+args[0]);


            } else {
                sender.sendMessage(Main.pr+"§aThis player is not online!");
            }
        } else {
            sender.sendMessage(Main.pr+"§c/report <PLAYER> <REASON>");
            sender.sendMessage(Main.pr+"§cPlease don't report a Player who did nothing!");
        }

        return true;
    }
}

ERROR-Meldung:

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
org.bukkit.command.CommandException: Unhandled exception executing command 'report' in plugin ReportSystem v1.0
    	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-a3b3a42]
    	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit.jar:git-Bukkit-a3b3a42]
    	at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:631) ~[craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1333) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1193) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
    	at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
    	at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:696) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:371) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:651) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:555) [craftbukkit.jar:git-Bukkit-a3b3a42]
    	at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: java.lang.NullPointerException
    	at de.didi090302.reportsystem.utils.Commands.onCommand(Commands.java:30) ~[?:?]
    	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-a3b3a42]
    	... 15 more

Mit freundlichen Grüßen
didi090302

xtrumb

User / Kunde

  • "xtrumb" is male

Posts: 2,295

Location: hier

Occupation: Fachinformatiker für Systemintegration

Thanks: 16

  • Send private message

2

Thursday, May 31st 2018, 8:28am

Bitte sende uns den Code und den passenden Fehlercode dazu
Mit freundlichen Grüßen
TrueMB

Dienstleistungs Service
Unser Csgo Team

didi090302

User / Kunde

  • "didi090302" started this thread

Posts: 5

  • Send private message

3

Thursday, May 31st 2018, 11:16am

Bitte sende uns den Code und den passenden Fehlercode dazu



Ich habe denn Code und die Fehlermeldung in die beiden Spoiler eingefügt. Oder meinst du etwas anderes?

Mit freundlichen Grüßen
didi090302

xtrumb

User / Kunde

  • "xtrumb" is male

Posts: 2,295

Location: hier

Occupation: Fachinformatiker für Systemintegration

Thanks: 16

  • Send private message

4

Thursday, May 31st 2018, 12:52pm

Laut Fehler bekommst du einen Nullpointer in der Zeile 30.

Im Code ist die Zeile 30 aber eine Klammer.
Mit freundlichen Grüßen
TrueMB

Dienstleistungs Service
Unser Csgo Team

Bitte besucht unser neues Forum unter https://forum.nitrado.net| Please visit our new Forum at https://forum.nitrado.net