Refactor debug command

This commit is contained in:
GeorgH93 2023-12-13 15:21:33 +01:00
parent 032f22a3df
commit 222e122eda
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
1 changed files with 47 additions and 40 deletions

View File

@ -70,7 +70,7 @@ public class DebugCommand extends MinepacksCommand
builder = new MessageBuilder("All data has been collected!", MessageColor.GREEN, MessageFormat.BOLD).appendNewLine();
builder.append("You can now interact with your game again.").appendNewLine();
builder.append("The collected data can be found in your plugins directory inside the 'debug.txt' file.").appendNewLine();
builder.append("Please upload this fiel to ");
builder.append("Please upload this file to ");
builder.append("https://pastebin.com/", MessageColor.YELLOW, MessageFormat.UNDERLINE).onClick(MessageClickEvent.ClickEventAction.OPEN_URL, "https://pastebin.com/");
builder.append(" and send the link to the developer.");
messageDone = builder.getMessage();
@ -157,10 +157,20 @@ public class DebugCommand extends MinepacksCommand
}
else if (args.length == 2 && args[0].equals("size"))
{
Player player = Bukkit.getServer().getPlayer(args[1]);
executeSize(commandSender, args[1]);
}
else
{
debugSystem(commandSender);
}
}
void executeSize(final @NotNull CommandSender commandSender, final @NotNull String playerName)
{
Player player = Bukkit.getServer().getPlayer(playerName);
if (player == null)
{
commandSender.sendMessage("Player " + args[1] + " is offline.");
commandSender.sendMessage("Player " + playerName + " is offline.");
return;
}
Backpack bp = Minepacks.getInstance().getBackpackCachedOnly(player);
@ -177,9 +187,9 @@ public class DebugCommand extends MinepacksCommand
commandSender.sendMessage("Size: " + actualSize);
commandSender.sendMessage("Inventory Size: " + actualSizeInventory);
commandSender.sendMessage("Should be: " + sizeShouldBe);
if (bpSize != sizeShouldBe)
if (bpSize != sizeShouldBe && bp != null)
{
commandSender.sendMessage("Size missmatch detected, attempt resize ...");
commandSender.sendMessage("Size mismatch detected, attempt resize ...");
((at.pcgamingfreaks.Minepacks.Bukkit.Backpack) bp).checkResize();
if (bp.getSize() != sizeShouldBe)
{
@ -197,9 +207,6 @@ public class DebugCommand extends MinepacksCommand
commandSender.sendMessage("Player class: " + player.getClass().getName());
commandSender.sendMessage("###############################");
}
else
debugSystem(commandSender);
}
@Override
public List<String> tabComplete(@NotNull CommandSender commandSender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String[] args)