use of com.bewitchment.common.core.capability.divination.CapabilityDivination in project Bewitchment by Um-Mitternacht.
the class CommandForceFortune method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length == 0)
throw new WrongUsageException("commands.set_fortune.usage");
if (sender instanceof EntityPlayer) {
CapabilityDivination dc = ((EntityPlayer) sender).getCapability(CapabilityDivination.CAPABILITY, null);
IFortune add = Fortune.REGISTRY.getValue(new ResourceLocation(args[0]));
if (add == null) {
throw new CommandException("commands.set_fortune.error.no_fortune");
}
dc.setFortune(add);
sender.sendMessage(new TextComponentTranslation("commands.set_fortune.success"));
} else {
throw new CommandException("commands.error.no_console");
}
}
Aggregations