mirror of
https://github.com/plexusorg/Medina.git
synced 2024-11-22 13:54:59 +00:00
fix npes
This commit is contained in:
parent
49b1a18d43
commit
7fe69c305e
@ -17,13 +17,13 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@CommandParameters(name = "reports", usage = "/<command> <player> <list | details <id> | delete <id>>", description = "View existing reports on a player", permission = "medina.reports", source = RequiredCommandSource.ANY)
|
@CommandParameters(name = "reports", usage = "/<command> <player> <list | delete <id>>", description = "View existing reports on a player", permission = "medina.reports", source = RequiredCommandSource.ANY)
|
||||||
public class ReportsCommand extends MedinaCommand
|
public class ReportsCommand extends MedinaCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
@ -56,9 +56,18 @@ public class ReportsCommand extends MedinaCommand
|
|||||||
}
|
}
|
||||||
case "delete":
|
case "delete":
|
||||||
{
|
{
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
int id = parseInt(sender, args[2]);
|
int id = parseInt(sender, args[2]);
|
||||||
plugin.getSqlReports().getReports(id).whenComplete(((report, ex) ->
|
plugin.getSqlReports().getReports(id).whenComplete(((report, ex) ->
|
||||||
{
|
{
|
||||||
|
if (report == null)
|
||||||
|
{
|
||||||
|
send(sender, messageComponent("reportDoesntExist"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (report.isDeleted())
|
if (report.isDeleted())
|
||||||
{
|
{
|
||||||
send(sender, messageComponent("reportDoesntExist"));
|
send(sender, messageComponent("reportDoesntExist"));
|
||||||
|
Loading…
Reference in New Issue
Block a user