Files
BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/commands/CommandBloodMagic.java
T
Abdiel KavashandMartin Robertz ff2f889c76 Ritual of Gaia's Transformation fixes. (#49)
* Added server->client notification of biome change.

* Fix floating point inaccuracy.

* Replaced inefficient search algorithm.

* Move structure initialization out of a loop. Oops.

* update bs+deps+gardle

* fix wci

* one more

* Always send full 32 bytes with every message.

---------

Co-authored-by: Martin Robertz <[email protected]>
2024-01-21 20:30:57 +01:00

81 lines
2.7 KiB
Java

package WayofTime.alchemicalWizardry.common.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import WayofTime.alchemicalWizardry.api.command.ISubCommand;
import WayofTime.alchemicalWizardry.common.commands.sub.SubCommandBind;
import WayofTime.alchemicalWizardry.common.commands.sub.SubCommandHelp;
import WayofTime.alchemicalWizardry.common.commands.sub.SubCommandNetwork;
import WayofTime.alchemicalWizardry.common.commands.sub.SubCommandOrb;
public class CommandBloodMagic extends CommandBase {
private final List aliases = new ArrayList();
private final Map<String, ISubCommand> subCommands = new HashMap<String, ISubCommand>();
@SuppressWarnings("unchecked")
public CommandBloodMagic() {
aliases.add("BloodMagic");
aliases.add("bloodmagic");
aliases.add("bloodMagic");
aliases.add("bm");
subCommands.put("help", new SubCommandHelp(this));
subCommands.put("network", new SubCommandNetwork(this));
subCommands.put("bind", new SubCommandBind(this));
subCommands.put("orb", new SubCommandOrb(this));
}
@Override
public String getCommandName() {
return "/bloodmagic";
}
@Override
public int getRequiredPermissionLevel() {
return 3;
}
@Override
public String getCommandUsage(ICommandSender commandSender) {
return getCommandName() + " help";
}
@Override
public List getCommandAliases() {
return aliases;
}
@Override
public void processCommand(ICommandSender commandSender, String[] args) {
if (args.length > 0 && subCommands.containsKey(args[0])) {
ISubCommand subCommand = subCommands.get(args[0]);
String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
if (subCommand.canSenderUseSubCommand(commandSender)) subCommand.processSubCommand(commandSender, subArgs);
else commandSender.addChatMessage(
new ChatComponentTranslation("commands.error.perm")
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
} else {
commandSender.addChatMessage(
new ChatComponentTranslation("commands.error.unknown")
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
}
}
public Map<String, ISubCommand> getSubCommands() {
return subCommands;
}
}