Skip to content

Commit

Permalink
[1.10.10]修复命令导致StackOverflowError的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Sep 13, 2024
1 parent 8282e13 commit 7be769c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import java.text.SimpleDateFormat
version = "1.10.9"
version = "1.10.10"

plugins {
`java-library`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ private ItemCommand() {
regSub(SaveItemCommand.INSTANCE).regSub(GiveItemCommand.INSTANCE).regSub(FuelCommand.INSTANCE);
}



@Override
public boolean execute(CommandSender sender, List<String> args) {
if (args.isEmpty()) {
sendNotEnoughCmdParamMsg(sender, 2);
return true;
}
return super.onCommand(sender, args);
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.github.yufiriamazenta.craftorithm.cmd.sub.item.fuel;

import com.github.yufiriamazenta.craftorithm.cmd.sub.AbstractSubCommand;
import crypticlib.command.SubcommandHandler;
import crypticlib.command.annotation.Subcommand;

public class FuelCommand extends AbstractSubCommand {

public static final FuelCommand INSTANCE = new FuelCommand();

protected FuelCommand() {
super("fuel", "craftorithm.command.item.fuel");
regSub(AddFuelCommand.INSTANCE).regSub(RemoveFuelCommand.INSTANCE);
}

@Subcommand
SubcommandHandler add = AddFuelCommand.INSTANCE;

@Subcommand
SubcommandHandler remove = RemoveFuelCommand.INSTANCE;

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.yufiriamazenta.craftorithm.menu.display.RecipeListMenu;
import com.github.yufiriamazenta.craftorithm.recipe.RecipeManager;
import crypticlib.command.SubcommandHandler;
import crypticlib.command.annotation.Subcommand;
import crypticlib.perm.PermInfo;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand All @@ -21,32 +22,32 @@ public final class RecipeListCommand extends AbstractSubCommand {

private RecipeListCommand() {
super("list", "craftorithm.command.list");
regSub(new SubcommandHandler(SERVER) {
@Override
public boolean execute(CommandSender sender, List<String> args) {
new RecipeListMenu((Player) sender, RecipeManager.INSTANCE.serverRecipesCache().keySet()).openMenu();
return true;
}
}.setPermission(new PermInfo("craftorithm.command.list.server")));
regSub(
new SubcommandHandler(CRAFTORITHM) {
@Override
public boolean execute(CommandSender sender, List<String> args) {
new RecipeGroupListMenu((Player) sender).openMenu();
return true;
}
}.setPermission("craftorithm.command.list"));
}

@Subcommand
SubcommandHandler server = new SubcommandHandler(SERVER, new PermInfo("craftorithm.command.list.server")) {
@Override
public boolean execute(CommandSender sender, List<String> args) {
new RecipeListMenu((Player) sender, RecipeManager.INSTANCE.serverRecipesCache().keySet()).openMenu();
return true;
}
};

@Subcommand
SubcommandHandler craftorithm = new SubcommandHandler(CRAFTORITHM, new PermInfo("craftorithm.command.list")) {
@Override
public boolean execute(CommandSender sender, List<String> args) {
new RecipeGroupListMenu((Player) sender).openMenu();
return true;
}
};

@Override
public boolean execute(CommandSender sender, List<String> args) {
if (!checkSenderIsPlayer(sender)) {
return true;
}
if (args.isEmpty()) {
args = new ArrayList<>(Collections.singletonList(CRAFTORITHM));
}
return super.onCommand(sender, args);
return craftorithm.execute(sender, args);
}

}

0 comments on commit 7be769c

Please sign in to comment.